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