Changes in protocols/nogaim.c [dfde8e0:65e2ce1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
rdfde8e0 r65e2ce1 39 39 #include <iconv.h> 40 40 41 struct prpl *proto_prpl[PROTO_MAX];42 char proto_name[PROTO_MAX][8] = { "TOC", "OSCAR", "YAHOO", "ICQ", "MSN", "", "", "", "JABBER", "", "", "", "", "", "", "" };43 44 41 static char *proto_away_alias[7][5] = 45 42 { … … 58 55 GSList *connections; 59 56 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 } 105 #endif 60 106 61 107 /* nogaim.c */ 62 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 */ 63 130 void nogaim_init() 64 131 { 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 66 137 #ifdef WITH_MSN 67 msn_init( proto_prpl[PROTO_MSN]);138 msn_init(); 68 139 #endif 69 140 70 proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );71 141 #ifdef WITH_OSCAR 72 oscar_init( proto_prpl[PROTO_OSCAR]);142 oscar_init(); 73 143 #endif 74 144 75 proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );76 145 #ifdef WITH_YAHOO 77 byahoo_init( proto_prpl[PROTO_YAHOO]);146 byahoo_init(); 78 147 #endif 79 148 80 proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );81 149 #ifdef WITH_JABBER 82 jabber_init( proto_prpl[PROTO_JABBER] ); 150 jabber_init(); 151 #endif 152 153 #ifdef WITH_PLUGINS 154 load_plugins(); 83 155 #endif 84 156 } … … 172 244 gc = g_new0( struct gaim_connection, 1 ); 173 245 174 gc->protocol = user->protocol; 175 gc->prpl = proto_prpl[gc->protocol]; 246 gc->prpl = user->prpl; 176 247 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); 177 248 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); … … 254 325 /* Try to find a different connection on the same protocol. */ 255 326 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 ) 257 328 break; 258 329 259 330 /* If we found one, add the screenname to the acc_id. */ 260 331 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 ); 262 333 else 263 g_snprintf( acc_id, 32, "%s", proto_name[gc->protocol]);334 g_snprintf( acc_id, 32, "%s", gc->prpl->name ); 264 335 265 336 irc_usermsg( gc->irc, "%s - %s", acc_id, msg ); … … 295 366 if( u && u->away ) proto_away( gc, u->away ); 296 367 297 if( gc->protocol == PROTO_ICQ)368 if( !strcmp(gc->prpl->name, "icq") ) 298 369 { 299 370 for( u = gc->irc->users; u; u = u->next ) … … 423 494 424 495 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 425 strcpy( nick, nick_get( gc->irc, handle, gc->pr otocol, realname ) );496 strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) ); 426 497 427 498 u = user_add( gc->irc, nick ); … … 447 518 else 448 519 { 449 u->host = g_strdup( proto_name[gc->user->protocol]);520 u->host = g_strdup( gc->user->prpl->name ); 450 521 u->user = g_strdup( handle ); 451 522 } … … 576 647 } 577 648 578 if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC) )649 if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) ) 579 650 { 580 651 u->away = g_strdup( "Away" ); 581 652 } 582 else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER) )653 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) ) 583 654 { 584 655 if( type & UC_DND )
Note: See TracChangeset
for help on using the changeset viewer.