Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    rd636233 r4bfca70  
    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
     57#ifdef WITH_PLUGINS
     58gboolean 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
     79void load_plugins(void)
     80{
     81        GDir *dir;
     82        GError *error = NULL;
     83
     84        dir = g_dir_open(global.conf->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(global.conf->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
    60106
    61107/* nogaim.c */
    62108
     109GList *protocols = NULL;
     110 
     111void register_protocol (struct prpl *p)
     112{
     113        protocols = g_list_append(protocols, p);
     114}
     115
     116 
     117struct 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 */
    63130void nogaim_init()
    64131{
    65         proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 );
     132        extern void msn_init();
     133        extern void oscar_init();
     134        extern void byahoo_init();
     135        extern void jabber_init();
     136
    66137#ifdef WITH_MSN
    67         msn_init( proto_prpl[PROTO_MSN] );
     138        msn_init();
    68139#endif
    69140
    70         proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );
    71141#ifdef WITH_OSCAR
    72         oscar_init( proto_prpl[PROTO_OSCAR] );
     142        oscar_init();
    73143#endif
    74144       
    75         proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );
    76145#ifdef WITH_YAHOO
    77         byahoo_init( proto_prpl[PROTO_YAHOO] );
     146        byahoo_init();
    78147#endif
    79148       
    80         proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );
    81149#ifdef WITH_JABBER
    82         jabber_init( proto_prpl[PROTO_JABBER] );
     150        jabber_init();
     151#endif
     152
     153#ifdef WITH_PLUGINS
     154        load_plugins();
    83155#endif
    84156}
     
    172244        gc = g_new0( struct gaim_connection, 1 );
    173245       
    174         gc->protocol = user->protocol;
    175         gc->prpl = proto_prpl[gc->protocol];
     246        gc->prpl = user->prpl;
    176247        g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );
    177248        g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );
     
    254325        /* Try to find a different connection on the same protocol. */
    255326        for( a = gc->irc->accounts; a; a = a->next )
    256                 if( proto_prpl[a->protocol] == gc->prpl && a->gc != gc )
     327                if( a->prpl == gc->prpl && a->gc != gc )
    257328                        break;
    258329       
    259330        /* If we found one, add the screenname to the acc_id. */
    260331        if( a )
    261                 g_snprintf( acc_id, 32, "%s(%s)", proto_name[gc->protocol], gc->username );
     332                g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username );
    262333        else
    263                 g_snprintf( acc_id, 32, "%s", proto_name[gc->protocol] );
     334                g_snprintf( acc_id, 32, "%s", gc->prpl->name );
    264335       
    265336        irc_usermsg( gc->irc, "%s - %s", acc_id, msg );
     
    295366        if( u && u->away ) proto_away( gc, u->away );
    296367       
    297         if( gc->protocol == PROTO_ICQ )
     368        if( !strcmp(gc->prpl->name, "icq") )
    298369        {
    299370                for( u = gc->irc->users; u; u = u->next )
     
    430501       
    431502        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    432         strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) );
     503        strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
    433504       
    434505        u = user_add( gc->irc, nick );
     
    454525        else
    455526        {
    456                 u->host = g_strdup( proto_name[gc->user->protocol] );
     527                u->host = g_strdup( gc->user->prpl->name );
    457528                u->user = g_strdup( handle );
    458529        }
     
    583654        }
    584655       
    585         if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) )
     656        if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
    586657        {
    587658                u->away = g_strdup( "Away" );
    588659        }
    589         else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) )
     660        else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
    590661        {
    591662                if( type & UC_DND )
     
    697768}
    698769
    699 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 )
    700771{
    701772        user_t *u;
     
    704775                return;
    705776       
    706         if( ( u = user_findhandle( gc, handle ) ) )
    707                 irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\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        }
    708789}
    709790
Note: See TracChangeset for help on using the changeset viewer.