Changes in protocols/nogaim.c [65e2ce1:d636233]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r65e2ce1 rd636233 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 #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 63 void nogaim_init() 64 { 65 proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 ); 66 #ifdef WITH_MSN 67 msn_init( proto_prpl[PROTO_MSN] ); 105 68 #endif 106 69 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] ); 139 73 #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] ); 143 78 #endif 144 79 145 #ifdef WITH_YAHOO 146 byahoo_init(); 147 #endif 148 80 proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 ); 149 81 #ifdef WITH_JABBER 150 jabber_init(); 151 #endif 152 153 #ifdef WITH_PLUGINS 154 load_plugins(); 82 jabber_init( proto_prpl[PROTO_JABBER] ); 155 83 #endif 156 84 } … … 244 172 gc = g_new0( struct gaim_connection, 1 ); 245 173 246 gc->prpl = user->prpl; 174 gc->protocol = user->protocol; 175 gc->prpl = proto_prpl[gc->protocol]; 247 176 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); 248 177 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); … … 325 254 /* Try to find a different connection on the same protocol. */ 326 255 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 ) 328 257 break; 329 258 330 259 /* If we found one, add the screenname to the acc_id. */ 331 260 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 ); 333 262 else 334 g_snprintf( acc_id, 32, "%s", gc->prpl->name);263 g_snprintf( acc_id, 32, "%s", proto_name[gc->protocol] ); 335 264 336 265 irc_usermsg( gc->irc, "%s - %s", acc_id, msg ); … … 366 295 if( u && u->away ) proto_away( gc, u->away ); 367 296 368 if( !strcmp(gc->prpl->name, "icq"))297 if( gc->protocol == PROTO_ICQ ) 369 298 { 370 299 for( u = gc->irc->users; u; u = u->next ) … … 452 381 void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ) 453 382 { 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" ); 455 391 } 456 392 … … 494 430 495 431 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 496 strcpy( nick, nick_get( gc->irc, handle, gc->pr pl, realname ) );432 strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) ); 497 433 498 434 u = user_add( gc->irc, nick ); … … 518 454 else 519 455 { 520 u->host = g_strdup( gc->user->prpl->name);456 u->host = g_strdup( proto_name[gc->user->protocol] ); 521 457 u->user = g_strdup( handle ); 522 458 } … … 647 583 } 648 584 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 ) ) 650 586 { 651 587 u->away = g_strdup( "Away" ); 652 588 } 653 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber")) )589 else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) ) 654 590 { 655 591 if( type & UC_DND ) … … 737 673 /* If there's a newline/space in this string, split up there, 738 674 looks a bit prettier. */ 739 if( ( nl = strrchr( msg, '\n' ) ) || ( nl = str chr( msg, ' ' ) ) )675 if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) ) 740 676 { 741 677 msg[425] = tmp; … … 769 705 770 706 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" ); 772 708 } 773 709
Note: See TracChangeset
for help on using the changeset viewer.