- Timestamp:
- 2009-01-07T01:23:38Z (16 years ago)
- Branches:
- master
- Children:
- e200daf
- Parents:
- 6e14204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skype/skype.c
r6e14204 r9f2f25f 560 560 } 561 561 562 static void skype_parse_call(struct im_connection *ic, char *line) 563 { 564 struct skype_data *sd = ic->proto_data; 565 char *id = strchr(line, ' '); 566 char buf[1024]; 567 568 if (++id) { 569 char *info = strchr(id, ' '); 570 571 if (!info) 572 return; 573 *info = '\0'; 574 info++; 575 if (!strncmp(info, "FAILUREREASON ", 14)) 576 sd->failurereason = atoi(strchr(info, ' ')); 577 else if (!strcmp(info, "STATUS RINGING")) { 578 if (sd->call_id) 579 g_free(sd->call_id); 580 sd->call_id = g_strdup(id); 581 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 582 skype_write(ic, buf); 583 sd->call_status = SKYPE_CALL_RINGING; 584 } else if (!strcmp(info, "STATUS MISSED")) { 585 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 586 skype_write(ic, buf); 587 sd->call_status = SKYPE_CALL_MISSED; 588 } else if (!strcmp(info, "STATUS CANCELLED")) { 589 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 590 skype_write(ic, buf); 591 sd->call_status = SKYPE_CALL_CANCELLED; 592 } else if (!strcmp(info, "STATUS FINISHED")) { 593 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 594 skype_write(ic, buf); 595 sd->call_status = SKYPE_CALL_FINISHED; 596 } else if (!strcmp(info, "STATUS REFUSED")) { 597 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 598 skype_write(ic, buf); 599 sd->call_status = SKYPE_CALL_REFUSED; 600 } else if (!strcmp(info, "STATUS UNPLACED")) { 601 if (sd->call_id) 602 g_free(sd->call_id); 603 /* Save the ID for later usage (Cancel/Finish). */ 604 sd->call_id = g_strdup(id); 605 sd->call_out = TRUE; 606 } else if (!strcmp(info, "STATUS FAILED")) { 607 imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); 608 sd->call_id = NULL; 609 } else if (!strncmp(info, "DURATION ", 9)) { 610 if (sd->call_duration) 611 g_free(sd->call_duration); 612 sd->call_duration = g_strdup(info+9); 613 } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { 614 info += 15; 615 if (sd->call_status) { 616 switch (sd->call_status) { 617 case SKYPE_CALL_RINGING: 618 if (sd->call_out) 619 imcb_log(ic, "You are currently ringing the user %s.", info); 620 else { 621 g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); 622 skype_call_ask(ic, sd->call_id, buf); 623 } 624 break; 625 case SKYPE_CALL_MISSED: 626 imcb_log(ic, "You have missed a call from user %s.", info); 627 break; 628 case SKYPE_CALL_CANCELLED: 629 imcb_log(ic, "You cancelled the call to the user %s.", info); 630 sd->call_status = 0; 631 sd->call_out = FALSE; 632 break; 633 case SKYPE_CALL_REFUSED: 634 if (sd->call_out) 635 imcb_log(ic, "The user %s refused the call.", info); 636 else 637 imcb_log(ic, "You refused the call from user %s.", info); 638 sd->call_out = FALSE; 639 break; 640 case SKYPE_CALL_FINISHED: 641 if (sd->call_duration) 642 imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); 643 else 644 imcb_log(ic, "You finished the call to the user %s.", info); 645 sd->call_out = FALSE; 646 break; 647 default: 648 /* Don't be noisy, ignore other statuses for now. */ 649 break; 650 } 651 sd->call_status = 0; 652 } 653 } 654 } 655 } 656 562 657 static gboolean skype_read_callback(gpointer data, gint fd, 563 658 b_input_condition cond) … … 585 680 if (!strncmp(line, "USERS ", 6)) 586 681 skype_parse_users(ic, line); 587 else if (!strncmp(line, "USER ", 5)) {682 else if (!strncmp(line, "USER ", 5)) 588 683 skype_parse_user(ic, line); 589 } else if (!strncmp(line, "CHATMESSAGE ", 12)) {684 else if (!strncmp(line, "CHATMESSAGE ", 12)) 590 685 skype_parse_chatmessage(ic, line); 591 } else if (!strncmp(line, "CALL ", 5)) { 592 char *id = strchr(line, ' '); 593 if (++id) { 594 char *info = strchr(id, ' '); 595 *info = '\0'; 596 info++; 597 if (!strncmp(info, "FAILUREREASON ", 14)) 598 sd->failurereason = atoi(strchr(info, ' ')); 599 else if (!strcmp(info, "STATUS RINGING")) { 600 if (sd->call_id) 601 g_free(sd->call_id); 602 sd->call_id = g_strdup(id); 603 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 604 skype_write(ic, buf); 605 sd->call_status = SKYPE_CALL_RINGING; 606 } else if (!strcmp(info, "STATUS MISSED")) { 607 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 608 skype_write(ic, buf); 609 sd->call_status = SKYPE_CALL_MISSED; 610 } else if (!strcmp(info, "STATUS CANCELLED")) { 611 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 612 skype_write(ic, buf); 613 sd->call_status = SKYPE_CALL_CANCELLED; 614 } else if (!strcmp(info, "STATUS FINISHED")) { 615 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 616 skype_write(ic, buf); 617 sd->call_status = SKYPE_CALL_FINISHED; 618 } else if (!strcmp(info, "STATUS REFUSED")) { 619 g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); 620 skype_write(ic, buf); 621 sd->call_status = SKYPE_CALL_REFUSED; 622 } else if (!strcmp(info, "STATUS UNPLACED")) { 623 if (sd->call_id) 624 g_free(sd->call_id); 625 /* Save the ID for later usage (Cancel/Finish). */ 626 sd->call_id = g_strdup(id); 627 sd->call_out = TRUE; 628 } else if (!strcmp(info, "STATUS FAILED")) { 629 imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); 630 sd->call_id = NULL; 631 } else if (!strncmp(info, "DURATION ", 9)) { 632 if (sd->call_duration) 633 g_free(sd->call_duration); 634 sd->call_duration = g_strdup(info+9); 635 } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { 636 info += 15; 637 if (sd->call_status) { 638 switch (sd->call_status) { 639 case SKYPE_CALL_RINGING: 640 if (sd->call_out) 641 imcb_log(ic, "You are currently ringing the user %s.", info); 642 else { 643 g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); 644 skype_call_ask(ic, sd->call_id, buf); 645 } 646 break; 647 case SKYPE_CALL_MISSED: 648 imcb_log(ic, "You have missed a call from user %s.", info); 649 break; 650 case SKYPE_CALL_CANCELLED: 651 imcb_log(ic, "You cancelled the call to the user %s.", info); 652 sd->call_status = 0; 653 sd->call_out = FALSE; 654 break; 655 case SKYPE_CALL_REFUSED: 656 if (sd->call_out) 657 imcb_log(ic, "The user %s refused the call.", info); 658 else 659 imcb_log(ic, "You refused the call from user %s.", info); 660 sd->call_out = FALSE; 661 break; 662 case SKYPE_CALL_FINISHED: 663 if (sd->call_duration) 664 imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); 665 else 666 imcb_log(ic, "You finished the call to the user %s.", info); 667 sd->call_out = FALSE; 668 break; 669 default: 670 /* Don't be noisy, ignore other statuses for now. */ 671 break; 672 } 673 sd->call_status = 0; 674 } 675 } 676 } 677 } else if (!strncmp(line, "FILETRANSFER ", 13)) { 686 else if (!strncmp(line, "CALL ", 5)) 687 skype_parse_call(ic, line); 688 else if (!strncmp(line, "FILETRANSFER ", 13)) { 678 689 char *id = strchr(line, ' '); 679 690 if (++id) {
Note: See TracChangeset
for help on using the changeset viewer.