3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * Rewritten from scratch during Google Summer of Code 2012
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
10 * Previously implemented by:
11 * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001);
12 * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005;
13 * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011).
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
35 #include "tcpsocket.h"
37 guint
ggp_purplew_http_input_add(struct gg_http
*http_req
,
38 PurpleInputFunction func
, gpointer user_data
)
40 if (purple_debug_is_verbose()) {
41 purple_debug_misc("gg", "ggp_purplew_http_input_add: "
42 "[req=%p, fd=%d, cond=%d]\n",
43 http_req
, http_req
->fd
, http_req
->check
);
45 return purple_input_add(http_req
->fd
,
46 ggp_tcpsocket_inputcond_gg_to_purple(http_req
->check
),
50 static void ggp_purplew_request_processing_cancel(
51 ggp_purplew_request_processing_handle
*handle
, gint id
)
53 handle
->cancel_cb(handle
->gc
, handle
->user_data
);
57 ggp_purplew_request_processing_handle
* ggp_purplew_request_processing(
58 PurpleConnection
*gc
, const gchar
*msg
, void *user_data
,
59 ggp_purplew_request_processing_cancel_cb cancel_cb
)
61 ggp_purplew_request_processing_handle
*handle
=
62 g_new(ggp_purplew_request_processing_handle
, 1);
65 handle
->cancel_cb
= cancel_cb
;
66 handle
->user_data
= user_data
;
67 handle
->request_handle
= purple_request_action(gc
, _("Please wait..."),
68 (msg
? msg
: _("Please wait...")), NULL
,
69 PURPLE_DEFAULT_ACTION_NONE
,
70 purple_request_cpar_from_connection(gc
), handle
, 1,
71 _("Cancel"), G_CALLBACK(ggp_purplew_request_processing_cancel
));
76 void ggp_purplew_request_processing_done(
77 ggp_purplew_request_processing_handle
*handle
)
79 purple_request_close(PURPLE_REQUEST_ACTION
, handle
->request_handle
);
83 PurpleGroup
* ggp_purplew_buddy_get_group_only(PurpleBuddy
*buddy
)
85 PurpleGroup
*group
= purple_buddy_get_group(buddy
);
88 if (0 == g_strcmp0(PURPLE_BLIST_DEFAULT_GROUP_NAME
,
89 purple_group_get_name(group
)))
93 if (0 == g_strcmp0("Buddies", purple_group_get_name(group
)))
98 GList
* ggp_purplew_group_get_buddies(PurpleGroup
*group
, PurpleAccount
*account
)
100 GList
*buddies
= NULL
;
101 PurpleBlistNode
*gnode
, *cnode
, *bnode
;
103 g_return_val_if_fail(group
!= NULL
, NULL
);
105 gnode
= PURPLE_BLIST_NODE(group
);
106 for (cnode
= gnode
->child
; cnode
; cnode
= cnode
->next
) {
107 if (!PURPLE_IS_CONTACT(cnode
))
109 for (bnode
= cnode
->child
; bnode
; bnode
= bnode
->next
) {
111 if (!PURPLE_IS_BUDDY(bnode
))
114 buddy
= PURPLE_BUDDY(bnode
);
115 if (account
== NULL
||
116 purple_buddy_get_account(buddy
) == account
)
118 buddies
= g_list_append(buddies
, buddy
);
126 GList
* ggp_purplew_account_get_groups(PurpleAccount
*account
, gboolean exclusive
)
128 PurpleBlistNode
*bnode
;
129 GList
*groups
= NULL
;
130 for (bnode
= purple_blist_get_default_root(); bnode
;
131 bnode
= bnode
->next
) {
134 gboolean have_specified
= FALSE
, have_others
= FALSE
;
136 if (!PURPLE_IS_GROUP(bnode
))
139 group
= PURPLE_GROUP(bnode
);
140 for (accounts
= purple_group_get_accounts(group
); accounts
;
141 accounts
= g_slist_delete_link(accounts
, accounts
))
143 if (accounts
->data
== account
)
144 have_specified
= TRUE
;
149 if (have_specified
&& (!exclusive
|| !have_others
))
150 groups
= g_list_append(groups
, group
);