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