Mercurial > pidgin.yaz
comparison src/protocols/gg/confer.c @ 12373:508512caa22e
[gaim-migrate @ 14677]
deryni pointed out that ggp_buddy_get_name leaks when the user isn't a buddy. I went to fix that and tweaked a bunch of code.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 06 Dec 2005 19:50:47 +0000 |
parents | 8724718d387f |
children | 4eae108efdde |
comparison
equal
deleted
inserted
replaced
12372:188d7e79166b | 12373:508512caa22e |
---|---|
54 | 54 |
55 if (g_utf8_collate(chat->name, chat_name) != 0) | 55 if (g_utf8_collate(chat->name, chat_name) != 0) |
56 continue; | 56 continue; |
57 | 57 |
58 if (g_list_find(chat->participants, str_uin) == NULL) { | 58 if (g_list_find(chat->participants, str_uin) == NULL) { |
59 GaimBuddy *buddy; | |
60 | |
59 chat->participants = g_list_append( | 61 chat->participants = g_list_append( |
60 chat->participants, str_uin); | 62 chat->participants, str_uin); |
61 | 63 |
62 conv = ggp_confer_find_by_name(gc, chat_name); | 64 conv = ggp_confer_find_by_name(gc, chat_name); |
63 | 65 |
64 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | 66 buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); |
65 ggp_buddy_get_name(gc, uin), NULL, | 67 if (buddy != NULL) { |
66 GAIM_CBFLAGS_NONE, TRUE); | 68 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
69 gaim_buddy_get_alias(buddy), NULL, | |
70 GAIM_CBFLAGS_NONE, TRUE); | |
71 } else { | |
72 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | |
73 str_uin, NULL, | |
74 GAIM_CBFLAGS_NONE, TRUE); | |
75 } | |
67 } | 76 } |
68 break; | 77 break; |
69 } | 78 } |
79 | |
80 g_free(str_uin); | |
70 } | 81 } |
71 /* }}} */ | 82 /* }}} */ |
72 | 83 |
73 /* void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */ | 84 /* void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */ |
74 void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, | 85 void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, |
75 const uin_t *recipients, int count) | 86 const uin_t *recipients, int count) |
76 { | 87 { |
77 GaimConversation *conv; | |
78 GGPInfo *info = gc->proto_data; | 88 GGPInfo *info = gc->proto_data; |
79 GGPChat *chat; | |
80 GList *l; | 89 GList *l; |
81 int i; | |
82 gchar *uin; | |
83 | 90 |
84 for (l = info->chats; l != NULL; l = l->next) { | 91 for (l = info->chats; l != NULL; l = l->next) { |
85 chat = l->data; | 92 GGPChat *chat = l->data; |
93 int i; | |
86 | 94 |
87 if (g_utf8_collate(chat->name, chat_name) != 0) | 95 if (g_utf8_collate(chat->name, chat_name) != 0) |
88 continue; | 96 continue; |
89 | 97 |
90 for (i = 0; i < count; i++) { | 98 for (i = 0; i < count; i++) { |
91 uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); | 99 gchar *str_uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); |
100 GaimConversation *conv; | |
101 GaimBuddy *buddy; | |
92 | 102 |
93 if (g_list_find(chat->participants, uin) != NULL) { | 103 if (g_list_find(chat->participants, str_uin) != NULL) { |
94 g_free(uin); | 104 g_free(str_uin); |
95 continue; | 105 continue; |
96 } | 106 } |
97 | 107 |
98 chat->participants = g_list_append(chat->participants, uin); | 108 chat->participants = g_list_append(chat->participants, str_uin); |
99 conv = ggp_confer_find_by_name(gc, chat_name); | 109 conv = ggp_confer_find_by_name(gc, chat_name); |
100 | 110 |
101 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | 111 buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); |
102 ggp_buddy_get_name(gc, recipients[i]), | 112 if (buddy != NULL) { |
103 NULL, GAIM_CBFLAGS_NONE, TRUE); | 113 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
104 | 114 gaim_buddy_get_alias(buddy), NULL, |
105 g_free(uin); | 115 GAIM_CBFLAGS_NONE, TRUE); |
116 } else { | |
117 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | |
118 str_uin, NULL, | |
119 GAIM_CBFLAGS_NONE, TRUE); | |
120 } | |
121 g_free(str_uin); | |
106 } | 122 } |
107 break; | 123 break; |
108 } | 124 } |
109 } | 125 } |
110 /* }}} */ | 126 /* }}} */ |
113 const char *ggp_confer_find_by_participants(GaimConnection *gc, | 129 const char *ggp_confer_find_by_participants(GaimConnection *gc, |
114 const uin_t *recipients, int count) | 130 const uin_t *recipients, int count) |
115 { | 131 { |
116 GGPInfo *info = gc->proto_data; | 132 GGPInfo *info = gc->proto_data; |
117 GGPChat *chat = NULL; | 133 GGPChat *chat = NULL; |
118 GList *l, *m; | 134 GList *l; |
119 int i; | 135 int matches; |
120 int maches; | |
121 | 136 |
122 g_return_val_if_fail(info->chats != NULL, NULL); | 137 g_return_val_if_fail(info->chats != NULL, NULL); |
123 | 138 |
124 for (l = info->chats; l != NULL; l = l->next) { | 139 for (l = info->chats; l != NULL; l = l->next) { |
140 GList *m; | |
141 | |
125 chat = l->data; | 142 chat = l->data; |
126 maches = 0; | 143 matches = 0; |
127 | 144 |
128 for (m = chat->participants; m != NULL; m = m->next) { | 145 for (m = chat->participants; m != NULL; m = m->next) { |
129 uin_t p = ggp_str_to_uin(m->data); | 146 uin_t p = ggp_str_to_uin(m->data); |
147 int i; | |
130 | 148 |
131 for (i = 0; i < count; i++) | 149 for (i = 0; i < count; i++) |
132 if (p == recipients[i]) | 150 if (p == recipients[i]) |
133 maches++; | 151 matches++; |
134 } | 152 } |
135 | 153 |
136 if (maches == count) | 154 if (matches == count) |
137 break; | 155 break; |
138 | 156 |
139 chat = NULL; | 157 chat = NULL; |
140 } | 158 } |
141 | 159 |