- Timestamp:
- 2011-01-02T02:32:38Z (14 years ago)
- Branches:
- master
- Children:
- 54ca269
- Parents:
- 8b8d1bed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skype/skype.c
r8b8d1bed r89d6845 2 2 * skype.c - Skype plugin for BitlBee 3 3 * 4 * Copyright (c) 2007, 2008, 2009, 2010 by Miklos Vajna <vmiklos@frugalware.org>4 * Copyright (c) 2007, 2008, 2009, 2010, 2011 by Miklos Vajna <vmiklos@frugalware.org> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 108 108 /* If this is just an update of an already received message. */ 109 109 int is_edit; 110 /* List of struct skype_group* */ 111 GList *groups; 110 112 }; 111 113 … … 119 121 /* This is also used for call IDs for simplicity */ 120 122 char *handle; 123 }; 124 125 struct skype_group { 126 int id; 127 char *name; 128 GList *users; 121 129 }; 122 130 … … 736 744 } 737 745 746 static struct skype_group *skype_group_by_id(struct im_connection *ic, int id) { 747 struct skype_data *sd = ic->proto_data; 748 int i; 749 750 for (i = 0; i < g_list_length(sd->groups); i++) { 751 struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i); 752 753 if (sg->id == id) 754 return sg; 755 } 756 return NULL; 757 } 758 759 static void skype_group_free(struct skype_group* sg, gboolean usersonly) { 760 int i; 761 762 for (i = 0; i < g_list_length(sg->users); i++) { 763 char *user = g_list_nth_data(sg->users, i); 764 g_free(user); 765 } 766 sg->users = NULL; 767 if (usersonly) 768 return; 769 g_free(sg->name); 770 g_free(sg); 771 } 772 773 static void skype_parse_group(struct im_connection *ic, char *line) 774 { 775 struct skype_data *sd = ic->proto_data; 776 char *id = strchr(line, ' '); 777 778 if (!++id) 779 return; 780 781 char *info = strchr(id, ' '); 782 783 if (!info) 784 return; 785 *info = '\0'; 786 info++; 787 788 if (!strncmp(info, "DISPLAYNAME ", 12)) { 789 info += 12; 790 791 /* Name given for a group ID: try to update it or insert a new 792 * one if not found */ 793 struct skype_group *sg = skype_group_by_id(ic, atoi(id)); 794 if (sg) { 795 g_free(sg->name); 796 sg->name = g_strdup(info); 797 } else { 798 sg = g_new0(struct skype_group, 1); 799 sg->id = atoi(id); 800 sg->name = g_strdup(info); 801 sd->groups = g_list_append(sd->groups, sg); 802 } 803 } else if (!strncmp(info, "USERS ", 6)) { 804 struct skype_group *sg = skype_group_by_id(ic, atoi(id)); 805 806 if (sg) { 807 char **i; 808 char **users = g_strsplit(info + 6, ", ", 0); 809 810 skype_group_free(sg, TRUE); 811 i = users; 812 while (*i) { 813 sg->users = g_list_append(sg->users, g_strdup(*i)); 814 i++; 815 } 816 g_strfreev(users); 817 } else 818 log_message(LOGLVL_ERROR, "No skype group with id %s. That's probably a bug.", id); 819 } 820 } 821 738 822 static void skype_parse_chat(struct im_connection *ic, char *line) 739 823 { … … 893 977 { "FILETRANSFER ", skype_parse_filetransfer }, 894 978 { "CHAT ", skype_parse_chat }, 979 { "GROUP ", skype_parse_group }, 895 980 { "PASSWORD ", skype_parse_password }, 896 981 { "PROFILE PSTN_BALANCE ", skype_parse_profile }, … … 1007 1092 { 1008 1093 struct skype_data *sd = ic->proto_data; 1094 int i; 1009 1095 1010 1096 skype_printf(ic, "SET USERSTATUS OFFLINE\n"); 1011 1097 1098 for (i = 0; i < g_list_length(sd->groups); i++) { 1099 struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i); 1100 skype_group_free(sg, FALSE); 1101 } 1012 1102 g_free(sd->username); 1013 1103 g_free(sd->handle);
Note: See TracChangeset
for help on using the changeset viewer.