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