~ubuntu-branches/ubuntu/quantal/pidgin/quantal

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ari Pollak
  • Date: 2011-06-13 21:17:20 UTC
  • mfrom: (1.3.19 upstream)
  • mto: This revision was merged to the branch mainline in revision 73.
  • Revision ID: james.westby@ubuntu.com-20110613211720-ke87vzmdcuaxams7
Tags: 2.8.0-1
* Imported Upstream version 2.8.0 (Closes: #630124)
* Remove SILC support since the library will be orphaned (Closes: #629222)
* Fix typo in libpurple-bin description (Closes: #625462)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * @file group.c
3
 
 *
4
 
 * purple
5
 
 *
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
8
 
 * source distribution.
9
 
 *
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
12
 
 * the Free Software Foundation; either version 2 of the License, or
13
 
 * (at your option) any later version.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this program; if not, write to the Free Software
22
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
23
 
 */
24
 
 
25
 
#include "internal.h"
26
 
 
27
 
#include "debug.h"
28
 
#include "prpl.h"
29
 
#include "request.h"
30
 
 
31
 
#include "group_internal.h"
32
 
#include "group_info.h"
33
 
#include "group_join.h"
34
 
#include "utils.h"
35
 
#include "qq_network.h"
36
 
#include "qq_define.h"
37
 
 
38
 
static void _qq_group_search_callback(PurpleConnection *gc, const gchar *input)
39
 
{
40
 
        guint32 ext_id;
41
 
 
42
 
        g_return_if_fail(input != NULL);
43
 
        ext_id = strtoul(input, NULL, 10);
44
 
        /* 0x00000000 means search for demo group */
45
 
        qq_request_room_search(gc, ext_id, QQ_ROOM_SEARCH_ONLY);
46
 
}
47
 
 
48
 
static void _qq_group_search_cancel_callback(PurpleConnection *gc, const gchar *input)
49
 
{
50
 
        qq_data *qd;
51
 
 
52
 
        qd = (qq_data *) gc->proto_data;
53
 
        purple_roomlist_set_in_progress(qd->roomlist, FALSE);
54
 
}
55
 
 
56
 
/* This is needed for PurpleChat node to be valid */
57
 
GList *qq_chat_info(PurpleConnection *gc)
58
 
{
59
 
        GList *m;
60
 
        struct proto_chat_entry *pce;
61
 
 
62
 
        m = NULL;
63
 
 
64
 
        pce = g_new0(struct proto_chat_entry, 1);
65
 
        pce->label = _("ID: ");
66
 
        pce->identifier = QQ_ROOM_KEY_EXTERNAL_ID;
67
 
        m = g_list_append(m, pce);
68
 
 
69
 
        return m;
70
 
}
71
 
 
72
 
GHashTable *qq_chat_info_defaults(PurpleConnection *gc, const gchar *chat_name)
73
 
{
74
 
        GHashTable *defaults;
75
 
 
76
 
        defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
77
 
 
78
 
        if (chat_name != NULL)
79
 
                g_hash_table_insert(defaults, QQ_ROOM_KEY_EXTERNAL_ID, g_strdup(chat_name));
80
 
 
81
 
        return defaults;
82
 
}
83
 
 
84
 
/*  get a list of qq groups */
85
 
PurpleRoomlist *qq_roomlist_get_list(PurpleConnection *gc)
86
 
{
87
 
        GList *fields;
88
 
        qq_data *qd;
89
 
        PurpleRoomlist *rl;
90
 
        PurpleRoomlistField *f;
91
 
 
92
 
        qd = (qq_data *) gc->proto_data;
93
 
 
94
 
        fields = NULL;
95
 
        rl = purple_roomlist_new(purple_connection_get_account(gc));
96
 
        qd->roomlist = rl;
97
 
 
98
 
        f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Group ID"), QQ_ROOM_KEY_EXTERNAL_ID, FALSE);
99
 
        fields = g_list_append(fields, f);
100
 
        f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", QQ_ROOM_KEY_INTERNAL_ID, TRUE);
101
 
        fields = g_list_append(fields, f);
102
 
 
103
 
        fields = g_list_append(fields, f);
104
 
        purple_roomlist_set_fields(rl, fields);
105
 
        purple_roomlist_set_in_progress(qd->roomlist, TRUE);
106
 
 
107
 
        purple_request_input(gc, _("QQ Qun"),
108
 
                           _("Please enter Qun number"),
109
 
                           _("You can only search for permanent Qun\n"),
110
 
                           NULL, FALSE, FALSE, NULL,
111
 
                           _("Search"), G_CALLBACK(_qq_group_search_callback),
112
 
                           _("Cancel"), G_CALLBACK(_qq_group_search_cancel_callback),
113
 
                           purple_connection_get_account(gc), NULL, NULL,
114
 
                           gc);
115
 
 
116
 
        return qd->roomlist;
117
 
}
118
 
 
119
 
/* free roomlist space, I have no idea when this one is called... */
120
 
void qq_roomlist_cancel(PurpleRoomlist *list)
121
 
{
122
 
        PurpleConnection *gc;
123
 
 
124
 
        g_return_if_fail(list != NULL);
125
 
        gc = purple_account_get_connection(list->account);
126
 
 
127
 
        purple_roomlist_set_in_progress(list, FALSE);
128
 
        purple_roomlist_unref(list);
129
 
}