Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r7b23afd r06045f6  
    3939#include <iconv.h>
    4040
     41struct prpl *proto_prpl[PROTO_MAX];
     42char proto_name[PROTO_MAX][8] = { "TOC", "OSCAR", "YAHOO", "ICQ", "MSN", "", "", "", "JABBER", "", "", "", "", "", "", "" };
     43
    4144static char *proto_away_alias[7][5] =
    4245{
     
    5558GSList *connections;
    5659
    57 gboolean 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 }
    7760
    7861/* nogaim.c */
    7962
    80 GList *protocols = NULL;
    81  
    82 void register_protocol (struct prpl *p)
    83 {
    84         protocols = g_list_append(protocols, p);
    85 }
    86 
    87  
    88 struct 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 */
    10163void nogaim_init()
    10264{
    103         GDir *dir;
    104         GError *error = NULL;
    105 
     65        proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 );
    10666#ifdef WITH_MSN
    107         extern void msn_init();
    108         msn_init();
     67        msn_init( proto_prpl[PROTO_MSN] );
    10968#endif
    11069
     70        proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );
    11171#ifdef WITH_OSCAR
    112         extern void oscar_init();
    113         oscar_init();
     72        oscar_init( proto_prpl[PROTO_OSCAR] );
    11473#endif
    11574       
     75        proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );
    11676#ifdef WITH_YAHOO
    117         extern void byahoo_init();
    118         byahoo_init();
     77        byahoo_init( proto_prpl[PROTO_YAHOO] );
    11978#endif
    12079       
     80        proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );
    12181#ifdef WITH_JABBER
    122         extern void jabber_init();
    123         jabber_init();
     82        jabber_init( proto_prpl[PROTO_JABBER] );
    12483#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         }
    14684}
    14785
     
    184122                        gc->prpl->set_away( gc, s, away );
    185123                        if( set_getint( gc->irc, "debug" ) )
    186                                 irc_usermsg( gc->irc, "Setting away state for %s to %s", gc->prpl->name, s );
     124                                irc_usermsg( gc->irc, "Setting away state for %s to %s", proto_name[gc->protocol], s );
    187125                }
    188126                else
     
    230168   way for now because I don't want to touch the Gaim code too much since
    231169   it's not going to be here for too long anymore. */
    232 int handle_cmp( char *a, char *b, struct prpl *protocol )
    233 {
    234         if( !strcmp(protocol->name, "oscar") )
     170int handle_cmp( char *a, char *b, int protocol )
     171{
     172        if( protocol == PROTO_TOC || protocol == PROTO_ICQ )
    235173        {
    236174                /* AIM, being teh evil, thinks it's cool that users can put
     
    272210        gc = g_new0( struct gaim_connection, 1 );
    273211       
    274         gc->prpl = user->prpl;
     212        gc->protocol = user->protocol;
     213        gc->prpl = proto_prpl[gc->protocol];
    275214        g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );
    276215        g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );
     
    315254void set_login_progress( struct gaim_connection *gc, int step, char *msg )
    316255{
    317         irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", gc->prpl->name, gc->username, msg );
     256        irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", proto_name[gc->protocol], gc->username, msg );
    318257}
    319258
     
    321260void hide_login_progress( struct gaim_connection *gc, char *msg )
    322261{
    323         irc_usermsg( gc->irc, "%s(%s) - Login error: %s", gc->prpl->name, gc->username, msg );
     262        irc_usermsg( gc->irc, "%s(%s) - Login error: %s", proto_name[gc->protocol], gc->username, msg );
    324263}
    325264
     
    327266void hide_login_progress_error( struct gaim_connection *gc, char *msg )
    328267{
    329         irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", gc->prpl->name, gc->username, msg );
     268        irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", proto_name[gc->protocol], gc->username, msg );
    330269}
    331270
     
    350289                strip_html( msg );
    351290       
    352         irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, msg );
     291        irc_usermsg( gc->irc, "%s(%s) - %s", proto_name[gc->protocol], gc->username, msg );
    353292}
    354293
     
    375314        u = user_find( gc->irc, gc->irc->nick );
    376315       
    377         irc_usermsg( gc->irc, "%s(%s) - Logged in", gc->prpl->name, gc->username );
     316        irc_usermsg( gc->irc, "%s(%s) - Logged in", proto_name[gc->protocol], gc->username );
    378317       
    379318        gc->keepalive = g_timeout_add( 60000, send_keepalive, gc );
     
    382321        if( u && u->away ) proto_away( gc, u->away );
    383322       
    384         if( !strcmp(gc->prpl->name, "icq") )
     323        if( gc->protocol == PROTO_ICQ )
    385324        {
    386325                for( u = gc->irc->users; u; u = u->next )
     
    422361        account_t *a;
    423362       
    424         irc_usermsg( gc->irc, "%s(%s) - Signing off..", gc->prpl->name, gc->username );
     363        irc_usermsg( gc->irc, "%s(%s) - Signing off..", proto_name[gc->protocol], gc->username );
    425364
    426365        gaim_input_remove( gc->keepalive );
     
    454393        {
    455394                int delay = set_getint( irc, "auto_reconnect_delay" );
    456                 irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", gc->prpl->name, gc->username, delay);
     395                irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", proto_name[gc->protocol], gc->username, delay);
    457396               
    458397                a->reconnect = 1;
     
    468407void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )
    469408{
    470         irc_usermsg( gc->irc, "%s(%s) - Error: %s", gc->username, title, msg );
     409        irc_usermsg( gc->irc, "%s(%s) - Error: %s", proto_name[gc->protocol], gc->username, msg );
    471410}
    472411
     
    510449       
    511450        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    512         strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
     451        strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) );
    513452       
    514453        u = user_add( gc->irc, nick );
     
    534473        else
    535474        {
    536                 u->host = g_strdup( gc->user->prpl->name );
     475                u->host = g_strdup( proto_name[gc->user->protocol] );
    537476                u->user = g_strdup( handle );
    538477        }
     
    628567                        if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 )
    629568                        {
    630                                 irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, gc->prpl->name, gc->username );
     569                                irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username );
    631570                                irc_usermsg( gc->irc, "loggedin = %d, type = %d", loggedin, type );
    632571                        }
     
    663602        }
    664603       
    665         if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
     604        if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) )
    666605        {
    667606                u->away = g_strdup( "Away" );
    668607        }
    669         else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
     608        else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) )
    670609        {
    671610                if( type & UC_DND )
     
    709648                {
    710649                        if( set_getint( irc, "debug" ) )
    711                                 irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, gc->prpl->name, gc->username );
     650                                irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, proto_name[gc->protocol], gc->username );
    712651                       
    713652                        return;
     
    731670                else
    732671                {
    733                         irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, gc->prpl->name, gc->username );
     672                        irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username );
    734673                        u = user_find( irc, irc->mynick );
    735674                }
     
    897836       
    898837        /* It might be yourself! */
    899         if( handle_cmp ( handle, b->gc->user->username, b->gc->prpl ) == 0 )
     838        if( handle_cmp ( handle, b->gc->user->username, b->gc->protocol ) == 0 )
    900839        {
    901840                u = user_find( b->gc->irc, b->gc->irc->nick );
Note: See TracChangeset for help on using the changeset viewer.