~ubuntu-branches/ubuntu/raring/pidgin/raring

« back to all changes in this revision

Viewing changes to libpurple/protocols/qq/group_opt.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-22 21:51:41 UTC
  • mto: (46.1.1 karmic)
  • mto: This revision was merged to the branch mainline in revision 31.
  • Revision ID: james.westby@ubuntu.com-20081022215141-ofqitm4aggw7x7ip
Tags: upstream-2.5.2
ImportĀ upstreamĀ versionĀ 2.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "header_info.h"
39
39
#include "packet_parse.h"
40
40
#include "qq_network.h"
 
41
#include "qq_process.h"
41
42
#include "utils.h"
42
43
 
43
44
static int _compare_guint32(const void *a,
67
68
        }
68
69
        data_len = 6 + count * 4;
69
70
        data = g_newa(guint8, data_len);
70
 
        
 
71
 
71
72
        bytes = 0;
72
73
        bytes += qq_put8(data + bytes, operation);
73
74
        for (i = 0; i < count; i++)
88
89
        g_return_if_fail(g != NULL && g->gc != NULL && g->id > 0 && g->member > 0);
89
90
        group = qq_room_search_id(g->gc, g->id);
90
91
        g_return_if_fail(group != NULL);
91
 
        qq_send_cmd_group_auth(g->gc, group, QQ_GROUP_AUTH_REQUEST_REJECT, g->member, msg_utf8);
 
92
        qq_send_cmd_group_auth(g->gc, group, QQ_ROOM_AUTH_REQUEST_REJECT, g->member, msg_utf8);
92
93
        g_free(g);
93
94
}
94
95
 
111
112
        g_return_if_fail(g != NULL && g->gc != NULL && g->member > 0);
112
113
 
113
114
        msg1 = g_strdup_printf(_("You rejected %d's request"), g->member);
114
 
        msg2 = g_strdup(_("Enter your reason:"));
 
115
        msg2 = g_strdup(_("Message:"));
115
116
 
116
117
        nombre = uid_to_purple_name(g->member);
117
118
        purple_request_input(g->gc, /* title */ NULL, msg1, msg2,
118
 
                           _("Sorry, you are not my type..."), /* multiline */ TRUE, /* masked */ FALSE,
 
119
                           _("Sorry, you are not my style..."), /* multiline */ TRUE, /* masked */ FALSE,
119
120
                           /* hint */ NULL,
120
121
                           _("Send"), G_CALLBACK(_qq_group_reject_application_real),
121
122
                           _("Cancel"), G_CALLBACK(_qq_group_do_nothing_with_struct),
133
134
        g_return_if_fail(g != NULL && g->gc != NULL && g->id > 0 && g->member > 0);
134
135
        group = qq_room_search_id(g->gc, g->id);
135
136
        g_return_if_fail(group != NULL);
136
 
        qq_send_cmd_group_auth(g->gc, group, QQ_GROUP_AUTH_REQUEST_APPROVE, g->member, "");
 
137
        qq_send_cmd_group_auth(g->gc, group, QQ_ROOM_AUTH_REQUEST_APPROVE, g->member, "");
137
138
        qq_group_find_or_add_member(g->gc, group, g->member);
138
139
        g_free(g);
139
140
}
189
190
                qq_group_find_or_add_member(gc, group, add_members[i]);
190
191
 
191
192
        if (del > 0)
192
 
                _qq_group_member_opt(gc, group, QQ_GROUP_MEMBER_DEL, del_members);
 
193
                _qq_group_member_opt(gc, group, QQ_ROOM_MEMBER_DEL, del_members);
193
194
        if (add > 0)
194
 
                _qq_group_member_opt(gc, group, QQ_GROUP_MEMBER_ADD, add_members);
 
195
                _qq_group_member_opt(gc, group, QQ_ROOM_MEMBER_ADD, add_members);
195
196
}
196
197
 
197
198
void qq_group_process_modify_members_reply(guint8 *data, gint len, PurpleConnection *gc)
209
210
        group = qq_room_search_id(gc, id);
210
211
        g_return_if_fail(group != NULL);
211
212
 
212
 
        purple_debug(PURPLE_DEBUG_INFO, "QQ", "Succeed in modify members for Qun %d\n", group->ext_id);
 
213
        purple_debug_info("QQ", "Succeed in modify members for room %d\n", group->ext_id);
213
214
 
214
 
        purple_notify_info(gc, _("QQ Qun Operation"), _("You have successfully modified Qun member"), NULL);
 
215
        purple_notify_info(gc, _("QQ Qun Operation"), _("Successed:"), _("Change Qun member"));
215
216
}
216
217
 
217
218
void qq_room_change_info(PurpleConnection *gc, qq_group *group)
223
224
 
224
225
        g_return_if_fail(group != NULL);
225
226
 
226
 
        group_name = group->group_name_utf8 == NULL ? "" : utf8_to_qq(group->group_name_utf8, QQ_CHARSET_DEFAULT);
227
 
        group_desc = group->group_desc_utf8 == NULL ? "" : utf8_to_qq(group->group_desc_utf8, QQ_CHARSET_DEFAULT);
 
227
        group_name = group->title_utf8 == NULL ? "" : utf8_to_qq(group->title_utf8, QQ_CHARSET_DEFAULT);
 
228
        group_desc = group->desc_utf8 == NULL ? "" : utf8_to_qq(group->desc_utf8, QQ_CHARSET_DEFAULT);
