annotate src/protocols/gg/search.c @ 13626:fa7313d125ac

[gaim-migrate @ 16013] utils.c / utils.h is a common name. Namespacing the gg prpl's utils files to gg-utils.c and gg-utils.h. committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 11 Apr 2006 21:48:11 +0000
parents 41747a38a1a8
children d12bbe6da705
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
1 /**
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
2 * @file search.c
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
3 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
4 * gaim
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
5 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
6 * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us>
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
7 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
12 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
17 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
21 */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
22
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
23
13317
41747a38a1a8 [gaim-migrate @ 15686]
Richard Laager <rlaager@wiktel.com>
parents: 12007
diff changeset
24 #include <libgadu.h>
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
25
13626
fa7313d125ac [gaim-migrate @ 16013]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13317
diff changeset
26 #include "gg-utils.h"
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
27 #include "search.h"
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
28
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
29 /* GGPSearchForm *ggp_search_form_new() {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
30 GGPSearchForm *ggp_search_form_new()
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
31 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
32 GGPSearchForm *form;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
33
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
34 form = g_new0(GGPSearchForm, 1);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
35 form->uin = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
36 form->lastname = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
37 form->firstname = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
38 form->nickname = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
39 form->city = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
40 form->birthyear = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
41 form->gender = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
42 form->active = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
43 form->offset = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
44
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
45 form->last_uin = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
46
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
47 return form;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
48 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
49 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
50
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
51 /* void ggp_search_start(GaimConnection *gc, GGPSearchForm *form) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
52 void ggp_search_start(GaimConnection *gc, GGPSearchForm *form)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
53 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
54 GGPInfo *info = gc->proto_data;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
55 gg_pubdir50_t req;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
56
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
57 gaim_debug_info("gg", "It's time to perform a search...\n");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
58
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
59 if ((req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)) == NULL) {
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
60 gaim_debug_error("gg",
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
61 "ggp_bmenu_show_details: Unable to create req variable.\n");
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
62 return;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
63 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
64
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
65 if (form->uin != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
66 gaim_debug_info("gg", " uin: %s\n", form->uin);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
67 gg_pubdir50_add(req, GG_PUBDIR50_UIN, form->uin);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
68 } else {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
69 if (form->lastname != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
70 gaim_debug_info("gg", " lastname: %s\n", form->lastname);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
71 gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, form->lastname);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
72 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
73
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
74 if (form->firstname != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
75 gaim_debug_info("gg", " firstname: %s\n", form->firstname);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
76 gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, form->firstname);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
77 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
78
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
79 if (form->nickname != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
80 gaim_debug_info("gg", " nickname: %s\n", form->nickname);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
81 gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, form->nickname);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
82 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
83
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
84 if (form->city != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
85 gaim_debug_info("gg", " city: %s\n", form->city);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
86 gg_pubdir50_add(req, GG_PUBDIR50_CITY, form->city);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
87 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
88
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
89 if (form->birthyear != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
90 gaim_debug_info("gg", " birthyear: %s\n", form->birthyear);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
91 gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, form->birthyear);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
92 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
93
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
94 if (form->gender != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
95 gaim_debug_info("gg", " gender: %s\n", form->gender);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
96 gg_pubdir50_add(req, GG_PUBDIR50_GENDER, form->gender);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
97 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
98
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
99 if (form->active != NULL) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
100 gaim_debug_info("gg", " active: %s\n", form->active);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
101 gg_pubdir50_add(req, GG_PUBDIR50_ACTIVE, form->active);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
102 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
103 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
104
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
105 gaim_debug_info("gg", "offset: %s\n", form->offset);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
106 gg_pubdir50_add(req, GG_PUBDIR50_START, g_strdup(form->offset));
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
107
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
108 if (gg_pubdir50(info->session, req) == 0) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
109 gaim_debug_warning("gg", "ggp_bmenu_show_details: Search failed.\n");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
110 return;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
111 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
112
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
113 gg_pubdir50_free(req);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
114 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
115 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
116
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
117 /* char *ggp_search_get_result(gg_pubdir50_t res, int num, const char *field) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
118 char *ggp_search_get_result(gg_pubdir50_t res, int num, const char *field)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
119 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
120 char *tmp;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
121
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
122 tmp = charset_convert(gg_pubdir50_get(res, num, field), "CP1250", "UTF-8");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
123
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
124 return (tmp == NULL) ? g_strdup("") : tmp;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
125 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
126 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
127
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
128
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
129 /* vim: set ts=8 sts=0 sw=8 noet: */