Thu, 29 May 2008 12:17:05 +0000
Add a prototype for ggp_to_gg_status.
| 11394 | 1 | /** |
| 2 | * @file gg.c Gadu-Gadu protocol plugin | |
| 3 | * | |
| 15884 | 4 | * purple |
| 11394 | 5 | * |
| 6 | * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> | |
| 7 | * | |
| 12007 | 8 | * Some parts of the code are adapted or taken from the previous implementation |
| 11394 | 9 | * of this plugin written by Arkadiusz Miskiewicz <misiek@pld.org.pl> |
| 10 | * | |
| 11 | * Thanks to Google's Summer of Code Program. | |
| 12 | * | |
| 13 | * This program is free software; you can redistribute it and/or modify | |
| 14 | * it under the terms of the GNU General Public License as published by | |
| 15 | * the Free Software Foundation; either version 2 of the License, or | |
| 16 | * (at your option) any later version. | |
| 17 | * | |
| 18 | * This program is distributed in the hope that it will be useful, | |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | * GNU General Public License for more details. | |
| 22 | * | |
| 23 | * You should have received a copy of the GNU General Public License | |
| 24 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18629
diff
changeset
|
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11394 | 26 | */ |
| 27 | ||
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
28 | #include "internal.h" |
| 2393 | 29 | |
| 11360 | 30 | #include "plugin.h" |
| 31 | #include "version.h" | |
| 32 | #include "notify.h" | |
| 33 | #include "status.h" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
34 | #include "blist.h" |
| 11360 | 35 | #include "accountopt.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
36 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
37 | #include "util.h" |
| 11360 | 38 | #include "request.h" |
| 2393 | 39 | |
| 13318 | 40 | #include <libgadu.h> |
| 5603 | 41 | |
| 11414 | 42 | #include "gg.h" |
| 43 | #include "confer.h" | |
| 44 | #include "search.h" | |
| 45 | #include "buddylist.h" | |
|
13627
44233a1064f9
[gaim-migrate @ 16013]
Evan Schoenberg <evands@pidgin.im>
parents:
13573
diff
changeset
|
46 | #include "gg-utils.h" |
| 11394 | 47 | |
| 15884 | 48 | static PurplePlugin *my_protocol = NULL; |
| 11394 | 49 | |
| 11360 | 50 | /* ---------------------------------------------------------------------- */ |
| 11414 | 51 | /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ |
| 11360 | 52 | /* ---------------------------------------------------------------------- */ |
| 9950 | 53 | |
| 12007 | 54 | |
| 55 | /* ----- HELPERS -------------------------------------------------------- */ | |
| 56 | ||
| 13515 | 57 | /** |
| 58 | * Set up libgadu's proxy. | |
| 59 | * | |
| 60 | * @param account Account for which to set up the proxy. | |
| 61 | * | |
| 62 | * @return Zero if proxy setup is valid, otherwise -1. | |
| 63 | */ | |
| 15884 | 64 | /* static int ggp_setup_proxy(PurpleAccount *account) {{{ */ |
| 65 | static int ggp_setup_proxy(PurpleAccount *account) | |
| 13515 | 66 | { |
| 15884 | 67 | PurpleProxyInfo *gpi; |
| 13515 | 68 | |
| 15884 | 69 | gpi = purple_proxy_get_setup(account); |
| 13515 | 70 | |
| 15884 | 71 | if ((purple_proxy_info_get_type(gpi) != PURPLE_PROXY_NONE) && |
| 72 | (purple_proxy_info_get_host(gpi) == NULL || | |
| 73 | purple_proxy_info_get_port(gpi) <= 0)) { | |
| 13515 | 74 | |
| 75 | gg_proxy_enabled = 0; | |
| 15884 | 76 | purple_notify_error(NULL, NULL, _("Invalid proxy settings"), |
| 13515 | 77 | _("Either the host name or port number specified for your given proxy type is invalid.")); |
| 78 | return -1; | |
| 15884 | 79 | } else if (purple_proxy_info_get_type(gpi) != PURPLE_PROXY_NONE) { |
| 13515 | 80 | gg_proxy_enabled = 1; |
| 15884 | 81 | gg_proxy_host = g_strdup(purple_proxy_info_get_host(gpi)); |
| 82 | gg_proxy_port = purple_proxy_info_get_port(gpi); | |
| 83 | gg_proxy_username = g_strdup(purple_proxy_info_get_username(gpi)); | |
| 84 | gg_proxy_password = g_strdup(purple_proxy_info_get_password(gpi)); | |
| 13515 | 85 | } else { |
| 86 | gg_proxy_enabled = 0; | |
| 87 | } | |
| 88 | ||
| 89 | return 0; | |
| 90 | } | |
| 91 | /* }}} */ | |
| 92 | ||
| 12007 | 93 | /* |
| 94 | */ | |
| 15884 | 95 | /* static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */ |
| 96 | static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) | |
| 12007 | 97 | { |
| 15884 | 98 | PurpleConnection *gc = _gc; |
| 12007 | 99 | GGPInfo *info = gc->proto_data; |
| 100 | GGPToken *token = info->token; | |
| 101 | GGPTokenCallback cb; | |
| 102 | ||
| 103 | struct gg_token *t = NULL; | |
| 104 | ||
| 15884 | 105 | purple_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n", |
| 12007 | 106 | token->req->check, token->req->state); |
| 107 | ||
| 108 | if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) { | |
| 15884 | 109 | purple_debug_error("gg", "token error (1): %d\n", token->req->error); |
| 110 | purple_input_remove(token->inpa); | |
| 12007 | 111 | gg_token_free(token->req); |
| 112 | token->req = NULL; | |
| 113 | ||
| 15884 | 114 | purple_notify_error(purple_connection_get_account(gc), |
| 12007 | 115 | _("Token Error"), |
| 116 | _("Unable to fetch the token.\n"), NULL); | |
| 117 | return; | |
| 118 | } | |
| 119 | ||
| 120 | if (token->req->state != GG_STATE_DONE) { | |
| 15884 | 121 | purple_input_remove(token->inpa); |
| 122 | token->inpa = purple_input_add(token->req->fd, | |
| 12007 | 123 | (token->req->check == 1) |
| 15884 | 124 | ? PURPLE_INPUT_WRITE |
| 125 | : PURPLE_INPUT_READ, | |
| 12007 | 126 | ggp_async_token_handler, gc); |
| 127 | return; | |
| 128 | } | |
| 129 | ||
| 130 | if (!(t = token->req->data) || !token->req->body) { | |
| 15884 | 131 | purple_debug_error("gg", "token error (2): %d\n", token->req->error); |
| 132 | purple_input_remove(token->inpa); | |
| 12007 | 133 | gg_token_free(token->req); |
| 134 | token->req = NULL; | |
| 135 | ||
| 15884 | 136 | purple_notify_error(purple_connection_get_account(gc), |
| 12007 | 137 | _("Token Error"), |
| 138 | _("Unable to fetch the token.\n"), NULL); | |
| 139 | return; | |
| 140 | } | |
| 141 | ||
| 15884 | 142 | purple_input_remove(token->inpa); |
| 12007 | 143 | |
| 144 | token->id = g_strdup(t->tokenid); | |
| 145 | token->size = token->req->body_size; | |
| 146 | token->data = g_new0(char, token->size); | |
| 147 | memcpy(token->data, token->req->body, token->size); | |
| 148 | ||
| 15884 | 149 | purple_debug_info("gg", "TOKEN! tokenid = %s; size = %d\n", |
| 12007 | 150 | token->id, token->size); |
| 151 | ||
| 152 | gg_token_free(token->req); | |
| 153 | token->req = NULL; | |
| 154 | token->inpa = 0; | |
| 155 | ||
| 156 | cb = token->cb; | |
| 157 | token->cb = NULL; | |
| 158 | cb(gc); | |
| 159 | } | |
| 160 | /* }}} */ | |
| 161 | ||
| 162 | /* | |
| 163 | */ | |
| 15884 | 164 | /* static void ggp_token_request(PurpleConnection *gc, GGPTokenCallback cb) {{{ */ |
| 165 | static void ggp_token_request(PurpleConnection *gc, GGPTokenCallback cb) | |
| 12007 | 166 | { |
| 15884 | 167 | PurpleAccount *account; |
| 12007 | 168 | struct gg_http *req; |
| 13515 | 169 | GGPInfo *info; |
| 170 | ||
| 15884 | 171 | account = purple_connection_get_account(gc); |
| 13515 | 172 | |
| 173 | if (ggp_setup_proxy(account) == -1) | |
| 174 | return; | |
| 175 | ||
| 176 | info = gc->proto_data; | |
| 12007 | 177 | |
| 178 | if ((req = gg_token(1)) == NULL) { | |
| 15884 | 179 | purple_notify_error(account, |
| 12007 | 180 | _("Token Error"), |
| 181 | _("Unable to fetch the token.\n"), NULL); | |
| 182 | return; | |
| 183 | } | |
| 184 | ||
| 185 | info->token = g_new(GGPToken, 1); | |
| 186 | info->token->cb = cb; | |
| 187 | ||
| 188 | info->token->req = req; | |
| 15884 | 189 | info->token->inpa = purple_input_add(req->fd, PURPLE_INPUT_READ, |
| 12007 | 190 | ggp_async_token_handler, gc); |
| 191 | } | |
| 192 | /* }}} */ | |
| 193 | ||
| 194 | /* ---------------------------------------------------------------------- */ | |
| 195 | ||
| 11360 | 196 | /** |
| 197 | * Request buddylist from the server. | |
| 198 | * Buddylist is received in the ggp_callback_recv(). | |
| 199 | * | |
| 200 | * @param Current action handler. | |
| 201 | */ | |
| 15884 | 202 | /* static void ggp_action_buddylist_get(PurplePluginAction *action) {{{ */ |
| 203 | static void ggp_action_buddylist_get(PurplePluginAction *action) | |
| 11360 | 204 | { |
| 15884 | 205 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 206 | GGPInfo *info = gc->proto_data; |
| 207 | ||
| 15884 | 208 | purple_debug_info("gg", "Downloading...\n"); |
| 11360 | 209 | |
| 210 | gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | |
| 211 | } | |
| 212 | /* }}} */ | |
| 213 | ||
| 214 | /** | |
| 215 | * Upload the buddylist to the server. | |
| 216 | * | |
| 217 | * @param action Current action handler. | |
| 218 | */ | |
| 15884 | 219 | /* static void ggp_action_buddylist_put(PurplePluginAction *action) {{{ */ |
| 220 | static void ggp_action_buddylist_put(PurplePluginAction *action) | |
| 11360 | 221 | { |
| 15884 | 222 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 223 | GGPInfo *info = gc->proto_data; |
| 224 | ||
| 15884 | 225 | char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc)); |
| 11360 | 226 | |
| 15884 | 227 | purple_debug_info("gg", "Uploading...\n"); |
| 11360 | 228 | |
| 229 | if (buddylist == NULL) | |
| 230 | return; | |
| 231 | ||
| 232 | gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist); | |
| 233 | g_free(buddylist); | |
| 234 | } | |
| 235 | /* }}} */ | |
| 236 | ||
| 237 | /** | |
| 238 | * Delete buddylist from the server. | |
| 239 | * | |
| 240 | * @param action Current action handler. | |
| 241 | */ | |
| 15884 | 242 | /* static void ggp_action_buddylist_delete(PurplePluginAction *action) {{{ */ |
| 243 | static void ggp_action_buddylist_delete(PurplePluginAction *action) | |
| 11360 | 244 | { |
| 15884 | 245 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 246 | GGPInfo *info = gc->proto_data; |
| 247 | ||
| 15884 | 248 | purple_debug_info("gg", "Deleting...\n"); |
| 11360 | 249 | |
| 250 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 251 | } | |
| 252 | /* }}} */ | |
| 253 | ||
| 254 | /* | |
| 255 | */ | |
|
17455
18680c136815
Fix a small memory leak and eliminate a double-free.
Richard Laager <rlaager@pidgin.im>
parents:
16746
diff
changeset
|
256 | /* static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *file) {{{ */ |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
257 | static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *filename) |
| 11360 | 258 | { |
| 15884 | 259 | PurpleAccount *account = purple_connection_get_account(gc); |
| 11360 | 260 | |
| 261 | char *buddylist = ggp_buddylist_dump(account); | |
| 262 | ||
| 15884 | 263 | purple_debug_info("gg", "Saving...\n"); |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
264 | purple_debug_info("gg", "file = %s\n", filename); |
| 11360 | 265 | |
| 266 | if (buddylist == NULL) { | |
| 15884 | 267 | purple_notify_info(account, _("Save Buddylist..."), |
| 12007 | 268 | _("Your buddylist is empty, nothing was written to the file."), |
| 269 | NULL); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
270 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
271 | } |
| 2393 | 272 | |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
273 | if(purple_util_write_data_to_file_absolute(filename, buddylist, -1)) { |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
274 | purple_notify_info(account, _("Save Buddylist..."), |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
275 | _("Buddylist saved successfully!"), NULL); |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
276 | } else { |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
277 | gchar *primary = g_strdup_printf( |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
278 | _("Couldn't write buddy list for %s to %s"), |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
279 | purple_account_get_username(account), filename); |
|
21497
8187406f2043
May as well use an existing string as the title for the error notification.
Will Thompson <resiak@pidgin.im>
parents:
21496
diff
changeset
|
280 | purple_notify_error(account, _("Save Buddylist..."), |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
281 | primary, NULL); |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
282 | g_free(primary); |
| 11360 | 283 | } |
| 284 | ||
| 285 | g_free(buddylist); | |
| 286 | } | |
| 287 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
288 | |
| 11360 | 289 | /* |
| 290 | */ | |
| 15884 | 291 | /* static void ggp_callback_buddylist_load_ok(PurpleConnection *gc, gchar *file) {{{ */ |
| 292 | static void ggp_callback_buddylist_load_ok(PurpleConnection *gc, gchar *file) | |
| 11360 | 293 | { |
| 15884 | 294 | PurpleAccount *account = purple_connection_get_account(gc); |
| 12007 | 295 | GError *error = NULL; |
| 296 | char *buddylist = NULL; | |
| 297 | gsize length; | |
| 11360 | 298 | |
| 15884 | 299 | purple_debug_info("gg", "file_name = %s\n", file); |
| 11360 | 300 | |
| 12007 | 301 | if (!g_file_get_contents(file, &buddylist, &length, &error)) { |
| 15884 | 302 | purple_notify_error(account, |
| 12007 | 303 | _("Couldn't load buddylist"), |
| 304 | _("Couldn't load buddylist"), | |
| 305 | error->message); | |
| 306 | ||
| 15884 | 307 | purple_debug_error("gg", |
| 12007 | 308 | "Couldn't load buddylist. file = %s; error = %s\n", |
| 309 | file, error->message); | |
| 310 | ||
| 311 | g_error_free(error); | |
| 312 | ||
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
313 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
314 | } |
| 11360 | 315 | |
| 316 | ggp_buddylist_load(gc, buddylist); | |
| 317 | g_free(buddylist); | |
| 318 | ||
| 15884 | 319 | purple_notify_info(account, |
| 11360 | 320 | _("Load Buddylist..."), |
| 321 | _("Buddylist loaded successfully!"), NULL); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
322 | } |
| 11360 | 323 | /* }}} */ |
| 324 | ||
| 325 | /* | |
| 326 | */ | |
| 15884 | 327 | /* static void ggp_action_buddylist_save(PurplePluginAction *action) {{{ */ |
| 328 | static void ggp_action_buddylist_save(PurplePluginAction *action) | |
| 11360 | 329 | { |
| 15884 | 330 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 331 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
332 | purple_request_file(action, _("Save buddylist..."), NULL, TRUE, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
333 | G_CALLBACK(ggp_callback_buddylist_save_ok), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
334 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
335 | gc); |
| 11360 | 336 | } |
| 337 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
338 | |
| 11360 | 339 | /* |
| 340 | */ | |
| 15884 | 341 | /* static void ggp_action_buddylist_load(PurplePluginAction *action) {{{ */ |
| 342 | static void ggp_action_buddylist_load(PurplePluginAction *action) | |
| 11360 | 343 | { |
| 15884 | 344 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 345 | |
|
23379
536450c4f7f9
Mark a string as translatable in prpl-gg. References #5693.
Will Thompson <resiak@pidgin.im>
parents:
23325
diff
changeset
|
346 | purple_request_file(action, _("Load buddylist from file..."), NULL, |
|
536450c4f7f9
Mark a string as translatable in prpl-gg. References #5693.
Will Thompson <resiak@pidgin.im>
parents:
23325
diff
changeset
|
347 | FALSE, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
348 | G_CALLBACK(ggp_callback_buddylist_load_ok), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
349 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
350 | gc); |
| 11360 | 351 | } |
| 352 | /* }}} */ | |
| 353 | ||
| 354 | /* | |
| 355 | */ | |
| 15884 | 356 | /* static void ggp_callback_register_account_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 357 | static void ggp_callback_register_account_ok(PurpleConnection *gc, | |
| 358 | PurpleRequestFields *fields) | |
| 11414 | 359 | { |
| 15884 | 360 | PurpleAccount *account; |
| 11414 | 361 | GGPInfo *info = gc->proto_data; |
| 362 | struct gg_http *h = NULL; | |
| 363 | struct gg_pubdir *s; | |
| 364 | uin_t uin; | |
| 365 | gchar *email, *p1, *p2, *t; | |
| 12007 | 366 | GGPToken *token = info->token; |
| 11414 | 367 | |
| 15884 | 368 | email = charset_convert(purple_request_fields_get_string(fields, "email"), |
| 11414 | 369 | "UTF-8", "CP1250"); |
| 15884 | 370 | p1 = charset_convert(purple_request_fields_get_string(fields, "password1"), |
| 11414 | 371 | "UTF-8", "CP1250"); |
| 15884 | 372 | p2 = charset_convert(purple_request_fields_get_string(fields, "password2"), |
| 11414 | 373 | "UTF-8", "CP1250"); |
| 15884 | 374 | t = charset_convert(purple_request_fields_get_string(fields, "token"), |
| 11414 | 375 | "UTF-8", "CP1250"); |
| 376 | ||
| 15884 | 377 | account = purple_connection_get_account(gc); |
| 11414 | 378 | |
| 379 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 380 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 21279 | 381 | purple_connection_error_reason (gc, |
| 382 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
383 | _("Fill in the registration fields.")); |
| 11414 | 384 | goto exit_err; |
| 385 | } | |
| 386 | ||
| 387 | if (g_utf8_collate(p1, p2) != 0) { | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
388 | purple_connection_error_reason (gc, |
| 21279 | 389 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
390 | _("Passwords do not match.")); |
| 11414 | 391 | goto exit_err; |
| 392 | } | |
| 393 | ||
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22546
diff
changeset
|
394 | purple_debug_info("gg", "register_account_ok: token_id = %s; t = %s\n", |
| 12007 | 395 | token->id, t); |
| 396 | h = gg_register3(email, p1, token->id, t, 0); | |
| 11414 | 397 | if (h == NULL || !(s = h->data) || !s->success) { |
| 21279 | 398 | purple_connection_error_reason (gc, |
| 399 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
400 | _("Unable to register new account. Error occurred.\n")); |
| 11414 | 401 | goto exit_err; |
| 402 | } | |
| 403 | ||
| 404 | uin = s->uin; | |
| 15884 | 405 | purple_debug_info("gg", "registered uin: %d\n", uin); |
| 11414 | 406 | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
407 | g_free(t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
408 | t = g_strdup_printf("%u", uin); |
| 15884 | 409 | purple_account_set_username(account, t); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
410 | /* Save the password if remembering passwords for the account */ |
| 15884 | 411 | purple_account_set_password(account, p1); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
412 | |
| 15884 | 413 | purple_notify_info(NULL, _("New Gadu-Gadu Account Registered"), |
| 11414 | 414 | _("Registration completed successfully!"), NULL); |
| 415 | ||
|
18997
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
416 | if(account->registration_cb) |
|
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
417 | (account->registration_cb)(account, TRUE, account->registration_cb_user_data); |
| 12007 | 418 | /* TODO: the currently open Accounts Window will not be updated withthe |
| 419 | * new username and etc, we need to somehow have it refresh at this | |
| 420 | * point | |
| 421 | */ | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
422 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
423 | /* Need to disconnect or actually log in. For now, we disconnect. */ |
| 15884 | 424 | purple_connection_destroy(gc); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
425 | |
| 11414 | 426 | exit_err: |
|
18997
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
427 | if(account->registration_cb) |
|
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
428 | (account->registration_cb)(account, FALSE, account->registration_cb_user_data); |
|
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
429 | |
| 11414 | 430 | gg_register_free(h); |
| 431 | g_free(email); | |
| 432 | g_free(p1); | |
| 433 | g_free(p2); | |
| 434 | g_free(t); | |
| 12007 | 435 | g_free(token->id); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
436 | g_free(token); |
| 11414 | 437 | } |
| 438 | /* }}} */ | |
| 439 | ||
| 11565 | 440 | /* |
| 441 | */ | |
| 15884 | 442 | /* static void ggp_callback_register_account_cancel(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 443 | static void ggp_callback_register_account_cancel(PurpleConnection *gc, | |
| 444 | PurpleRequestFields *fields) | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
445 | { |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
446 | GGPInfo *info = gc->proto_data; |
| 12007 | 447 | GGPToken *token = info->token; |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
448 | |
| 15884 | 449 | purple_connection_destroy(gc); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
450 | |
| 12007 | 451 | g_free(token->id); |
| 452 | g_free(token->data); | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
453 | g_free(token); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
454 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
455 | } |
| 11565 | 456 | /* }}} */ |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
457 | |
| 12007 | 458 | /* |
| 459 | */ | |
| 15884 | 460 | /* static void ggp_register_user_dialog(PurpleConnection *gc) {{{ */ |
| 461 | static void ggp_register_user_dialog(PurpleConnection *gc) | |
| 12007 | 462 | { |
| 15884 | 463 | PurpleAccount *account; |
| 464 | PurpleRequestFields *fields; | |
| 465 | PurpleRequestFieldGroup *group; | |
| 466 | PurpleRequestField *field; | |
| 12007 | 467 | |
| 468 | GGPInfo *info = gc->proto_data; | |
| 469 | GGPToken *token = info->token; | |
| 470 | ||
| 471 | ||
| 15884 | 472 | account = purple_connection_get_account(gc); |
| 12007 | 473 | |
| 15884 | 474 | fields = purple_request_fields_new(); |
| 475 | group = purple_request_field_group_new(NULL); | |
| 476 | purple_request_fields_add_group(fields, group); | |
| 12007 | 477 | |
| 15884 | 478 | field = purple_request_field_string_new("email", |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23295
diff
changeset
|
479 | _("Email"), "", FALSE); |
| 15884 | 480 | purple_request_field_string_set_masked(field, FALSE); |
| 481 | purple_request_field_group_add_field(group, field); | |
| 12007 | 482 | |
| 15884 | 483 | field = purple_request_field_string_new("password1", |
| 12007 | 484 | _("Password"), "", FALSE); |
| 15884 | 485 | purple_request_field_string_set_masked(field, TRUE); |
| 486 | purple_request_field_group_add_field(group, field); | |
| 12007 | 487 | |
| 15884 | 488 | field = purple_request_field_string_new("password2", |
| 12007 | 489 | _("Password (retype)"), "", FALSE); |
| 15884 | 490 | purple_request_field_string_set_masked(field, TRUE); |
| 491 | purple_request_field_group_add_field(group, field); | |
| 12007 | 492 | |
| 15884 | 493 | field = purple_request_field_string_new("token", |
| 12007 | 494 | _("Enter current token"), "", FALSE); |
| 15884 | 495 | purple_request_field_string_set_masked(field, FALSE); |
| 496 | purple_request_field_group_add_field(group, field); | |
| 12007 | 497 | |
| 498 | /* original size: 60x24 */ | |
| 15884 | 499 | field = purple_request_field_image_new("token_img", |
| 12007 | 500 | _("Current token"), token->data, token->size); |
| 15884 | 501 | purple_request_field_group_add_field(group, field); |
| 12007 | 502 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
503 | purple_request_fields(account, |
| 12007 | 504 | _("Register New Gadu-Gadu Account"), |
| 505 | _("Register New Gadu-Gadu Account"), | |
| 506 | _("Please, fill in the following fields"), | |
| 507 | fields, | |
| 508 | _("OK"), G_CALLBACK(ggp_callback_register_account_ok), | |
| 509 | _("Cancel"), G_CALLBACK(ggp_callback_register_account_cancel), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
510 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
511 | gc); |
| 12007 | 512 | } |
| 513 | /* }}} */ | |
| 514 | ||
| 11414 | 515 | /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ |
| 516 | ||
| 517 | /* | |
| 518 | */ | |
| 15884 | 519 | /* static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 520 | static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) | |
| 11414 | 521 | { |
| 522 | GGPInfo *info = gc->proto_data; | |
| 13641 | 523 | GGPSearchForm *form = user_data; |
| 524 | guint32 seq; | |
| 11414 | 525 | |
| 13641 | 526 | g_free(form->offset); |
| 527 | form->offset = g_strdup(form->last_uin); | |
| 528 | ||
| 529 | ggp_search_remove(info->searches, form->seq); | |
| 530 | ||
| 531 | seq = ggp_search_start(gc, form); | |
| 532 | ggp_search_add(info->searches, seq, form); | |
| 11414 | 533 | } |
| 534 | /* }}} */ | |
| 535 | ||
| 536 | /* | |
| 537 | */ | |
| 15884 | 538 | /* static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 539 | static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data) | |
| 11414 | 540 | { |
| 15884 | 541 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
| 12007 | 542 | g_list_nth_data(row, 0), NULL, NULL); |
| 11414 | 543 | } |
| 544 | /* }}} */ | |
| 545 | ||
| 546 | /* | |
| 547 | */ | |
| 15884 | 548 | /* static void ggp_callback_im(PurpleConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 549 | static void ggp_callback_im(PurpleConnection *gc, GList *row, gpointer user_data) | |
| 13642 | 550 | { |
| 15884 | 551 | PurpleAccount *account; |
| 552 | PurpleConversation *conv; | |
| 13642 | 553 | char *name; |
| 554 | ||
| 15884 | 555 | account = purple_connection_get_account(gc); |
| 13642 | 556 | |
| 557 | name = g_list_nth_data(row, 0); | |
| 15884 | 558 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name); |
| 559 | purple_conversation_present(conv); | |
| 13642 | 560 | } |
| 561 | /* }}} */ | |
| 562 | ||
| 563 | /* | |
| 564 | */ | |
| 15884 | 565 | /* static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 566 | static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) | |
| 11414 | 567 | { |
| 568 | GGPInfo *info = gc->proto_data; | |
| 569 | GGPSearchForm *form; | |
| 13641 | 570 | guint32 seq; |
| 11414 | 571 | |
| 13641 | 572 | form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL); |
| 11414 | 573 | |
| 13641 | 574 | form->user_data = info; |
| 12007 | 575 | form->lastname = charset_convert( |
| 15884 | 576 | purple_request_fields_get_string(fields, "lastname"), |
| 12007 | 577 | "UTF-8", "CP1250"); |
| 578 | form->firstname = charset_convert( | |
| 15884 | 579 | purple_request_fields_get_string(fields, "firstname"), |
| 12007 | 580 | "UTF-8", "CP1250"); |
| 581 | form->nickname = charset_convert( | |
| 15884 | 582 | purple_request_fields_get_string(fields, "nickname"), |
| 12007 | 583 | "UTF-8", "CP1250"); |
| 584 | form->city = charset_convert( | |
| 15884 | 585 | purple_request_fields_get_string(fields, "city"), |
| 12007 | 586 | "UTF-8", "CP1250"); |
| 587 | form->birthyear = charset_convert( | |
| 15884 | 588 | purple_request_fields_get_string(fields, "year"), |
| 12007 | 589 | "UTF-8", "CP1250"); |
| 11414 | 590 | |
| 15884 | 591 | switch (purple_request_fields_get_choice(fields, "gender")) { |
| 11414 | 592 | case 1: |
| 593 | form->gender = g_strdup(GG_PUBDIR50_GENDER_MALE); | |
| 594 | break; | |
| 595 | case 2: | |
| 596 | form->gender = g_strdup(GG_PUBDIR50_GENDER_FEMALE); | |
| 597 | break; | |
| 598 | default: | |
| 599 | form->gender = NULL; | |
| 600 | break; | |
| 601 | } | |
| 602 | ||
| 15884 | 603 | form->active = purple_request_fields_get_bool(fields, "active") |
| 11414 | 604 | ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL; |
| 605 | ||
| 606 | form->offset = g_strdup("0"); | |
| 607 | ||
| 13641 | 608 | seq = ggp_search_start(gc, form); |
| 609 | ggp_search_add(info->searches, seq, form); | |
| 11414 | 610 | } |
| 611 | /* }}} */ | |
| 612 | ||
| 613 | /* | |
| 614 | */ | |
| 15884 | 615 | /* static void ggp_find_buddies(PurplePluginAction *action) {{{ */ |
| 616 | static void ggp_find_buddies(PurplePluginAction *action) | |
| 11414 | 617 | { |
| 15884 | 618 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11414 | 619 | |
| 15884 | 620 | PurpleRequestFields *fields; |
| 621 | PurpleRequestFieldGroup *group; | |
| 622 | PurpleRequestField *field; | |
| 11414 | 623 | |
| 15884 | 624 | fields = purple_request_fields_new(); |
| 625 | group = purple_request_field_group_new(NULL); | |
| 626 | purple_request_fields_add_group(fields, group); | |
| 11414 | 627 | |
| 15884 | 628 | field = purple_request_field_string_new("lastname", |
| 12007 | 629 | _("Last name"), NULL, FALSE); |
| 15884 | 630 | purple_request_field_string_set_masked(field, FALSE); |
| 631 | purple_request_field_group_add_field(group, field); | |
| 11414 | 632 | |
| 15884 | 633 | field = purple_request_field_string_new("firstname", |
| 12007 | 634 | _("First name"), NULL, FALSE); |
| 15884 | 635 | purple_request_field_string_set_masked(field, FALSE); |
| 636 | purple_request_field_group_add_field(group, field); | |
| 11414 | 637 | |
| 15884 | 638 | field = purple_request_field_string_new("nickname", |
| 12007 | 639 | _("Nickname"), NULL, FALSE); |
| 15884 | 640 | purple_request_field_string_set_masked(field, FALSE); |
| 641 | purple_request_field_group_add_field(group, field); | |
| 11414 | 642 | |
| 15884 | 643 | field = purple_request_field_string_new("city", |
| 12007 | 644 | _("City"), NULL, FALSE); |
| 15884 | 645 | purple_request_field_string_set_masked(field, FALSE); |
| 646 | purple_request_field_group_add_field(group, field); | |
| 11414 | 647 | |
| 15884 | 648 | field = purple_request_field_string_new("year", |
| 12007 | 649 | _("Year of birth"), NULL, FALSE); |
| 15884 | 650 | purple_request_field_group_add_field(group, field); |
| 11414 | 651 | |
| 15884 | 652 | field = purple_request_field_choice_new("gender", _("Gender"), 0); |
| 653 | purple_request_field_choice_add(field, _("Male or female")); | |
| 654 | purple_request_field_choice_add(field, _("Male")); | |
| 655 | purple_request_field_choice_add(field, _("Female")); | |
| 656 | purple_request_field_group_add_field(group, field); | |
| 11414 | 657 | |
| 15884 | 658 | field = purple_request_field_bool_new("active", |
| 12007 | 659 | _("Only online"), FALSE); |
| 15884 | 660 | purple_request_field_group_add_field(group, field); |
| 11414 | 661 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
662 | purple_request_fields(gc, |
| 11414 | 663 | _("Find buddies"), |
| 664 | _("Find buddies"), | |
| 665 | _("Please, enter your search criteria below"), | |
| 666 | fields, | |
| 667 | _("OK"), G_CALLBACK(ggp_callback_find_buddies), | |
| 668 | _("Cancel"), NULL, | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
669 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
670 | gc); |
| 11414 | 671 | } |
| 672 | /* }}} */ | |
| 673 | ||
| 674 | /* ----- CHANGE PASSWORD ------------------------------------------------ */ | |
| 675 | ||
| 676 | /* | |
| 677 | */ | |
| 15884 | 678 | /* static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 679 | static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) | |
| 2393 | 680 | { |
| 15884 | 681 | PurpleAccount *account; |
| 11360 | 682 | GGPInfo *info = gc->proto_data; |
| 683 | struct gg_http *h; | |
| 684 | gchar *cur, *p1, *p2, *t; | |
| 685 | ||
| 12007 | 686 | cur = charset_convert( |
| 15884 | 687 | purple_request_fields_get_string(fields, "password_cur"), |
| 12007 | 688 | "UTF-8", "CP1250"); |
| 689 | p1 = charset_convert( | |
| 15884 | 690 | purple_request_fields_get_string(fields, "password1"), |
| 12007 | 691 | "UTF-8", "CP1250"); |
| 692 | p2 = charset_convert( | |
| 15884 | 693 | purple_request_fields_get_string(fields, "password2"), |
| 12007 | 694 | "UTF-8", "CP1250"); |
| 695 | t = charset_convert( | |
| 15884 | 696 | purple_request_fields_get_string(fields, "token"), |
| 12007 | 697 | "UTF-8", "CP1250"); |
| 11360 | 698 | |
| 15884 | 699 | account = purple_connection_get_account(gc); |
| 11360 | 700 | |
| 701 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 702 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 15884 | 703 | purple_notify_error(account, NULL, _("Fill in the fields."), NULL); |
| 11360 | 704 | goto exit_err; |
| 705 | } | |
| 706 | ||
| 707 | if (g_utf8_collate(p1, p2) != 0) { | |
| 15884 | 708 | purple_notify_error(account, NULL, |
| 12007 | 709 | _("New passwords do not match."), NULL); |
| 11360 | 710 | goto exit_err; |
| 711 | } | |
| 2393 | 712 | |
| 15884 | 713 | if (g_utf8_collate(cur, purple_account_get_password(account)) != 0) { |
| 714 | purple_notify_error(account, NULL, | |
| 11360 | 715 | _("Your current password is different from the one that you specified."), |
| 716 | NULL); | |
| 717 | goto exit_err; | |
| 718 | } | |
| 719 | ||
| 15884 | 720 | purple_debug_info("gg", "Changing password\n"); |
| 11360 | 721 | |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23295
diff
changeset
|
722 | /* XXX: this email should be a pref... */ |
| 11360 | 723 | h = gg_change_passwd4(ggp_get_uin(account), |
| 15884 | 724 | "user@example.net", purple_account_get_password(account), |
| 12007 | 725 | p1, info->token->id, t, 0); |
| 2393 | 726 | |
| 11360 | 727 | if (h == NULL) { |
| 15884 | 728 | purple_notify_error(account, NULL, |
| 14754 | 729 | _("Unable to change password. Error occurred.\n"), |
| 11360 | 730 | NULL); |
| 731 | goto exit_err; | |
| 732 | } | |
| 733 | ||
| 15884 | 734 | purple_account_set_password(account, p1); |
| 11360 | 735 | |
| 736 | gg_change_passwd_free(h); | |
| 737 | ||
| 15884 | 738 | purple_notify_info(account, _("Change password for the Gadu-Gadu account"), |
| 11360 | 739 | _("Password was changed successfully!"), NULL); |
| 740 | ||
| 741 | exit_err: | |
| 742 | g_free(cur); | |
| 743 | g_free(p1); | |
| 744 | g_free(p2); | |
| 745 | g_free(t); | |
| 12007 | 746 | g_free(info->token->id); |
| 747 | g_free(info->token->data); | |
| 748 | g_free(info->token); | |
| 749 | } | |
| 750 | /* }}} */ | |
| 751 | ||
| 752 | /* | |
| 753 | */ | |
| 15884 | 754 | /* static void ggp_change_passwd_dialog(PurpleConnection *gc) {{{ */ |
| 755 | static void ggp_change_passwd_dialog(PurpleConnection *gc) | |
| 12007 | 756 | { |
| 15884 | 757 | PurpleRequestFields *fields; |
| 758 | PurpleRequestFieldGroup *group; | |
| 759 | PurpleRequestField *field; | |
| 12007 | 760 | |
| 761 | GGPInfo *info = gc->proto_data; | |
| 762 | GGPToken *token = info->token; | |
| 763 | ||
| 764 | char *msg; | |
| 765 | ||
| 766 | ||
| 15884 | 767 | fields = purple_request_fields_new(); |
| 768 | group = purple_request_field_group_new(NULL); | |
| 769 | purple_request_fields_add_group(fields, group); | |
| 12007 | 770 | |
| 15884 | 771 | field = purple_request_field_string_new("password_cur", |
| 12007 | 772 | _("Current password"), "", FALSE); |
| 15884 | 773 | purple_request_field_string_set_masked(field, TRUE); |
| 774 | purple_request_field_group_add_field(group, field); | |
| 12007 | 775 | |
| 15884 | 776 | field = purple_request_field_string_new("password1", |
| 12007 | 777 | _("Password"), "", FALSE); |
| 15884 | 778 | purple_request_field_string_set_masked(field, TRUE); |
| 779 | purple_request_field_group_add_field(group, field); | |
| 12007 | 780 | |
| 15884 | 781 | field = purple_request_field_string_new("password2", |
| 12007 | 782 | _("Password (retype)"), "", FALSE); |
| 15884 | 783 | purple_request_field_string_set_masked(field, TRUE); |
| 784 | purple_request_field_group_add_field(group, field); | |
| 12007 | 785 | |
| 15884 | 786 | field = purple_request_field_string_new("token", |
| 12007 | 787 | _("Enter current token"), "", FALSE); |
| 15884 | 788 | purple_request_field_string_set_masked(field, FALSE); |
| 789 | purple_request_field_group_add_field(group, field); | |
| 12007 | 790 | |
| 791 | /* original size: 60x24 */ | |
| 15884 | 792 | field = purple_request_field_image_new("token_img", |
| 12007 | 793 | _("Current token"), token->data, token->size); |
| 15884 | 794 | purple_request_field_group_add_field(group, field); |
| 12007 | 795 | |
| 796 | msg = g_strdup_printf("%s %d", | |
| 797 | _("Please, enter your current password and your new password for UIN: "), | |
| 15884 | 798 | ggp_get_uin(purple_connection_get_account(gc))); |
| 12007 | 799 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
800 | purple_request_fields(gc, |
| 12007 | 801 | _("Change Gadu-Gadu Password"), |
| 802 | _("Change Gadu-Gadu Password"), | |
| 803 | msg, | |
| 804 | fields, _("OK"), G_CALLBACK(ggp_callback_change_passwd_ok), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
805 | _("Cancel"), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
806 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
807 | gc); |
| 12007 | 808 | |
| 809 | g_free(msg); | |
| 11360 | 810 | } |
| 811 | /* }}} */ | |
| 2393 | 812 | |
| 11360 | 813 | /* |
| 814 | */ | |
| 15884 | 815 | /* static void ggp_change_passwd(PurplePluginAction *action) {{{ */ |
| 816 | static void ggp_change_passwd(PurplePluginAction *action) | |
| 11360 | 817 | { |
| 15884 | 818 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 819 | |
| 12007 | 820 | ggp_token_request(gc, ggp_change_passwd_dialog); |
| 11360 | 821 | } |
| 822 | /* }}} */ | |
| 823 | ||
| 11414 | 824 | /* ----- CONFERENCES ---------------------------------------------------- */ |
| 825 | ||
| 11394 | 826 | /* |
| 827 | */ | |
| 15884 | 828 | /* static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 829 | static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields) | |
| 11394 | 830 | { |
| 831 | GGPInfo *info = gc->proto_data; | |
| 15884 | 832 | PurpleRequestField *field; |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
833 | /* TODO: sel may be null. */ |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17455
diff
changeset
|
834 | GList *sel; |
| 11394 | 835 | |
| 15884 | 836 | field = purple_request_fields_get_field(fields, "name"); |
| 837 | sel = purple_request_field_list_get_selected(field); | |
| 11394 | 838 | |
| 12961 | 839 | ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy); |
| 840 | info->tmp_buddy = 0; | |
| 11394 | 841 | } |
| 842 | /* }}} */ | |
| 843 | ||
| 844 | /* | |
| 845 | */ | |
| 15884 | 846 | /* static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored) {{{ */ |
| 847 | static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored) | |
| 11394 | 848 | { |
| 15884 | 849 | PurpleBuddy *buddy; |
| 850 | PurpleConnection *gc; | |
| 11394 | 851 | GGPInfo *info; |
| 852 | ||
| 15884 | 853 | PurpleRequestFields *fields; |
| 854 | PurpleRequestFieldGroup *group; | |
| 855 | PurpleRequestField *field; | |
| 11394 | 856 | |
| 857 | GList *l; | |
| 858 | gchar *msg; | |
| 859 | ||
| 15884 | 860 | buddy = (PurpleBuddy *)node; |
| 861 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11394 | 862 | info = gc->proto_data; |
| 863 | ||
| 12961 | 864 | /* TODO: It tmp_buddy != 0 then stop! */ |
| 15884 | 865 | info->tmp_buddy = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11394 | 866 | |
| 15884 | 867 | fields = purple_request_fields_new(); |
| 868 | group = purple_request_field_group_new(NULL); | |
| 869 | purple_request_fields_add_group(fields, group); | |
| 11394 | 870 | |
| 15884 | 871 | field = purple_request_field_list_new("name", "Chat name"); |
| 11394 | 872 | for (l = info->chats; l != NULL; l = l->next) { |
| 873 | GGPChat *chat = l->data; | |
| 15884 | 874 | purple_request_field_list_add(field, g_strdup(chat->name), |
| 12007 | 875 | g_strdup(chat->name)); |
| 11394 | 876 | } |
| 15884 | 877 | purple_request_field_group_add_field(group, field); |
| 11394 | 878 | |
| 12007 | 879 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
| 15884 | 880 | purple_buddy_get_alias(buddy)); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
881 | purple_request_fields(gc, |
| 11394 | 882 | _("Add to chat..."), |
| 883 | _("Add to chat..."), | |
| 884 | msg, | |
| 885 | fields, | |
| 886 | _("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
887 | _("Cancel"), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
888 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
889 | gc); |
| 11394 | 890 | g_free(msg); |
| 891 | } | |
| 892 | /* }}} */ | |
| 893 | ||
| 11414 | 894 | /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
| 895 | ||
| 11410 | 896 | /* |
| 897 | */ | |
| 15884 | 898 | /* static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored) {{{ */ |
| 899 | static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored) | |
| 11410 | 900 | { |
| 15884 | 901 | PurpleConnection *gc; |
| 902 | PurpleBuddy *buddy; | |
| 11410 | 903 | GGPInfo *info; |
| 904 | uin_t uin; | |
| 905 | ||
| 15884 | 906 | buddy = (PurpleBuddy *)node; |
| 907 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11410 | 908 | info = gc->proto_data; |
| 909 | ||
| 15884 | 910 | uin = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11410 | 911 | |
| 15884 | 912 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 913 | purple_blist_node_set_bool(node, "blocked", FALSE); | |
| 11410 | 914 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); |
| 915 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 15884 | 916 | purple_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); |
| 11410 | 917 | } else { |
| 15884 | 918 | purple_blist_node_set_bool(node, "blocked", TRUE); |
| 11410 | 919 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); |
| 920 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 15884 | 921 | purple_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); |
| 11410 | 922 | } |
| 923 | } | |
| 924 | /* }}} */ | |
| 925 | ||
| 11360 | 926 | /* ---------------------------------------------------------------------- */ |
| 11414 | 927 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 928 | /* ---------------------------------------------------------------------- */ | |
| 929 | ||
|
23381
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
930 | /* Prototypes */ |
| 15884 | 931 | static void ggp_set_status(PurpleAccount *account, PurpleStatus *status); |
|
23381
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
932 | static int ggp_to_gg_status(PurpleStatus *status, char **msg); |
|
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
933 | |
| 12964 | 934 | |
| 11414 | 935 | /** |
| 936 | * Handle change of the status of the buddy. | |
| 937 | * | |
| 15884 | 938 | * @param gc PurpleConnection |
| 11414 | 939 | * @param uin UIN of the buddy. |
| 940 | * @param status ID of the status. | |
| 941 | * @param descr Description. | |
| 942 | */ | |
| 15884 | 943 | /* static void ggp_generic_status_handler(PurpleConnection *gc, uin_t uin, int status, const char *descr) {{{ */ |
| 944 | static void ggp_generic_status_handler(PurpleConnection *gc, uin_t uin, | |
| 12007 | 945 | int status, const char *descr) |
| 11414 | 946 | { |
| 947 | gchar *from; | |
| 948 | const char *st; | |
| 949 | gchar *msg; | |
| 950 | ||
| 951 | from = g_strdup_printf("%ld", (unsigned long int)uin); | |
| 952 | switch (status) { | |
| 953 | case GG_STATUS_NOT_AVAIL: | |
| 954 | case GG_STATUS_NOT_AVAIL_DESCR: | |
| 955 | st = "offline"; | |
| 956 | break; | |
| 957 | case GG_STATUS_AVAIL: | |
| 958 | case GG_STATUS_AVAIL_DESCR: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
959 | st = "available"; |
| 11414 | 960 | break; |
| 961 | case GG_STATUS_BUSY: | |
| 962 | case GG_STATUS_BUSY_DESCR: | |
|
12718
34152a2d35fc
[gaim-migrate @ 15062]
Richard Laager <rlaager@pidgin.im>
parents:
12717
diff
changeset
|
963 | st = "away"; |
| 11414 | 964 | break; |
| 965 | case GG_STATUS_BLOCKED: | |
| 966 | /* user is blocking us.... */ | |
| 967 | st = "blocked"; | |
| 968 | break; | |
| 969 | default: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
970 | st = "available"; |
| 15884 | 971 | purple_debug_info("gg", |
| 12007 | 972 | "GG_EVENT_NOTIFY: Unknown status: %d\n", status); |
| 11414 | 973 | break; |
| 974 | } | |
| 975 | ||
| 15884 | 976 | purple_debug_info("gg", "st = %s\n", st); |
| 11414 | 977 | msg = charset_convert(descr, "CP1250", "UTF-8"); |
| 15884 | 978 | purple_prpl_got_user_status(purple_connection_get_account(gc), |
| 12007 | 979 | from, st, "message", msg, NULL); |
| 11414 | 980 | g_free(from); |
| 981 | g_free(msg); | |
| 982 | } | |
| 983 | /* }}} */ | |
| 984 | ||
| 12007 | 985 | /* |
| 986 | */ | |
| 13643 | 987 | /* static void ggp_sr_close_cb(gpointer user_data) {{{ */ |
| 988 | static void ggp_sr_close_cb(gpointer user_data) | |
| 12220 | 989 | { |
| 13643 | 990 | GGPSearchForm *form = user_data; |
| 13641 | 991 | GGPInfo *info = form->user_data; |
| 12220 | 992 | |
| 13641 | 993 | ggp_search_remove(info->searches, form->seq); |
| 994 | ggp_search_form_destroy(form); | |
| 12220 | 995 | } |
| 996 | /* }}} */ | |
| 997 | ||
| 13645 | 998 | /** |
| 999 | * Translate a status' ID to a more user-friendly name. | |
| 1000 | * | |
| 1001 | * @param id The ID of the status. | |
| 1002 | * | |
| 1003 | * @return The user-friendly name of the status. | |
| 1004 | */ | |
| 1005 | /* static const char *ggp_status_by_id(unsigned int id) {{{ */ | |
| 1006 | static const char *ggp_status_by_id(unsigned int id) | |
| 1007 | { | |
| 1008 | const char *st; | |
| 1009 | ||
| 15884 | 1010 | purple_debug_info("gg", "ggp_status_by_id: %d\n", id); |
| 13645 | 1011 | switch (id) { |
| 1012 | case GG_STATUS_NOT_AVAIL: | |
| 1013 | st = _("Offline"); | |
| 1014 | break; | |
| 1015 | case GG_STATUS_AVAIL: | |
| 1016 | st = _("Available"); | |
| 1017 | break; | |
| 1018 | case GG_STATUS_BUSY: | |
| 1019 | st = _("Away"); | |
| 1020 | break; | |
| 1021 | default: | |
| 1022 | st = _("Unknown"); | |
| 1023 | break; | |
| 1024 | } | |
| 1025 | ||
| 1026 | return st; | |
| 1027 | } | |
| 1028 | /* }}} */ | |
| 1029 | ||
| 12220 | 1030 | /* |
| 1031 | */ | |
| 15884 | 1032 | /* static void ggp_pubdir_handle_info(PurpleConnection *gc, gg_pubdir50_t req, GGPSearchForm *form) {{{ */ |
| 1033 | static void ggp_pubdir_handle_info(PurpleConnection *gc, gg_pubdir50_t req, | |
| 13643 | 1034 | GGPSearchForm *form) |
| 12007 | 1035 | { |
| 15884 | 1036 | PurpleNotifyUserInfo *user_info; |
| 1037 | PurpleBuddy *buddy; | |
| 13643 | 1038 | char *val, *who; |
| 1039 | ||
| 15884 | 1040 | user_info = purple_notify_user_info_new(); |
| 13643 | 1041 | |
| 1042 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_STATUS); | |
| 13645 | 1043 | /* XXX: Use of ggp_str_to_uin() is an ugly hack! */ |
| 15884 | 1044 | purple_notify_user_info_add_pair(user_info, _("Status"), ggp_status_by_id(ggp_str_to_uin(val))); |
| 13643 | 1045 | g_free(val); |
| 1046 | ||
| 1047 | who = ggp_search_get_result(req, 0, GG_PUBDIR50_UIN); | |
| 15884 | 1048 | purple_notify_user_info_add_pair(user_info, _("UIN"), who); |
| 13643 | 1049 | |
| 1050 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_FIRSTNAME); | |
| 15884 | 1051 | purple_notify_user_info_add_pair(user_info, _("First Name"), val); |
| 13643 | 1052 | g_free(val); |
| 1053 | ||
| 1054 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_NICKNAME); | |
| 15884 | 1055 | purple_notify_user_info_add_pair(user_info, _("Nickname"), val); |
| 13643 | 1056 | g_free(val); |
| 1057 | ||
| 1058 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_CITY); | |
| 15884 | 1059 | purple_notify_user_info_add_pair(user_info, _("City"), val); |
| 13643 | 1060 | g_free(val); |
| 1061 | ||
| 1062 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_BIRTHYEAR); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1063 | if (strncmp(val, "0", 1)) { |
| 15884 | 1064 | purple_notify_user_info_add_pair(user_info, _("Birth Year"), val); |
| 13643 | 1065 | } |
| 1066 | g_free(val); | |
| 1067 | ||
| 15294 | 1068 | /* |
| 1069 | * Include a status message, if exists and buddy is in the blist. | |
| 1070 | */ | |
| 15884 | 1071 | buddy = purple_find_buddy(purple_connection_get_account(gc), who); |
| 15294 | 1072 | if (NULL != buddy) { |
| 15884 | 1073 | PurpleStatus *status; |
| 15294 | 1074 | const char *msg; |
| 1075 | char *text; | |
| 13643 | 1076 | |
| 15884 | 1077 | status = purple_presence_get_active_status(purple_buddy_get_presence(buddy)); |
| 1078 | msg = purple_status_get_attr_string(status, "message"); | |
| 13643 | 1079 | |
| 15294 | 1080 | if (msg != NULL) { |
| 1081 | text = g_markup_escape_text(msg, -1); | |
| 15884 | 1082 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15294 | 1083 | g_free(text); |
| 1084 | } | |
| 1085 | } | |
| 1086 | ||
|
18629
9e78088bfc46
Close temporary Get Info window when showing the real one. Fixes #1720.
Bartosz Oler <bartosz@pidgin.im>
parents:
18190
diff
changeset
|
1087 | purple_notify_userinfo(gc, who, user_info, ggp_sr_close_cb, form); |
| 15294 | 1088 | g_free(who); |
| 15884 | 1089 | purple_notify_user_info_destroy(user_info); |
| 13643 | 1090 | } |
| 1091 | /* }}} */ | |
| 1092 | ||
| 1093 | /* | |
| 1094 | */ | |
| 15884 | 1095 | /* static void ggp_pubdir_handle_full(PurpleConnection *gc, gg_pubdir50_t req, GGPSearchForm *form) {{{ */ |
| 1096 | static void ggp_pubdir_handle_full(PurpleConnection *gc, gg_pubdir50_t req, | |
| 13643 | 1097 | GGPSearchForm *form) |
| 1098 | { | |
| 15884 | 1099 | PurpleNotifySearchResults *results; |
| 1100 | PurpleNotifySearchColumn *column; | |
| 13643 | 1101 | int res_count; |
| 12007 | 1102 | int start; |
| 1103 | int i; | |
| 13641 | 1104 | |
| 13643 | 1105 | g_return_if_fail(form != NULL); |
| 12007 | 1106 | |
| 1107 | res_count = gg_pubdir50_count(req); | |
| 13643 | 1108 | res_count = (res_count > PUBDIR_RESULTS_MAX) ? PUBDIR_RESULTS_MAX : res_count; |
| 12007 | 1109 | |
| 15884 | 1110 | results = purple_notify_searchresults_new(); |
| 12007 | 1111 | |
| 12257 | 1112 | if (results == NULL) { |
| 15884 | 1113 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
| 12257 | 1114 | "Unable to display the search results.\n"); |
| 15884 | 1115 | purple_notify_error(gc, NULL, |
| 12257 | 1116 | _("Unable to display the search results."), |
| 1117 | NULL); | |
| 13641 | 1118 | ggp_sr_close_cb(form); |
| 12257 | 1119 | return; |
| 1120 | } | |
| 1121 | ||
| 15884 | 1122 | column = purple_notify_searchresults_column_new(_("UIN")); |
| 1123 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1124 | |
| 15884 | 1125 | column = purple_notify_searchresults_column_new(_("First Name")); |
| 1126 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1127 | |
| 15884 | 1128 | column = purple_notify_searchresults_column_new(_("Nickname")); |
| 1129 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1130 | |
| 15884 | 1131 | column = purple_notify_searchresults_column_new(_("City")); |
| 1132 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1133 | |
| 15884 | 1134 | column = purple_notify_searchresults_column_new(_("Birth Year")); |
| 1135 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1136 | |
| 15884 | 1137 | purple_debug_info("gg", "Going with %d entries\n", res_count); |
| 12007 | 1138 | |
| 1139 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 15884 | 1140 | purple_debug_info("gg", "start = %d\n", start); |
| 12007 | 1141 | |
| 1142 | for (i = 0; i < res_count; i++) { | |
| 1143 | GList *row = NULL; | |
| 1144 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 1145 | ||
| 1146 | /* TODO: Status will be displayed as an icon. */ | |
| 1147 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 1148 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1149 | GG_PUBDIR50_UIN)); | |
| 1150 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1151 | GG_PUBDIR50_FIRSTNAME)); | |
| 1152 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1153 | GG_PUBDIR50_NICKNAME)); | |
| 1154 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1155 | GG_PUBDIR50_CITY)); | |
| 1156 | row = g_list_append(row, | |
| 1157 | (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 1158 | ||
| 15884 | 1159 | purple_notify_searchresults_row_add(results, row); |
| 12007 | 1160 | |
| 1161 | if (i == res_count - 1) { | |
| 13641 | 1162 | g_free(form->last_uin); |
| 1163 | form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN); | |
| 12007 | 1164 | } |
| 1165 | } | |
| 1166 | ||
| 15884 | 1167 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_CONTINUE, |
| 12007 | 1168 | ggp_callback_show_next); |
| 15884 | 1169 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 12007 | 1170 | ggp_callback_add_buddy); |
| 15884 | 1171 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_IM, |
| 13642 | 1172 | ggp_callback_im); |
| 13643 | 1173 | |
| 13641 | 1174 | if (form->window == NULL) { |
| 15884 | 1175 | void *h = purple_notify_searchresults(gc, |
| 12007 | 1176 | _("Gadu-Gadu Public Directory"), |
| 12220 | 1177 | _("Search results"), NULL, results, |
| 15884 | 1178 | (PurpleNotifyCloseCallback)ggp_sr_close_cb, |
| 13641 | 1179 | form); |
| 12257 | 1180 | |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1181 | if (h == NULL) { |
| 15884 | 1182 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1183 | "Unable to display the search results.\n"); |
| 15884 | 1184 | purple_notify_error(gc, NULL, |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1185 | _("Unable to display the search results."), |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1186 | NULL); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1187 | return; |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1188 | } |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1189 | |
| 13641 | 1190 | form->window = h; |
| 12007 | 1191 | } else { |
| 15884 | 1192 | purple_notify_searchresults_new_rows(gc, results, form->window); |
| 12007 | 1193 | } |
| 1194 | } | |
| 1195 | /* }}} */ | |
| 1196 | ||
| 13643 | 1197 | /* |
| 1198 | */ | |
| 15884 | 1199 | /* static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) {{{ */ |
| 1200 | static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) | |
| 13643 | 1201 | { |
| 1202 | GGPInfo *info = gc->proto_data; | |
| 1203 | GGPSearchForm *form; | |
| 1204 | int res_count; | |
| 1205 | guint32 seq; | |
| 1206 | ||
| 1207 | seq = gg_pubdir50_seq(req); | |
| 1208 | form = ggp_search_get(info->searches, seq); | |
| 1209 | ||
| 1210 | /* | |
| 1211 | * this can happen when user will request more results | |
| 1212 | * and close the results window before they arrive. | |
| 1213 | */ | |
| 1214 | g_return_if_fail(form != NULL); | |
| 1215 | ||
| 1216 | res_count = gg_pubdir50_count(req); | |
| 1217 | if (res_count < 1) { | |
| 15884 | 1218 | purple_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); |
| 1219 | purple_notify_error(gc, NULL, | |
| 13643 | 1220 | _("No matching users found"), |
| 1221 | _("There are no users matching your search criteria.")); | |
| 1222 | ggp_sr_close_cb(form); | |
| 1223 | return; | |
| 1224 | } | |
| 1225 | ||
| 1226 | switch (form->search_type) { | |
| 1227 | case GGP_SEARCH_TYPE_INFO: | |
| 1228 | ggp_pubdir_handle_info(gc, req, form); | |
| 1229 | break; | |
| 1230 | case GGP_SEARCH_TYPE_FULL: | |
| 1231 | ggp_pubdir_handle_full(gc, req, form); | |
| 1232 | break; | |
| 1233 | default: | |
| 15884 | 1234 | purple_debug_warning("gg", "Unknown search_type!\n"); |
| 13643 | 1235 | break; |
| 1236 | } | |
| 1237 | } | |
| 1238 | /* }}} */ | |
| 1239 | ||
| 11414 | 1240 | /** |
| 1241 | * Dispatch a message received from a buddy. | |
| 1242 | * | |
| 15884 | 1243 | * @param gc PurpleConnection. |
| 11414 | 1244 | * @param ev Gadu-Gadu event structure. |
| 1245 | */ | |
| 15884 | 1246 | /* static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) {{{ */ |
| 1247 | static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) | |
| 11414 | 1248 | { |
| 1249 | GGPInfo *info = gc->proto_data; | |
| 15884 | 1250 | PurpleConversation *conv; |
| 11414 | 1251 | gchar *from; |
| 1252 | gchar *msg; | |
| 1253 | gchar *tmp; | |
| 1254 | ||
| 1255 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 1256 | ||
| 12961 | 1257 | tmp = charset_convert((const char *)ev->event.msg.message, |
| 12007 | 1258 | "CP1250", "UTF-8"); |
| 15884 | 1259 | purple_str_strip_char(tmp, '\r'); |
| 12961 | 1260 | msg = g_markup_escape_text(tmp, -1); |
| 1261 | g_free(tmp); | |
| 11414 | 1262 | |
| 15884 | 1263 | purple_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", |
| 12961 | 1264 | from, msg, ev->event.msg.msgclass, |
| 12007 | 1265 | ev->event.msg.recipients_count); |
| 11414 | 1266 | |
| 1267 | if (ev->event.msg.recipients_count == 0) { | |
| 12961 | 1268 | serv_got_im(gc, from, msg, 0, ev->event.msg.time); |
| 11414 | 1269 | } else { |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1270 | const char *chat_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1271 | int chat_id; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1272 | char *buddy_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1273 | |
| 11414 | 1274 | chat_name = ggp_confer_find_by_participants(gc, |
| 12007 | 1275 | ev->event.msg.recipients, |
| 1276 | ev->event.msg.recipients_count); | |
| 12961 | 1277 | |
| 11414 | 1278 | if (chat_name == NULL) { |
| 1279 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 1280 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 12007 | 1281 | |
| 1282 | ggp_confer_participants_add_uin(gc, chat_name, | |
| 1283 | ev->event.msg.sender); | |
| 1284 | ||
| 1285 | ggp_confer_participants_add(gc, chat_name, | |
| 1286 | ev->event.msg.recipients, | |
| 1287 | ev->event.msg.recipients_count); | |
| 11414 | 1288 | } |
| 1289 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 15884 | 1290 | chat_id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1291 | |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1292 | buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1293 | serv_got_chat_in(gc, chat_id, buddy_name, |
| 15884 | 1294 | PURPLE_MESSAGE_RECV, msg, ev->event.msg.time); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1295 | g_free(buddy_name); |
| 11414 | 1296 | } |
| 12961 | 1297 | g_free(msg); |
| 11414 | 1298 | g_free(from); |
| 1299 | } | |
| 1300 | /* }}} */ | |
| 1301 | ||
| 1302 | /* | |
| 1303 | */ | |
| 15884 | 1304 | /* static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */ |
| 1305 | static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) | |
| 11414 | 1306 | { |
| 15884 | 1307 | PurpleConnection *gc = _gc; |
| 11414 | 1308 | GGPInfo *info = gc->proto_data; |
| 1309 | struct gg_event *ev; | |
| 1310 | int i; | |
| 1311 | ||
| 1312 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1313 | purple_debug_error("gg", |
| 12007 | 1314 | "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); |
| 21279 | 1315 | purple_connection_error_reason (gc, |
| 1316 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1317 | _("Unable to read socket")); |
| 11414 | 1318 | return; |
| 1319 | } | |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
21630
diff
changeset
|
1320 | gc->last_received = time(NULL); |
| 11414 | 1321 | switch (ev->type) { |
| 1322 | case GG_EVENT_NONE: | |
| 1323 | /* Nothing happened. */ | |
| 1324 | break; | |
| 1325 | case GG_EVENT_MSG: | |
| 1326 | ggp_recv_message_handler(gc, ev); | |
| 1327 | break; | |
| 1328 | case GG_EVENT_ACK: | |
| 15884 | 1329 | purple_debug_info("gg", |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22546
diff
changeset
|
1330 | "message sent to: %u, delivery status=%d, seq=%d\n", |
| 12007 | 1331 | ev->event.ack.recipient, ev->event.ack.status, |
| 1332 | ev->event.ack.seq); | |
| 11414 | 1333 | break; |
| 1334 | case GG_EVENT_NOTIFY: | |
| 1335 | case GG_EVENT_NOTIFY_DESCR: | |
| 1336 | { | |
| 1337 | struct gg_notify_reply *n; | |
| 1338 | char *descr; | |
| 1339 | ||
| 15884 | 1340 | purple_debug_info("gg", "notify_pre: (%d) status: %d\n", |
| 11414 | 1341 | ev->event.notify->uin, |
| 1342 | ev->event.notify->status); | |
| 1343 | ||
| 1344 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 1345 | : ev->event.notify_descr.notify; | |
| 1346 | ||
| 1347 | for (; n->uin; n++) { | |
| 1348 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 12007 | 1349 | : ev->event.notify_descr.descr; |
| 1350 | ||
| 15884 | 1351 | purple_debug_info("gg", |
| 12007 | 1352 | "notify: (%d) status: %d; descr: %s\n", |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1353 | n->uin, n->status, descr ? descr : "(null)"); |
| 11414 | 1354 | |
| 1355 | ggp_generic_status_handler(gc, | |
| 12007 | 1356 | n->uin, n->status, descr); |
| 11414 | 1357 | } |
| 1358 | } | |
| 1359 | break; | |
| 1360 | case GG_EVENT_NOTIFY60: | |
| 15884 | 1361 | purple_debug_info("gg", |
| 12007 | 1362 | "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", |
| 1363 | ev->event.notify60->uin, ev->event.notify60->status, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1364 | ev->event.notify60->version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1365 | ev->event.notify60->descr ? ev->event.notify60->descr : "(null)"); |
| 11414 | 1366 | |
| 1367 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 15884 | 1368 | purple_debug_info("gg", |
| 12007 | 1369 | "notify60: (%d) status=%d; version=%d; descr=%s\n", |
| 1370 | ev->event.notify60[i].uin, | |
| 1371 | ev->event.notify60[i].status, | |
| 1372 | ev->event.notify60[i].version, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1373 | ev->event.notify60[i].descr ? ev->event.notify60[i].descr : "(null)"); |
| 11414 | 1374 | |
| 12007 | 1375 | ggp_generic_status_handler(gc, ev->event.notify60[i].uin, |
| 1376 | ev->event.notify60[i].status, | |
| 1377 | ev->event.notify60[i].descr); | |
| 11414 | 1378 | } |
| 1379 | break; | |
| 1380 | case GG_EVENT_STATUS: | |
| 15884 | 1381 | purple_debug_info("gg", "status: (%d) status=%d; descr=%s\n", |
| 11414 | 1382 | ev->event.status.uin, ev->event.status.status, |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1383 | ev->event.status.descr ? ev->event.status.descr : "(null)"); |
| 11414 | 1384 | |
| 12007 | 1385 | ggp_generic_status_handler(gc, ev->event.status.uin, |
| 1386 | ev->event.status.status, ev->event.status.descr); | |
| 11414 | 1387 | break; |
| 1388 | case GG_EVENT_STATUS60: | |
| 15884 | 1389 | purple_debug_info("gg", |
| 12007 | 1390 | "status60: (%d) status=%d; version=%d; descr=%s\n", |
| 1391 | ev->event.status60.uin, ev->event.status60.status, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1392 | ev->event.status60.version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1393 | ev->event.status60.descr ? ev->event.status60.descr : "(null)"); |
| 11414 | 1394 | |
| 12007 | 1395 | ggp_generic_status_handler(gc, ev->event.status60.uin, |
| 1396 | ev->event.status60.status, ev->event.status60.descr); | |
| 11414 | 1397 | break; |
| 1398 | case GG_EVENT_USERLIST: | |
| 1399 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 15884 | 1400 | purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); |
| 1401 | purple_notify_info(gc, NULL, | |
| 12220 | 1402 | _("Buddy list downloaded"), |
| 1403 | _("Your buddy list was downloaded from the server.")); | |
| 11414 | 1404 | if (ev->event.userlist.reply != NULL) { |
| 12007 | 1405 | ggp_buddylist_load(gc, ev->event.userlist.reply); |
| 11414 | 1406 | } |
| 1407 | } else { | |
| 15884 | 1408 | purple_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
| 1409 | purple_notify_info(gc, NULL, | |
| 12220 | 1410 | _("Buddy list uploaded"), |
| 1411 | _("Your buddy list was stored on the server.")); | |
| 11414 | 1412 | } |
| 1413 | break; | |
| 1414 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 12007 | 1415 | ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
| 1416 | break; | |
| 1417 | default: | |
| 15884 | 1418 | purple_debug_error("gg", |
| 12007 | 1419 | "unsupported event type=%d\n", ev->type); |
| 1420 | break; | |
| 1421 | } | |
| 11414 | 1422 | |
| 12007 | 1423 | gg_free_event(ev); |
| 1424 | } | |
| 1425 | /* }}} */ | |
| 11414 | 1426 | |
| 12007 | 1427 | /* |
| 1428 | */ | |
| 15884 | 1429 | /* static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */ |
| 1430 | static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) | |
| 12007 | 1431 | { |
| 15884 | 1432 | PurpleConnection *gc = _gc; |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1433 | GGPInfo *info; |
| 12007 | 1434 | struct gg_event *ev; |
| 11414 | 1435 | |
| 15884 | 1436 | g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1437 | |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1438 | info = gc->proto_data; |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1439 | |
| 15884 | 1440 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
| 12007 | 1441 | info->session->check, info->session->state); |
| 11414 | 1442 | |
| 12007 | 1443 | switch (info->session->state) { |
| 1444 | case GG_STATE_RESOLVING: | |
| 15884 | 1445 | purple_debug_info("gg", "GG_STATE_RESOLVING\n"); |
| 12007 | 1446 | break; |
| 1447 | case GG_STATE_CONNECTING_HUB: | |
| 15884 | 1448 | purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); |
| 12007 | 1449 | break; |
| 1450 | case GG_STATE_READING_DATA: | |
| 15884 | 1451 | purple_debug_info("gg", "GG_STATE_READING_DATA\n"); |
| 12007 | 1452 | break; |
| 1453 | case GG_STATE_CONNECTING_GG: | |
| 15884 | 1454 | purple_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); |
| 12007 | 1455 | break; |
| 1456 | case GG_STATE_READING_KEY: | |
| 15884 | 1457 | purple_debug_info("gg", "GG_STATE_READING_KEY\n"); |
| 12007 | 1458 | break; |
| 1459 | case GG_STATE_READING_REPLY: | |
| 15884 | 1460 | purple_debug_info("gg", "GG_STATE_READING_REPLY\n"); |
| 11414 | 1461 | break; |
| 1462 | default: | |
| 15884 | 1463 | purple_debug_error("gg", "unknown state = %d\n", |
| 12007 | 1464 | info->session->state); |
| 1465 | break; | |
| 1466 | } | |
| 1467 | ||
| 1468 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1469 | purple_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); |
| 21279 | 1470 | purple_connection_error_reason (gc, |
| 1471 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1472 | _("Unable to read socket")); |
| 12007 | 1473 | return; |
| 1474 | } | |
| 15884 | 1475 | purple_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); |
| 1476 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | |
| 12007 | 1477 | info->session->check, info->session->state); |
| 1478 | ||
| 15884 | 1479 | purple_input_remove(gc->inpa); |
| 12007 | 1480 | |
| 1481 | /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ | |
| 15884 | 1482 | gc->inpa = purple_input_add(info->session->fd, |
| 1483 | (info->session->check == 1) ? PURPLE_INPUT_WRITE | |
| 1484 | : PURPLE_INPUT_READ, | |
| 12007 | 1485 | ggp_async_login_handler, gc); |
| 1486 | ||
| 1487 | switch (ev->type) { | |
| 1488 | case GG_EVENT_NONE: | |
| 1489 | /* Nothing happened. */ | |
| 15884 | 1490 | purple_debug_info("gg", "GG_EVENT_NONE\n"); |
| 12007 | 1491 | break; |
| 1492 | case GG_EVENT_CONN_SUCCESS: | |
| 12964 | 1493 | { |
| 15884 | 1494 | PurpleAccount *account; |
| 1495 | PurplePresence *presence; | |
| 1496 | PurpleStatus *status; | |
| 12964 | 1497 | |
| 15884 | 1498 | purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); |
| 1499 | purple_input_remove(gc->inpa); | |
| 1500 | gc->inpa = purple_input_add(info->session->fd, | |
| 1501 | PURPLE_INPUT_READ, | |
| 12964 | 1502 | ggp_callback_recv, gc); |
| 12007 | 1503 | |
| 12964 | 1504 | /* gg_change_status(info->session, GG_STATUS_AVAIL); */ |
| 1505 | ||
| 15884 | 1506 | account = purple_connection_get_account(gc); |
| 1507 | presence = purple_account_get_presence(account); | |
| 1508 | status = purple_presence_get_active_status(presence); | |
| 12964 | 1509 | |
| 1510 | ggp_set_status(account, status); | |
| 15884 | 1511 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
| 12964 | 1512 | ggp_buddylist_send(gc); |
| 1513 | } | |
| 12007 | 1514 | break; |
| 1515 | case GG_EVENT_CONN_FAILED: | |
| 15884 | 1516 | purple_input_remove(gc->inpa); |
| 12007 | 1517 | gc->inpa = 0; |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1518 | purple_connection_error_reason (gc, |
| 21279 | 1519 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1520 | _("Connection failed.")); |
| 12007 | 1521 | break; |
| 1522 | default: | |
| 15884 | 1523 | purple_debug_error("gg", "strange event: %d\n", ev->type); |
| 11414 | 1524 | break; |
| 1525 | } | |
| 1526 | ||
| 1527 | gg_free_event(ev); | |
| 1528 | } | |
| 1529 | /* }}} */ | |
| 1530 | ||
| 1531 | /* ---------------------------------------------------------------------- */ | |
| 15884 | 1532 | /* ----- PurplePluginProtocolInfo ----------------------------------------- */ |
| 11360 | 1533 | /* ---------------------------------------------------------------------- */ |
| 1534 | ||
| 15884 | 1535 | /* static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) {{{ */ |
| 1536 | static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) | |
| 11360 | 1537 | { |
| 1538 | return "gadu-gadu"; | |
| 1539 | } | |
| 1540 | /* }}} */ | |
| 1541 | ||
| 15884 | 1542 | /* static char *ggp_status_text(PurpleBuddy *b) {{{ */ |
| 1543 | static char *ggp_status_text(PurpleBuddy *b) | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1544 | { |
| 15884 | 1545 | PurpleStatus *status; |
| 11360 | 1546 | const char *msg; |
| 1547 | char *text; | |
| 1548 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1549 | |
| 15884 | 1550 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1551 | |
| 15884 | 1552 | msg = purple_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1553 | |
| 11360 | 1554 | if (msg != NULL) { |
| 15884 | 1555 | tmp = purple_markup_strip_html(msg); |
| 11360 | 1556 | text = g_markup_escape_text(tmp, -1); |
| 1557 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1558 | |
| 11360 | 1559 | return text; |
| 1560 | } else { | |
| 15884 | 1561 | tmp = purple_utf8_salvage(purple_status_get_name(status)); |
| 11360 | 1562 | text = g_markup_escape_text(tmp, -1); |
| 1563 | g_free(tmp); | |
| 1564 | ||
| 1565 | return text; | |
| 8997 | 1566 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1567 | } |
| 11360 | 1568 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1569 | |
| 15884 | 1570 | /* static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) {{{ */ |
| 1571 | static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) | |
| 11360 | 1572 | { |
| 15884 | 1573 | PurpleStatus *status; |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1574 | char *text, *tmp; |
| 11360 | 1575 | const char *msg, *name; |
| 1576 | ||
| 15005 | 1577 | g_return_if_fail(b != NULL); |
| 1578 | ||
| 15884 | 1579 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
| 1580 | msg = purple_status_get_attr_string(status, "message"); | |
| 1581 | name = purple_status_get_name(status); | |
| 11360 | 1582 | |
| 1583 | if (msg != NULL) { | |
| 13455 | 1584 | text = g_markup_escape_text(msg, -1); |
| 15884 | 1585 | if (PURPLE_BUDDY_IS_ONLINE(b)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1586 | tmp = g_strdup_printf("%s: %s", name, text); |
| 15884 | 1587 | purple_notify_user_info_add_pair(user_info, _("Status"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1588 | g_free(tmp); |
| 15196 | 1589 | } else { |
| 15884 | 1590 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15196 | 1591 | } |
| 11360 | 1592 | g_free(text); |
| 15227 | 1593 | /* We don't want to duplicate 'Status: Offline'. */ |
| 15884 | 1594 | } else if (PURPLE_BUDDY_IS_ONLINE(b)) { |
| 1595 | purple_notify_user_info_add_pair(user_info, _("Status"), name); | |
| 11360 | 1596 | } |
| 1597 | } | |
| 1598 | /* }}} */ | |
| 1599 | ||
| 15884 | 1600 | /* static GList *ggp_status_types(PurpleAccount *account) {{{ */ |
| 1601 | static GList *ggp_status_types(PurpleAccount *account) | |
| 11360 | 1602 | { |
| 15884 | 1603 | PurpleStatusType *type; |
| 11360 | 1604 | GList *types = NULL; |
| 1605 | ||
| 15884 | 1606 | type = purple_status_type_new_with_attrs( |
| 1607 | PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1608 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1609 | NULL); |
| 11360 | 1610 | types = g_list_append(types, type); |
| 1611 | ||
| 1612 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1613 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1614 | * work. It's not used and not needed to show status of buddies. |
| 1615 | */ | |
| 15884 | 1616 | type = purple_status_type_new_with_attrs( |
| 1617 | PURPLE_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1618 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1619 | NULL); |
| 11360 | 1620 | types = g_list_append(types, type); |
| 1621 | ||
| 15884 | 1622 | type = purple_status_type_new_with_attrs( |
| 1623 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1624 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1625 | NULL); |
| 11360 | 1626 | types = g_list_append(types, type); |
| 1627 | ||
| 12964 | 1628 | /* |
| 1629 | * This status is necessary to display guys who are blocking *us*. | |
| 1630 | */ | |
| 15884 | 1631 | type = purple_status_type_new_with_attrs( |
| 1632 | PURPLE_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, | |
| 1633 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); | |
| 11360 | 1634 | types = g_list_append(types, type); |
| 1635 | ||
| 15884 | 1636 | type = purple_status_type_new_with_attrs( |
| 1637 | PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1638 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1639 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1640 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1641 | |
| 11360 | 1642 | return types; |
| 1643 | } | |
| 1644 | /* }}} */ | |
| 1645 | ||
| 15884 | 1646 | /* static GList *ggp_blist_node_menu(PurpleBlistNode *node) {{{ */ |
| 1647 | static GList *ggp_blist_node_menu(PurpleBlistNode *node) | |
| 2393 | 1648 | { |
| 15884 | 1649 | PurpleMenuAction *act; |
| 2393 | 1650 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1651 | |
| 15884 | 1652 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
| 11360 | 1653 | return NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1654 | |
| 15884 | 1655 | act = purple_menu_action_new(_("Add to chat"), |
| 1656 | PURPLE_CALLBACK(ggp_bmenu_add_to_chat), | |
| 12919 | 1657 | NULL, NULL); |
| 11410 | 1658 | m = g_list_append(m, act); |
| 1659 | ||
| 12641 | 1660 | /* Using a blist node boolean here is also wrong. |
| 1661 | * Once the Block and Unblock actions are added to the core, | |
| 1662 | * this will have to go. -- rlaager */ | |
| 15884 | 1663 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 1664 | act = purple_menu_action_new(_("Unblock"), | |
| 1665 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1666 | NULL, NULL); |
| 12007 | 1667 | } else { |
| 15884 | 1668 | act = purple_menu_action_new(_("Block"), |
| 1669 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1670 | NULL, NULL); |
| 12007 | 1671 | } |
| 11394 | 1672 | m = g_list_append(m, act); |
| 2393 | 1673 | |
| 1674 | return m; | |
| 1675 | } | |
| 11360 | 1676 | /* }}} */ |
| 2393 | 1677 | |
| 15884 | 1678 | /* static GList *ggp_chat_info(PurpleConnection *gc) {{{ */ |
| 1679 | static GList *ggp_chat_info(PurpleConnection *gc) | |
| 11394 | 1680 | { |
| 1681 | GList *m = NULL; | |
| 1682 | struct proto_chat_entry *pce; | |
| 1683 | ||
| 1684 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1685 | pce->label = _("Chat _name:"); | |
| 1686 | pce->identifier = "name"; | |
| 1687 | pce->required = TRUE; | |
| 1688 | m = g_list_append(m, pce); | |
| 1689 | ||
| 1690 | return m; | |
| 1691 | } | |
| 1692 | /* }}} */ | |
| 1693 | ||
| 15884 | 1694 | /* static void ggp_login(PurpleAccount *account) {{{ */ |
| 1695 | static void ggp_login(PurpleAccount *account) | |
| 2393 | 1696 | { |
| 15884 | 1697 | PurpleConnection *gc; |
| 13515 | 1698 | struct gg_login_params *glp; |
| 1699 | GGPInfo *info; | |
| 1700 | ||
| 1701 | if (ggp_setup_proxy(account) == -1) | |
| 1702 | return; | |
| 1703 | ||
| 15884 | 1704 | gc = purple_account_get_connection(account); |
| 13515 | 1705 | glp = g_new0(struct gg_login_params, 1); |
| 1706 | info = g_new0(GGPInfo, 1); | |
| 11360 | 1707 | |
| 12007 | 1708 | /* Probably this should be moved to *_new() function. */ |
| 11360 | 1709 | info->session = NULL; |
| 11394 | 1710 | info->chats = NULL; |
| 1711 | info->chats_count = 0; | |
| 12007 | 1712 | info->token = NULL; |
| 13641 | 1713 | info->searches = ggp_search_new(); |
| 11360 | 1714 | |
| 1715 | gc->proto_data = info; | |
| 1716 | ||
| 1717 | glp->uin = ggp_get_uin(account); | |
| 15884 | 1718 | glp->password = (char *)purple_account_get_password(account); |
| 11360 | 1719 | |
| 12007 | 1720 | glp->async = 1; |
| 11360 | 1721 | glp->status = GG_STATUS_AVAIL; |
| 1722 | glp->tls = 0; | |
| 1723 | ||
| 1724 | info->session = gg_login(glp); | |
| 1725 | if (info->session == NULL) { | |
| 21279 | 1726 | purple_connection_error_reason (gc, |
| 1727 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1728 | _("Connection failed.")); |
| 11360 | 1729 | g_free(glp); |
| 1730 | return; | |
| 1731 | } | |
| 15884 | 1732 | gc->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ, |
| 12007 | 1733 | ggp_async_login_handler, gc); |
| 11360 | 1734 | } |
| 1735 | /* }}} */ | |
| 1736 | ||
| 15884 | 1737 | /* static void ggp_close(PurpleConnection *gc) {{{ */ |
| 1738 | static void ggp_close(PurpleConnection *gc) | |
| 11360 | 1739 | { |
| 8997 | 1740 | |
| 11360 | 1741 | if (gc == NULL) { |
| 15884 | 1742 | purple_debug_info("gg", "gc == NULL\n"); |
| 11360 | 1743 | return; |
| 1744 | } | |
| 1745 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1746 | if (gc->proto_data) { |
| 15884 | 1747 | PurpleAccount *account = purple_connection_get_account(gc); |
| 1748 | PurpleStatus *status; | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1749 | GGPInfo *info = gc->proto_data; |
| 12964 | 1750 | |
| 15884 | 1751 | status = purple_account_get_active_status(account); |
| 12964 | 1752 | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1753 | if (info->session != NULL) { |
| 12964 | 1754 | ggp_set_status(account, status); |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1755 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1756 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1757 | } |
| 13641 | 1758 | |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1759 | /* Immediately close any notifications on this handle since that process depends |
|
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1760 | * upon the contents of info->searches, which we are about to destroy. |
|
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1761 | */ |
| 15884 | 1762 | purple_notify_close_with_handle(gc); |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1763 | |
| 13641 | 1764 | ggp_search_destroy(info->searches); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1765 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1766 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1767 | } |
| 11360 | 1768 | |
| 1769 | if (gc->inpa > 0) | |
| 15884 | 1770 | purple_input_remove(gc->inpa); |
| 11360 | 1771 | |
| 1772 | ggp_buddylist_offline(gc); | |
| 2393 | 1773 | |
| 15884 | 1774 | purple_debug_info("gg", "Connection closed.\n"); |
| 11360 | 1775 | } |
| 1776 | /* }}} */ | |
| 1777 | ||
| 15884 | 1778 | /* static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, PurpleMessageFlags flags) {{{ */ |
| 1779 | static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, | |
| 1780 | PurpleMessageFlags flags) | |
| 11360 | 1781 | { |
| 1782 | GGPInfo *info = gc->proto_data; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1783 | char *tmp, *plain; |
| 15287 | 1784 | int ret = 0; |
| 11360 | 1785 | |
| 15287 | 1786 | if (strlen(msg) == 0) { |
| 1787 | return 0; | |
| 1788 | } | |
| 1789 | ||
| 15884 | 1790 | purple_debug_info("gg", "ggp_send_im: msg = %s\n", msg); |
| 1791 | plain = purple_unescape_html(msg); | |
| 15287 | 1792 | tmp = charset_convert(plain, "UTF-8", "CP1250"); |
| 11360 | 1793 | |
| 15287 | 1794 | if (NULL == tmp || strlen(tmp) == 0) { |
| 1795 | ret = 0; | |
| 1796 | } else if (strlen(tmp) > GG_MSG_MAXSIZE) { | |
| 1797 | ret = -E2BIG; | |
| 1798 | } else if (gg_send_message(info->session, GG_CLASS_CHAT, | |
| 1799 | ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { | |
| 1800 | ret = -1; | |
| 1801 | } else { | |
| 1802 | ret = 1; | |
| 1803 | } | |
| 1804 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1805 | g_free(plain); |
| 11565 | 1806 | g_free(tmp); |
| 11360 | 1807 | |
| 15287 | 1808 | return ret; |
| 11360 | 1809 | } |
| 1810 | /* }}} */ | |
| 1811 | ||
| 15884 | 1812 | /* static void ggp_get_info(PurpleConnection *gc, const char *name) { {{{ */ |
| 1813 | static void ggp_get_info(PurpleConnection *gc, const char *name) | |
| 11360 | 1814 | { |
| 1815 | GGPInfo *info = gc->proto_data; | |
| 1816 | GGPSearchForm *form; | |
| 13641 | 1817 | guint32 seq; |
| 2393 | 1818 | |
| 13641 | 1819 | form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); |
| 12220 | 1820 | |
| 13641 | 1821 | form->user_data = info; |
| 11360 | 1822 | form->uin = g_strdup(name); |
| 1823 | form->offset = g_strdup("0"); | |
| 1824 | form->last_uin = g_strdup("0"); | |
| 1825 | ||
| 13641 | 1826 | seq = ggp_search_start(gc, form); |
| 1827 | ggp_search_add(info->searches, seq, form); | |
| 11360 | 1828 | } |
| 1829 | /* }}} */ | |
| 1830 | ||
| 15884 | 1831 | /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */ |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1832 | static int ggp_to_gg_status(PurpleStatus *status, char **msg) |
| 11360 | 1833 | { |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1834 | const char *status_id = purple_status_get_id(status); |
| 11360 | 1835 | int new_status, new_status_descr; |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1836 | const char *new_msg; |
| 11360 | 1837 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1838 | g_return_val_if_fail(msg == NULL, 0); |
| 11360 | 1839 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1840 | purple_debug_info("gg", "ggp_to_gg_status: Requested status = %s\n", |
| 12007 | 1841 | status_id); |
| 2393 | 1842 | |
| 11360 | 1843 | if (strcmp(status_id, "available") == 0) { |
| 1844 | new_status = GG_STATUS_AVAIL; | |
| 1845 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1846 | } else if (strcmp(status_id, "away") == 0) { | |
| 1847 | new_status = GG_STATUS_BUSY; | |
| 1848 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1849 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1850 | new_status = GG_STATUS_INVISIBLE; | |
| 1851 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 12964 | 1852 | } else if (strcmp(status_id, "offline") == 0) { |
| 1853 | new_status = GG_STATUS_NOT_AVAIL; | |
| 1854 | new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; | |
| 11360 | 1855 | } else { |
| 1856 | new_status = GG_STATUS_AVAIL; | |
| 1857 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 15884 | 1858 | purple_debug_info("gg", |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1859 | "ggp_set_status: unknown status requested (status_id=%s)\n", |
| 12007 | 1860 | status_id); |
| 11360 | 1861 | } |
| 4916 | 1862 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1863 | new_msg = purple_status_get_attr_string(status, "message"); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1864 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1865 | if(new_msg) { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1866 | char *tmp = purple_markup_strip_html(new_msg); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1867 | *msg = charset_convert(tmp, "UTF-8", "CP1250"); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1868 | g_free(tmp); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1869 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1870 | return new_status_descr; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1871 | } else { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1872 | *msg = NULL; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1873 | return new_status; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1874 | } |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1875 | } |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1876 | /* }}} */ |
| 11360 | 1877 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1878 | /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */ |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1879 | static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1880 | { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1881 | PurpleConnection *gc; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1882 | GGPInfo *info; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1883 | int new_status; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1884 | char *new_msg = NULL; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1885 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1886 | if (!purple_status_is_active(status)) |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1887 | return; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1888 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1889 | gc = purple_account_get_connection(account); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1890 | info = gc->proto_data; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1891 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1892 | new_status = ggp_to_gg_status(status, &new_msg); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1893 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1894 | if (new_msg == NULL) { |
| 11360 | 1895 | gg_change_status(info->session, new_status); |
| 1896 | } else { | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1897 | gg_change_status_descr(info->session, new_status, new_msg); |
| 12964 | 1898 | g_free(new_msg); |
| 11360 | 1899 | } |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1900 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1901 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1902 | |
| 11360 | 1903 | } |
| 1904 | /* }}} */ | |
| 1905 | ||
| 15884 | 1906 | /* static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {{{ */ |
| 1907 | static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | |
| 11360 | 1908 | { |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1909 | PurpleAccount *account; |
| 11360 | 1910 | GGPInfo *info = gc->proto_data; |
| 1911 | ||
| 1912 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1913 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1914 | account = purple_connection_get_account(gc); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1915 | if (strcmp(purple_account_get_username(account), buddy->name) == 0) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1916 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1917 | } |
| 11360 | 1918 | } |
| 1919 | /* }}} */ | |
| 1920 | ||
| 15884 | 1921 | /* static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {{{ */ |
| 1922 | static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, | |
| 1923 | PurpleGroup *group) | |
| 11360 | 1924 | { |
| 1925 | GGPInfo *info = gc->proto_data; | |
| 1926 | ||
| 1927 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1928 | } | |
| 1929 | /* }}} */ | |
| 1930 | ||
| 15884 | 1931 | /* static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) {{{ */ |
| 1932 | static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) | |
| 11394 | 1933 | { |
| 1934 | GGPInfo *info = gc->proto_data; | |
| 1935 | GGPChat *chat; | |
| 1936 | char *chat_name; | |
| 1937 | GList *l; | |
| 15884 | 1938 | PurpleConversation *conv; |
| 1939 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 11394 | 1940 | |
| 1941 | chat_name = g_hash_table_lookup(data, "name"); | |
| 1942 | ||
| 1943 | if (chat_name == NULL) | |
| 1944 | return; | |
| 1945 | ||
| 15884 | 1946 | purple_debug_info("gg", "joined %s chat\n", chat_name); |
| 11394 | 1947 | |
| 1948 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1949 | chat = l->data; | |
| 1950 | ||
| 1951 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 15884 | 1952 | purple_notify_error(gc, _("Chat error"), |
| 12007 | 1953 | _("This chat name is already in use"), NULL); |
| 11394 | 1954 | return; |
| 1955 | } | |
| 1956 | } | |
| 1957 | ||
| 11414 | 1958 | ggp_confer_add_new(gc, chat_name); |
| 12961 | 1959 | conv = serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 15884 | 1960 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(conv), |
| 1961 | purple_account_get_username(account), NULL, | |
| 1962 | PURPLE_CBFLAGS_NONE, TRUE); | |
| 11394 | 1963 | } |
| 1964 | /* }}} */ | |
| 1965 | ||
| 1966 | /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | |
| 1967 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 1968 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 1969 | } | |
| 1970 | /* }}} */ | |
| 1971 | ||
| 15884 | 1972 | /* static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) {{{ */ |
| 1973 | static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) | |
| 11394 | 1974 | { |
| 15884 | 1975 | PurpleConversation *conv; |
| 11394 | 1976 | GGPInfo *info = gc->proto_data; |
| 1977 | GGPChat *chat = NULL; | |
| 1978 | GList *l; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1979 | char *msg, *plain; |
| 11394 | 1980 | uin_t *uins; |
| 1981 | int count = 0; | |
| 1982 | ||
| 15884 | 1983 | if ((conv = purple_find_chat(gc, id)) == NULL) |
| 11394 | 1984 | return -EINVAL; |
| 1985 | ||
| 1986 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1987 | chat = l->data; | |
| 1988 | ||
| 1989 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 1990 | break; | |
| 1991 | } | |
| 1992 | ||
| 1993 | chat = NULL; | |
| 1994 | } | |
| 1995 | ||
| 1996 | if (chat == NULL) { | |
| 15884 | 1997 | purple_debug_error("gg", |
| 12007 | 1998 | "ggp_chat_send: Hm... that's strange. No such chat?\n"); |
| 11394 | 1999 | return -EINVAL; |
| 2000 | } | |
| 2001 | ||
| 2002 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 12961 | 2003 | |
| 11394 | 2004 | for (l = chat->participants; l != NULL; l = l->next) { |
| 12961 | 2005 | uin_t uin = GPOINTER_TO_INT(l->data); |
| 11394 | 2006 | |
| 12961 | 2007 | uins[count++] = uin; |
| 11394 | 2008 | } |
| 2009 | ||
| 15884 | 2010 | plain = purple_unescape_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2011 | msg = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2012 | g_free(plain); |
| 12007 | 2013 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
| 12961 | 2014 | (unsigned char *)msg); |
| 11394 | 2015 | g_free(msg); |
| 2016 | g_free(uins); | |
| 2017 | ||
| 12007 | 2018 | serv_got_chat_in(gc, id, |
| 15884 | 2019 | purple_account_get_username(purple_connection_get_account(gc)), |
|
23295
5d3a2fd59439
When calling serv_got_chat_in() after sending a group chat message (to let
Evan Schoenberg <evands@pidgin.im>
parents:
23277
diff
changeset
|
2020 | flags, message, time(NULL)); |
| 11394 | 2021 | |
| 2022 | return 0; | |
| 2023 | } | |
| 2024 | /* }}} */ | |
| 2025 | ||
| 15884 | 2026 | /* static void ggp_keepalive(PurpleConnection *gc) {{{ */ |
| 2027 | static void ggp_keepalive(PurpleConnection *gc) | |
| 11360 | 2028 | { |
| 2029 | GGPInfo *info = gc->proto_data; | |
| 2030 | ||
| 15884 | 2031 | /* purple_debug_info("gg", "Keeping connection alive....\n"); */ |
| 11360 | 2032 | |
| 2033 | if (gg_ping(info->session) < 0) { | |
| 15884 | 2034 | purple_debug_info("gg", "Not connected to the server " |
| 11360 | 2035 | "or gg_session is not correct\n"); |
| 21279 | 2036 | purple_connection_error_reason (gc, |
| 2037 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
2038 | _("Not connected to the server.")); |
| 4916 | 2039 | } |
| 2393 | 2040 | } |
| 11360 | 2041 | /* }}} */ |
| 2042 | ||
| 15884 | 2043 | /* static void ggp_register_user(PurpleAccount *account) {{{ */ |
| 2044 | static void ggp_register_user(PurpleAccount *account) | |
| 11360 | 2045 | { |
| 15884 | 2046 | PurpleConnection *gc = purple_account_get_connection(account); |
| 11360 | 2047 | GGPInfo *info; |
| 2048 | ||
| 12007 | 2049 | info = gc->proto_data = g_new0(GGPInfo, 1); |
| 11360 | 2050 | |
| 12007 | 2051 | ggp_token_request(gc, ggp_register_user_dialog); |
| 2393 | 2052 | } |
| 11360 | 2053 | /* }}} */ |
| 2393 | 2054 | |
| 15884 | 2055 | /* static GList *ggp_actions(PurplePlugin *plugin, gpointer context) {{{ */ |
| 2056 | static GList *ggp_actions(PurplePlugin *plugin, gpointer context) | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2057 | { |
| 11360 | 2058 | GList *m = NULL; |
| 15884 | 2059 | PurplePluginAction *act; |
| 11360 | 2060 | |
| 15884 | 2061 | act = purple_plugin_action_new(_("Find buddies..."), |
| 12007 | 2062 | ggp_find_buddies); |
| 11360 | 2063 | m = g_list_append(m, act); |
| 2064 | ||
| 2065 | m = g_list_append(m, NULL); | |
| 2066 | ||
| 15884 | 2067 | act = purple_plugin_action_new(_("Change password..."), |
| 12007 | 2068 | ggp_change_passwd); |
| 11360 | 2069 | m = g_list_append(m, act); |
| 2070 | ||
| 2071 | m = g_list_append(m, NULL); | |
| 2072 | ||
| 15884 | 2073 | act = purple_plugin_action_new(_("Upload buddylist to Server"), |
| 12007 | 2074 | ggp_action_buddylist_put); |
| 11360 | 2075 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2076 | |
| 15884 | 2077 | act = purple_plugin_action_new(_("Download buddylist from Server"), |
| 12007 | 2078 | ggp_action_buddylist_get); |
| 11360 | 2079 | m = g_list_append(m, act); |
| 2080 | ||
| 15884 | 2081 | act = purple_plugin_action_new(_("Delete buddylist from Server"), |
| 12007 | 2082 | ggp_action_buddylist_delete); |
| 11360 | 2083 | m = g_list_append(m, act); |
| 2084 | ||
| 15884 | 2085 | act = purple_plugin_action_new(_("Save buddylist to file..."), |
| 12007 | 2086 | ggp_action_buddylist_save); |
| 11360 | 2087 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2088 | |
| 15884 | 2089 | act = purple_plugin_action_new(_("Load buddylist from file..."), |
| 12007 | 2090 | ggp_action_buddylist_load); |
| 11360 | 2091 | m = g_list_append(m, act); |
| 2092 | ||
| 2093 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2094 | } |
| 11360 | 2095 | /* }}} */ |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2096 | |
| 15884 | 2097 | /* static gboolean ggp_offline_message(const PurpleBuddy *buddy) {{{ */ |
| 2098 | static gboolean ggp_offline_message(const PurpleBuddy *buddy) | |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2099 | { |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2100 | return TRUE; |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2101 | } |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2102 | /* }}} */ |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2103 | |
| 11360 | 2104 | /* prpl_info setup {{{ */ |
| 15884 | 2105 | static PurplePluginProtocolInfo prpl_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2106 | { |
| 11360 | 2107 | OPT_PROTO_REGISTER_NOSCREENNAME, |
| 12007 | 2108 | NULL, /* user_splits */ |
| 2109 | NULL, /* protocol_options */ | |
|
22546
3f7e366741a3
Patch from Tomasz Salacinski to allow setting buddy icons in GG prpl.
Bartosz Oler <bartosz@pidgin.im>
parents:
22277
diff
changeset
|
2110 | {"png", 32, 32, 96, 96, 0, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ |
| 11360 | 2111 | ggp_list_icon, /* list_icon */ |
| 15524 | 2112 | NULL, /* list_emblem */ |
| 11360 | 2113 | ggp_status_text, /* status_text */ |
| 2114 | ggp_tooltip_text, /* tooltip_text */ | |
| 2115 | ggp_status_types, /* status_types */ | |
| 12007 | 2116 | ggp_blist_node_menu, /* blist_node_menu */ |
| 11394 | 2117 | ggp_chat_info, /* chat_info */ |
| 12007 | 2118 | NULL, /* chat_info_defaults */ |
| 2119 | ggp_login, /* login */ | |
| 2120 | ggp_close, /* close */ | |
| 11360 | 2121 | ggp_send_im, /* send_im */ |
| 12007 | 2122 | NULL, /* set_info */ |
| 2123 | NULL, /* send_typing */ | |
| 11360 | 2124 | ggp_get_info, /* get_info */ |
| 2125 | ggp_set_status, /* set_away */ | |
| 12007 | 2126 | NULL, /* set_idle */ |
| 2127 | NULL, /* change_passwd */ | |
| 11360 | 2128 | ggp_add_buddy, /* add_buddy */ |
| 12007 | 2129 | NULL, /* add_buddies */ |
| 11360 | 2130 | ggp_remove_buddy, /* remove_buddy */ |
| 12007 | 2131 | NULL, /* remove_buddies */ |
| 2132 | NULL, /* add_permit */ | |
| 2133 | NULL, /* add_deny */ | |
| 2134 | NULL, /* rem_permit */ | |
| 2135 | NULL, /* rem_deny */ | |
| 2136 | NULL, /* set_permit_deny */ | |
| 11394 | 2137 | ggp_join_chat, /* join_chat */ |
| 12007 | 2138 | NULL, /* reject_chat */ |
| 11394 | 2139 | ggp_get_chat_name, /* get_chat_name */ |
| 12007 | 2140 | NULL, /* chat_invite */ |
| 2141 | NULL, /* chat_leave */ | |
| 2142 | NULL, /* chat_whisper */ | |
| 11394 | 2143 | ggp_chat_send, /* chat_send */ |
| 11360 | 2144 | ggp_keepalive, /* keepalive */ |
| 2145 | ggp_register_user, /* register_user */ | |
| 12007 | 2146 | NULL, /* get_cb_info */ |
| 2147 | NULL, /* get_cb_away */ | |
| 2148 | NULL, /* alias_buddy */ | |
| 2149 | NULL, /* group_buddy */ | |
| 2150 | NULL, /* rename_group */ | |
| 2151 | NULL, /* buddy_free */ | |
| 2152 | NULL, /* convo_closed */ | |
| 2153 | NULL, /* normalize */ | |
| 2154 | NULL, /* set_buddy_icon */ | |
| 2155 | NULL, /* remove_group */ | |
| 2156 | NULL, /* get_cb_real_name */ | |
| 2157 | NULL, /* set_chat_topic */ | |
| 2158 | NULL, /* find_blist_chat */ | |
| 2159 | NULL, /* roomlist_get_list */ | |
| 2160 | NULL, /* roomlist_cancel */ | |
| 2161 | NULL, /* roomlist_expand_category */ | |
| 2162 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12007
diff
changeset
|
2163 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2164 | NULL, /* new_xfer */ |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2165 | ggp_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2166 | NULL, /* whiteboard_prpl_ops */ |
| 14604 | 2167 | NULL, /* send_raw */ |
| 15185 | 2168 | NULL, /* roomlist_room_serialize */ |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2169 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2170 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2171 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2172 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2173 | NULL, |
|
23276
f4944cfaa1ff
Use up the last padding for PurplePluginProtocolInfo in a way that allows
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22622
diff
changeset
|
2174 | sizeof(PurplePluginProtocolInfo), /* struct_size */ |
|
23277
ea315a8d5bad
Patch from Jaywalker to let prpls add some helpful text for some account
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23276
diff
changeset
|
2175 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2176 | }; |
| 11360 | 2177 | /* }}} */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2178 | |
| 15884 | 2179 | /* PurplePluginInfo setup {{{ */ |
| 2180 | static PurplePluginInfo info = { | |
| 2181 | PURPLE_PLUGIN_MAGIC, /* magic */ | |
| 2182 | PURPLE_MAJOR_VERSION, /* major_version */ | |
| 2183 | PURPLE_MINOR_VERSION, /* minor_version */ | |
| 2184 | PURPLE_PLUGIN_PROTOCOL, /* plugin type */ | |
| 11360 | 2185 | NULL, /* ui_requirement */ |
| 2186 | 0, /* flags */ | |
| 2187 | NULL, /* dependencies */ | |
| 15884 | 2188 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
| 11360 | 2189 | |
| 2190 | "prpl-gg", /* id */ | |
| 2191 | "Gadu-Gadu", /* name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19897
diff
changeset
|
2192 | DISPLAY_VERSION, /* version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2193 | |
| 11360 | 2194 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 2195 | N_("Polish popular IM"), /* description */ | |
| 2196 | "boler@sourceforge.net", /* author */ | |
| 15884 | 2197 | PURPLE_WEBSITE, /* homepage */ |
| 11360 | 2198 | |
| 2199 | NULL, /* load */ | |
| 2200 | NULL, /* unload */ | |
| 2201 | NULL, /* destroy */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2202 | |
| 11360 | 2203 | NULL, /* ui_info */ |
| 2204 | &prpl_info, /* extra_info */ | |
| 2205 | NULL, /* prefs_info */ | |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2206 | ggp_actions, /* actions */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2207 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2208 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2209 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2210 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2211 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2212 | NULL |
| 11360 | 2213 | }; |
| 2214 | /* }}} */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2215 | |
| 15884 | 2216 | /* static void purple_gg_debug_handler(int level, const char * format, va_list args) {{{ */ |
| 2217 | static void purple_gg_debug_handler(int level, const char * format, va_list args) { | |
| 2218 | PurpleDebugLevel purple_level; | |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2219 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2220 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2221 | /* This is pretty pointless since the GG_DEBUG levels don't correspond to |
| 15884 | 2222 | * the purple ones */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2223 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2224 | case GG_DEBUG_FUNCTION: |
| 15884 | 2225 | purple_level = PURPLE_DEBUG_INFO; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2226 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2227 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2228 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2229 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2230 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2231 | default: |
| 15884 | 2232 | purple_level = PURPLE_DEBUG_MISC; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2233 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2234 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2235 | |
| 15884 | 2236 | purple_debug(purple_level, "gg", msg); |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2237 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2238 | } |
| 11565 | 2239 | /* }}} */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2240 | |
| 11360 | 2241 | /* |
| 2242 | */ | |
| 15884 | 2243 | /* static void init_plugin(PurplePlugin *plugin) {{{ */ |
| 2244 | static void init_plugin(PurplePlugin *plugin) | |
| 2393 | 2245 | { |
| 15884 | 2246 | PurpleAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2247 | |
| 15884 | 2248 | option = purple_account_option_string_new(_("Nickname"), |
| 12007 | 2249 | "nick", _("Gadu-Gadu User")); |
| 2250 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2251 | option); | |
| 3572 | 2252 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2253 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2254 | |
| 15884 | 2255 | gg_debug_handler = purple_gg_debug_handler; |
| 2393 | 2256 | } |
| 11360 | 2257 | /* }}} */ |
| 2393 | 2258 | |
| 15884 | 2259 | PURPLE_INIT_PLUGIN(gg, init_plugin, info); |
| 11360 | 2260 | |
| 12007 | 2261 | /* vim: set ts=8 sts=0 sw=8 noet: */ |