Changeset 85d7b85 for protocols/yahoo/yahoo.c
- Timestamp:
- 2008-04-02T14:22:57Z (16 years ago)
- Branches:
- master
- Children:
- f9dbc99
- Parents:
- 875ad42 (diff), dd34575 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/yahoo.c
r875ad42 r85d7b85 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 … … 67 67 static int byahoo_chat_id = 0; 68 68 69 static char *byahoo_strip( c har *in )69 static char *byahoo_strip( const char *in ) 70 70 { 71 71 int len; 72 72 73 /* This should get rid of HTML tagsat the beginning of the string. */73 /* This should get rid of the markup noise at the beginning of the string. */ 74 74 while( *in ) 75 75 { … … 86 86 else if( strncmp( in, "\e[", 2 ) == 0 ) 87 87 { 88 c har *s;88 const char *s; 89 89 90 90 for( s = in + 2; *s && *s != 'm'; s ++ ); … … 101 101 } 102 102 103 /* This is supposed to get rid of the closing HTML tagsat the end of the line. */103 /* This is supposed to get rid of the noise at the end of the line. */ 104 104 len = strlen( in ); 105 while( len > 0 && in[len-1] == '>')105 while( len > 0 && ( in[len-1] == '>' || in[len-1] == 'm' ) ) 106 106 { 107 107 int blen = len; 108 109 len --; 110 while( len > 0 && ( in[len] != '<' || in[len+1] != '/' ) ) 108 const char *search; 109 110 if( in[len-1] == '>' ) 111 search = "</"; 112 else 113 search = "\e["; 114 115 len -= 3; 116 while( len > 0 && strncmp( in + len, search, 2 ) != 0 ) 111 117 len --; 112 118 113 if( len == 0 && ( in[len] != '<' || in[len+1] != '/' ))119 if( len <= 0 && strncmp( in, search, 2 ) != 0 ) 114 120 { 115 121 len = blen; … … 121 127 } 122 128 123 static void byahoo_login( struct aim_user *user ) 124 { 125 struct gaim_connection *gc = new_gaim_conn( user ); 126 struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 ); 129 static void byahoo_init( account_t *acc ) 130 { 131 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 132 } 133 134 static void byahoo_login( account_t *acc ) 135 { 136 struct im_connection *ic = imcb_new( acc ); 137 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); 127 138 128 139 yd->logged_in = FALSE; 129 140 yd->current_status = YAHOO_STATUS_AVAILABLE; 130 141 131 set_login_progress( gc, 1, "Connecting" );132 yd->y2_id = yahoo_init( user->username, user->password);142 imcb_log( ic, "Connecting" ); 143 yd->y2_id = yahoo_init( acc->user, acc->pass ); 133 144 yahoo_login( yd->y2_id, yd->current_status ); 134 145 } 135 146 136 static void byahoo_ close( struct gaim_connection *gc )137 { 138 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;147 static void byahoo_logout( struct im_connection *ic ) 148 { 149 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 139 150 GSList *l; 140 151 141 while( gc->conversations )142 serv_got_chat_left( gc, gc->conversations->id);152 while( ic->groupchats ) 153 imcb_chat_free( ic->groupchats ); 143 154 144 155 for( l = yd->buddygroups; l; l = l->next ) … … 160 171 } 161 172 162 static void byahoo_get_info(struct gaim_connection *gc, char *who)173 static void byahoo_get_info(struct im_connection *ic, char *who) 163 174 { 164 175 /* Just make an URL and let the user fetch the info */ 165 serv_got_crap(gc, "%s\n%s: %s%s", _("User Info"),176 imcb_log(ic, "%s\n%s: %s%s", _("User Info"), 166 177 _("For now, fetch yourself"), yahoo_get_profile_url(), 167 178 who); 168 179 } 169 180 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;173 174 yahoo_send_im( yd->y2_id, NULL, who, what, 1 );181 static int byahoo_buddy_msg( struct im_connection *ic, char *who, char *what, int flags ) 182 { 183 struct byahoo_data *yd = ic->proto_data; 184 185 yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0 ); 175 186 176 187 return 1; 177 188 } 178 189 179 static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing )180 { 181 struct byahoo_data *yd = gc->proto_data;182 183 yahoo_send_typing( yd->y2_id, NULL, who, typing);190 static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) 191 { 192 struct byahoo_data *yd = ic->proto_data; 193 194 yahoo_send_typing( yd->y2_id, NULL, who, ( typing & OPT_TYPING ) != 0 ); 184 195 185 196 return 1; 186 197 } 187 198 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;193 194 if( msg)199 static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) 200 { 201 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 202 203 ic->away = NULL; 204 205 if( state && msg && g_strcasecmp( state, msg ) != 0 ) 195 206 { 196 207 yd->current_status = YAHOO_STATUS_CUSTOM; 197 gc->away = ""; 198 } 199 if( state ) 200 { 201 gc->away = ""; 208 ic->away = ""; 209 } 210 else if( state ) 211 { 212 /* Set msg to NULL since (if it isn't NULL already) it's equal 213 to state. msg must be empty if we want to use an existing 214 away state. */ 215 msg = NULL; 216 217 ic->away = ""; 202 218 if( g_strcasecmp( state, "Available" ) == 0 ) 203 219 { 204 220 yd->current_status = YAHOO_STATUS_AVAILABLE; 205 gc->away = NULL;221 ic->away = NULL; 206 222 } 207 223 else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) … … 229 245 yd->current_status = YAHOO_STATUS_AVAILABLE; 230 246 231 gc->away = NULL;247 ic->away = NULL; 232 248 } 233 249 } … … 235 251 yd->current_status = YAHOO_STATUS_AVAILABLE; 236 252 237 if( yd->current_status == YAHOO_STATUS_INVISIBLE ) 238 yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL ); 239 else 240 yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL ); 241 } 242 243 static GList *byahoo_away_states( struct gaim_connection *gc ) 253 yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ? 2 : 0 ); 254 } 255 256 static GList *byahoo_away_states( struct im_connection *ic ) 244 257 { 245 258 GList *m = NULL; … … 261 274 } 262 275 263 static void byahoo_keepalive( struct gaim_connection *gc )264 { 265 struct byahoo_data *yd = gc->proto_data;276 static void byahoo_keepalive( struct im_connection *ic ) 277 { 278 struct byahoo_data *yd = ic->proto_data; 266 279 267 280 yahoo_keepalive( yd->y2_id ); 268 281 } 269 282 270 static void byahoo_add_buddy( struct gaim_connection *gc, char *who)271 { 272 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;273 274 yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP);275 } 276 277 static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group )278 { 279 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;283 static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) 284 { 285 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 286 287 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL ); 288 } 289 290 static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group ) 291 { 292 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 280 293 GSList *bgl; 281 294 … … 291 304 } 292 305 293 static char *byahoo_get_status_string( struct gaim_connection *gc, int stat ) 294 { 295 enum yahoo_status a = stat >> 1; 296 297 switch (a) 298 { 299 case YAHOO_STATUS_BRB: 300 return "Be Right Back"; 301 case YAHOO_STATUS_BUSY: 302 return "Busy"; 303 case YAHOO_STATUS_NOTATHOME: 304 return "Not At Home"; 305 case YAHOO_STATUS_NOTATDESK: 306 return "Not At Desk"; 307 case YAHOO_STATUS_NOTINOFFICE: 308 return "Not In Office"; 309 case YAHOO_STATUS_ONPHONE: 310 return "On Phone"; 311 case YAHOO_STATUS_ONVACATION: 312 return "On Vacation"; 313 case YAHOO_STATUS_OUTTOLUNCH: 314 return "Out To Lunch"; 315 case YAHOO_STATUS_STEPPEDOUT: 316 return "Stepped Out"; 317 case YAHOO_STATUS_INVISIBLE: 318 return "Invisible"; 319 case YAHOO_STATUS_CUSTOM: 320 return "Away"; 321 case YAHOO_STATUS_IDLE: 322 return "Idle"; 323 case YAHOO_STATUS_OFFLINE: 324 return "Offline"; 325 case YAHOO_STATUS_NOTIFY: 326 return "Notify"; 327 default: 328 return "Away"; 329 } 330 } 331 332 static int byahoo_chat_send( struct gaim_connection *gc, int id, char *message ) 333 { 334 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; 335 struct conversation *c; 336 337 for( c = gc->conversations; c && c->id != id; c = c->next ); 338 306 static void byahoo_chat_msg( struct groupchat *c, char *message, int flags ) 307 { 308 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 309 339 310 yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); 340 341 return( 0 ); 342 } 343 344 static void byahoo_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) 345 { 346 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; 347 struct conversation *c; 348 349 for( c = gc->conversations; c && c->id != id; c = c->next ); 350 351 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); 352 } 353 354 static void byahoo_chat_leave( struct gaim_connection *gc, int id ) 355 { 356 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; 357 struct conversation *c; 358 359 for( c = gc->conversations; c && c->id != id; c = c->next ); 311 } 312 313 static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg ) 314 { 315 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 316 317 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "" ); 318 } 319 320 static void byahoo_chat_leave( struct groupchat *c ) 321 { 322 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 360 323 361 324 yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); 362 serv_got_chat_left( gc, c->id);363 } 364 365 static int byahoo_chat_open( struct gaim_connection *gc, char *who )366 { 367 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;368 struct conversation*c;325 imcb_chat_free( c ); 326 } 327 328 static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) 329 { 330 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 331 struct groupchat *c; 369 332 char *roomname; 370 333 YList *members; 371 334 372 roomname = g_new0( char, strlen( gc->username ) + 16 ); 373 g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id ); 374 375 c = serv_got_joined_chat( gc, ++byahoo_chat_id, roomname ); 376 add_chat_buddy( c, gc->username ); 335 roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id ); 336 337 c = imcb_chat_new( ic, roomname ); 338 imcb_chat_add_buddy( c, ic->acc->user ); 377 339 378 340 /* FIXME: Free this thing when the chat's destroyed. We can't *always* … … 385 347 g_free( roomname ); 386 348 387 return ( 1 );388 } 389 390 void byahoo_init ( )349 return c; 350 } 351 352 void byahoo_initmodule( ) 391 353 { 392 354 struct prpl *ret = g_new0(struct prpl, 1); 393 355 ret->name = "yahoo"; 356 ret->init = byahoo_init; 394 357 395 358 ret->login = byahoo_login; 396 ret->close = byahoo_close; 397 ret->send_im = byahoo_send_im; 359 ret->keepalive = byahoo_keepalive; 360 ret->logout = byahoo_logout; 361 362 ret->buddy_msg = byahoo_buddy_msg; 398 363 ret->get_info = byahoo_get_info; 399 364 ret->away_states = byahoo_away_states; 400 365 ret->set_away = byahoo_set_away; 401 ret->keepalive = byahoo_keepalive;402 366 ret->add_buddy = byahoo_add_buddy; 403 367 ret->remove_buddy = byahoo_remove_buddy; 404 ret->get_status_string = byahoo_get_status_string;405 368 ret->send_typing = byahoo_send_typing; 406 369 407 ret->chat_ send = byahoo_chat_send;370 ret->chat_msg = byahoo_chat_msg; 408 371 ret->chat_invite = byahoo_chat_invite; 409 372 ret->chat_leave = byahoo_chat_leave; 410 ret->chat_open = byahoo_chat_open; 411 ret->cmp_buddynames = g_strcasecmp; 373 ret->chat_with = byahoo_chat_with; 374 375 ret->handle_cmp = g_strcasecmp; 412 376 413 377 register_protocol(ret); 414 378 } 415 379 416 static struct gaim_connection *byahoo_get_gc_by_id( int id )380 static struct im_connection *byahoo_get_ic_by_id( int id ) 417 381 { 418 382 GSList *l; 419 struct gaim_connection *gc;383 struct im_connection *ic; 420 384 struct byahoo_data *yd; 421 385 422 386 for( l = get_connections(); l; l = l->next ) 423 387 { 424 gc = l->data;425 yd = gc->proto_data;426 427 if( !strcmp(gc->prpl->name, "yahoo")&& yd->y2_id == id )428 return( gc );388 ic = l->data; 389 yd = ic->proto_data; 390 391 if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) 392 return( ic ); 429 393 } 430 394 … … 443 407 }; 444 408 445 void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond )409 void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond ) 446 410 { 447 411 struct byahoo_connect_callback_data *d = data; 448 412 449 if( !byahoo_get_ gc_by_id( d->id ) )413 if( !byahoo_get_ic_by_id( d->id ) ) 450 414 { 451 415 g_free( d ); … … 465 429 }; 466 430 467 void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond )431 gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond ) 468 432 { 469 433 struct byahoo_read_ready_data *d = data; 470 434 471 if( !byahoo_get_gc_by_id( d->id ) ) 472 { 435 if( !byahoo_get_ic_by_id( d->id ) ) 473 436 /* WTF doesn't libyahoo clean this up? */ 474 ext_yahoo_remove_handler( d->id, d->tag ); 475 return; 476 } 437 return FALSE; 477 438 478 439 yahoo_read_ready( d->id, d->fd, d->data ); 440 441 return TRUE; 479 442 } 480 443 … … 487 450 }; 488 451 489 void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond )452 gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond ) 490 453 { 491 454 struct byahoo_write_ready_data *d = data; 492 455 493 if( !byahoo_get_gc_by_id( d->id ) ) 494 { 456 if( !byahoo_get_ic_by_id( d->id ) ) 495 457 /* WTF doesn't libyahoo clean this up? */ 496 ext_yahoo_remove_handler( d->id, d->tag ); 497 return; 498 } 458 return FALSE; 499 459 500 460 yahoo_write_ready( d->id, d->fd, d->data ); 501 } 502 503 void ext_yahoo_login_response( int id, int succ, char *url ) 504 { 505 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 461 462 return FALSE; 463 } 464 465 void ext_yahoo_login_response( int id, int succ, const char *url ) 466 { 467 struct im_connection *ic = byahoo_get_ic_by_id( id ); 506 468 struct byahoo_data *yd = NULL; 507 469 508 if( gc == NULL )470 if( ic == NULL ) 509 471 { 510 472 /* libyahoo2 seems to call this one twice when something … … 516 478 } 517 479 518 yd = (struct byahoo_data *) gc->proto_data;480 yd = (struct byahoo_data *) ic->proto_data; 519 481 520 482 if( succ == YAHOO_LOGIN_OK ) 521 483 { 522 account_online( gc );484 imcb_connected( ic ); 523 485 524 486 yd->logged_in = TRUE; … … 527 489 { 528 490 char *errstr; 529 char *s;491 int allow_reconnect = TRUE; 530 492 531 493 yd->logged_in = FALSE; … … 540 502 { 541 503 errstr = "Logged in on a different machine or device"; 542 gc->wants_to_die = TRUE;504 allow_reconnect = FALSE; 543 505 } 544 506 else if( succ == YAHOO_LOGIN_SOCK ) … … 548 510 549 511 if( url && *url ) 550 { 551 s = g_malloc( strlen( "Error %d (%s). See %s for more information." ) + strlen( url ) + strlen( errstr ) + 16 ); 552 sprintf( s, "Error %d (%s). See %s for more information.", succ, errstr, url ); 553 } 512 imcb_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url ); 554 513 else 555 { 556 s = g_malloc( strlen( "Error %d (%s)" ) + strlen( errstr ) + 16 ); 557 sprintf( s, "Error %d (%s)", succ, errstr ); 558 } 559 560 if( yd->logged_in ) 561 hide_login_progress_error( gc, s ); 562 else 563 hide_login_progress( gc, s ); 564 565 g_free( s ); 566 567 signoff( gc ); 514 imcb_error( ic, "Error %d (%s)", succ, errstr ); 515 516 imc_logout( ic, allow_reconnect ); 568 517 } 569 518 } … … 571 520 void ext_yahoo_got_buddies( int id, YList *buds ) 572 521 { 573 struct gaim_connection *gc = byahoo_get_gc_by_id( id );574 struct byahoo_data *yd = gc->proto_data;522 struct im_connection *ic = byahoo_get_ic_by_id( id ); 523 struct byahoo_data *yd = ic->proto_data; 575 524 YList *bl = buds; 576 525 … … 589 538 } 590 539 591 add_buddy( gc, b->group, b->id, b->real_name ); 540 imcb_add_buddy( ic, b->id, b->group ); 541 imcb_rename_buddy( ic, b->id, b->real_name ); 542 592 543 bl = bl->next; 593 544 } … … 606 557 } 607 558 608 void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) 609 { 610 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 611 612 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 613 ( stat == YAHOO_STATUS_IDLE ) ? away : 0, 614 ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); 615 } 616 617 void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) 618 { 619 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 620 char *m = byahoo_strip( msg ); 621 622 serv_got_im( gc, who, m, 0, 0, strlen( m ) ); 623 g_free( m ); 624 } 625 626 void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize ) 627 { 628 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 629 630 serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 631 } 632 633 void ext_yahoo_typing_notify( int id, char *who, int stat ) 634 { 635 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 636 if (stat == 1) { 637 /* User is typing */ 638 serv_got_typing( gc, who, 1, 1 ); 639 } 640 else { 641 /* User stopped typing */ 642 serv_got_typing( gc, who, 1, 0 ); 643 } 644 } 645 646 void ext_yahoo_system_message( int id, char *msg ) 647 { 648 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 649 650 serv_got_crap( gc, "Yahoo! system message: %s", msg ); 651 } 652 653 void ext_yahoo_webcam_invite( int id, char *from ) 654 { 655 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 656 657 serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); 658 } 659 660 void ext_yahoo_error( int id, char *err, int fatal ) 661 { 662 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 559 void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile ) 560 { 561 struct im_connection *ic = byahoo_get_ic_by_id( id ); 562 char *state_string = NULL; 563 int flags = OPT_LOGGED_IN; 564 565 if( away ) 566 flags |= OPT_AWAY; 567 568 switch (stat) 569 { 570 case YAHOO_STATUS_BRB: 571 state_string = "Be Right Back"; 572 break; 573 case YAHOO_STATUS_BUSY: 574 state_string = "Busy"; 575 break; 576 case YAHOO_STATUS_NOTATHOME: 577 state_string = "Not At Home"; 578 break; 579 case YAHOO_STATUS_NOTATDESK: 580 state_string = "Not At Desk"; 581 break; 582 case YAHOO_STATUS_NOTINOFFICE: 583 state_string = "Not In Office"; 584 break; 585 case YAHOO_STATUS_ONPHONE: 586 state_string = "On Phone"; 587 break; 588 case YAHOO_STATUS_ONVACATION: 589 state_string = "On Vacation"; 590 break; 591 case YAHOO_STATUS_OUTTOLUNCH: 592 state_string = "Out To Lunch"; 593 break; 594 case YAHOO_STATUS_STEPPEDOUT: 595 state_string = "Stepped Out"; 596 break; 597 case YAHOO_STATUS_INVISIBLE: 598 state_string = "Invisible"; 599 break; 600 case YAHOO_STATUS_CUSTOM: 601 state_string = "Away"; 602 break; 603 case YAHOO_STATUS_IDLE: 604 state_string = "Idle"; 605 break; 606 case YAHOO_STATUS_OFFLINE: 607 state_string = "Offline"; 608 flags = 0; 609 break; 610 case YAHOO_STATUS_NOTIFY: 611 state_string = "Notify"; 612 break; 613 } 614 615 imcb_buddy_status( ic, who, flags, state_string, msg ); 616 617 /* Not implemented yet... 618 if( stat == YAHOO_STATUS_IDLE ) 619 imcb_buddy_times( ic, who, 0, away ); 620 */ 621 } 622 623 void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 ) 624 { 625 struct im_connection *ic = byahoo_get_ic_by_id( id ); 626 char *m; 627 628 if( msg ) 629 { 630 m = byahoo_strip( msg ); 631 imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); 632 g_free( m ); 633 } 634 } 635 636 void ext_yahoo_got_file( int id, 637 const char *ignored, 638 const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize ) 639 { 640 struct im_connection *ic = byahoo_get_ic_by_id( id ); 641 642 imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 643 } 644 645 void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat ) 646 { 647 struct im_connection *ic = byahoo_get_ic_by_id( id ); 648 649 if( stat == 1 ) 650 imcb_buddy_typing( ic, (char*) who, OPT_TYPING ); 651 else 652 imcb_buddy_typing( ic, (char*) who, 0 ); 653 } 654 655 void ext_yahoo_system_message( int id, const char *msg ) 656 { 657 struct im_connection *ic = byahoo_get_ic_by_id( id ); 658 659 imcb_log( ic, "Yahoo! system message: %s", msg ); 660 } 661 662 void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from ) 663 { 664 struct im_connection *ic = byahoo_get_ic_by_id( id ); 665 666 imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); 667 } 668 669 void ext_yahoo_error( int id, const char *err, int fatal, int num ) 670 { 671 struct im_connection *ic = byahoo_get_ic_by_id( id ); 672 673 imcb_error( ic, "%s", err ); 663 674 664 675 if( fatal ) 665 { 666 hide_login_progress_error( gc, err ); 667 signoff( gc ); 668 } 669 else 670 { 671 do_error_dialog( gc, err, "Yahoo! error" ); 672 } 676 imc_logout( ic, TRUE ); 673 677 } 674 678 … … 687 691 688 692 inp->d = d; 689 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d );693 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); 690 694 } 691 695 else if( cond == YAHOO_INPUT_WRITE ) … … 698 702 699 703 inp->d = d; 700 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d );704 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d ); 701 705 } 702 706 else … … 729 733 } 730 734 731 gaim_input_remove( tag );732 } 733 734 int ext_yahoo_connect_async( int id, c har *host, int port, yahoo_connect_callback callback, void *data )735 b_event_remove( tag ); 736 } 737 738 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data ) 735 739 { 736 740 struct byahoo_connect_callback_data *d; … … 738 742 739 743 d = g_new0( struct byahoo_connect_callback_data, 1 ); 740 if( ( fd = proxy_connect( host, port, ( GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 )744 if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 ) 741 745 { 742 746 g_free( d ); … … 753 757 /* Because we don't want asynchronous connects in BitlBee, and because 754 758 libyahoo doesn't seem to use this one anyway, this one is now defunct. */ 755 int ext_yahoo_connect(c har *host, int port)759 int ext_yahoo_connect(const char *host, int port) 756 760 { 757 761 #if 0 … … 796 800 { 797 801 yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); 798 add_chat_buddy( inv->c, inv->gc->username);802 imcb_chat_add_buddy( inv->c, inv->ic->acc->user ); 799 803 g_free( inv->name ); 800 804 g_free( inv ); … … 804 808 { 805 809 yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); 806 serv_got_chat_left( inv->gc, inv->c->id);810 imcb_chat_free( inv->c ); 807 811 g_free( inv->name ); 808 812 g_free( inv ); 809 813 } 810 814 811 void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members ) 812 { 813 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 815 void ext_yahoo_got_conf_invite( int id, const char *ignored, 816 const char *who, const char *room, const char *msg, YList *members ) 817 { 818 struct im_connection *ic = byahoo_get_ic_by_id( id ); 814 819 struct byahoo_conf_invitation *inv; 815 820 char txt[1024]; … … 819 824 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); 820 825 inv->name = g_strdup( room ); 821 inv->c = serv_got_joined_chat( gc, ++byahoo_chat_id,room );826 inv->c = imcb_chat_new( ic, (char*) room ); 822 827 inv->c->data = members; 823 828 inv->yid = id; 824 829 inv->members = members; 825 inv-> gc = gc;830 inv->ic = ic; 826 831 827 832 for( m = members; m; m = m->next ) 828 if( g_strcasecmp( m->data, gc->username) != 0 )829 add_chat_buddy( inv->c, m->data );833 if( g_strcasecmp( m->data, ic->acc->user ) != 0 ) 834 imcb_chat_add_buddy( inv->c, m->data ); 830 835 831 836 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); 832 837 833 do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf );834 } 835 836 void ext_yahoo_conf_userdecline( int id, c har *who, char *room,char *msg )837 { 838 struct gaim_connection *gc = byahoo_get_gc_by_id( id );839 840 serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg );841 } 842 843 void ext_yahoo_conf_userjoin( int id, c har *who,char *room )844 { 845 struct gaim_connection *gc = byahoo_get_gc_by_id( id );846 struct conversation*c;847 848 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );838 imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); 839 } 840 841 void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg ) 842 { 843 struct im_connection *ic = byahoo_get_ic_by_id( id ); 844 845 imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); 846 } 847 848 void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room ) 849 { 850 struct im_connection *ic = byahoo_get_ic_by_id( id ); 851 struct groupchat *c; 852 853 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 849 854 850 855 if( c ) 851 add_chat_buddy( c, who ); 852 } 853 854 void ext_yahoo_conf_userleave( int id, char *who, char *room ) 855 { 856 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 857 struct conversation *c; 858 859 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 856 imcb_chat_add_buddy( c, (char*) who ); 857 } 858 859 void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room ) 860 861 { 862 struct im_connection *ic = byahoo_get_ic_by_id( id ); 863 struct groupchat *c; 864 865 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 860 866 861 867 if( c ) 862 remove_chat_buddy( c,who, "" );863 } 864 865 void ext_yahoo_conf_message( int id, c har *who, char *room,char *msg, int utf8 )866 { 867 struct gaim_connection *gc = byahoo_get_gc_by_id( id );868 imcb_chat_remove_buddy( c, (char*) who, "" ); 869 } 870 871 void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 ) 872 { 873 struct im_connection *ic = byahoo_get_ic_by_id( id ); 868 874 char *m = byahoo_strip( msg ); 869 struct conversation *c; 870 871 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 872 873 serv_got_chat_in( gc, c ? c->id : 0, who, 0, m, 0 ); 875 struct groupchat *c; 876 877 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 878 879 if( c ) 880 imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 ); 874 881 g_free( m ); 875 882 } 876 883 877 void ext_yahoo_chat_cat_xml( int id, char *xml ) 878 { 879 } 880 881 void ext_yahoo_chat_join( int id, char *room, char *topic, YList *members, int fd ) 882 { 883 } 884 885 void ext_yahoo_chat_userjoin( int id, char *room, struct yahoo_chat_member *who ) 886 { 887 } 888 889 void ext_yahoo_chat_userleave( int id, char *room, char *who ) 890 { 891 } 892 893 void ext_yahoo_chat_message( int id, char *who, char *room, char *msg, int msgtype, int utf8 ) 894 { 895 } 896 897 void ext_yahoo_chat_yahoologout( int id ) 898 { 899 } 900 901 void ext_yahoo_chat_yahooerror( int id ) 902 { 903 } 904 905 void ext_yahoo_contact_added( int id, char *myid, char *who, char *msg ) 906 { 907 } 908 909 void ext_yahoo_rejected( int id, char *who, char *msg ) 910 { 911 } 912 913 void ext_yahoo_game_notify( int id, char *who, int stat ) 914 { 915 } 916 917 void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) 918 { 919 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 920 921 if( from && subj ) 922 serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj ); 884 void ext_yahoo_chat_cat_xml( int id, const char *xml ) 885 { 886 } 887 888 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd ) 889 { 890 } 891 892 void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who ) 893 { 894 free(who->id); 895 free(who->alias); 896 free(who->location); 897 free(who); 898 } 899 900 void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who ) 901 { 902 } 903 904 void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 ) 905 { 906 } 907 908 void ext_yahoo_chat_yahoologout( int id, const char *me ) 909 { 910 } 911 912 void ext_yahoo_chat_yahooerror( int id, const char *me ) 913 { 914 } 915 916 void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) 917 { 918 /* Groups schmoups. If I want to handle groups properly I can get the 919 buddy data from some internal libyahoo2 structure. */ 920 imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL ); 921 } 922 923 void ext_yahoo_rejected( int id, const char *who, const char *msg ) 924 { 925 } 926 927 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat ) 928 { 929 } 930 931 void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt ) 932 { 933 struct im_connection *ic = byahoo_get_ic_by_id( id ); 934 935 if( !set_getbool( &ic->acc->set, "mail_notifications" ) ) 936 ; /* The user doesn't care. */ 937 else if( from && subj ) 938 imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); 923 939 else if( cnt > 0 ) 924 serv_got_crap( gc, "Received %d new e-mails", cnt );925 } 926 927 void ext_yahoo_webcam_invite_reply( int id, c har *from, int accept )928 { 929 } 930 931 void ext_yahoo_webcam_closed( int id, c har *who, int reason )940 imcb_log( ic, "Received %d new e-mails", cnt ); 941 } 942 943 void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept ) 944 { 945 } 946 947 void ext_yahoo_webcam_closed( int id, const char *who, int reason ) 932 948 { 933 949 } … … 937 953 } 938 954 939 void ext_yahoo_webcam_viewer( int id, c har *who, int connect )955 void ext_yahoo_webcam_viewer( int id, const char *who, int connect ) 940 956 { 941 957 } … … 945 961 } 946 962 947 int ext_yahoo_log( c har *fmt, ... )963 int ext_yahoo_log( const char *fmt, ... ) 948 964 { 949 965 return( 0 ); … … 953 969 { 954 970 } 971 972 void ext_yahoo_got_ping( int id, const char *msg) 973 { 974 } 975 976 void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {} 977 void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {} 978 979 void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){} 980 void ext_yahoo_buddyicon_uploaded(int id, const char *url){}
Note: See TracChangeset
for help on using the changeset viewer.