- Timestamp:
- 2005-11-07T16:16:18Z (19 years ago)
- Branches:
- master
- Children:
- f7f3ada
- Parents:
- fe51bcf
- Location:
- protocols
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
rfe51bcf r7b23afd 157 157 #define JCS_CLOSED 3 /* closed */ 158 158 159 160 static char *jabber_name()161 {162 return "Jabber";163 }164 159 165 160 #define STATE_EVT(arg) if(gjc->on_state) { (gjc->on_state)(gjc, (arg) ); } … … 2413 2408 } 2414 2409 2415 static struct prpl *my_protocol = NULL; 2416 2417 void jabber_init(struct prpl *ret) 2418 { 2410 2411 void jabber_init() 2412 { 2413 struct prpl *ret = g_new0(struct prpl, 1); 2414 2419 2415 /* the NULL's aren't required but they're nice to have */ 2420 ret->protocol = PROTO_JABBER; 2421 ret->name = jabber_name; 2416 ret->name = "jabber"; 2422 2417 ret->away_states = jabber_away_states; 2423 2418 ret->actions = jabber_actions; … … 2442 2437 ret->group_buddy = jabber_group_change; 2443 2438 2444 my_protocol = ret;2445 } 2439 register_protocol (ret); 2440 } -
protocols/msn/msn.c
rfe51bcf r7b23afd 26 26 #include "nogaim.h" 27 27 #include "msn.h" 28 29 static struct prpl *my_protocol = NULL;30 28 31 29 static void msn_login( struct aim_user *acct ) … … 375 373 } 376 374 377 void msn_init(struct prpl *ret) 378 { 379 ret->protocol = PROTO_MSN; 375 void msn_init() 376 { 377 struct prpl *ret = g_new0(struct prpl, 1); 378 ret->name = "msn"; 380 379 ret->login = msn_login; 381 380 ret->close = msn_close; … … 399 398 ret->send_typing = msn_send_typing; 400 399 401 my_protocol = ret;402 } 400 register_protocol(ret); 401 } -
protocols/nogaim.c
rfe51bcf r7b23afd 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 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 } 60 77 61 78 /* nogaim.c */ 62 79 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 */ 63 101 void nogaim_init() 64 102 { 65 proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 ); 103 GDir *dir; 104 GError *error = NULL; 105 66 106 #ifdef WITH_MSN 67 msn_init( proto_prpl[PROTO_MSN] ); 107 extern void msn_init(); 108 msn_init(); 68 109 #endif 69 110 70 proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );71 111 #ifdef WITH_OSCAR 72 oscar_init( proto_prpl[PROTO_OSCAR] ); 112 extern void oscar_init(); 113 oscar_init(); 73 114 #endif 74 115 75 proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );76 116 #ifdef WITH_YAHOO 77 byahoo_init( proto_prpl[PROTO_YAHOO] ); 117 extern void byahoo_init(); 118 byahoo_init(); 78 119 #endif 79 120 80 proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );81 121 #ifdef WITH_JABBER 82 jabber_init( proto_prpl[PROTO_JABBER] ); 122 extern void jabber_init(); 123 jabber_init(); 83 124 #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 } 84 146 } 85 147 … … 122 184 gc->prpl->set_away( gc, s, away ); 123 185 if( set_getint( gc->irc, "debug" ) ) 124 irc_usermsg( gc->irc, "Setting away state for %s to %s", proto_name[gc->protocol], s );186 irc_usermsg( gc->irc, "Setting away state for %s to %s", gc->prpl->name, s ); 125 187 } 126 188 else … … 168 230 way for now because I don't want to touch the Gaim code too much since 169 231 it's not going to be here for too long anymore. */ 170 int handle_cmp( char *a, char *b, intprotocol )171 { 172 if( protocol == PROTO_TOC || protocol == PROTO_ICQ)232 int handle_cmp( char *a, char *b, struct prpl *protocol ) 233 { 234 if( !strcmp(protocol->name, "oscar") ) 173 235 { 174 236 /* AIM, being teh evil, thinks it's cool that users can put … … 210 272 gc = g_new0( struct gaim_connection, 1 ); 211 273 212 gc->protocol = user->protocol; 213 gc->prpl = proto_prpl[gc->protocol]; 274 gc->prpl = user->prpl; 214 275 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); 215 276 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); … … 254 315 void set_login_progress( struct gaim_connection *gc, int step, char *msg ) 255 316 { 256 irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", proto_name[gc->protocol], gc->username, msg );317 irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", gc->prpl->name, gc->username, msg ); 257 318 } 258 319 … … 260 321 void hide_login_progress( struct gaim_connection *gc, char *msg ) 261 322 { 262 irc_usermsg( gc->irc, "%s(%s) - Login error: %s", proto_name[gc->protocol], gc->username, msg );323 irc_usermsg( gc->irc, "%s(%s) - Login error: %s", gc->prpl->name, gc->username, msg ); 263 324 } 264 325 … … 266 327 void hide_login_progress_error( struct gaim_connection *gc, char *msg ) 267 328 { 268 irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", proto_name[gc->protocol], gc->username, msg );329 irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", gc->prpl->name, gc->username, msg ); 269 330 } 270 331 … … 289 350 strip_html( msg ); 290 351 291 irc_usermsg( gc->irc, "%s(%s) - %s", proto_name[gc->protocol], gc->username, msg );352 irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, msg ); 292 353 } 293 354 … … 314 375 u = user_find( gc->irc, gc->irc->nick ); 315 376 316 irc_usermsg( gc->irc, "%s(%s) - Logged in", proto_name[gc->protocol], gc->username );377 irc_usermsg( gc->irc, "%s(%s) - Logged in", gc->prpl->name, gc->username ); 317 378 318 379 gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); … … 321 382 if( u && u->away ) proto_away( gc, u->away ); 322 383 323 if( gc->protocol == PROTO_ICQ)384 if( !strcmp(gc->prpl->name, "icq") ) 324 385 { 325 386 for( u = gc->irc->users; u; u = u->next ) … … 361 422 account_t *a; 362 423 363 irc_usermsg( gc->irc, "%s(%s) - Signing off..", proto_name[gc->protocol], gc->username );424 irc_usermsg( gc->irc, "%s(%s) - Signing off..", gc->prpl->name, gc->username ); 364 425 365 426 gaim_input_remove( gc->keepalive ); … … 393 454 { 394 455 int delay = set_getint( irc, "auto_reconnect_delay" ); 395 irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", proto_name[gc->protocol], gc->username, delay);456 irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", gc->prpl->name, gc->username, delay); 396 457 397 458 a->reconnect = 1; … … 449 510 450 511 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 451 strcpy( nick, nick_get( gc->irc, handle, gc->pr otocol, realname ) );512 strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) ); 452 513 453 514 u = user_add( gc->irc, nick ); … … 473 534 else 474 535 { 475 u->host = g_strdup( proto_name[gc->user->protocol]);536 u->host = g_strdup( gc->user->prpl->name ); 476 537 u->user = g_strdup( handle ); 477 538 } … … 567 628 if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 ) 568 629 { 569 irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username );630 irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, gc->prpl->name, gc->username ); 570 631 irc_usermsg( gc->irc, "loggedin = %d, type = %d", loggedin, type ); 571 632 } … … 602 663 } 603 664 604 if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC) )665 if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) ) 605 666 { 606 667 u->away = g_strdup( "Away" ); 607 668 } 608 else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER) )669 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) ) 609 670 { 610 671 if( type & UC_DND ) … … 648 709 { 649 710 if( set_getint( irc, "debug" ) ) 650 irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, proto_name[gc->protocol], gc->username );711 irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, gc->prpl->name, gc->username ); 651 712 652 713 return; … … 670 731 else 671 732 { 672 irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username );733 irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, gc->prpl->name, gc->username ); 673 734 u = user_find( irc, irc->mynick ); 674 735 } … … 836 897 837 898 /* It might be yourself! */ 838 if( handle_cmp ( handle, b->gc->user->username, b->gc->pr otocol ) == 0 )899 if( handle_cmp ( handle, b->gc->user->username, b->gc->prpl ) == 0 ) 839 900 { 840 901 u = user_find( b->gc->irc, b->gc->irc->nick ); -
protocols/nogaim.h
rfe51bcf r7b23afd 72 72 /* we need to do either oscar or TOC */ 73 73 /* we make this as an int in case if we want to add more protocols later */ 74 int protocol;75 74 struct prpl *prpl; 76 75 guint32 flags; … … 152 151 char user_info[2048]; 153 152 int options; 154 int protocol;153 struct prpl *prpl; 155 154 /* prpls can use this to save information about the user, 156 155 * like which server to connect to, etc */ … … 161 160 }; 162 161 162 struct ft 163 { 164 const char *filename; 165 166 /* Total number of bytes in file */ 167 size_t total_bytes; 168 169 /* Current number of bytes received */ 170 size_t cur_bytes; 171 }; 172 173 struct ft_request 174 { 175 const char *filename; 176 struct gaim_connection *gc; 177 }; 178 179 typedef void (*ft_recv_handler) (struct ft *, void *data, size_t len); 180 163 181 struct prpl { 164 int protocol;165 182 int options; 166 c har *(* name)();183 const char *name; 167 184 168 185 /* for ICQ and Yahoo, who have off/on per-conversation options */ … … 217 234 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 218 235 236 /* file transfers */ 237 struct ft_send_req *(* req_send_file) (struct gaim_connection *, const char *file); 238 void (* send_file_part) (struct gaim_connection *, struct ft*, void *data, size_t length); 239 void (* accept_recv_file) (struct gaim_connection *, struct ft*, ft_recv_handler); 240 219 241 void (* buddy_free) (struct buddy *); 220 242 221 243 char *(* get_status_string) (struct gaim_connection *gc, int stat); 222 244 }; 223 224 #define PROTO_TOC 0225 #define PROTO_OSCAR 1226 #define PROTO_YAHOO 2227 #define PROTO_ICQ 3228 #define PROTO_MSN 4229 #define PROTO_IRC 5230 #define PROTO_FTP 6231 #define PROTO_VGATE 7232 #define PROTO_JABBER 8233 #define PROTO_NAPSTER 9234 #define PROTO_ZEPHYR 10235 #define PROTO_GADUGADU 11236 #define PROTO_MAX 16237 238 extern char proto_name[PROTO_MAX][8];239 245 240 246 #define UC_UNAVAILABLE 1 … … 247 253 248 254 G_MODULE_EXPORT GSList *get_connections(); 249 extern struct prpl *proto_prpl[16]; 255 G_MODULE_EXPORT struct prpl *find_protocol(const char *name); 256 G_MODULE_EXPORT void register_protocol(struct prpl *); 250 257 251 258 /* nogaim.c */ … … 259 266 int proto_away( struct gaim_connection *gc, char *away ); 260 267 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); 261 int handle_cmp( char *a, char *b, intprotocol );268 int handle_cmp( char *a, char *b, struct prpl *protocol ); 262 269 263 270 gboolean auto_reconnect( gpointer data ); … … 318 325 G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value); 319 326 320 #ifdef WITH_MSN 321 /* msn.c */ 322 G_MODULE_EXPORT void msn_init( struct prpl *ret ); 323 #endif 324 325 #ifdef WITH_OSCAR 326 /* oscar.c */ 327 G_MODULE_EXPORT void oscar_init( struct prpl *ret ); 328 #endif 329 330 #ifdef WITH_JABBER 331 /* jabber.c */ 332 G_MODULE_EXPORT void jabber_init( struct prpl *ret ); 333 #endif 334 335 #ifdef WITH_YAHOO 336 /* yahoo.c */ 337 G_MODULE_EXPORT void byahoo_init( struct prpl *ret ); 338 #endif 327 /* file transfers */ 328 G_MODULE_EXPORT void ft_progress( struct ft *, int); 329 G_MODULE_EXPORT void ft_incoming( struct ft_request * ); 330 G_MODULE_EXPORT void ft_accepted( struct ft_request *, struct ft *); 331 G_MODULE_EXPORT void ft_denied( struct ft_request *, const char *reason); 339 332 340 333 /* prefs.c */ -
protocols/oscar/oscar.c
rfe51bcf r7b23afd 364 364 odata->icq = TRUE; 365 365 /* this is odd but it's necessary for a proper do_import and do_export */ 366 gc->protocol = PROTO_ICQ;367 366 gc->password[8] = 0; 368 367 } else { 369 gc->protocol = PROTO_TOC;370 368 gc->flags |= OPT_CONN_HTML; 371 369 } … … 2467 2465 } 2468 2466 2469 static struct prpl *my_protocol = NULL; 2470 2471 void oscar_init(struct prpl *ret) { 2472 ret-> protocol = PROTO_OSCAR;2467 void oscar_init() 2468 { 2469 struct prpl *ret = g_new0(struct prpl, 1); 2470 ret->name = "oscar"; 2473 2471 ret->away_states = oscar_away_states; 2474 2472 ret->login = oscar_login; … … 2488 2486 ret->get_status_string = oscar_get_status_string; 2489 2487 2490 my_protocol = ret;2491 } 2488 register_protocol(ret); 2489 } -
protocols/proxy.c
rfe51bcf r7b23afd 50 50 #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL) 51 51 52 /*FIXME*53 #ifndef _WIN3254 if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {55 closesocket(fd);56 g_free(phb);57 return -1;58 }59 fcntl(fd, F_SETFL, 0);60 #endif*/61 62 52 char proxyhost[128] = ""; 63 53 int proxyport = 0; -
protocols/yahoo/yahoo.c
rfe51bcf r7b23afd 64 64 }; 65 65 66 static char *yahoo_name()67 {68 return "Yahoo";69 }70 71 static struct prpl *my_protocol = NULL;72 66 static GSList *byahoo_inputs = NULL; 73 67 static int byahoo_chat_id = 0; … … 396 390 } 397 391 398 void byahoo_init( struct prpl *ret)399 { 400 ret->protocol = PROTO_YAHOO;401 ret->name = yahoo_name;392 void byahoo_init( ) 393 { 394 struct prpl *ret = g_new0(struct prpl, 1); 395 ret->name = "yahoo"; 402 396 403 397 ret->login = byahoo_login; 404 398 ret->close = byahoo_close; 405 399 ret->send_im = byahoo_send_im; 406 ret->send_typing = byahoo_send_typing;407 400 ret->get_info = byahoo_get_info; 408 401 ret->away_states = byahoo_away_states; … … 412 405 ret->remove_buddy = byahoo_remove_buddy; 413 406 ret->get_status_string = byahoo_get_status_string; 407 ret->send_typing = byahoo_send_typing; 414 408 415 409 ret->chat_send = byahoo_chat_send; … … 418 412 ret->chat_open = byahoo_chat_open; 419 413 420 my_protocol = ret;414 register_protocol(ret); 421 415 } 422 416 … … 432 426 yd = gc->proto_data; 433 427 434 if( gc->protocol == PROTO_YAHOO&& yd->y2_id == id )428 if( !strcmp(gc->prpl->name, "yahoo") && yd->y2_id == id ) 435 429 return( gc ); 436 430 }
Note: See TracChangeset
for help on using the changeset viewer.