Changes in protocols/nogaim.c [5b52a48:fb62f81f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r5b52a48 rfb62f81f 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 6Wilmer van der Gaast and others *4 * Copyright 2002-2004 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 13 13 * from scratch for BitlBee and doesn't contain any code from Gaim anymore 14 14 * (except for the function names). 15 * 16 * Copyright 2002-2006 Wilmer van der Gaast <wilmer@gaast.net> and others 15 17 */ 16 18 … … 145 147 /* multi.c */ 146 148 147 struct gaim_connection *new_gaim_conn( account_t *acc)149 struct gaim_connection *new_gaim_conn( struct aim_user *user ) 148 150 { 149 151 struct gaim_connection *gc; 152 account_t *a; 150 153 151 154 gc = g_new0( struct gaim_connection, 1 ); 152 155 153 /* Maybe we should get rid of this memory waste later. ;-) */154 g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user);155 g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass);156 157 gc->irc = acc->irc;158 gc->acc = acc;159 acc->gc = gc;156 gc->prpl = user->prpl; 157 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); 158 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); 159 /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. 160 * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. 161 */ 162 gc->irc=user->irc; 160 163 161 164 connections = g_slist_append( connections, gc ); 165 166 user->gc = gc; 167 gc->user = user; 168 169 // Find the account_t so we can set its gc pointer 170 for( a = gc->irc->accounts; a; a = a->next ) 171 if( ( struct aim_user * ) a->gc == user ) 172 { 173 a->gc = gc; 174 break; 175 } 162 176 163 177 return( gc ); … … 177 191 178 192 connections = g_slist_remove( connections, gc ); 193 g_free( gc->user ); 179 194 g_free( gc ); 180 195 } … … 207 222 va_end( params ); 208 223 209 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||210 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )224 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 225 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 211 226 strip_html( text ); 212 227 213 228 /* Try to find a different connection on the same protocol. */ 214 229 for( a = gc->irc->accounts; a; a = a->next ) 215 if( a->prpl == gc-> acc->prpl && a->gc != gc )230 if( a->prpl == gc->prpl && a->gc != gc ) 216 231 break; 217 232 218 233 /* If we found one, include the screenname in the message. */ 219 234 if( a ) 220 irc_usermsg( gc->irc, "%s(%s) - %s", gc-> acc->prpl->name, gc->username, text );235 irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, text ); 221 236 else 222 irc_usermsg( gc->irc, "%s - %s", gc-> acc->prpl->name, text );237 irc_usermsg( gc->irc, "%s - %s", gc->prpl->name, text ); 223 238 224 239 g_free( text ); 225 240 } 226 241 227 static gboolean send_keepalive( gpointer d , gint fd, b_input_condition cond)242 static gboolean send_keepalive( gpointer d ) 228 243 { 229 244 struct gaim_connection *gc = d; 230 245 231 if( gc-> acc->prpl->keepalive )232 gc-> acc->prpl->keepalive( gc );246 if( gc->prpl && gc->prpl->keepalive ) 247 gc->prpl->keepalive( gc ); 233 248 234 249 return TRUE; … … 249 264 serv_got_crap( gc, "Logged in" ); 250 265 251 gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );266 gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); 252 267 gc->flags |= OPT_LOGGED_IN; 253 268 … … 257 272 } 258 273 259 gboolean auto_reconnect( gpointer data , gint fd, b_input_condition cond)274 gboolean auto_reconnect( gpointer data ) 260 275 { 261 276 account_t *a = data; … … 269 284 void cancel_auto_reconnect( account_t *a ) 270 285 { 271 /* while( b_event_remove_by_data( (gpointer) a ) ); */ 272 b_event_remove( a->reconnect ); 286 while( g_source_remove_by_user_data( (gpointer) a ) ); 273 287 a->reconnect = 0; 274 288 } … … 281 295 282 296 serv_got_crap( gc, "Signing off.." ); 283 284 b_event_remove( gc->keepalive );285 297 gc->flags |= OPT_LOGGING_OUT; 286 298 299 gaim_input_remove( gc->keepalive ); 287 300 gc->keepalive = 0; 288 gc-> acc->prpl->close( gc );289 b_event_remove( gc->inpa );301 gc->prpl->close( gc ); 302 gaim_input_remove( gc->inpa ); 290 303 291 304 while( u ) … … 311 324 /* Uhm... This is very sick. */ 312 325 } 313 else if( !gc->wants_to_die && set_getint( &irc->set, "auto_reconnect" ) ) 314 { 315 int delay = set_getint( &irc->set, "auto_reconnect_delay" ); 316 326 else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) ) 327 { 328 int delay = set_getint( irc, "auto_reconnect_delay" ); 317 329 serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); 318 a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); 330 331 a->reconnect = 1; 332 g_timeout_add( delay * 1000, auto_reconnect, a ); 319 333 } 320 334 … … 352 366 irc_t *irc = gc->irc; 353 367 354 if( set_getint( &irc->set, "debug" ) && 0 ) /* This message is too useless */368 if( set_getint( irc, "debug" ) && 0 ) /* This message is too useless */ 355 369 serv_got_crap( gc, "Receiving user add from handle: %s", handle ); 356 370 357 371 if( user_findhandle( gc, handle ) ) 358 372 { 359 if( set_getint( &irc->set, "debug" ) )373 if( set_getint( irc, "debug" ) ) 360 374 serv_got_crap( gc, "User already exists, ignoring add request: %s", handle ); 361 375 … … 366 380 367 381 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 368 strcpy( nick, nick_get( gc-> acc, handle, realname ) );382 strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) ); 369 383 370 384 u = user_add( gc->irc, nick ); … … 378 392 u->user = g_strndup( handle, s - handle ); 379 393 } 380 else if( gc-> acc->server)394 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) 381 395 { 382 396 char *colon; 383 397 384 if( ( colon = strchr( gc-> acc->server, ':' ) ) )385 u->host = g_strndup( gc-> acc->server,386 colon - gc-> acc->server);398 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) 399 u->host = g_strndup( gc->user->proto_opt[0], 400 colon - gc->user->proto_opt[0] ); 387 401 else 388 u->host = g_strdup( gc-> acc->server);402 u->host = g_strdup( gc->user->proto_opt[0] ); 389 403 390 404 u->user = g_strdup( handle ); … … 397 411 else 398 412 { 399 u->host = g_strdup( gc-> acc->prpl->name );413 u->host = g_strdup( gc->user->prpl->name ); 400 414 u->user = g_strdup( handle ); 401 415 } … … 445 459 u->realname = g_strdup( realname ); 446 460 447 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( &gc->irc->set, "display_namechanges" ) )461 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) ) 448 462 serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname ); 449 463 } … … 467 481 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 468 482 { 469 data->gc-> acc->prpl->add_buddy( data->gc, data->handle );483 data->gc->prpl->add_buddy( data->gc, data->handle ); 470 484 add_buddy( data->gc, NULL, data->handle, data->handle ); 471 485 … … 501 515 if( !u ) 502 516 { 503 if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 )517 if( g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "add" ) == 0 ) 504 518 { 505 519 add_buddy( gc, NULL, handle, NULL ); … … 508 522 else 509 523 { 510 if( set_getint( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )524 if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 ) 511 525 { 512 526 serv_got_crap( gc, "serv_got_update() for handle %s:", handle ); … … 546 560 } 547 561 548 if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0) )562 if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) ) 549 563 { 550 564 u->away = g_strdup( "Away" ); 551 565 } 552 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0) )566 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) ) 553 567 { 554 568 if( type & UC_DND ) … … 559 573 u->away = g_strdup( "Away" ); 560 574 } 561 else if( ( type & UC_UNAVAILABLE ) && gc-> acc->prpl->get_status_string )562 { 563 u->away = g_strdup( gc-> acc->prpl->get_status_string( gc, type ) );575 else if( ( type & UC_UNAVAILABLE ) && gc->prpl->get_status_string ) 576 { 577 u->away = g_strdup( gc->prpl->get_status_string( gc, type ) ); 564 578 } 565 579 else … … 567 581 568 582 /* LISPy... */ 569 if( ( set_getint( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */583 if( ( set_getint( gc->irc, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 570 584 ( u->online ) && /* Don't touch offline people */ 571 585 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ … … 586 600 if( !u ) 587 601 { 588 char *h = set_getstr( &irc->set, "handle_unknown" );602 char *h = set_getstr( irc, "handle_unknown" ); 589 603 590 604 if( g_strcasecmp( h, "ignore" ) == 0 ) 591 605 { 592 if( set_getint( &irc->set, "debug" ) )606 if( set_getint( irc, "debug" ) ) 593 607 serv_got_crap( gc, "Ignoring message from unknown handle %s", handle ); 594 608 … … 597 611 else if( g_strncasecmp( h, "add", 3 ) == 0 ) 598 612 { 599 int private = set_getint( &irc->set, "private" );613 int private = set_getint( irc, "private" ); 600 614 601 615 if( h[3] ) … … 618 632 } 619 633 620 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||621 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )634 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 635 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 622 636 strip_html( msg ); 623 637 … … 659 673 user_t *u; 660 674 661 if( !set_getint( &gc->irc->set, "typing_notice" ) )675 if( !set_getint( gc->irc, "typing_notice" ) ) 662 676 return; 663 677 … … 681 695 GList *ir; 682 696 683 if( set_getint( &gc->irc->set, "debug" ) )697 if( set_getint( gc->irc, "debug" ) ) 684 698 serv_got_crap( gc, "You were removed from conversation %d", (int) id ); 685 699 … … 720 734 721 735 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ 722 if( g_strcasecmp( who, gc->user name ) == 0 )736 if( g_strcasecmp( who, gc->user->username ) == 0 ) 723 737 return; 724 738 … … 726 740 for( c = gc->conversations; c && c->id != id; c = c->next ); 727 741 728 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||729 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )742 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 743 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 730 744 strip_html( msg ); 731 745 … … 760 774 g_free( s ); 761 775 762 if( set_getint( &gc->irc->set, "debug" ) )776 if( set_getint( gc->irc, "debug" ) ) 763 777 serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); 764 778 … … 774 788 int me = 0; 775 789 776 if( set_getint( &b->gc->irc->set, "debug" ) )790 if( set_getint( b->gc->irc, "debug" ) ) 777 791 serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); 778 792 779 793 /* It might be yourself! */ 780 if( b->gc-> acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )794 if( b->gc->prpl->cmp_buddynames( handle, b->gc->user->username ) == 0 ) 781 795 { 782 796 u = user_find( b->gc->irc, b->gc->irc->nick ); … … 808 822 int me = 0; 809 823 810 if( set_getint( &b->gc->irc->set, "debug" ) )824 if( set_getint( b->gc->irc, "debug" ) ) 811 825 serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); 812 826 813 827 /* It might be yourself! */ 814 if( g_strcasecmp( handle, b->gc->user name ) == 0 )828 if( g_strcasecmp( handle, b->gc->user->username ) == 0 ) 815 829 { 816 830 u = user_find( b->gc->irc, b->gc->irc->nick ); … … 870 884 } 871 885 872 char *set_eval_away_devoice( set_t *set, char *value ) 873 { 874 irc_t *irc = set->data; 886 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) 887 { 875 888 int st; 876 889 … … 886 899 /* Horror.... */ 887 900 888 if( st != set_getint( &irc->set, "away_devoice" ) )901 if( st != set_getint( irc, "away_devoice" ) ) 889 902 { 890 903 char list[80] = ""; … … 926 939 } 927 940 928 return( set_eval_bool( set, value ) );941 return( set_eval_bool( irc, set, value ) ); 929 942 } 930 943 … … 946 959 } 947 960 948 st = gc-> acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );961 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 949 962 g_free( buf ); 950 963 … … 963 976 } 964 977 965 st = gc-> acc->prpl->chat_send( gc, id, msg );978 st = gc->prpl->chat_send( gc, id, msg ); 966 979 g_free( buf ); 967 980 … … 977 990 978 991 if( !away ) away = ""; 979 ms = m = gc-> acc->prpl->away_states( gc );992 ms = m = gc->prpl->away_states( gc ); 980 993 981 994 while( m ) … … 998 1011 if( m ) 999 1012 { 1000 gc-> acc->prpl->set_away( gc, m->data, *away ? away : NULL );1013 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1001 1014 } 1002 1015 else … … 1005 1018 if( s ) 1006 1019 { 1007 gc-> acc->prpl->set_away( gc, s, away );1008 if( set_getint( &gc->irc->set, "debug" ) )1020 gc->prpl->set_away( gc, s, away ); 1021 if( set_getint( gc->irc, "debug" ) ) 1009 1022 serv_got_crap( gc, "Setting away state to %s", s ); 1010 1023 } 1011 1024 else 1012 gc-> acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );1025 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1013 1026 } 1014 1027 … … 1062 1075 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1063 1076 { 1064 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) == NULL )1077 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1065 1078 { 1066 1079 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1067 1080 } 1068 1081 1069 gc-> acc->prpl->add_permit( gc, handle );1082 gc->prpl->add_permit( gc, handle ); 1070 1083 } 1071 1084 … … 1074 1087 GSList *l; 1075 1088 1076 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) ) )1089 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1077 1090 { 1078 1091 g_free( l->data ); … … 1080 1093 } 1081 1094 1082 gc-> acc->prpl->rem_permit( gc, handle );1095 gc->prpl->rem_permit( gc, handle ); 1083 1096 } 1084 1097 1085 1098 void bim_add_block( struct gaim_connection *gc, char *handle ) 1086 1099 { 1087 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) == NULL )1100 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1088 1101 { 1089 1102 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1090 1103 } 1091 1104 1092 gc-> acc->prpl->add_deny( gc, handle );1105 gc->prpl->add_deny( gc, handle ); 1093 1106 } 1094 1107 … … 1097 1110 GSList *l; 1098 1111 1099 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) ) )1112 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1100 1113 { 1101 1114 g_free( l->data ); … … 1103 1116 } 1104 1117 1105 gc-> acc->prpl->rem_deny( gc, handle );1106 } 1118 gc->prpl->rem_deny( gc, handle ); 1119 }
Note: See TracChangeset
for help on using the changeset viewer.