libpurple/protocols/gg/pubdir-prpl.c

Wed, 25 May 2022 23:52:45 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 25 May 2022 23:52:45 -0500
changeset 41408
5323c0b51ddc
parent 41214
b0b7d118475f
child 41700
9f6a2c90800e
permissions
-rw-r--r--

Remove prpl-gtalk from XMPP console

It no longer exists, and complicates the code a bit.

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
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: 33347
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: 33347
diff changeset
5 * source distribution.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
6 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
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: 33347
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
9 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
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: 33347
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: 33347
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: 33347
diff changeset
14 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
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: 33347
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: 33347
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: 33347
diff changeset
18 * (at your option) any later version.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
19 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
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: 33347
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: 33347
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: 33347
diff changeset
23 * GNU General Public License for more details.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
24 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
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: 33347
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: 33347
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: 33347
diff changeset
28 */
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33347
diff changeset
29
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
30 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
31
40474
1341be8e3402 Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
32 #include <purple.h>
41212
9f0f4c23132e Use accessor for SoupMessage->status_code
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40708
diff changeset
33 #include "libpurple/soupcompat.h"
40474
1341be8e3402 Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
34
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
35 #include "pubdir-prpl.h"
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
36 #include "gg.h"
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
37
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
38 #include "oauth/oauth-purple.h"
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
39 #include "xml.h"
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
40 #include "utils.h"
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
41 #include "status.h"
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
42
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
43 typedef struct
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
44 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
45 PurpleConnection *gc;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
46 ggp_pubdir_request_cb cb;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
47 void *user_data;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
48 enum
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
49 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
50 GGP_PUBDIR_REQUEST_TYPE_INFO,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
51 GGP_PUBDIR_REQUEST_TYPE_SEARCH,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
52 } type;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
53 union
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
54 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
55 struct
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
56 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
57 uin_t uin;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
58 } user_info;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
59 ggp_pubdir_search_form *search_form;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
60 } params;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
61 } ggp_pubdir_request;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
62
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
63 /* Searching for buddies. */
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
64
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
65 #define GGP_PUBDIR_SEARCH_TITLE _("Gadu-Gadu Public Directory")
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
66 #define GGP_PUBDIR_SEARCH_PER_PAGE 20
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
67
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
68 struct _ggp_pubdir_search_form
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
69 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
70 gchar *nick, *city;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
71 ggp_pubdir_gender gender;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
72 int offset;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
73 int limit;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
74
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
75 void *display_handle;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
76 };
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
77
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
78 /* For ggp_pubdir_search_results_next, which is called by this. */
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
79 static void ggp_pubdir_search_results_display(PurpleConnection *gc,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
80 int records_count, const ggp_pubdir_record *records, int next_offset,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
81 void *user_data);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
82
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
83 /******************************************************************************/
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
84
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
85 static const gchar *ggp_pubdir_provinces[] =
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
86 {
34338
c652670afac5 Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
87 N_("Not specified"),
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
88 "dolnośląskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
89 "kujawsko-pomorskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
90 "lubelskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
91 "lubuskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
92 "łódzkie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
93 "małopolskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
94 "mazowieckie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
95 "opolskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
96 "podkarpackie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
97 "podlaskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
98 "pomorskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
99 "śląskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
100 "świętokrzyskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
101 "warmińsko-mazurskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
102 "wielkopolskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
103 "zachodniopomorskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
104 };
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
105
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34287
diff changeset
106 static gsize ggp_pubdir_provinces_count = sizeof(ggp_pubdir_provinces)/sizeof(gchar*);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
107
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
108 /******************************************************************************/
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
109
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
110 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
111 ggp_pubdir_record_free(ggp_pubdir_record *records, int count)
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
112 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
113 int i;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
114 for (i = 0; i < count; i++) {
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
115 g_free(records[i].label);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
116 g_free(records[i].nickname);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
117 g_free(records[i].first_name);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
118 g_free(records[i].last_name);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
119 g_free(records[i].city);
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
120 g_date_time_unref(records[i].birth);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
121 }
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
122 g_free(records);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
123 }
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
124
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
125 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
126 ggp_pubdir_search_form_free(ggp_pubdir_search_form *form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
127 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
128 g_free(form->nick);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
129 g_free(form->city);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
130 g_free(form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
131 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
132
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
133 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
134 ggp_pubdir_request_free(ggp_pubdir_request *request)
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
135 {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
136 if (request->type == GGP_PUBDIR_REQUEST_TYPE_SEARCH)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
137 ggp_pubdir_search_form_free(request->params.search_form);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
138 g_free(request);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
139 }
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
140
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
141 static void
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
142 ggp_pubdir_got_data(G_GNUC_UNUSED SoupSession *session, SoupMessage *msg,
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
143 gpointer _request)
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
144 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
145 ggp_pubdir_request *request = _request;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
146 PurpleConnection *gc = request->gc;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
147 gboolean succ = TRUE;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
148 PurpleXmlNode *xml;
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
149 const gchar *xml_raw;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
150 unsigned int status, next_offset;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
151 int record_count, i;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
152 ggp_pubdir_record *records;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
153
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
154 xml_raw = msg->response_body->data;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
155
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
156 if (purple_debug_is_verbose() && purple_debug_is_unsafe()) {
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
157 purple_debug_misc("gg", "ggp_pubdir_got_data: xml=[%s]\n",
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
158 xml_raw);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
159 }
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
160
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
161 xml = purple_xmlnode_from_str(xml_raw, -1);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
162 if (xml == NULL) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
163 purple_debug_error("gg", "ggp_pubdir_got_data: "
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
164 "invalid xml\n");
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
165 request->cb(gc, -1, NULL, 0, request->user_data);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
166 ggp_pubdir_request_free(request);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
167 return;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
168 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
169
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
170 succ &= ggp_xml_get_uint(xml, "status", &status);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
171 if (!ggp_xml_get_uint(xml, "nextOffset", &next_offset))
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
172 next_offset = 0;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
173 xml = purple_xmlnode_get_child(xml, "users");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
174 if (!succ || status != 0 || !xml) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
175 purple_debug_error("gg", "ggp_pubdir_got_data: "
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
176 "invalid reply\n");
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
177 request->cb(gc, -1, NULL, 0, request->user_data);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
178 ggp_pubdir_request_free(request);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
179 return;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
180 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
181
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
182 record_count = ggp_xml_child_count(xml, "user");
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
183 records = g_new0(ggp_pubdir_record, record_count);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
184
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
185 xml = purple_xmlnode_get_child(xml, "user");
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
186 i = 0;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
187 while (xml) {
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
188 ggp_pubdir_record *record = &records[i++];
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
189 gchar *city = NULL, *birth_s = NULL;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
190 unsigned int gender = 0;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
191 const gchar *uin_s;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
192
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
193 g_assert(i <= record_count);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
194
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
195 record->uin = ggp_str_to_uin(purple_xmlnode_get_attrib(xml, "uin"));
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
196 if (record->uin == 0)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
197 ggp_xml_get_uint(xml, "uin", &record->uin);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
198 if (record->uin == 0)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
199 purple_debug_error("gg", "ggp_pubdir_got_data:"
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
200 " invalid uin\n");
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
201 uin_s = ggp_uin_to_str(record->uin);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
202
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
203 ggp_xml_get_string(xml, "label", &record->label);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
204 ggp_xml_get_string(xml, "nick", &record->nickname);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
205 ggp_xml_get_string(xml, "name", &record->first_name);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
206 ggp_xml_get_string(xml, "surname", &record->last_name);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
207 ggp_xml_get_string(xml, "city", &city);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
208 ggp_xml_get_string(xml, "birth", &birth_s);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
209 ggp_xml_get_uint(xml, "gender", &gender);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
210 ggp_xml_get_uint(xml, "age", &record->age);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
211 ggp_xml_get_uint(xml, "province", &record->province);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
212
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
213 record->label = ggp_free_if_equal(record->label, uin_s);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
214 record->label = ggp_free_if_equal(record->label, "");
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
215 record->nickname = ggp_free_if_equal(record->nickname, uin_s);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
216 record->nickname = ggp_free_if_equal(record->nickname, "");
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
217 record->first_name = ggp_free_if_equal(record->first_name, "");
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
218 record->last_name = ggp_free_if_equal(record->last_name, "");
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
219 g_clear_pointer(&record->birth, g_date_time_unref);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
220
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
221 if (record->label) {}
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
222 else if (record->nickname)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
223 record->label = g_strdup(record->nickname);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
224 else if (record->first_name && record->last_name)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
225 record->label = g_strdup_printf("%s %s",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
226 record->first_name, record->last_name);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
227 else if (record->first_name)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
228 record->label = g_strdup(record->first_name);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
229 else if (record->last_name)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
230 record->label = g_strdup(record->last_name);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
231 if (record->label)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
232 g_strstrip(record->label);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
233 if (record->nickname)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
234 g_strstrip(record->nickname);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
235
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
236 if (gender == 1)
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
237 record->gender = GGP_PUBDIR_GENDER_FEMALE;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
238 else if (gender == 2)
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
239 record->gender = GGP_PUBDIR_GENDER_MALE;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
240 else
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
241 record->gender = GGP_PUBDIR_GENDER_UNSPECIFIED;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
242
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
243 if (city && city[0] != '\0')
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
244 record->city = g_strdup(city);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
245 if (record->city)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
246 g_strstrip(record->city);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
247 if (!record->city) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
248 g_free(record->city);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
249 record->city = NULL;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
250 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
251
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
252 record->birth = g_date_time_new_from_iso8601(birth_s, NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
253 /*TODO: calculate age from birth */
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
254
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
255 if (purple_debug_is_verbose()) {
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
256 purple_debug_misc("gg", "ggp_pubdir_got_data: [uin:%d] "
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
257 "[label:%s] [nick:%s] [first name:%s] "
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
258 "[last name:%s] [city:%s] [gender:%d] [age:%d] "
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
259 "[birth:%lu]\n", record->uin, record->label,
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
260 record->nickname, record->first_name,
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
261 record->last_name, record->city, record->gender,
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
262 record->age, g_date_time_to_unix(record->birth));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
263 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
264
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40514
diff changeset
265 g_clear_pointer(&city, g_free);
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40514
diff changeset
266 g_clear_pointer(&birth_s, g_free);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
267
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
268 xml = purple_xmlnode_get_next_twin(xml);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
269 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
270
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
271 request->cb(gc, record_count, records, next_offset, request->user_data);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
272
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
273 ggp_pubdir_request_free(request);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
274 ggp_pubdir_record_free(records, record_count);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
275 }
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
276
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
277 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
278 ggp_pubdir_get_info_got_token(PurpleConnection *gc, const gchar *token,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
279 gpointer _request)
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
280 {
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
281 GGPInfo *info = NULL;
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
282 gchar *url;
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
283 SoupMessage *msg;
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
284 ggp_pubdir_request *request = _request;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
285
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
286 PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
287
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
288 if (!token) {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
289 request->cb(gc, -1, NULL, 0, request->user_data);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
290 ggp_pubdir_request_free(request);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
291 return;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
292 }
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
293
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
294 info = purple_connection_get_protocol_data(gc);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
295
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
296 url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u",
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
297 request->params.user_info.uin);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
298 msg = soup_message_new("GET", url);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
299 g_free(url);
41214
b0b7d118475f Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41212
diff changeset
300 soup_message_headers_replace(soup_message_get_request_headers(msg),
b0b7d118475f Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41212
diff changeset
301 "Authorization", token);
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
302 soup_session_queue_message(info->http, msg, ggp_pubdir_got_data, request);
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
303 }
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
304
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
305 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
306 ggp_pubdir_get_info(PurpleConnection *gc, uin_t uin, ggp_pubdir_request_cb cb,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
307 void *user_data)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
308 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
309 ggp_pubdir_request *request = g_new0(ggp_pubdir_request, 1);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
310 gchar *url;
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
311
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
312 request->type = GGP_PUBDIR_REQUEST_TYPE_INFO;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
313 request->gc = gc;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
314 request->cb = cb;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
315 request->user_data = user_data;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
316 request->params.user_info.uin = uin;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
317
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
318 url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u", uin);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
319 ggp_oauth_request(gc, ggp_pubdir_get_info_got_token, request, "GET", url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
320 g_free(url);
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
321 }
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
322
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
323 static void ggp_pubdir_get_info_protocol_got(PurpleConnection *gc,
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
324 int records_count, const ggp_pubdir_record *records, int next_offset,
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
325 void *_uin_p)
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
326 {
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
327 uin_t uin = *((uin_t*)_uin_p);
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
328 PurpleNotifyUserInfo *info = purple_notify_user_info_new();
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
329 const ggp_pubdir_record *record = &records[0];
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
330 PurpleBuddy *buddy;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
331
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
332 g_free(_uin_p);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
333
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
334 if (records_count < 1) {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
335 purple_debug_error("gg", "ggp_pubdir_get_info_protocol_got: "
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
336 "couldn't get info for %u\n", uin);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
337 purple_notify_user_info_add_pair_plaintext(info, NULL,
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
338 _("Cannot get user information"));
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
339 purple_notify_userinfo(gc, ggp_uin_to_str(uin), info,
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
340 NULL, NULL);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
341 purple_notify_user_info_destroy(info);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
342 return;
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
343 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
344
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
345 purple_debug_info("gg", "ggp_pubdir_get_info_protocol_got: %u\n", uin);
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
346 g_assert(uin == record->uin);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
347 g_assert(records_count == 1);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
348
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34701
diff changeset
349 buddy = purple_blist_find_buddy(purple_connection_get_account(gc),
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
350 ggp_uin_to_str(uin));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
351 if (buddy) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
352 const char *alias;
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
353 PurpleStatus *status;
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
354 gchar *status_message;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
355
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
356 alias = purple_buddy_get_alias_only(buddy);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
357 if (alias)
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
358 purple_notify_user_info_add_pair_plaintext(info,
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
359 _("Alias"), alias);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
360
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
361 status = purple_presence_get_active_status(
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
362 purple_buddy_get_presence(buddy));
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
363 ggp_status_from_purplestatus(status, &status_message);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
364 purple_notify_user_info_add_pair_plaintext(info, _("Status"),
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
365 purple_status_get_name(status));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
366 if (status_message) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
367 purple_notify_user_info_add_pair_plaintext(info,
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
368 _("Message"), status_message);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
369 }
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
370 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
371
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
372 if (record->nickname) {
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
373 purple_notify_user_info_add_pair_plaintext(info,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
374 _("Nickname"), record->nickname);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
375 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
376 if (record->first_name) {
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
377 purple_notify_user_info_add_pair_plaintext(info,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
378 _("First name"), record->first_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
379 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
380 if (record->last_name) {
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
381 purple_notify_user_info_add_pair_plaintext(info,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
382 _("Last name"), record->last_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
383 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
384 if (record->gender != GGP_PUBDIR_GENDER_UNSPECIFIED) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
385 purple_notify_user_info_add_pair_plaintext(info, _("Gender"),
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
386 record->gender == GGP_PUBDIR_GENDER_FEMALE ?
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
387 _("Female") : _("Male"));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
388 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
389 if (record->city) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
390 purple_notify_user_info_add_pair_plaintext(info, _("City"),
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
391 record->city);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
392 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
393 if (record->birth) {
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
394 gchar *bday = g_date_time_format(record->birth, "%Y-%m-%d");
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
395
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
396 purple_notify_user_info_add_pair_plaintext(info, _("Birthday"), bday);
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
397
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
398 g_free(bday);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
399 } else if (record->age) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
400 gchar *age_s = g_strdup_printf("%d", record->age);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
401 purple_notify_user_info_add_pair_plaintext(info, _("Age"),
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
402 age_s);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
403 g_free(age_s);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
404 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
405
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
406 purple_notify_userinfo(gc, ggp_uin_to_str(uin), info, NULL, NULL);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
407 purple_notify_user_info_destroy(info);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
408 }
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
409
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
410 void
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
411 ggp_pubdir_get_info_protocol(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
412 PurpleConnection *gc, const gchar *name)
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
413 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
414 uin_t uin = ggp_str_to_uin(name);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
415 uin_t *uin_p = g_new0(uin_t, 1);
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
416
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
417 *uin_p = uin;
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
418
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
419 purple_debug_info("gg", "ggp_pubdir_get_info_protocol: %u", uin);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
420
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
421 ggp_pubdir_get_info(gc, uin, ggp_pubdir_get_info_protocol_got, uin_p);
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
422 }
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
423
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
424 static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
425 int records_count, const ggp_pubdir_record *records, int next_offset,
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
426 void *user_data)
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
427 {
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
428 uin_t uin;
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
429 const gchar *alias;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
430
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
431 if (records_count < 0) {
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
432 purple_debug_error("gg", "ggp_pubdir_request_buddy_alias_got: "
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
433 "couldn't get info for user\n");
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
434 return;
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
435 }
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
436 uin = records[0].uin;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
437
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
438 alias = records[0].label;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
439 if (!alias) {
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
440 purple_debug_info("gg", "ggp_pubdir_request_buddy_alias_got: "
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
441 "public alias for %u is not available\n", uin);
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
442 return;
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
443 }
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
444
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
445 purple_debug_info("gg", "ggp_pubdir_request_buddy_alias_got: "
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
446 "public alias for %u is \"%s\"\n", uin, alias);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
447
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35361
diff changeset
448 purple_serv_got_alias(gc, ggp_uin_to_str(uin), alias);
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
449 }
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
450
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
451 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
452 ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
453 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
454 uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
455
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
456 purple_debug_info("gg", "ggp_pubdir_request_buddy_alias: %u", uin);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
457
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
458 ggp_pubdir_get_info(gc, uin, ggp_pubdir_request_buddy_alias_got, NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
459 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
460
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
461 /*******************************************************************************
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
462 * Searching for buddies.
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
463 ******************************************************************************/
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
464
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
465 static ggp_pubdir_search_form *
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
466 ggp_pubdir_search_form_clone(const ggp_pubdir_search_form *form)
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
467 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
468 ggp_pubdir_search_form *dup = g_new(ggp_pubdir_search_form, 1);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
469
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
470 dup->nick = g_strdup(form->nick);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
471 dup->city = g_strdup(form->city);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
472 dup->gender = form->gender;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
473 dup->offset = form->offset;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
474 dup->limit = form->limit;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
475
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
476 dup->display_handle = form->display_handle;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
477
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
478 return dup;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
479 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
480
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
481 static gchar * ggp_pubdir_search_make_query(const ggp_pubdir_search_form *form)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
482 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
483 gchar *nick, *city, *gender;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
484 gchar *query;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
485
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
486 if (form->nick && form->nick[0] != '\0') {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
487 gchar *nick_e = g_uri_escape_string(form->nick, NULL, FALSE);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
488 nick = g_strdup_printf("&nick=%s", nick_e);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
489 g_free(nick_e);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
490 } else
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
491 nick = g_strdup("");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
492
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
493 if (form->city && form->city[0] != '\0') {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
494 gchar *city_e = g_uri_escape_string(form->city, NULL, FALSE);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
495 city = g_strdup_printf("&city=%s", city_e);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
496 g_free(city_e);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
497 } else
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
498 city = g_strdup("");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
499
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
500 if (form->gender != GGP_PUBDIR_GENDER_UNSPECIFIED) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
501 gender = g_strdup_printf("&gender=%d",
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
502 form->gender == GGP_PUBDIR_GENDER_MALE ? 2 : 1);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
503 } else
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
504 gender = g_strdup("");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
505
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
506 query = g_strdup_printf("/users.xml?offset=%d&limit=%d%s%s%s",
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
507 form->offset, form->limit, nick, city, gender);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
508
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
509 g_free(nick);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
510 g_free(city);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
511 g_free(gender);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
512
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
513 return query;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
514 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
515
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
516 static void ggp_pubdir_search_got_token(PurpleConnection *gc,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
517 const gchar *token, gpointer _request)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
518 {
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
519 GGPInfo *info = NULL;
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
520 gchar *url;
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
521 SoupMessage *msg;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
522 ggp_pubdir_request *request = _request;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
523 gchar *query;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
524
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
525 PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
526
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
527 if (!token) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
528 request->cb(gc, -1, NULL, 0, request->user_data);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
529 ggp_pubdir_request_free(request);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
530 return;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
531 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
532
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
533 purple_debug_misc("gg", "ggp_pubdir_search_got_token\n");
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
534
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
535 query = ggp_pubdir_search_make_query(request->params.search_form);
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
536
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
537 info = purple_connection_get_protocol_data(gc);
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
538
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
539 url = g_strdup_printf("http://api.gadu-gadu.pl%s", query);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
540 msg = soup_message_new("GET", url);
41214
b0b7d118475f Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41212
diff changeset
541 soup_message_headers_replace(soup_message_get_request_headers(msg),
b0b7d118475f Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41212
diff changeset
542 "Authorization", token);
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
543 soup_session_queue_message(info->http, msg, ggp_pubdir_got_data, request);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
544
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
545 g_free(url);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
546 g_free(query);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
547 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
548
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
549 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
550 ggp_pubdir_search_execute(PurpleConnection *gc,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
551 const ggp_pubdir_search_form *form,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
552 ggp_pubdir_request_cb cb, void *user_data)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
553 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
554 ggp_pubdir_request *request = g_new0(ggp_pubdir_request, 1);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
555 gchar *url;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
556 ggp_pubdir_search_form *local_form = ggp_pubdir_search_form_clone(form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
557 gchar *query;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
558
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
559 request->type = GGP_PUBDIR_REQUEST_TYPE_SEARCH;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
560 request->gc = gc;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
561 request->cb = cb;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
562 request->user_data = user_data;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
563 request->params.search_form = local_form;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
564
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
565 query = ggp_pubdir_search_make_query(form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
566 purple_debug_misc("gg", "ggp_pubdir_search_execute: %s", query);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
567 url = g_strdup_printf("http://api.gadu-gadu.pl%s", query);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
568 ggp_oauth_request(gc, ggp_pubdir_search_got_token, request, "GET", url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
569 g_free(query);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
570 g_free(url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
571 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
572
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
573 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
574 ggp_pubdir_search_results_new(PurpleConnection *gc, GList *row, gpointer _form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
575 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
576 ggp_pubdir_search_form *form = _form;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
577 ggp_pubdir_search(gc, form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
578 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
579
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
580 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
581 ggp_pubdir_search_results_close(gpointer _form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
582 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
583 ggp_pubdir_search_form *form = _form;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
584 ggp_pubdir_search_form_free(form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
585 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
586
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
587 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
588 ggp_pubdir_search_results_next(PurpleConnection *gc, GList *row, gpointer _form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
589 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
590 ggp_pubdir_search_form *form = _form;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
591 ggp_pubdir_search_execute(gc, form, ggp_pubdir_search_results_display,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
592 form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
593 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
594
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
595 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
596 ggp_pubdir_search_results_add(PurpleConnection *gc, GList *row, gpointer _form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
597 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
598 purple_blist_request_add_buddy(purple_connection_get_account(gc),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
599 g_list_nth_data(row, 0), NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
600 g_list_nth_data(row, 1));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
601 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
602
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
603 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
604 ggp_pubdir_search_results_im(PurpleConnection *gc, GList *row, gpointer _form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
605 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
606 purple_conversation_present(PURPLE_CONVERSATION(purple_im_conversation_new(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
607 purple_connection_get_account(gc), g_list_nth_data(row, 0))));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
608 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
609
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
610 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
611 ggp_pubdir_search_results_info(PurpleConnection *gc, GList *row, gpointer _form)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
612 {
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
613 ggp_pubdir_get_info_protocol(NULL, gc, g_list_nth_data(row, 0));
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
614 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
615
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
616 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
617 ggp_pubdir_search_results_display(PurpleConnection *gc, int records_count,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
618 const ggp_pubdir_record *records,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
619 int next_offset, void *_form)
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
620 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
621 ggp_pubdir_search_form *form = _form;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
622 PurpleNotifySearchResults *results;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
623 int i;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
624
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
625 purple_debug_info("gg", "ggp_pubdir_search_results_display: "
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
626 "got %d records (next offset: %d)\n",
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
627 records_count, next_offset);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
628
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
629 if (records_count < 0 ||
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
630 (records_count == 0 && form->offset != 0))
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
631 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
632 purple_notify_error(gc, GGP_PUBDIR_SEARCH_TITLE,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
633 _("Error while searching for buddies"), NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
634 purple_request_cpar_from_connection(gc));
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
635 ggp_pubdir_search_form_free(form);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
636 return;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
637 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
638
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
639 if (records_count == 0) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
640 purple_notify_info(gc, GGP_PUBDIR_SEARCH_TITLE,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
641 _("No matching users found"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
642 _("There are no users matching your search criteria."),
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
643 purple_request_cpar_from_connection(gc));
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
644 ggp_pubdir_search_form_free(form);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
645 return;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
646 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
647
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
648 form->offset = next_offset;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
649
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
650 results = purple_notify_searchresults_new();
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
651
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
652 purple_notify_searchresults_column_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
653 purple_notify_searchresults_column_new(_("GG Number")));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
654 purple_notify_searchresults_column_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
655 purple_notify_searchresults_column_new(_("Name")));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
656 purple_notify_searchresults_column_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
657 purple_notify_searchresults_column_new(_("City")));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
658 purple_notify_searchresults_column_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
659 purple_notify_searchresults_column_new(_("Gender")));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
660 purple_notify_searchresults_column_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
661 purple_notify_searchresults_column_new(_("Age")));
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
662
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
663 for (i = 0; i < records_count; i++) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
664 GList *row = NULL;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
665 const ggp_pubdir_record *record = &records[i];
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
666 gchar *gender = NULL, *age = NULL;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
667
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
668 if (record->gender == GGP_PUBDIR_GENDER_MALE)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
669 gender = g_strdup("male");
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
670 else if (record->gender == GGP_PUBDIR_GENDER_FEMALE)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
671 gender = g_strdup("female");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
672
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
673 if (record->age)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
674 age = g_strdup_printf("%d", record->age);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
675
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
676 row = g_list_append(row, g_strdup(ggp_uin_to_str(record->uin)));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
677 row = g_list_append(row, g_strdup(record->label));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
678 row = g_list_append(row, g_strdup(record->city));
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
679 row = g_list_append(row, gender);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
680 row = g_list_append(row, age);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
681 purple_notify_searchresults_row_add(results, row);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
682 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
683
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
684 purple_notify_searchresults_button_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
685 PURPLE_NOTIFY_BUTTON_ADD, ggp_pubdir_search_results_add);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
686 purple_notify_searchresults_button_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
687 PURPLE_NOTIFY_BUTTON_IM, ggp_pubdir_search_results_im);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
688 purple_notify_searchresults_button_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
689 PURPLE_NOTIFY_BUTTON_INFO, ggp_pubdir_search_results_info);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
690 purple_notify_searchresults_button_add_labeled(results, _("New search"),
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
691 ggp_pubdir_search_results_new);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
692 if (next_offset != 0)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
693 purple_notify_searchresults_button_add(results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
694 PURPLE_NOTIFY_BUTTON_CONTINUE,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
695 ggp_pubdir_search_results_next);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
696
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
697 if (!form->display_handle)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
698 form->display_handle = purple_notify_searchresults(gc,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
699 GGP_PUBDIR_SEARCH_TITLE, _("Search results"), NULL,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
700 results, ggp_pubdir_search_results_close, form);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
701 else
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
702 purple_notify_searchresults_new_rows(gc, results,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
703 form->display_handle);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
704 g_assert(form->display_handle);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
705 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
706
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
707 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
708 ggp_pubdir_search_request(PurpleConnection *gc, PurpleRequestFields *fields)
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
709 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
710 ggp_pubdir_search_form *form = g_new0(ggp_pubdir_search_form, 1);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
711
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
712 purple_debug_info("gg", "ggp_pubdir_search_request");
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
713
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
714 form->nick = g_strdup(purple_request_fields_get_string(fields, "name"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
715 form->city = g_strdup(purple_request_fields_get_string(fields, "city"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
716 form->gender =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
717 GPOINTER_TO_INT(purple_request_fields_get_choice(fields, "gender"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
718 form->offset = 0;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
719 form->limit = GGP_PUBDIR_SEARCH_PER_PAGE;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
720
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
721 ggp_pubdir_search_execute(gc, form, ggp_pubdir_search_results_display,
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
722 form);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
723 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
724
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
725 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
726 ggp_pubdir_search(PurpleConnection *gc, const ggp_pubdir_search_form *form)
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
727 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
728 PurpleRequestFields *fields;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
729 PurpleRequestFieldGroup *group;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
730 PurpleRequestField *field;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
731
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
732 purple_debug_info("gg", "ggp_pubdir_search");
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
733
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
734 fields = purple_request_fields_new();
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
735 group = purple_request_field_group_new(NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
736 purple_request_fields_add_group(fields, group);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
737
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
738 field = purple_request_field_string_new("name", _("Name"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
739 form ? form->nick : NULL, FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
740 purple_request_field_group_add_field(group, field);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
741
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
742 field = purple_request_field_string_new("city", _("City"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
743 form ? form->city : NULL, FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
744 purple_request_field_group_add_field(group, field);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
745
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
746 field = purple_request_field_choice_new(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
747 "gender", _("Gender"), form ? GINT_TO_POINTER(form->gender) : NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
748 purple_request_field_choice_add(field, _("Male or female"), NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
749 purple_request_field_choice_add(field, _("Male"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
750 GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
751 purple_request_field_choice_add(field, _("Female"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
752 GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
753 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
754
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
755 purple_request_fields(gc, _("Find buddies"), _("Find buddies"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
756 _("Please, enter your search criteria below"), fields,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
757 _("OK"), G_CALLBACK(ggp_pubdir_search_request),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
758 _("Cancel"), NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
759 purple_request_cpar_from_connection(gc), gc);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
760 }
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
761
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
762 /*******************************************************************************
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
763 * Own profile.
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
764 ******************************************************************************/
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
765
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
766 static void
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
767 ggp_pubdir_set_info_got_response(G_GNUC_UNUSED SoupSession *session,
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
768 SoupMessage *msg, gpointer user_data)
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
769 {
41212
9f0f4c23132e Use accessor for SoupMessage->status_code
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40708
diff changeset
770 if (!SOUP_STATUS_IS_SUCCESSFUL(soup_message_get_status(msg))) {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
771 purple_debug_error("gg", "ggp_pubdir_set_info_got_response: failed");
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
772 return;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
773 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
774
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
775 purple_debug_info("gg", "ggp_pubdir_set_info_got_response: [%s]",
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
776 msg->response_body->data);
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
777 /* <result><status>0</status></result> */
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
778
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
779 /* TODO: notify about failure */
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
780 }
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
781
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
782 static void ggp_pubdir_set_info_got_token(PurpleConnection *gc,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
783 const gchar *token, gpointer _record)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
784 {
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
785 ggp_pubdir_record *record = _record;
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
786 GGPInfo *info = NULL;
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
787 SoupMessage *msg;
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
788 gchar *url;
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
789 gchar *request_data;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
790 gchar *name, *surname, *city;
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
791 gchar *bday;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
792 uin_t uin = record->uin;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
793
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
794 PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
795
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
796 if (!token) {
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
797 /* TODO: notify about failure */
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
798 ggp_pubdir_record_free(record, 1);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
799 return;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
800 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
801
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
802 info = purple_connection_get_protocol_data(gc);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
803
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
804 name = g_uri_escape_string(record->first_name, NULL, FALSE);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
805 surname = g_uri_escape_string(record->last_name, NULL, FALSE);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
806 city = g_uri_escape_string(record->city, NULL, FALSE);
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
807 bday = g_date_time_format(record->birth, "%Y-%m-%d");
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
808
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
809 request_data = g_strdup_printf(
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
810 "name=%s&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
811 "surname=%s&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
812 "birth=%sT10:00:00%%2B00:00&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
813 "birth_priv=2&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
814 "gender=%d&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
815 "gender_priv=2&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
816 "city=%s&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
817 "province=%d",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
818 name, surname,
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
819 bday,
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
820 record->gender,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
821 city,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
822 record->province);
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
823
40514
30d9cbf04922 Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40512
diff changeset
824 g_free(name);
30d9cbf04922 Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40512
diff changeset
825 g_free(surname);
30d9cbf04922 Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40512
diff changeset
826 g_free(city);
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
827 g_free(bday);
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
828
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
829 if (purple_debug_is_verbose() && purple_debug_is_unsafe()) {
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
830 purple_debug_misc("gg", "ggp_pubdir_set_info_got_token: "
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
831 "query [%s]\n", request_data);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
832 }
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
833
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
834 url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
835 msg = soup_message_new("PUT", url);
41214
b0b7d118475f Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41212
diff changeset
836 soup_message_headers_replace(soup_message_get_request_headers(msg),
b0b7d118475f Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41212
diff changeset
837 "Authorization", token);
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
838 soup_message_set_request(msg, "application/x-www-form-urlencoded",
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
839 SOUP_MEMORY_TAKE, request_data, -1);
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
840 soup_session_queue_message(info->http, msg,
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
841 ggp_pubdir_set_info_got_response, NULL);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
842
40020
76afb08714b4 Convert GG pubdir to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40010
diff changeset
843 g_free(url);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
844 ggp_pubdir_record_free(record, 1);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
845 }
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
846
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
847 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
848 ggp_pubdir_set_info_request(PurpleConnection *gc, PurpleRequestFields *fields)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
849 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
850 gchar *url;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
851 uin_t uin = ggp_str_to_uin(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
852 purple_account_get_username(purple_connection_get_account(gc)));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
853 ggp_pubdir_record *record = g_new0(ggp_pubdir_record, 1);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
854 gchar *birth_s;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
855
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
856 purple_debug_info("gg", "ggp_pubdir_set_info_request");
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
857
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
858 record->uin = uin;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
859 record->first_name =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
860 g_strdup(purple_request_fields_get_string(fields, "first_name"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
861 record->last_name =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
862 g_strdup(purple_request_fields_get_string(fields, "last_name"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
863 record->gender =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
864 GPOINTER_TO_INT(purple_request_fields_get_choice(fields, "gender"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
865 record->city = g_strdup(purple_request_fields_get_string(fields, "city"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
866 record->province = GPOINTER_TO_INT(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
867 purple_request_fields_get_choice(fields, "province"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
868
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
869 birth_s = g_strdup_printf(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
870 "%sT10:00:00+00:00",
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
871 purple_request_fields_get_string(fields, "birth_date"));
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
872 record->birth = g_date_time_new_from_iso8601(birth_s, NULL);
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
873 g_free(birth_s);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
874 purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]",
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
875 g_date_time_to_unix(record->birth),
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
876 purple_request_fields_get_string(fields, "birth_date"));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
877
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
878 url = g_strdup_printf("http://api.gadu-gadu.pl/users/%u.xml", uin);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
879 ggp_oauth_request(gc, ggp_pubdir_set_info_got_token, record, "PUT", url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
880 g_free(url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
881 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
882
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
883 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
884 ggp_pubdir_set_info_dialog(PurpleConnection *gc, int records_count,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
885 const ggp_pubdir_record *records, int next_offset,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
886 void *user_data)
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
887 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
888 PurpleRequestFields *fields;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
889 PurpleRequestFieldGroup *group;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
890 PurpleRequestField *field;
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
891 gchar *bday = NULL;
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
892 gsize i;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
893 const ggp_pubdir_record *record;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
894
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
895 purple_debug_info("gg", "ggp_pubdir_set_info_dialog (record: %d)",
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
896 records_count);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
897
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
898 record = (records_count == 1 ? &records[0] : NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
899
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
900 fields = purple_request_fields_new();
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
901 group = purple_request_field_group_new(NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
902 purple_request_fields_add_group(fields, group);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
903
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
904 field = purple_request_field_string_new("first_name", _("First name"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
905 record ? record->first_name : NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
906 FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
907 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
908
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
909 field = purple_request_field_string_new("last_name", _("Last name"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
910 record ? record->last_name : NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
911 FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
912 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
913
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
914 field = purple_request_field_choice_new(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
915 "gender", _("Gender"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
916 record ? GINT_TO_POINTER(record->gender)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
917 : GGP_PUBDIR_GENDER_UNSPECIFIED);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
918 purple_request_field_set_required(field, TRUE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
919 purple_request_field_choice_add(field, _("Male"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
920 GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
921 purple_request_field_choice_add(field, _("Female"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
922 GINT_TO_POINTER(GGP_PUBDIR_GENDER_FEMALE));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
923 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
924
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
925 if(record != NULL && record->birth != NULL) {
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
926 bday = g_date_time_format(record->birth, "%Y-%m-%d");
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
927 }
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
928
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
929 field = purple_request_field_string_new(
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
930 "birth_date", _("Birth Day"), bday,
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
931 FALSE);
40512
05663def7b82 Fix some easy compiler warnings
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
932 g_free(bday);
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
933 purple_request_field_set_required(field, TRUE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
934 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
935
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
936 field = purple_request_field_string_new(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
937 "city", _("City"), record ? record->city : NULL, FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
938 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
939
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
940 /* Translators: This word is basically used to describe a Polish
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
941 province. Gadu-Gadu users outside of Poland might choose to enter some
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
942 equivalent value for themselves. For example, users in the USA might
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
943 use their state (e.g. New York). If there is an equivalent term for
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
944 your language, feel free to use it. Otherwise it's probably acceptable
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
945 to leave it changed or transliterate it into your alphabet. */
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
946 field = purple_request_field_choice_new("province", _("Voivodeship"), 0);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
947 purple_request_field_group_add_field(group, field);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
948 for (i = 0; i < ggp_pubdir_provinces_count; i++) {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
949 purple_request_field_choice_add(field, ggp_pubdir_provinces[i],
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
950 GINT_TO_POINTER(i));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
951 if (record && i == record->province) {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
952 purple_request_field_choice_set_value(field, GINT_TO_POINTER(i));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
953 purple_request_field_choice_set_default_value(field,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
954 GINT_TO_POINTER(i));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
955 }
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
956 }
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
957
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
958 purple_request_fields(gc, _("Set User Info"), _("Set User Info"), NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
959 fields, _("OK"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
960 G_CALLBACK(ggp_pubdir_set_info_request), _("Cancel"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
961 NULL, purple_request_cpar_from_connection(gc), gc);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
962 }
34232
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
963
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
964 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
965 ggp_pubdir_set_info(PurpleConnection *gc)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
966 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
967 ggp_pubdir_get_info(gc,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
968 ggp_str_to_uin(purple_account_get_username(
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
969 purple_connection_get_account(gc))),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
970 ggp_pubdir_set_info_dialog, NULL);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
971 }

mercurial