Changes in / [5898ef8:c121f89]


Ignore:
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r5898ef8 rc121f89  
    228228                irc->w_watch_source_id = 0;
    229229               
    230                 if( irc->status & USTATUS_SHUTDOWN )
     230                if( irc->status == USTATUS_SHUTDOWN )
    231231                        irc_free( irc );
    232232               
  • ipc.c

    r5898ef8 rc121f89  
    115115static void ipc_child_cmd_wallops( irc_t *irc, char **cmd )
    116116{
    117         if( !( irc->status & USTATUS_LOGGED_IN ) )
     117        if( irc->status < USTATUS_LOGGED_IN )
    118118                return;
    119119       
     
    124124static void ipc_child_cmd_lilo( irc_t *irc, char **cmd )
    125125{
    126         if( !( irc->status & USTATUS_LOGGED_IN ) )
     126        if( irc->status < USTATUS_LOGGED_IN )
    127127                return;
    128128       
     
    133133static void ipc_child_cmd_opermsg( irc_t *irc, char **cmd )
    134134{
    135         if( !( irc->status & USTATUS_LOGGED_IN ) )
     135        if( irc->status < USTATUS_LOGGED_IN )
    136136                return;
    137137       
     
    154154static void ipc_child_cmd_kill( irc_t *irc, char **cmd )
    155155{
    156         if( !( irc->status & USTATUS_LOGGED_IN ) )
     156        if( irc->status < USTATUS_LOGGED_IN )
    157157                return;
    158158       
     
    166166static void ipc_child_cmd_hello( irc_t *irc, char **cmd )
    167167{
    168         if( !( irc->status & USTATUS_LOGGED_IN ) )
     168        if( irc->status < USTATUS_LOGGED_IN )
    169169                ipc_to_master_str( "HELLO\r\n" );
    170170        else
  • irc.c

    r5898ef8 rc121f89  
    177177        }
    178178       
    179         irc->status |= USTATUS_SHUTDOWN;
     179        irc->status = USTATUS_SHUTDOWN;
    180180        if( irc->sendbuffer && !immed )
    181181        {
     
    211211        log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
    212212       
    213         if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )
     213        if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )
    214214                if( storage_save( irc, TRUE ) != STORAGE_OK )
    215215                        irc_usermsg( irc, "Error while saving settings!" );
     
    577577               
    578578        /* Don't try to write anything new anymore when shutting down. */
    579         if( irc->status & USTATUS_SHUTDOWN )
     579        if( irc->status == USTATUS_SHUTDOWN )
    580580                return;
    581581       
     
    707707        if( irc->user && irc->nick )
    708708        {
    709                 if( global.conf->authmode == AUTHMODE_CLOSED && !( irc->status & USTATUS_AUTHORIZED ) )
     709                if( global.conf->authmode == AUTHMODE_CLOSED && irc->status < USTATUS_AUTHORIZED )
    710710                {
    711711                        irc_reply( irc, 464, ":This server is password-protected." );
     
    764764                ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname );
    765765       
    766         irc->status |= USTATUS_LOGGED_IN;
     766        irc->status = USTATUS_LOGGED_IN;
    767767}
    768768
     
    11871187        int rv = 0;
    11881188       
    1189         if( !( irc->status & USTATUS_LOGGED_IN ) )
     1189        if( irc->status < USTATUS_LOGGED_IN )
    11901190        {
    11911191                if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) )
  • irc.h

    r5898ef8 rc121f89  
    4242{
    4343        USTATUS_OFFLINE = 0,
    44         USTATUS_AUTHORIZED = 1,
    45         USTATUS_LOGGED_IN = 2,
    46         USTATUS_IDENTIFIED = 4,
    47         USTATUS_SHUTDOWN = 8
     44        USTATUS_AUTHORIZED,
     45        USTATUS_LOGGED_IN,
     46        USTATUS_IDENTIFIED,
     47        USTATUS_SHUTDOWN = -1
    4848} irc_status_t;
    4949
  • irc_commands.c

    r5898ef8 rc121f89  
    3232        if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 )
    3333        {
    34                 irc->status |= USTATUS_AUTHORIZED;
     34                irc->status = USTATUS_AUTHORIZED;
    3535                irc_check_login( irc );
    3636        }
     
    610610                        for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --;
    611611                       
    612                         if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN )
     612                        if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN )
    613613                        {
    614614                                irc_reply( irc, 462, ":Only allowed before logging in" );
    615615                        }
    616                         else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ) )
     616                        else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN )
    617617                        {
    618618                                irc_reply( irc, 451, ":Register first" );
  • protocols/msn/msn.c

    r5898ef8 rc121f89  
    6464        GSList *l;
    6565       
    66         if( md )
    67         {
    68                 if( md->fd >= 0 )
    69                         closesocket( md->fd );
    70                
    71                 if( md->handler )
    72                 {
    73                         if( md->handler->rxq ) g_free( md->handler->rxq );
    74                         if( md->handler->cmd_text ) g_free( md->handler->cmd_text );
    75                         g_free( md->handler );
    76                 }
    77                
    78                 while( md->switchboards )
    79                         msn_sb_destroy( md->switchboards->data );
    80                
    81                 if( md->msgq )
    82                 {
    83                         struct msn_message *m;
    84                        
    85                         for( l = md->msgq; l; l = l->next )
    86                         {
    87                                 m = l->data;
    88                        
    89                                 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
    90                                 g_free( m->who );
    91                                 g_free( m->text );
    92                                 g_free( m );
    93                         }
    94                         g_slist_free( md->msgq );
    95                 }
    96                
    97                 g_free( md );
     66        if( md->fd >= 0 )
     67                closesocket( md->fd );
     68       
     69        if( md->handler )
     70        {
     71                if( md->handler->rxq ) g_free( md->handler->rxq );
     72                if( md->handler->cmd_text ) g_free( md->handler->cmd_text );
     73                g_free( md->handler );
     74        }
     75       
     76        while( md->switchboards )
     77                msn_sb_destroy( md->switchboards->data );
     78       
     79        if( md->msgq )
     80        {
     81                struct msn_message *m;
     82               
     83                for( l = md->msgq; l; l = l->next )
     84                {
     85                        m = l->data;
     86               
     87                        serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
     88                        g_free( m->who );
     89                        g_free( m->text );
     90                        g_free( m );
     91                }
     92                g_slist_free( md->msgq );
    9893        }
    9994       
     
    105100                g_free( l->data );
    106101        g_slist_free( gc->deny );
     102       
     103        g_free( md );
    107104       
    108105        msn_connections = g_slist_remove( msn_connections, gc );
  • root_commands.c

    r5898ef8 rc121f89  
    164164                       
    165165                case STORAGE_OK:
    166                         irc->status |= USTATUS_IDENTIFIED;
     166                        irc->status = USTATUS_IDENTIFIED;
    167167                        irc_umode_set( irc, "+R", 1 );
    168168                        break;
     
    188188        case STORAGE_OK:
    189189                irc_setpass( irc, NULL );
    190                 irc->status &= ~USTATUS_IDENTIFIED;
     190                irc->status = USTATUS_LOGGED_IN;
    191191                irc_umode_set( irc, "-R", 1 );
    192192                irc_usermsg( irc, "Account `%s' removed", irc->nick );
     
    202202        account_t *a;
    203203       
    204         if( global.conf->authmode == AUTHMODE_REGISTERED && !( irc->status & USTATUS_IDENTIFIED ) )
     204        if( global.conf->authmode == AUTHMODE_REGISTERED && irc->status < USTATUS_IDENTIFIED )
    205205        {
    206206                irc_usermsg( irc, "This server only accepts registered users" );
  • storage_text.c

    r5898ef8 rc121f89  
    7171        user_t *ru = user_find( irc, ROOT_NICK );
    7272       
    73         if( irc->status & USTATUS_IDENTIFIED )
     73        if( irc->status >= USTATUS_IDENTIFIED )
    7474                return( 1 );
    7575       
     
    8888        /* Do this now. If the user runs with AuthMode = Registered, the
    8989           account command will not work otherwise. */
    90         irc->status |= USTATUS_IDENTIFIED;
     90        irc->status = USTATUS_IDENTIFIED;
    9191       
    9292        while( fscanf( fp, "%511[^\n]s", s ) > 0 )
  • storage_xml.c

    r5898ef8 rc121f89  
    169169static void xml_end_element( GMarkupParseContext *ctx, const gchar *element_name, gpointer data, GError **error )
    170170{
    171         struct xml_parsedata *xd = data;
    172         // irc_t *irc = xd->irc;
    173        
    174         if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting )
    175         {
    176                 g_free( xd->current_setting );
    177                 xd->current_setting = NULL;
    178         }
    179         else if( g_strcasecmp( element_name, "account" ) == 0 )
    180         {
    181                 xd->current_account = NULL;
    182         }
    183171}
    184172
     
    200188                xd->current_setting = NULL;
    201189        }
     190}
     191
     192static void xml_error( GMarkupParseContext *ctx, GError *error, gpointer data )
     193{
    202194}
    203195
     
    208200        xml_text,
    209201        NULL,
    210         NULL
     202        xml_error
    211203};
    212204
     
    227219        int fd, st;
    228220       
    229         if( irc->status & USTATUS_IDENTIFIED )
     221        if( irc->status >= USTATUS_IDENTIFIED )
    230222                return( 1 );
    231223       
     
    252244                {
    253245                        g_markup_parse_context_free( ctx );
    254                         close( fd );
    255                        
    256                         /* Slightly dirty... */
     246                       
     247                        /* TODO: Display useful error msg */
     248                       
    257249                        if( gerr && strcmp( gerr->message, XML_PASS_ERRORMSG ) == 0 )
    258250                                return STORAGE_INVALID_PASSWORD;
    259251                        else
    260                         {
    261                                 if( gerr )
    262                                         irc_usermsg( irc, "Error from XML-parser: %s", gerr->message );
    263                                
    264252                                return STORAGE_OTHER_ERROR;
    265                         }
    266253                }
    267254        }
    268255       
    269256        g_markup_parse_context_free( ctx );
    270         close( fd );
    271        
    272         irc->status |= USTATUS_IDENTIFIED;
     257       
     258        irc->status = USTATUS_IDENTIFIED;
    273259       
    274260        if( set_getint( irc, "auto_connect" ) )
     
    282268}
    283269
    284 static int xml_printf( int fd, char *fmt, ... )
    285 {
    286         va_list params;
    287         char *out;
    288         int len;
    289        
    290         va_start( params, fmt );
    291         out = g_markup_vprintf_escaped( fmt, params );
    292         va_end( params );
    293        
    294         len = strlen( out );
    295         len -= write( fd, out, len );
    296         g_free( out );
    297        
    298         return len == 0;
    299 }
    300 
    301270static storage_status_t xml_save( irc_t *irc, int overwrite )
    302271{
    303         char path[512], *path2;
    304         set_t *set;
    305         nick_t *nick;
    306         account_t *acc;
    307         int fd;
    308        
    309         g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, irc->nick, ".xml" );
    310        
    311         if( !overwrite && access( path, F_OK ) != -1 )
    312                 return STORAGE_ALREADY_EXISTS;
    313        
    314         strcat( path, "~" );
    315         if( ( fd = open( path, O_WRONLY | O_CREAT, 0600 ) ) < 0 )
    316         {
    317                 irc_usermsg( irc, "Error while opening configuration file." );
    318                 return STORAGE_OTHER_ERROR;
    319         }
    320        
    321         if( !xml_printf( fd, "<user nick=\"%s\" password=\"%s\">\n", irc->nick, irc->password ) )
    322                 goto write_error;
    323        
    324         for( set = irc->set; set; set = set->next )
    325                 if( set->value && set->def )
    326                         if( !xml_printf( fd, "\t<setting name=\"%s\">%s</setting>\n", set->key, set->value ) )
    327                                 goto write_error;
    328        
    329         for( acc = irc->accounts; acc; acc = acc->next )
    330         {
    331                 if( !xml_printf( fd, "\t<account protocol=\"%s\" handle=\"%s\" password=\"%s\" autoconnect=\"%s\"", acc->prpl->name, acc->user, acc->pass, "yes" ) )
    332                         goto write_error;
    333                 if( acc->server && acc->server[0] && !xml_printf( fd, " server=\"%s\"", acc->server ) )
    334                         goto write_error;
    335                 if( !xml_printf( fd, ">\n" ) )
    336                         goto write_error;
    337                
    338                 for( nick = irc->nicks; nick; nick = nick->next )
    339                         if( nick->proto == acc->prpl )
    340                                 if( !xml_printf( fd, "\t\t<buddy handle=\"%s\" nick=\"%s\" />\n", nick->handle, nick->nick ) )
    341                                         goto write_error;
    342                
    343                 if( !xml_printf( fd, "\t</account>\n" ) )
    344                         goto write_error;
    345         }
    346        
    347         if( !xml_printf( fd, "</user>\n" ) )
    348                 goto write_error;
    349        
    350         close( fd );
    351        
    352         path2 = g_strndup( path, strlen( path ) - 1 );
    353         if( rename( path, path2 ) != 0 )
    354         {
    355                 irc_usermsg( irc, "Error while renaming temporary configuration file." );
    356                
    357                 g_free( path2 );
    358                 unlink( path );
    359                
    360                 return STORAGE_OTHER_ERROR;
    361         }
    362        
    363         g_free( path2 );
    364        
     272/*      if (!overwrite) {
     273                g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
     274                if (access( path, F_OK ) != -1)
     275                        return STORAGE_ALREADY_EXISTS;
     276       
     277                g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
     278                if (access( path, F_OK ) != -1)
     279                        return STORAGE_ALREADY_EXISTS;
     280        }
     281*/     
    365282        return STORAGE_OK;
    366 
    367 write_error:
    368         irc_usermsg( irc, "Write error. Disk full?" );
    369         close( fd );
    370        
    371         return STORAGE_OTHER_ERROR;
    372283}
    373284
Note: See TracChangeset for help on using the changeset viewer.