libpurple/protocols/gg/purplew.c

Wed, 03 Jul 2013 21:49:28 +0530

author
Ankit Vani <a@nevitus.org>
date
Wed, 03 Jul 2013 21:49:28 +0530
branch
soc.2013.gobjectification
changeset 34696
6e0d13978666
parent 33348
2394cd23ce8f
child 34697
fde4eb63fab0
permissions
-rw-r--r--

Global replace to use GObject-style macros. See details.
* Changed 'PURPLE_BLIST_NODE_IS_' to 'PURPLE_IS_'
* Changed 'PURPLE_BUDDY_IS_ONLINE' to 'PURPLE_IS_BUDDY_ONLINE'

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
5 * source distribution.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
6 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
7 * Rewritten from scratch during Google Summer of Code 2012
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
9 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
11 * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001);
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
12 * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005;
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
13 * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
14 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
15 * This program is free software; you can redistribute it and/or modify
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
16 * it under the terms of the GNU General Public License as published by
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
17 * the Free Software Foundation; either version 2 of the License, or
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
18 * (at your option) any later version.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
19 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
20 * This program is distributed in the hope that it will be useful,
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
23 * GNU General Public License for more details.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
24 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
25 * You should have received a copy of the GNU General Public License
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
26 * along with this program; if not, write to the Free Software
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
28 */
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
29
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
30 #include "purplew.h"
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
31
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
32 #include <request.h>
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
33 #include <debug.h>
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
34
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
35 guint ggp_purplew_http_input_add(struct gg_http *http_req,
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
36 PurpleInputFunction func, gpointer user_data)
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
37 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
38 PurpleInputCondition cond = 0;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
39 int check = http_req->check;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
40
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
41 if (check & GG_CHECK_READ)
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
42 cond |= PURPLE_INPUT_READ;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
43 if (check & GG_CHECK_WRITE)
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
44 cond |= PURPLE_INPUT_WRITE;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
45
33309
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
46 //TODO: verbose mode
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
47 //purple_debug_misc("gg", "ggp_purplew_http_input_add: "
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
48 // "[req=%x, fd=%d, cond=%d]\n",
bc2f2ea7b5ab Gadu-Gadu: refactoring of account registration done
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33306
diff changeset
49 // (unsigned int)http_req, http_req->fd, cond);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
50 return purple_input_add(http_req->fd, cond, func, user_data);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
51 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
52
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
53 static void ggp_purplew_request_processing_cancel(
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
54 ggp_purplew_request_processing_handle *handle, gint id)
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
55 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
56 handle->cancel_cb(handle->gc, handle->user_data);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
57 g_free(handle);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
58 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
59
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
60 ggp_purplew_request_processing_handle * ggp_purplew_request_processing(
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
61 PurpleConnection *gc, const gchar *msg, void *user_data,
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
62 ggp_purplew_request_processing_cancel_cb cancel_cb)
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
63 {
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
64 ggp_purplew_request_processing_handle *handle =
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
65 g_new(ggp_purplew_request_processing_handle, 1);
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
66
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
67 handle->gc = gc;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
68 handle->cancel_cb = cancel_cb;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
69 handle->user_data = user_data;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
70 handle->request_handle = purple_request_action(gc, _("Please wait..."),
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
71 (msg ? msg : _("Please wait...")), NULL,
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
72 PURPLE_DEFAULT_ACTION_NONE, purple_connection_get_account(gc),
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
73 NULL, NULL, handle, 1,
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
74 _("Cancel"), G_CALLBACK(ggp_purplew_request_processing_cancel));
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
75
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
76 return handle;
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
77 }
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
78
33306
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
79 void ggp_purplew_request_processing_done(
b1bef9a92b4c Gadu-Gadu: rename purple.(c|h) to purplew.(c|h) - purple wrappers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33305
diff changeset
80 ggp_purplew_request_processing_handle *handle)
33305
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
81 {
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
82 purple_request_close(PURPLE_REQUEST_ACTION, handle->request_handle);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
83 g_free(handle);
41e5ff454167 Gadu-Gadu: ggp_purple_request_processing implementation; refactoring of account registration (first stage); cancellable token request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
84 }
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
85
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
86 PurpleGroup * ggp_purplew_buddy_get_group_only(PurpleBuddy *buddy)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
87 {
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
88 PurpleGroup *group = purple_buddy_get_group(buddy);
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
89 if (!group)
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
90 return NULL;
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
91 if (0 == strcmp(GGP_PURPLEW_GROUP_DEFAULT, purple_group_get_name(group)))
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
92 return NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
93 return group;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33309
diff changeset
94 }
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
95
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
96 GList * ggp_purplew_group_get_buddies(PurpleGroup *group, PurpleAccount *account)
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
97 {
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
98 GList *buddies = NULL;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
99 PurpleBlistNode *gnode, *cnode, *bnode;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
100
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
101 g_return_val_if_fail(group != NULL, NULL);
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
102
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
103 gnode = PURPLE_BLIST_NODE(group);
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
104 for (cnode = gnode->child; cnode; cnode = cnode->next)
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
105 {
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
106 if (!PURPLE_IS_CONTACT(cnode))
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
107 continue;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
108 for (bnode = cnode->child; bnode; bnode = bnode->next)
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
109 {
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
110 PurpleBuddy *buddy;
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
111 if (!PURPLE_IS_BUDDY(bnode))
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
112 continue;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
113
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
114 buddy = PURPLE_BUDDY(bnode);
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
115 if (account == NULL || buddy->account == account)
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
116 buddies = g_list_append(buddies, buddy);
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
117 }
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
118 }
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
119
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
120 return buddies;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
121 }
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
122
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
123 GList * ggp_purplew_account_get_groups(PurpleAccount *account, gboolean exclusive)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
124 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
125 PurpleBlistNode *bnode;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
126 GList *groups = NULL;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
127 for (bnode = purple_blist_get_root(); bnode; bnode = bnode->next)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
128 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
129 PurpleGroup *group;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
130 GSList *accounts;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
131 gboolean have_specified = FALSE, have_others = FALSE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
132
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
133 if (!PURPLE_IS_GROUP(bnode))
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
134 continue;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
135
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
136 group = PURPLE_GROUP(bnode);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
137 for (accounts = purple_group_get_accounts(group); accounts; accounts = g_slist_delete_link(accounts, accounts))
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
138 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
139 if (accounts->data == account)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
140 have_specified = TRUE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
141 else
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
142 have_others = TRUE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
143 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
144
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
145 if (have_specified && (!exclusive || !have_others))
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
146 groups = g_list_append(groups, group);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
147 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
148 return groups;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
149 }

mercurial