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