Changeset 0da65d5 for protocols/yahoo
- Timestamp:
- 2007-03-31T05:40:45Z (18 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/yahoo.c
rfa29d093 r0da65d5 58 58 { 59 59 char *name; 60 struct conversation*c;60 struct groupchat *c; 61 61 int yid; 62 62 YList *members; 63 struct gaim_connection *gc;63 struct im_connection *ic; 64 64 }; 65 65 … … 123 123 static void byahoo_login( account_t *acc ) 124 124 { 125 struct gaim_connection *gc = new_gaim_conn( acc );126 struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 );125 struct im_connection *ic = new_gaim_conn( acc ); 126 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); 127 127 128 128 yd->logged_in = FALSE; 129 129 yd->current_status = YAHOO_STATUS_AVAILABLE; 130 130 131 set_login_progress( gc, 1, "Connecting" );131 set_login_progress( ic, 1, "Connecting" ); 132 132 yd->y2_id = yahoo_init( acc->user, acc->pass ); 133 133 yahoo_login( yd->y2_id, yd->current_status ); 134 134 } 135 135 136 static void byahoo_ close( struct gaim_connection *gc )137 { 138 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;136 static void byahoo_logout( struct im_connection *ic ) 137 { 138 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 139 139 GSList *l; 140 140 141 while( gc->conversations )142 serv_got_chat_left( gc->conversations );141 while( ic->conversations ) 142 serv_got_chat_left( ic->conversations ); 143 143 144 144 for( l = yd->buddygroups; l; l = l->next ) … … 160 160 } 161 161 162 static void byahoo_get_info(struct gaim_connection *gc, char *who)162 static void byahoo_get_info(struct im_connection *ic, char *who) 163 163 { 164 164 /* Just make an URL and let the user fetch the info */ 165 serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"),165 serv_got_crap(ic, "%s\n%s: %s%s", _("User Info"), 166 166 _("For now, fetch yourself"), yahoo_get_profile_url(), 167 167 who); 168 168 } 169 169 170 static int byahoo_send_im( struct gaim_connection *gc, char *who, char *what, int len, int flags )171 { 172 struct byahoo_data *yd = gc->proto_data;170 static int byahoo_send_im( struct im_connection *ic, char *who, char *what, int flags ) 171 { 172 struct byahoo_data *yd = ic->proto_data; 173 173 174 174 yahoo_send_im( yd->y2_id, NULL, who, what, 1 ); … … 177 177 } 178 178 179 static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing )180 { 181 struct byahoo_data *yd = gc->proto_data;179 static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) 180 { 181 struct byahoo_data *yd = ic->proto_data; 182 182 183 183 yahoo_send_typing( yd->y2_id, NULL, who, typing ); … … 186 186 } 187 187 188 static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg )189 { 190 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;191 192 gc->away = NULL;188 static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) 189 { 190 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 191 192 ic->away = NULL; 193 193 194 194 if( state && msg && g_strcasecmp( state, msg ) != 0 ) 195 195 { 196 196 yd->current_status = YAHOO_STATUS_CUSTOM; 197 gc->away = "";197 ic->away = ""; 198 198 } 199 199 else if( state ) … … 204 204 msg = NULL; 205 205 206 gc->away = "";206 ic->away = ""; 207 207 if( g_strcasecmp( state, "Available" ) == 0 ) 208 208 { 209 209 yd->current_status = YAHOO_STATUS_AVAILABLE; 210 gc->away = NULL;210 ic->away = NULL; 211 211 } 212 212 else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) … … 234 234 yd->current_status = YAHOO_STATUS_AVAILABLE; 235 235 236 gc->away = NULL;236 ic->away = NULL; 237 237 } 238 238 } … … 240 240 yd->current_status = YAHOO_STATUS_AVAILABLE; 241 241 242 yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );243 } 244 245 static GList *byahoo_away_states( struct gaim_connection *gc )242 yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ); 243 } 244 245 static GList *byahoo_away_states( struct im_connection *ic ) 246 246 { 247 247 GList *m = NULL; … … 263 263 } 264 264 265 static void byahoo_keepalive( struct gaim_connection *gc )266 { 267 struct byahoo_data *yd = gc->proto_data;265 static void byahoo_keepalive( struct im_connection *ic ) 266 { 267 struct byahoo_data *yd = ic->proto_data; 268 268 269 269 yahoo_keepalive( yd->y2_id ); 270 270 } 271 271 272 static void byahoo_add_buddy( struct gaim_connection *gc, char *who)273 { 274 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;275 276 yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP );277 } 278 279 static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group )280 { 281 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;272 static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) 273 { 274 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 275 276 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP ); 277 } 278 279 static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group ) 280 { 281 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 282 282 GSList *bgl; 283 283 … … 293 293 } 294 294 295 static char *byahoo_get_status_string( struct gaim_connection *gc, int stat )295 static char *byahoo_get_status_string( struct im_connection *ic, int stat ) 296 296 { 297 297 enum yahoo_status a = stat >> 1; … … 332 332 } 333 333 334 static int byahoo_chat_send( struct conversation *c, char *message)335 { 336 struct byahoo_data *yd = (struct byahoo_data *) c-> gc->proto_data;334 static void byahoo_chat_send( struct groupchat *c, char *message, int flags ) 335 { 336 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 337 337 338 338 yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); 339 340 return( 0 ); 341 } 342 343 static void byahoo_chat_invite( struct conversation *c, char *msg, char *who ) 344 { 345 struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; 339 } 340 341 static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who ) 342 { 343 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 346 344 347 345 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); 348 346 } 349 347 350 static void byahoo_chat_leave( struct conversation*c )351 { 352 struct byahoo_data *yd = (struct byahoo_data *) c-> gc->proto_data;348 static void byahoo_chat_leave( struct groupchat *c ) 349 { 350 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 353 351 354 352 yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); … … 356 354 } 357 355 358 static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who )359 { 360 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;361 struct conversation*c;356 static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) 357 { 358 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 359 struct groupchat *c; 362 360 char *roomname; 363 361 YList *members; 364 362 365 roomname = g_new0( char, strlen( gc->username ) + 16 );366 g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id );367 368 c = serv_got_joined_chat( gc, roomname );369 add_chat_buddy( c, gc->username );363 roomname = g_new0( char, strlen( ic->username ) + 16 ); 364 g_snprintf( roomname, strlen( ic->username ) + 16, "%s-Bee-%d", ic->username, byahoo_chat_id ); 365 366 c = serv_got_joined_chat( ic, roomname ); 367 add_chat_buddy( c, ic->username ); 370 368 371 369 /* FIXME: Free this thing when the chat's destroyed. We can't *always* … … 381 379 } 382 380 383 void byahoo_init ( )381 void byahoo_initmodule( ) 384 382 { 385 383 struct prpl *ret = g_new0(struct prpl, 1); … … 387 385 388 386 ret->login = byahoo_login; 389 ret->close = byahoo_close; 387 ret->keepalive = byahoo_keepalive; 388 ret->logout = byahoo_logout; 389 390 390 ret->send_im = byahoo_send_im; 391 391 ret->get_info = byahoo_get_info; 392 392 ret->away_states = byahoo_away_states; 393 393 ret->set_away = byahoo_set_away; 394 ret->keepalive = byahoo_keepalive;395 394 ret->add_buddy = byahoo_add_buddy; 396 395 ret->remove_buddy = byahoo_remove_buddy; … … 401 400 ret->chat_invite = byahoo_chat_invite; 402 401 ret->chat_leave = byahoo_chat_leave; 403 ret->chat_ open = byahoo_chat_open;402 ret->chat_with = byahoo_chat_with; 404 403 405 404 ret->handle_cmp = g_strcasecmp; … … 408 407 } 409 408 410 static struct gaim_connection *byahoo_get_gc_by_id( int id )409 static struct im_connection *byahoo_get_ic_by_id( int id ) 411 410 { 412 411 GSList *l; 413 struct gaim_connection *gc;412 struct im_connection *ic; 414 413 struct byahoo_data *yd; 415 414 416 415 for( l = get_connections(); l; l = l->next ) 417 416 { 418 gc = l->data;419 yd = gc->proto_data;420 421 if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id )422 return( gc );417 ic = l->data; 418 yd = ic->proto_data; 419 420 if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) 421 return( ic ); 423 422 } 424 423 … … 441 440 struct byahoo_connect_callback_data *d = data; 442 441 443 if( !byahoo_get_ gc_by_id( d->id ) )442 if( !byahoo_get_ic_by_id( d->id ) ) 444 443 { 445 444 g_free( d ); … … 463 462 struct byahoo_read_ready_data *d = data; 464 463 465 if( !byahoo_get_ gc_by_id( d->id ) )464 if( !byahoo_get_ic_by_id( d->id ) ) 466 465 /* WTF doesn't libyahoo clean this up? */ 467 466 return FALSE; … … 484 483 struct byahoo_write_ready_data *d = data; 485 484 486 if( !byahoo_get_ gc_by_id( d->id ) )485 if( !byahoo_get_ic_by_id( d->id ) ) 487 486 /* WTF doesn't libyahoo clean this up? */ 488 487 return FALSE; … … 495 494 void ext_yahoo_login_response( int id, int succ, char *url ) 496 495 { 497 struct gaim_connection *gc = byahoo_get_gc_by_id( id );496 struct im_connection *ic = byahoo_get_ic_by_id( id ); 498 497 struct byahoo_data *yd = NULL; 499 498 500 if( gc == NULL )499 if( ic == NULL ) 501 500 { 502 501 /* libyahoo2 seems to call this one twice when something … … 508 507 } 509 508 510 yd = (struct byahoo_data *) gc->proto_data;509 yd = (struct byahoo_data *) ic->proto_data; 511 510 512 511 if( succ == YAHOO_LOGIN_OK ) 513 512 { 514 account_online( gc );513 account_online( ic ); 515 514 516 515 yd->logged_in = TRUE; … … 532 531 { 533 532 errstr = "Logged in on a different machine or device"; 534 gc->wants_to_die = TRUE;533 ic->wants_to_die = TRUE; 535 534 } 536 535 else if( succ == YAHOO_LOGIN_SOCK ) … … 551 550 552 551 if( yd->logged_in ) 553 hide_login_progress_error( gc, s );552 hide_login_progress_error( ic, s ); 554 553 else 555 hide_login_progress( gc, s );554 hide_login_progress( ic, s ); 556 555 557 556 g_free( s ); 558 557 559 signoff( gc );558 signoff( ic ); 560 559 } 561 560 } … … 563 562 void ext_yahoo_got_buddies( int id, YList *buds ) 564 563 { 565 struct gaim_connection *gc = byahoo_get_gc_by_id( id );566 struct byahoo_data *yd = gc->proto_data;564 struct im_connection *ic = byahoo_get_ic_by_id( id ); 565 struct byahoo_data *yd = ic->proto_data; 567 566 YList *bl = buds; 568 567 … … 581 580 } 582 581 583 add_buddy( gc, b->group, b->id, b->real_name );582 add_buddy( ic, b->group, b->id, b->real_name ); 584 583 bl = bl->next; 585 584 } … … 600 599 void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) 601 600 { 602 struct gaim_connection *gc = byahoo_get_gc_by_id( id );603 604 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0,601 struct im_connection *ic = byahoo_get_ic_by_id( id ); 602 603 serv_got_update( ic, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 605 604 ( stat == YAHOO_STATUS_IDLE ) ? away : 0, 606 605 ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); … … 609 608 void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) 610 609 { 611 struct gaim_connection *gc = byahoo_get_gc_by_id( id );610 struct im_connection *ic = byahoo_get_ic_by_id( id ); 612 611 char *m = byahoo_strip( msg ); 613 612 614 serv_got_im( gc, who, m, 0, 0, strlen( m ) );613 serv_got_im( ic, who, m, 0, 0, strlen( m ) ); 615 614 g_free( m ); 616 615 } … … 618 617 void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize ) 619 618 { 620 struct gaim_connection *gc = byahoo_get_gc_by_id( id );621 622 serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );619 struct im_connection *ic = byahoo_get_ic_by_id( id ); 620 621 serv_got_crap( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 623 622 } 624 623 625 624 void ext_yahoo_typing_notify( int id, char *who, int stat ) 626 625 { 627 struct gaim_connection *gc = byahoo_get_gc_by_id( id );626 struct im_connection *ic = byahoo_get_ic_by_id( id ); 628 627 if (stat == 1) { 629 628 /* User is typing */ 630 serv_got_typing( gc, who, 1, 1 );629 serv_got_typing( ic, who, 1, 1 ); 631 630 } 632 631 else { 633 632 /* User stopped typing */ 634 serv_got_typing( gc, who, 1, 0 );633 serv_got_typing( ic, who, 1, 0 ); 635 634 } 636 635 } … … 638 637 void ext_yahoo_system_message( int id, char *msg ) 639 638 { 640 struct gaim_connection *gc = byahoo_get_gc_by_id( id );641 642 serv_got_crap( gc, "Yahoo! system message: %s", msg );639 struct im_connection *ic = byahoo_get_ic_by_id( id ); 640 641 serv_got_crap( ic, "Yahoo! system message: %s", msg ); 643 642 } 644 643 645 644 void ext_yahoo_webcam_invite( int id, char *from ) 646 645 { 647 struct gaim_connection *gc = byahoo_get_gc_by_id( id );648 649 serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );646 struct im_connection *ic = byahoo_get_ic_by_id( id ); 647 648 serv_got_crap( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); 650 649 } 651 650 652 651 void ext_yahoo_error( int id, char *err, int fatal ) 653 652 { 654 struct gaim_connection *gc = byahoo_get_gc_by_id( id );653 struct im_connection *ic = byahoo_get_ic_by_id( id ); 655 654 656 655 if( fatal ) 657 656 { 658 hide_login_progress_error( gc, err );659 signoff( gc );657 hide_login_progress_error( ic, err ); 658 signoff( ic ); 660 659 } 661 660 else 662 661 { 663 do_error_dialog( gc, err, "Yahoo! error" );662 do_error_dialog( ic, err, "Yahoo! error" ); 664 663 } 665 664 } … … 788 787 { 789 788 yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); 790 add_chat_buddy( inv->c, inv-> gc->username );789 add_chat_buddy( inv->c, inv->ic->username ); 791 790 g_free( inv->name ); 792 791 g_free( inv ); … … 803 802 void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members ) 804 803 { 805 struct gaim_connection *gc = byahoo_get_gc_by_id( id );804 struct im_connection *ic = byahoo_get_ic_by_id( id ); 806 805 struct byahoo_conf_invitation *inv; 807 806 char txt[1024]; … … 811 810 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); 812 811 inv->name = g_strdup( room ); 813 inv->c = serv_got_joined_chat( gc, room );812 inv->c = serv_got_joined_chat( ic, room ); 814 813 inv->c->data = members; 815 814 inv->yid = id; 816 815 inv->members = members; 817 inv-> gc = gc;816 inv->ic = ic; 818 817 819 818 for( m = members; m; m = m->next ) 820 if( g_strcasecmp( m->data, gc->username ) != 0 )819 if( g_strcasecmp( m->data, ic->username ) != 0 ) 821 820 add_chat_buddy( inv->c, m->data ); 822 821 823 822 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); 824 823 825 do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf );824 do_ask_dialog( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); 826 825 } 827 826 828 827 void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg ) 829 828 { 830 struct gaim_connection *gc = byahoo_get_gc_by_id( id );831 832 serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg );829 struct im_connection *ic = byahoo_get_ic_by_id( id ); 830 831 serv_got_crap( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); 833 832 } 834 833 835 834 void ext_yahoo_conf_userjoin( int id, char *who, char *room ) 836 835 { 837 struct gaim_connection *gc = byahoo_get_gc_by_id( id );838 struct conversation*c;839 840 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );836 struct im_connection *ic = byahoo_get_ic_by_id( id ); 837 struct groupchat *c; 838 839 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 841 840 842 841 if( c ) … … 846 845 void ext_yahoo_conf_userleave( int id, char *who, char *room ) 847 846 { 848 struct gaim_connection *gc = byahoo_get_gc_by_id( id );849 struct conversation*c;850 851 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );847 struct im_connection *ic = byahoo_get_ic_by_id( id ); 848 struct groupchat *c; 849 850 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 852 851 853 852 if( c ) … … 857 856 void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 ) 858 857 { 859 struct gaim_connection *gc = byahoo_get_gc_by_id( id );858 struct im_connection *ic = byahoo_get_ic_by_id( id ); 860 859 char *m = byahoo_strip( msg ); 861 struct conversation*c;862 863 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );860 struct groupchat *c; 861 862 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 864 863 865 864 if( c ) … … 910 909 void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) 911 910 { 912 struct gaim_connection *gc = byahoo_get_gc_by_id( id );911 struct im_connection *ic = byahoo_get_ic_by_id( id ); 913 912 914 913 if( from && subj ) 915 serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj );914 serv_got_crap( ic, "Received e-mail message from %s with subject `%s'", from, subj ); 916 915 else if( cnt > 0 ) 917 serv_got_crap( gc, "Received %d new e-mails", cnt );916 serv_got_crap( ic, "Received %d new e-mails", cnt ); 918 917 } 919 918
Note: See TracChangeset
for help on using the changeset viewer.