libpurple/protocols/gg/pubdir-prpl.c

Fri, 11 Oct 2019 20:16:27 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Fri, 11 Oct 2019 20:16:27 -0400
changeset 40010
a72915f6fb1d
parent 37155
1aee6d5eefba
child 40020
76afb08714b4
permissions
-rw-r--r--

Re-arrange GG pubdir-prpl file to avoid prototypes.

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
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
30 #include "pubdir-prpl.h"
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
31
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
32 #include <debug.h>
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
33 #include <http.h>
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
34 #include <request.h>
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
35
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
36 #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
37 #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
38 #include "utils.h"
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
39 #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
40
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
41 typedef struct
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 PurpleConnection *gc;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
44 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
45 void *user_data;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
46 enum
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
47 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
48 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
49 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
50 } type;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
51 union
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
52 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
53 struct
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 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
56 } user_info;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
57 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
58 } params;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
59 } 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
60
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
61 /* Searching for buddies. */
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
62
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
63 #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
64 #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
65
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
66 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
67 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
68 gchar *nick, *city;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
69 ggp_pubdir_gender gender;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
70 int offset;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
71 int limit;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
72
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
73 void *display_handle;
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
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
76 /* 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
77 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
78 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
79 void *user_data);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
80
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
81 /******************************************************************************/
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 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
84 {
34338
c652670afac5 Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
85 N_("Not specified"),
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
86 "dolnośląskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
87 "kujawsko-pomorskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
88 "lubelskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
89 "lubuskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
90 "łódzkie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
91 "małopolskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
92 "mazowieckie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
93 "opolskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
94 "podkarpackie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
95 "podlaskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
96 "pomorskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
97 "śląskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
98 "świętokrzyskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
99 "warmińsko-mazurskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
100 "wielkopolskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
101 "zachodniopomorskie",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
102 };
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
103
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34287
diff changeset
104 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
105
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
106 /******************************************************************************/
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
107
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
108 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
109 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
110 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
111 int i;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
112 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
113 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
114 g_free(records[i].nickname);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
115 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
116 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
117 g_free(records[i].city);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
118 }
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);
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
120 }
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
121
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
122 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
123 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
124 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
125 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
126 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
127 g_free(form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
128 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
129
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
130 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
131 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
132 {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
133 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
134 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
135 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
136 }
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
137
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
138 static void ggp_pubdir_got_data(PurpleHttpConnection *http_conn,
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
139 PurpleHttpResponse *response, 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
140 {
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149
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
150 xml_raw = purple_http_response_get_data(response, NULL);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
151
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
152 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
153 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
154 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
155 }
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
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
157 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
158 if (xml == NULL) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
159 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
160 "invalid xml\n");
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
161 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
162 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
163 return;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
164 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
165
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
166 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
167 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
168 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
169 xml = purple_xmlnode_get_child(xml, "users");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
170 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
171 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
172 "invalid reply\n");
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
173 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
174 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
175 return;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
176 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
177
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
178 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
179 records = g_new0(ggp_pubdir_record, record_count);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
180
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
181 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
182 i = 0;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
183 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
184 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
185 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
186 unsigned int gender = 0;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
187 const gchar *uin_s;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
188
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
189 g_assert(i <= record_count);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
190
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
191 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
192 if (record->uin == 0)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
193 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
194 if (record->uin == 0)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
195 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
196 " invalid uin\n");
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
197 uin_s = ggp_uin_to_str(record->uin);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
198
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 ggp_xml_get_uint(xml, "province", &record->province);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
208
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
209 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
210 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
211 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
212 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
213 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
214 record->last_name = ggp_free_if_equal(record->last_name, "");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
215
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
216 if (record->label) {}
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
217 else if (record->nickname)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
218 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
219 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
220 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
221 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
222 else if (record->first_name)
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->first_name);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
224 else if (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(record->last_name);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
226 if (record->label)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
227 g_strstrip(record->label);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
228 if (record->nickname)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
229 g_strstrip(record->nickname);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
230
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
231 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
232 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
233 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
234 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
235 else
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
236 record->gender = GGP_PUBDIR_GENDER_UNSPECIFIED;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
237
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
238 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
239 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
240 if (record->city)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
241 g_strstrip(record->city);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
242 if (!record->city) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
243 g_free(record->city);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
244 record->city = NULL;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
245 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
246
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
247 record->birth = ggp_date_from_iso8601(birth_s);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
248 /*TODO: calculate age from birth */
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
249
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
250 if (purple_debug_is_verbose()) {
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
251 purple_debug_misc("gg", "ggp_pubdir_got_data: [uin:%d] "
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
252 "[label:%s] [nick:%s] [first name:%s] "
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
253 "[last name:%s] [city:%s] [gender:%d] [age:%d] "
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
254 "[birth:%lu]\n", record->uin, record->label,
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
255 record->nickname, record->first_name,
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
256 record->last_name, record->city, record->gender,
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
257 record->age, record->birth);
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
258 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
259
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
260 g_free(city);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
261
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
262 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
263 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
264
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
265 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
266
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
267 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
268 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
269 }
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
270
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
271 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
272 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
273 gpointer _request)
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
274 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
275 PurpleHttpRequest *req;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
276 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
277
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
278 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
279
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
280 if (!token) {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
281 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
282 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
283 return;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
284 }
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
285
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
286 req = purple_http_request_new(NULL);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
287 purple_http_request_set_url_printf(req, "http://api.gadu-gadu.pl/users/%u",
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
288 request->params.user_info.uin);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
289 purple_http_request_header_set(req, "Authorization", token);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
290 purple_http_request(gc, req, ggp_pubdir_got_data, request);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
291 purple_http_request_unref(req);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
292 }
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
293
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
294 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
295 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
296 void *user_data)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
297 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
298 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
299 gchar *url;
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
300
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
301 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
302 request->gc = gc;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
303 request->cb = cb;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
304 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
305 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
306
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
307 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
308 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
309 g_free(url);
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
310 }
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
311
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
312 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
313 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
314 void *_uin_p)
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
315 {
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
316 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
317 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
318 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
319 PurpleBuddy *buddy;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
320
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
321 g_free(_uin_p);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
322
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
323 if (records_count < 1) {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
324 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
325 "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
326 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
327 _("Cannot get user information"));
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
328 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
329 NULL, NULL);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
330 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
331 return;
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
332 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
333
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
334 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
335 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
336 g_assert(records_count == 1);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
337
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34701
diff changeset
338 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
339 ggp_uin_to_str(uin));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
340 if (buddy) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
341 const char *alias;
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
342 PurpleStatus *status;
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
343 gchar *status_message;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
344
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
345 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
346 if (alias)
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
347 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
348 _("Alias"), alias);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
349
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
350 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
351 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
352 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
353 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
354 purple_status_get_name(status));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
355 if (status_message) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
356 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
357 _("Message"), status_message);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
358 }
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
359 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
360
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
361 if (record->nickname) {
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
362 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
363 _("Nickname"), record->nickname);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
364 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
365 if (record->first_name) {
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
366 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
367 _("First name"), record->first_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
368 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
369 if (record->last_name) {
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
370 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
371 _("Last name"), record->last_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
372 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
373 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
374 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
375 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
376 _("Female") : _("Male"));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
377 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
378 if (record->city) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
379 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
380 record->city);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
381 }
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
382 if (record->birth) {
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
383 purple_notify_user_info_add_pair_plaintext(info, _("Birthday"),
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
384 ggp_date_strftime("%Y-%m-%d", record->birth));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
385 } 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
386 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
387 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
388 age_s);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
389 g_free(age_s);
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
390 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
391
33344
2a2560bb1445 Gadu-Gadu: getting user information with gg10.5 API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
392 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
393 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
394 }
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
395
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
396 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
397 ggp_pubdir_get_info_protocol(PurpleConnection *gc, const char *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
398 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
399 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
400 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
401
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
402 *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
403
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
404 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
405
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
406 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
407 }
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
408
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
409 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
410 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
411 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
412 {
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
413 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
414 const gchar *alias;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
415
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
416 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
417 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
418 "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
419 return;
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
420 }
33351
bd15903d0d89 Gadu-Gadu: fix compilation on 64bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33348
diff changeset
421 uin = records[0].uin;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
422
33345
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
423 alias = records[0].label;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
424 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
425 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
426 "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
427 return;
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
428 }
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
429
740174b22496 Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33344
diff changeset
430 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
431 "public alias for %u is \"%s\"\n", uin, alias);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
432
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35361
diff changeset
433 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
434 }
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
435
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
436 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
437 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
438 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
439 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
440
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
441 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
442
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
443 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
444 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
445
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
446 /*******************************************************************************
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
447 * Searching for buddies.
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
448 ******************************************************************************/
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
449
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
450 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
451 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
452 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
453 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
454
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
455 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
456 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
457 dup->gender = form->gender;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
458 dup->offset = form->offset;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
459 dup->limit = form->limit;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
460
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
461 dup->display_handle = form->display_handle;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
462
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
463 return dup;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
464 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
465
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
466 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
467 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
468 gchar *nick, *city, *gender;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
469 gchar *query;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
470
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
471 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
472 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
473 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
474 g_free(nick_e);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
475 } else
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
476 nick = g_strdup("");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
477
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
478 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
479 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
480 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
481 g_free(city_e);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
482 } else
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
483 city = g_strdup("");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
484
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
485 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
486 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
487 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
488 } else
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
489 gender = g_strdup("");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
490
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
491 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
492 form->offset, form->limit, nick, city, gender);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
493
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
494 g_free(nick);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
495 g_free(city);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
496 g_free(gender);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
497
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
498 return query;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
499 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
500
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
501 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
502 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
503 {
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
504 PurpleHttpRequest *req;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
505 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
506 gchar *query;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
507
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
508 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
509
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
510 if (!token) {
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
511 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
512 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
513 return;
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 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
517
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
518 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
519
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
520 req = purple_http_request_new(NULL);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
521 purple_http_request_set_url_printf(req, "http://api.gadu-gadu.pl%s", query);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
522 purple_http_request_header_set(req, "Authorization", 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
523 purple_http_request(gc, req, ggp_pubdir_got_data, request);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
524 purple_http_request_unref(req);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
525
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
526 g_free(query);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
527 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
528
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
529 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
530 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
531 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
532 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
533 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
534 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
535 gchar *url;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
536 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
537 gchar *query;
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
538
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
539 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
540 request->gc = gc;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
541 request->cb = cb;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
542 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
543 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
544
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
545 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
546 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
547 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
548 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
549 g_free(query);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
550 g_free(url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
551 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
552
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
553 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
554 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
555 {
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 *form = _form;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
557 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
558 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
559
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
560 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
561 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
562 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
563 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
564 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
565 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
566
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
567 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
568 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
569 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
570 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
571 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
572 form);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
573 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
574
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
575 static void
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_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
577 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
578 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
579 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
580 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
581 }
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 static void
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_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
585 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
586 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
587 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
588 }
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 static void
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_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
592 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
593 ggp_pubdir_get_info_protocol(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
594 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
595
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
596 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
597 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
598 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
599 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
600 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
601 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
602 PurpleNotifySearchResults *results;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
603 int i;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
604
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
605 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
606 "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
607 records_count, next_offset);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
608
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
609 if (records_count < 0 ||
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
610 (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
611 {
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
612 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
613 _("Error while searching for buddies"), NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
614 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
615 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
616 return;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
617 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
618
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
619 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
620 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
621 _("No matching users found"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
622 _("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
623 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
624 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
625 return;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
626 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
627
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
628 form->offset = next_offset;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
629
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
630 results = purple_notify_searchresults_new();
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
631
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
632 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
633 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
634 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
635 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
636 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
637 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
638 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
639 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
640 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
641 purple_notify_searchresults_column_new(_("Age")));
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
642
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
643 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
644 GList *row = NULL;
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
645 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
646 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
647
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
648 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
649 gender = g_strdup("male");
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
650 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
651 gender = g_strdup("female");
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
652
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
653 if (record->age)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
654 age = g_strdup_printf("%d", record->age);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
655
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
656 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
657 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
658 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
659 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
660 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
661 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
662 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
663
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
664 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
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 if (next_offset != 0)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
673 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
674 PURPLE_NOTIFY_BUTTON_CONTINUE,
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
675 ggp_pubdir_search_results_next);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
676
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
677 if (!form->display_handle)
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
678 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
679 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
680 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
681 else
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
682 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
683 form->display_handle);
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
684 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
685 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
686
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
687 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
688 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
689 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
690 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
691
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
692 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
693
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
694 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
695 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
696 form->gender =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
697 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
698 form->offset = 0;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
699 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
700
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
701 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
702 form);
33346
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
703 }
3b4cbb0e10d6 Gadu-Gadu: public directory search with gg10.5 api
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33345
diff changeset
704
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
705 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
706 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
707 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
708 PurpleRequestFields *fields;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
709 PurpleRequestFieldGroup *group;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
710 PurpleRequestField *field;
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");
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
713
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
714 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
715 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
716 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
717
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
718 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
719 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
720 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
721
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
722 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
723 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
724 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
725
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
726 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
727 "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
728 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
729 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
730 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
731 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
732 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
733 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
734
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
735 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
736 _("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
737 _("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
738 _("Cancel"), NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
739 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
740 }
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
741
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
742 /*******************************************************************************
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
743 * Own profile.
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
744 ******************************************************************************/
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
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 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
747 ggp_pubdir_set_info_got_response(PurpleHttpConnection *http_conn,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
748 PurpleHttpResponse *response,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
749 gpointer user_data)
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
750 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
751 if (!purple_http_response_is_successful(response)) {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
752 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
753 return;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
754 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
755
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
756 purple_debug_info("gg", "ggp_pubdir_set_info_got_response: [%s]",
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
757 purple_http_response_get_data(response, NULL));
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
758 /* <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
759
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
760 /* TODO: notify about failure */
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 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
764 const gchar *token, gpointer _record)
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
765 {
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
766 PurpleHttpRequest *req;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
767 ggp_pubdir_record *record = _record;
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
768 gchar *request_data;
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
769 gchar *name, *surname, *city;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
770 uin_t uin = record->uin;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
771
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
772 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
773
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
774 if (!token) {
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
775 /* TODO: notify about failure */
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
776 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
777 return;
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
778 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
779
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
780 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
781 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
782 city = g_uri_escape_string(record->city, NULL, FALSE);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35158
diff changeset
783
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
784 request_data = g_strdup_printf(
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
785 "name=%s&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
786 "surname=%s&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
787 "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
788 "birth_priv=2&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
789 "gender=%d&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
790 "gender_priv=2&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
791 "city=%s&"
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
792 "province=%d",
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
793 name, surname,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
794 ggp_date_strftime("%Y-%m-%d", record->birth),
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
795 record->gender,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
796 city,
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
797 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
798
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
799 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
800 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
801 "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
802 }
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
803
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
804 req = purple_http_request_new(NULL);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
805 purple_http_request_set_method(req, "PUT");
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
806 purple_http_request_set_url_printf(req,
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
807 "http://api.gadu-gadu.pl/users/%u.xml", uin);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
808 purple_http_request_header_set(req, "Authorization", 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
809 purple_http_request_header_set(req, "Content-Type",
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
810 "application/x-www-form-urlencoded");
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
811 purple_http_request_set_contents(req, request_data, -1);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
812 purple_http_request(gc, req, ggp_pubdir_set_info_got_response, NULL);
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
813 purple_http_request_unref(req);
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
814
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
815 g_free(request_data);
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
816 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
817 }
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
818
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
819 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
820 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
821 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
822 gchar *url;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
823 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
824 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
825 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
826 gchar *birth_s;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
827
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
828 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
829
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
830 record->uin = uin;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
831 record->first_name =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
832 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
833 record->last_name =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
834 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
835 record->gender =
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
836 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
837 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
838 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
839 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
840
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
841 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
842 "%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
843 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
844 record->birth = ggp_date_from_iso8601(birth_s);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
845 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
846 purple_debug_info("gg", "ggp_pubdir_set_info_request: birth [%lu][%s]",
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
847 record->birth,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
848 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
849
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
850 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
851 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
852 g_free(url);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
853 }
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
854
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
855 static void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
856 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
857 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
858 void *user_data)
33347
cc3f8295618a Gadu-Gadu: setting public profile information. Fixes #6918
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33346
diff changeset
859 {
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
860 PurpleRequestFields *fields;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
861 PurpleRequestFieldGroup *group;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
862 PurpleRequestField *field;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
863 gsize i;
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
864 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
865
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
866 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
867 records_count);
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 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
870
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
871 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
872 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
873 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
874
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
875 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
876 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
877 FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
878 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
879
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
880 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
881 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
882 FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
883 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
884
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
885 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
886 "gender", _("Gender"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
887 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
888 : 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
889 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
890 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
891 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
892 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
893 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
894 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
895
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
896 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
897 "birth_date", _("Birth Day"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
898 (record && record->birth)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
899 ? ggp_date_strftime("%Y-%m-%d", record->birth)
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
900 : NULL,
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
901 FALSE);
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
902 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
903 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
904
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
905 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
906 "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
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 /* 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
910 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
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 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
924 }
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
925 }
a5517f235e0f HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33865
diff changeset
926
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
927 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
928 fields, _("OK"),
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
929 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
930 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
931 }
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
932
40010
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
933 void
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
934 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
935 {
a72915f6fb1d Re-arrange GG pubdir-prpl file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37155
diff changeset
936 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
937 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
938 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
939 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
940 }

mercurial