Changeset 7b23afd


Ignore:
Timestamp:
2005-11-07T16:16:18Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
f7f3ada
Parents:
fe51bcf
Message:

Migrate my pluginable branch to use Wilmers' branch as parent

Files:
19 edited

Legend:

Unmodified
Added
Removed
  • account.c

    rfe51bcf r7b23afd  
    2828#include "account.h"
    2929
    30 account_t *account_add( irc_t *irc, int protocol, char *user, char *pass )
     30account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass )
    3131{
    3232        account_t *a;
     
    4242        }
    4343       
    44         a->protocol = protocol;
     44        a->prpl = prpl;
    4545        a->user = g_strdup( user );
    4646        a->pass = g_strdup( pass );
     
    6666        for( a = irc->accounts; a; a = a->next )
    6767        {
    68                 if( g_strcasecmp( id, proto_name[a->protocol] ) == 0 )
     68                if( g_strcasecmp( id, a->prpl->name ) == 0 )
    6969                {
    7070                        if( !ret )
     
    124124        }
    125125       
    126         if( proto_prpl[a->protocol]->login == NULL )
     126        if (a->prpl == NULL )
    127127        {
    128                 irc_usermsg( irc, "Support for protocol %s is not included in this BitlBee", proto_name[a->protocol] );
     128                irc_usermsg( irc, "Support for protocol %s is not included in this BitlBee", a->prpl->name );
    129129                return;
    130130        }
     
    134134        u = g_new0 ( struct aim_user, 1 );
    135135        u->irc = irc;
    136         u->protocol = a->protocol;
     136        u->prpl = a->prpl;
    137137        strncpy( u->username, a->user, sizeof( u->username ) - 1 );
    138138        strncpy( u->password, a->pass, sizeof( u->password ) - 1 );
     
    142142        a->reconnect = 0;
    143143       
    144         proto_prpl[a->protocol]->login( u );
     144        a->prpl->login( u );
    145145}
    146146
  • account.h

    rfe51bcf r7b23afd  
    2929typedef struct account
    3030{
    31         int protocol;
     31        struct prpl *prpl;
    3232        char *user;
    3333        char *pass;
     
    4141} account_t;
    4242
    43 account_t *account_add( irc_t *irc, int protocol, char *user, char *pass );
     43account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass );
    4444account_t *account_get( irc_t *irc, char *id );
    4545void account_del( irc_t *irc, account_t *acc );
  • bitlbee.c

    rfe51bcf r7b23afd  
    242242}
    243243
     244/* DO NOT USE THIS FUNCTION IN NEW CODE. This
     245 * function is here merely because the save/load code still uses
     246 * ids rather then names */
     247struct prpl *find_protocol_by_id(int id)
     248{
     249        switch (id) {
     250        case 1: return find_protocol("oscar");
     251        case 4: return find_protocol("msn");
     252        case 2: return find_protocol("yahoo");
     253        case 8: return find_protocol("jabber");
     254        default: break;
     255        }
     256        return NULL;
     257}
     258
    244259int bitlbee_load( irc_t *irc, char* password )
    245260{
    246261        char s[512];
    247262        char *line;
    248         int proto;
     263        char proto[20];
    249264        char nick[MAX_NICK_LENGTH+1];
    250265        FILE *fp;
     
    281296        fp = fopen( s, "r" );
    282297        if( !fp ) return( 0 );
    283         while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 )
    284         {
     298        while( fscanf( fp, "%s %s %s", s, proto, nick ) > 0 )
     299        {
     300                struct prpl *prpl;
     301
     302                prpl = find_protocol(proto);
     303
     304                /* Older files saved the protocol number rather then the protocol name */
     305                if (!prpl && atoi(proto)) {
     306                        prpl = find_protocol_by_id(atoi(proto));
     307                }
     308
     309                if (!prpl)
     310                        continue;
     311
    285312                http_decode( s );
    286                 nick_set( irc, s, proto, nick );
     313                nick_set( irc, s, prpl, nick );
    287314        }
    288315        fclose( fp );
     
    339366                s[169] = 0; /* Prevent any overflow (169 ~ 512 / 3) */
    340367                http_encode( s );
    341                 g_snprintf( s + strlen( s ), 510 - strlen( s ), " %d %s", n->proto, n->nick );
     368                g_snprintf( s + strlen( s ), 510 - strlen( s ), " %s %s", n->proto->name, n->nick );
    342369                if( fprintf( fp, "%s\n", s ) != strlen( s ) + 1 )
    343370                {
     
    381408        for( a = irc->accounts; a; a = a->next )
    382409        {
    383                 if( a->protocol == PROTO_OSCAR || a->protocol == PROTO_ICQ || a->protocol == PROTO_TOC )
     410                if( !strcmp( a->prpl->name, "oscar" ) )
    384411                        g_snprintf( s, sizeof( s ), "account add oscar \"%s\" \"%s\" %s", a->user, a->pass, a->server );
    385412                else
    386413                        g_snprintf( s, sizeof( s ), "account add %s \"%s\" \"%s\" \"%s\"",
    387                                     proto_name[a->protocol], a->user, a->pass, a->server ? a->server : "" );
     414                                    a->prpl->name, a->user, a->pass, a->server ? a->server : "" );
    388415               
    389416                line = obfucrypt( irc, s );
  • commands.c

    rfe51bcf r7b23afd  
    185185        if( g_strcasecmp( cmd[1], "add" ) == 0 )
    186186        {
    187                 int prot;
     187                struct prpl *prpl;
    188188               
    189189                if( cmd[2] == NULL || cmd[3] == NULL || cmd[4] == NULL )
     
    193193                }
    194194               
    195                 for( prot = 0; prot < PROTO_MAX; prot ++ )
    196                         if( proto_name[prot] && *proto_name[prot] && g_strcasecmp( proto_name[prot], cmd[2] ) == 0 )
    197                                 break;
    198                
    199                 if( ( prot == PROTO_MAX ) || ( proto_prpl[prot] == NULL ) )
     195                prpl = find_protocol(cmd[2]);
     196               
     197                if( prpl == NULL )
    200198                {
    201199                        irc_usermsg( irc, "Unknown protocol" );
     
    203201                }
    204202
    205                 if( prot == PROTO_OSCAR && cmd[5] == NULL )
    206                 {
    207                         irc_usermsg( irc, "Not enough parameters" );
    208                         return( 0 );
    209                 }
    210                
    211                 a = account_add( irc, prot, cmd[3], cmd[4] );
     203                a = account_add( irc, prpl, cmd[3], cmd[4] );
    212204               
    213205                if( cmd[5] )
     
    253245                                con = "";
    254246                       
    255                         if( a->protocol == PROTO_OSCAR || a->protocol == PROTO_ICQ || a->protocol == PROTO_TOC )
    256                                 irc_usermsg( irc, "%2d. OSCAR, %s on %s%s", i, a->user, a->server, con );
    257                         else
    258                                 irc_usermsg( irc, "%2d. %s, %s%s", i, proto_name[a->protocol], a->user, con );
     247                        irc_usermsg( irc, "%2d. %s, %s%s", i, a->prpl->name, a->user, con );
    259248                       
    260249                        i ++;
     
    373362                else
    374363                {
    375                         nick_set( irc, cmd[2], a->gc->protocol, cmd[3] );
     364                        nick_set( irc, cmd[2], a->gc->prpl, cmd[3] );
    376365                }
    377366        }
     
    454443        else if( u->send_handler == buddy_send_handler )
    455444        {
    456                 nick_set( irc, u->handle, u->gc->protocol, cmd[2] );
     445                nick_set( irc, u->handle, u->gc->prpl, cmd[2] );
    457446        }
    458447       
     
    665654        if( online == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away )
    666655        {
    667                 g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
     656                g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name );
    668657                irc_usermsg( irc, "%-16.16s  %-40.40s  %s", u->nick, s, "Online" );
    669658                n_online ++;
     
    672661        if( away == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away )
    673662        {
    674                 g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
     663                g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name );
    675664                irc_usermsg( irc, "%-16.16s  %-40.40s  %s", u->nick, s, u->away );
    676665                n_away ++;
     
    679668        if( offline == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && !u->online )
    680669        {
    681                 g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
     670                g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name );
    682671                irc_usermsg( irc, "%-16.16s  %-40.40s  %s", u->nick, s, "Offline" );
    683672                n_offline ++;
     
    785774        for( n = gc->irc->nicks; n; n = n->next )
    786775        {
    787                 if( n->proto == gc->protocol && !user_findhandle( gc, n->handle ) )
     776                if( n->proto == gc->prpl && !user_findhandle( gc, n->handle ) )
    788777                {
    789778                        gc->prpl->add_buddy( gc, n->handle );
  • configure

    rfe51bcf r7b23afd  
    1414datadir='$prefix/share/bitlbee/'
    1515config='/var/lib/bitlbee/'
     16plugindir='$prefix/lib/bitlbee'
    1617
    1718msn=1
     
    4546--mandir=...                                            $mandir
    4647--datadir=...                                           $datadir
     48--plugindir=...                                         $plugindir
    4749--config=...                                            $config
    4850
     
    7375datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
    7476config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
     77plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
    7578
    7679cat<<EOF>Makefile.settings
     
    8184MANDIR=$mandir
    8285DATADIR=$datadir
     86PLUGINDIR=$plugindir
    8387CONFIG=$config
    8488
     
    101105#define ETCDIR "$etcdir"
    102106#define VARDIR "$datadir"
     107#define PLUGINDIR "$plugindir"
    103108#define ARCH "$arch"
    104109#define CPU "$cpu"
     
    141146if type pkg-config > /dev/null 2>/dev/null && pkg-config glib-2.0; then
    142147        cat<<EOF>>Makefile.settings
    143 EFLAGS+=`pkg-config --libs glib-2.0`
    144 CFLAGS+=`pkg-config --cflags glib-2.0`
     148EFLAGS+=`pkg-config --libs glib-2.0 gmodule-2.0`
     149CFLAGS+=`pkg-config --cflags glib-2.0 gmodule-2.0`
    145150EOF
    146151        echo '#define GLIB2' >> config.h
  • irc.c

    rfe51bcf r7b23afd  
    11531153                if( u->gc )
    11541154                        irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->user->username,
    1155                                    *u->gc->user->proto_opt[0] ? u->gc->user->proto_opt[0] : "", proto_name[u->gc->user->protocol] );
     1155                                   *u->gc->user->proto_opt[0] ? u->gc->user->proto_opt[0] : "", u->gc->prpl->name );
    11561156                else
    11571157                        irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO );
  • nick.c

    rfe51bcf r7b23afd  
    2727#include "bitlbee.h"
    2828
    29 void nick_set( irc_t *irc, char *handle, int proto, char *nick )
     29void nick_set( irc_t *irc, char *handle, struct prpl *proto, char *nick )
    3030{
    3131        nick_t *m = NULL, *n = irc->nicks;
     
    5656}
    5757
    58 char *nick_get( irc_t *irc, char *handle, int proto, const char *realname )
     58char *nick_get( irc_t *irc, char *handle, struct prpl *proto, const char *realname )
    5959{
    6060        static char nick[MAX_NICK_LENGTH+1];
  • nick.h

    rfe51bcf r7b23afd  
    2727{
    2828        char *handle;
    29         int proto;
     29        struct prpl *proto;
    3030        char *nick;
    3131        struct __NICK *next;
    3232} nick_t;
    3333
    34 void nick_set( irc_t *irc, char *handle, int proto, char *nick );
    35 char *nick_get( irc_t *irc, char *handle, int proto, const char *realname );
     34void nick_set( irc_t *irc, char *handle, struct prpl *proto, char *nick );
     35char *nick_get( irc_t *irc, char *handle, struct prpl *proto, const char *realname );
    3636void nick_del( irc_t *irc, char *nick );
    3737void nick_strip( char *nick );
  • protocols/jabber/jabber.c

    rfe51bcf r7b23afd  
    157157#define JCS_CLOSED  3   /* closed */
    158158
    159 
    160 static char *jabber_name()
    161 {
    162         return "Jabber";
    163 }
    164159
    165160#define STATE_EVT(arg) if(gjc->on_state) { (gjc->on_state)(gjc, (arg) ); }
     
    24132408}
    24142409
    2415 static struct prpl *my_protocol = NULL;
    2416 
    2417 void jabber_init(struct prpl *ret)
    2418 {
     2410
     2411void jabber_init()
     2412{
     2413        struct prpl *ret = g_new0(struct prpl, 1);
     2414
    24192415        /* the NULL's aren't required but they're nice to have */
    2420         ret->protocol = PROTO_JABBER;
    2421         ret->name = jabber_name;
     2416        ret->name = "jabber";
    24222417        ret->away_states = jabber_away_states;
    24232418        ret->actions = jabber_actions;
     
    24422437        ret->group_buddy = jabber_group_change;
    24432438
    2444         my_protocol = ret;
    2445 }
     2439        register_protocol (ret);
     2440}
  • protocols/msn/msn.c

    rfe51bcf r7b23afd  
    2626#include "nogaim.h"
    2727#include "msn.h"
    28 
    29 static struct prpl *my_protocol = NULL;
    3028
    3129static void msn_login( struct aim_user *acct )
     
    375373}
    376374
    377 void msn_init(struct prpl *ret)
    378 {
    379         ret->protocol = PROTO_MSN;
     375void msn_init()
     376{
     377        struct prpl *ret = g_new0(struct prpl, 1);
     378        ret->name = "msn";
    380379        ret->login = msn_login;
    381380        ret->close = msn_close;
     
    399398        ret->send_typing = msn_send_typing;
    400399
    401         my_protocol = ret;
    402 }
     400        register_protocol(ret);
     401}
  • protocols/nogaim.c

    rfe51bcf r7b23afd  
    3939#include <iconv.h>
    4040
    41 struct prpl *proto_prpl[PROTO_MAX];
    42 char proto_name[PROTO_MAX][8] = { "TOC", "OSCAR", "YAHOO", "ICQ", "MSN", "", "", "", "JABBER", "", "", "", "", "", "", "" };
    43 
    4441static char *proto_away_alias[7][5] =
    4542{
     
    5855GSList *connections;
    5956
     57gboolean load_plugin(char *path)
     58{
     59        void (*init_function) (void);
     60       
     61        GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY);
     62
     63        if(!mod) {
     64                log_message(LOGLVL_ERROR, "Can't find `%s', not loading", path);
     65                return FALSE;
     66        }
     67
     68        if(!g_module_symbol(mod,"init_plugin",(gpointer *) &init_function)) {
     69                log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path);
     70                return FALSE;
     71        }
     72
     73        init_function();
     74
     75        return TRUE;
     76}
    6077
    6178/* nogaim.c */
    6279
     80GList *protocols = NULL;
     81 
     82void register_protocol (struct prpl *p)
     83{
     84        protocols = g_list_append(protocols, p);
     85}
     86
     87 
     88struct prpl *find_protocol(const char *name)
     89{
     90        GList *gl;
     91        for (gl = protocols; gl; gl = gl->next)
     92        {
     93                struct prpl *proto = gl->data;
     94                if(!g_strcasecmp(proto->name, name))
     95                        return proto;
     96        }
     97        return NULL;
     98}
     99
     100/* nogaim.c */
    63101void nogaim_init()
    64102{
    65         proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 );
     103        GDir *dir;
     104        GError *error = NULL;
     105
    66106#ifdef WITH_MSN
    67         msn_init( proto_prpl[PROTO_MSN] );
     107        extern void msn_init();
     108        msn_init();
    68109#endif
    69110
    70         proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );
    71111#ifdef WITH_OSCAR
    72         oscar_init( proto_prpl[PROTO_OSCAR] );
     112        extern void oscar_init();
     113        oscar_init();
    73114#endif
    74115       
    75         proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );
    76116#ifdef WITH_YAHOO
    77         byahoo_init( proto_prpl[PROTO_YAHOO] );
     117        extern void byahoo_init();
     118        byahoo_init();
    78119#endif
    79120       
    80         proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );
    81121#ifdef WITH_JABBER
    82         jabber_init( proto_prpl[PROTO_JABBER] );
     122        extern void jabber_init();
     123        jabber_init();
    83124#endif
     125
     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        }
    84146}
    85147
     
    122184                        gc->prpl->set_away( gc, s, away );
    123185                        if( set_getint( gc->irc, "debug" ) )
    124                                 irc_usermsg( gc->irc, "Setting away state for %s to %s", proto_name[gc->protocol], s );
     186                                irc_usermsg( gc->irc, "Setting away state for %s to %s", gc->prpl->name, s );
    125187                }
    126188                else
     
    168230   way for now because I don't want to touch the Gaim code too much since
    169231   it's not going to be here for too long anymore. */
    170 int handle_cmp( char *a, char *b, int protocol )
    171 {
    172         if( protocol == PROTO_TOC || protocol == PROTO_ICQ )
     232int handle_cmp( char *a, char *b, struct prpl *protocol )
     233{
     234        if( !strcmp(protocol->name, "oscar") )
    173235        {
    174236                /* AIM, being teh evil, thinks it's cool that users can put
     
    210272        gc = g_new0( struct gaim_connection, 1 );
    211273       
    212         gc->protocol = user->protocol;
    213         gc->prpl = proto_prpl[gc->protocol];
     274        gc->prpl = user->prpl;
    214275        g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );
    215276        g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );
     
    254315void set_login_progress( struct gaim_connection *gc, int step, char *msg )
    255316{
    256         irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", proto_name[gc->protocol], gc->username, msg );
     317        irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", gc->prpl->name, gc->username, msg );
    257318}
    258319
     
    260321void hide_login_progress( struct gaim_connection *gc, char *msg )
    261322{
    262         irc_usermsg( gc->irc, "%s(%s) - Login error: %s", proto_name[gc->protocol], gc->username, msg );
     323        irc_usermsg( gc->irc, "%s(%s) - Login error: %s", gc->prpl->name, gc->username, msg );
    263324}
    264325
     
    266327void hide_login_progress_error( struct gaim_connection *gc, char *msg )
    267328{
    268         irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", proto_name[gc->protocol], gc->username, msg );
     329        irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", gc->prpl->name, gc->username, msg );
    269330}
    270331
     
    289350                strip_html( msg );
    290351       
    291         irc_usermsg( gc->irc, "%s(%s) - %s", proto_name[gc->protocol], gc->username, msg );
     352        irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, msg );
    292353}
    293354
     
    314375        u = user_find( gc->irc, gc->irc->nick );
    315376       
    316         irc_usermsg( gc->irc, "%s(%s) - Logged in", proto_name[gc->protocol], gc->username );
     377        irc_usermsg( gc->irc, "%s(%s) - Logged in", gc->prpl->name, gc->username );
    317378       
    318379        gc->keepalive = g_timeout_add( 60000, send_keepalive, gc );
     
    321382        if( u && u->away ) proto_away( gc, u->away );
    322383       
    323         if( gc->protocol == PROTO_ICQ )
     384        if( !strcmp(gc->prpl->name, "icq") )
    324385        {
    325386                for( u = gc->irc->users; u; u = u->next )
     
    361422        account_t *a;
    362423       
    363         irc_usermsg( gc->irc, "%s(%s) - Signing off..", proto_name[gc->protocol], gc->username );
     424        irc_usermsg( gc->irc, "%s(%s) - Signing off..", gc->prpl->name, gc->username );
    364425
    365426        gaim_input_remove( gc->keepalive );
     
    393454        {
    394455                int delay = set_getint( irc, "auto_reconnect_delay" );
    395                 irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", proto_name[gc->protocol], gc->username, delay);
     456                irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", gc->prpl->name, gc->username, delay);
    396457               
    397458                a->reconnect = 1;
     
    449510       
    450511        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    451         strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) );
     512        strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
    452513       
    453514        u = user_add( gc->irc, nick );
     
    473534        else
    474535        {
    475                 u->host = g_strdup( proto_name[gc->user->protocol] );
     536                u->host = g_strdup( gc->user->prpl->name );
    476537                u->user = g_strdup( handle );
    477538        }
     
    567628                        if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 )
    568629                        {
    569                                 irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username );
     630                                irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, gc->prpl->name, gc->username );
    570631                                irc_usermsg( gc->irc, "loggedin = %d, type = %d", loggedin, type );
    571632                        }
     
    602663        }
    603664       
    604         if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) )
     665        if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
    605666        {
    606667                u->away = g_strdup( "Away" );
    607668        }
    608         else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) )
     669        else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
    609670        {
    610671                if( type & UC_DND )
     
    648709                {
    649710                        if( set_getint( irc, "debug" ) )
    650                                 irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, proto_name[gc->protocol], gc->username );
     711                                irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, gc->prpl->name, gc->username );
    651712                       
    652713                        return;
     
    670731                else
    671732                {
    672                         irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username );
     733                        irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, gc->prpl->name, gc->username );
    673734                        u = user_find( irc, irc->mynick );
    674735                }
     
    836897       
    837898        /* It might be yourself! */
    838         if( handle_cmp ( handle, b->gc->user->username, b->gc->protocol ) == 0 )
     899        if( handle_cmp ( handle, b->gc->user->username, b->gc->prpl ) == 0 )
    839900        {
    840901                u = user_find( b->gc->irc, b->gc->irc->nick );
  • protocols/nogaim.h

    rfe51bcf r7b23afd  
    7272        /* we need to do either oscar or TOC */
    7373        /* we make this as an int in case if we want to add more protocols later */
    74         int protocol;
    7574        struct prpl *prpl;
    7675        guint32 flags;
     
    152151        char user_info[2048];
    153152        int options;
    154         int protocol;
     153        struct prpl *prpl;
    155154        /* prpls can use this to save information about the user,
    156155         * like which server to connect to, etc */
     
    161160};
    162161
     162struct ft
     163{
     164        const char *filename;
     165       
     166        /* Total number of bytes in file */
     167        size_t total_bytes;
     168       
     169        /* Current number of bytes received */
     170        size_t cur_bytes;
     171};
     172
     173struct ft_request
     174{
     175        const char *filename;
     176        struct gaim_connection *gc;
     177};
     178
     179typedef void (*ft_recv_handler) (struct ft *, void *data, size_t len);
     180
    163181struct prpl {
    164         int protocol;
    165182        int options;
    166         char *(* name)();
     183        const char *name;
    167184
    168185        /* for ICQ and Yahoo, who have off/on per-conversation options */
     
    217234        void (* group_buddy)    (struct gaim_connection *, char *who, char *old_group, char *new_group);
    218235
     236        /* file transfers */
     237        struct ft_send_req *(* req_send_file) (struct gaim_connection *, const char *file);
     238        void (* send_file_part) (struct gaim_connection *, struct ft*, void *data, size_t length);
     239        void (* accept_recv_file) (struct gaim_connection *, struct ft*, ft_recv_handler);
     240
    219241        void (* buddy_free)     (struct buddy *);
    220242
    221243        char *(* get_status_string) (struct gaim_connection *gc, int stat);
    222244};
    223 
    224 #define PROTO_TOC       0
    225 #define PROTO_OSCAR     1
    226 #define PROTO_YAHOO     2
    227 #define PROTO_ICQ       3
    228 #define PROTO_MSN       4
    229 #define PROTO_IRC       5
    230 #define PROTO_FTP       6
    231 #define PROTO_VGATE     7
    232 #define PROTO_JABBER    8
    233 #define PROTO_NAPSTER   9
    234 #define PROTO_ZEPHYR    10
    235 #define PROTO_GADUGADU  11
    236 #define PROTO_MAX       16
    237 
    238 extern char proto_name[PROTO_MAX][8];
    239245
    240246#define UC_UNAVAILABLE  1
     
    247253
    248254G_MODULE_EXPORT GSList *get_connections();
    249 extern struct prpl *proto_prpl[16];
     255G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
     256G_MODULE_EXPORT void register_protocol(struct prpl *);
    250257
    251258/* nogaim.c */
     
    259266int proto_away( struct gaim_connection *gc, char *away );
    260267char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
    261 int handle_cmp( char *a, char *b, int protocol );
     268int handle_cmp( char *a, char *b, struct prpl *protocol );
    262269
    263270gboolean auto_reconnect( gpointer data );
     
    318325G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value);
    319326
    320 #ifdef WITH_MSN
    321 /* msn.c */
    322 G_MODULE_EXPORT void msn_init( struct prpl *ret );
    323 #endif
    324 
    325 #ifdef WITH_OSCAR
    326 /* oscar.c */
    327 G_MODULE_EXPORT void oscar_init( struct prpl *ret );
    328 #endif
    329 
    330 #ifdef WITH_JABBER
    331 /* jabber.c */
    332 G_MODULE_EXPORT void jabber_init( struct prpl *ret );
    333 #endif
    334 
    335 #ifdef WITH_YAHOO
    336 /* yahoo.c */
    337 G_MODULE_EXPORT void byahoo_init( struct prpl *ret );
    338 #endif
     327/* file transfers */
     328G_MODULE_EXPORT void ft_progress( struct ft *, int);
     329G_MODULE_EXPORT void ft_incoming( struct ft_request * );
     330G_MODULE_EXPORT void ft_accepted( struct ft_request *, struct ft *);
     331G_MODULE_EXPORT void ft_denied( struct ft_request *, const char *reason);
    339332
    340333/* prefs.c */
  • protocols/oscar/oscar.c

    rfe51bcf r7b23afd  
    364364                odata->icq = TRUE;
    365365                /* this is odd but it's necessary for a proper do_import and do_export */
    366                 gc->protocol = PROTO_ICQ;
    367366                gc->password[8] = 0;
    368367        } else {
    369                 gc->protocol = PROTO_TOC;
    370368                gc->flags |= OPT_CONN_HTML;
    371369        }
     
    24672465}
    24682466
    2469 static struct prpl *my_protocol = NULL;
    2470 
    2471 void oscar_init(struct prpl *ret) {
    2472         ret->protocol = PROTO_OSCAR;
     2467void oscar_init()
     2468{
     2469        struct prpl *ret = g_new0(struct prpl, 1);
     2470        ret->name = "oscar";
    24732471        ret->away_states = oscar_away_states;
    24742472        ret->login = oscar_login;
     
    24882486        ret->get_status_string = oscar_get_status_string;
    24892487
    2490         my_protocol = ret;
    2491 }
     2488        register_protocol(ret);
     2489}
  • protocols/proxy.c

    rfe51bcf r7b23afd  
    5050#define GAIM_ERR_COND   (G_IO_HUP | G_IO_ERR | G_IO_NVAL)
    5151
    52 /*FIXME*               
    53         #ifndef _WIN32
    54                 if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
    55                         closesocket(fd);
    56                         g_free(phb);
    57                         return -1;
    58                 }
    59                 fcntl(fd, F_SETFL, 0);
    60 #endif*/
    61 
    6252char proxyhost[128] = "";
    6353int proxyport = 0;
  • protocols/yahoo/yahoo.c

    rfe51bcf r7b23afd  
    6464};
    6565
    66 static char *yahoo_name()
    67 {
    68         return "Yahoo";
    69 }
    70 
    71 static struct prpl *my_protocol = NULL;
    7266static GSList *byahoo_inputs = NULL;
    7367static int byahoo_chat_id = 0;
     
    396390}
    397391
    398 void byahoo_init( struct prpl *ret )
    399 {
    400         ret->protocol = PROTO_YAHOO;
    401         ret->name = yahoo_name;
     392void byahoo_init( )
     393{
     394        struct prpl *ret = g_new0(struct prpl, 1);
     395        ret->name = "yahoo";
    402396       
    403397        ret->login = byahoo_login;
    404398        ret->close = byahoo_close;
    405399        ret->send_im = byahoo_send_im;
    406         ret->send_typing = byahoo_send_typing;
    407400        ret->get_info = byahoo_get_info;
    408401        ret->away_states = byahoo_away_states;
     
    412405        ret->remove_buddy = byahoo_remove_buddy;
    413406        ret->get_status_string = byahoo_get_status_string;
     407        ret->send_typing = byahoo_send_typing;
    414408       
    415409        ret->chat_send = byahoo_chat_send;
     
    418412        ret->chat_open = byahoo_chat_open;
    419413       
    420         my_protocol = ret;
     414        register_protocol(ret);
    421415}
    422416
     
    432426                yd = gc->proto_data;
    433427               
    434                 if( gc->protocol == PROTO_YAHOO && yd->y2_id == id )
     428                if( !strcmp(gc->prpl->name, "yahoo") && yd->y2_id == id )
    435429                        return( gc );
    436430        }
  • query.c

    rfe51bcf r7b23afd  
    149149{
    150150        if( q->gc )
    151                 irc_usermsg( irc, "Question on %s connection (handle %s):", proto_name[q->gc->protocol], q->gc->username );
     151                irc_usermsg( irc, "Question on %s connection (handle %s):", q->gc->prpl->name, q->gc->username );
    152152        else
    153153                irc_usermsg( irc, "Question:" );
  • unix.c

    rfe51bcf r7b23afd  
    4848       
    4949        log_init( );
    50         nogaim_init( );
    51        
     50
     51        nogaim_init();
     52
    5253        CONF_FILE = g_strdup( CONF_FILE_DEF );
    5354       
  • url.h

    rfe51bcf r7b23afd  
    2626#include "bitlbee.h"
    2727
    28 #define PROTO_HTTP      2
     28#define PROTO_FTP               1
     29#define PROTO_HTTP              2
    2930#define PROTO_SOCKS4    3
    3031#define PROTO_SOCKS5    4
  • user.c

    rfe51bcf r7b23afd  
    146146        while( u )
    147147        {
    148                 if( u->gc == gc && u->handle && handle_cmp( u->handle, handle, gc->protocol ) == 0 )
     148                if( u->gc == gc && u->handle && handle_cmp( u->handle, handle, gc->prpl) == 0 )
    149149                        break;
    150150                u = u->next;
Note: See TracChangeset for help on using the changeset viewer.