Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/group_internal.c @ 23753:5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
* Commit to Pidgin
2008.08.06 - ccpaging <ecc_hy(at)hotmail.com>
* Rename names of variables, Group, to Room
* Functions of group_network merged into qq_network and qq_process
* Canceled managing glist of group packet, add sub_cmdd and room_id to transaction
* Fixed error of demo group:
If 'room list' and 'room infor' are not setup, response received from server will emits
'room_id = 0' packet.
2008.08.04 - ccpaging <ecc_hy(at)hotmail.com>
* Use new crypt/decrypt functions
* Rename crypt.c/h to qq_crypt.c/h
* Clean code of decrypt functions
* Fixed decryption failure
2008.08.04 - csyfek <csyfek(at)gmail.com>
* Update AUTHORS
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 04:32:14 +0000 |
parents | bdb38a8bf721 |
children | 967344bc404d |
comparison
equal
deleted
inserted
replaced
23748:107166bb2a64 | 23753:5f454b975a99 |
---|---|
66 g = qq_get_purple_group(PURPLE_GROUP_QQ_QUN); | 66 g = qq_get_purple_group(PURPLE_GROUP_QQ_QUN); |
67 purple_blist_add_chat(chat, g, NULL); | 67 purple_blist_add_chat(chat, g, NULL); |
68 purple_debug(PURPLE_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, ext_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(PurpleConnection *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 ext_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 |
81 g_return_val_if_fail(internal_id > 0, NULL); | 81 g_return_val_if_fail(internal_id > 0, NULL); |
82 qd = (qq_data *) gc->proto_data; | 82 qd = (qq_data *) gc->proto_data; |
83 | 83 |
84 group = g_new0(qq_group, 1); | 84 group = g_new0(qq_group, 1); |
85 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; | 85 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; |
86 group->my_status_desc = _qq_group_set_my_status_desc(group); | 86 group->my_status_desc = _qq_group_set_my_status_desc(group); |
87 group->internal_group_id = internal_id; | 87 group->id = internal_id; |
88 group->external_group_id = external_id; | 88 group->ext_id = ext_id; |
89 group->group_type = 0x01; /* assume permanent Qun */ | 89 group->type8 = 0x01; /* assume permanent Qun */ |
90 group->creator_uid = 10000; /* assume by QQ admin */ | 90 group->creator_uid = 10000; /* assume by QQ admin */ |
91 group->group_category = 0x01; | 91 group->group_category = 0x01; |
92 group->auth_type = 0x02; /* assume need auth */ | 92 group->auth_type = 0x02; /* assume need auth */ |
93 group->group_name_utf8 = g_strdup(group_name_utf8 == NULL ? "" : group_name_utf8); | 93 group->group_name_utf8 = g_strdup(group_name_utf8 == NULL ? "" : group_name_utf8); |
94 group->group_desc_utf8 = g_strdup(""); | 94 group->group_desc_utf8 = g_strdup(""); |
99 _qq_group_add_to_blist(gc, group); | 99 _qq_group_add_to_blist(gc, group); |
100 | 100 |
101 return group; | 101 return group; |
102 } | 102 } |
103 | 103 |
104 void qq_group_delete_internal_record(qq_data *qd, guint32 internal_group_id) | 104 void qq_group_delete_internal_record(qq_data *qd, guint32 id) |
105 { | 105 { |
106 qq_group *group; | 106 qq_group *group; |
107 GList *list; | 107 GList *list; |
108 | 108 |
109 list = qd->groups; | 109 list = qd->groups; |
110 while (list != NULL) { | 110 while (list != NULL) { |
111 group = (qq_group *) qd->groups->data; | 111 group = (qq_group *) qd->groups->data; |
112 if (internal_group_id == group->internal_group_id) { | 112 if (id == group->id) { |
113 qd->groups = g_list_remove(qd->groups, group); | 113 qd->groups = g_list_remove(qd->groups, group); |
114 qq_group_free(group); | 114 qq_group_free(group); |
115 break; | 115 break; |
116 } else { | 116 } else { |
117 list = list->next; | 117 list = list->next; |
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)); |
128 group->my_status_desc = _qq_group_set_my_status_desc(group); | 128 group->my_status_desc = _qq_group_set_my_status_desc(group); |
129 | 129 |
130 g_hash_table_insert(components, | 130 g_hash_table_insert(components, |
131 g_strdup(QQ_GROUP_KEY_INTERNAL_ID), g_strdup_printf("%d", group->internal_group_id)); | 131 g_strdup(QQ_GROUP_KEY_INTERNAL_ID), g_strdup_printf("%d", group->id)); |
132 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_EXTERNAL_ID), | 132 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_EXTERNAL_ID), |
133 g_strdup_printf("%d", group->external_group_id)); | 133 g_strdup_printf("%d", group->ext_id)); |
134 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_GROUP_TYPE), g_strdup_printf("%d", group->group_type)); | 134 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_TYPE), g_strdup_printf("%d", group->type8)); |
135 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_CREATOR_UID), g_strdup_printf("%d", group->creator_uid)); | 135 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_CREATOR_UID), g_strdup_printf("%d", group->creator_uid)); |
136 g_hash_table_insert(components, | 136 g_hash_table_insert(components, |
137 g_strdup(QQ_GROUP_KEY_GROUP_CATEGORY), g_strdup_printf("%d", group->group_category)); | 137 g_strdup(QQ_GROUP_KEY_GROUP_CATEGORY), g_strdup_printf("%d", group->group_category)); |
138 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_AUTH_TYPE), g_strdup_printf("%d", group->auth_type)); | 138 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_AUTH_TYPE), g_strdup_printf("%d", group->auth_type)); |
139 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_MEMBER_STATUS_DESC), g_strdup(group->my_status_desc)); | 139 g_hash_table_insert(components, g_strdup(QQ_GROUP_KEY_MEMBER_STATUS_DESC), g_strdup(group->my_status_desc)); |
155 group->my_status = | 155 group->my_status = |
156 qq_string_to_dec_value | 156 qq_string_to_dec_value |
157 (NULL == | 157 (NULL == |
158 g_hash_table_lookup(data, | 158 g_hash_table_lookup(data, |
159 QQ_GROUP_KEY_MEMBER_STATUS) ? | 159 QQ_GROUP_KEY_MEMBER_STATUS) ? |
160 g_strdup_printf("%d", | 160 g_strdup_printf("%d", QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) : |
161 QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) : | |
162 g_hash_table_lookup(data, QQ_GROUP_KEY_MEMBER_STATUS)); | 161 g_hash_table_lookup(data, QQ_GROUP_KEY_MEMBER_STATUS)); |
163 group->internal_group_id = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_INTERNAL_ID)); | 162 group->id = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_INTERNAL_ID)); |
164 group->external_group_id = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_EXTERNAL_ID)); | 163 group->ext_id = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_EXTERNAL_ID)); |
165 group->group_type = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_TYPE)); | 164 group->type8 = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_TYPE)); |
166 group->creator_uid = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_CREATOR_UID)); | 165 group->creator_uid = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_CREATOR_UID)); |
167 group->group_category = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_CATEGORY)); | 166 group->group_category = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_CATEGORY)); |
168 group->auth_type = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_AUTH_TYPE)); | 167 group->auth_type = qq_string_to_dec_value(g_hash_table_lookup(data, QQ_GROUP_KEY_AUTH_TYPE)); |
169 group->group_name_utf8 = g_strdup(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_NAME_UTF8)); | 168 group->group_name_utf8 = g_strdup(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_NAME_UTF8)); |
170 group->group_desc_utf8 = g_strdup(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_DESC_UTF8)); | 169 group->group_desc_utf8 = g_strdup(g_hash_table_lookup(data, QQ_GROUP_KEY_GROUP_DESC_UTF8)); |
177 | 176 |
178 /* refresh group local subscription */ | 177 /* refresh group local subscription */ |
179 void qq_group_refresh(PurpleConnection *gc, qq_group *group) | 178 void qq_group_refresh(PurpleConnection *gc, qq_group *group) |
180 { | 179 { |
181 PurpleChat *chat; | 180 PurpleChat *chat; |
182 gchar *external_group_id; | 181 gchar *ext_id; |
183 g_return_if_fail(group != NULL); | 182 g_return_if_fail(group != NULL); |
184 | 183 |
185 external_group_id = g_strdup_printf("%d", group->external_group_id); | 184 ext_id = g_strdup_printf("%d", group->ext_id); |
186 chat = purple_blist_find_chat(purple_connection_get_account(gc), external_group_id); | 185 chat = purple_blist_find_chat(purple_connection_get_account(gc), ext_id); |
187 g_free(external_group_id); | 186 g_free(ext_id); |
188 if (chat == NULL && group->my_status != QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) { | 187 if (chat == NULL && group->my_status != QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) { |
189 _qq_group_add_to_blist(gc, group); | 188 _qq_group_add_to_blist(gc, group); |
190 } else if (chat != NULL) { /* we have a local record, update its info */ | 189 } else if (chat != NULL) { /* we have a local record, update its info */ |
191 /* if there is group_name_utf8, we update the group name */ | 190 /* if there is group_name_utf8, we update the group name */ |
192 if (group->group_name_utf8 != NULL && strlen(group->group_name_utf8) > 0) | 191 if (group->group_name_utf8 != NULL && strlen(group->group_name_utf8) > 0) |
196 group->my_status_desc = _qq_group_set_my_status_desc(group); | 195 group->my_status_desc = _qq_group_set_my_status_desc(group); |
197 g_hash_table_replace(chat->components, | 196 g_hash_table_replace(chat->components, |
198 g_strdup(QQ_GROUP_KEY_MEMBER_STATUS_DESC), g_strdup(group->my_status_desc)); | 197 g_strdup(QQ_GROUP_KEY_MEMBER_STATUS_DESC), g_strdup(group->my_status_desc)); |
199 g_hash_table_replace(chat->components, | 198 g_hash_table_replace(chat->components, |
200 g_strdup(QQ_GROUP_KEY_INTERNAL_ID), | 199 g_strdup(QQ_GROUP_KEY_INTERNAL_ID), |
201 g_strdup_printf("%d", group->internal_group_id)); | 200 g_strdup_printf("%d", group->id)); |
202 g_hash_table_replace(chat->components, | 201 g_hash_table_replace(chat->components, |
203 g_strdup(QQ_GROUP_KEY_EXTERNAL_ID), | 202 g_strdup(QQ_GROUP_KEY_EXTERNAL_ID), |
204 g_strdup_printf("%d", group->external_group_id)); | 203 g_strdup_printf("%d", group->ext_id)); |
205 g_hash_table_replace(chat->components, | 204 g_hash_table_replace(chat->components, |
206 g_strdup(QQ_GROUP_KEY_GROUP_TYPE), g_strdup_printf("%d", group->group_type)); | 205 g_strdup(QQ_GROUP_KEY_TYPE), g_strdup_printf("%d", group->type8)); |
207 g_hash_table_replace(chat->components, | 206 g_hash_table_replace(chat->components, |
208 g_strdup(QQ_GROUP_KEY_CREATOR_UID), g_strdup_printf("%d", group->creator_uid)); | 207 g_strdup(QQ_GROUP_KEY_CREATOR_UID), g_strdup_printf("%d", group->creator_uid)); |
209 g_hash_table_replace(chat->components, | 208 g_hash_table_replace(chat->components, |
210 g_strdup(QQ_GROUP_KEY_GROUP_CATEGORY), | 209 g_strdup(QQ_GROUP_KEY_GROUP_CATEGORY), |
211 g_strdup_printf("%d", group->group_category)); | 210 g_strdup_printf("%d", group->group_category)); |