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