Changeset bd69a21


Ignore:
Timestamp:
2005-12-15T12:24:25Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
4146a07
Parents:
2983f5e (diff), bf02a67 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge Wilmer

Files:
3 added
1 deleted
37 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r2983f5e rbd69a21  
    1717build-arch-stamp
    1818tags
     19decode
     20encode
  • Makefile

    r2983f5e rbd69a21  
    1010
    1111# Program variables
    12 objects = account.o bitlbee.o commands.o crypting.o help.o ini.o irc.o nick.o query.o set.o url.o user.o log.o
     12objects = account.o bitlbee.o commands.o crypting.o help.o ini.o irc.o log.o nick.o query.o set.o url.o user.o storage_text.o storage.o
    1313subdirs = protocols
    1414
  • account.c

    r2983f5e rbd69a21  
    124124        }
    125125       
    126         if (a->prpl == NULL )
    127         {
    128                 irc_usermsg( irc, "Support for protocol %s is not included in this BitlBee", a->prpl->name );
    129                 return;
    130         }
    131        
    132126        cancel_auto_reconnect( a );
    133127       
  • bitlbee.c

    r2983f5e rbd69a21  
    2727#include "bitlbee.h"
    2828#include "commands.h"
    29 #include "crypting.h"
    3029#include "protocols/nogaim.h"
    3130#include "help.h"
     
    159158                return FALSE;
    160159        }
    161                
     160       
     161        /* Very naughty, go read the RFCs! >:) */
     162        if( irc->readbuffer && ( strlen( irc->readbuffer ) > 1024 ) )
     163        {
     164                log_message( LOGLVL_ERROR, "Maximum line length exceeded." );
     165                irc_free( irc );
     166                return FALSE;
     167        }
     168       
    162169        return TRUE;
    163170}
     
    230237}
    231238
    232 /* DO NOT USE THIS FUNCTION IN NEW CODE. This
    233  * function is here merely because the save/load code still uses
    234  * ids rather then names */
    235 struct prpl *find_protocol_by_id(int id)
    236 {
    237         switch (id) {
    238         case 1: return find_protocol("oscar");
    239         case 4: return find_protocol("msn");
    240         case 2: return find_protocol("yahoo");
    241         case 8: return find_protocol("jabber");
    242         default: break;
    243         }
    244         return NULL;
    245 }
    246 
    247 int bitlbee_load( irc_t *irc, char* password )
    248 {
    249         char s[512];
    250         char *line;
    251         char proto[20];
    252         char nick[MAX_NICK_LENGTH+1];
    253         FILE *fp;
    254         user_t *ru = user_find( irc, ROOT_NICK );
    255        
    256         if( irc->status == USTATUS_IDENTIFIED )
    257                 return( 1 );
    258        
    259         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    260         fp = fopen( s, "r" );
    261         if( !fp ) return( 0 );
    262        
    263         fscanf( fp, "%32[^\n]s", s );
    264         if( setpass( irc, password, s ) < 0 )
    265         {
    266                 fclose( fp );
    267                 return( -1 );
    268         }
    269        
    270         /* Do this now. If the user runs with AuthMode = Registered, the
    271            account command will not work otherwise. */
    272         irc->status = USTATUS_IDENTIFIED;
    273        
    274         while( fscanf( fp, "%511[^\n]s", s ) > 0 )
    275         {
    276                 fgetc( fp );
    277                 line = deobfucrypt( irc, s );
    278                 root_command_string( irc, ru, line, 0 );
    279                 g_free( line );
    280         }
    281         fclose( fp );
    282        
    283         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
    284         fp = fopen( s, "r" );
    285         if( !fp ) return( 0 );
    286         while( fscanf( fp, "%s %s %s", s, proto, nick ) > 0 )
    287         {
    288                 struct prpl *prpl;
    289 
    290                 prpl = find_protocol(proto);
    291 
    292                 /* Older files saved the protocol number rather then the protocol name */
    293                 if (!prpl && atoi(proto)) {
    294                         prpl = find_protocol_by_id(atoi(proto));
    295                 }
    296 
    297                 if (!prpl)
    298                         continue;
    299 
    300                 http_decode( s );
    301                 nick_set( irc, s, prpl, nick );
    302         }
    303         fclose( fp );
    304        
    305         if( set_getint( irc, "auto_connect" ) )
    306         {
    307                 strcpy( s, "account on" );      /* Can't do this directly because r_c_s alters the string */
    308                 root_command_string( irc, ru, s, 0 );
    309         }
    310        
    311         return( 1 );
    312 }
    313 
    314 int bitlbee_save( irc_t *irc )
    315 {
    316         char s[512];
    317         char path[512], new_path[512];
    318         char *line;
    319         nick_t *n;
    320         set_t *set;
    321         mode_t ou = umask( 0077 );
    322         account_t *a;
    323         FILE *fp;
    324         char *hash;
    325        
    326         /*\
    327          *  [SH] Nothing should be saved if no password is set, because the
    328          *  password is not set if it was wrong, or if one is not identified
    329          *  yet. This means that a malicious user could easily overwrite
    330          *  files owned by someone else:
    331          *  a Bad Thing, methinks
    332         \*/
    333 
    334         /* [WVG] No? Really? */
    335 
    336         /*\
    337          *  [SH] Okay, okay, it wasn't really Wilmer who said that, it was
    338          *  me. I just thought it was funny.
    339         \*/
    340        
    341         hash = hashpass( irc );
    342         if( hash == NULL )
    343         {
    344                 irc_usermsg( irc, "Please register yourself if you want to save your settings." );
    345                 return( 0 );
    346         }
    347        
    348         g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks~" );
    349         fp = fopen( path, "w" );
    350         if( !fp ) return( 0 );
    351         for( n = irc->nicks; n; n = n->next )
    352         {
    353                 strcpy( s, n->handle );
    354                 s[169] = 0; /* Prevent any overflow (169 ~ 512 / 3) */
    355                 http_encode( s );
    356                 g_snprintf( s + strlen( s ), 510 - strlen( s ), " %s %s", n->proto->name, n->nick );
    357                 if( fprintf( fp, "%s\n", s ) != strlen( s ) + 1 )
    358                 {
    359                         irc_usermsg( irc, "fprintf() wrote too little. Disk full?" );
    360                         fclose( fp );
    361                         return( 0 );
    362                 }
    363         }
    364         if( fclose( fp ) != 0 )
    365         {
    366                 irc_usermsg( irc, "fclose() reported an error. Disk full?" );
    367                 return( 0 );
    368         }
    369  
    370         g_snprintf( new_path, 512, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
    371         if( unlink( new_path ) != 0 )
    372         {
    373                 if( errno != ENOENT )
    374                 {
    375                         irc_usermsg( irc, "Error while removing old .nicks file" );
    376                         return( 0 );
    377                 }
    378         }
    379         if( rename( path, new_path ) != 0 )
    380         {
    381                 irc_usermsg( irc, "Error while renaming new .nicks file" );
    382                 return( 0 );
    383         }
    384        
    385         g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts~" );
    386         fp = fopen( path, "w" );
    387         if( !fp ) return( 0 );
    388         if( fprintf( fp, "%s", hash ) != strlen( hash ) )
    389         {
    390                 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" );
    391                 fclose( fp );
    392                 return( 0 );
    393         }
    394         g_free( hash );
    395 
    396         for( a = irc->accounts; a; a = a->next )
    397         {
    398                 if( !strcmp( a->prpl->name, "oscar" ) )
    399                         g_snprintf( s, sizeof( s ), "account add oscar \"%s\" \"%s\" %s", a->user, a->pass, a->server );
    400                 else
    401                         g_snprintf( s, sizeof( s ), "account add %s \"%s\" \"%s\" \"%s\"",
    402                                     a->prpl->name, a->user, a->pass, a->server ? a->server : "" );
    403                
    404                 line = obfucrypt( irc, s );
    405                 if( *line )
    406                 {
    407                         if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 )
    408                         {
    409                                 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" );
    410                                 fclose( fp );
    411                                 return( 0 );
    412                         }
    413                 }
    414                 g_free( line );
    415         }
    416        
    417         for( set = irc->set; set; set = set->next )
    418         {
    419                 if( set->value && set->def )
    420                 {
    421                         g_snprintf( s, sizeof( s ), "set %s \"%s\"", set->key, set->value );
    422                         line = obfucrypt( irc, s );
    423                         if( *line )
    424                         {
    425                                 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 )
    426                                 {
    427                                         irc_usermsg( irc, "fprintf() wrote too little. Disk full?" );
    428                                         fclose( fp );
    429                                         return( 0 );
    430                                 }
    431                         }
    432                         g_free( line );
    433                 }
    434         }
    435        
    436         if( strcmp( irc->mynick, ROOT_NICK ) != 0 )
    437         {
    438                 g_snprintf( s, sizeof( s ), "rename %s %s", ROOT_NICK, irc->mynick );
    439                 line = obfucrypt( irc, s );
    440                 if( *line )
    441                 {
    442                         if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 )
    443                         {
    444                                 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" );
    445                                 fclose( fp );
    446                                 return( 0 );
    447                         }
    448                 }
    449                 g_free( line );
    450         }
    451         if( fclose( fp ) != 0 )
    452         {
    453                 irc_usermsg( irc, "fclose() reported an error. Disk full?" );
    454                 return( 0 );
    455         }
    456        
    457         g_snprintf( new_path, 512, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    458         if( unlink( new_path ) != 0 )
    459         {
    460                 if( errno != ENOENT )
    461                 {
    462                         irc_usermsg( irc, "Error while removing old .accounts file" );
    463                         return( 0 );
    464                 }
    465         }
    466         if( rename( path, new_path ) != 0 )
    467         {
    468                 irc_usermsg( irc, "Error while renaming new .accounts file" );
    469                 return( 0 );
    470         }
    471        
    472         umask( ou );
    473        
    474         return( 1 );
    475 }
    476 
    477239void bitlbee_shutdown( gpointer data )
    478240{
  • bitlbee.h

    r2983f5e rbd69a21  
    3030
    3131#define PACKAGE "BitlBee"
    32 #define BITLBEE_VERSION "1.0pre"
     32#define BITLBEE_VERSION "BZR"
    3333#define VERSION BITLBEE_VERSION
    3434
     
    100100
    101101#include "irc.h"
     102#include "storage.h"
    102103#include "set.h"
    103104#include "protocols/nogaim.h"
     
    115116        help_t *help;
    116117        conf_t *conf;
     118        GList *storage; /* The first backend in the list will be used for saving */
    117119        char *helpfile;
    118120        GMainLoop *loop;
     
    127129int root_command_string( irc_t *irc, user_t *u, char *command, int flags );
    128130int root_command( irc_t *irc, char *command[] );
    129 int bitlbee_load( irc_t *irc, char *password );
    130 int bitlbee_save( irc_t *irc );
    131131void bitlbee_shutdown( gpointer data );
    132132double gettime( void );
  • commands.c

    r2983f5e rbd69a21  
    8686int cmd_identify( irc_t *irc, char **cmd )
    8787{
    88         int checkie = bitlbee_load( irc, cmd[1] );
    89        
    90         if( checkie == -1 )
    91         {
     88        storage_status_t status = storage_load( irc->nick, cmd[1], irc );
     89       
     90        switch (status) {
     91        case STORAGE_INVALID_PASSWORD:
    9292                irc_usermsg( irc, "Incorrect password" );
    93         }
    94         else if( checkie == 0 )
    95         {
     93                break;
     94        case STORAGE_NO_SUCH_USER:
    9695                irc_usermsg( irc, "The nick is (probably) not registered" );
    97         }
    98         else if( checkie == 1 )
    99         {
     96                break;
     97        case STORAGE_OK:
    10098                irc_usermsg( irc, "Password accepted" );
    101         }
    102         else
    103         {
     99                break;
     100        default:
    104101                irc_usermsg( irc, "Something very weird happened" );
    105         }
    106        
     102                break;
     103        }
     104
    107105        return( 0 );
    108106}
     
    110108int cmd_register( irc_t *irc, char **cmd )
    111109{
    112         int checkie;
    113         char path[512];
    114        
    115110        if( global.conf->authmode == AUTHMODE_REGISTERED )
    116111        {
     
    118113                return( 0 );
    119114        }
    120        
    121         g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    122         checkie = access( path, F_OK );
    123        
    124         g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
    125         checkie += access( path, F_OK );
    126        
    127         if( checkie == -2 )
    128         {
    129                 setpassnc( irc, cmd[1] );
    130                 root_command_string( irc, user_find( irc, irc->mynick ), "save", 0 );
    131                 irc->status = USTATUS_IDENTIFIED;
    132         }
    133         else
    134         {
    135                 irc_usermsg( irc, "Nick is already registered" );
     115
     116        irc_setpass( irc, cmd[1] );
     117        switch( storage_save( irc, FALSE )) {
     118                case STORAGE_ALREADY_EXISTS:
     119                        irc_usermsg( irc, "Nick is already registered" );
     120                        break;
     121                       
     122                case STORAGE_OK:
     123                        irc->status = USTATUS_IDENTIFIED;
     124                        break;
     125
     126                default:
     127                        irc_usermsg( irc, "Error registering" );
     128                        break;
    136129        }
    137130       
     
    141134int cmd_drop( irc_t *irc, char **cmd )
    142135{
    143         char s[512];
    144         FILE *fp;
    145        
    146         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    147         fp = fopen( s, "r" );
    148         if( !fp )
    149         {
     136        storage_status_t status;
     137       
     138        status = storage_remove (irc->nick, cmd[1]);
     139        switch (status) {
     140        case STORAGE_NO_SUCH_USER:
    150141                irc_usermsg( irc, "That account does not exist" );
    151142                return( 0 );
    152         }
    153        
    154         fscanf( fp, "%32[^\n]s", s );
    155         fclose( fp );
    156         if( setpass( irc, cmd[1], s ) < 0 )
    157         {
    158                 irc_usermsg( irc, "Incorrect password" );
    159                 return( 0 );
    160         }
    161        
    162         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    163         unlink( s );
    164        
    165         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
    166         unlink( s );
    167        
    168         setpassnc( irc, NULL );
    169         irc_usermsg( irc, "Files belonging to account `%s' removed", irc->nick );
    170        
    171         return( 0 );
     143        case STORAGE_INVALID_PASSWORD:
     144                irc_usermsg( irc, "Password invalid" );
     145                return( 0 );
     146        case STORAGE_OK:
     147                irc_setpass( irc, NULL );
     148                irc_usermsg( irc, "Account `%s' removed", irc->nick );
     149                return( 0 );
     150        default:
     151                irc_usermsg( irc, "Error: '%d'", status );
     152                return( 0 );
     153        }
    172154}
    173155
     
    623605int cmd_save( irc_t *irc, char **cmd )
    624606{
    625         if( bitlbee_save( irc ) )
     607        if( storage_save( irc, TRUE ) == STORAGE_OK )
    626608                irc_usermsg( irc, "Configuration saved" );
    627609        else
  • conf.c

    r2983f5e rbd69a21  
    5050        conf->nofork = 0;
    5151        conf->verbose = 0;
     52        conf->primary_storage = "text";
    5253        conf->runmode = RUNMODE_INETD;
    5354        conf->authmode = AUTHMODE_OPEN;
     
    198199                                conf->motdfile = g_strdup( ini->value );
    199200                        }
     201                        else if( g_strcasecmp( ini->key, "account_storage" ) == 0 )
     202                        {
     203                                g_free( conf->primary_storage );
     204                                conf->primary_storage = g_strdup( ini->value );
     205                        }
     206                        else if( g_strcasecmp( ini->key, "account_storage_migrate" ) == 0 )
     207                        {
     208                                g_strfreev( conf->migrate_storage );
     209                                conf->migrate_storage = g_strsplit( ini->value, " \t,;", -1 );
     210                        }
    200211                        else if( g_strcasecmp( ini->key, "pinginterval" ) == 0 )
    201212                        {
  • conf.h

    r2983f5e rbd69a21  
    4242        char *configdir;
    4343        char *motdfile;
     44        char *primary_storage;
     45        char **migrate_storage;
    4446        int ping_interval;
    4547        int ping_timeout;
  • configure

    r2983f5e rbd69a21  
    5757--strip=0/1     Disable/enable binary stripping         $strip
    5858
    59 --flood=0/1     Flood protection                        $flood
    6059--ipv6=0/1      IPv6 socket support                     $ipv6
    6160
     
    287286
    288287if [ "$flood" = 1 ]; then
    289         echo '#define FLOOD_SEND' >> config.h
     288        # echo '#define FLOOD_SEND' >> config.h
     289        echo 'Flood protection is disabled in this release because of too many bugs.' 2> /dev/stderr
     290        rm config.h
     291        rm Makefile.settings
     292        exit 1
    290293fi
    291294
     
    345348case "$arch" in
    346349Linux )
    347         echo 'Linux.'
    348350;;
    349351GNU/* )
    350         echo 'Debian with non-Linux kernel?'
    351352;;
    352353*BSD )
    353         echo '*BSD.'
    354354        echo 'EFLAGS+=-liconv' >> Makefile.settings;
    355355;;
    356356SunOS )
    357         echo 'Solaris.'
    358357        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
    359358        echo 'STRIP=\# skip strip' >> Makefile.settings
     
    361360;;
    362361Darwin )
    363         echo 'Darwin/Mac OS X.'
    364362        echo 'EFLAGS+=-liconv' >> Makefile.settings;
    365363;;
    366364IRIX )
    367         echo 'IRIX.'
    368365;;
    369366CYGWIN* )
     
    371368;;
    372369* )
    373         echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV. Please report any problems to <wilmer@gaast.net>.'
     370        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
     371        echo 'Please report any problems at http://bugs.bitlbee.org/.'
    374372;;
    375373esac
     
    394392fi
    395393
    396 if [ "$flood" = "0" ]; then
    397         echo '  Flood protection disabled.';
    398 else
    399         echo '  Flood protection enabled.';
    400 fi
     394#if [ "$flood" = "0" ]; then
     395#       echo '  Flood protection disabled.';
     396#else
     397#       echo '  Flood protection enabled.';
     398#fi
    401399
    402400if [ -n "$protocols" ]; then
  • crypting.c

    r2983f5e rbd69a21  
    2929   the programs will be built. */
    3030
    31 #ifndef CRYPTING_MAIN
    32 #define BITLBEE_CORE
    33 #include "bitlbee.h"
    34 #include "irc.h"
    3531#include "md5.h"
    3632#include "crypting.h"
     
    3834#include <stdio.h>
    3935#include <stdlib.h>
    40 
    41 #else
    42 
    43 typedef struct irc
    44 {
    45         char *password;
    46 } irc_t;
    47 
    48 #define set_add( a, b, c, d )
    49 #define set_find( a, b ) NULL
    50 
    51 #include "md5.h"
    52 #include "crypting.h"
    53 #include <string.h>
    54 #include <stdio.h>
    55 #include <stdlib.h>
    56 
    57 #define irc_usermsg
    58 
    59 #endif
    6036
    6137/*\
     
    6541\*/
    6642
    67 /* USE WITH CAUTION!
    68    Sets pass without checking */
    69 void setpassnc (irc_t *irc, char *pass) {
    70         if (!set_find (irc, "password"))
    71                 set_add (irc, "password", NULL, passchange);
    72        
    73         if (irc->password) g_free (irc->password);
    74        
    75         if (pass) {
    76                 irc->password = g_strdup (pass);
    77                 irc_usermsg (irc, "Password successfully changed");
    78         } else {
    79                 irc->password = NULL;
    80         }
    81 }
    82 
    83 char *passchange (irc_t *irc, void *set, char *value) {
    84         setpassnc (irc, value);
    85         return (NULL);
    86 }
    87 
    88 int setpass (irc_t *irc, char *pass, char* md5sum) {
     43int checkpass (const char *pass, const char *md5sum)
     44{
    8945        md5_state_t md5state;
    9046        md5_byte_t digest[16];
     
    10359                if (digits[1] != md5sum[j + 1]) return (-1);
    10460        }
    105        
    106         /* If pass is correct, we end up here and we set the pass */
    107         setpassnc (irc, pass);
    108        
    109         return (0);
     61
     62        return( 0 );
    11063}
    11164
    112 char *hashpass (irc_t *irc) {
     65
     66char *hashpass (const char *password)
     67{
    11368        md5_state_t md5state;
    11469        md5_byte_t digest[16];
     
    11772        char *rv;
    11873       
    119         if (irc->password == NULL) return (NULL);
     74        if (password == NULL) return (NULL);
    12075       
    121         rv = (char *)g_malloc (33);
    122         memset (rv, 0, 33);
     76        rv = g_new0 (char, 33);
    12377       
    12478        md5_init (&md5state);
    125         md5_append (&md5state, (unsigned char *)irc->password, strlen (irc->password));
     79        md5_append (&md5state, (const unsigned char *)password, strlen (password));
    12680        md5_finish (&md5state, digest);
    12781       
     
    13589}
    13690
    137 char *obfucrypt (irc_t *irc, char *line) {
     91char *obfucrypt (char *line, const char *password)
     92{
    13893        int i, j;
    13994        char *rv;
    14095       
    141         if (irc->password == NULL) return (NULL);
     96        if (password == NULL) return (NULL);
    14297       
    143         rv = (char *)g_malloc (strlen (line) + 1);
    144         memset (rv, '\0', strlen (line) + 1);
     98        rv = g_new0 (char, strlen (line) + 1);
    14599       
    146100        i = j = 0;
     
    148102                /* Encrypt/obfuscate the line, using the password */
    149103                if (*(signed char*)line < 0) *line = - (*line);
    150                 if (((signed char*)irc->password)[i] < 0) irc->password[i] = - irc->password[i];
    151104               
    152                 rv[j] = *line + irc->password[i]; /* Overflow intended */
     105                rv[j] = *line + password[i]; /* Overflow intended */
    153106               
    154107                line++;
    155                 if (!irc->password[++i]) i = 0;
     108                if (!password[++i]) i = 0;
    156109                j++;
    157110        }
     
    160113}
    161114
    162 char *deobfucrypt (irc_t *irc, char *line) {
     115char *deobfucrypt (char *line, const char *password)
     116{
    163117        int i, j;
    164118        char *rv;
    165119       
    166         if (irc->password == NULL) return (NULL);
     120        if (password == NULL) return (NULL);
    167121       
    168         rv = (char *)g_malloc (strlen (line) + 1);
    169         memset (rv, '\0', strlen (line) + 1);
     122        rv = g_new0 (char, strlen (line) + 1);
    170123       
    171124        i = j = 0;
    172125        while (*line) {
    173126                /* Decrypt/deobfuscate the line, using the pass */
    174                 rv[j] = *line - irc->password[i]; /* Overflow intended */
     127                rv[j] = *line - password[i]; /* Overflow intended */
    175128               
    176129                line++;
    177                 if (!irc->password[++i]) i = 0;
     130                if (!password[++i]) i = 0;
    178131                j++;
    179132        }
     
    189142int main( int argc, char *argv[] )
    190143{
    191         irc_t *irc = g_malloc( sizeof( irc_t ) );
    192144        char *hash, *action, line[256];
    193         char* (*func)( irc_t *, char * );
     145        char* (*func)( char *, const char * );
    194146       
    195147        if( argc < 2 )
     
    201153        }
    202154       
    203         memset( irc, 0, sizeof( irc_t ) );
    204         irc->password = g_strdup( argv[1] );
    205        
    206         hash = hashpass( irc );
     155        hash = hashpass( argv[1] );
    207156        action = argv[0] + strlen( argv[0] ) - strlen( "encode" );
    208157       
     
    236185                fgetc( stdin );
    237186               
    238                 out = func( irc, line );
     187                out = func( line, argv[1] );
    239188                printf( "%s\n", out );
    240189                g_free( out );
  • crypting.h

    r2983f5e rbd69a21  
    2424*/
    2525
    26 void setpassnc (irc_t *irc, char *pass); /* USE WITH CAUTION! */
    27 char *passchange (irc_t *irc, void *set, char *value);
    28 int setpass (irc_t *irc, char *pass, char* md5sum);
    29 char *hashpass (irc_t *irc);
    30 char *obfucrypt (irc_t *irc, char *line);
    31 char *deobfucrypt (irc_t *irc, char *line);
     26int checkpass (const char *password, const char *md5sum);
     27char *hashpass (const char *password);
     28char *obfucrypt (char *line, const char *password);
     29char *deobfucrypt (char *line, const char *password);
  • doc/AUTHORS

    r2983f5e rbd69a21  
    44        Main developer
    55
    6 Jelmer 'ctrlsoft' Vernooij <jelmer@nl.linux.org>
     6Jelmer 'ctrlsoft' Vernooij <jelmer@samba.org>
    77        Documentation, general hacking, Win32 port
    88
  • doc/CHANGES

    r2983f5e rbd69a21  
    1111  handlers for headline messages (which allows you to use RSS-to-Jabber
    1212  gateways).
    13 
    14 Finished ...
     13- Lowered the line splitting limit a bit to fix data loss issues.
     14- The $proto($handle) format used for messages specific to one IM-connection
     15  now only include the ($handle) part when there's more than one $proto-
     16  connection.
     17- Fix for a crash-bug on broken Jabber/SSL connections.
     18- Incoming typing notifications now also come in as CTCP TYPING messages, for
     19  better consistency. Don't forget to update your scripts!
     20- AIM typing notifications are supported now.
     21- Jabber module only accepts ports 5220-5229 now, to prevent people from
     22  abusing it as a port scanner. We aren't aware of any Jabber server that
     23  runs on other ports than those. If you are, please warn us.
     24- Send flood protection can't be enabled anymore. It was disabled by default
     25  for a good reason for some time already, but some package maintainers
     26  turned it back on while it's way too unreliable and trigger-happy to be
     27  used.
     28- Removed TODO file, the current to-do list is always in the on-line bug
     29  tracking system.
     30- Fixed a potential DoS bug in input handling.
     31
     32Finished 4 Dec 2005
    1533
    1634Version 0.99:
  • doc/FAQ

    r2983f5e rbd69a21  
    3939
    4040Q: When is $random_feature going to be implemented?
    41 A: Please do consult doc/TODO (preferably in a development snapshot, which
    42    is more up-to-date than a TODO in a release version) before asking.
    43    Please also check the documentation. You'd not be the first one to request
    44    a feature which already exists!
    45    
    46    If your fabulous feature seems not to be requested before, just join
    47    #bitlbee on irc.oftc.net and tell us the news.
    48    
    49    If your feature request is already in the TODO list, of course you can
    50    still request it again/make us know that you'd like to see the feature as
    51    well. But when the feature is in the "post-1.0" list, it's probably not
    52    going to help. Most of the features in this list are low-priority because
    53    we (the developers) don't need (or even want) them. (File transfers are a
    54    good example here.)
    55    Hence, they'll only be implemented when we really got too much spare
    56    time. Obviously, if you're willing to help (i.e. submit a patch), you're
    57    always welcome.
     41A: It depends on the feature. We keep a list of all wishlist "bugs" in our
     42   Bug Tracking system at http://bugs.bitlbee.org/
    5843
    5944Q: The messages I send and/or receive look weird. I see weird characters and
     
    6146   non-ASCII characters!
    6247A: You probably have to change some settings. To get rid of HTML in messages,
    63    see "help set html". If you seem to have problems with your charset, see
    64    "help set charset".
     48   see "help set strip_html". If you seem to have problems with your charset,
     49   see "help set charset".
     50   
     51   Although actually most of these problems should be gone by now. So if you
     52   can't get things to work well, you might have found a bug.
    6553
    6654Q: Is BitlBee forked from Gaim?
  • doc/README

    r2983f5e rbd69a21  
    108108See utils/bitlbeed.c for more information about the program.
    109109
    110 Just a little note: We run our public server im.bitlbee.org for a couple of
    111 months now, and so far we haven't experienced this problem yet. The only
    112 BitlBee processes killed because of CPU-time overuse were running for a long
    113 time already, they were usually killed during the MSN login process (which
    114 is quite CPU-time consuming).
     110Just a little note: Now that we reach version 1.0, this shouldn't be that
     111much of an issue anymore. However, on a public server, especially if you
     112also use it for other things, it can't hurt to protect yourself against
     113possible problems.
    115114
    116115
     
    145144You can find new releases of BitlBee at:
    146145http://www.bitlbee.org/
     146
     147The bug tracking system:
     148http://bugs.bitlbee.org/
     149
     150Our version control system is Bazaar-NG. Our repository is at:
     151http://code.bitlbee.org/
    147152
    148153
     
    187192        BitlBee - An IRC to other chat networks gateway
    188193                  <http://www.bitlbee.org/>
    189         Copyright (C) 2002-2004  Wilmer van der Gaast <wilmer@gaast.net>
     194        Copyright (C) 2002-2005  Wilmer van der Gaast <wilmer@gaast.net>
    190195                                 and others
  • doc/user-guide/user-guide.xml

    r2983f5e rbd69a21  
    2121
    2222        <legalnotice id="legalnotice">
    23      <para>
    24          Permission is granted to copy, distribute and/or modify this
    25          document under the terms of the <ulink type="help"
    26          url="gnome-help:fdl"><citetitle>GNU Free Documentation
    27          License</citetitle></ulink>, Version 1.1 or any later version
    28          published by the Free Software Foundation with no Invariant
    29          Sections, no Front-Cover Texts, and no Back-Cover Texts. You
    30          may obtain a copy of the <citetitle>GNU Free Documentation
    31          License</citetitle> from the Free Software Foundation by
    32          visiting <ulink type="http" url="http://www.fsf.org">their
    33          Web site</ulink> or by writing to: Free Software Foundation,
    34          Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    35          USA.
    36        </para>
    3723    </legalnotice>
    3824
    3925   <releaseinfo>
    40                 This is the initial release of the BitlBee User Guide.
     26                This is the BitlBee User Guide. For now, the on-line help is
     27                the most up-to-date documentation. Although this document shares
     28                some parts with the on-line help system, other parts might be
     29                very outdated.
    4130   </releaseinfo>
    4231
  • irc.c

    r2983f5e rbd69a21  
    3131
    3232GSList *irc_connection_list = NULL;
     33
     34static char *passchange (irc_t *irc, void *set, char *value)
     35{
     36        irc_setpass (irc, value);
     37        return (NULL);
     38}
    3339
    3440irc_t *irc_new( int fd )
     
    129135        set_add( irc, "to_char", ": ", set_eval_to_char );
    130136        set_add( irc, "typing_notice", "false", set_eval_bool );
     137        set_add( irc, "password", NULL, passchange);
    131138       
    132139        conf_loaddefaults( irc );
     
    154161       
    155162        if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )
    156                 if( !bitlbee_save( irc ) )
     163                if( storage_save( irc, TRUE ) != STORAGE_OK )
    157164                        irc_usermsg( irc, "Error while saving settings!" );
    158165       
     
    259266        if( global.conf->runmode == RUNMODE_INETD )
    260267                g_main_quit( global.loop );
     268}
     269
     270/* USE WITH CAUTION!
     271   Sets pass without checking */
     272void irc_setpass (irc_t *irc, const char *pass)
     273{
     274        if (irc->password) g_free (irc->password);
     275       
     276        if (pass) {
     277                irc->password = g_strdup (pass);
     278                irc_usermsg (irc, "Password successfully changed");
     279        } else {
     280                irc->password = NULL;
     281        }
    261282}
    262283
     
    15101531                        {
    15111532                                irc_write( irc, ":%s!%s@%s %s %s :%s%s", u->nick, u->user, u->host,
    1512                                            type, to, prefix, line );
     1533                                           type, to, prefix ? prefix : "", line );
    15131534                        }
    15141535                        line = s + 1;
  • irc.h

    r2983f5e rbd69a21  
    137137void irc_whois( irc_t *irc, char *nick );
    138138int irc_away( irc_t *irc, char *away );
     139void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */
    139140
    140141int irc_send( irc_t *irc, char *nick, char *s, int flags );
  • nick.c

    r2983f5e rbd69a21  
    2727#include "bitlbee.h"
    2828
    29 void nick_set( irc_t *irc, char *handle, struct prpl *proto, char *nick )
     29void nick_set( irc_t *irc, const char *handle, struct prpl *proto, const char *nick )
    3030{
    3131        nick_t *m = NULL, *n = irc->nicks;
     
    5656}
    5757
    58 char *nick_get( irc_t *irc, char *handle, struct prpl *proto, const char *realname )
     58char *nick_get( irc_t *irc, const char *handle, struct prpl *proto, const char *realname )
    5959{
    6060        static char nick[MAX_NICK_LENGTH+1];
     
    129129}
    130130
    131 void nick_del( irc_t *irc, char *nick )
     131void nick_del( irc_t *irc, const char *nick )
    132132{
    133133        nick_t *l = NULL, *n = irc->nicks;
     
    176176}
    177177
    178 int nick_ok( char *nick )
    179 {
    180         char *s;
     178int nick_ok( const char *nick )
     179{
     180        const char *s;
    181181       
    182182        /* Empty/long nicks are not allowed */
     
    237237}
    238238
    239 int nick_cmp( char *a, char *b )
     239int nick_cmp( const char *a, const char *b )
    240240{
    241241        char aa[1024] = "", bb[1024] = "";
     
    253253}
    254254
    255 char *nick_dup( char *nick )
    256 {
    257         char *cp;
    258        
    259         cp = g_new0 ( char, MAX_NICK_LENGTH + 1 );
    260         strncpy( cp, nick, MAX_NICK_LENGTH );
    261        
    262         return( cp );
    263 }
     255char *nick_dup( const char *nick )
     256{
     257        return g_strndup( nick, MAX_NICK_LENGTH );
     258}
  • nick.h

    r2983f5e rbd69a21  
    3232} nick_t;
    3333
    34 void nick_set( irc_t *irc, char *handle, struct prpl *proto, char *nick );
    35 char *nick_get( irc_t *irc, char *handle, struct prpl *proto, const char *realname );
    36 void nick_del( irc_t *irc, char *nick );
     34void nick_set( irc_t *irc, const char *handle, struct prpl *proto, const char *nick );
     35char *nick_get( irc_t *irc, const char *handle, struct prpl *proto, const char *realname );
     36void nick_del( irc_t *irc, const char *nick );
    3737void nick_strip( char *nick );
    3838
    39 int nick_ok( char *nick );
     39int nick_ok( const char *nick );
    4040int nick_lc( char *nick );
    4141int nick_uc( char *nick );
    42 int nick_cmp( char *a, char *b );
    43 char *nick_dup( char *nick );
     42int nick_cmp( const char *a, const char *b );
     43char *nick_dup( const char *nick );
  • protocols/jabber/jabber.c

    r2983f5e rbd69a21  
    2222 */
    2323
    24 #ifdef HAVE_CONFIG_H
    25 #include "config.h"
    26 #endif
    27 
    2824#ifndef _WIN32
    2925#include <sys/utsname.h>
     
    5955#define DEFAULT_PORT 5222
    6056#define DEFAULT_PORT_SSL 5223
     57#define JABBER_PORT_MIN 5220
     58#define JABBER_PORT_MAX 5229
    6159
    6260#define JABBER_GROUP "Friends"
     
    541539        gjconn gjc;
    542540       
    543         if (!g_slist_find(get_connections(), gc)) {
    544                 ssl_disconnect(source);
    545                 return;
    546         }
    547        
    548541        jd = gc->proto_data;
    549542        gjc = jd->gjc;
     
    551544        if (source == NULL) {
    552545                STATE_EVT(JCONN_STATE_OFF)
     546                return;
     547        }
     548       
     549        if (!g_slist_find(get_connections(), gc)) {
     550                ssl_disconnect(source);
    553551                return;
    554552        }
     
    589587        else if (port == -1 && ssl)
    590588                port = DEFAULT_PORT_SSL;
     589        else if (port < JABBER_PORT_MIN || port > JABBER_PORT_MAX) {
     590                serv_got_crap(GJ_GC(gjc), "For security reasons, the Jabber port number must be in the %d-%d range.", JABBER_PORT_MIN, JABBER_PORT_MAX);
     591                STATE_EVT(JCONN_STATE_OFF)
     592                return;
     593        }
    591594       
    592595        if (server == NULL)
  • protocols/msn/sb.c

    r2983f5e rbd69a21  
    644644                        if( who )
    645645                        {
    646                                 serv_got_typing( gc, who, 5 );
     646                                serv_got_typing( gc, who, 5, 1 );
    647647                                g_free( who );
    648648                        }
  • protocols/nogaim.c

    r2983f5e rbd69a21  
    5555GSList *connections;
    5656
     57#ifdef WITH_PLUGINS
    5758gboolean load_plugin(char *path)
    5859{
     
    7576        return TRUE;
    7677}
     78
     79void load_plugins(void)
     80{
     81        GDir *dir;
     82        GError *error = NULL;
     83
     84        dir = g_dir_open(PLUGINDIR, 0, &error);
     85
     86        if (dir) {
     87                const gchar *entry;
     88                char *path;
     89
     90                while ((entry = g_dir_read_name(dir))) {
     91                        path = g_build_filename(PLUGINDIR, entry, NULL);
     92                        if(!path) {
     93                                log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry);
     94                                continue;
     95                        }
     96
     97                        load_plugin(path);
     98
     99                        g_free(path);
     100                }
     101
     102                g_dir_close(dir);
     103        }
     104}
     105#endif
    77106
    78107/* nogaim.c */
     
    101130void nogaim_init()
    102131{
    103         GDir *dir;
    104         GError *error = NULL;
     132        extern void msn_init();
     133        extern void oscar_init();
     134        extern void byahoo_init();
     135        extern void jabber_init();
    105136
    106137#ifdef WITH_MSN
    107         extern void msn_init();
    108138        msn_init();
    109139#endif
    110140
    111141#ifdef WITH_OSCAR
    112         extern void oscar_init();
    113142        oscar_init();
    114143#endif
    115144       
    116145#ifdef WITH_YAHOO
    117         extern void byahoo_init();
    118146        byahoo_init();
    119147#endif
    120148       
    121149#ifdef WITH_JABBER
    122         extern void jabber_init();
    123150        jabber_init();
    124151#endif
    125152
    126         dir = g_dir_open(PLUGINDIR, 0, &error);
    127 
    128         if (dir) {
    129                 const gchar *entry;
    130                 char *path;
    131 
    132                 while ((entry = g_dir_read_name(dir))) {
    133                         path = g_build_filename(PLUGINDIR, entry, NULL);
    134                         if(!path) {
    135                                 log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry);
    136                                 continue;
    137                         }
    138 
    139                         load_plugin(path);
    140 
    141                         g_free(path);
    142                 }
    143 
    144                 g_dir_close(dir);
    145         }
     153#ifdef WITH_PLUGINS
     154        load_plugins();
     155#endif
    146156}
    147157
     
    442452void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )
    443453{
    444         serv_got_crap( gc, "Error: %s", msg );
     454        if( msg && title )
     455                serv_got_crap( gc, "Error: %s: %s", title, msg );
     456        else if( msg )
     457                serv_got_crap( gc, "Error: %s", msg );
     458        else if( title )
     459                serv_got_crap( gc, "Error: %s", title );
     460        else
     461                serv_got_crap( gc, "Error" );
    445462}
    446463
     
    727744                /* If there's a newline/space in this string, split up there,
    728745                   looks a bit prettier. */
    729                 if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strchr( msg, ' ' ) ) )
     746                if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) )
    730747                {
    731748                        msg[425] = tmp;
     
    751768}
    752769
    753 void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout )
     770void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type )
    754771{
    755772        user_t *u;
     
    758775                return;
    759776       
    760         if( ( u = user_findhandle( gc, handle ) ) )
    761                 irc_msgfrom( gc->irc, u->nick, "\1TYPING 1\1" );
     777        if( ( u = user_findhandle( gc, handle ) ) ) {
     778                /* If type is:
     779                 * 0: user has stopped typing
     780                 * 1: user is actively typing
     781                 * 2: user has entered text, but is not actively typing
     782                 */
     783                if (type == 0 || type == 1 || type == 2) {
     784                        char buf[256];
     785                        g_snprintf(buf, 256, "\1TYPING %d\1", type);
     786                        irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf );
     787                }
     788        }
    762789}
    763790
  • protocols/nogaim.h

    r2983f5e rbd69a21  
    307307G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );
    308308G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
    309 G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout );
     309G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type );
    310310G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data );
    311311G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle );
     
    326326G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value);
    327327
    328 /* file transfers */
    329 G_MODULE_EXPORT void ft_progress( struct ft *, int);
    330 G_MODULE_EXPORT void ft_incoming( struct ft_request * );
    331 G_MODULE_EXPORT void ft_accepted( struct ft_request *, struct ft *);
    332 G_MODULE_EXPORT void ft_denied( struct ft_request *, const char *reason);
    333 
    334328/* prefs.c */
    335329G_MODULE_EXPORT void build_block_list();
  • protocols/oscar/aim.h

    r2983f5e rbd69a21  
    466466int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps);
    467467int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type);
     468int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
    468469int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui);
    469470int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl);
     
    572573};
    573574
     575struct aim_chat_invitation {
     576        struct gaim_connection * gc;
     577        char * name;
     578        guint8 exchange;
     579};
    574580
    575581#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
  • protocols/oscar/chat.c

    r2983f5e rbd69a21  
    180180       
    181181        aim_tx_enqueue(sess, fr);
    182 
    183         return 0;
    184 }
    185 
    186 static int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)
    187 {
    188         guint8 *buf;
    189         int buflen;
    190         aim_bstream_t bs;
    191 
    192         buflen = 2 + 1 + strlen(roomname) + 2;
    193        
    194         if (!(buf = g_malloc(buflen)))
    195                 return 0;
    196 
    197         aim_bstream_init(&bs, buf, buflen);
    198 
    199         aimbs_put16(&bs, exchange);
    200         aimbs_put8(&bs, strlen(roomname));
    201         aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname));
    202         aimbs_put16(&bs, instance);
    203 
    204         aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf);
    205 
    206         g_free(buf);
    207182
    208183        return 0;
  • protocols/oscar/im.c

    r2983f5e rbd69a21  
    13691369}
    13701370
     1371
     1372static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
     1373{
     1374
     1375        /* XXX aim_chat_roominfo_free() */
     1376        g_free(args->info.chat.roominfo.name);
     1377
     1378        return;
     1379}
     1380
     1381static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
     1382{
     1383
     1384        /*
     1385         * Chat room info.
     1386         */
     1387        if (servdata)
     1388                aim_chat_readroominfo(servdata, &args->info.chat.roominfo);
     1389
     1390        args->destructor = (void *)incomingim_ch2_chat_free;
     1391
     1392        return;
     1393}
     1394
    13711395static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
    13721396{
     
    16171641        if (args.reqclass & AIM_CAPS_ICQSERVERRELAY)
    16181642                incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr);
     1643        else if (args.reqclass & AIM_CAPS_CHAT)
     1644                incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr);
    16191645
    16201646
  • protocols/oscar/oscar.c

    r2983f5e rbd69a21  
    6262   static int gaim_caps = AIM_CAPS_UTF8; */
    6363
    64 static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY;
     64static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT;
    6565static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02};
    6666
     
    156156}
    157157
    158 #if 0
    159158static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) {
    160159        GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats;
     
    171170        return c;
    172171}
    173 #endif
     172
    174173
    175174static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,
     
    10741073}
    10751074
     1075void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv);
     1076void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv);
     1077       
    10761078static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
    1077 #if 0
    10781079        struct gaim_connection *gc = sess->aux_data;
    1079 #endif
    10801080
    10811081        if (args->status != AIM_RENDEZVOUS_PROPOSE)
    10821082                return 1;
    1083 #if 0
     1083
    10841084        if (args->reqclass & AIM_CAPS_CHAT) {
    10851085                char *name = extract_name(args->info.chat.roominfo.name);
    10861086                int *exch = g_new0(int, 1);
    10871087                GList *m = NULL;
     1088                char txt[1024];
     1089                struct aim_chat_invitation * inv = g_new0(struct aim_chat_invitation, 1);
     1090
    10881091                m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name));
    10891092                *exch = args->info.chat.roominfo.exchange;
    10901093                m = g_list_append(m, exch);
    1091                 serv_got_chat_invite(gc,
    1092                                      name ? name : args->info.chat.roominfo.name,
    1093                                      userinfo->sn,
    1094                                      (char *)args->msg,
    1095                                      m);
     1094
     1095                g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg );
     1096
     1097                inv->gc = gc;
     1098                inv->exchange = *exch;
     1099                inv->name = g_strdup(name);
     1100               
     1101                do_ask_dialog( gc, txt, inv, oscar_accept_chat, oscar_reject_chat);
     1102       
    10961103                if (name)
    10971104                        g_free(name);
    10981105        }
    1099 #endif
     1106
    11001107        return 1;
    11011108}
     
    24412448        type2 = va_arg(ap, int);
    24422449        va_end(ap);
    2443 
    2444         if(type2 == 0x0001 || type2 == 0x0002)
    2445                 serv_got_typing(gc, sn, 0);
    2446 
     2450   
     2451        if(type2 == 0x0002) {
     2452                /* User is typing */
     2453                serv_got_typing(gc, sn, 0, 1);
     2454        }
     2455        else if (type2 == 0x0001) {
     2456                /* User has typed something, but is not actively typing (stale) */
     2457                serv_got_typing(gc, sn, 0, 2);
     2458        }
     2459        else {
     2460                /* User has stopped typing */
     2461                serv_got_typing(gc, sn, 0, 0);
     2462        }       
     2463       
    24472464        return 1;
    24482465}
     
    24822499}
    24832500
     2501int oscar_chat_send(struct gaim_connection * gc, int id, char *message)
     2502{
     2503        struct oscar_data * od = (struct oscar_data*)gc->proto_data;
     2504        struct chat_connection * ccon;
     2505        int ret;
     2506        guint8 len = strlen(message);
     2507        char *s;
     2508       
     2509        if(!(ccon = find_oscar_chat(gc, id)))
     2510                return -1;
     2511               
     2512        for (s = message; *s; s++)
     2513                if (*s & 128)
     2514                        break;
     2515               
     2516        /* Message contains high ASCII chars, time for some translation! */
     2517        if (*s) {
     2518                s = g_malloc(BUF_LONG);
     2519                /* Try if we can put it in an ISO8859-1 string first.
     2520                   If we can't, fall back to UTF16. */
     2521                if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) {
     2522                        len = ret;
     2523                } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {
     2524                        len = ret;
     2525                } else {
     2526                        /* OOF, translation failed... Oh well.. */
     2527                        g_free( s );
     2528                        s = message;
     2529                }
     2530        } else {
     2531                s = message;
     2532        }
     2533               
     2534        ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);
     2535               
     2536        if (s != message) {     
     2537                g_free(s);
     2538  }
     2539 
     2540  return (ret >= 0);
     2541}
     2542
     2543void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who)
     2544{
     2545        struct oscar_data * od = (struct oscar_data *)gc->proto_data;
     2546        struct chat_connection *ccon = find_oscar_chat(gc, id);
     2547       
     2548        if (ccon == NULL)
     2549                return;
     2550       
     2551        aim_chat_invite(od->sess, od->conn, who, message ? message : "",
     2552                                        ccon->exchange, ccon->name, 0x0);
     2553}
     2554
     2555void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc)
     2556{
     2557        struct oscar_data *od = (struct oscar_data *)gc->proto_data;
     2558
     2559        /* Notify the conversation window that we've left the chat */
     2560        serv_got_chat_left(gc, cc->id);
     2561
     2562        /* Destroy the chat_connection */
     2563        od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
     2564        if (cc->inpa > 0)
     2565                gaim_input_remove(cc->inpa);
     2566        aim_conn_kill(od->sess, &cc->conn);
     2567        g_free(cc->name);
     2568        g_free(cc->show);
     2569        g_free(cc);
     2570}
     2571
     2572void oscar_chat_leave(struct gaim_connection * gc, int id)
     2573{
     2574        struct chat_connection * ccon = find_oscar_chat(gc, id);
     2575
     2576        if(ccon == NULL)
     2577                return;
     2578
     2579        oscar_chat_kill(gc, ccon);
     2580}
     2581
     2582int oscar_chat_join(struct gaim_connection * gc, char * name)
     2583{
     2584    struct oscar_data * od = (struct oscar_data *)gc->proto_data;
     2585       
     2586        aim_conn_t * cur;
     2587
     2588        if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {
     2589       
     2590                return (aim_chatnav_createroom(od->sess, cur, name, 4) == 0);
     2591       
     2592        } else {
     2593                struct create_room * cr = g_new0(struct create_room, 1);
     2594                cr->exchange = 4;
     2595                cr->name = g_strdup(name);
     2596                od->create_rooms = g_slist_append(od->create_rooms, cr);
     2597                aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV);
     2598                return 1;
     2599        }
     2600}
     2601
     2602int oscar_chat_open(struct gaim_connection * gc, char *who)
     2603{
     2604        struct oscar_data * od = (struct oscar_data *)gc->proto_data;
     2605        int ret;
     2606        static int chat_id = 0;
     2607        char * chatname = g_new0(char, strlen(gc->username)+4);
     2608       
     2609        g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++);
     2610 
     2611        ret = oscar_chat_join(gc, chatname);
     2612
     2613        aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0);
     2614
     2615        g_free(chatname);
     2616       
     2617        return ret;
     2618}
     2619
     2620void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv)
     2621{
     2622        oscar_chat_join(inv->gc, inv->name);
     2623        g_free(inv->name);
     2624        g_free(inv);
     2625}
     2626
     2627void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv)
     2628{
     2629        g_free(inv->name);
     2630        g_free(inv);
     2631}
     2632
    24842633void oscar_init()
    24852634{
     
    24952644        ret->add_buddy = oscar_add_buddy;
    24962645        ret->remove_buddy = oscar_remove_buddy;
     2646        ret->chat_send = oscar_chat_send;
     2647        ret->chat_invite = oscar_chat_invite;
     2648        ret->chat_leave = oscar_chat_leave;
     2649        ret->chat_open = oscar_chat_open;
    24972650        ret->add_permit = oscar_add_permit;
    24982651        ret->add_deny = oscar_add_deny;
  • protocols/oscar/tlv.c

    r2983f5e rbd69a21  
    340340}
    341341
     342int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)
     343{
     344        guint8 *buf;
     345        int buflen;
     346        aim_bstream_t bs;
     347
     348        buflen = 2 + 1 + strlen(roomname) + 2;
     349       
     350        if (!(buf = g_malloc(buflen)))
     351                return 0;
     352
     353        aim_bstream_init(&bs, buf, buflen);
     354
     355        aimbs_put16(&bs, exchange);
     356        aimbs_put8(&bs, strlen(roomname));
     357        aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname));
     358        aimbs_put16(&bs, instance);
     359
     360        aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf);
     361
     362        g_free(buf);
     363
     364        return 0;
     365}
     366
    342367/**
    343368 * aim_writetlvchain - Write a TLV chain into a data buffer.
  • protocols/proxy.c

    r2983f5e rbd69a21  
    7373
    7474
    75 static struct sockaddr_in *gaim_gethostbyname(char *host, int port)
     75static struct sockaddr_in *gaim_gethostbyname(const char *host, int port)
    7676{
    7777        static struct sockaddr_in sin;
     
    114114}
    115115
    116 static void no_one_calls(gpointer data, gint source, GaimInputCondition cond)
     116static void gaim_io_connected(gpointer data, gint source, GaimInputCondition cond)
    117117{
    118118        struct PHB *phb = data;
     
    144144}
    145145
    146 static int proxy_connect_none(char *host, unsigned short port, struct PHB *phb)
     146static int proxy_connect_none(const char *host, unsigned short port, struct PHB *phb)
    147147{
    148148        struct sockaddr_in *sin;
     
    163163        if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
    164164                if (sockerr_again()) {
    165                         phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb);
     165                        phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);
    166166                        phb->fd = fd;
    167167                } else {
     
    271271}
    272272
    273 static int proxy_connect_http(char *host, unsigned short port, struct PHB *phb)
     273static int proxy_connect_http(const char *host, unsigned short port, struct PHB *phb)
    274274{
    275275        phb->host = g_strdup(host);
     
    355355}
    356356
    357 static int proxy_connect_socks4(char *host, unsigned short port, struct PHB *phb)
     357static int proxy_connect_socks4(const char *host, unsigned short port, struct PHB *phb)
    358358{
    359359        phb->host = g_strdup(host);
     
    537537}
    538538
    539 static int proxy_connect_socks5(char *host, unsigned short port, struct PHB *phb)
     539static int proxy_connect_socks5(const char *host, unsigned short port, struct PHB *phb)
    540540{
    541541        phb->host = g_strdup(host);
     
    578578}
    579579
    580 int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data)
     580int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data)
    581581{
    582582        struct PHB *phb;
  • protocols/proxy.h

    r2983f5e rbd69a21  
    5656G_MODULE_EXPORT void gaim_input_remove(gint);
    5757
    58 G_MODULE_EXPORT int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data);
     58G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data);
    5959
    6060#endif /* _PROXY_H_ */
  • protocols/yahoo/crypt.c

    r2983f5e rbd69a21  
    2222 * already had. isn't that lovely. people should just use linux or
    2323 * freebsd, crypt works properly on those systems. i hate solaris */
    24 
    25 #if HAVE_CONFIG_H
    26 #  include <config.h>
    27 #endif
    2824
    2925#if HAVE_STRING_H
  • protocols/yahoo/libyahoo2.c

    r2983f5e rbd69a21  
    4343 *
    4444 */
    45 
    46 #if HAVE_CONFIG_H
    47 # include <config.h>
    48 #endif
    4945
    5046#ifndef _WIN32
  • protocols/yahoo/yahoo.c

    r2983f5e rbd69a21  
    635635{
    636636        struct gaim_connection *gc = byahoo_get_gc_by_id( id );
    637        
    638         serv_got_typing( gc, who, 1 );
     637        if (stat == 1) {
     638                /* User is typing */
     639                serv_got_typing( gc, who, 1, 1 );
     640        }
     641        else {
     642                /* User stopped typing */
     643                serv_got_typing( gc, who, 1, 0 );
     644        }
    639645}
    640646
  • protocols/yahoo/yahoo_httplib.c

    r2983f5e rbd69a21  
    1919 *
    2020 */
    21 
    22 #if HAVE_CONFIG_H
    23 # include <config.h>
    24 #endif
    2521
    2622#include <stdio.h>
  • protocols/yahoo/yahoo_util.c

    r2983f5e rbd69a21  
    1919 *
    2020 */
    21 
    22 #if HAVE_CONFIG_H
    23 # include <config.h>
    24 #endif
    2521
    2622#if STDC_HEADERS
  • unix.c

    r2983f5e rbd69a21  
    5353       
    5454        global.helpfile = g_strdup( HELP_FILE );
    55        
     55
    5656        global.conf = conf_load( argc, argv );
    5757        if( global.conf == NULL )
    5858                return( 1 );
    59        
     59
     60
    6061        if( global.conf->runmode == RUNMODE_INETD )
    6162        {
     
    7778        if( i != 0 )
    7879                return( i );
     80
     81        global.storage = storage_init( global.conf->primary_storage,
     82                                                                   global.conf->migrate_storage );
     83        if ( global.storage == NULL) {
     84                log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );
     85                return( 1 );
     86        }
     87       
    7988       
    8089        /* Catch some signals to tell the user what's happening before quitting */
     
    94103        if( !getuid() || !geteuid() )
    95104                log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" );
    96         if( access( global.conf->configdir, F_OK ) != 0 )
    97                 log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", CONFIG );
    98         else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
    99                 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
    100105        if( help_init( &(global.help) ) == NULL )
    101106                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
Note: See TracChangeset for help on using the changeset viewer.