Mercurial > pidgin
annotate src/protocols/gg/gg.c @ 9800:cc68a8c6e741
[gaim-migrate @ 10668]
I rather dislike that gc is used implicitly as the handle.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 21 Aug 2004 05:12:23 +0000 |
parents | 62eb9fe24692 |
children | 0e3a84f18467 |
rev | line source |
---|---|
2393 | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | |
9797 | 3 * $Id: gg.c 10665 2004-08-20 22:05:18Z lschiere $ |
2393 | 4 * |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6 * |
2393 | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
22 #include "internal.h" |
2393 | 23 |
24 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */ | |
25 #include "libgg.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
26 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
27 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
28 #include "accountopt.h" |
9030 | 29 #include "blist.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
30 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
31 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
32 #include "proxy.h" |
2393 | 33 #include "prpl.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
34 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
35 #include "util.h" |
2393 | 36 |
5603 | 37 #define GG_CONNECT_STEPS 5 |
38 | |
2393 | 39 #define AGG_BUF_LEN 1024 |
40 | |
41 #define AGG_GENDER_NONE -1 | |
42 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
43 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
44 #define AGG_PUBDIR_USERLIST_IMPORT_FORM "/appsvc/fmcontactsget.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
45 #define AGG_PUBDIR_SEARCH_FORM "/appsvc/fmpubquery2.asp" |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
46 #define AGG_REGISTER_DATA_FORM "/appsvc/fmregister.asp" |
2393 | 47 #define AGG_PUBDIR_MAX_ENTRIES 200 |
48 | |
49 #define AGG_STATUS_AVAIL _("Available") | |
50 #define AGG_STATUS_AVAIL_FRIENDS _("Available for friends only") | |
51 #define AGG_STATUS_BUSY _("Away") | |
52 #define AGG_STATUS_BUSY_FRIENDS _("Away for friends only") | |
53 #define AGG_STATUS_INVISIBLE _("Invisible") | |
54 #define AGG_STATUS_INVISIBLE_FRIENDS _("Invisible for friends only") | |
55 #define AGG_STATUS_NOT_AVAIL _("Unavailable") | |
56 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
57 #define AGG_HTTP_NONE 0 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
58 #define AGG_HTTP_SEARCH 1 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
59 #define AGG_HTTP_USERLIST_IMPORT 2 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
60 #define AGG_HTTP_USERLIST_EXPORT 3 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
61 #define AGG_HTTP_USERLIST_DELETE 4 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
62 #define AGG_HTTP_PASSWORD_CHANGE 5 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
63 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
64 #define UC_NORMAL 2 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
65 |
2393 | 66 struct agg_data { |
67 struct gg_session *sess; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
68 int own_status; |
2393 | 69 }; |
70 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
71 struct agg_http { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
72 GaimConnection *gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
73 gchar *request; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
74 gchar *form; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
75 gchar *host; |
2393 | 76 int inpa; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
77 int type; |
2393 | 78 }; |
79 | |
80 | |
3466 | 81 static gchar *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) |
2393 | 82 { |
4051 | 83 return (g_convert (locstr, strlen (locstr), encdst, encsrc, NULL, NULL, NULL)); |
2393 | 84 } |
85 | |
3466 | 86 static gboolean invalid_uin(const char *uin) |
2393 | 87 { |
88 unsigned long int res = strtol(uin, (char **)NULL, 10); | |
7631 | 89 if (res == ULONG_MAX || res == 0) |
2393 | 90 return TRUE; |
91 return FALSE; | |
92 } | |
93 | |
94 static gint args_compare(gconstpointer a, gconstpointer b) | |
95 { | |
4793 | 96 return g_ascii_strcasecmp((const gchar *)a,(const gchar *)b); |
2393 | 97 } |
98 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
99 static gboolean allowed_uin(GaimConnection *gc, char *uin) |
2393 | 100 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
101 GaimAccount *account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
102 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
103 switch (account->perm_deny) { |
2393 | 104 case 1: |
105 /* permit all, deny none */ | |
106 return TRUE; | |
107 break; | |
108 case 2: | |
109 /* deny all, permit none. */ | |
110 return FALSE; | |
111 break; | |
112 case 3: | |
113 /* permit some. */ | |
4491 | 114 if (g_slist_find_custom(gc->account->permit, uin, args_compare)) |
2393 | 115 return TRUE; |
116 return FALSE; | |
117 break; | |
118 case 4: | |
119 /* deny some. */ | |
4491 | 120 if (g_slist_find_custom(gc->account->deny, uin, args_compare)) |
2393 | 121 return FALSE; |
122 return TRUE; | |
123 break; | |
124 default: | |
125 return TRUE; | |
126 break; | |
127 } | |
128 } | |
129 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
130 static char *handle_errcode(GaimConnection *gc, int errcode) |
2393 | 131 { |
132 static char msg[AGG_BUF_LEN]; | |
133 | |
134 switch (errcode) { | |
135 case GG_FAILURE_RESOLVING: | |
136 g_snprintf(msg, sizeof(msg), _("Unable to resolve hostname.")); | |
137 break; | |
138 case GG_FAILURE_CONNECTING: | |
139 g_snprintf(msg, sizeof(msg), _("Unable to connect to server.")); | |
140 break; | |
141 case GG_FAILURE_INVALID: | |
142 g_snprintf(msg, sizeof(msg), _("Invalid response from server.")); | |
143 break; | |
144 case GG_FAILURE_READING: | |
145 g_snprintf(msg, sizeof(msg), _("Error while reading from socket.")); | |
146 break; | |
147 case GG_FAILURE_WRITING: | |
3100 | 148 g_snprintf(msg, sizeof(msg), _("Error while writing to socket.")); |
2393 | 149 break; |
150 case GG_FAILURE_PASSWORD: | |
3100 | 151 g_snprintf(msg, sizeof(msg), _("Authentication failed.")); |
2393 | 152 break; |
153 default: | |
154 g_snprintf(msg, sizeof(msg), _("Unknown Error Code.")); | |
155 break; | |
156 } | |
157 | |
5603 | 158 gaim_connection_error(gc, msg); |
2393 | 159 |
160 return msg; | |
161 } | |
162 | |
6059 | 163 static void agg_set_away(GaimConnection *gc, const char *state, const char *msg) |
2393 | 164 { |
165 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
166 int status = gd->own_status; |
2393 | 167 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
168 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
169 g_free(gc->away); |
2393 | 170 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
171 } |
2393 | 172 |
4793 | 173 if (!gaim_utf8_strcasecmp(state, AGG_STATUS_AVAIL)) |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
174 status = GG_STATUS_AVAIL; |
4793 | 175 else if (!gaim_utf8_strcasecmp(state, AGG_STATUS_AVAIL_FRIENDS)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
176 status = GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
177 gc->away = g_strdup(""); |
4793 | 178 } else if (!gaim_utf8_strcasecmp(state, AGG_STATUS_BUSY)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
179 status = GG_STATUS_BUSY; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
180 gc->away = g_strdup(""); |
4793 | 181 } else if (!gaim_utf8_strcasecmp(state, AGG_STATUS_BUSY_FRIENDS)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
182 status = GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
183 gc->away = g_strdup(""); |
4793 | 184 } else if (!gaim_utf8_strcasecmp(state, AGG_STATUS_INVISIBLE)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
185 status = GG_STATUS_INVISIBLE; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
186 gc->away = g_strdup(""); |
4793 | 187 } else if (!gaim_utf8_strcasecmp(state, AGG_STATUS_INVISIBLE_FRIENDS)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
188 status = GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
189 gc->away = g_strdup(""); |
4793 | 190 } else if (!gaim_utf8_strcasecmp(state, AGG_STATUS_NOT_AVAIL)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
191 status = GG_STATUS_NOT_AVAIL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
192 gc->away = g_strdup(""); |
4793 | 193 } else if (!gaim_utf8_strcasecmp(state, GAIM_AWAY_CUSTOM)) { |
2393 | 194 if (msg) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
195 status = GG_STATUS_BUSY; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
196 gc->away = g_strdup(""); |
2393 | 197 } else |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
198 status = GG_STATUS_AVAIL; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
199 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
200 if (gd->own_status & GG_STATUS_FRIENDS_MASK) |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
201 status |= GG_STATUS_FRIENDS_MASK; |
2393 | 202 } |
9415 | 203 |
204 if (msg) { | |
205 switch (status) { | |
206 case GG_STATUS_AVAIL: | |
207 status = GG_STATUS_AVAIL_DESCR; | |
208 break; | |
209 case GG_STATUS_BUSY: | |
210 status = GG_STATUS_BUSY_DESCR; | |
211 break; | |
212 case GG_STATUS_INVISIBLE: | |
213 status = GG_STATUS_INVISIBLE_DESCR; | |
214 break; | |
215 case GG_STATUS_NOT_AVAIL: | |
216 status = GG_STATUS_NOT_AVAIL_DESCR; | |
217 break; | |
218 } | |
219 } | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
220 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
221 gd->own_status = status; |
9415 | 222 if (msg) |
223 gg_change_status_descr(gd->sess, status, msg); | |
224 else | |
225 gg_change_status(gd->sess, status); | |
226 } | |
227 | |
9421 | 228 #if 0 |
9415 | 229 static void agg_get_away(GaimConnection *gc, const char *who) |
230 { | |
231 GaimBuddy *buddy; | |
232 char *dialog_msg, **splitmsg; | |
233 | |
234 if (invalid_uin(who)) | |
9421 | 235 return; |
9415 | 236 |
237 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | |
238 if (buddy->proto_data) { | |
9421 | 239 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ |
240 splitmsg = g_strsplit(buddy->proto_data, "\r\n", 0); | |
9415 | 241 |
9421 | 242 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, (char *)buddy->proto_data, g_strjoinv("<BR>", splitmsg)); |
9797 | 243 gaim_notify_userinfo(gc, who, NULL, _("Buddy Information"), buddy->proto_data, dialog_msg, NULL, NULL); |
9415 | 244 } |
2393 | 245 } |
9421 | 246 #endif |
2393 | 247 |
248 static gchar *get_away_text(int uc) | |
249 { | |
250 if (uc == UC_UNAVAILABLE) | |
251 return AGG_STATUS_NOT_AVAIL; | |
252 uc = uc >> 5; | |
253 switch (uc) { | |
254 case GG_STATUS_AVAIL: | |
255 default: | |
256 return AGG_STATUS_AVAIL; | |
257 case GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK: | |
258 return AGG_STATUS_AVAIL_FRIENDS; | |
259 case GG_STATUS_BUSY: | |
260 return AGG_STATUS_BUSY; | |
261 case GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK: | |
262 return AGG_STATUS_BUSY_FRIENDS; | |
263 case GG_STATUS_INVISIBLE: | |
264 return AGG_STATUS_INVISIBLE; | |
265 case GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK: | |
266 return AGG_STATUS_INVISIBLE_FRIENDS; | |
267 case GG_STATUS_NOT_AVAIL: | |
268 return AGG_STATUS_NOT_AVAIL; | |
269 } | |
270 } | |
271 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
272 static GList *agg_away_states(GaimConnection *gc) |
2393 | 273 { |
274 GList *m = NULL; | |
275 | |
276 m = g_list_append(m, AGG_STATUS_AVAIL); | |
277 m = g_list_append(m, AGG_STATUS_BUSY); | |
278 m = g_list_append(m, AGG_STATUS_INVISIBLE); | |
279 m = g_list_append(m, AGG_STATUS_AVAIL_FRIENDS); | |
280 m = g_list_append(m, AGG_STATUS_BUSY_FRIENDS); | |
281 m = g_list_append(m, AGG_STATUS_INVISIBLE_FRIENDS); | |
282 m = g_list_append(m, AGG_STATUS_NOT_AVAIL); | |
283 return m; | |
284 } | |
285 | |
286 /* Enhance these functions, more options and such stuff */ | |
9030 | 287 static GList *agg_buddy_menu(GaimBuddy *buddy) |
2393 | 288 { |
289 GList *m = NULL; | |
9030 | 290 GaimBlistNodeAction *act; |
291 | |
2393 | 292 static char buf[AGG_BUF_LEN]; |
9030 | 293 g_snprintf(buf, sizeof(buf), _("Status: %s"), get_away_text(buddy->uc)); |
2393 | 294 |
9030 | 295 /* um... this seems silly. since in this pass, I'm only converting |
296 over the menu building, I'm not going to mess with it though */ | |
297 /* XXX: shouldn't this be in the tooltip instead? */ | |
298 act = gaim_blist_node_action_new(buf, NULL, NULL); | |
299 m = g_list_append(m, act); | |
2393 | 300 |
301 return m; | |
302 } | |
303 | |
9030 | 304 |
305 static GList * | |
306 agg_blist_node_menu(GaimBlistNode *node) | |
307 { | |
308 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
309 return agg_buddy_menu((GaimBuddy *) node); | |
310 } else { | |
311 return NULL; | |
312 } | |
313 } | |
314 | |
315 | |
8775 | 316 static void agg_load_buddy_list(GaimConnection *gc, char *buddylist) |
317 { | |
318 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
319 gchar *ptr = buddylist; | |
320 gchar **users_tbl; | |
321 int i; | |
322 uin_t *userlist = NULL; | |
323 int userlist_size = 0; | |
324 | |
325 users_tbl = g_strsplit(ptr, "\r\n", AGG_PUBDIR_MAX_ENTRIES); | |
326 | |
327 /* Parse array of Buddies List */ | |
328 for (i = 0; users_tbl[i] != NULL; i++) { | |
329 gchar **data_tbl; | |
330 gchar *name, *show; | |
331 | |
332 if (strlen(users_tbl[i])==0) { | |
333 gaim_debug(GAIM_DEBUG_MISC, "gg", | |
334 "import_buddies_server_results: users_tbl[i] is empty\n"); | |
335 continue; | |
336 } | |
337 | |
338 data_tbl = g_strsplit(users_tbl[i], ";", 8); | |
339 | |
340 show = charset_convert(data_tbl[3], "CP1250", "UTF-8"); | |
341 name = data_tbl[6]; | |
8996 | 342 |
8775 | 343 if (invalid_uin(name)) { |
344 continue; | |
345 } | |
346 | |
347 gaim_debug(GAIM_DEBUG_MISC, "gg", | |
348 "import_buddies_server_results: uin: %s\n", name); | |
349 if (!gaim_find_buddy(gc->account, name)) { | |
350 GaimBuddy *b; | |
351 GaimGroup *g; | |
352 /* Default group if none specified on server */ | |
353 gchar *group = g_strdup("Gadu-Gadu"); | |
354 if (strlen(data_tbl[5])) { | |
355 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); | |
356 if (strlen(group_tbl[0])) { | |
357 g_free(group); | |
358 group = g_strdup(group_tbl[0]); | |
359 } | |
360 g_strfreev(group_tbl); | |
361 } | |
362 /* Add Buddy to our userlist */ | |
363 if (!(g = gaim_find_group(group))) { | |
364 g = gaim_group_new(group); | |
365 gaim_blist_add_group(g, NULL); | |
366 } | |
367 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); | |
368 gaim_blist_add_buddy(b,NULL,g,NULL); | |
8996 | 369 |
8775 | 370 userlist_size++; |
371 userlist = g_renew(uin_t, userlist, userlist_size); | |
372 userlist[userlist_size - 1] = | |
373 (uin_t) strtol((char *)name, (char **)NULL, 10); | |
8996 | 374 |
8775 | 375 g_free(group); |
376 } | |
377 g_free(show); | |
378 g_strfreev(data_tbl); | |
379 } | |
380 g_strfreev(users_tbl); | |
8996 | 381 |
8775 | 382 if (userlist) { |
383 gg_notify(gd->sess, userlist, userlist_size); | |
384 g_free(userlist); | |
385 } | |
386 } | |
387 | |
9285 | 388 static void agg_save_buddy_list(GaimConnection *gc, char *existlist) |
8775 | 389 { |
9285 | 390 struct agg_data *gd = (struct agg_data *)gc->proto_data; |
8775 | 391 GaimBlistNode *gnode, *cnode, *bnode; |
392 char *buddylist = g_strdup(existlist ? existlist : ""); | |
393 char *ptr; | |
394 | |
395 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
396 GaimGroup *g = (GaimGroup *)gnode; | |
397 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
398 continue; | |
399 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
400 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
401 continue; | |
402 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
403 GaimBuddy *b = (GaimBuddy *)bnode; | |
404 | |
405 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
406 continue; | |
407 | |
408 if(b->account == gc->account) { | |
409 gchar *newdata; | |
410 /* GG Number */ | |
411 gchar *name = b->name; | |
412 /* GG Pseudo */ | |
413 gchar *show = b->alias ? b->alias : b->name; | |
414 /* Group Name */ | |
415 gchar *gname = g->name; | |
416 | |
417 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s;%s%s\r\n", | |
418 show, show, show, show, "", gname, name, "", ""); | |
8996 | 419 |
8775 | 420 ptr = buddylist; |
421 buddylist = g_strconcat(ptr, newdata, NULL); | |
8996 | 422 |
8775 | 423 g_free(newdata); |
424 g_free(ptr); | |
425 } | |
426 } | |
427 } | |
428 } | |
8996 | 429 |
8775 | 430 /* save the list to the gadu gadu server */ |
431 gg_userlist_request(gd->sess, GG_USERLIST_PUT, buddylist); | |
432 } | |
433 | |
2393 | 434 static void main_callback(gpointer data, gint source, GaimInputCondition cond) |
435 { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
436 GaimConnection *gc = data; |
2393 | 437 struct agg_data *gd = gc->proto_data; |
438 struct gg_event *e; | |
439 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
440 gaim_debug(GAIM_DEBUG_INFO, "gg", "main_callback enter: begin\n"); |
2393 | 441 |
442 if (gd->sess->fd != source) | |
443 gd->sess->fd = source; | |
444 | |
4511 | 445 if (source == 0) { |
5603 | 446 gaim_connection_error(gc, _("Could not connect")); |
2393 | 447 return; |
448 } | |
449 | |
450 if (!(e = gg_watch_fd(gd->sess))) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
451 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
452 "main_callback: gg_watch_fd failed - CRITICAL!\n"); |
5603 | 453 gaim_connection_error(gc, _("Unable to read socket")); |
2393 | 454 return; |
455 } | |
456 | |
457 switch (e->type) { | |
458 case GG_EVENT_NONE: | |
459 /* do nothing */ | |
460 break; | |
461 case GG_EVENT_CONN_SUCCESS: | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
462 gaim_debug(GAIM_DEBUG_WARNING, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
463 "main_callback: CONNECTED AGAIN!?\n"); |
2393 | 464 break; |
465 case GG_EVENT_CONN_FAILED: | |
466 if (gc->inpa) | |
467 gaim_input_remove(gc->inpa); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
468 handle_errcode(gc, e->event.failure); |
2393 | 469 break; |
470 case GG_EVENT_MSG: | |
471 { | |
472 gchar *imsg; | |
8442 | 473 gchar *jmsg; |
2393 | 474 gchar user[20]; |
475 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
476 g_snprintf(user, sizeof(user), "%lu", e->event.msg.sender); |
2393 | 477 if (!allowed_uin(gc, user)) |
478 break; | |
4051 | 479 imsg = charset_convert(e->event.msg.message, "CP1250", "UTF-8"); |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7386
diff
changeset
|
480 gaim_str_strip_cr(imsg); |
8442 | 481 jmsg = gaim_escape_html(imsg); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
482 /* e->event.msg.time - we don't know what this time is for */ |
8442 | 483 serv_got_im(gc, user, jmsg, 0, time(NULL)); |
2393 | 484 g_free(imsg); |
8442 | 485 g_free(jmsg); |
2393 | 486 } |
487 break; | |
488 case GG_EVENT_NOTIFY: | |
489 { | |
490 gchar user[20]; | |
491 struct gg_notify_reply *n = e->event.notify; | |
492 guint status; | |
493 | |
494 while (n->uin) { | |
495 switch (n->status) { | |
496 case GG_STATUS_NOT_AVAIL: | |
497 status = UC_UNAVAILABLE; | |
498 break; | |
499 case GG_STATUS_AVAIL: | |
500 case GG_STATUS_BUSY: | |
501 case GG_STATUS_INVISIBLE: | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
502 status = UC_NORMAL | (n->status << 5); |
2393 | 503 break; |
504 default: | |
505 status = UC_NORMAL; | |
506 break; | |
507 } | |
508 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
509 g_snprintf(user, sizeof(user), "%lu", n->uin); |
2393 | 510 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
4732 | 511 status); |
2393 | 512 n++; |
513 } | |
514 } | |
515 break; | |
8775 | 516 case GG_EVENT_NOTIFY60: |
517 { | |
518 gchar user[20]; | |
519 guint status; | |
9415 | 520 guint i = 0; |
521 | |
522 for (i = 0; e->event.notify60[i].uin; i++) { | |
523 GaimBuddy *buddy; | |
524 | |
525 g_snprintf(user, sizeof(user), "%lu", (long unsigned int)e->event.notify60[i].uin); | |
8775 | 526 |
9415 | 527 buddy = gaim_find_buddy(gaim_connection_get_account(gc), user); |
528 if (buddy && buddy->proto_data != NULL) { | |
529 g_free(buddy->proto_data); | |
530 buddy->proto_data = NULL; | |
531 } | |
532 | |
533 switch (e->event.notify60[i].status) { | |
8775 | 534 case GG_STATUS_NOT_AVAIL: |
9415 | 535 case GG_STATUS_NOT_AVAIL_DESCR: |
8775 | 536 status = UC_UNAVAILABLE; |
537 break; | |
538 case GG_STATUS_AVAIL: | |
9415 | 539 case GG_STATUS_AVAIL_DESCR: |
8775 | 540 case GG_STATUS_BUSY: |
9415 | 541 case GG_STATUS_BUSY_DESCR: |
8775 | 542 case GG_STATUS_INVISIBLE: |
9415 | 543 case GG_STATUS_INVISIBLE_DESCR: |
544 status = UC_NORMAL | (e->event.notify60[i].status << 5); | |
8775 | 545 break; |
546 default: | |
547 status = UC_NORMAL; | |
548 break; | |
549 } | |
9415 | 550 |
551 if (buddy && e->event.notify60[i].descr != NULL) { | |
552 buddy->proto_data = g_strdup(e->event.notify60[i].descr); | |
553 } | |
8775 | 554 |
555 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, | |
556 status); | |
9415 | 557 i++; |
8775 | 558 } |
559 } | |
560 break; | |
2393 | 561 case GG_EVENT_STATUS: |
562 { | |
563 gchar user[20]; | |
564 guint status; | |
565 | |
566 switch (e->event.status.status) { | |
567 case GG_STATUS_NOT_AVAIL: | |
568 status = UC_UNAVAILABLE; | |
569 break; | |
570 case GG_STATUS_AVAIL: | |
571 case GG_STATUS_BUSY: | |
572 case GG_STATUS_INVISIBLE: | |
573 status = UC_NORMAL | (e->event.status.status << 5); | |
574 break; | |
575 default: | |
576 status = UC_NORMAL; | |
577 break; | |
578 } | |
579 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
580 g_snprintf(user, sizeof(user), "%lu", e->event.status.uin); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
581 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
4732 | 582 status); |
2393 | 583 } |
584 break; | |
8775 | 585 case GG_EVENT_STATUS60: |
586 { | |
587 gchar user[20]; | |
588 guint status; | |
589 | |
9415 | 590 GaimBuddy *buddy; |
591 | |
592 g_snprintf(user, sizeof(user), "%lu", e->event.status60.uin); | |
593 | |
594 buddy = gaim_find_buddy(gaim_connection_get_account(gc), user); | |
595 if (buddy && buddy->proto_data != NULL) { | |
596 g_free(buddy->proto_data); | |
597 buddy->proto_data = NULL; | |
598 } | |
599 | |
8775 | 600 switch (e->event.status60.status) { |
601 case GG_STATUS_NOT_AVAIL: | |
9415 | 602 case GG_STATUS_NOT_AVAIL_DESCR: |
8775 | 603 status = UC_UNAVAILABLE; |
604 break; | |
605 case GG_STATUS_AVAIL: | |
9415 | 606 case GG_STATUS_AVAIL_DESCR: |
8775 | 607 case GG_STATUS_BUSY: |
9415 | 608 case GG_STATUS_BUSY_DESCR: |
8775 | 609 case GG_STATUS_INVISIBLE: |
9415 | 610 case GG_STATUS_INVISIBLE_DESCR: |
8775 | 611 status = UC_NORMAL | (e->event.status60.status << 5); |
612 break; | |
613 default: | |
614 status = UC_NORMAL; | |
615 break; | |
616 } | |
9415 | 617 |
618 if (buddy && e->event.status60.descr != NULL) { | |
619 buddy->proto_data = g_strdup(e->event.status60.descr); | |
620 } | |
621 | |
8775 | 622 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
623 status); | |
624 } | |
8997 | 625 break; |
2393 | 626 case GG_EVENT_ACK: |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
627 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
628 "main_callback: message %d to %lu sent with status %d\n", |
2393 | 629 e->event.ack.seq, e->event.ack.recipient, e->event.ack.status); |
630 break; | |
8775 | 631 case GG_EVENT_USERLIST: |
632 { | |
633 gaim_debug(GAIM_DEBUG_MISC, "gg", "main_callback: received userlist reply\n"); | |
634 switch (e->event.userlist.type) { | |
635 case GG_USERLIST_GET_REPLY: | |
636 { | |
8996 | 637 |
8775 | 638 if (e->event.userlist.reply) { |
639 agg_load_buddy_list(gc, e->event.userlist.reply); | |
640 } | |
641 break; | |
642 } | |
643 | |
644 case GG_USERLIST_PUT_REPLY: | |
645 { | |
646 /* ignored */ | |
647 } | |
648 } | |
649 } | |
650 | |
2393 | 651 default: |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
652 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
653 "main_callback: unsupported event %d\n", e->type); |
2393 | 654 break; |
655 } | |
656 gg_free_event(e); | |
657 } | |
658 | |
3630 | 659 void login_callback(gpointer data, gint source, GaimInputCondition cond) |
2393 | 660 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
661 GaimConnection *gc = data; |
2393 | 662 struct agg_data *gd = gc->proto_data; |
663 struct gg_event *e; | |
664 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
665 gaim_debug(GAIM_DEBUG_INFO, "gg", "login_callback...\n"); |
5605 | 666 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2393 | 667 close(source); |
668 return; | |
669 } | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
670 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
671 gaim_debug(GAIM_DEBUG_INFO, "gg", "Found GG connection\n"); |
5603 | 672 |
4511 | 673 if (source == 0) { |
5603 | 674 gaim_connection_error(gc, _("Unable to connect.")); |
2393 | 675 return; |
676 } | |
4452 | 677 |
678 gd->sess->fd = source; | |
679 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
680 gaim_debug(GAIM_DEBUG_MISC, "gg", "Source is valid.\n"); |
3630 | 681 if (gc->inpa == 0) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
682 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
683 "login_callback.. checking gc->inpa .. is 0.. setting fd watch\n"); |
2393 | 684 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
685 gaim_debug(GAIM_DEBUG_INFO, "gg", "Adding watch on fd\n"); |
3630 | 686 } |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
687 gaim_debug(GAIM_DEBUG_INFO, "gg", "Checking State.\n"); |
2393 | 688 switch (gd->sess->state) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
689 case GG_STATE_READING_DATA: |
8896 | 690 gaim_connection_update_progress(gc, _("Reading data"), 1, GG_CONNECT_STEPS); |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
691 break; |
2393 | 692 case GG_STATE_CONNECTING_GG: |
8896 | 693 gaim_connection_update_progress(gc, _("Balancer handshake"), 2, GG_CONNECT_STEPS); |
2393 | 694 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
695 case GG_STATE_READING_KEY: |
8896 | 696 gaim_connection_update_progress(gc, _("Reading server key"), 3, GG_CONNECT_STEPS); |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
697 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
698 case GG_STATE_READING_REPLY: |
8896 | 699 gaim_connection_update_progress(gc, _("Exchanging key hash"), 4, GG_CONNECT_STEPS); |
2393 | 700 break; |
701 default: | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
702 gaim_debug(GAIM_DEBUG_INFO, "gg", "No State found\n"); |
2393 | 703 break; |
704 } | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
705 gaim_debug(GAIM_DEBUG_MISC, "gg", "gg_watch_fd\n"); |
2393 | 706 if (!(e = gg_watch_fd(gd->sess))) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
707 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
708 "login_callback: gg_watch_fd failed - CRITICAL!\n"); |
5603 | 709 gaim_connection_error(gc, _("Critical error in GG library\n")); |
2393 | 710 return; |
711 } | |
712 | |
3630 | 713 /* If we are GG_STATE_CONNECTING_GG then we still need to connect, as |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
714 we could not use gaim_proxy_connect in libgg.c */ |
3630 | 715 switch( gd->sess->state ) { |
716 case GG_STATE_CONNECTING_GG: | |
717 { | |
718 struct in_addr ip; | |
719 char buf[256]; | |
4634 | 720 |
3630 | 721 /* Remove watch on initial socket - now that we have ip and port of login server */ |
722 gaim_input_remove(gc->inpa); | |
723 | |
724 ip.s_addr = gd->sess->server_ip; | |
4634 | 725 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
726 if (gaim_proxy_connect(gc->account, inet_ntoa(ip), gd->sess->port, login_callback, gc) < 0) { |
3630 | 727 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), inet_ntoa(ip)); |
5603 | 728 gaim_connection_error(gc, buf); |
3630 | 729 return; |
730 } | |
731 break; | |
732 } | |
733 case GG_STATE_READING_KEY: | |
734 /* Set new watch on login server ip */ | |
735 if(gc->inpa) | |
736 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
737 gaim_debug(GAIM_DEBUG_INFO, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
738 "Setting watch on connection with login server.\n"); |
3630 | 739 break; |
740 }/* end switch() */ | |
741 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
742 gaim_debug(GAIM_DEBUG_MISC, "gg", "checking gg_event\n"); |
2393 | 743 switch (e->type) { |
744 case GG_EVENT_NONE: | |
745 /* nothing */ | |
746 break; | |
747 case GG_EVENT_CONN_SUCCESS: | |
748 /* Setup new input handler */ | |
749 if (gc->inpa) | |
750 gaim_input_remove(gc->inpa); | |
751 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, main_callback, gc); | |
752 | |
753 /* Our signon is complete */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
754 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2393 | 755 serv_finish_login(gc); |
756 | |
757 break; | |
758 case GG_EVENT_CONN_FAILED: | |
759 gaim_input_remove(gc->inpa); | |
760 gc->inpa = 0; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
761 handle_errcode(gc, e->event.failure); |
2393 | 762 break; |
763 default: | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
764 gaim_debug(GAIM_DEBUG_MISC, "gg", "no gg_event\n"); |
2393 | 765 break; |
766 } | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
767 gaim_debug(GAIM_DEBUG_INFO, "gg", "Returning from login_callback\n"); |
2393 | 768 gg_free_event(e); |
769 } | |
770 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
771 static void agg_keepalive(GaimConnection *gc) |
2393 | 772 { |
773 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
774 if (gg_ping(gd->sess) < 0) { | |
5603 | 775 gaim_connection_error(gc, _("Unable to ping server")); |
2393 | 776 return; |
777 } | |
778 } | |
779 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
780 static void agg_login(GaimAccount *account) |
2393 | 781 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
782 GaimConnection *gc = gaim_account_get_connection(account); |
2393 | 783 struct agg_data *gd = gc->proto_data = g_new0(struct agg_data, 1); |
784 char buf[80]; | |
785 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
786 #if 0 |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
787 gc->checkbox = _("Send as message"); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
788 #endif |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
789 |
2393 | 790 gd->sess = g_new0(struct gg_session, 1); |
791 | |
8896 | 792 gaim_connection_update_progress(gc, _("Looking up GG server"), 0, GG_CONNECT_STEPS); |
2393 | 793 |
4491 | 794 if (invalid_uin(account->username)) { |
5603 | 795 gaim_connection_error(gc, _("Invalid Gadu-Gadu UIN specified")); |
2393 | 796 return; |
797 } | |
798 | |
799 gc->inpa = 0; | |
800 | |
801 /* | |
802 if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
803 gaim_debug(GAIM_DEBUG_MISC, "gg", "uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password); |
6321 | 804 gaim_connection_error(gc, _("Unable to connect.")); |
2393 | 805 signoff(gc); |
806 return; | |
807 } | |
808 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
809 gg_login() sucks for me, so I'm using gaim_proxy_connect() |
2393 | 810 */ |
811 | |
4491 | 812 gd->sess->uin = (uin_t) strtol(account->username, (char **)NULL, 10); |
813 gd->sess->password = g_strdup(account->password); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
814 gd->sess->state = GG_STATE_CONNECTING; |
2393 | 815 gd->sess->check = GG_CHECK_WRITE; |
816 gd->sess->async = 1; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
817 if (gaim_proxy_connect(account, GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc) < 0) { |
2393 | 818 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); |
5603 | 819 gaim_connection_error(gc, buf); |
2393 | 820 return; |
821 } | |
822 } | |
823 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
824 static void agg_close(GaimConnection *gc) |
2393 | 825 { |
826 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
827 if (gc->inpa) | |
828 gaim_input_remove(gc->inpa); | |
829 gg_logoff(gd->sess); | |
3339 | 830 gd->own_status = GG_STATUS_NOT_AVAIL; |
2393 | 831 gg_free_session(gd->sess); |
832 g_free(gc->proto_data); | |
833 } | |
834 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
835 static int agg_send_im(GaimConnection *gc, const char *who, const char *msg, GaimConvImFlags flags) |
2393 | 836 { |
837 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
838 gchar *imsg; | |
839 | |
840 if (invalid_uin(who)) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
841 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
842 _("You are trying to send a message to an " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
843 "invalid Gadu-Gadu UIN."), NULL); |
2393 | 844 return -1; |
845 } | |
846 | |
847 if (strlen(msg) > 0) { | |
4051 | 848 imsg = charset_convert(msg, "UTF-8", "CP1250"); |
6622 | 849 if (gg_send_message(gd->sess, GG_CLASS_CHAT, |
2393 | 850 strtol(who, (char **)NULL, 10), imsg) < 0) |
851 return -1; | |
852 g_free(imsg); | |
853 } | |
854 return 1; | |
855 } | |
856 | |
9285 | 857 static void agg_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
2393 | 858 { |
859 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
9285 | 860 if (invalid_uin(buddy->name)) |
2393 | 861 return; |
9285 | 862 gg_add_notify(gd->sess, strtol(buddy->name, (char **)NULL, 10)); |
8775 | 863 agg_save_buddy_list(gc, NULL); |
2393 | 864 } |
865 | |
9285 | 866 static void agg_rem_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
2393 | 867 { |
868 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
9285 | 869 if (invalid_uin(buddy->name)) |
2393 | 870 return; |
9285 | 871 gg_remove_notify(gd->sess, strtol(buddy->name, (char **)NULL, 10)); |
8775 | 872 agg_save_buddy_list(gc, NULL); |
2393 | 873 } |
874 | |
9285 | 875 static void agg_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) |
2393 | 876 { |
877 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
878 uin_t *userlist = NULL; | |
879 int userlist_size = 0; | |
880 | |
9285 | 881 while (buddies) { |
882 GaimBuddy *buddy = buddies->data; | |
883 if (!invalid_uin(buddy->name)) { | |
2393 | 884 userlist_size++; |
885 userlist = g_renew(uin_t, userlist, userlist_size); | |
886 userlist[userlist_size - 1] = | |
9285 | 887 (uin_t) strtol(buddy->name, (char **)NULL, 10); |
2393 | 888 } |
9285 | 889 buddies = g_list_next(buddies); |
2393 | 890 } |
891 | |
892 if (userlist) { | |
893 gg_notify(gd->sess, userlist, userlist_size); | |
894 g_free(userlist); | |
895 } | |
8997 | 896 |
8775 | 897 agg_save_buddy_list(gc, NULL); |
2393 | 898 } |
899 | |
9415 | 900 static void agg_buddy_free (GaimBuddy *buddy) |
901 { | |
902 if (buddy->proto_data) { | |
903 g_free(buddy->proto_data); | |
904 buddy->proto_data = NULL; | |
905 } | |
906 } | |
907 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
908 static void search_results(GaimConnection *gc, gchar *webdata) |
2393 | 909 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
910 gchar **webdata_tbl; |
2393 | 911 gchar *buf; |
912 char *ptr; | |
913 int i, j; | |
914 | |
915 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
916 gaim_debug(GAIM_DEBUG_MISC, "gg", "search_callback: pubdir result [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
917 gaim_notify_error(gc, NULL, _("Couldn't get search results"), NULL); |
2393 | 918 return; |
919 } | |
920 ptr++; | |
921 | |
922 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL); | |
923 | |
924 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); | |
925 | |
926 j = 0; | |
927 | |
928 /* Parse array */ | |
9285 | 929 /* XXX - Make this use a GString */ |
2393 | 930 for (i = 0; webdata_tbl[i] != NULL; i++) { |
931 gchar *p, *oldibuf; | |
932 static gchar *ibuf; | |
933 | |
934 g_strdelimit(webdata_tbl[i], "\t\n", ' '); | |
935 | |
936 /* GG_PUBDIR_HOST service returns 7 lines of data per directory entry */ | |
937 if (i % 8 == 0) | |
938 j = 0; | |
939 | |
4051 | 940 p = charset_convert(g_strstrip(webdata_tbl[i]), "CP1250", "UTF-8"); |
2393 | 941 |
942 oldibuf = ibuf; | |
943 | |
944 switch (j) { | |
945 case 0: | |
946 ibuf = g_strconcat("---------------------------------<BR>\n", NULL); | |
947 oldibuf = ibuf; | |
948 ibuf = g_strconcat(oldibuf, "<B>", _("Active"), ":</B> ", | |
4606 | 949 (atoi(p) == 2) ? _("Yes") : _("No"), "<BR>\n", NULL); |
2393 | 950 g_free(oldibuf); |
951 break; | |
952 case 1: | |
953 ibuf = g_strconcat(oldibuf, "<B>", _("UIN"), ":</B> ", p, "<BR>\n", NULL); | |
954 g_free(oldibuf); | |
955 break; | |
956 case 2: | |
7981 | 957 ibuf = g_strconcat(oldibuf, "<B>", _("First Name"), ":</B> ", p, "<BR>\n", NULL); |
2393 | 958 g_free(oldibuf); |
959 break; | |
960 case 3: | |
961 ibuf = | |
6623 | 962 g_strconcat(oldibuf, "<B>", _("Last Name"), ":</B> ", p, "<BR>\n", NULL); |
2393 | 963 g_free(oldibuf); |
964 break; | |
965 case 4: | |
966 ibuf = g_strconcat(oldibuf, "<B>", _("Nick"), ":</B> ", p, "<BR>\n", NULL); | |
967 g_free(oldibuf); | |
968 break; | |
969 case 5: | |
970 /* Hack, invalid_uin does what we really want here but may change in future */ | |
971 if (invalid_uin(p)) | |
972 ibuf = | |
8063 | 973 g_strconcat(oldibuf, "<B>", _("Birth Year"), ":</B> <BR>\n", NULL); |
2393 | 974 else |
975 ibuf = | |
8063 | 976 g_strconcat(oldibuf, "<B>", _("Birth Year"), ":</B> ", p, "<BR>\n", |
2393 | 977 NULL); |
978 g_free(oldibuf); | |
979 break; | |
980 case 6: | |
981 if (atoi(p) == GG_GENDER_FEMALE) | |
982 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> woman<BR>\n", NULL); | |
983 else if (atoi(p) == GG_GENDER_MALE) | |
984 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> man<BR>\n", NULL); | |
985 else | |
986 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> <BR>\n", NULL); | |
987 g_free(oldibuf); | |
988 break; | |
989 case 7: | |
990 ibuf = g_strconcat(oldibuf, "<B>", _("City"), ":</B> ", p, "<BR>\n", NULL); | |
991 g_free(oldibuf); | |
992 | |
993 /* We have all lines, so add them to buffer */ | |
994 { | |
995 gchar *oldbuf = buf; | |
996 buf = g_strconcat(oldbuf, ibuf, NULL); | |
997 g_free(oldbuf); | |
998 } | |
999 | |
1000 g_free(ibuf); | |
1001 break; | |
1002 } | |
1003 | |
1004 g_free(p); | |
1005 | |
1006 j++; | |
1007 } | |
1008 | |
1009 g_strfreev(webdata_tbl); | |
1010 | |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1011 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, |
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1012 buf, NULL, NULL); |
2393 | 1013 |
1014 g_free(buf); | |
1015 } | |
1016 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1017 static void |
9015 | 1018 change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1019 { |
9015 | 1020 GaimConnection *gc = (GaimConnection *) action->context; |
1021 GaimAccount *account = gaim_connection_get_account(gc); | |
1022 gaim_account_request_change_password(account); | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1023 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1024 |
8775 | 1025 #if 0 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1026 static void import_buddies_server_results(GaimConnection *gc, gchar *webdata) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1027 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1028 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1029 gchar **users_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1030 int i; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1031 if (strstr(webdata, "no_data:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1032 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1033 _("There is no Buddy List stored on the " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1034 "Gadu-Gadu server."), NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1035 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1036 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1037 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1038 if ((ptr = strstr(webdata, "get_results:")) == NULL || (ptr = strchr(ptr, ':')) == NULL) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1039 gaim_debug(GAIM_DEBUG_MISC, "gg", "import_buddies_server_results: import buddies result [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1040 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1041 _("Couldn't Import Buddy List from Server"), NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1042 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1043 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1044 ptr++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1045 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1046 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1047 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1048 /* Parse array of Buddies List */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1049 for (i = 0; users_tbl[i] != NULL; i++) { |
4520
4fe661860577
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
1050 gchar **data_tbl; |
4fe661860577
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
1051 gchar *name, *show; |
4fe661860577
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
1052 |
4516 | 1053 if (strlen(users_tbl[i])==0) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1054 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1055 "import_buddies_server_results: users_tbl[i] is empty\n"); |
4530 | 1056 continue; |
4516 | 1057 } |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1058 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1059 g_strdelimit(users_tbl[i], "\r\t\n\015", ' '); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1060 data_tbl = g_strsplit(users_tbl[i], ";", 8); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1061 |
4437 | 1062 show = charset_convert(data_tbl[3], "CP1250", "UTF-8"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1063 name = data_tbl[6]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1064 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1065 if (invalid_uin(name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1066 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1067 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1068 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1069 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1070 "import_buddies_server_results: uin: %s\n", name); |
4687 | 1071 if (!gaim_find_buddy(gc->account, name)) { |
6695 | 1072 GaimBuddy *b; |
1073 GaimGroup *g; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1074 /* Default group if none specified on server */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1075 gchar *group = g_strdup("Gadu-Gadu"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1076 if (strlen(data_tbl[5])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1077 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1078 if (strlen(group_tbl[0])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1079 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1080 group = g_strdup(group_tbl[0]); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1081 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1082 g_strfreev(group_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1083 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1084 /* Add Buddy to our userlist */ |
4775 | 1085 if (!(g = gaim_find_group(group))) { |
4687 | 1086 g = gaim_group_new(group); |
4775 | 1087 gaim_blist_add_group(g, NULL); |
1088 } | |
4687 | 1089 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); |
9295 | 1090 gaim_blist_add_buddy(b, NULL, g, NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1091 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1092 } |
4437 | 1093 g_free(show); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1094 g_strfreev(data_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1095 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1096 g_strfreev(users_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1097 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1098 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1099 static void export_buddies_server_results(GaimConnection *gc, gchar *webdata) |
2393 | 1100 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1101 if (strstr(webdata, "put_success:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1102 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1103 _("Buddy List successfully transferred to " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1104 "Gadu-Gadu server"), NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1105 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1106 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1107 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1108 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1109 "export_buddies_server_results: webdata [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1110 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1111 _("Couldn't transfer Buddy List to Gadu-Gadu server"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1112 NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1113 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1114 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1115 static void delete_buddies_server_results(GaimConnection *gc, gchar *webdata) |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1116 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1117 if (strstr(webdata, "put_success:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1118 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1119 _("Buddy List successfully deleted from " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1120 "Gadu-Gadu server"), NULL); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1121 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1122 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1123 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1124 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1125 "delete_buddies_server_results: webdata [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1126 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1127 _("Couldn't delete Buddy List from Gadu-Gadu server"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1128 NULL); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1129 } |
8775 | 1130 #endif |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1131 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1132 static void password_change_server_results(GaimConnection *gc, gchar *webdata) |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1133 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1134 if (strstr(webdata, "reg_success:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1135 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1136 _("Password changed successfully"), NULL); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1137 return; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1138 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1139 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1140 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1141 "password_change_server_results: webdata [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1142 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1143 _("Password couldn't be changed"), NULL); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1144 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1145 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1146 static void http_results(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1147 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1148 struct agg_http *hdata = data; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1149 GaimConnection *gc = hdata->gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1150 char *webdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1151 int len; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1152 char read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1153 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1154 gaim_debug(GAIM_DEBUG_INFO, "gg", "http_results: begin\n"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1155 |
5605 | 1156 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1157 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1158 "search_callback: g_slist_find error\n"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1159 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1160 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1161 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1162 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1163 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1164 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1165 webdata = NULL; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1166 len = 0; |
3717
988485669631
[gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
1167 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1168 while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1169 if (errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1170 errno = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1171 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1172 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1173 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1174 if (!read_data) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1175 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1176 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1177 len++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1178 webdata = g_realloc(webdata, len); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1179 webdata[len - 1] = read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1180 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1181 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1182 webdata = g_realloc(webdata, len + 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1183 webdata[len] = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1184 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1185 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1186 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1187 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1188 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1189 "http_results: type %d, webdata [%s]\n", hdata->type, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1190 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1191 switch (hdata->type) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1192 case AGG_HTTP_SEARCH: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1193 search_results(gc, webdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1194 break; |
8775 | 1195 #if 0 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1196 case AGG_HTTP_USERLIST_IMPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1197 import_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1198 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1199 case AGG_HTTP_USERLIST_EXPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1200 export_buddies_server_results(gc, webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1201 break; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1202 case AGG_HTTP_USERLIST_DELETE: |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1203 delete_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1204 break; |
8775 | 1205 #endif |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1206 case AGG_HTTP_PASSWORD_CHANGE: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1207 password_change_server_results(gc, webdata); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1208 break; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1209 case AGG_HTTP_NONE: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1210 default: |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1211 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1212 "http_results: unsupported type %d\n", hdata->type); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1213 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1214 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1215 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1216 g_free(webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1217 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1218 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1219 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1220 static void http_req_callback(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1221 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1222 struct agg_http *hdata = data; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1223 GaimConnection *gc = hdata->gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1224 gchar *request = hdata->request; |
2393 | 1225 gchar *buf; |
1226 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1227 gaim_debug(GAIM_DEBUG_INFO, "gg", "http_req_callback: begin\n"); |
2393 | 1228 |
5605 | 1229 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1230 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1231 "http_req_callback: g_slist_find error\n"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1232 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1233 g_free(hdata); |
2393 | 1234 close(source); |
1235 return; | |
1236 } | |
1237 | |
4511 | 1238 if (source == 0) { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1239 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1240 g_free(hdata); |
2393 | 1241 return; |
1242 } | |
1243 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1244 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1245 "http_req_callback: http request [%s]\n", request); |
2393 | 1246 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1247 buf = g_strdup_printf("POST %s HTTP/1.0\r\n" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1248 "Host: %s\r\n" |
2393 | 1249 "Content-Type: application/x-www-form-urlencoded\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1250 "User-Agent: " GG_HTTP_USERAGENT "\r\n" |
2393 | 1251 "Content-Length: %d\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1252 "Pragma: no-cache\r\n" "\r\n" "%s\r\n", |
7386 | 1253 hdata->form, hdata->host, (int)strlen(request), request); |
2393 | 1254 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1255 g_free(request); |
2393 | 1256 |
1257 if (write(source, buf, strlen(buf)) < strlen(buf)) { | |
1258 g_free(buf); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1259 g_free(hdata); |
2393 | 1260 close(source); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1261 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1262 _("Error communicating with Gadu-Gadu server"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1263 _("Gaim was unable to complete your request due " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1264 "to a problem communicating with the Gadu-Gadu " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1265 "HTTP server. Please try again later.")); |
2393 | 1266 return; |
1267 } | |
1268 | |
1269 g_free(buf); | |
1270 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1271 hdata->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_results, hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1272 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1273 |
8775 | 1274 #if 0 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1275 static void import_buddies_server(GaimConnection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1276 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1277 struct agg_http *hi = g_new0(struct agg_http, 1); |
5603 | 1278 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1279 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1280 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1281 hi->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1282 hi->type = AGG_HTTP_USERLIST_IMPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1283 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1284 hi->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1285 hi->request = g_strdup_printf("FmNum=%s&Pass=%s", u, p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1286 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1287 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1288 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1289 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1290 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1291 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1292 _("Unable to import Gadu-Gadu buddy list"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1293 _("Gaim was unable to connect to the Gadu-Gadu " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1294 "buddy list server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1295 g_free(hi->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1296 g_free(hi); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1297 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1298 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1299 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1300 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1301 static void export_buddies_server(GaimConnection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1302 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1303 struct agg_http *he = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1304 gchar *ptr; |
5603 | 1305 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1306 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1307 |
6695 | 1308 GaimBlistNode *gnode, *cnode, *bnode; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1309 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1310 he->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1311 he->type = AGG_HTTP_USERLIST_EXPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1312 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1313 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1314 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Contacts=", u, p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1315 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1316 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1317 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1318 |
4785 | 1319 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 1320 GaimGroup *g = (GaimGroup *)gnode; |
4516 | 1321 int num_added=0; |
4785 | 1322 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
1323 continue; | |
6695 | 1324 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1325 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
1326 continue; | |
1327 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1328 GaimBuddy *b = (GaimBuddy *)bnode; | |
4785 | 1329 |
6695 | 1330 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
1331 continue; | |
4349 | 1332 |
6695 | 1333 if(b->account == gc->account) { |
1334 gchar *newdata; | |
1335 /* GG Number */ | |
1336 gchar *name = gg_urlencode(b->name); | |
1337 /* GG Pseudo */ | |
1338 gchar *show = gg_urlencode(b->alias ? b->alias : b->name); | |
1339 /* Group Name */ | |
1340 gchar *gname = gg_urlencode(g->name); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1341 |
6695 | 1342 ptr = he->request; |
1343 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s", | |
1344 show, show, show, show, "", gname, name); | |
4516 | 1345 |
6695 | 1346 if(num_added > 0) |
1347 he->request = g_strconcat(ptr, "%0d%0a", newdata, NULL); | |
1348 else | |
1349 he->request = g_strconcat(ptr, newdata, NULL); | |
4516 | 1350 |
6695 | 1351 num_added++; |
1352 | |
1353 g_free(newdata); | |
1354 g_free(ptr); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1355 |
6695 | 1356 g_free(gname); |
1357 g_free(show); | |
1358 g_free(name); | |
1359 } | |
4349 | 1360 } |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1361 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1362 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1363 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1364 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1365 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1366 _("Couldn't export buddy list"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1367 _("Gaim was unable to connect to the buddy " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1368 "list server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1369 g_free(he->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1370 g_free(he); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1371 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1372 } |
2393 | 1373 } |
1374 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1375 static void delete_buddies_server(GaimConnection *gc) |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1376 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1377 struct agg_http *he = g_new0(struct agg_http, 1); |
5603 | 1378 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1379 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1380 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1381 he->gc = gc; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1382 he->type = AGG_HTTP_USERLIST_DELETE; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1383 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1384 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1385 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", u, p); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1386 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1387 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1388 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1389 _("Unable to delete Gadu-Gadu buddy list"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1390 _("Gaim was unable to connect to the buddy " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1391 "list server. Please try again later.")); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1392 g_free(he->request); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1393 g_free(he); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1394 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1395 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1396 } |
8775 | 1397 #endif |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1398 |
8950 | 1399 #if 0 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1400 static void agg_dir_search(GaimConnection *gc, const char *first, const char *middle, |
3466 | 1401 const char *last, const char *maiden, const char *city, const char *state, |
1402 const char *country, const char *email) | |
2393 | 1403 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1404 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1405 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1406 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1407 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1408 srch->host = GG_PUBDIR_HOST; |
2393 | 1409 |
1410 if (email && strlen(email)) { | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1411 gchar *eemail = gg_urlencode(email); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1412 srch->request = g_strdup_printf("Mode=1&Email=%s", eemail); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1413 g_free(eemail); |
2393 | 1414 } else { |
4051 | 1415 gchar *new_first = charset_convert(first, "UTF-8", "CP1250"); |
1416 gchar *new_last = charset_convert(last, "UTF-8", "CP1250"); | |
1417 gchar *new_city = charset_convert(city, "UTF-8", "CP1250"); | |
2393 | 1418 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1419 gchar *enew_first = gg_urlencode(new_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1420 gchar *enew_last = gg_urlencode(new_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1421 gchar *enew_city = gg_urlencode(new_city); |
2393 | 1422 |
1423 g_free(new_first); | |
1424 g_free(new_last); | |
1425 g_free(new_city); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1426 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1427 /* For active only add &ActiveOnly= */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1428 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d" |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1429 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1430 enew_first, enew_last, AGG_GENDER_NONE, |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1431 "", enew_city, 0, 0); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1432 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1433 g_free(enew_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1434 g_free(enew_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1435 g_free(enew_city); |
2393 | 1436 } |
1437 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1438 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1439 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1440 _("Unable to access directory"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1441 _("Gaim was unable to search the Directory " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1442 "because it was unable to connect to the " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1443 "directory server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1444 g_free(srch->request); |
2393 | 1445 g_free(srch); |
1446 return; | |
1447 } | |
1448 } | |
8950 | 1449 #endif |
2393 | 1450 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1451 static void agg_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1452 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1453 struct agg_http *hpass = g_new0(struct agg_http, 1); |
5603 | 1454 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1455 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1456 gchar *enew = gg_urlencode(new); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1457 gchar *eold = gg_urlencode(old); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1458 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1459 hpass->gc = gc; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1460 hpass->type = AGG_HTTP_PASSWORD_CHANGE; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1461 hpass->form = AGG_REGISTER_DATA_FORM; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1462 hpass->host = GG_REGISTER_HOST; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1463 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1464 /* We are using old password as place for email - it's ugly */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1465 hpass->request = g_strdup_printf("fmnumber=%s&fmpwd=%s&pwd=%s&email=%s&code=%u", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1466 u, p, enew, eold, gg_http_hash(old, new)); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1467 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1468 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1469 g_free(p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1470 g_free(enew); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1471 g_free(eold); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1472 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1473 if (gaim_proxy_connect(gc->account, GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { |
8997 | 1474 gaim_notify_error(gc, NULL, |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1475 _("Unable to change Gadu-Gadu password"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1476 _("Gaim was unable to change your password " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1477 "due to an error connecting to the " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1478 "Gadu-Gadu server. Please try again " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1479 "later.")); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1480 g_free(hpass->request); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1481 g_free(hpass); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1482 return; |
8997 | 1483 } |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1484 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1485 |
9015 | 1486 static GList *agg_actions(GaimPlugin *plugin, gpointer context) |
2393 | 1487 { |
1488 GList *m = NULL; | |
9015 | 1489 GaimPluginAction *act = NULL; |
2393 | 1490 |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1491 #if 0 |
9015 | 1492 act = gaim_plugin_action_new(_("Directory Search"), show_find_info); |
1493 m = g_list_append(m, act); | |
4333 | 1494 m = g_list_append(m, NULL); |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1495 #endif |
4333 | 1496 |
9015 | 1497 act = gaim_plugin_action_new(_("Change Password"), change_pass); |
1498 m = g_list_append(m, act); | |
4333 | 1499 |
8775 | 1500 #if 0 |
9015 | 1501 act = gaim_plugin_action_new(_("Import Buddy List from Server"), |
1502 import_buddies_server); | |
1503 m = g_list_append(m, act); | |
4333 | 1504 |
9015 | 1505 act = gaim_plugin_action_new(_("Export Buddy List to Server"), |
1506 export_buddies_server); | |
1507 m = g_list_append(m, act); | |
4333 | 1508 |
9015 | 1509 act = gaim_plugin_action_new(_("Delete Buddy List from Server"), |
1510 delete_buddies_server); | |
1511 m = g_list_append(m, act); | |
8775 | 1512 #endif |
2393 | 1513 |
1514 return m; | |
1515 } | |
1516 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1517 static void agg_get_info(GaimConnection *gc, const char *who) |
2393 | 1518 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1519 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1520 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1521 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1522 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1523 srch->host = GG_PUBDIR_HOST; |
2393 | 1524 |
1525 /* If it's invalid uin then maybe it's nickname? */ | |
1526 if (invalid_uin(who)) { | |
4051 | 1527 gchar *new_who = charset_convert(who, "UTF-8", "CP1250"); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1528 gchar *enew_who = gg_urlencode(new_who); |
8997 | 1529 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1530 g_free(new_who); |
2393 | 1531 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1532 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1533 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1534 "", "", AGG_GENDER_NONE, enew_who, "", 0, 0); |
2393 | 1535 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1536 g_free(enew_who); |
2393 | 1537 } else |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1538 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); |
2393 | 1539 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1540 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1541 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1542 _("Unable to access user profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1543 _("Gaim was unable to access this user's " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1544 "profile due to an error connecting to the " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1545 "directory server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1546 g_free(srch->request); |
2393 | 1547 g_free(srch); |
1548 return; | |
1549 } | |
1550 } | |
1551 | |
6695 | 1552 static const char *agg_list_icon(GaimAccount *a, GaimBuddy *b) |
2393 | 1553 { |
4687 | 1554 return "gadu-gadu"; |
1555 } | |
4916 | 1556 |
6695 | 1557 static void agg_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4916 | 1558 { |
1559 int status; | |
5068 | 1560 if (b->present == GAIM_BUDDY_OFFLINE) |
4916 | 1561 *se = "offline"; |
1562 else if (b->uc == UC_UNAVAILABLE) | |
1563 *se = "away"; | |
1564 else { | |
1565 status = b->uc >> 5; | |
1566 /* Drop all masks */ | |
1567 status &= ~(GG_STATUS_FRIENDS_MASK); | |
1568 if (status == GG_STATUS_BUSY) | |
5597 | 1569 *se = "away"; |
4916 | 1570 else if (status == GG_STATUS_INVISIBLE) |
1571 *se = "invisiible"; | |
1572 } | |
2393 | 1573 } |
4916 | 1574 |
2393 | 1575 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1576 static void agg_set_permit_deny_dummy(GaimConnection *gc) |
2393 | 1577 { |
1578 /* It's implemented on client side because GG server doesn't support this */ | |
1579 } | |
1580 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1581 static void agg_permit_deny_dummy(GaimConnection *gc, const char *who) |
2393 | 1582 { |
1583 /* It's implemented on client side because GG server doesn't support this */ | |
1584 } | |
1585 | |
8796 | 1586 static void agg_group_buddy (GaimConnection *gc, const char *who, |
8775 | 1587 const char *old_group, const char *new_group) |
1588 { | |
1589 GaimBuddy *buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | |
1590 gchar *newdata; | |
1591 /* GG Number */ | |
1592 gchar *name = buddy->name; | |
1593 /* GG Pseudo */ | |
1594 gchar *show = buddy->alias ? buddy->alias : buddy->name; | |
1595 /* Group Name */ | |
1596 const gchar *gname = new_group; | |
1597 | |
1598 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s;%s%s\r\n", | |
1599 show, show, show, show, "", gname, name, "", ""); | |
1600 agg_save_buddy_list(gc, newdata); | |
1601 g_free(newdata); | |
1602 } | |
1603 | |
9285 | 1604 static void agg_rename_group (GaimConnection *gc, const char *old_name, |
1605 GaimGroup *group, GList *moved_buddies) | |
8775 | 1606 { |
1607 agg_save_buddy_list(gc, NULL); | |
1608 } | |
1609 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1610 static GaimPlugin *my_protocol = NULL; |
2393 | 1611 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1612 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1613 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1614 GAIM_PRPL_API_VERSION, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1615 0, |
9475 | 1616 NULL, /* user_splits */ |
1617 NULL, /* protocol_options */ | |
1618 NO_BUDDY_ICONS, /* icon_spec */ | |
1619 agg_list_icon, /* list_icon */ | |
1620 agg_list_emblems, /* list_emblems */ | |
1621 NULL, /* status_text */ | |
1622 NULL, /* tooltip_text */ | |
1623 agg_away_states, /* away_states */ | |
1624 agg_blist_node_menu, /* blist_node_menu */ | |
1625 NULL, /* chat_info */ | |
9754 | 1626 NULL, /* chat_info_defaults */ |
9475 | 1627 agg_login, /* login */ |
1628 agg_close, /* close */ | |
1629 agg_send_im, /* send_im */ | |
1630 NULL, /* set_info */ | |
1631 NULL, /* send_typing */ | |
1632 agg_get_info, /* get_info */ | |
1633 agg_set_away, /* set_away */ | |
1634 NULL, /* set_idle */ | |
1635 agg_change_passwd, /* change_passwd */ | |
1636 agg_add_buddy, /* add_buddy */ | |
1637 agg_add_buddies, /* add_buddies */ | |
1638 agg_rem_buddy, /* remove_buddy */ | |
1639 NULL, /* remove_buddies */ | |
1640 agg_permit_deny_dummy, /* add_permit */ | |
1641 agg_permit_deny_dummy, /* add_deny */ | |
1642 agg_permit_deny_dummy, /* rem_permit */ | |
1643 agg_permit_deny_dummy, /* rem_deny */ | |
1644 agg_set_permit_deny_dummy, /* set_permit_deny */ | |
1645 NULL, /* warn */ | |
1646 NULL, /* join_chat */ | |
1647 NULL, /* reject_chat */ | |
1648 NULL, /* chat_invite */ | |
1649 NULL, /* chat_leave */ | |
1650 NULL, /* chat_whisper */ | |
1651 NULL, /* chat_send */ | |
1652 agg_keepalive, /* keepalive */ | |
1653 NULL, /* register_user */ | |
1654 NULL, /* get_cb_info */ | |
1655 NULL, /* get_cb_away */ | |
1656 NULL, /* alias_buddy */ | |
1657 agg_group_buddy, /* group_buddy */ | |
1658 agg_rename_group, /* rename_group */ | |
1659 agg_buddy_free, /* buddy_free */ | |
1660 NULL, /* convo_closed */ | |
1661 NULL, /* normalize */ | |
1662 NULL, /* set_buddy_icon */ | |
1663 NULL, /* remove_group */ | |
1664 NULL, /* get_cb_real_name */ | |
1665 NULL, /* set_chat_topic */ | |
1666 NULL, /* find_blist_chat */ | |
1667 NULL, /* roomlist_get_list */ | |
1668 NULL, /* roomlist_cancel */ | |
1669 NULL, /* roomlist_expand_category */ | |
1670 NULL, /* can_receive_file */ | |
1671 NULL /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1672 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1673 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1674 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1675 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1676 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1677 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1678 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1679 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1680 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1681 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1682 |
9030 | 1683 "prpl-gg", /**< id */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1684 "Gadu-Gadu", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1685 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1686 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1687 N_("Gadu-Gadu Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1688 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1689 N_("Gadu-Gadu Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1690 "Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>", /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
1691 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1692 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1693 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1694 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1695 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1696 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1697 NULL, /**< ui_info */ |
8993 | 1698 &prpl_info, /**< extra_info */ |
1699 NULL, | |
9015 | 1700 agg_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1701 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1702 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1703 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1704 init_plugin(GaimPlugin *plugin) |
2393 | 1705 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1706 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1707 |
5645
a9cd11fd0d6f
[gaim-migrate @ 6059]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
1708 option = gaim_account_option_string_new(_("Nick"), "nick", |
9030 | 1709 "Gadu-Gadu User"); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1710 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
9030 | 1711 option); |
3572 | 1712 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1713 my_protocol = plugin; |
2393 | 1714 } |
1715 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1716 GAIM_INIT_PLUGIN(gg, init_plugin, info); |