- Timestamp:
- 2009-01-07T02:29:07Z (16 years ago)
- Branches:
- master
- Children:
- 16304ab
- Parents:
- 6b9d22a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skype/skype.c
r6b9d22a r62f51ee9 307 307 ptr = g_strdup_printf("%s@skype.com", user); 308 308 imcb_add_buddy(ic, ptr, NULL); 309 if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) 309 if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || 310 !set_getbool(&ic->acc->set, "skypeout_offline"))) 310 311 flags |= OPT_LOGGED_IN; 311 if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0)312 if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME")) 312 313 flags |= OPT_AWAY; 313 314 imcb_buddy_status(ic, ptr, flags, NULL, NULL); … … 359 360 if (sd->info_fullname) { 360 361 if (strlen(sd->info_fullname)) 361 g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); 362 g_string_append_printf(st, "Full Name: %s\n", 363 sd->info_fullname); 362 364 g_free(sd->info_fullname); 363 365 } 364 366 if (sd->info_phonehome) { 365 367 if (strlen(sd->info_phonehome)) 366 g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); 368 g_string_append_printf(st, "Home Phone: %s\n", 369 sd->info_phonehome); 367 370 g_free(sd->info_phonehome); 368 371 } 369 372 if (sd->info_phoneoffice) { 370 373 if (strlen(sd->info_phoneoffice)) 371 g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); 374 g_string_append_printf(st, "Office Phone: %s\n", 375 sd->info_phoneoffice); 372 376 g_free(sd->info_phoneoffice); 373 377 } 374 378 if (sd->info_phonemobile) { 375 379 if (strlen(sd->info_phonemobile)) 376 g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); 380 g_string_append_printf(st, "Mobile Phone: %s\n", 381 sd->info_phonemobile); 377 382 g_free(sd->info_phonemobile); 378 383 } … … 380 385 if (sd->info_nrbuddies) { 381 386 if (strlen(sd->info_nrbuddies)) 382 g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); 387 g_string_append_printf(st, 388 "Contacts: %s\n", sd->info_nrbuddies); 383 389 g_free(sd->info_nrbuddies); 384 390 } … … 390 396 struct tm *gt = gmtime(&t); 391 397 strftime(ib, 256, "%H:%M:%S", gt); 392 g_string_append_printf(st, "Local Time: %s\n", ib); 398 g_string_append_printf(st, 399 "Local Time: %s\n", ib); 393 400 } 394 401 g_free(sd->info_tz); … … 400 407 struct tm *tm = localtime(&it); 401 408 strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); 402 g_string_append_printf(st, "Last Seen: %s\n", ib); 409 g_string_append_printf(st, 410 "Last Seen: %s\n", ib); 403 411 } 404 412 g_free(sd->info_seen); 405 413 } 406 414 if (sd->info_birthday) { 407 if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { 415 if (strlen(sd->info_birthday) && 416 strcmp(sd->info_birthday, "0")) { 408 417 char ib[256]; 409 418 struct tm tm; 410 419 strptime(sd->info_birthday, "%Y%m%d", &tm); 411 420 strftime(ib, 256, "%B %d, %Y", &tm); 412 g_string_append_printf(st, "Birthday: %s\n", ib); 421 g_string_append_printf(st, 422 "Birthday: %s\n", ib); 413 423 414 424 strftime(ib, 256, "%Y", &tm); … … 416 426 time_t t = time(NULL); 417 427 struct tm *lt = localtime(&t); 418 g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year); 428 g_string_append_printf(st, 429 "Age: %d\n", lt->tm_year+1900-year); 419 430 } 420 431 g_free(sd->info_birthday); … … 425 436 while (*iptr++) 426 437 *iptr = tolower(*iptr); 427 g_string_append_printf(st, "Gender: %s\n", sd->info_sex); 438 g_string_append_printf(st, 439 "Gender: %s\n", sd->info_sex); 428 440 } 429 441 g_free(sd->info_sex); … … 436 448 else 437 449 iptr = sd->info_language; 438 g_string_append_printf(st, "Language: %s\n", iptr); 450 g_string_append_printf(st, 451 "Language: %s\n", iptr); 439 452 } 440 453 g_free(sd->info_language); … … 447 460 else 448 461 iptr = sd->info_country; 449 g_string_append_printf(st, "Country: %s\n", iptr); 462 g_string_append_printf(st, 463 "Country: %s\n", iptr); 450 464 } 451 465 g_free(sd->info_country); … … 453 467 if (sd->info_province) { 454 468 if (strlen(sd->info_province)) 455 g_string_append_printf(st, "Region: %s\n", sd->info_province); 469 g_string_append_printf(st, 470 "Region: %s\n", sd->info_province); 456 471 g_free(sd->info_province); 457 472 } 458 473 if (sd->info_city) { 459 474 if (strlen(sd->info_city)) 460 g_string_append_printf(st, "City: %s\n", sd->info_city); 475 g_string_append_printf(st, 476 "City: %s\n", sd->info_city); 461 477 g_free(sd->info_city); 462 478 } 463 479 if (sd->info_homepage) { 464 480 if (strlen(sd->info_homepage)) 465 g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); 481 g_string_append_printf(st, 482 "Homepage: %s\n", sd->info_homepage); 466 483 g_free(sd->info_homepage); 467 484 } 468 485 if (sd->info_about) { 469 486 if (strlen(sd->info_about)) 470 g_string_append_printf(st, "%s\n", sd->info_about); 487 g_string_append_printf(st, "%s\n", 488 sd->info_about); 471 489 g_free(sd->info_about); 472 490 } … … 536 554 for (i = 0; i < g_list_length(sd->body); i++) { 537 555 char *body = g_list_nth_data(sd->body, i); 538 if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { 556 if (!strcmp(sd->type, "SAID") || 557 !strcmp(sd->type, "EMOTED")) { 539 558 if (!strcmp(sd->type, "SAID")) 540 g_snprintf(buf, 1024, "%s", body); 559 g_snprintf(buf, 1024, "%s", 560 body); 541 561 else 542 g_snprintf(buf, 1024, "/me %s", body); 562 g_snprintf(buf, 1024, "/me %s", 563 body); 543 564 if (!gc) 544 565 /* Private message */ 545 imcb_buddy_msg(ic, sd->handle, buf, 0, 0); 566 imcb_buddy_msg(ic, 567 sd->handle, buf, 0, 0); 546 568 else 547 569 /* Groupchat message */ 548 imcb_chat_msg(gc, sd->handle, buf, 0, 0);549 } else if (!strcmp(sd->type, "SETTOPIC")) {550 if (gc)551 imcb_chat_topic(gc, sd->handle, body, 0);552 } else if (!strcmp(sd->type, "LEFT")) {553 if (gc)554 imcb_chat_remove_buddy(gc, sd->handle, NULL);555 }570 imcb_chat_msg(gc, 571 sd->handle, buf, 0, 0); 572 } else if (!strcmp(sd->type, "SETTOPIC") && gc) 573 imcb_chat_topic(gc, 574 sd->handle, body, 0); 575 else if (!strcmp(sd->type, "LEFT") && gc) 576 imcb_chat_remove_buddy(gc, 577 sd->handle, NULL); 556 578 } 557 579 g_list_free(sd->body); … … 607 629 sd->call_out = TRUE; 608 630 } else if (!strcmp(info, "STATUS FAILED")) { 609 imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); 631 imcb_error(ic, "Call failed: %s", 632 skype_call_strerror(sd->failurereason)); 610 633 sd->call_id = NULL; 611 634 } else if (!strncmp(info, "DURATION ", 9)) { … … 615 638 } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { 616 639 info += 15; 617 if (sd->call_status) { 618 switch (sd->call_status) { 619 case SKYPE_CALL_RINGING: 620 if (sd->call_out) 621 imcb_log(ic, "You are currently ringing the user %s.", info); 622 else { 623 g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); 624 skype_call_ask(ic, sd->call_id, buf); 625 } 626 break; 627 case SKYPE_CALL_MISSED: 628 imcb_log(ic, "You have missed a call from user %s.", info); 629 break; 630 case SKYPE_CALL_CANCELLED: 631 imcb_log(ic, "You cancelled the call to the user %s.", info); 632 sd->call_status = 0; 633 sd->call_out = FALSE; 634 break; 635 case SKYPE_CALL_REFUSED: 636 if (sd->call_out) 637 imcb_log(ic, "The user %s refused the call.", info); 638 else 639 imcb_log(ic, "You refused the call from user %s.", info); 640 sd->call_out = FALSE; 641 break; 642 case SKYPE_CALL_FINISHED: 643 if (sd->call_duration) 644 imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); 645 else 646 imcb_log(ic, "You finished the call to the user %s.", info); 647 sd->call_out = FALSE; 648 break; 649 default: 650 /* Don't be noisy, ignore other statuses for now. */ 651 break; 640 if (!sd->call_status) 641 return; 642 switch (sd->call_status) { 643 case SKYPE_CALL_RINGING: 644 if (sd->call_out) 645 imcb_log(ic, "You are currently ringing " 646 "the user %s.", info); 647 else { 648 g_snprintf(buf, 1024, 649 "The user %s is currently ringing you.", 650 info); 651 skype_call_ask(ic, sd->call_id, buf); 652 652 } 653 break; 654 case SKYPE_CALL_MISSED: 655 imcb_log(ic, "You have missed a call from user %s.", 656 info); 657 break; 658 case SKYPE_CALL_CANCELLED: 659 imcb_log(ic, "You cancelled the call to the user %s.", 660 info); 653 661 sd->call_status = 0; 654 } 662 sd->call_out = FALSE; 663 break; 664 case SKYPE_CALL_REFUSED: 665 if (sd->call_out) 666 imcb_log(ic, "The user %s refused the call.", 667 info); 668 else 669 imcb_log(ic, 670 "You refused the call from user %s.", 671 info); 672 sd->call_out = FALSE; 673 break; 674 case SKYPE_CALL_FINISHED: 675 if (sd->call_duration) 676 imcb_log(ic, 677 "You finished the call to the user %s " 678 "(duration: %s seconds).", 679 info, sd->call_duration); 680 else 681 imcb_log(ic, 682 "You finished the call to the user %s.", 683 info); 684 sd->call_out = FALSE; 685 break; 686 default: 687 /* Don't be noisy, ignore other statuses for now. */ 688 break; 689 } 690 sd->call_status = 0; 655 691 } 656 692 } … … 671 707 info++; 672 708 if (!strcmp(info, "STATUS NEW")) { 673 g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); 709 g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", 710 id); 674 711 skype_write(ic, buf); 675 712 sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; 676 713 } else if (!strcmp(info, "STATUS FAILED")) { 677 g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); 714 g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", 715 id); 678 716 skype_write(ic, buf); 679 717 sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; 680 718 } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { 681 719 info += 15; 682 if (sd->filetransfer_status) { 683 switch (sd->filetransfer_status) { 684 case SKYPE_FILETRANSFER_NEW: 685 imcb_log(ic, "The user %s offered a new file for you.", info); 686 break; 687 case SKYPE_FILETRANSFER_FAILED: 688 imcb_log(ic, "Failed to transfer file from user %s.", info); 689 break; 690 } 691 sd->filetransfer_status = 0; 692 } 720 if (!sd->filetransfer_status) 721 return; 722 switch (sd->filetransfer_status) { 723 case SKYPE_FILETRANSFER_NEW: 724 imcb_log(ic, "The user %s offered a new file for you.", 725 info); 726 break; 727 case SKYPE_FILETRANSFER_FAILED: 728 imcb_log(ic, "Failed to transfer file from user %s.", 729 info); 730 break; 731 } 732 sd->filetransfer_status = 0; 693 733 } 694 734 } … … 765 805 * so that we won't rejoin 766 806 * after a /part. */ 767 if (gc && !gc->data) { 768 char **members = g_strsplit(info, " ", 0); 769 int i; 770 for (i = 0; members[i]; i++) { 771 if (!strcmp(members[i], sd->username)) 772 continue; 773 g_snprintf(buf, 1024, "%s@skype.com", members[i]); 774 if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) 775 imcb_chat_add_buddy(gc, buf); 776 } 777 imcb_chat_add_buddy(gc, sd->username); 778 g_strfreev(members); 779 } 807 if (!gc || gc->data) 808 return; 809 char **members = g_strsplit(info, " ", 0); 810 int i; 811 for (i = 0; members[i]; i++) { 812 if (!strcmp(members[i], sd->username)) 813 continue; 814 g_snprintf(buf, 1024, "%s@skype.com", members[i]); 815 if (!g_list_find_custom(gc->in_room, buf, 816 (GCompareFunc)strcmp)) 817 imcb_chat_add_buddy(gc, buf); 818 } 819 imcb_chat_add_buddy(gc, sd->username); 820 g_strfreev(members); 780 821 } 781 822 }
Note: See TracChangeset
for help on using the changeset viewer.