Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/group_internal.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | b8572b937c09 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file group_internal.c | 2 * @file group_internal.c |
3 * | 3 * |
4 * gaim | 4 * purple |
5 * | 5 * |
6 * Gaim is the legal property of its developers, whose names are too numerous | 6 * Purple is the legal property of its developers, whose names are too numerous |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | 7 * to list here. Please refer to the COPYRIGHT file distributed with this |
8 * source distribution. | 8 * source distribution. |
9 * | 9 * |
10 * This program is free software; you can redistribute it and/or modify | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | 11 * it under the terms of the GNU General Public License as published by |
54 } | 54 } |
55 | 55 |
56 return g_strdup(status_desc); | 56 return g_strdup(status_desc); |
57 } | 57 } |
58 | 58 |
59 static void _qq_group_add_to_blist(GaimConnection *gc, qq_group *group) | 59 static void _qq_group_add_to_blist(PurpleConnection *gc, qq_group *group) |
60 { | 60 { |
61 GHashTable *components; | 61 GHashTable *components; |
62 GaimGroup *g; | 62 PurpleGroup *g; |
63 GaimChat *chat; | 63 PurpleChat *chat; |
64 components = qq_group_to_hashtable(group); | 64 components = qq_group_to_hashtable(group); |
65 chat = gaim_chat_new(gaim_connection_get_account(gc), group->group_name_utf8, components); | 65 chat = purple_chat_new(purple_connection_get_account(gc), group->group_name_utf8, components); |
66 g = qq_get_gaim_group(GAIM_GROUP_QQ_QUN); | 66 g = qq_get_purple_group(PURPLE_GROUP_QQ_QUN); |
67 gaim_blist_add_chat(chat, g, NULL); | 67 purple_blist_add_chat(chat, g, NULL); |
68 gaim_debug(GAIM_DEBUG_INFO, "QQ", "You have added group \"%s\" to blist locally\n", group->group_name_utf8); | 68 purple_debug(PURPLE_DEBUG_INFO, "QQ", "You have added group \"%s\" to blist locally\n", group->group_name_utf8); |
69 } | 69 } |
70 | 70 |
71 /* Create a dummy qq_group, which includes only internal_id, external_id, | 71 /* Create a dummy qq_group, which includes only internal_id, external_id, |
72 * and potentially group_name_utf8, in case we need to call group_conv_show_window | 72 * and potentially group_name_utf8, in case we need to call group_conv_show_window |
73 * right after creation. All other attributes are set to empty. | 73 * right after creation. All other attributes are set to empty. |
74 * We need to send a get_group_info to the QQ server to update it right away */ | 74 * We need to send a get_group_info to the QQ server to update it right away */ |
75 qq_group *qq_group_create_internal_record(GaimConnection *gc, | 75 qq_group *qq_group_create_internal_record(PurpleConnection *gc, |
76 guint32 internal_id, guint32 external_id, gchar *group_name_utf8) | 76 guint32 internal_id, guint32 external_id, gchar *group_name_utf8) |
77 { | 77 { |
78 qq_group *group; | 78 qq_group *group; |
79 qq_data *qd; | 79 qq_data *qd; |
80 | 80 |
117 list = list->next; | 117 list = list->next; |
118 } | 118 } |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 /* convert a qq_group to hash-table, which could be component of GaimChat */ | 122 /* convert a qq_group to hash-table, which could be component of PurpleChat */ |
123 GHashTable *qq_group_to_hashtable(qq_group *group) | 123 GHashTable *qq_group_to_hashtable(qq_group *group) |
124 { | 124 { |
125 GHashTable *components; | 125 GHashTable *components; |
126 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 126 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
127 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_MEMBER_STATUS), g_strdup_printf("%d", group->my_status)); | 127 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_MEMBER_STATUS), g_strdup_printf("%d", group->my_status)); |
141 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_GROUP_DESC_UTF8), g_strdup(group->group_desc_utf8)); | 141 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_GROUP_DESC_UTF8), g_strdup(group->group_desc_utf8)); |
142 return components; | 142 return components; |
143 } | 143 } |
144 | 144 |
145 /* create a qq_group from hashtable */ | 145 /* create a qq_group from hashtable */ |
146 qq_group *qq_group_from_hashtable(GaimConnection *gc, GHashTable *data) | 146 qq_group *qq_group_from_hashtable(PurpleConnection *gc, GHashTable *data) |
147 { | 147 { |
148 qq_data *qd; | 148 qq_data *qd; |
149 qq_group *group; | 149 qq_group *group; |
150 | 150 |
151 g_return_val_if_fail(data != NULL, NULL); | 151 g_return_val_if_fail(data != NULL, NULL); |
174 | 174 |
175 return group; | 175 return group; |
176 } | 176 } |
177 | 177 |
178 /* refresh group local subscription */ | 178 /* refresh group local subscription */ |
179 void qq_group_refresh(GaimConnection *gc, qq_group *group) | 179 void qq_group_refresh(PurpleConnection *gc, qq_group *group) |
180 { | 180 { |
181 GaimChat *chat; | 181 PurpleChat *chat; |
182 gchar *external_group_id; | 182 gchar *external_group_id; |
183 g_return_if_fail(group != NULL); | 183 g_return_if_fail(group != NULL); |
184 | 184 |
185 external_group_id = g_strdup_printf("%d", group->external_group_id); | 185 external_group_id = g_strdup_printf("%d", group->external_group_id); |
186 chat = gaim_blist_find_chat(gaim_connection_get_account(gc), external_group_id); | 186 chat = purple_blist_find_chat(purple_connection_get_account(gc), external_group_id); |
187 g_free(external_group_id); | 187 g_free(external_group_id); |
188 if (chat == NULL && group->my_status != QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) { | 188 if (chat == NULL && group->my_status != QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) { |
189 _qq_group_add_to_blist(gc, group); | 189 _qq_group_add_to_blist(gc, group); |
190 } else if (chat != NULL) { /* we have a local record, update its info */ | 190 } else if (chat != NULL) { /* we have a local record, update its info */ |
191 /* if there is group_name_utf8, we update the group name */ | 191 /* if there is group_name_utf8, we update the group name */ |
192 if (group->group_name_utf8 != NULL && strlen(group->group_name_utf8) > 0) | 192 if (group->group_name_utf8 != NULL && strlen(group->group_name_utf8) > 0) |
193 gaim_blist_alias_chat(chat, group->group_name_utf8); | 193 purple_blist_alias_chat(chat, group->group_name_utf8); |
194 g_hash_table_replace(chat->components, | 194 g_hash_table_replace(chat->components, |
195 g_strdup(QQ_GROUP_KEY_MEMBER_STATUS), g_strdup_printf("%d", group->my_status)); | 195 g_strdup(QQ_GROUP_KEY_MEMBER_STATUS), g_strdup_printf("%d", group->my_status)); |
196 group->my_status_desc = _qq_group_set_my_status_desc(group); | 196 group->my_status_desc = _qq_group_set_my_status_desc(group); |
197 g_hash_table_replace(chat->components, | 197 g_hash_table_replace(chat->components, |
198 g_strdup(QQ_GROUP_KEY_MEMBER_STATUS_DESC), g_strdup(group->my_status_desc)); | 198 g_strdup(QQ_GROUP_KEY_MEMBER_STATUS_DESC), g_strdup(group->my_status_desc)); |