Sun, 16 Apr 2006 10:49:35 +0000
[gaim-migrate @ 16039]
Fixes #1448164 (Add IM button to the search results window).
| 11394 | 1 | /** |
| 2 | * @file gg.c Gadu-Gadu protocol plugin | |
| 3 | * | |
| 4 | * gaim | |
| 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 | |
| 11414 | 48 | static GaimPlugin *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 | */ | |
| 64 | /* static int ggp_setup_proxy(GaimAccount *account) {{{ */ | |
| 65 | static int ggp_setup_proxy(GaimAccount *account) | |
| 66 | { | |
| 67 | GaimProxyInfo *gpi; | |
| 68 | ||
| 69 | gpi = gaim_proxy_get_setup(account); | |
| 70 | ||
| 71 | if ((gaim_proxy_info_get_type(gpi) != GAIM_PROXY_NONE) && | |
| 72 | (gaim_proxy_info_get_host(gpi) == NULL || | |
| 73 | gaim_proxy_info_get_port(gpi) <= 0)) { | |
| 74 | ||
| 75 | gg_proxy_enabled = 0; | |
| 76 | gaim_notify_error(NULL, NULL, _("Invalid proxy settings"), | |
| 77 | _("Either the host name or port number specified for your given proxy type is invalid.")); | |
| 78 | return -1; | |
| 79 | } else if (gaim_proxy_info_get_type(gpi) != GAIM_PROXY_NONE) { | |
| 80 | gg_proxy_enabled = 1; | |
| 81 | gg_proxy_host = g_strdup(gaim_proxy_info_get_host(gpi)); | |
| 82 | gg_proxy_port = gaim_proxy_info_get_port(gpi); | |
| 83 | gg_proxy_username = g_strdup(gaim_proxy_info_get_username(gpi)); | |
| 84 | gg_proxy_password = g_strdup(gaim_proxy_info_get_password(gpi)); | |
| 85 | } else { | |
| 86 | gg_proxy_enabled = 0; | |
| 87 | } | |
| 88 | ||
| 89 | return 0; | |
| 90 | } | |
| 91 | /* }}} */ | |
| 92 | ||
| 12007 | 93 | /* |
| 94 | */ | |
| 95 | /* static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 96 | static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 97 | { | |
| 98 | GaimConnection *gc = _gc; | |
| 99 | GGPInfo *info = gc->proto_data; | |
| 100 | GGPToken *token = info->token; | |
| 101 | GGPTokenCallback cb; | |
| 102 | ||
| 103 | struct gg_token *t = NULL; | |
| 104 | ||
| 105 | gaim_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n", | |
| 106 | token->req->check, token->req->state); | |
| 107 | ||
| 108 | if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) { | |
| 109 | gaim_debug_error("gg", "token error (1): %d\n", token->req->error); | |
| 110 | gaim_input_remove(token->inpa); | |
| 111 | gg_token_free(token->req); | |
| 112 | token->req = NULL; | |
| 113 | ||
| 114 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 115 | _("Token Error"), | |
| 116 | _("Unable to fetch the token.\n"), NULL); | |
| 117 | return; | |
| 118 | } | |
| 119 | ||
| 120 | if (token->req->state != GG_STATE_DONE) { | |
| 121 | gaim_input_remove(token->inpa); | |
| 122 | token->inpa = gaim_input_add(token->req->fd, | |
| 123 | (token->req->check == 1) | |
| 124 | ? GAIM_INPUT_WRITE | |
| 125 | : GAIM_INPUT_READ, | |
| 126 | ggp_async_token_handler, gc); | |
| 127 | return; | |
| 128 | } | |
| 129 | ||
| 130 | if (!(t = token->req->data) || !token->req->body) { | |
| 131 | gaim_debug_error("gg", "token error (2): %d\n", token->req->error); | |
| 132 | gaim_input_remove(token->inpa); | |
| 133 | gg_token_free(token->req); | |
| 134 | token->req = NULL; | |
| 135 | ||
| 136 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 137 | _("Token Error"), | |
| 138 | _("Unable to fetch the token.\n"), NULL); | |
| 139 | return; | |
| 140 | } | |
| 141 | ||
| 142 | gaim_input_remove(token->inpa); | |
| 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 | ||
| 149 | gaim_debug_info("gg", "TOKEN! tokenid = %s; size = %d\n", | |
| 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 | */ | |
| 164 | /* static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) {{{ */ | |
| 165 | static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) | |
| 166 | { | |
| 13515 | 167 | GaimAccount *account; |
| 12007 | 168 | struct gg_http *req; |
| 13515 | 169 | GGPInfo *info; |
| 170 | ||
| 171 | account = gaim_connection_get_account(gc); | |
| 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) { | |
| 13515 | 179 | gaim_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; | |
| 189 | info->token->inpa = gaim_input_add(req->fd, GAIM_INPUT_READ, | |
| 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 | */ | |
| 202 | /* static void ggp_action_buddylist_get(GaimPluginAction *action) {{{ */ | |
| 203 | static void ggp_action_buddylist_get(GaimPluginAction *action) | |
| 204 | { | |
| 205 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 206 | GGPInfo *info = gc->proto_data; | |
| 207 | ||
| 208 | gaim_debug_info("gg", "Downloading...\n"); | |
| 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 | */ | |
| 219 | /* static void ggp_action_buddylist_put(GaimPluginAction *action) {{{ */ | |
| 220 | static void ggp_action_buddylist_put(GaimPluginAction *action) | |
| 221 | { | |
| 222 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 223 | GGPInfo *info = gc->proto_data; | |
| 224 | ||
| 225 | char *buddylist = ggp_buddylist_dump(gaim_connection_get_account(gc)); | |
| 226 | ||
| 227 | gaim_debug_info("gg", "Uploading...\n"); | |
| 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 | */ | |
| 242 | /* static void ggp_action_buddylist_delete(GaimPluginAction *action) {{{ */ | |
| 243 | static void ggp_action_buddylist_delete(GaimPluginAction *action) | |
| 244 | { | |
| 245 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 246 | GGPInfo *info = gc->proto_data; | |
| 247 | ||
| 248 | gaim_debug_info("gg", "Deleting...\n"); | |
| 249 | ||
| 250 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 251 | } | |
| 252 | /* }}} */ | |
| 253 | ||
| 254 | /* | |
| 255 | */ | |
| 256 | /* static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 257 | static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) | |
| 258 | { | |
| 259 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 260 | ||
| 261 | FILE *fh; | |
| 262 | char *buddylist = ggp_buddylist_dump(account); | |
| 263 | gchar *msg; | |
| 264 | ||
| 265 | gaim_debug_info("gg", "Saving...\n"); | |
| 266 | gaim_debug_info("gg", "file = %s\n", file); | |
| 267 | ||
| 268 | if (buddylist == NULL) { | |
| 269 | gaim_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); | |
| 277 | gaim_debug_error("gg", "Could not open file: %s\n", file); | |
| 278 | gaim_notify_error(account, _("Couldn't open file"), msg, NULL); | |
| 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 | ||
| 288 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 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 | */ | |
| 295 | /* static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 296 | static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) | |
| 297 | { | |
| 298 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 12007 | 299 | GError *error = NULL; |
| 300 | char *buddylist = NULL; | |
| 301 | gsize length; | |
| 11360 | 302 | |
| 303 | gaim_debug_info("gg", "file_name = %s\n", file); | |
| 304 | ||
| 12007 | 305 | if (!g_file_get_contents(file, &buddylist, &length, &error)) { |
| 306 | gaim_notify_error(account, | |
| 307 | _("Couldn't load buddylist"), | |
| 308 | _("Couldn't load buddylist"), | |
| 309 | error->message); | |
| 310 | ||
| 311 | gaim_debug_error("gg", | |
| 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 | ||
| 323 | gaim_notify_info(account, | |
| 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 | */ | |
| 331 | /* static void ggp_action_buddylist_save(GaimPluginAction *action) {{{ */ | |
| 332 | static void ggp_action_buddylist_save(GaimPluginAction *action) | |
| 333 | { | |
| 334 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 335 | ||
| 336 | gaim_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 | */ | |
| 343 | /* static void ggp_action_buddylist_load(GaimPluginAction *action) {{{ */ | |
| 344 | static void ggp_action_buddylist_load(GaimPluginAction *action) | |
| 345 | { | |
| 346 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 347 | ||
| 348 | gaim_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 | */ | |
| 11414 | 355 | /* static void ggp_callback_register_account_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 12007 | 356 | static void ggp_callback_register_account_ok(GaimConnection *gc, |
| 357 | GaimRequestFields *fields) | |
| 11414 | 358 | { |
| 359 | GaimAccount *account; | |
| 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 | |
| 367 | email = charset_convert(gaim_request_fields_get_string(fields, "email"), | |
| 368 | "UTF-8", "CP1250"); | |
| 369 | p1 = charset_convert(gaim_request_fields_get_string(fields, "password1"), | |
| 370 | "UTF-8", "CP1250"); | |
| 371 | p2 = charset_convert(gaim_request_fields_get_string(fields, "password2"), | |
| 372 | "UTF-8", "CP1250"); | |
| 373 | t = charset_convert(gaim_request_fields_get_string(fields, "token"), | |
| 374 | "UTF-8", "CP1250"); | |
| 375 | ||
| 376 | account = gaim_connection_get_account(gc); | |
| 377 | ||
| 378 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 379 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
380 | gaim_connection_error(gc, _("Fill in the registration fields.")); |
| 11414 | 381 | goto exit_err; |
| 382 | } | |
| 383 | ||
| 384 | if (g_utf8_collate(p1, p2) != 0) { | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
385 | gaim_connection_error(gc, _("Passwords do not match.")); |
| 11414 | 386 | goto exit_err; |
| 387 | } | |
| 388 | ||
| 12007 | 389 | gaim_debug_info("gg", "register_account_ok: token_id = %d; t = %s\n", |
| 390 | token->id, t); | |
| 391 | h = gg_register3(email, p1, token->id, t, 0); | |
| 11414 | 392 | if (h == NULL || !(s = h->data) || !s->success) { |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
393 | gaim_connection_error(gc, |
|
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; | |
| 399 | gaim_debug_info("gg", "registered uin: %d\n", uin); | |
| 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); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
403 | gaim_account_set_username(account, t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
404 | /* Save the password if remembering passwords for the account */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
405 | gaim_account_set_password(account, p1); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
406 | |
| 11414 | 407 | gaim_notify_info(NULL, _("New Gadu-Gadu Account Registered"), |
| 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. */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
416 | gaim_connection_destroy(gc); |
|
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 | */ | |
| 431 | /* static void ggp_callback_register_account_cancel(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 12007 | 432 | static void ggp_callback_register_account_cancel(GaimConnection *gc, |
| 433 | GaimRequestFields *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 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
438 | gaim_connection_destroy(gc); |
|
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 | */ | |
| 449 | /* static void ggp_register_user_dialog(GaimConnection *gc) {{{ */ | |
| 450 | static void ggp_register_user_dialog(GaimConnection *gc) | |
| 451 | { | |
| 452 | GaimAccount *account; | |
| 453 | GaimRequestFields *fields; | |
| 454 | GaimRequestFieldGroup *group; | |
| 455 | GaimRequestField *field; | |
| 456 | ||
| 457 | GGPInfo *info = gc->proto_data; | |
| 458 | GGPToken *token = info->token; | |
| 459 | ||
| 460 | ||
| 461 | account = gaim_connection_get_account(gc); | |
| 462 | ||
| 463 | fields = gaim_request_fields_new(); | |
| 464 | group = gaim_request_field_group_new(NULL); | |
| 465 | gaim_request_fields_add_group(fields, group); | |
| 466 | ||
| 467 | field = gaim_request_field_string_new("email", | |
|
13546
0700f0c29e14
[gaim-migrate @ 15922]
Richard Laager <rlaager@pidgin.im>
parents:
13518
diff
changeset
|
468 | _("E-mail"), "", FALSE); |
| 12007 | 469 | gaim_request_field_string_set_masked(field, FALSE); |
| 470 | gaim_request_field_group_add_field(group, field); | |
| 471 | ||
| 472 | field = gaim_request_field_string_new("password1", | |
| 473 | _("Password"), "", FALSE); | |
| 474 | gaim_request_field_string_set_masked(field, TRUE); | |
| 475 | gaim_request_field_group_add_field(group, field); | |
| 476 | ||
| 477 | field = gaim_request_field_string_new("password2", | |
| 478 | _("Password (retype)"), "", FALSE); | |
| 479 | gaim_request_field_string_set_masked(field, TRUE); | |
| 480 | gaim_request_field_group_add_field(group, field); | |
| 481 | ||
| 482 | field = gaim_request_field_string_new("token", | |
| 483 | _("Enter current token"), "", FALSE); | |
| 484 | gaim_request_field_string_set_masked(field, FALSE); | |
| 485 | gaim_request_field_group_add_field(group, field); | |
| 486 | ||
| 487 | /* original size: 60x24 */ | |
| 488 | field = gaim_request_field_image_new("token_img", | |
| 489 | _("Current token"), token->data, token->size); | |
| 490 | gaim_request_field_group_add_field(group, field); | |
| 491 | ||
| 492 | gaim_request_fields(account, | |
| 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 | */ | |
| 13642 | 507 | /* static void ggp_callback_show_next(GaimConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 508 | static void ggp_callback_show_next(GaimConnection *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 | */ | |
| 13642 | 526 | /* static void ggp_callback_add_buddy(GaimConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 527 | static void ggp_callback_add_buddy(GaimConnection *gc, GList *row, gpointer user_data) | |
| 11414 | 528 | { |
| 529 | gaim_blist_request_add_buddy(gaim_connection_get_account(gc), | |
| 12007 | 530 | g_list_nth_data(row, 0), NULL, NULL); |
| 11414 | 531 | } |
| 532 | /* }}} */ | |
| 533 | ||
| 534 | /* | |
| 535 | */ | |
| 13642 | 536 | /* static void ggp_callback_im(GaimConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 537 | static void ggp_callback_im(GaimConnection *gc, GList *row, gpointer user_data) | |
| 538 | { | |
| 539 | GaimAccount *account; | |
| 540 | GaimConversation *conv; | |
| 541 | char *name; | |
| 542 | ||
| 543 | account = gaim_connection_get_account(gc); | |
| 544 | ||
| 545 | name = g_list_nth_data(row, 0); | |
| 546 | conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); | |
| 547 | gaim_conversation_present(conv); | |
| 548 | } | |
| 549 | /* }}} */ | |
| 550 | ||
| 551 | /* | |
| 552 | */ | |
| 11414 | 553 | /* static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 554 | static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) | |
| 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( |
| 564 | gaim_request_fields_get_string(fields, "lastname"), | |
| 565 | "UTF-8", "CP1250"); | |
| 566 | form->firstname = charset_convert( | |
| 567 | gaim_request_fields_get_string(fields, "firstname"), | |
| 568 | "UTF-8", "CP1250"); | |
| 569 | form->nickname = charset_convert( | |
| 570 | gaim_request_fields_get_string(fields, "nickname"), | |
| 571 | "UTF-8", "CP1250"); | |
| 572 | form->city = charset_convert( | |
| 573 | gaim_request_fields_get_string(fields, "city"), | |
| 574 | "UTF-8", "CP1250"); | |
| 575 | form->birthyear = charset_convert( | |
| 576 | gaim_request_fields_get_string(fields, "year"), | |
| 577 | "UTF-8", "CP1250"); | |
| 11414 | 578 | |
| 579 | switch (gaim_request_fields_get_choice(fields, "gender")) { | |
| 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 | ||
| 591 | form->active = gaim_request_fields_get_bool(fields, "active") | |
| 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 | */ | |
| 603 | /* static void ggp_find_buddies(GaimPluginAction *action) {{{ */ | |
| 604 | static void ggp_find_buddies(GaimPluginAction *action) | |
| 605 | { | |
| 606 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 607 | ||
| 608 | GaimRequestFields *fields; | |
| 609 | GaimRequestFieldGroup *group; | |
| 610 | GaimRequestField *field; | |
| 611 | ||
| 612 | fields = gaim_request_fields_new(); | |
| 613 | group = gaim_request_field_group_new(NULL); | |
| 614 | gaim_request_fields_add_group(fields, group); | |
| 615 | ||
| 12007 | 616 | field = gaim_request_field_string_new("lastname", |
| 617 | _("Last name"), NULL, FALSE); | |
| 11414 | 618 | gaim_request_field_string_set_masked(field, FALSE); |
| 619 | gaim_request_field_group_add_field(group, field); | |
| 620 | ||
| 12007 | 621 | field = gaim_request_field_string_new("firstname", |
| 622 | _("First name"), NULL, FALSE); | |
| 11414 | 623 | gaim_request_field_string_set_masked(field, FALSE); |
| 624 | gaim_request_field_group_add_field(group, field); | |
| 625 | ||
| 12007 | 626 | field = gaim_request_field_string_new("nickname", |
| 627 | _("Nickname"), NULL, FALSE); | |
| 11414 | 628 | gaim_request_field_string_set_masked(field, FALSE); |
| 629 | gaim_request_field_group_add_field(group, field); | |
| 630 | ||
| 12007 | 631 | field = gaim_request_field_string_new("city", |
| 632 | _("City"), NULL, FALSE); | |
| 11414 | 633 | gaim_request_field_string_set_masked(field, FALSE); |
| 634 | gaim_request_field_group_add_field(group, field); | |
| 635 | ||
| 12007 | 636 | field = gaim_request_field_string_new("year", |
| 637 | _("Year of birth"), NULL, FALSE); | |
| 11414 | 638 | gaim_request_field_group_add_field(group, field); |
| 639 | ||
| 12007 | 640 | field = gaim_request_field_choice_new("gender", _("Gender"), 0); |
| 641 | gaim_request_field_choice_add(field, _("Male or female")); | |
| 642 | gaim_request_field_choice_add(field, _("Male")); | |
| 643 | gaim_request_field_choice_add(field, _("Female")); | |
| 11414 | 644 | gaim_request_field_group_add_field(group, field); |
| 645 | ||
| 12007 | 646 | field = gaim_request_field_bool_new("active", |
| 647 | _("Only online"), FALSE); | |
| 11414 | 648 | gaim_request_field_group_add_field(group, field); |
| 649 | ||
| 650 | gaim_request_fields(gc, | |
| 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 | */ | |
| 11360 | 665 | /* static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 666 | static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 2393 | 667 | { |
| 11360 | 668 | GaimAccount *account; |
| 669 | GGPInfo *info = gc->proto_data; | |
| 670 | struct gg_http *h; | |
| 671 | gchar *cur, *p1, *p2, *t; | |
| 672 | ||
| 12007 | 673 | cur = charset_convert( |
| 674 | gaim_request_fields_get_string(fields, "password_cur"), | |
| 675 | "UTF-8", "CP1250"); | |
| 676 | p1 = charset_convert( | |
| 677 | gaim_request_fields_get_string(fields, "password1"), | |
| 678 | "UTF-8", "CP1250"); | |
| 679 | p2 = charset_convert( | |
| 680 | gaim_request_fields_get_string(fields, "password2"), | |
| 681 | "UTF-8", "CP1250"); | |
| 682 | t = charset_convert( | |
| 683 | gaim_request_fields_get_string(fields, "token"), | |
| 684 | "UTF-8", "CP1250"); | |
| 11360 | 685 | |
| 686 | account = gaim_connection_get_account(gc); | |
| 687 | ||
| 688 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 689 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 690 | gaim_notify_error(account, NULL, _("Fill in the fields."), NULL); | |
| 691 | goto exit_err; | |
| 692 | } | |
| 693 | ||
| 694 | if (g_utf8_collate(p1, p2) != 0) { | |
| 12007 | 695 | gaim_notify_error(account, NULL, |
| 696 | _("New passwords do not match."), NULL); | |
| 11360 | 697 | goto exit_err; |
| 698 | } | |
| 2393 | 699 | |
| 11360 | 700 | if (g_utf8_collate(cur, gaim_account_get_password(account)) != 0) { |
| 701 | gaim_notify_error(account, NULL, | |
| 702 | _("Your current password is different from the one that you specified."), | |
| 703 | NULL); | |
| 704 | goto exit_err; | |
| 705 | } | |
| 706 | ||
|
12457
6d2633b10f1d
[gaim-migrate @ 14766]
Casey Harkins <charkins@pidgin.im>
parents:
12373
diff
changeset
|
707 | gaim_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), | |
| 711 | "user@example.net", gaim_account_get_password(account), | |
| 12007 | 712 | p1, info->token->id, t, 0); |
| 2393 | 713 | |
| 11360 | 714 | if (h == NULL) { |
| 715 | gaim_notify_error(account, NULL, | |
| 716 | _("Unable to change password. Error occured.\n"), | |
| 717 | NULL); | |
| 718 | goto exit_err; | |
| 719 | } | |
| 720 | ||
| 721 | gaim_account_set_password(account, p1); | |
| 722 | ||
| 723 | gg_change_passwd_free(h); | |
| 724 | ||
| 725 | gaim_notify_info(account, _("Change password for the Gadu-Gadu account"), | |
| 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 | */ | |
| 741 | /* static void ggp_change_passwd_dialog(GaimConnection *gc) {{{ */ | |
| 742 | static void ggp_change_passwd_dialog(GaimConnection *gc) | |
| 743 | { | |
| 744 | GaimRequestFields *fields; | |
| 745 | GaimRequestFieldGroup *group; | |
| 746 | GaimRequestField *field; | |
| 747 | ||
| 748 | GGPInfo *info = gc->proto_data; | |
| 749 | GGPToken *token = info->token; | |
| 750 | ||
| 751 | char *msg; | |
| 752 | ||
| 753 | ||
| 754 | fields = gaim_request_fields_new(); | |
| 755 | group = gaim_request_field_group_new(NULL); | |
| 756 | gaim_request_fields_add_group(fields, group); | |
| 757 | ||
| 758 | field = gaim_request_field_string_new("password_cur", | |
| 759 | _("Current password"), "", FALSE); | |
| 760 | gaim_request_field_string_set_masked(field, TRUE); | |
| 761 | gaim_request_field_group_add_field(group, field); | |
| 762 | ||
| 763 | field = gaim_request_field_string_new("password1", | |
| 764 | _("Password"), "", FALSE); | |
| 765 | gaim_request_field_string_set_masked(field, TRUE); | |
| 766 | gaim_request_field_group_add_field(group, field); | |
| 767 | ||
| 768 | field = gaim_request_field_string_new("password2", | |
| 769 | _("Password (retype)"), "", FALSE); | |
| 770 | gaim_request_field_string_set_masked(field, TRUE); | |
| 771 | gaim_request_field_group_add_field(group, field); | |
| 772 | ||
| 773 | field = gaim_request_field_string_new("token", | |
| 774 | _("Enter current token"), "", FALSE); | |
| 775 | gaim_request_field_string_set_masked(field, FALSE); | |
| 776 | gaim_request_field_group_add_field(group, field); | |
| 777 | ||
| 778 | /* original size: 60x24 */ | |
| 779 | field = gaim_request_field_image_new("token_img", | |
| 780 | _("Current token"), token->data, token->size); | |
| 781 | gaim_request_field_group_add_field(group, field); | |
| 782 | ||
| 783 | msg = g_strdup_printf("%s %d", | |
| 784 | _("Please, enter your current password and your new password for UIN: "), | |
| 785 | ggp_get_uin(gaim_connection_get_account(gc))); | |
| 786 | ||
| 787 | gaim_request_fields(gc, | |
| 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 | */ | |
| 800 | /* static void ggp_change_passwd(GaimPluginAction *action) {{{ */ | |
| 801 | static void ggp_change_passwd(GaimPluginAction *action) | |
| 802 | { | |
| 803 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 804 | ||
| 12007 | 805 | ggp_token_request(gc, ggp_change_passwd_dialog); |
| 11360 | 806 | } |
| 807 | /* }}} */ | |
| 808 | ||
| 11414 | 809 | /* ----- CONFERENCES ---------------------------------------------------- */ |
| 810 | ||
| 11394 | 811 | /* |
| 812 | */ | |
| 813 | /* static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 814 | static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 815 | { | |
| 816 | GGPInfo *info = gc->proto_data; | |
| 817 | GaimRequestField *field; | |
| 12961 | 818 | const GList *sel; |
| 11394 | 819 | |
| 820 | field = gaim_request_fields_get_field(fields, "name"); | |
| 821 | sel = gaim_request_field_list_get_selected(field); | |
| 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 | */ | |
| 830 | /* static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 831 | static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) | |
| 832 | { | |
| 833 | GaimBuddy *buddy; | |
| 834 | GaimConnection *gc; | |
| 835 | GGPInfo *info; | |
| 836 | ||
| 837 | GaimRequestFields *fields; | |
| 838 | GaimRequestFieldGroup *group; | |
| 839 | GaimRequestField *field; | |
| 840 | ||
| 841 | GList *l; | |
| 842 | gchar *msg; | |
| 843 | ||
| 844 | buddy = (GaimBuddy *)node; | |
| 845 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 846 | info = gc->proto_data; | |
| 847 | ||
| 12961 | 848 | /* TODO: It tmp_buddy != 0 then stop! */ |
| 849 | info->tmp_buddy = ggp_str_to_uin(gaim_buddy_get_name(buddy)); | |
| 11394 | 850 | |
| 851 | fields = gaim_request_fields_new(); | |
| 852 | group = gaim_request_field_group_new(NULL); | |
| 853 | gaim_request_fields_add_group(fields, group); | |
| 854 | ||
| 855 | field = gaim_request_field_list_new("name", "Chat name"); | |
| 856 | for (l = info->chats; l != NULL; l = l->next) { | |
| 857 | GGPChat *chat = l->data; | |
| 12007 | 858 | gaim_request_field_list_add(field, g_strdup(chat->name), |
| 859 | g_strdup(chat->name)); | |
| 11394 | 860 | } |
| 861 | gaim_request_field_group_add_field(group, field); | |
| 862 | ||
| 12007 | 863 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
| 13466 | 864 | gaim_buddy_get_alias(buddy)); |
| 11394 | 865 | gaim_request_fields(gc, |
| 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 | */ | |
| 880 | /* static void ggp_bmenu_block(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 881 | static void ggp_bmenu_block(GaimBlistNode *node, gpointer ignored) | |
| 882 | { | |
| 883 | GaimConnection *gc; | |
| 884 | GaimBuddy *buddy; | |
| 885 | GGPInfo *info; | |
| 886 | uin_t uin; | |
| 887 | ||
| 888 | buddy = (GaimBuddy *)node; | |
| 889 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 890 | info = gc->proto_data; | |
| 891 | ||
| 892 | uin = ggp_str_to_uin(gaim_buddy_get_name(buddy)); | |
| 893 | ||
| 894 | if (gaim_blist_node_get_bool(node, "blocked")) { | |
| 895 | gaim_blist_node_set_bool(node, "blocked", FALSE); | |
| 896 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 897 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 898 | gaim_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); | |
| 899 | } else { | |
| 900 | gaim_blist_node_set_bool(node, "blocked", TRUE); | |
| 901 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 902 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 903 | gaim_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); | |
| 904 | } | |
| 905 | } | |
| 906 | /* }}} */ | |
| 907 | ||
| 11360 | 908 | /* ---------------------------------------------------------------------- */ |
| 11414 | 909 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 910 | /* ---------------------------------------------------------------------- */ | |
| 911 | ||
| 12964 | 912 | /* just a prototype */ |
| 913 | static void ggp_set_status(GaimAccount *account, GaimStatus *status); | |
| 914 | ||
| 11414 | 915 | /** |
| 916 | * Handle change of the status of the buddy. | |
| 917 | * | |
| 918 | * @param gc GaimConnection | |
| 919 | * @param uin UIN of the buddy. | |
| 920 | * @param status ID of the status. | |
| 921 | * @param descr Description. | |
| 922 | */ | |
| 923 | /* static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, int status, const char *descr) {{{ */ | |
| 12007 | 924 | static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, |
| 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"; |
| 12007 | 951 | gaim_debug_info("gg", |
| 952 | "GG_EVENT_NOTIFY: Unknown status: %d\n", status); | |
| 11414 | 953 | break; |
| 954 | } | |
| 955 | ||
| 956 | gaim_debug_info("gg", "st = %s\n", st); | |
| 957 | msg = charset_convert(descr, "CP1250", "UTF-8"); | |
| 12007 | 958 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), |
| 959 | from, st, "message", msg, NULL); | |
| 11414 | 960 | g_free(from); |
| 961 | g_free(msg); | |
| 962 | } | |
| 963 | /* }}} */ | |
| 964 | ||
| 12007 | 965 | /* |
| 966 | */ | |
| 13641 | 967 | /* static void ggp_sr_close_cb(GGPSearchForm *form) {{{ */ |
| 968 | static void ggp_sr_close_cb(GGPSearchForm *form) | |
| 12220 | 969 | { |
| 13641 | 970 | GGPInfo *info = form->user_data; |
| 12220 | 971 | |
| 13641 | 972 | ggp_search_remove(info->searches, form->seq); |
| 973 | ggp_search_form_destroy(form); | |
| 12220 | 974 | } |
| 975 | /* }}} */ | |
| 976 | ||
| 977 | /* | |
| 978 | */ | |
| 12007 | 979 | /* static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) {{{ */ |
| 980 | static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) | |
| 981 | { | |
| 982 | GGPInfo *info = gc->proto_data; | |
| 983 | GaimNotifySearchResults *results; | |
| 984 | GaimNotifySearchColumn *column; | |
| 13641 | 985 | GGPSearchForm *form; |
| 12007 | 986 | int res_count = 0; |
| 987 | int start; | |
| 988 | int i; | |
| 13641 | 989 | guint32 seq; |
| 990 | ||
| 991 | seq = gg_pubdir50_seq(req); | |
| 992 | form = ggp_search_get(info->searches, seq); | |
| 993 | ||
| 994 | if (form == NULL) { | |
| 995 | /* | |
| 996 | * this can happen when user will request more results | |
| 997 | * and close the results window before they arrive. | |
| 998 | */ | |
| 999 | gaim_debug_error("gg", "No search form available for this search!\n"); | |
| 1000 | return; | |
| 1001 | } | |
| 12007 | 1002 | |
| 1003 | res_count = gg_pubdir50_count(req); | |
| 1004 | if (res_count < 1) { | |
| 1005 | gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); | |
| 12220 | 1006 | gaim_notify_error(gc, NULL, |
| 1007 | _("No matching users found"), | |
| 1008 | _("There are no users matching your search criteria.")); | |
| 13641 | 1009 | ggp_sr_close_cb(form); |
| 12007 | 1010 | return; |
| 1011 | } | |
| 1012 | res_count = (res_count > 20) ? 20 : res_count; | |
| 1013 | ||
| 1014 | results = gaim_notify_searchresults_new(); | |
| 1015 | ||
| 12257 | 1016 | if (results == NULL) { |
| 1017 | gaim_debug_error("gg", "ggp_pubdir_reply_handler: " | |
| 1018 | "Unable to display the search results.\n"); | |
| 1019 | gaim_notify_error(gc, NULL, | |
| 1020 | _("Unable to display the search results."), | |
| 1021 | NULL); | |
| 13641 | 1022 | ggp_sr_close_cb(form); |
| 12257 | 1023 | return; |
| 1024 | } | |
| 1025 | ||
| 12220 | 1026 | column = gaim_notify_searchresults_column_new(_("UIN")); |
| 12007 | 1027 | gaim_notify_searchresults_column_add(results, column); |
| 1028 | ||
|
13573
b054b0e348fe
[gaim-migrate @ 15951]
Richard Laager <rlaager@pidgin.im>
parents:
13546
diff
changeset
|
1029 | column = gaim_notify_searchresults_column_new(_("First Name")); |
| 12007 | 1030 | gaim_notify_searchresults_column_add(results, column); |
| 1031 | ||
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12467
diff
changeset
|
1032 | column = gaim_notify_searchresults_column_new(_("Nickname")); |
| 12007 | 1033 | gaim_notify_searchresults_column_add(results, column); |
| 1034 | ||
| 12220 | 1035 | column = gaim_notify_searchresults_column_new(_("City")); |
| 12007 | 1036 | gaim_notify_searchresults_column_add(results, column); |
| 1037 | ||
|
13573
b054b0e348fe
[gaim-migrate @ 15951]
Richard Laager <rlaager@pidgin.im>
parents:
13546
diff
changeset
|
1038 | column = gaim_notify_searchresults_column_new(_("Birth Year")); |
| 12007 | 1039 | gaim_notify_searchresults_column_add(results, column); |
| 1040 | ||
| 1041 | gaim_debug_info("gg", "Going with %d entries\n", res_count); | |
| 1042 | ||
| 1043 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 1044 | gaim_debug_info("gg", "start = %d\n", start); | |
| 1045 | ||
| 1046 | for (i = 0; i < res_count; i++) { | |
| 1047 | GList *row = NULL; | |
| 1048 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 1049 | ||
| 1050 | /* TODO: Status will be displayed as an icon. */ | |
| 1051 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 1052 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1053 | GG_PUBDIR50_UIN)); | |
| 1054 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1055 | GG_PUBDIR50_FIRSTNAME)); | |
| 1056 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1057 | GG_PUBDIR50_NICKNAME)); | |
| 1058 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1059 | GG_PUBDIR50_CITY)); | |
| 1060 | row = g_list_append(row, | |
| 1061 | (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 1062 | ||
| 1063 | gaim_notify_searchresults_row_add(results, row); | |
| 1064 | ||
| 1065 | if (i == res_count - 1) { | |
| 13641 | 1066 | g_free(form->last_uin); |
| 1067 | form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN); | |
| 12007 | 1068 | } |
| 1069 | } | |
| 1070 | ||
| 1071 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_CONTINUE, | |
| 1072 | ggp_callback_show_next); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12600
diff
changeset
|
1073 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD, |
| 12007 | 1074 | ggp_callback_add_buddy); |
| 13642 | 1075 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_IM, |
| 1076 | ggp_callback_im); | |
| 13641 | 1077 | if (form->window == NULL) { |
| 12007 | 1078 | void *h = gaim_notify_searchresults(gc, |
| 1079 | _("Gadu-Gadu Public Directory"), | |
| 12220 | 1080 | _("Search results"), NULL, results, |
| 12257 | 1081 | (GaimNotifyCloseCallback)ggp_sr_close_cb, |
| 13641 | 1082 | form); |
| 12257 | 1083 | |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1084 | if (h == NULL) { |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1085 | gaim_debug_error("gg", "ggp_pubdir_reply_handler: " |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1086 | "Unable to display the search results.\n"); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1087 | gaim_notify_error(gc, NULL, |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1088 | _("Unable to display the search results."), |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1089 | NULL); |
| 13641 | 1090 | ggp_sr_close_cb(form); |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1091 | return; |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1092 | } |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1093 | |
| 13641 | 1094 | form->window = h; |
| 12007 | 1095 | } else { |
| 13641 | 1096 | gaim_notify_searchresults_new_rows(gc, results, form->window); |
| 12007 | 1097 | } |
| 1098 | } | |
| 1099 | /* }}} */ | |
| 1100 | ||
| 11414 | 1101 | /** |
| 1102 | * Dispatch a message received from a buddy. | |
| 1103 | * | |
| 1104 | * @param gc GaimConnection. | |
| 1105 | * @param ev Gadu-Gadu event structure. | |
| 1106 | */ | |
| 1107 | /* static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) {{{ */ | |
| 1108 | static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) | |
| 1109 | { | |
| 1110 | GGPInfo *info = gc->proto_data; | |
| 1111 | GaimConversation *conv; | |
| 1112 | gchar *from; | |
| 1113 | gchar *msg; | |
| 1114 | gchar *tmp; | |
| 1115 | ||
| 1116 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 1117 | ||
| 12961 | 1118 | tmp = charset_convert((const char *)ev->event.msg.message, |
| 12007 | 1119 | "CP1250", "UTF-8"); |
| 12961 | 1120 | gaim_str_strip_char(tmp, '\r'); |
| 1121 | msg = g_markup_escape_text(tmp, -1); | |
| 1122 | g_free(tmp); | |
| 11414 | 1123 | |
| 1124 | gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", | |
| 12961 | 1125 | from, msg, ev->event.msg.msgclass, |
| 12007 | 1126 | ev->event.msg.recipients_count); |
| 11414 | 1127 | |
| 1128 | if (ev->event.msg.recipients_count == 0) { | |
| 12961 | 1129 | serv_got_im(gc, from, msg, 0, ev->event.msg.time); |
| 11414 | 1130 | } else { |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1131 | const char *chat_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1132 | int chat_id; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1133 | char *buddy_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1134 | |
| 11414 | 1135 | chat_name = ggp_confer_find_by_participants(gc, |
| 12007 | 1136 | ev->event.msg.recipients, |
| 1137 | ev->event.msg.recipients_count); | |
| 12961 | 1138 | |
| 11414 | 1139 | if (chat_name == NULL) { |
| 1140 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 1141 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 12007 | 1142 | |
| 1143 | ggp_confer_participants_add_uin(gc, chat_name, | |
| 1144 | ev->event.msg.sender); | |
| 1145 | ||
| 1146 | ggp_confer_participants_add(gc, chat_name, | |
| 1147 | ev->event.msg.recipients, | |
| 1148 | ev->event.msg.recipients_count); | |
| 11414 | 1149 | } |
| 1150 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 1151 | chat_id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1152 | |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1153 | buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1154 | serv_got_chat_in(gc, chat_id, buddy_name, |
| 12961 | 1155 | GAIM_MESSAGE_RECV, msg, ev->event.msg.time); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1156 | g_free(buddy_name); |
| 11414 | 1157 | } |
| 12961 | 1158 | g_free(msg); |
| 11414 | 1159 | g_free(from); |
| 1160 | } | |
| 1161 | /* }}} */ | |
| 1162 | ||
| 1163 | /* | |
| 1164 | */ | |
| 1165 | /* static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 1166 | static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 1167 | { | |
| 1168 | GaimConnection *gc = _gc; | |
| 1169 | GGPInfo *info = gc->proto_data; | |
| 1170 | struct gg_event *ev; | |
| 1171 | int i; | |
| 1172 | ||
| 1173 | if (!(ev = gg_watch_fd(info->session))) { | |
| 12007 | 1174 | gaim_debug_error("gg", |
| 1175 | "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); | |
| 11414 | 1176 | gaim_connection_error(gc, _("Unable to read socket")); |
| 1177 | return; | |
| 1178 | } | |
| 1179 | ||
| 1180 | switch (ev->type) { | |
| 1181 | case GG_EVENT_NONE: | |
| 1182 | /* Nothing happened. */ | |
| 1183 | break; | |
| 1184 | case GG_EVENT_MSG: | |
| 1185 | ggp_recv_message_handler(gc, ev); | |
| 1186 | break; | |
| 1187 | case GG_EVENT_ACK: | |
| 12007 | 1188 | gaim_debug_info("gg", |
| 1189 | "message sent to: %ld, delivery status=%d, seq=%d\n", | |
| 1190 | ev->event.ack.recipient, ev->event.ack.status, | |
| 1191 | ev->event.ack.seq); | |
| 11414 | 1192 | break; |
| 1193 | case GG_EVENT_NOTIFY: | |
| 1194 | case GG_EVENT_NOTIFY_DESCR: | |
| 1195 | { | |
| 1196 | struct gg_notify_reply *n; | |
| 1197 | char *descr; | |
| 1198 | ||
| 1199 | gaim_debug_info("gg", "notify_pre: (%d) status: %d\n", | |
| 1200 | ev->event.notify->uin, | |
| 1201 | ev->event.notify->status); | |
| 1202 | ||
| 1203 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 1204 | : ev->event.notify_descr.notify; | |
| 1205 | ||
| 1206 | for (; n->uin; n++) { | |
| 1207 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 12007 | 1208 | : ev->event.notify_descr.descr; |
| 1209 | ||
| 1210 | gaim_debug_info("gg", | |
| 1211 | "notify: (%d) status: %d; descr: %s\n", | |
| 1212 | n->uin, n->status, descr); | |
| 11414 | 1213 | |
| 1214 | ggp_generic_status_handler(gc, | |
| 12007 | 1215 | n->uin, n->status, descr); |
| 11414 | 1216 | } |
| 1217 | } | |
| 1218 | break; | |
| 1219 | case GG_EVENT_NOTIFY60: | |
| 12007 | 1220 | gaim_debug_info("gg", |
| 1221 | "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", | |
| 1222 | ev->event.notify60->uin, ev->event.notify60->status, | |
| 1223 | ev->event.notify60->version, ev->event.notify60->descr); | |
| 11414 | 1224 | |
| 1225 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 12007 | 1226 | gaim_debug_info("gg", |
| 1227 | "notify60: (%d) status=%d; version=%d; descr=%s\n", | |
| 1228 | ev->event.notify60[i].uin, | |
| 1229 | ev->event.notify60[i].status, | |
| 1230 | ev->event.notify60[i].version, | |
| 1231 | ev->event.notify60[i].descr); | |
| 11414 | 1232 | |
| 12007 | 1233 | ggp_generic_status_handler(gc, ev->event.notify60[i].uin, |
| 1234 | ev->event.notify60[i].status, | |
| 1235 | ev->event.notify60[i].descr); | |
| 11414 | 1236 | } |
| 1237 | break; | |
| 1238 | case GG_EVENT_STATUS: | |
| 1239 | gaim_debug_info("gg", "status: (%d) status=%d; descr=%s\n", | |
| 1240 | ev->event.status.uin, ev->event.status.status, | |
| 1241 | ev->event.status.descr); | |
| 1242 | ||
| 12007 | 1243 | ggp_generic_status_handler(gc, ev->event.status.uin, |
| 1244 | ev->event.status.status, ev->event.status.descr); | |
| 11414 | 1245 | break; |
| 1246 | case GG_EVENT_STATUS60: | |
| 12007 | 1247 | gaim_debug_info("gg", |
| 1248 | "status60: (%d) status=%d; version=%d; descr=%s\n", | |
| 1249 | ev->event.status60.uin, ev->event.status60.status, | |
| 1250 | ev->event.status60.version, ev->event.status60.descr); | |
| 11414 | 1251 | |
| 12007 | 1252 | ggp_generic_status_handler(gc, ev->event.status60.uin, |
| 1253 | ev->event.status60.status, ev->event.status60.descr); | |
| 11414 | 1254 | break; |
| 1255 | case GG_EVENT_USERLIST: | |
| 1256 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 1257 | gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); | |
| 12220 | 1258 | gaim_notify_info(gc, NULL, |
| 1259 | _("Buddy list downloaded"), | |
| 1260 | _("Your buddy list was downloaded from the server.")); | |
| 11414 | 1261 | if (ev->event.userlist.reply != NULL) { |
| 12007 | 1262 | ggp_buddylist_load(gc, ev->event.userlist.reply); |
| 11414 | 1263 | } |
| 1264 | } else { | |
| 12220 | 1265 | gaim_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
| 1266 | gaim_notify_info(gc, NULL, | |
| 1267 | _("Buddy list uploaded"), | |
| 1268 | _("Your buddy list was stored on the server.")); | |
| 11414 | 1269 | } |
| 1270 | break; | |
| 1271 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 12007 | 1272 | ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
| 1273 | break; | |
| 1274 | default: | |
| 1275 | gaim_debug_error("gg", | |
| 1276 | "unsupported event type=%d\n", ev->type); | |
| 1277 | break; | |
| 1278 | } | |
| 11414 | 1279 | |
| 12007 | 1280 | gg_free_event(ev); |
| 1281 | } | |
| 1282 | /* }}} */ | |
| 11414 | 1283 | |
| 12007 | 1284 | /* |
| 1285 | */ | |
| 1286 | /* static void ggp_async_login_handler(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 1287 | static void ggp_async_login_handler(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 1288 | { | |
| 1289 | GaimConnection *gc = _gc; | |
| 1290 | GGPInfo *info = gc->proto_data; | |
| 1291 | struct gg_event *ev; | |
| 11414 | 1292 | |
| 12007 | 1293 | gaim_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
| 1294 | info->session->check, info->session->state); | |
| 11414 | 1295 | |
| 12007 | 1296 | switch (info->session->state) { |
| 1297 | case GG_STATE_RESOLVING: | |
| 1298 | gaim_debug_info("gg", "GG_STATE_RESOLVING\n"); | |
| 1299 | break; | |
| 1300 | case GG_STATE_CONNECTING_HUB: | |
| 1301 | gaim_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); | |
| 1302 | break; | |
| 1303 | case GG_STATE_READING_DATA: | |
| 1304 | gaim_debug_info("gg", "GG_STATE_READING_DATA\n"); | |
| 1305 | break; | |
| 1306 | case GG_STATE_CONNECTING_GG: | |
| 1307 | gaim_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); | |
| 1308 | break; | |
| 1309 | case GG_STATE_READING_KEY: | |
| 1310 | gaim_debug_info("gg", "GG_STATE_READING_KEY\n"); | |
| 1311 | break; | |
| 1312 | case GG_STATE_READING_REPLY: | |
| 1313 | gaim_debug_info("gg", "GG_STATE_READING_REPLY\n"); | |
| 11414 | 1314 | break; |
| 1315 | default: | |
| 12007 | 1316 | gaim_debug_error("gg", "unknown state = %d\n", |
| 1317 | info->session->state); | |
| 1318 | break; | |
| 1319 | } | |
| 1320 | ||
| 1321 | if (!(ev = gg_watch_fd(info->session))) { | |
| 1322 | gaim_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); | |
| 1323 | gaim_connection_error(gc, _("Unable to read socket")); | |
| 1324 | return; | |
| 1325 | } | |
| 1326 | gaim_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); | |
| 1327 | gaim_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | |
| 1328 | info->session->check, info->session->state); | |
| 1329 | ||
| 1330 | gaim_input_remove(gc->inpa); | |
| 1331 | ||
| 1332 | /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ | |
| 1333 | gc->inpa = gaim_input_add(info->session->fd, | |
| 1334 | (info->session->check == 1) ? GAIM_INPUT_WRITE | |
| 1335 | : GAIM_INPUT_READ, | |
| 1336 | ggp_async_login_handler, gc); | |
| 1337 | ||
| 1338 | switch (ev->type) { | |
| 1339 | case GG_EVENT_NONE: | |
| 1340 | /* Nothing happened. */ | |
| 1341 | gaim_debug_info("gg", "GG_EVENT_NONE\n"); | |
| 1342 | break; | |
| 1343 | case GG_EVENT_CONN_SUCCESS: | |
| 12964 | 1344 | { |
| 1345 | GaimAccount *account; | |
| 1346 | GaimPresence *presence; | |
| 1347 | GaimStatus *status; | |
| 1348 | ||
| 1349 | gaim_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); | |
| 1350 | gaim_input_remove(gc->inpa); | |
| 1351 | gc->inpa = gaim_input_add(info->session->fd, | |
| 1352 | GAIM_INPUT_READ, | |
| 1353 | ggp_callback_recv, gc); | |
| 12007 | 1354 | |
| 12964 | 1355 | /* gg_change_status(info->session, GG_STATUS_AVAIL); */ |
| 1356 | ||
| 1357 | account = gaim_connection_get_account(gc); | |
| 1358 | presence = gaim_account_get_presence(account); | |
| 1359 | status = gaim_presence_get_active_status(presence); | |
| 1360 | ||
| 1361 | ggp_set_status(account, status); | |
| 1362 | gaim_connection_set_state(gc, GAIM_CONNECTED); | |
| 1363 | ggp_buddylist_send(gc); | |
| 1364 | } | |
| 12007 | 1365 | break; |
| 1366 | case GG_EVENT_CONN_FAILED: | |
| 1367 | gaim_input_remove(gc->inpa); | |
| 1368 | gc->inpa = 0; | |
| 1369 | gaim_connection_error(gc, _("Connection failed.")); | |
| 1370 | break; | |
| 1371 | default: | |
| 1372 | gaim_debug_error("gg", "strange event: %d\n", ev->type); | |
| 11414 | 1373 | break; |
| 1374 | } | |
| 1375 | ||
| 1376 | gg_free_event(ev); | |
| 1377 | } | |
| 1378 | /* }}} */ | |
| 1379 | ||
| 1380 | /* ---------------------------------------------------------------------- */ | |
| 11360 | 1381 | /* ----- GaimPluginProtocolInfo ----------------------------------------- */ |
| 1382 | /* ---------------------------------------------------------------------- */ | |
| 1383 | ||
| 1384 | /* static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) {{{ */ | |
| 1385 | static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) | |
| 1386 | { | |
| 1387 | return "gadu-gadu"; | |
| 1388 | } | |
| 1389 | /* }}} */ | |
| 1390 | ||
| 1391 | /* static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) {{{ */ | |
| 12007 | 1392 | static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
| 1393 | const char **nw, const char **ne) | |
| 11360 | 1394 | { |
| 1395 | GaimPresence *presence = gaim_buddy_get_presence(b); | |
| 1396 | ||
| 1397 | /* | |
| 1398 | * Note to myself: | |
| 1399 | * The only valid status types are those defined | |
| 1400 | * in prpl_info->status_types. | |
| 1401 | * | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1402 | * Usable icons: away, blocked, dnd, extended_away, |
| 11360 | 1403 | * freeforchat, ignored, invisible, na, offline. |
| 1404 | */ | |
| 1405 | ||
| 1406 | if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 1407 | *se = "offline"; | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1408 | } else if (gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_AWAY)) { |
| 11360 | 1409 | *se = "away"; |
| 1410 | } else if (gaim_presence_is_status_active(presence, "blocked")) { | |
| 1411 | *se = "blocked"; | |
| 1412 | } | |
| 2393 | 1413 | } |
| 11360 | 1414 | /* }}} */ |
| 2393 | 1415 | |
| 11360 | 1416 | /* static char *ggp_status_text(GaimBuddy *b) {{{ */ |
| 1417 | static char *ggp_status_text(GaimBuddy *b) | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1418 | { |
| 11360 | 1419 | GaimStatus *status; |
| 1420 | const char *msg; | |
| 1421 | char *text; | |
| 1422 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1423 | |
| 11360 | 1424 | status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1425 | |
| 11360 | 1426 | msg = gaim_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1427 | |
| 11360 | 1428 | if (msg != NULL) { |
| 1429 | tmp = gaim_markup_strip_html(msg); | |
| 1430 | text = g_markup_escape_text(tmp, -1); | |
| 1431 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1432 | |
| 11360 | 1433 | return text; |
| 1434 | } else { | |
| 1435 | tmp = g_strdup(gaim_status_get_name(status)); | |
| 1436 | text = g_markup_escape_text(tmp, -1); | |
| 1437 | g_free(tmp); | |
| 1438 | ||
| 1439 | return text; | |
| 8997 | 1440 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1441 | } |
| 11360 | 1442 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1443 | |
|
12970
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12964
diff
changeset
|
1444 | /* static void ggp_tooltip_text(GaimBuddy *b, GString *str, gboolean full) {{{ */ |
|
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12964
diff
changeset
|
1445 | static void ggp_tooltip_text(GaimBuddy *b, GString *str, gboolean full) |
| 11360 | 1446 | { |
| 1447 | GaimStatus *status; | |
| 1448 | char *text; | |
| 1449 | const char *msg, *name; | |
| 1450 | ||
| 1451 | status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
| 1452 | msg = gaim_status_get_attr_string(status, "message"); | |
| 1453 | name = gaim_status_get_name(status); | |
| 1454 | ||
| 1455 | if (msg != NULL) { | |
| 13455 | 1456 | text = g_markup_escape_text(msg, -1); |
|
12970
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12964
diff
changeset
|
1457 | g_string_append_printf(str, "\n<b>%s:</b> %s: %s", |
|
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12964
diff
changeset
|
1458 | _("Status"), name, text); |
| 11360 | 1459 | g_free(text); |
| 1460 | } else { | |
|
12970
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12964
diff
changeset
|
1461 | g_string_append_printf(str, "\n<b>%s:</b> %s", |
|
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12964
diff
changeset
|
1462 | _("Status"), name); |
| 11360 | 1463 | } |
| 1464 | } | |
| 1465 | /* }}} */ | |
| 1466 | ||
| 1467 | /* static GList *ggp_status_types(GaimAccount *account) {{{ */ | |
| 1468 | static GList *ggp_status_types(GaimAccount *account) | |
| 1469 | { | |
| 1470 | GaimStatusType *type; | |
| 1471 | GList *types = NULL; | |
| 1472 | ||
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1473 | type = gaim_status_type_new_with_attrs( |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1474 | GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1475 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1476 | NULL); |
| 11360 | 1477 | types = g_list_append(types, type); |
| 1478 | ||
| 1479 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1480 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1481 | * work. It's not used and not needed to show status of buddies. |
| 1482 | */ | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1483 | type = gaim_status_type_new_with_attrs( |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1484 | GAIM_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1485 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1486 | NULL); |
| 11360 | 1487 | types = g_list_append(types, type); |
| 1488 | ||
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1489 | type = gaim_status_type_new_with_attrs( |
|
12718
34152a2d35fc
[gaim-migrate @ 15062]
Richard Laager <rlaager@pidgin.im>
parents:
12717
diff
changeset
|
1490 | GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1491 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1492 | NULL); |
| 11360 | 1493 | types = g_list_append(types, type); |
| 1494 | ||
| 12964 | 1495 | /* |
| 1496 | * This status is necessary to display guys who are blocking *us*. | |
| 1497 | */ | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1498 | type = gaim_status_type_new_with_attrs( |
| 12641 | 1499 | GAIM_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1500 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
| 11360 | 1501 | types = g_list_append(types, type); |
| 1502 | ||
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1503 | type = gaim_status_type_new_with_attrs( |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1504 | GAIM_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1505 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1506 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1507 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1508 | |
| 11360 | 1509 | return types; |
| 1510 | } | |
| 1511 | /* }}} */ | |
| 1512 | ||
| 1513 | /* static GList *ggp_blist_node_menu(GaimBlistNode *node) {{{ */ | |
| 1514 | static GList *ggp_blist_node_menu(GaimBlistNode *node) | |
| 2393 | 1515 | { |
| 12919 | 1516 | GaimMenuAction *act; |
| 2393 | 1517 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1518 | |
| 11360 | 1519 | if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 1520 | return NULL; | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1521 | |
| 12919 | 1522 | act = gaim_menu_action_new(_("Add to chat"), |
| 1523 | GAIM_CALLBACK(ggp_bmenu_add_to_chat), | |
| 1524 | NULL, NULL); | |
| 11410 | 1525 | m = g_list_append(m, act); |
| 1526 | ||
| 12641 | 1527 | /* Using a blist node boolean here is also wrong. |
| 1528 | * Once the Block and Unblock actions are added to the core, | |
| 1529 | * this will have to go. -- rlaager */ | |
| 12007 | 1530 | if (gaim_blist_node_get_bool(node, "blocked")) { |
| 12919 | 1531 | act = gaim_menu_action_new(_("Unblock"), |
| 1532 | GAIM_CALLBACK(ggp_bmenu_block), | |
| 1533 | NULL, NULL); | |
| 12007 | 1534 | } else { |
| 12919 | 1535 | act = gaim_menu_action_new(_("Block"), |
| 1536 | GAIM_CALLBACK(ggp_bmenu_block), | |
| 1537 | NULL, NULL); | |
| 12007 | 1538 | } |
| 11394 | 1539 | m = g_list_append(m, act); |
| 2393 | 1540 | |
| 1541 | return m; | |
| 1542 | } | |
| 11360 | 1543 | /* }}} */ |
| 2393 | 1544 | |
| 11394 | 1545 | /* static GList *ggp_chat_info(GaimConnection *gc) {{{ */ |
| 1546 | static GList *ggp_chat_info(GaimConnection *gc) | |
| 1547 | { | |
| 1548 | GList *m = NULL; | |
| 1549 | struct proto_chat_entry *pce; | |
| 1550 | ||
| 1551 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1552 | pce->label = _("Chat _name:"); | |
| 1553 | pce->identifier = "name"; | |
| 1554 | pce->required = TRUE; | |
| 1555 | m = g_list_append(m, pce); | |
| 1556 | ||
| 1557 | return m; | |
| 1558 | } | |
| 1559 | /* }}} */ | |
| 1560 | ||
| 12007 | 1561 | /* static void ggp_login(GaimAccount *account) {{{ */ |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11718
diff
changeset
|
1562 | static void ggp_login(GaimAccount *account) |
| 2393 | 1563 | { |
| 13515 | 1564 | GaimConnection *gc; |
| 1565 | struct gg_login_params *glp; | |
| 1566 | GGPInfo *info; | |
| 1567 | ||
| 1568 | if (ggp_setup_proxy(account) == -1) | |
| 1569 | return; | |
| 1570 | ||
| 1571 | gc = gaim_account_get_connection(account); | |
| 1572 | glp = g_new0(struct gg_login_params, 1); | |
| 1573 | info = g_new0(GGPInfo, 1); | |
| 11360 | 1574 | |
| 12007 | 1575 | /* Probably this should be moved to *_new() function. */ |
| 11360 | 1576 | info->session = NULL; |
| 11394 | 1577 | info->chats = NULL; |
| 1578 | info->chats_count = 0; | |
| 12007 | 1579 | info->token = NULL; |
| 13641 | 1580 | info->searches = ggp_search_new(); |
| 11360 | 1581 | |
| 1582 | gc->proto_data = info; | |
| 1583 | ||
| 1584 | glp->uin = ggp_get_uin(account); | |
| 1585 | glp->password = (char *)gaim_account_get_password(account); | |
| 1586 | ||
| 12007 | 1587 | glp->async = 1; |
| 11360 | 1588 | glp->status = GG_STATUS_AVAIL; |
| 1589 | glp->tls = 0; | |
| 1590 | ||
| 1591 | info->session = gg_login(glp); | |
| 1592 | if (info->session == NULL) { | |
| 1593 | gaim_connection_error(gc, _("Connection failed.")); | |
| 1594 | g_free(glp); | |
| 1595 | return; | |
| 1596 | } | |
| 12007 | 1597 | gc->inpa = gaim_input_add(info->session->fd, GAIM_INPUT_READ, |
| 1598 | ggp_async_login_handler, gc); | |
| 11360 | 1599 | } |
| 1600 | /* }}} */ | |
| 1601 | ||
| 1602 | /* static void ggp_close(GaimConnection *gc) {{{ */ | |
| 1603 | static void ggp_close(GaimConnection *gc) | |
| 1604 | { | |
| 8997 | 1605 | |
| 11360 | 1606 | if (gc == NULL) { |
| 1607 | gaim_debug_info("gg", "gc == NULL\n"); | |
| 1608 | return; | |
| 1609 | } | |
| 1610 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1611 | if (gc->proto_data) { |
| 12964 | 1612 | GaimAccount *account = gaim_connection_get_account(gc); |
| 1613 | GaimStatus *status; | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1614 | GGPInfo *info = gc->proto_data; |
| 12964 | 1615 | |
| 1616 | status = gaim_account_get_active_status(account); | |
| 1617 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1618 | if (info->session != NULL) { |
| 12964 | 1619 | ggp_set_status(account, status); |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1620 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1621 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1622 | } |
| 13641 | 1623 | |
| 1624 | ggp_search_destroy(info->searches); | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1625 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1626 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1627 | } |
| 11360 | 1628 | |
| 1629 | if (gc->inpa > 0) | |
| 1630 | gaim_input_remove(gc->inpa); | |
| 1631 | ||
| 1632 | ggp_buddylist_offline(gc); | |
| 2393 | 1633 | |
| 11360 | 1634 | gaim_debug_info("gg", "Connection closed.\n"); |
| 1635 | } | |
| 1636 | /* }}} */ | |
| 1637 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1638 | /* static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, GaimMessageFlags flags) {{{ */ |
| 12007 | 1639 | static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1640 | GaimMessageFlags flags) |
| 11360 | 1641 | { |
| 1642 | GGPInfo *info = gc->proto_data; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1643 | char *tmp, *plain; |
| 11360 | 1644 | |
| 1645 | if (strlen(msg) == 0) | |
| 1646 | return 1; | |
| 1647 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1648 | plain = gaim_unescape_html(msg); |
| 11565 | 1649 | gaim_debug_info("gg", "ggp_send_im: msg = %s\n", msg); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1650 | tmp = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1651 | g_free(plain); |
| 2393 | 1652 | |
| 11360 | 1653 | if (tmp != NULL && strlen(tmp) > 0) { |
| 12007 | 1654 | if (gg_send_message(info->session, GG_CLASS_CHAT, |
| 1655 | ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { | |
| 11360 | 1656 | return -1; |
| 1657 | } | |
| 1658 | } | |
| 11565 | 1659 | g_free(tmp); |
| 11360 | 1660 | |
| 1661 | return 1; | |
| 1662 | } | |
| 1663 | /* }}} */ | |
| 1664 | ||
| 1665 | /* static void ggp_get_info(GaimConnection *gc, const char *name) { {{{ */ | |
| 1666 | static void ggp_get_info(GaimConnection *gc, const char *name) | |
| 1667 | { | |
| 1668 | GGPInfo *info = gc->proto_data; | |
| 1669 | GGPSearchForm *form; | |
| 13641 | 1670 | guint32 seq; |
| 2393 | 1671 | |
| 13641 | 1672 | form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); |
| 12220 | 1673 | |
| 13641 | 1674 | form->user_data = info; |
| 11360 | 1675 | form->uin = g_strdup(name); |
| 1676 | form->offset = g_strdup("0"); | |
| 1677 | form->last_uin = g_strdup("0"); | |
| 1678 | ||
| 13641 | 1679 | seq = ggp_search_start(gc, form); |
| 1680 | ggp_search_add(info->searches, seq, form); | |
| 11360 | 1681 | } |
| 1682 | /* }}} */ | |
| 1683 | ||
| 1684 | /* static void ggp_set_status(GaimAccount *account, GaimStatus *status) {{{ */ | |
| 1685 | static void ggp_set_status(GaimAccount *account, GaimStatus *status) | |
| 1686 | { | |
| 1687 | GaimConnection *gc; | |
| 1688 | GGPInfo *info; | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1689 | const char *status_id, *msg; |
| 11360 | 1690 | int new_status, new_status_descr; |
| 1691 | ||
| 1692 | if (!gaim_status_is_active(status)) | |
| 1693 | return; | |
| 1694 | ||
| 1695 | gc = gaim_account_get_connection(account); | |
| 1696 | info = gc->proto_data; | |
| 1697 | ||
| 1698 | status_id = gaim_status_get_id(status); | |
| 1699 | ||
| 12007 | 1700 | gaim_debug_info("gg", "ggp_set_status: Requested status = %s\n", |
| 1701 | status_id); | |
| 2393 | 1702 | |
| 11360 | 1703 | if (strcmp(status_id, "available") == 0) { |
| 1704 | new_status = GG_STATUS_AVAIL; | |
| 1705 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1706 | } else if (strcmp(status_id, "away") == 0) { | |
| 1707 | new_status = GG_STATUS_BUSY; | |
| 1708 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1709 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1710 | new_status = GG_STATUS_INVISIBLE; | |
| 1711 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 12964 | 1712 | } else if (strcmp(status_id, "offline") == 0) { |
| 1713 | new_status = GG_STATUS_NOT_AVAIL; | |
| 1714 | new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; | |
| 11360 | 1715 | } else { |
| 1716 | new_status = GG_STATUS_AVAIL; | |
| 1717 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 12007 | 1718 | gaim_debug_info("gg", |
| 1719 | "ggp_set_status: uknown status requested (status_id=%s)\n", | |
| 1720 | status_id); | |
| 11360 | 1721 | } |
| 4916 | 1722 | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1723 | msg = gaim_status_get_attr_string(status, "message"); |
| 11360 | 1724 | |
| 1725 | if (msg == NULL) { | |
| 1726 | gg_change_status(info->session, new_status); | |
| 1727 | } else { | |
| 12964 | 1728 | gchar *tmp, *new_msg; |
| 1729 | ||
| 13455 | 1730 | tmp = charset_convert(msg, "UTF-8", "CP1250"); |
| 1731 | new_msg = gaim_markup_strip_html(tmp); | |
| 12964 | 1732 | g_free(tmp); |
| 1733 | ||
| 13455 | 1734 | gg_change_status_descr(info->session, new_status_descr, new_msg); |
| 12964 | 1735 | g_free(new_msg); |
| 11360 | 1736 | } |
| 1737 | } | |
| 1738 | /* }}} */ | |
| 1739 | ||
| 1740 | /* static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 1741 | static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
| 1742 | { | |
| 1743 | GGPInfo *info = gc->proto_data; | |
| 1744 | ||
| 1745 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1746 | } | |
| 1747 | /* }}} */ | |
| 1748 | ||
| 1749 | /* static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 12007 | 1750 | static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, |
| 1751 | GaimGroup *group) | |
| 11360 | 1752 | { |
| 1753 | GGPInfo *info = gc->proto_data; | |
| 1754 | ||
| 1755 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1756 | } | |
| 1757 | /* }}} */ | |
| 1758 | ||
| 11394 | 1759 | /* static void ggp_join_chat(GaimConnection *gc, GHashTable *data) {{{ */ |
| 1760 | static void ggp_join_chat(GaimConnection *gc, GHashTable *data) | |
| 1761 | { | |
| 1762 | GGPInfo *info = gc->proto_data; | |
| 1763 | GGPChat *chat; | |
| 1764 | char *chat_name; | |
| 1765 | GList *l; | |
| 12961 | 1766 | GaimConversation *conv; |
| 1767 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 11394 | 1768 | |
| 1769 | chat_name = g_hash_table_lookup(data, "name"); | |
| 1770 | ||
| 1771 | if (chat_name == NULL) | |
| 1772 | return; | |
| 1773 | ||
| 1774 | gaim_debug_info("gg", "joined %s chat\n", chat_name); | |
| 1775 | ||
| 1776 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1777 | chat = l->data; | |
| 1778 | ||
| 1779 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 1780 | gaim_notify_error(gc, _("Chat error"), | |
| 12007 | 1781 | _("This chat name is already in use"), NULL); |
| 11394 | 1782 | return; |
| 1783 | } | |
| 1784 | } | |
| 1785 | ||
| 11414 | 1786 | ggp_confer_add_new(gc, chat_name); |
| 12961 | 1787 | conv = serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 1788 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | |
| 1789 | gaim_account_get_username(account), NULL, | |
| 1790 | GAIM_CBFLAGS_NONE, TRUE); | |
| 11394 | 1791 | } |
| 1792 | /* }}} */ | |
| 1793 | ||
| 1794 | /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | |
| 1795 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 1796 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 1797 | } | |
| 1798 | /* }}} */ | |
| 1799 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1800 | /* static int ggp_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) {{{ */ |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1801 | static int ggp_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) |
| 11394 | 1802 | { |
| 1803 | GaimConversation *conv; | |
| 1804 | GGPInfo *info = gc->proto_data; | |
| 1805 | GGPChat *chat = NULL; | |
| 1806 | GList *l; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1807 | char *msg, *plain; |
| 11394 | 1808 | uin_t *uins; |
| 1809 | int count = 0; | |
| 1810 | ||
| 1811 | if ((conv = gaim_find_chat(gc, id)) == NULL) | |
| 1812 | return -EINVAL; | |
| 1813 | ||
| 1814 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1815 | chat = l->data; | |
| 1816 | ||
| 1817 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 1818 | break; | |
| 1819 | } | |
| 1820 | ||
| 1821 | chat = NULL; | |
| 1822 | } | |
| 1823 | ||
| 1824 | if (chat == NULL) { | |
| 12007 | 1825 | gaim_debug_error("gg", |
| 1826 | "ggp_chat_send: Hm... that's strange. No such chat?\n"); | |
| 11394 | 1827 | return -EINVAL; |
| 1828 | } | |
| 1829 | ||
| 1830 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 12961 | 1831 | |
| 11394 | 1832 | for (l = chat->participants; l != NULL; l = l->next) { |
| 12961 | 1833 | uin_t uin = GPOINTER_TO_INT(l->data); |
| 11394 | 1834 | |
| 12961 | 1835 | uins[count++] = uin; |
| 11394 | 1836 | } |
| 1837 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1838 | plain = gaim_unescape_html(message); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1839 | msg = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1840 | g_free(plain); |
| 12007 | 1841 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
| 12961 | 1842 | (unsigned char *)msg); |
| 11394 | 1843 | g_free(msg); |
| 1844 | g_free(uins); | |
| 1845 | ||
| 12007 | 1846 | serv_got_chat_in(gc, id, |
| 1847 | gaim_account_get_username(gaim_connection_get_account(gc)), | |
| 1848 | 0, message, time(NULL)); | |
| 11394 | 1849 | |
| 1850 | return 0; | |
| 1851 | } | |
| 1852 | /* }}} */ | |
| 1853 | ||
| 11360 | 1854 | /* static void ggp_keepalive(GaimConnection *gc) {{{ */ |
| 1855 | static void ggp_keepalive(GaimConnection *gc) | |
| 1856 | { | |
| 1857 | GGPInfo *info = gc->proto_data; | |
| 1858 | ||
| 1859 | /* gaim_debug_info("gg", "Keeping connection alive....\n"); */ | |
| 1860 | ||
| 1861 | if (gg_ping(info->session) < 0) { | |
| 1862 | gaim_debug_info("gg", "Not connected to the server " | |
| 1863 | "or gg_session is not correct\n"); | |
| 1864 | gaim_connection_error(gc, _("Not connected to the server.")); | |
| 4916 | 1865 | } |
| 2393 | 1866 | } |
| 11360 | 1867 | /* }}} */ |
| 1868 | ||
| 1869 | /* static void ggp_register_user(GaimAccount *account) {{{ */ | |
| 1870 | static void ggp_register_user(GaimAccount *account) | |
| 1871 | { | |
|
11542
fabce19a4ccf
[gaim-migrate @ 13797]
Daniel Atallah <datallah@pidgin.im>
parents:
11541
diff
changeset
|
1872 | GaimConnection *gc = gaim_account_get_connection(account); |
| 11360 | 1873 | GGPInfo *info; |
| 1874 | ||
| 12007 | 1875 | info = gc->proto_data = g_new0(GGPInfo, 1); |
| 11360 | 1876 | |
| 12007 | 1877 | ggp_token_request(gc, ggp_register_user_dialog); |
| 2393 | 1878 | } |
| 11360 | 1879 | /* }}} */ |
| 2393 | 1880 | |
| 11360 | 1881 | /* static GList *ggp_actions(GaimPlugin *plugin, gpointer context) {{{ */ |
| 1882 | static GList *ggp_actions(GaimPlugin *plugin, gpointer context) | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1883 | { |
| 11360 | 1884 | GList *m = NULL; |
| 1885 | GaimPluginAction *act; | |
| 1886 | ||
| 12220 | 1887 | act = gaim_plugin_action_new(_("Find buddies..."), |
| 12007 | 1888 | ggp_find_buddies); |
| 11360 | 1889 | m = g_list_append(m, act); |
| 1890 | ||
| 1891 | m = g_list_append(m, NULL); | |
| 1892 | ||
| 12220 | 1893 | act = gaim_plugin_action_new(_("Change password..."), |
| 12007 | 1894 | ggp_change_passwd); |
| 11360 | 1895 | m = g_list_append(m, act); |
| 1896 | ||
| 1897 | m = g_list_append(m, NULL); | |
| 1898 | ||
| 12007 | 1899 | act = gaim_plugin_action_new(_("Upload buddylist to Server"), |
| 1900 | ggp_action_buddylist_put); | |
| 11360 | 1901 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1902 | |
| 12007 | 1903 | act = gaim_plugin_action_new(_("Download buddylist from Server"), |
| 1904 | ggp_action_buddylist_get); | |
| 11360 | 1905 | m = g_list_append(m, act); |
| 1906 | ||
| 12007 | 1907 | act = gaim_plugin_action_new(_("Delete buddylist from Server"), |
| 1908 | ggp_action_buddylist_delete); | |
| 11360 | 1909 | m = g_list_append(m, act); |
| 1910 | ||
| 12220 | 1911 | act = gaim_plugin_action_new(_("Save buddylist to file..."), |
| 12007 | 1912 | ggp_action_buddylist_save); |
| 11360 | 1913 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1914 | |
| 12220 | 1915 | act = gaim_plugin_action_new(_("Load buddylist from file..."), |
| 12007 | 1916 | ggp_action_buddylist_load); |
| 11360 | 1917 | m = g_list_append(m, act); |
| 1918 | ||
| 1919 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1920 | } |
| 11360 | 1921 | /* }}} */ |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1922 | |
|
13300
2003b857b5ca
[gaim-migrate @ 15665]
Richard Laager <rlaager@pidgin.im>
parents:
13298
diff
changeset
|
1923 | /* static gboolean ggp_offline_message(const GaimBuddy *buddy) {{{ */ |
|
2003b857b5ca
[gaim-migrate @ 15665]
Richard Laager <rlaager@pidgin.im>
parents:
13298
diff
changeset
|
1924 | static gboolean ggp_offline_message(const GaimBuddy *buddy) |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
1925 | { |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
1926 | return TRUE; |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
1927 | } |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
1928 | /* }}} */ |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
1929 | |
| 11360 | 1930 | /* prpl_info setup {{{ */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1931 | static GaimPluginProtocolInfo prpl_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1932 | { |
| 11360 | 1933 | OPT_PROTO_REGISTER_NOSCREENNAME, |
| 12007 | 1934 | NULL, /* user_splits */ |
| 1935 | NULL, /* protocol_options */ | |
| 9950 | 1936 | NO_BUDDY_ICONS, /* icon_spec */ |
| 11360 | 1937 | ggp_list_icon, /* list_icon */ |
| 1938 | ggp_list_emblems, /* list_emblems */ | |
| 1939 | ggp_status_text, /* status_text */ | |
| 1940 | ggp_tooltip_text, /* tooltip_text */ | |
| 1941 | ggp_status_types, /* status_types */ | |
| 12007 | 1942 | ggp_blist_node_menu, /* blist_node_menu */ |
| 11394 | 1943 | ggp_chat_info, /* chat_info */ |
| 12007 | 1944 | NULL, /* chat_info_defaults */ |
| 1945 | ggp_login, /* login */ | |
| 1946 | ggp_close, /* close */ | |
| 11360 | 1947 | ggp_send_im, /* send_im */ |
| 12007 | 1948 | NULL, /* set_info */ |
| 1949 | NULL, /* send_typing */ | |
| 11360 | 1950 | ggp_get_info, /* get_info */ |
| 1951 | ggp_set_status, /* set_away */ | |
| 12007 | 1952 | NULL, /* set_idle */ |
| 1953 | NULL, /* change_passwd */ | |
| 11360 | 1954 | ggp_add_buddy, /* add_buddy */ |
| 12007 | 1955 | NULL, /* add_buddies */ |
| 11360 | 1956 | ggp_remove_buddy, /* remove_buddy */ |
| 12007 | 1957 | NULL, /* remove_buddies */ |
| 1958 | NULL, /* add_permit */ | |
| 1959 | NULL, /* add_deny */ | |
| 1960 | NULL, /* rem_permit */ | |
| 1961 | NULL, /* rem_deny */ | |
| 1962 | NULL, /* set_permit_deny */ | |
| 11394 | 1963 | ggp_join_chat, /* join_chat */ |
| 12007 | 1964 | NULL, /* reject_chat */ |
| 11394 | 1965 | ggp_get_chat_name, /* get_chat_name */ |
| 12007 | 1966 | NULL, /* chat_invite */ |
| 1967 | NULL, /* chat_leave */ | |
| 1968 | NULL, /* chat_whisper */ | |
| 11394 | 1969 | ggp_chat_send, /* chat_send */ |
| 11360 | 1970 | ggp_keepalive, /* keepalive */ |
| 1971 | ggp_register_user, /* register_user */ | |
| 12007 | 1972 | NULL, /* get_cb_info */ |
| 1973 | NULL, /* get_cb_away */ | |
| 1974 | NULL, /* alias_buddy */ | |
| 1975 | NULL, /* group_buddy */ | |
| 1976 | NULL, /* rename_group */ | |
| 1977 | NULL, /* buddy_free */ | |
| 1978 | NULL, /* convo_closed */ | |
| 1979 | NULL, /* normalize */ | |
| 1980 | NULL, /* set_buddy_icon */ | |
| 1981 | NULL, /* remove_group */ | |
| 1982 | NULL, /* get_cb_real_name */ | |
| 1983 | NULL, /* set_chat_topic */ | |
| 1984 | NULL, /* find_blist_chat */ | |
| 1985 | NULL, /* roomlist_get_list */ | |
| 1986 | NULL, /* roomlist_cancel */ | |
| 1987 | NULL, /* roomlist_expand_category */ | |
| 1988 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12007
diff
changeset
|
1989 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1990 | NULL, /* new_xfer */ |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
1991 | ggp_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1992 | NULL, /* whiteboard_prpl_ops */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1993 | }; |
| 11360 | 1994 | /* }}} */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1995 | |
| 11360 | 1996 | /* GaimPluginInfo setup {{{ */ |
| 1997 | static GaimPluginInfo info = { | |
| 1998 | GAIM_PLUGIN_MAGIC, /* magic */ | |
| 1999 | GAIM_MAJOR_VERSION, /* major_version */ | |
| 2000 | GAIM_MINOR_VERSION, /* minor_version */ | |
| 2001 | GAIM_PLUGIN_PROTOCOL, /* plugin type */ | |
| 2002 | NULL, /* ui_requirement */ | |
| 2003 | 0, /* flags */ | |
| 2004 | NULL, /* dependencies */ | |
| 2005 | GAIM_PRIORITY_DEFAULT, /* priority */ | |
| 2006 | ||
| 2007 | "prpl-gg", /* id */ | |
| 2008 | "Gadu-Gadu", /* name */ | |
| 2009 | VERSION, /* version */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2010 | |
| 11360 | 2011 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 2012 | N_("Polish popular IM"), /* description */ | |
| 2013 | "boler@sourceforge.net", /* author */ | |
| 2014 | GAIM_WEBSITE, /* homepage */ | |
| 2015 | ||
| 2016 | NULL, /* load */ | |
| 2017 | NULL, /* unload */ | |
| 2018 | NULL, /* destroy */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2019 | |
| 11360 | 2020 | NULL, /* ui_info */ |
| 2021 | &prpl_info, /* extra_info */ | |
| 2022 | NULL, /* prefs_info */ | |
| 2023 | ggp_actions /* actions */ | |
| 2024 | }; | |
| 2025 | /* }}} */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2026 | |
| 11565 | 2027 | /* static void gaim_gg_debug_handler(int level, const char * format, va_list args) {{{ */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2028 | static void gaim_gg_debug_handler(int level, const char * format, va_list args) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2029 | GaimDebugLevel gaim_level; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2030 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2031 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2032 | /* This is pretty pointless since the GG_DEBUG levels don't correspond to |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2033 | * the gaim ones */ |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2034 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2035 | case GG_DEBUG_FUNCTION: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2036 | gaim_level = GAIM_DEBUG_INFO; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2037 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2038 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2039 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2040 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2041 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2042 | default: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2043 | gaim_level = GAIM_DEBUG_MISC; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2044 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2045 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2046 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2047 | gaim_debug(gaim_level, "gg", msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2048 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2049 | } |
| 11565 | 2050 | /* }}} */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2051 | |
| 11360 | 2052 | /* |
| 2053 | */ | |
| 2054 | /* static void init_plugin(GaimPlugin *plugin) {{{ */ | |
| 2055 | static void init_plugin(GaimPlugin *plugin) | |
| 2393 | 2056 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
2057 | GaimAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2058 | |
| 12007 | 2059 | option = gaim_account_option_string_new(_("Nickname"), |
| 2060 | "nick", _("Gadu-Gadu User")); | |
| 2061 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2062 | option); | |
| 3572 | 2063 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2064 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2065 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2066 | gg_debug_handler = gaim_gg_debug_handler; |
| 2393 | 2067 | } |
| 11360 | 2068 | /* }}} */ |
| 2393 | 2069 | |
|
11909
a0a7331365e1
[gaim-migrate @ 14200]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2070 | GAIM_INIT_PLUGIN(gg, init_plugin, info); |
| 11360 | 2071 | |
| 12007 | 2072 | /* vim: set ts=8 sts=0 sw=8 noet: */ |