228
229
        notice = group->notice_utf8 == NULL ? "" : utf8_to_qq(group->notice_utf8, QQ_CHARSET_DEFAULT);
229
230
 
230
231
        data_len = 64 + strlen(group_name) + strlen(group_desc) + strlen(notice);
237
238
        /* 007-008 */
238
239
        bytes += qq_put16(data + bytes, 0x0000);
239
240
        /* 009-010 */
240
 
        bytes += qq_put16(data + bytes, group->group_category);
 
241
        bytes += qq_put16(data + bytes, group->category);
241
242
 
242
243
        bytes += qq_put8(data + bytes, strlen(group_name));
243
244
        bytes += qq_putdata(data + bytes, (guint8 *) group_name, strlen(group_name));
251
252
        bytes += qq_putdata(data + bytes, (guint8 *) group_desc, strlen(group_desc));
252
253
 
253
254
        if (bytes > data_len) {
254
 
                purple_debug(PURPLE_DEBUG_ERROR, "QQ",
 
255
                purple_debug_error("QQ",
255
256
                           "Overflow in qq_room_change_info, max %d bytes, now %d bytes\n",
256
257
                           data_len, bytes);
257
258
                return;
274
275
        group = qq_room_search_id(gc, id);
275
276
        g_return_if_fail(group != NULL);
276
277
 
277
 
        purple_debug(PURPLE_DEBUG_INFO, "QQ", "Succeed in modify info for Qun %d\n", group->ext_id);
 
278
        purple_debug_info("QQ", "Succeed in modify info for Qun %d\n", group->ext_id);
278
279
        qq_group_refresh(gc, group);
279
280
 
280
 
        purple_notify_info(gc, _("QQ Qun Operation"), _("You have successfully modified Qun information"), NULL);
 
281
        purple_notify_info(gc, _("QQ Qun Operation"), _("Successed:"), _("Change Qun information"));
281
282
}
282
283
 
283
284
/* we create a very simple group first, and then let the user to modify */
297
298
        bytes = 0;
298
299
        /* we create the simpleset group, only group name is given */
299
300
        /* 001 */
300
 
        bytes += qq_put8(data + bytes, QQ_GROUP_TYPE_PERMANENT);
 
301
        bytes += qq_put8(data + bytes, QQ_ROOM_TYPE_PERMANENT);
301
302
        /* 002 */
302
 
        bytes += qq_put8(data + bytes, QQ_GROUP_AUTH_TYPE_NEED_AUTH);
 
303
        bytes += qq_put8(data + bytes, QQ_ROOM_AUTH_TYPE_NEED_AUTH);
303
304
        /* 003-004 */
304
305
        bytes += qq_put16(data + bytes, 0x0000);
305
306
        /* 005-006 */
313
314
        bytes += qq_put32(data + bytes, qd->uid);       /* I am member of coz */
314
315
 
315
316
        if (bytes > data_len) {
316
 
                purple_debug(PURPLE_DEBUG_ERROR, "QQ",
 
317
                purple_debug_error("QQ",
317
318
                           "Overflow in qq_room_create, max %d bytes, now %d bytes\n",
318
319
                           data_len, bytes);
319
320
                return;
352
353
        g_return_if_fail(id > 0 && ext_id);
353
354
 
354
355
        group = qq_group_create_internal_record(gc, id, ext_id, NULL);
355
 
        group->my_status = QQ_GROUP_MEMBER_STATUS_IS_ADMIN;
 
356
        group->my_role = QQ_ROOM_ROLE_ADMIN;
356
357
        group->creator_uid = qd->uid;
357
358
        qq_group_refresh(gc, group);
358
359
 
359
360
        qq_send_room_cmd_only(gc, QQ_ROOM_CMD_ACTIVATE, id);
360
 
        qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_INFO, id);
 
361
        qq_update_room(gc, 0, group->id);
361
362
 
362
 
        purple_debug(PURPLE_DEBUG_INFO, "QQ", "Succeed in create Qun, external ID %d\n", group->ext_id);
 
363
        purple_debug_info("QQ", "Succeed in create Qun, external ID %d\n", group->ext_id);
363
364
 
364
365
        g = g_new0(gc_and_uid, 1);
365
366
        g->gc = gc;
368
369
        purple_request_action(gc, _("QQ Qun Operation"),
369
370
                            _("You have successfully created a Qun"),
370
371
                            _
371
 
                            ("Would you like to set up the Qun details now?"),
 
372
                            ("Would you like to set up the detail information now?"),
372
373
                            1,
373
374
                                purple_connection_get_account(gc), NULL, NULL,
374
375
                                g, 2,
391
392
        group = qq_room_search_id(gc, id);
392
393
        g_return_if_fail(group != NULL);
393
394
 
394
 
        purple_debug(PURPLE_DEBUG_INFO, "QQ", "Succeed in activate Qun %d\n", group->ext_id);
 
395
        purple_debug_info("QQ", "Succeed in activate Qun %d\n", group->ext_id);
395
396
}
396
397
 
397
398
void qq_group_manage_group(PurpleConnection *gc, GHashTable *data)
402
403
 
403
404
        g_return_if_fail(data != NULL);
404
405
 
405
 
        id_ptr = g_hash_table_lookup(data, QQ_GROUP_KEY_INTERNAL_ID);
 
406
        id_ptr = g_hash_table_lookup(data, QQ_ROOM_KEY_INTERNAL_ID);
406
407
        id = strtol(id_ptr, NULL, 10);
407
408
        g_return_if_fail(id > 0);
408
409