Changes in protocols/nogaim.c [7b23afd:06045f6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r7b23afd r06045f6 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 41 44 static char *proto_away_alias[7][5] = 42 45 { … … 55 58 GSList *connections; 56 59 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 }77 60 78 61 /* nogaim.c */ 79 62 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 */101 63 void nogaim_init() 102 64 { 103 GDir *dir; 104 GError *error = NULL; 105 65 proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 ); 106 66 #ifdef WITH_MSN 107 extern void msn_init(); 108 msn_init(); 67 msn_init( proto_prpl[PROTO_MSN] ); 109 68 #endif 110 69 70 proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 ); 111 71 #ifdef WITH_OSCAR 112 extern void oscar_init(); 113 oscar_init(); 72 oscar_init( proto_prpl[PROTO_OSCAR] ); 114 73 #endif 115 74 75 proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 ); 116 76 #ifdef WITH_YAHOO 117 extern void byahoo_init(); 118 byahoo_init(); 77 byahoo_init( proto_prpl[PROTO_YAHOO] ); 119 78 #endif 120 79 80 proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 ); 121 81 #ifdef WITH_JABBER 122 extern void jabber_init(); 123 jabber_init(); 82 jabber_init( proto_prpl[PROTO_JABBER] ); 124 83 #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 }146 84 } 147 85 … … 184 122 gc->prpl->set_away( gc, s, away ); 185 123 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 ); 187 125 } 188 126 else … … 230 168 way for now because I don't want to touch the Gaim code too much since 231 169 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"))170 int handle_cmp( char *a, char *b, int protocol ) 171 { 172 if( protocol == PROTO_TOC || protocol == PROTO_ICQ ) 235 173 { 236 174 /* AIM, being teh evil, thinks it's cool that users can put … … 272 210 gc = g_new0( struct gaim_connection, 1 ); 273 211 274 gc->prpl = user->prpl; 212 gc->protocol = user->protocol; 213 gc->prpl = proto_prpl[gc->protocol]; 275 214 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); 276 215 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); … … 315 254 void set_login_progress( struct gaim_connection *gc, int step, char *msg ) 316 255 { 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 ); 318 257 } 319 258 … … 321 260 void hide_login_progress( struct gaim_connection *gc, char *msg ) 322 261 { 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 ); 324 263 } 325 264 … … 327 266 void hide_login_progress_error( struct gaim_connection *gc, char *msg ) 328 267 { 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 ); 330 269 } 331 270 … … 350 289 strip_html( msg ); 351 290 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 ); 353 292 } 354 293 … … 375 314 u = user_find( gc->irc, gc->irc->nick ); 376 315 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 ); 378 317 379 318 gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); … … 382 321 if( u && u->away ) proto_away( gc, u->away ); 383 322 384 if( !strcmp(gc->prpl->name, "icq"))323 if( gc->protocol == PROTO_ICQ ) 385 324 { 386 325 for( u = gc->irc->users; u; u = u->next ) … … 422 361 account_t *a; 423 362 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 ); 425 364 426 365 gaim_input_remove( gc->keepalive ); … … 454 393 { 455 394 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); 457 396 458 397 a->reconnect = 1; … … 468 407 void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ) 469 408 { 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 ); 471 410 } 472 411 … … 510 449 511 450 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 512 strcpy( nick, nick_get( gc->irc, handle, gc->pr pl, realname ) );451 strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) ); 513 452 514 453 u = user_add( gc->irc, nick ); … … 534 473 else 535 474 { 536 u->host = g_strdup( gc->user->prpl->name);475 u->host = g_strdup( proto_name[gc->user->protocol] ); 537 476 u->user = g_strdup( handle ); 538 477 } … … 628 567 if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 ) 629 568 { 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 ); 631 570 irc_usermsg( gc->irc, "loggedin = %d, type = %d", loggedin, type ); 632 571 } … … 663 602 } 664 603 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 ) ) 666 605 { 667 606 u->away = g_strdup( "Away" ); 668 607 } 669 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber")) )608 else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) ) 670 609 { 671 610 if( type & UC_DND ) … … 709 648 { 710 649 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 ); 712 651 713 652 return; … … 731 670 else 732 671 { 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 ); 734 673 u = user_find( irc, irc->mynick ); 735 674 } … … 897 836 898 837 /* It might be yourself! */ 899 if( handle_cmp ( handle, b->gc->user->username, b->gc->pr pl ) == 0 )838 if( handle_cmp ( handle, b->gc->user->username, b->gc->protocol ) == 0 ) 900 839 { 901 840 u = user_find( b->gc->irc, b->gc->irc->nick );
Note: See TracChangeset
for help on using the changeset viewer.