Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r65e2ce1 rd636233  
    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 #ifdef WITH_PLUGINS
    58 gboolean load_plugin(char *path)
    59 {
    60         void (*init_function) (void);
    61        
    62         GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY);
    63 
    64         if(!mod) {
    65                 log_message(LOGLVL_ERROR, "Can't find `%s', not loading", path);
    66                 return FALSE;
    67         }
    68 
    69         if(!g_module_symbol(mod,"init_plugin",(gpointer *) &init_function)) {
    70                 log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path);
    71                 return FALSE;
    72         }
    73 
    74         init_function();
    75 
    76         return TRUE;
    77 }
    78 
    79 void 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 }
     60
     61/* nogaim.c */
     62
     63void nogaim_init()
     64{
     65        proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 );
     66#ifdef WITH_MSN
     67        msn_init( proto_prpl[PROTO_MSN] );
    10568#endif
    10669
    107 /* nogaim.c */
    108 
    109 GList *protocols = NULL;
    110  
    111 void register_protocol (struct prpl *p)
    112 {
    113         protocols = g_list_append(protocols, p);
    114 }
    115 
    116  
    117 struct prpl *find_protocol(const char *name)
    118 {
    119         GList *gl;
    120         for (gl = protocols; gl; gl = gl->next)
    121         {
    122                 struct prpl *proto = gl->data;
    123                 if(!g_strcasecmp(proto->name, name))
    124                         return proto;
    125         }
    126         return NULL;
    127 }
    128 
    129 /* nogaim.c */
    130 void nogaim_init()
    131 {
    132         extern void msn_init();
    133         extern void oscar_init();
    134         extern void byahoo_init();
    135         extern void jabber_init();
    136 
    137 #ifdef WITH_MSN
    138         msn_init();
     70        proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );
     71#ifdef WITH_OSCAR
     72        oscar_init( proto_prpl[PROTO_OSCAR] );
    13973#endif
    140 
    141 #ifdef WITH_OSCAR
    142         oscar_init();
     74       
     75        proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );
     76#ifdef WITH_YAHOO
     77        byahoo_init( proto_prpl[PROTO_YAHOO] );
    14378#endif
    14479       
    145 #ifdef WITH_YAHOO
    146         byahoo_init();
    147 #endif
    148        
     80        proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );
    14981#ifdef WITH_JABBER
    150         jabber_init();
    151 #endif
    152 
    153 #ifdef WITH_PLUGINS
    154         load_plugins();
     82        jabber_init( proto_prpl[PROTO_JABBER] );
    15583#endif
    15684}
     
    244172        gc = g_new0( struct gaim_connection, 1 );
    245173       
    246         gc->prpl = user->prpl;
     174        gc->protocol = user->protocol;
     175        gc->prpl = proto_prpl[gc->protocol];
    247176        g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );
    248177        g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );
     
    325254        /* Try to find a different connection on the same protocol. */
    326255        for( a = gc->irc->accounts; a; a = a->next )
    327                 if( a->prpl == gc->prpl && a->gc != gc )
     256                if( proto_prpl[a->protocol] == gc->prpl && a->gc != gc )
    328257                        break;
    329258       
    330259        /* If we found one, add the screenname to the acc_id. */
    331260        if( a )
    332                 g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username );
     261                g_snprintf( acc_id, 32, "%s(%s)", proto_name[gc->protocol], gc->username );
    333262        else
    334                 g_snprintf( acc_id, 32, "%s", gc->prpl->name );
     263                g_snprintf( acc_id, 32, "%s", proto_name[gc->protocol] );
    335264       
    336265        irc_usermsg( gc->irc, "%s - %s", acc_id, msg );
     
    366295        if( u && u->away ) proto_away( gc, u->away );
    367296       
    368         if( !strcmp(gc->prpl->name, "icq") )
     297        if( gc->protocol == PROTO_ICQ )
    369298        {
    370299                for( u = gc->irc->users; u; u = u->next )
     
    452381void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )
    453382{
    454         serv_got_crap( gc, "Error: %s", msg );
     383        if( msg && title )
     384                serv_got_crap( gc, "Error: %s: %s", title, msg );
     385        else if( msg )
     386                serv_got_crap( gc, "Error: %s", msg );
     387        else if( title )
     388                serv_got_crap( gc, "Error: %s", title );
     389        else
     390                serv_got_crap( gc, "Error" );
    455391}
    456392
     
    494430       
    495431        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    496         strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
     432        strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) );
    497433       
    498434        u = user_add( gc->irc, nick );
     
    518454        else
    519455        {
    520                 u->host = g_strdup( gc->user->prpl->name );
     456                u->host = g_strdup( proto_name[gc->user->protocol] );
    521457                u->user = g_strdup( handle );
    522458        }
     
    647583        }
    648584       
    649         if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
     585        if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) )
    650586        {
    651587                u->away = g_strdup( "Away" );
    652588        }
    653         else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
     589        else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) )
    654590        {
    655591                if( type & UC_DND )
     
    737673                /* If there's a newline/space in this string, split up there,
    738674                   looks a bit prettier. */
    739                 if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strchr( msg, ' ' ) ) )
     675                if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) )
    740676                {
    741677                        msg[425] = tmp;
     
    769705       
    770706        if( ( u = user_findhandle( gc, handle ) ) )
    771                 irc_msgfrom( gc->irc, u->nick, "\1TYPING 1\1" );
     707                irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\1TYPING 1\1" );
    772708}
    773709
Note: See TracChangeset for help on using the changeset viewer.