Tue, 17 Jan 2006 23:22:19 +0000
[gaim-migrate @ 15272]
Replace GaimBlistNodeAction with the more generic GaimMenuAction, this is in
preparation for letting the chat room user list have extensible menus like the
blist entries do. (I know it's not exactly the prettiest, and the callback
isn't exactly type-safe, when we eventually gobjectify everything we can get
some safety back by using (GObject, gpointer) but that's for later.)
I'm planning to look into merging GaimPluginActions into GaimMenuActions as
well.
| 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 | ||
| 11360 | 28 | |
| 2393 | 29 | /* |
| 11360 | 30 | * NOTES |
| 2393 | 31 | * |
| 11360 | 32 | * I don't like automatic updates of the buddylist stored on the server, so not |
| 33 | * going to implement this. Maybe some kind of option to enable/disable this | |
| 34 | * feature. | |
| 2393 | 35 | */ |
| 11360 | 36 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
37 | #include "internal.h" |
| 2393 | 38 | |
| 11360 | 39 | #include "plugin.h" |
| 40 | #include "version.h" | |
| 41 | #include "notify.h" | |
| 42 | #include "status.h" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
43 | #include "blist.h" |
| 11360 | 44 | #include "accountopt.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
45 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
46 | #include "util.h" |
| 11360 | 47 | #include "request.h" |
| 2393 | 48 | |
| 11360 | 49 | #include "lib/libgadu.h" |
| 5603 | 50 | |
| 11414 | 51 | #include "gg.h" |
| 52 | #include "confer.h" | |
| 53 | #include "search.h" | |
| 54 | #include "buddylist.h" | |
| 55 | #include "utils.h" | |
| 11394 | 56 | |
| 11414 | 57 | static GaimPlugin *my_protocol = NULL; |
| 11394 | 58 | |
| 11360 | 59 | /* ---------------------------------------------------------------------- */ |
| 11414 | 60 | /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ |
| 11360 | 61 | /* ---------------------------------------------------------------------- */ |
| 9950 | 62 | |
| 12007 | 63 | |
| 64 | /* ----- HELPERS -------------------------------------------------------- */ | |
| 65 | ||
| 66 | /* | |
| 67 | */ | |
| 68 | /* static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 69 | static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 70 | { | |
| 71 | GaimConnection *gc = _gc; | |
| 72 | GGPInfo *info = gc->proto_data; | |
| 73 | GGPToken *token = info->token; | |
| 74 | GGPTokenCallback cb; | |
| 75 | ||
| 76 | struct gg_token *t = NULL; | |
| 77 | ||
| 78 | gaim_debug_info("gg", "token_handler: token->req->fd = %d\n", token->req->fd); | |
| 79 | gaim_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n", | |
| 80 | token->req->check, token->req->state); | |
| 81 | ||
| 82 | if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) { | |
| 83 | gaim_debug_error("gg", "token error (1): %d\n", token->req->error); | |
| 84 | gaim_input_remove(token->inpa); | |
| 85 | gg_token_free(token->req); | |
| 86 | token->req = NULL; | |
| 87 | ||
| 88 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 89 | _("Token Error"), | |
| 90 | _("Unable to fetch the token.\n"), NULL); | |
| 91 | return; | |
| 92 | } | |
| 93 | ||
| 94 | if (token->req->state != GG_STATE_DONE) { | |
| 95 | gaim_input_remove(token->inpa); | |
| 96 | token->inpa = gaim_input_add(token->req->fd, | |
| 97 | (token->req->check == 1) | |
| 98 | ? GAIM_INPUT_WRITE | |
| 99 | : GAIM_INPUT_READ, | |
| 100 | ggp_async_token_handler, gc); | |
| 101 | return; | |
| 102 | } | |
| 103 | ||
| 104 | if (!(t = token->req->data) || !token->req->body) { | |
| 105 | gaim_debug_error("gg", "token error (2): %d\n", token->req->error); | |
| 106 | gaim_input_remove(token->inpa); | |
| 107 | gg_token_free(token->req); | |
| 108 | token->req = NULL; | |
| 109 | ||
| 110 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 111 | _("Token Error"), | |
| 112 | _("Unable to fetch the token.\n"), NULL); | |
| 113 | return; | |
| 114 | } | |
| 115 | ||
| 116 | gaim_input_remove(token->inpa); | |
| 117 | ||
| 118 | token->id = g_strdup(t->tokenid); | |
| 119 | token->size = token->req->body_size; | |
| 120 | token->data = g_new0(char, token->size); | |
| 121 | memcpy(token->data, token->req->body, token->size); | |
| 122 | ||
| 123 | gaim_debug_info("gg", "TOKEN! tokenid = %s; size = %d\n", | |
| 124 | token->id, token->size); | |
| 125 | ||
| 126 | gg_token_free(token->req); | |
| 127 | token->req = NULL; | |
| 128 | token->inpa = 0; | |
| 129 | ||
| 130 | cb = token->cb; | |
| 131 | token->cb = NULL; | |
| 132 | cb(gc); | |
| 133 | } | |
| 134 | /* }}} */ | |
| 135 | ||
| 136 | /* | |
| 137 | */ | |
| 138 | /* static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) {{{ */ | |
| 139 | static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) | |
| 140 | { | |
| 141 | GGPInfo *info = gc->proto_data; | |
| 142 | struct gg_http *req; | |
| 143 | ||
| 144 | if ((req = gg_token(1)) == NULL) { | |
| 145 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 146 | _("Token Error"), | |
| 147 | _("Unable to fetch the token.\n"), NULL); | |
| 148 | return; | |
| 149 | } | |
| 150 | ||
| 151 | info->token = g_new(GGPToken, 1); | |
| 152 | info->token->cb = cb; | |
| 153 | ||
| 154 | info->token->req = req; | |
| 155 | info->token->inpa = gaim_input_add(req->fd, GAIM_INPUT_READ, | |
| 156 | ggp_async_token_handler, gc); | |
| 157 | } | |
| 158 | /* }}} */ | |
| 159 | ||
| 160 | /* ---------------------------------------------------------------------- */ | |
| 161 | ||
| 11360 | 162 | /** |
| 163 | * Request buddylist from the server. | |
| 164 | * Buddylist is received in the ggp_callback_recv(). | |
| 165 | * | |
| 166 | * @param Current action handler. | |
| 167 | */ | |
| 168 | /* static void ggp_action_buddylist_get(GaimPluginAction *action) {{{ */ | |
| 169 | static void ggp_action_buddylist_get(GaimPluginAction *action) | |
| 170 | { | |
| 171 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 172 | GGPInfo *info = gc->proto_data; | |
| 173 | ||
| 174 | gaim_debug_info("gg", "Downloading...\n"); | |
| 175 | ||
| 176 | gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | |
| 177 | } | |
| 178 | /* }}} */ | |
| 179 | ||
| 180 | /** | |
| 181 | * Upload the buddylist to the server. | |
| 182 | * | |
| 183 | * @param action Current action handler. | |
| 184 | */ | |
| 185 | /* static void ggp_action_buddylist_put(GaimPluginAction *action) {{{ */ | |
| 186 | static void ggp_action_buddylist_put(GaimPluginAction *action) | |
| 187 | { | |
| 188 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 189 | GGPInfo *info = gc->proto_data; | |
| 190 | ||
| 191 | char *buddylist = ggp_buddylist_dump(gaim_connection_get_account(gc)); | |
| 192 | ||
| 193 | gaim_debug_info("gg", "Uploading...\n"); | |
| 194 | ||
| 195 | if (buddylist == NULL) | |
| 196 | return; | |
| 197 | ||
| 198 | gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist); | |
| 199 | g_free(buddylist); | |
| 200 | } | |
| 201 | /* }}} */ | |
| 202 | ||
| 203 | /** | |
| 204 | * Delete buddylist from the server. | |
| 205 | * | |
| 206 | * @param action Current action handler. | |
| 207 | */ | |
| 208 | /* static void ggp_action_buddylist_delete(GaimPluginAction *action) {{{ */ | |
| 209 | static void ggp_action_buddylist_delete(GaimPluginAction *action) | |
| 210 | { | |
| 211 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 212 | GGPInfo *info = gc->proto_data; | |
| 213 | ||
| 214 | gaim_debug_info("gg", "Deleting...\n"); | |
| 215 | ||
| 216 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 217 | } | |
| 218 | /* }}} */ | |
| 219 | ||
| 220 | /* | |
| 221 | */ | |
| 222 | /* static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 223 | static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) | |
| 224 | { | |
| 225 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 226 | ||
| 227 | FILE *fh; | |
| 228 | char *buddylist = ggp_buddylist_dump(account); | |
| 229 | gchar *msg; | |
| 230 | ||
| 231 | gaim_debug_info("gg", "Saving...\n"); | |
| 232 | gaim_debug_info("gg", "file = %s\n", file); | |
| 233 | ||
| 234 | if (buddylist == NULL) { | |
| 235 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 12007 | 236 | _("Your buddylist is empty, nothing was written to the file."), |
| 237 | NULL); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
238 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
239 | } |
| 2393 | 240 | |
| 11360 | 241 | if ((fh = g_fopen(file, "wb")) == NULL) { |
| 242 | msg = g_strconcat(_("Couldn't open file"), ": ", file, "\n", NULL); | |
| 243 | gaim_debug_error("gg", "Could not open file: %s\n", file); | |
| 244 | gaim_notify_error(account, _("Couldn't open file"), msg, NULL); | |
| 245 | g_free(msg); | |
| 246 | g_free(file); | |
| 247 | return; | |
| 248 | } | |
| 249 | ||
| 250 | fwrite(buddylist, sizeof(char), g_utf8_strlen(buddylist, -1), fh); | |
| 251 | fclose(fh); | |
| 252 | g_free(buddylist); | |
| 253 | ||
| 254 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 255 | _("Buddylist saved successfully!"), NULL); | |
| 256 | } | |
| 257 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
258 | |
| 11360 | 259 | /* |
| 260 | */ | |
| 261 | /* static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 262 | static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) | |
| 263 | { | |
| 264 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 12007 | 265 | GError *error = NULL; |
| 266 | char *buddylist = NULL; | |
| 267 | gsize length; | |
| 11360 | 268 | |
| 269 | gaim_debug_info("gg", "file_name = %s\n", file); | |
| 270 | ||
| 12007 | 271 | if (!g_file_get_contents(file, &buddylist, &length, &error)) { |
| 272 | gaim_notify_error(account, | |
| 273 | _("Couldn't load buddylist"), | |
| 274 | _("Couldn't load buddylist"), | |
| 275 | error->message); | |
| 276 | ||
| 277 | gaim_debug_error("gg", | |
| 278 | "Couldn't load buddylist. file = %s; error = %s\n", | |
| 279 | file, error->message); | |
| 280 | ||
| 281 | g_error_free(error); | |
| 282 | ||
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
283 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
284 | } |
| 11360 | 285 | |
| 286 | ggp_buddylist_load(gc, buddylist); | |
| 287 | g_free(buddylist); | |
| 288 | ||
| 289 | gaim_notify_info(account, | |
| 290 | _("Load Buddylist..."), | |
| 291 | _("Buddylist loaded successfully!"), NULL); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
292 | } |
| 11360 | 293 | /* }}} */ |
| 294 | ||
| 295 | /* | |
| 296 | */ | |
| 297 | /* static void ggp_action_buddylist_save(GaimPluginAction *action) {{{ */ | |
| 298 | static void ggp_action_buddylist_save(GaimPluginAction *action) | |
| 299 | { | |
| 300 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 301 | ||
| 302 | gaim_request_file(action, _("Save buddylist..."), NULL, TRUE, | |
| 12007 | 303 | G_CALLBACK(ggp_callback_buddylist_save_ok), NULL, gc); |
| 11360 | 304 | } |
| 305 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
306 | |
| 11360 | 307 | /* |
| 308 | */ | |
| 309 | /* static void ggp_action_buddylist_load(GaimPluginAction *action) {{{ */ | |
| 310 | static void ggp_action_buddylist_load(GaimPluginAction *action) | |
| 311 | { | |
| 312 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 313 | ||
| 314 | gaim_request_file(action, "Load buddylist from file...", NULL, FALSE, | |
| 12007 | 315 | G_CALLBACK(ggp_callback_buddylist_load_ok), NULL, gc); |
| 11360 | 316 | } |
| 317 | /* }}} */ | |
| 318 | ||
| 319 | /* | |
| 320 | */ | |
| 11414 | 321 | /* static void ggp_callback_register_account_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 12007 | 322 | static void ggp_callback_register_account_ok(GaimConnection *gc, |
| 323 | GaimRequestFields *fields) | |
| 11414 | 324 | { |
| 325 | GaimAccount *account; | |
| 326 | GGPInfo *info = gc->proto_data; | |
| 327 | struct gg_http *h = NULL; | |
| 328 | struct gg_pubdir *s; | |
| 329 | uin_t uin; | |
| 330 | gchar *email, *p1, *p2, *t; | |
| 12007 | 331 | GGPToken *token = info->token; |
| 11414 | 332 | |
| 333 | email = charset_convert(gaim_request_fields_get_string(fields, "email"), | |
| 334 | "UTF-8", "CP1250"); | |
| 335 | p1 = charset_convert(gaim_request_fields_get_string(fields, "password1"), | |
| 336 | "UTF-8", "CP1250"); | |
| 337 | p2 = charset_convert(gaim_request_fields_get_string(fields, "password2"), | |
| 338 | "UTF-8", "CP1250"); | |
| 339 | t = charset_convert(gaim_request_fields_get_string(fields, "token"), | |
| 340 | "UTF-8", "CP1250"); | |
| 341 | ||
| 342 | account = gaim_connection_get_account(gc); | |
| 343 | ||
| 344 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 345 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
346 | gaim_connection_error(gc, _("Fill in the registration fields.")); |
| 11414 | 347 | goto exit_err; |
| 348 | } | |
| 349 | ||
| 350 | if (g_utf8_collate(p1, p2) != 0) { | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
351 | gaim_connection_error(gc, _("Passwords do not match.")); |
| 11414 | 352 | goto exit_err; |
| 353 | } | |
| 354 | ||
| 12007 | 355 | gaim_debug_info("gg", "register_account_ok: token_id = %d; t = %s\n", |
| 356 | token->id, t); | |
| 357 | h = gg_register3(email, p1, token->id, t, 0); | |
| 11414 | 358 | if (h == NULL || !(s = h->data) || !s->success) { |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
359 | gaim_connection_error(gc, |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
360 | _("Unable to register new account. Error occurred.\n")); |
| 11414 | 361 | goto exit_err; |
| 362 | } | |
| 363 | ||
| 364 | uin = s->uin; | |
| 365 | gaim_debug_info("gg", "registered uin: %d\n", uin); | |
| 366 | ||
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
367 | g_free(t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
368 | t = g_strdup_printf("%u", uin); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
369 | gaim_account_set_username(account, t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
370 | /* Save the password if remembering passwords for the account */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
371 | gaim_account_set_password(account, p1); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
372 | |
| 11414 | 373 | gaim_notify_info(NULL, _("New Gadu-Gadu Account Registered"), |
| 374 | _("Registration completed successfully!"), NULL); | |
| 375 | ||
| 12007 | 376 | /* TODO: the currently open Accounts Window will not be updated withthe |
| 377 | * new username and etc, we need to somehow have it refresh at this | |
| 378 | * point | |
| 379 | */ | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
380 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
381 | /* Need to disconnect or actually log in. For now, we disconnect. */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
382 | gaim_connection_destroy(gc); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
383 | |
| 11414 | 384 | exit_err: |
| 385 | gg_register_free(h); | |
| 386 | g_free(email); | |
| 387 | g_free(p1); | |
| 388 | g_free(p2); | |
| 389 | g_free(t); | |
| 12007 | 390 | g_free(token->id); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
391 | g_free(token); |
| 11414 | 392 | } |
| 393 | /* }}} */ | |
| 394 | ||
| 11565 | 395 | /* |
| 396 | */ | |
| 397 | /* static void ggp_callback_register_account_cancel(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 12007 | 398 | static void ggp_callback_register_account_cancel(GaimConnection *gc, |
| 399 | GaimRequestFields *fields) | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
400 | { |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
401 | GGPInfo *info = gc->proto_data; |
| 12007 | 402 | GGPToken *token = info->token; |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
403 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
404 | gaim_connection_destroy(gc); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
405 | |
| 12007 | 406 | g_free(token->id); |
| 407 | g_free(token->data); | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
408 | g_free(token); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
409 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
410 | } |
| 11565 | 411 | /* }}} */ |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
412 | |
| 12007 | 413 | /* |
| 414 | */ | |
| 415 | /* static void ggp_register_user_dialog(GaimConnection *gc) {{{ */ | |
| 416 | static void ggp_register_user_dialog(GaimConnection *gc) | |
| 417 | { | |
| 418 | GaimAccount *account; | |
| 419 | GaimRequestFields *fields; | |
| 420 | GaimRequestFieldGroup *group; | |
| 421 | GaimRequestField *field; | |
| 422 | ||
| 423 | GGPInfo *info = gc->proto_data; | |
| 424 | GGPToken *token = info->token; | |
| 425 | ||
| 426 | ||
| 427 | account = gaim_connection_get_account(gc); | |
| 428 | ||
| 429 | fields = gaim_request_fields_new(); | |
| 430 | group = gaim_request_field_group_new(NULL); | |
| 431 | gaim_request_fields_add_group(fields, group); | |
| 432 | ||
| 433 | field = gaim_request_field_string_new("email", | |
| 434 | _("e-Mail"), "", FALSE); | |
| 435 | gaim_request_field_string_set_masked(field, FALSE); | |
| 436 | gaim_request_field_group_add_field(group, field); | |
| 437 | ||
| 438 | field = gaim_request_field_string_new("password1", | |
| 439 | _("Password"), "", FALSE); | |
| 440 | gaim_request_field_string_set_masked(field, TRUE); | |
| 441 | gaim_request_field_group_add_field(group, field); | |
| 442 | ||
| 443 | field = gaim_request_field_string_new("password2", | |
| 444 | _("Password (retype)"), "", FALSE); | |
| 445 | gaim_request_field_string_set_masked(field, TRUE); | |
| 446 | gaim_request_field_group_add_field(group, field); | |
| 447 | ||
| 448 | field = gaim_request_field_string_new("token", | |
| 449 | _("Enter current token"), "", FALSE); | |
| 450 | gaim_request_field_string_set_masked(field, FALSE); | |
| 451 | gaim_request_field_group_add_field(group, field); | |
| 452 | ||
| 453 | /* original size: 60x24 */ | |
| 454 | field = gaim_request_field_image_new("token_img", | |
| 455 | _("Current token"), token->data, token->size); | |
| 456 | gaim_request_field_group_add_field(group, field); | |
| 457 | ||
| 458 | gaim_request_fields(account, | |
| 459 | _("Register New Gadu-Gadu Account"), | |
| 460 | _("Register New Gadu-Gadu Account"), | |
| 461 | _("Please, fill in the following fields"), | |
| 462 | fields, | |
| 463 | _("OK"), G_CALLBACK(ggp_callback_register_account_ok), | |
| 464 | _("Cancel"), G_CALLBACK(ggp_callback_register_account_cancel), | |
| 465 | gc); | |
| 466 | } | |
| 467 | /* }}} */ | |
| 468 | ||
| 11414 | 469 | /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ |
| 470 | ||
| 471 | /* | |
| 472 | */ | |
| 473 | /* static void ggp_callback_show_next(GaimConnection *gc, GList *row) {{{ */ | |
| 474 | static void ggp_callback_show_next(GaimConnection *gc, GList *row) | |
| 475 | { | |
| 476 | GGPInfo *info = gc->proto_data; | |
| 477 | ||
| 478 | g_free(info->search_form->offset); | |
| 479 | info->search_form->offset = g_strdup(info->search_form->last_uin); | |
| 480 | ggp_search_start(gc, info->search_form); | |
| 481 | } | |
| 482 | /* }}} */ | |
| 483 | ||
| 484 | /* | |
| 485 | */ | |
| 486 | /* static void ggp_callback_add_buddy(GaimConnection *gc, GList *row) {{{ */ | |
| 487 | static void ggp_callback_add_buddy(GaimConnection *gc, GList *row) | |
| 488 | { | |
| 489 | gaim_blist_request_add_buddy(gaim_connection_get_account(gc), | |
| 12007 | 490 | g_list_nth_data(row, 0), NULL, NULL); |
| 11414 | 491 | } |
| 492 | /* }}} */ | |
| 493 | ||
| 494 | /* | |
| 495 | */ | |
| 496 | /* static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 497 | static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) | |
| 498 | { | |
| 499 | GGPInfo *info = gc->proto_data; | |
| 500 | GGPSearchForm *form; | |
| 501 | ||
| 502 | form = ggp_search_form_new(); | |
| 503 | info->search_form = form; | |
| 504 | ||
| 12007 | 505 | form->lastname = charset_convert( |
| 506 | gaim_request_fields_get_string(fields, "lastname"), | |
| 507 | "UTF-8", "CP1250"); | |
| 508 | form->firstname = charset_convert( | |
| 509 | gaim_request_fields_get_string(fields, "firstname"), | |
| 510 | "UTF-8", "CP1250"); | |
| 511 | form->nickname = charset_convert( | |
| 512 | gaim_request_fields_get_string(fields, "nickname"), | |
| 513 | "UTF-8", "CP1250"); | |
| 514 | form->city = charset_convert( | |
| 515 | gaim_request_fields_get_string(fields, "city"), | |
| 516 | "UTF-8", "CP1250"); | |
| 517 | form->birthyear = charset_convert( | |
| 518 | gaim_request_fields_get_string(fields, "year"), | |
| 519 | "UTF-8", "CP1250"); | |
| 11414 | 520 | |
| 521 | switch (gaim_request_fields_get_choice(fields, "gender")) { | |
| 522 | case 1: | |
| 523 | form->gender = g_strdup(GG_PUBDIR50_GENDER_MALE); | |
| 524 | break; | |
| 525 | case 2: | |
| 526 | form->gender = g_strdup(GG_PUBDIR50_GENDER_FEMALE); | |
| 527 | break; | |
| 528 | default: | |
| 529 | form->gender = NULL; | |
| 530 | break; | |
| 531 | } | |
| 532 | ||
| 533 | form->active = gaim_request_fields_get_bool(fields, "active") | |
| 534 | ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL; | |
| 535 | ||
| 536 | form->offset = g_strdup("0"); | |
| 537 | ||
| 538 | ggp_search_start(gc, form); | |
| 539 | } | |
| 540 | /* }}} */ | |
| 541 | ||
| 542 | /* | |
| 543 | */ | |
| 544 | /* static void ggp_find_buddies(GaimPluginAction *action) {{{ */ | |
| 545 | static void ggp_find_buddies(GaimPluginAction *action) | |
| 546 | { | |
| 547 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 12220 | 548 | GGPInfo *info = gc->proto_data; |
| 11414 | 549 | |
| 550 | GaimRequestFields *fields; | |
| 551 | GaimRequestFieldGroup *group; | |
| 552 | GaimRequestField *field; | |
| 553 | ||
| 12220 | 554 | if (info->search_form != NULL) { |
| 555 | gaim_notify_error(gc, NULL, | |
| 556 | _("Unable to initiate a new search"), | |
| 557 | _("You have a pending search. Please wait for it to finish.")); | |
| 558 | return; | |
| 559 | } | |
| 560 | ||
| 11414 | 561 | fields = gaim_request_fields_new(); |
| 562 | group = gaim_request_field_group_new(NULL); | |
| 563 | gaim_request_fields_add_group(fields, group); | |
| 564 | ||
| 12007 | 565 | field = gaim_request_field_string_new("lastname", |
| 566 | _("Last name"), NULL, FALSE); | |
| 11414 | 567 | gaim_request_field_string_set_masked(field, FALSE); |
| 568 | gaim_request_field_group_add_field(group, field); | |
| 569 | ||
| 12007 | 570 | field = gaim_request_field_string_new("firstname", |
| 571 | _("First name"), NULL, FALSE); | |
| 11414 | 572 | gaim_request_field_string_set_masked(field, FALSE); |
| 573 | gaim_request_field_group_add_field(group, field); | |
| 574 | ||
| 12007 | 575 | field = gaim_request_field_string_new("nickname", |
| 576 | _("Nickname"), NULL, FALSE); | |
| 11414 | 577 | gaim_request_field_string_set_masked(field, FALSE); |
| 578 | gaim_request_field_group_add_field(group, field); | |
| 579 | ||
| 12007 | 580 | field = gaim_request_field_string_new("city", |
| 581 | _("City"), NULL, FALSE); | |
| 11414 | 582 | gaim_request_field_string_set_masked(field, FALSE); |
| 583 | gaim_request_field_group_add_field(group, field); | |
| 584 | ||
| 12007 | 585 | field = gaim_request_field_string_new("year", |
| 586 | _("Year of birth"), NULL, FALSE); | |
| 11414 | 587 | gaim_request_field_group_add_field(group, field); |
| 588 | ||
| 12007 | 589 | field = gaim_request_field_choice_new("gender", _("Gender"), 0); |
| 590 | gaim_request_field_choice_add(field, _("Male or female")); | |
| 591 | gaim_request_field_choice_add(field, _("Male")); | |
| 592 | gaim_request_field_choice_add(field, _("Female")); | |
| 11414 | 593 | gaim_request_field_group_add_field(group, field); |
| 594 | ||
| 12007 | 595 | field = gaim_request_field_bool_new("active", |
| 596 | _("Only online"), FALSE); | |
| 11414 | 597 | gaim_request_field_group_add_field(group, field); |
| 598 | ||
| 599 | gaim_request_fields(gc, | |
| 600 | _("Find buddies"), | |
| 601 | _("Find buddies"), | |
| 602 | _("Please, enter your search criteria below"), | |
| 603 | fields, | |
| 604 | _("OK"), G_CALLBACK(ggp_callback_find_buddies), | |
| 605 | _("Cancel"), NULL, | |
| 606 | gc); | |
| 607 | } | |
| 608 | /* }}} */ | |
| 609 | ||
| 610 | /* ----- CHANGE PASSWORD ------------------------------------------------ */ | |
| 611 | ||
| 612 | /* | |
| 613 | */ | |
| 11360 | 614 | /* static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 615 | static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 2393 | 616 | { |
| 11360 | 617 | GaimAccount *account; |
| 618 | GGPInfo *info = gc->proto_data; | |
| 619 | struct gg_http *h; | |
| 620 | gchar *cur, *p1, *p2, *t; | |
| 621 | ||
| 12007 | 622 | cur = charset_convert( |
| 623 | gaim_request_fields_get_string(fields, "password_cur"), | |
| 624 | "UTF-8", "CP1250"); | |
| 625 | p1 = charset_convert( | |
| 626 | gaim_request_fields_get_string(fields, "password1"), | |
| 627 | "UTF-8", "CP1250"); | |
| 628 | p2 = charset_convert( | |
| 629 | gaim_request_fields_get_string(fields, "password2"), | |
| 630 | "UTF-8", "CP1250"); | |
| 631 | t = charset_convert( | |
| 632 | gaim_request_fields_get_string(fields, "token"), | |
| 633 | "UTF-8", "CP1250"); | |
| 11360 | 634 | |
| 635 | account = gaim_connection_get_account(gc); | |
| 636 | ||
| 637 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 638 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 639 | gaim_notify_error(account, NULL, _("Fill in the fields."), NULL); | |
| 640 | goto exit_err; | |
| 641 | } | |
| 642 | ||
| 643 | if (g_utf8_collate(p1, p2) != 0) { | |
| 12007 | 644 | gaim_notify_error(account, NULL, |
| 645 | _("New passwords do not match."), NULL); | |
| 11360 | 646 | goto exit_err; |
| 647 | } | |
| 2393 | 648 | |
| 11360 | 649 | if (g_utf8_collate(cur, gaim_account_get_password(account)) != 0) { |
| 650 | gaim_notify_error(account, NULL, | |
| 651 | _("Your current password is different from the one that you specified."), | |
| 652 | NULL); | |
| 653 | goto exit_err; | |
| 654 | } | |
| 655 | ||
|
12457
6d2633b10f1d
[gaim-migrate @ 14766]
Casey Harkins <charkins@pidgin.im>
parents:
12373
diff
changeset
|
656 | gaim_debug_info("gg", "Changing password\n"); |
| 11360 | 657 | |
| 658 | /* XXX: this e-mail should be a pref... */ | |
| 659 | h = gg_change_passwd4(ggp_get_uin(account), | |
| 660 | "user@example.net", gaim_account_get_password(account), | |
| 12007 | 661 | p1, info->token->id, t, 0); |
| 2393 | 662 | |
| 11360 | 663 | if (h == NULL) { |
| 664 | gaim_notify_error(account, NULL, | |
| 665 | _("Unable to change password. Error occured.\n"), | |
| 666 | NULL); | |
| 667 | goto exit_err; | |
| 668 | } | |
| 669 | ||
| 670 | gaim_account_set_password(account, p1); | |
| 671 | ||
| 672 | gg_change_passwd_free(h); | |
| 673 | ||
| 674 | gaim_notify_info(account, _("Change password for the Gadu-Gadu account"), | |
| 675 | _("Password was changed successfully!"), NULL); | |
| 676 | ||
| 677 | exit_err: | |
| 678 | g_free(cur); | |
| 679 | g_free(p1); | |
| 680 | g_free(p2); | |
| 681 | g_free(t); | |
| 12007 | 682 | g_free(info->token->id); |
| 683 | g_free(info->token->data); | |
| 684 | g_free(info->token); | |
| 685 | } | |
| 686 | /* }}} */ | |
| 687 | ||
| 688 | /* | |
| 689 | */ | |
| 690 | /* static void ggp_change_passwd_dialog(GaimConnection *gc) {{{ */ | |
| 691 | static void ggp_change_passwd_dialog(GaimConnection *gc) | |
| 692 | { | |
| 693 | GaimRequestFields *fields; | |
| 694 | GaimRequestFieldGroup *group; | |
| 695 | GaimRequestField *field; | |
| 696 | ||
| 697 | GGPInfo *info = gc->proto_data; | |
| 698 | GGPToken *token = info->token; | |
| 699 | ||
| 700 | char *msg; | |
| 701 | ||
| 702 | ||
| 703 | fields = gaim_request_fields_new(); | |
| 704 | group = gaim_request_field_group_new(NULL); | |
| 705 | gaim_request_fields_add_group(fields, group); | |
| 706 | ||
| 707 | field = gaim_request_field_string_new("password_cur", | |
| 708 | _("Current password"), "", FALSE); | |
| 709 | gaim_request_field_string_set_masked(field, TRUE); | |
| 710 | gaim_request_field_group_add_field(group, field); | |
| 711 | ||
| 712 | field = gaim_request_field_string_new("password1", | |
| 713 | _("Password"), "", FALSE); | |
| 714 | gaim_request_field_string_set_masked(field, TRUE); | |
| 715 | gaim_request_field_group_add_field(group, field); | |
| 716 | ||
| 717 | field = gaim_request_field_string_new("password2", | |
| 718 | _("Password (retype)"), "", FALSE); | |
| 719 | gaim_request_field_string_set_masked(field, TRUE); | |
| 720 | gaim_request_field_group_add_field(group, field); | |
| 721 | ||
| 722 | field = gaim_request_field_string_new("token", | |
| 723 | _("Enter current token"), "", FALSE); | |
| 724 | gaim_request_field_string_set_masked(field, FALSE); | |
| 725 | gaim_request_field_group_add_field(group, field); | |
| 726 | ||
| 727 | /* original size: 60x24 */ | |
| 728 | field = gaim_request_field_image_new("token_img", | |
| 729 | _("Current token"), token->data, token->size); | |
| 730 | gaim_request_field_group_add_field(group, field); | |
| 731 | ||
| 732 | msg = g_strdup_printf("%s %d", | |
| 733 | _("Please, enter your current password and your new password for UIN: "), | |
| 734 | ggp_get_uin(gaim_connection_get_account(gc))); | |
| 735 | ||
| 736 | gaim_request_fields(gc, | |
| 737 | _("Change Gadu-Gadu Password"), | |
| 738 | _("Change Gadu-Gadu Password"), | |
| 739 | msg, | |
| 740 | fields, _("OK"), G_CALLBACK(ggp_callback_change_passwd_ok), | |
| 741 | _("Cancel"), NULL, gc); | |
| 742 | ||
| 743 | g_free(msg); | |
| 11360 | 744 | } |
| 745 | /* }}} */ | |
| 2393 | 746 | |
| 11360 | 747 | /* |
| 748 | */ | |
| 749 | /* static void ggp_change_passwd(GaimPluginAction *action) {{{ */ | |
| 750 | static void ggp_change_passwd(GaimPluginAction *action) | |
| 751 | { | |
| 752 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 753 | ||
| 12007 | 754 | ggp_token_request(gc, ggp_change_passwd_dialog); |
| 11360 | 755 | } |
| 756 | /* }}} */ | |
| 757 | ||
| 11414 | 758 | /* ----- CONFERENCES ---------------------------------------------------- */ |
| 759 | ||
| 11394 | 760 | /* |
| 761 | */ | |
| 762 | /* static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 763 | static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 764 | { | |
| 765 | GGPInfo *info = gc->proto_data; | |
| 766 | GaimRequestField *field; | |
| 767 | const GList *sel, *l; | |
| 768 | ||
| 769 | field = gaim_request_fields_get_field(fields, "name"); | |
| 770 | sel = gaim_request_field_list_get_selected(field); | |
| 12007 | 771 | gaim_debug_info("gg", "selected chat %s for buddy %s\n", |
| 772 | sel->data, info->tmp_buddy); | |
| 11394 | 773 | |
| 774 | for (l = info->chats; l != NULL; l = l->next) { | |
| 775 | GGPChat *chat = l->data; | |
| 776 | ||
| 777 | if (g_utf8_collate(chat->name, sel->data) == 0) { | |
| 12007 | 778 | chat->participants = g_list_append(chat->participants, |
| 779 | info->tmp_buddy); | |
| 11394 | 780 | break; |
| 781 | } | |
| 782 | } | |
| 783 | } | |
| 784 | /* }}} */ | |
| 785 | ||
| 786 | /* | |
| 787 | */ | |
| 788 | /* static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 789 | static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) | |
| 790 | { | |
| 791 | GaimBuddy *buddy; | |
| 792 | GaimConnection *gc; | |
| 793 | GGPInfo *info; | |
| 794 | ||
| 795 | GaimRequestFields *fields; | |
| 796 | GaimRequestFieldGroup *group; | |
| 797 | GaimRequestField *field; | |
| 798 | ||
| 799 | GList *l; | |
| 800 | gchar *msg; | |
| 801 | ||
| 802 | buddy = (GaimBuddy *)node; | |
| 803 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 804 | info = gc->proto_data; | |
| 805 | ||
| 806 | /* TODO: It tmp_buddy != NULL then stop! */ | |
| 807 | info->tmp_buddy = g_strdup(gaim_buddy_get_name(buddy)); | |
| 808 | ||
| 809 | fields = gaim_request_fields_new(); | |
| 810 | group = gaim_request_field_group_new(NULL); | |
| 811 | gaim_request_fields_add_group(fields, group); | |
| 812 | ||
| 813 | field = gaim_request_field_list_new("name", "Chat name"); | |
| 814 | for (l = info->chats; l != NULL; l = l->next) { | |
| 815 | GGPChat *chat = l->data; | |
| 816 | gaim_debug_info("gg", "adding chat %s\n", chat->name); | |
| 12007 | 817 | gaim_request_field_list_add(field, g_strdup(chat->name), |
| 818 | g_strdup(chat->name)); | |
| 11394 | 819 | } |
| 820 | gaim_request_field_group_add_field(group, field); | |
| 821 | ||
| 12007 | 822 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
| 823 | gaim_buddy_get_name(buddy)); | |
| 11394 | 824 | gaim_request_fields(gc, |
| 825 | _("Add to chat..."), | |
| 826 | _("Add to chat..."), | |
| 827 | msg, | |
| 828 | fields, | |
| 829 | _("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok), | |
| 830 | _("Cancel"), NULL, gc); | |
| 831 | g_free(msg); | |
| 832 | } | |
| 833 | /* }}} */ | |
| 834 | ||
| 11414 | 835 | /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
| 836 | ||
| 11410 | 837 | /* |
| 838 | */ | |
| 839 | /* static void ggp_bmenu_block(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 840 | static void ggp_bmenu_block(GaimBlistNode *node, gpointer ignored) | |
| 841 | { | |
| 842 | GaimConnection *gc; | |
| 843 | GaimBuddy *buddy; | |
| 844 | GGPInfo *info; | |
| 845 | uin_t uin; | |
| 846 | ||
| 847 | buddy = (GaimBuddy *)node; | |
| 848 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 849 | info = gc->proto_data; | |
| 850 | ||
| 851 | uin = ggp_str_to_uin(gaim_buddy_get_name(buddy)); | |
| 852 | ||
| 853 | if (gaim_blist_node_get_bool(node, "blocked")) { | |
| 854 | gaim_blist_node_set_bool(node, "blocked", FALSE); | |
| 855 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 856 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 857 | gaim_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); | |
| 858 | } else { | |
| 859 | gaim_blist_node_set_bool(node, "blocked", TRUE); | |
| 860 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 861 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 862 | gaim_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); | |
| 863 | } | |
| 864 | } | |
| 865 | /* }}} */ | |
| 866 | ||
| 11360 | 867 | /* ---------------------------------------------------------------------- */ |
| 11414 | 868 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 869 | /* ---------------------------------------------------------------------- */ | |
| 870 | ||
| 871 | /** | |
| 872 | * Handle change of the status of the buddy. | |
| 873 | * | |
| 874 | * @param gc GaimConnection | |
| 875 | * @param uin UIN of the buddy. | |
| 876 | * @param status ID of the status. | |
| 877 | * @param descr Description. | |
| 878 | */ | |
| 879 | /* static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, int status, const char *descr) {{{ */ | |
| 12007 | 880 | static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, |
| 881 | int status, const char *descr) | |
| 11414 | 882 | { |
| 883 | gchar *from; | |
| 884 | const char *st; | |
| 885 | gchar *msg; | |
| 886 | ||
| 887 | from = g_strdup_printf("%ld", (unsigned long int)uin); | |
| 888 | switch (status) { | |
| 889 | case GG_STATUS_NOT_AVAIL: | |
| 890 | case GG_STATUS_NOT_AVAIL_DESCR: | |
| 891 | st = "offline"; | |
| 892 | break; | |
| 893 | case GG_STATUS_AVAIL: | |
| 894 | case GG_STATUS_AVAIL_DESCR: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
895 | st = "available"; |
| 11414 | 896 | break; |
| 897 | case GG_STATUS_BUSY: | |
| 898 | case GG_STATUS_BUSY_DESCR: | |
|
12718
34152a2d35fc
[gaim-migrate @ 15062]
Richard Laager <rlaager@pidgin.im>
parents:
12717
diff
changeset
|
899 | st = "away"; |
| 11414 | 900 | break; |
| 901 | case GG_STATUS_BLOCKED: | |
| 902 | /* user is blocking us.... */ | |
| 903 | st = "blocked"; | |
| 904 | break; | |
| 905 | default: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
906 | st = "available"; |
| 12007 | 907 | gaim_debug_info("gg", |
| 908 | "GG_EVENT_NOTIFY: Unknown status: %d\n", status); | |
| 11414 | 909 | break; |
| 910 | } | |
| 911 | ||
| 912 | gaim_debug_info("gg", "st = %s\n", st); | |
| 913 | msg = charset_convert(descr, "CP1250", "UTF-8"); | |
| 12007 | 914 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), |
| 915 | from, st, "message", msg, NULL); | |
| 11414 | 916 | g_free(from); |
| 917 | g_free(msg); | |
| 918 | } | |
| 919 | /* }}} */ | |
| 920 | ||
| 12007 | 921 | /* |
| 922 | */ | |
| 12220 | 923 | /* static void ggp_sr_close_cb(GaimAccount *account) {{{ */ |
| 924 | static void ggp_sr_close_cb(GaimAccount *account) | |
| 925 | { | |
| 926 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 927 | GGPInfo *info = gc->proto_data; | |
| 928 | GGPSearchForm *f; | |
| 929 | ||
| 930 | info->searchresults_window = NULL; | |
| 931 | ||
| 932 | f = info->search_form; | |
| 933 | g_free(f->uin); | |
| 934 | g_free(f->lastname); | |
| 935 | g_free(f->firstname); | |
| 936 | g_free(f->nickname); | |
| 937 | g_free(f->city); | |
| 938 | g_free(f->birthyear); | |
| 939 | g_free(f->gender); | |
| 940 | g_free(f->active); | |
| 941 | g_free(f->offset); | |
| 942 | g_free(f->last_uin); | |
| 943 | g_free(f); | |
| 944 | ||
| 945 | info->search_form = NULL; | |
| 946 | } | |
| 947 | /* }}} */ | |
| 948 | ||
| 949 | /* | |
| 950 | */ | |
| 12007 | 951 | /* static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) {{{ */ |
| 952 | static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) | |
| 953 | { | |
| 954 | GGPInfo *info = gc->proto_data; | |
| 955 | GaimNotifySearchResults *results; | |
| 956 | GaimNotifySearchColumn *column; | |
| 957 | int res_count = 0; | |
| 958 | int start; | |
| 959 | int i; | |
| 960 | ||
| 961 | res_count = gg_pubdir50_count(req); | |
| 962 | if (res_count < 1) { | |
| 963 | gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); | |
| 12220 | 964 | gaim_notify_error(gc, NULL, |
| 965 | _("No matching users found"), | |
| 966 | _("There are no users matching your search criteria.")); | |
| 12007 | 967 | return; |
| 968 | } | |
| 969 | res_count = (res_count > 20) ? 20 : res_count; | |
| 970 | ||
| 971 | results = gaim_notify_searchresults_new(); | |
| 972 | ||
| 12257 | 973 | if (results == NULL) { |
| 974 | gaim_debug_error("gg", "ggp_pubdir_reply_handler: " | |
| 975 | "Unable to display the search results.\n"); | |
| 976 | gaim_notify_error(gc, NULL, | |
| 977 | _("Unable to display the search results."), | |
| 978 | NULL); | |
| 979 | ggp_sr_close_cb(gaim_connection_get_account(gc)); | |
| 980 | return; | |
| 981 | } | |
| 982 | ||
| 12220 | 983 | column = gaim_notify_searchresults_column_new(_("UIN")); |
| 12007 | 984 | gaim_notify_searchresults_column_add(results, column); |
| 985 | ||
| 12220 | 986 | column = gaim_notify_searchresults_column_new(_("First name")); |
| 12007 | 987 | gaim_notify_searchresults_column_add(results, column); |
| 988 | ||
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12467
diff
changeset
|
989 | column = gaim_notify_searchresults_column_new(_("Nickname")); |
| 12007 | 990 | gaim_notify_searchresults_column_add(results, column); |
| 991 | ||
| 12220 | 992 | column = gaim_notify_searchresults_column_new(_("City")); |
| 12007 | 993 | gaim_notify_searchresults_column_add(results, column); |
| 994 | ||
| 12220 | 995 | column = gaim_notify_searchresults_column_new(_("Birth year")); |
| 12007 | 996 | gaim_notify_searchresults_column_add(results, column); |
| 997 | ||
| 998 | gaim_debug_info("gg", "Going with %d entries\n", res_count); | |
| 999 | ||
| 1000 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 1001 | gaim_debug_info("gg", "start = %d\n", start); | |
| 1002 | ||
| 1003 | for (i = 0; i < res_count; i++) { | |
| 1004 | GList *row = NULL; | |
| 1005 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 1006 | ||
| 1007 | /* TODO: Status will be displayed as an icon. */ | |
| 1008 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 1009 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1010 | GG_PUBDIR50_UIN)); | |
| 1011 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1012 | GG_PUBDIR50_FIRSTNAME)); | |
| 1013 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1014 | GG_PUBDIR50_NICKNAME)); | |
| 1015 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1016 | GG_PUBDIR50_CITY)); | |
| 1017 | row = g_list_append(row, | |
| 1018 | (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 1019 | ||
| 1020 | gaim_notify_searchresults_row_add(results, row); | |
| 1021 | ||
| 1022 | if (i == res_count - 1) { | |
| 1023 | g_free(info->search_form->last_uin); | |
| 1024 | info->search_form->last_uin = ggp_search_get_result(req, i, | |
| 1025 | GG_PUBDIR50_UIN); | |
| 1026 | } | |
| 1027 | } | |
| 1028 | ||
| 1029 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_CONTINUE, | |
| 1030 | ggp_callback_show_next); | |
|
12624
c1c92f08976b
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12600
diff
changeset
|
1031 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD, |
| 12007 | 1032 | ggp_callback_add_buddy); |
| 1033 | if (info->searchresults_window == NULL) { | |
| 1034 | void *h = gaim_notify_searchresults(gc, | |
| 1035 | _("Gadu-Gadu Public Directory"), | |
| 12220 | 1036 | _("Search results"), NULL, results, |
| 12257 | 1037 | (GaimNotifyCloseCallback)ggp_sr_close_cb, |
| 12220 | 1038 | gaim_connection_get_account(gc)); |
| 12257 | 1039 | |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1040 | if (h == NULL) { |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1041 | gaim_debug_error("gg", "ggp_pubdir_reply_handler: " |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1042 | "Unable to display the search results.\n"); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1043 | gaim_notify_error(gc, NULL, |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1044 | _("Unable to display the search results."), |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1045 | NULL); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1046 | ggp_sr_close_cb(gaim_connection_get_account(gc)); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1047 | return; |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1048 | } |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1049 | |
| 12007 | 1050 | info->searchresults_window = h; |
| 1051 | } else { | |
| 1052 | gaim_notify_searchresults_new_rows(gc, results, | |
| 1053 | info->searchresults_window, NULL); | |
| 1054 | } | |
| 1055 | } | |
| 1056 | /* }}} */ | |
| 1057 | ||
| 11414 | 1058 | /** |
| 1059 | * Dispatch a message received from a buddy. | |
| 1060 | * | |
| 1061 | * @param gc GaimConnection. | |
| 1062 | * @param ev Gadu-Gadu event structure. | |
| 1063 | */ | |
| 1064 | /* static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) {{{ */ | |
| 1065 | static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) | |
| 1066 | { | |
| 1067 | GGPInfo *info = gc->proto_data; | |
| 1068 | GaimConversation *conv; | |
| 1069 | gchar *from; | |
| 1070 | gchar *msg; | |
| 1071 | gchar *tmp; | |
| 1072 | ||
| 1073 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 1074 | ||
| 1075 | msg = charset_convert((const char *)ev->event.msg.message, | |
| 12007 | 1076 | "CP1250", "UTF-8"); |
|
11920
be80617ec59b
[gaim-migrate @ 14211]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11909
diff
changeset
|
1077 | gaim_str_strip_char(msg, '\r'); |
| 11414 | 1078 | tmp = g_markup_escape_text(msg, -1); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1079 | g_free(msg); |
| 11414 | 1080 | |
| 1081 | gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", | |
| 12007 | 1082 | from, tmp, ev->event.msg.msgclass, |
| 1083 | ev->event.msg.recipients_count); | |
| 11414 | 1084 | |
| 1085 | if (ev->event.msg.recipients_count == 0) { | |
| 1086 | serv_got_im(gc, from, tmp, 0, ev->event.msg.time); | |
| 1087 | } else { | |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1088 | const char *chat_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1089 | int chat_id; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1090 | char *buddy_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1091 | |
| 11414 | 1092 | chat_name = ggp_confer_find_by_participants(gc, |
| 12007 | 1093 | ev->event.msg.recipients, |
| 1094 | ev->event.msg.recipients_count); | |
| 11414 | 1095 | if (chat_name == NULL) { |
| 1096 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 1097 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 12007 | 1098 | |
| 1099 | ggp_confer_participants_add_uin(gc, chat_name, | |
| 1100 | ev->event.msg.sender); | |
| 1101 | ||
| 1102 | ggp_confer_participants_add(gc, chat_name, | |
| 1103 | ev->event.msg.recipients, | |
| 1104 | ev->event.msg.recipients_count); | |
| 11414 | 1105 | } |
| 1106 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 1107 | 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
|
1108 | |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1109 | buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1110 | serv_got_chat_in(gc, chat_id, buddy_name, |
| 12007 | 1111 | 0, msg, ev->event.msg.time); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1112 | g_free(buddy_name); |
| 11414 | 1113 | } |
| 1114 | g_free(tmp); | |
| 1115 | g_free(from); | |
| 1116 | } | |
| 1117 | /* }}} */ | |
| 1118 | ||
| 1119 | /* | |
| 1120 | */ | |
| 1121 | /* static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 1122 | static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 1123 | { | |
| 1124 | GaimConnection *gc = _gc; | |
| 1125 | GGPInfo *info = gc->proto_data; | |
| 1126 | struct gg_event *ev; | |
| 1127 | int i; | |
| 1128 | ||
| 1129 | if (!(ev = gg_watch_fd(info->session))) { | |
| 12007 | 1130 | gaim_debug_error("gg", |
| 1131 | "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); | |
| 11414 | 1132 | gaim_connection_error(gc, _("Unable to read socket")); |
| 1133 | return; | |
| 1134 | } | |
| 1135 | ||
| 1136 | switch (ev->type) { | |
| 1137 | case GG_EVENT_NONE: | |
| 1138 | /* Nothing happened. */ | |
| 1139 | break; | |
| 1140 | case GG_EVENT_MSG: | |
| 1141 | ggp_recv_message_handler(gc, ev); | |
| 1142 | break; | |
| 1143 | case GG_EVENT_ACK: | |
| 12007 | 1144 | gaim_debug_info("gg", |
| 1145 | "message sent to: %ld, delivery status=%d, seq=%d\n", | |
| 1146 | ev->event.ack.recipient, ev->event.ack.status, | |
| 1147 | ev->event.ack.seq); | |
| 11414 | 1148 | break; |
| 1149 | case GG_EVENT_NOTIFY: | |
| 1150 | case GG_EVENT_NOTIFY_DESCR: | |
| 1151 | { | |
| 1152 | struct gg_notify_reply *n; | |
| 1153 | char *descr; | |
| 1154 | ||
| 1155 | gaim_debug_info("gg", "notify_pre: (%d) status: %d\n", | |
| 1156 | ev->event.notify->uin, | |
| 1157 | ev->event.notify->status); | |
| 1158 | ||
| 1159 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 1160 | : ev->event.notify_descr.notify; | |
| 1161 | ||
| 1162 | for (; n->uin; n++) { | |
| 1163 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 12007 | 1164 | : ev->event.notify_descr.descr; |
| 1165 | ||
| 1166 | gaim_debug_info("gg", | |
| 1167 | "notify: (%d) status: %d; descr: %s\n", | |
| 1168 | n->uin, n->status, descr); | |
| 11414 | 1169 | |
| 1170 | ggp_generic_status_handler(gc, | |
| 12007 | 1171 | n->uin, n->status, descr); |
| 11414 | 1172 | } |
| 1173 | } | |
| 1174 | break; | |
| 1175 | case GG_EVENT_NOTIFY60: | |
| 12007 | 1176 | gaim_debug_info("gg", |
| 1177 | "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", | |
| 1178 | ev->event.notify60->uin, ev->event.notify60->status, | |
| 1179 | ev->event.notify60->version, ev->event.notify60->descr); | |
| 11414 | 1180 | |
| 1181 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 12007 | 1182 | gaim_debug_info("gg", |
| 1183 | "notify60: (%d) status=%d; version=%d; descr=%s\n", | |
| 1184 | ev->event.notify60[i].uin, | |
| 1185 | ev->event.notify60[i].status, | |
| 1186 | ev->event.notify60[i].version, | |
| 1187 | ev->event.notify60[i].descr); | |
| 11414 | 1188 | |
| 12007 | 1189 | ggp_generic_status_handler(gc, ev->event.notify60[i].uin, |
| 1190 | ev->event.notify60[i].status, | |
| 1191 | ev->event.notify60[i].descr); | |
| 11414 | 1192 | } |
| 1193 | break; | |
| 1194 | case GG_EVENT_STATUS: | |
| 1195 | gaim_debug_info("gg", "status: (%d) status=%d; descr=%s\n", | |
| 1196 | ev->event.status.uin, ev->event.status.status, | |
| 1197 | ev->event.status.descr); | |
| 1198 | ||
| 12007 | 1199 | ggp_generic_status_handler(gc, ev->event.status.uin, |
| 1200 | ev->event.status.status, ev->event.status.descr); | |
| 11414 | 1201 | break; |
| 1202 | case GG_EVENT_STATUS60: | |
| 12007 | 1203 | gaim_debug_info("gg", |
| 1204 | "status60: (%d) status=%d; version=%d; descr=%s\n", | |
| 1205 | ev->event.status60.uin, ev->event.status60.status, | |
| 1206 | ev->event.status60.version, ev->event.status60.descr); | |
| 11414 | 1207 | |
| 12007 | 1208 | ggp_generic_status_handler(gc, ev->event.status60.uin, |
| 1209 | ev->event.status60.status, ev->event.status60.descr); | |
| 11414 | 1210 | break; |
| 1211 | case GG_EVENT_USERLIST: | |
| 1212 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 1213 | gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); | |
| 12220 | 1214 | gaim_notify_info(gc, NULL, |
| 1215 | _("Buddy list downloaded"), | |
| 1216 | _("Your buddy list was downloaded from the server.")); | |
| 11414 | 1217 | if (ev->event.userlist.reply != NULL) { |
| 12007 | 1218 | ggp_buddylist_load(gc, ev->event.userlist.reply); |
| 11414 | 1219 | } |
| 1220 | } else { | |
| 12220 | 1221 | gaim_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
| 1222 | gaim_notify_info(gc, NULL, | |
| 1223 | _("Buddy list uploaded"), | |
| 1224 | _("Your buddy list was stored on the server.")); | |
| 11414 | 1225 | } |
| 1226 | break; | |
| 1227 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 12007 | 1228 | ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
| 1229 | break; | |
| 1230 | default: | |
| 1231 | gaim_debug_error("gg", | |
| 1232 | "unsupported event type=%d\n", ev->type); | |
| 1233 | break; | |
| 1234 | } | |
| 11414 | 1235 | |
| 12007 | 1236 | gg_free_event(ev); |
| 1237 | } | |
| 1238 | /* }}} */ | |
| 11414 | 1239 | |
| 12007 | 1240 | /* |
| 1241 | */ | |
| 1242 | /* static void ggp_async_login_handler(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 1243 | static void ggp_async_login_handler(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 1244 | { | |
| 1245 | GaimConnection *gc = _gc; | |
| 1246 | GGPInfo *info = gc->proto_data; | |
| 1247 | struct gg_event *ev; | |
| 11414 | 1248 | |
| 12007 | 1249 | gaim_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
| 1250 | info->session->check, info->session->state); | |
| 11414 | 1251 | |
| 12007 | 1252 | switch (info->session->state) { |
| 1253 | case GG_STATE_RESOLVING: | |
| 1254 | gaim_debug_info("gg", "GG_STATE_RESOLVING\n"); | |
| 1255 | break; | |
| 1256 | case GG_STATE_CONNECTING_HUB: | |
| 1257 | gaim_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); | |
| 1258 | break; | |
| 1259 | case GG_STATE_READING_DATA: | |
| 1260 | gaim_debug_info("gg", "GG_STATE_READING_DATA\n"); | |
| 1261 | break; | |
| 1262 | case GG_STATE_CONNECTING_GG: | |
| 1263 | gaim_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); | |
| 1264 | break; | |
| 1265 | case GG_STATE_READING_KEY: | |
| 1266 | gaim_debug_info("gg", "GG_STATE_READING_KEY\n"); | |
| 1267 | break; | |
| 1268 | case GG_STATE_READING_REPLY: | |
| 1269 | gaim_debug_info("gg", "GG_STATE_READING_REPLY\n"); | |
| 11414 | 1270 | break; |
| 1271 | default: | |
| 12007 | 1272 | gaim_debug_error("gg", "unknown state = %d\n", |
| 1273 | info->session->state); | |
| 1274 | break; | |
| 1275 | } | |
| 1276 | ||
| 1277 | if (!(ev = gg_watch_fd(info->session))) { | |
| 1278 | gaim_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); | |
| 1279 | gaim_connection_error(gc, _("Unable to read socket")); | |
| 1280 | return; | |
| 1281 | } | |
| 1282 | gaim_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); | |
| 1283 | gaim_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | |
| 1284 | info->session->check, info->session->state); | |
| 1285 | ||
| 1286 | gaim_input_remove(gc->inpa); | |
| 1287 | ||
| 1288 | /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ | |
| 1289 | gc->inpa = gaim_input_add(info->session->fd, | |
| 1290 | (info->session->check == 1) ? GAIM_INPUT_WRITE | |
| 1291 | : GAIM_INPUT_READ, | |
| 1292 | ggp_async_login_handler, gc); | |
| 1293 | ||
| 1294 | switch (ev->type) { | |
| 1295 | case GG_EVENT_NONE: | |
| 1296 | /* Nothing happened. */ | |
| 1297 | gaim_debug_info("gg", "GG_EVENT_NONE\n"); | |
| 1298 | break; | |
| 1299 | case GG_EVENT_CONN_SUCCESS: | |
| 1300 | gaim_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); | |
| 1301 | gaim_input_remove(gc->inpa); | |
| 1302 | gc->inpa = gaim_input_add(info->session->fd, | |
| 1303 | GAIM_INPUT_READ, | |
| 1304 | ggp_callback_recv, gc); | |
| 1305 | ||
| 1306 | /* gg_change_status(info->session, GG_STATUS_AVAIL); */ | |
| 1307 | gaim_connection_set_state(gc, GAIM_CONNECTED); | |
| 1308 | ggp_buddylist_send(gc); | |
| 1309 | break; | |
| 1310 | case GG_EVENT_CONN_FAILED: | |
| 1311 | gaim_input_remove(gc->inpa); | |
| 1312 | gc->inpa = 0; | |
| 1313 | gaim_connection_error(gc, _("Connection failed.")); | |
| 1314 | break; | |
| 1315 | default: | |
| 1316 | gaim_debug_error("gg", "strange event: %d\n", ev->type); | |
| 11414 | 1317 | break; |
| 1318 | } | |
| 1319 | ||
| 1320 | gg_free_event(ev); | |
| 1321 | } | |
| 1322 | /* }}} */ | |
| 1323 | ||
| 1324 | /* ---------------------------------------------------------------------- */ | |
| 11360 | 1325 | /* ----- GaimPluginProtocolInfo ----------------------------------------- */ |
| 1326 | /* ---------------------------------------------------------------------- */ | |
| 1327 | ||
| 1328 | /* static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) {{{ */ | |
| 1329 | static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) | |
| 1330 | { | |
| 1331 | return "gadu-gadu"; | |
| 1332 | } | |
| 1333 | /* }}} */ | |
| 1334 | ||
| 1335 | /* static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) {{{ */ | |
| 12007 | 1336 | static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
| 1337 | const char **nw, const char **ne) | |
| 11360 | 1338 | { |
| 1339 | GaimPresence *presence = gaim_buddy_get_presence(b); | |
| 1340 | ||
| 1341 | /* | |
| 1342 | * Note to myself: | |
| 1343 | * The only valid status types are those defined | |
| 1344 | * in prpl_info->status_types. | |
| 1345 | * | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1346 | * Usable icons: away, blocked, dnd, extended_away, |
| 11360 | 1347 | * freeforchat, ignored, invisible, na, offline. |
| 1348 | */ | |
| 1349 | ||
| 1350 | if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 1351 | *se = "offline"; | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1352 | } else if (gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_AWAY)) { |
| 11360 | 1353 | *se = "away"; |
| 1354 | } else if (gaim_presence_is_status_active(presence, "blocked")) { | |
| 1355 | *se = "blocked"; | |
| 1356 | } | |
| 2393 | 1357 | } |
| 11360 | 1358 | /* }}} */ |
| 2393 | 1359 | |
| 11360 | 1360 | /* static char *ggp_status_text(GaimBuddy *b) {{{ */ |
| 1361 | static char *ggp_status_text(GaimBuddy *b) | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1362 | { |
| 11360 | 1363 | GaimStatus *status; |
| 1364 | const char *msg; | |
| 1365 | char *text; | |
| 1366 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1367 | |
| 11360 | 1368 | 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
|
1369 | |
| 11360 | 1370 | msg = gaim_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1371 | |
| 11360 | 1372 | if (msg != NULL) { |
| 1373 | tmp = gaim_markup_strip_html(msg); | |
| 1374 | text = g_markup_escape_text(tmp, -1); | |
| 1375 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1376 | |
| 11360 | 1377 | return text; |
| 1378 | } else { | |
| 1379 | tmp = g_strdup(gaim_status_get_name(status)); | |
| 1380 | text = g_markup_escape_text(tmp, -1); | |
| 1381 | g_free(tmp); | |
| 1382 | ||
| 1383 | return text; | |
| 8997 | 1384 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1385 | } |
| 11360 | 1386 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1387 | |
| 11360 | 1388 | /* static char *ggp_tooltip_text(GaimBuddy *b) {{{ */ |
| 1389 | static char *ggp_tooltip_text(GaimBuddy *b) | |
| 1390 | { | |
| 1391 | GaimStatus *status; | |
| 1392 | char *text; | |
| 1393 | gchar *ret; | |
| 1394 | const char *msg, *name; | |
| 1395 | ||
| 1396 | status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
| 1397 | msg = gaim_status_get_attr_string(status, "message"); | |
| 1398 | name = gaim_status_get_name(status); | |
| 1399 | ||
| 1400 | if (msg != NULL) { | |
| 1401 | char *tmp = gaim_markup_strip_html(msg); | |
| 1402 | text = g_markup_escape_text(tmp, -1); | |
| 1403 | g_free(tmp); | |
| 1404 | ||
| 1405 | ret = g_strdup_printf("\n<b>%s:</b> %s: %s", | |
| 12007 | 1406 | _("Status"), name, text); |
| 11360 | 1407 | |
| 1408 | g_free(text); | |
| 1409 | } else { | |
| 1410 | ret = g_strdup_printf("\n<b>%s:</b> %s", | |
| 12007 | 1411 | _("Status"), name); |
| 11360 | 1412 | } |
| 1413 | ||
| 1414 | return ret; | |
| 1415 | } | |
| 1416 | /* }}} */ | |
| 1417 | ||
| 1418 | /* static GList *ggp_status_types(GaimAccount *account) {{{ */ | |
| 1419 | static GList *ggp_status_types(GaimAccount *account) | |
| 1420 | { | |
| 1421 | GaimStatusType *type; | |
| 1422 | GList *types = NULL; | |
| 1423 | ||
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1424 | type = gaim_status_type_new_with_attrs( |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1425 | GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1426 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1427 | NULL); |
| 11360 | 1428 | types = g_list_append(types, type); |
| 1429 | ||
| 1430 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1431 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1432 | * work. It's not used and not needed to show status of buddies. |
| 1433 | */ | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1434 | type = gaim_status_type_new_with_attrs( |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1435 | GAIM_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1436 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1437 | NULL); |
| 11360 | 1438 | types = g_list_append(types, type); |
| 1439 | ||
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1440 | type = gaim_status_type_new_with_attrs( |
|
12718
34152a2d35fc
[gaim-migrate @ 15062]
Richard Laager <rlaager@pidgin.im>
parents:
12717
diff
changeset
|
1441 | GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1442 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1443 | NULL); |
| 11360 | 1444 | types = g_list_append(types, type); |
| 1445 | ||
| 12641 | 1446 | /* This status is wrong. It shouldn't exist. This prpl must not be |
| 1447 | * using the privacy stuff correctly. -- rlaager */ | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1448 | type = gaim_status_type_new_with_attrs( |
| 12641 | 1449 | GAIM_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1450 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
| 11360 | 1451 | types = g_list_append(types, type); |
| 1452 | ||
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1453 | type = gaim_status_type_new_with_attrs( |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1454 | GAIM_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1455 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1456 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1457 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1458 | |
| 11360 | 1459 | return types; |
| 1460 | } | |
| 1461 | /* }}} */ | |
| 1462 | ||
| 1463 | /* static GList *ggp_blist_node_menu(GaimBlistNode *node) {{{ */ | |
| 1464 | static GList *ggp_blist_node_menu(GaimBlistNode *node) | |
| 2393 | 1465 | { |
| 12919 | 1466 | GaimMenuAction *act; |
| 2393 | 1467 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1468 | |
| 11360 | 1469 | if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 1470 | return NULL; | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1471 | |
| 12919 | 1472 | act = gaim_menu_action_new(_("Add to chat"), |
| 1473 | GAIM_CALLBACK(ggp_bmenu_add_to_chat), | |
| 1474 | NULL, NULL); | |
| 11410 | 1475 | m = g_list_append(m, act); |
| 1476 | ||
| 12641 | 1477 | /* Using a blist node boolean here is also wrong. |
| 1478 | * Once the Block and Unblock actions are added to the core, | |
| 1479 | * this will have to go. -- rlaager */ | |
| 12007 | 1480 | if (gaim_blist_node_get_bool(node, "blocked")) { |
| 12919 | 1481 | act = gaim_menu_action_new(_("Unblock"), |
| 1482 | GAIM_CALLBACK(ggp_bmenu_block), | |
| 1483 | NULL, NULL); | |
| 12007 | 1484 | } else { |
| 12919 | 1485 | act = gaim_menu_action_new(_("Block"), |
| 1486 | GAIM_CALLBACK(ggp_bmenu_block), | |
| 1487 | NULL, NULL); | |
| 12007 | 1488 | } |
| 11394 | 1489 | m = g_list_append(m, act); |
| 2393 | 1490 | |
| 1491 | return m; | |
| 1492 | } | |
| 11360 | 1493 | /* }}} */ |
| 2393 | 1494 | |
| 11394 | 1495 | /* static GList *ggp_chat_info(GaimConnection *gc) {{{ */ |
| 1496 | static GList *ggp_chat_info(GaimConnection *gc) | |
| 1497 | { | |
| 1498 | GList *m = NULL; | |
| 1499 | struct proto_chat_entry *pce; | |
| 1500 | ||
| 1501 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1502 | pce->label = _("Chat _name:"); | |
| 1503 | pce->identifier = "name"; | |
| 1504 | pce->required = TRUE; | |
| 1505 | m = g_list_append(m, pce); | |
| 1506 | ||
| 1507 | return m; | |
| 1508 | } | |
| 1509 | /* }}} */ | |
| 1510 | ||
| 12007 | 1511 | /* static void ggp_login(GaimAccount *account) {{{ */ |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11718
diff
changeset
|
1512 | static void ggp_login(GaimAccount *account) |
| 2393 | 1513 | { |
| 11360 | 1514 | GaimConnection *gc = gaim_account_get_connection(account); |
| 1515 | struct gg_login_params *glp = g_new0(struct gg_login_params, 1); | |
| 1516 | GGPInfo *info = g_new0(GGPInfo, 1); | |
| 1517 | ||
| 12007 | 1518 | /* Probably this should be moved to *_new() function. */ |
| 11360 | 1519 | info->session = NULL; |
| 1520 | info->searchresults_window = NULL; | |
| 11394 | 1521 | info->chats = NULL; |
| 1522 | info->chats_count = 0; | |
| 12007 | 1523 | info->token = NULL; |
| 11360 | 1524 | |
| 1525 | gc->proto_data = info; | |
| 1526 | ||
| 1527 | glp->uin = ggp_get_uin(account); | |
| 1528 | glp->password = (char *)gaim_account_get_password(account); | |
| 1529 | ||
| 12007 | 1530 | glp->async = 1; |
| 11360 | 1531 | glp->status = GG_STATUS_AVAIL; |
| 1532 | glp->tls = 0; | |
| 1533 | ||
| 1534 | info->session = gg_login(glp); | |
| 1535 | if (info->session == NULL) { | |
| 1536 | gaim_connection_error(gc, _("Connection failed.")); | |
| 1537 | g_free(glp); | |
| 1538 | return; | |
| 1539 | } | |
| 12007 | 1540 | gc->inpa = gaim_input_add(info->session->fd, GAIM_INPUT_READ, |
| 1541 | ggp_async_login_handler, gc); | |
| 11360 | 1542 | } |
| 1543 | /* }}} */ | |
| 1544 | ||
| 1545 | /* static void ggp_close(GaimConnection *gc) {{{ */ | |
| 1546 | static void ggp_close(GaimConnection *gc) | |
| 1547 | { | |
| 8997 | 1548 | |
| 11360 | 1549 | if (gc == NULL) { |
| 1550 | gaim_debug_info("gg", "gc == NULL\n"); | |
| 1551 | return; | |
| 1552 | } | |
| 1553 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1554 | if (gc->proto_data) { |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1555 | GGPInfo *info = gc->proto_data; |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1556 | /* XXX: Any way to pass description here? */ |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1557 | if (info->session != NULL) { |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1558 | gg_change_status(info->session, GG_STATUS_NOT_AVAIL); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1559 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1560 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1561 | } |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1562 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1563 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1564 | } |
| 11360 | 1565 | |
| 1566 | if (gc->inpa > 0) | |
| 1567 | gaim_input_remove(gc->inpa); | |
| 1568 | ||
| 1569 | ggp_buddylist_offline(gc); | |
| 2393 | 1570 | |
| 11360 | 1571 | gaim_debug_info("gg", "Connection closed.\n"); |
| 1572 | } | |
| 1573 | /* }}} */ | |
| 1574 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1575 | /* static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, GaimMessageFlags flags) {{{ */ |
| 12007 | 1576 | 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
|
1577 | GaimMessageFlags flags) |
| 11360 | 1578 | { |
| 1579 | GGPInfo *info = gc->proto_data; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1580 | char *tmp, *plain; |
| 11360 | 1581 | |
| 1582 | if (strlen(msg) == 0) | |
| 1583 | return 1; | |
| 1584 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1585 | plain = gaim_unescape_html(msg); |
| 11565 | 1586 | 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
|
1587 | tmp = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1588 | g_free(plain); |
| 2393 | 1589 | |
| 11360 | 1590 | if (tmp != NULL && strlen(tmp) > 0) { |
| 12007 | 1591 | if (gg_send_message(info->session, GG_CLASS_CHAT, |
| 1592 | ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { | |
| 11360 | 1593 | return -1; |
| 1594 | } | |
| 1595 | } | |
| 11565 | 1596 | g_free(tmp); |
| 11360 | 1597 | |
| 1598 | return 1; | |
| 1599 | } | |
| 1600 | /* }}} */ | |
| 1601 | ||
| 1602 | /* static void ggp_get_info(GaimConnection *gc, const char *name) { {{{ */ | |
| 1603 | static void ggp_get_info(GaimConnection *gc, const char *name) | |
| 1604 | { | |
| 1605 | GGPInfo *info = gc->proto_data; | |
| 1606 | GGPSearchForm *form; | |
| 2393 | 1607 | |
| 12220 | 1608 | if (info->search_form != NULL) { |
| 1609 | gaim_notify_error(gc, NULL, | |
| 1610 | _("Unable to initiate a new search"), | |
| 1611 | _("You have a pending search. Please wait for it to finish.")); | |
| 1612 | return; | |
| 1613 | } | |
| 1614 | ||
| 11414 | 1615 | form = ggp_search_form_new(); |
| 11360 | 1616 | info->search_form = form; |
| 1617 | ||
| 1618 | form->uin = g_strdup(name); | |
| 1619 | form->offset = g_strdup("0"); | |
| 1620 | form->last_uin = g_strdup("0"); | |
| 1621 | ||
| 11414 | 1622 | ggp_search_start(gc, form); |
| 11360 | 1623 | } |
| 1624 | /* }}} */ | |
| 1625 | ||
| 1626 | /* static void ggp_set_status(GaimAccount *account, GaimStatus *status) {{{ */ | |
| 1627 | static void ggp_set_status(GaimAccount *account, GaimStatus *status) | |
| 1628 | { | |
| 1629 | GaimStatusPrimitive prim; | |
| 1630 | GaimConnection *gc; | |
| 1631 | GGPInfo *info; | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1632 | const char *status_id, *msg; |
| 11360 | 1633 | int new_status, new_status_descr; |
| 1634 | ||
| 1635 | prim = gaim_status_type_get_primitive(gaim_status_get_type(status)); | |
| 1636 | ||
| 1637 | if (!gaim_status_is_active(status)) | |
| 1638 | return; | |
| 1639 | ||
| 1640 | gc = gaim_account_get_connection(account); | |
| 1641 | info = gc->proto_data; | |
| 1642 | ||
| 1643 | status_id = gaim_status_get_id(status); | |
| 1644 | ||
| 12007 | 1645 | gaim_debug_info("gg", "ggp_set_status: Requested status = %s\n", |
| 1646 | status_id); | |
| 2393 | 1647 | |
| 11360 | 1648 | if (strcmp(status_id, "available") == 0) { |
| 1649 | new_status = GG_STATUS_AVAIL; | |
| 1650 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1651 | } else if (strcmp(status_id, "away") == 0) { | |
| 1652 | new_status = GG_STATUS_BUSY; | |
| 1653 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1654 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1655 | new_status = GG_STATUS_INVISIBLE; | |
| 1656 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 1657 | } else { | |
| 1658 | new_status = GG_STATUS_AVAIL; | |
| 1659 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 12007 | 1660 | gaim_debug_info("gg", |
| 1661 | "ggp_set_status: uknown status requested (status_id=%s)\n", | |
| 1662 | status_id); | |
| 11360 | 1663 | } |
| 4916 | 1664 | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1665 | msg = gaim_status_get_attr_string(status, "message"); |
| 11360 | 1666 | |
| 1667 | if (msg == NULL) { | |
| 1668 | gaim_debug_info("gg", "ggp_set_status: msg == NULL\n"); | |
| 1669 | gg_change_status(info->session, new_status); | |
| 1670 | } else { | |
| 1671 | char *tmp = charset_convert(msg, "UTF-8", "CP1250"); | |
| 12007 | 1672 | gaim_debug_info("gg", |
| 1673 | "ggp_set_status: msg != NULL. msg = %s\n", tmp); | |
| 1674 | gaim_debug_info("gg", | |
| 1675 | "ggp_set_status: gg_change_status_descr() = %d\n", | |
| 1676 | gg_change_status_descr(info->session, new_status_descr, tmp)); | |
| 11360 | 1677 | g_free(tmp); |
| 1678 | } | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
1679 | |
| 11360 | 1680 | } |
| 1681 | /* }}} */ | |
| 1682 | ||
| 1683 | /* static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 1684 | static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
| 1685 | { | |
| 1686 | GGPInfo *info = gc->proto_data; | |
| 1687 | ||
| 1688 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1689 | } | |
| 1690 | /* }}} */ | |
| 1691 | ||
| 1692 | /* static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 12007 | 1693 | static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, |
| 1694 | GaimGroup *group) | |
| 11360 | 1695 | { |
| 1696 | GGPInfo *info = gc->proto_data; | |
| 1697 | ||
| 1698 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1699 | } | |
| 1700 | /* }}} */ | |
| 1701 | ||
| 11394 | 1702 | /* static void ggp_join_chat(GaimConnection *gc, GHashTable *data) {{{ */ |
| 1703 | static void ggp_join_chat(GaimConnection *gc, GHashTable *data) | |
| 1704 | { | |
| 1705 | GGPInfo *info = gc->proto_data; | |
| 1706 | GGPChat *chat; | |
| 1707 | char *chat_name; | |
| 1708 | GList *l; | |
| 1709 | ||
| 1710 | chat_name = g_hash_table_lookup(data, "name"); | |
| 1711 | ||
| 1712 | if (chat_name == NULL) | |
| 1713 | return; | |
| 1714 | ||
| 1715 | gaim_debug_info("gg", "joined %s chat\n", chat_name); | |
| 1716 | ||
| 1717 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1718 | chat = l->data; | |
| 1719 | ||
| 1720 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 1721 | gaim_notify_error(gc, _("Chat error"), | |
| 12007 | 1722 | _("This chat name is already in use"), NULL); |
| 11394 | 1723 | return; |
| 1724 | } | |
| 1725 | } | |
| 1726 | ||
| 11414 | 1727 | ggp_confer_add_new(gc, chat_name); |
| 11394 | 1728 | serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 1729 | } | |
| 1730 | /* }}} */ | |
| 1731 | ||
| 1732 | /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | |
| 1733 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 1734 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 1735 | } | |
| 1736 | /* }}} */ | |
| 1737 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1738 | /* 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
|
1739 | static int ggp_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) |
| 11394 | 1740 | { |
| 1741 | GaimConversation *conv; | |
| 1742 | GGPInfo *info = gc->proto_data; | |
| 1743 | GGPChat *chat = NULL; | |
| 1744 | GList *l; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1745 | char *msg, *plain; |
| 11394 | 1746 | uin_t *uins; |
| 1747 | int count = 0; | |
| 1748 | ||
| 1749 | if ((conv = gaim_find_chat(gc, id)) == NULL) | |
| 1750 | return -EINVAL; | |
| 1751 | ||
| 1752 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1753 | chat = l->data; | |
| 1754 | ||
| 1755 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 1756 | gaim_debug_info("gg", "found conv!\n"); | |
| 1757 | break; | |
| 1758 | } | |
| 1759 | ||
| 1760 | chat = NULL; | |
| 1761 | } | |
| 1762 | ||
| 1763 | if (chat == NULL) { | |
| 12007 | 1764 | gaim_debug_error("gg", |
| 1765 | "ggp_chat_send: Hm... that's strange. No such chat?\n"); | |
| 11394 | 1766 | return -EINVAL; |
| 1767 | } | |
| 1768 | ||
| 1769 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 1770 | for (l = chat->participants; l != NULL; l = l->next) { | |
| 1771 | gchar *name = l->data; | |
| 1772 | uin_t uin; | |
| 1773 | ||
| 1774 | if ((uin = ggp_str_to_uin(name)) != 0) | |
| 1775 | uins[count++] = uin; | |
| 1776 | } | |
| 1777 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1778 | plain = gaim_unescape_html(message); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1779 | msg = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1780 | g_free(plain); |
| 12007 | 1781 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
| 1782 | (unsigned char *)msg); | |
| 11394 | 1783 | g_free(msg); |
| 1784 | g_free(uins); | |
| 1785 | ||
| 12007 | 1786 | serv_got_chat_in(gc, id, |
| 1787 | gaim_account_get_username(gaim_connection_get_account(gc)), | |
| 1788 | 0, message, time(NULL)); | |
| 11394 | 1789 | |
| 1790 | return 0; | |
| 1791 | } | |
| 1792 | /* }}} */ | |
| 1793 | ||
| 11360 | 1794 | /* static void ggp_keepalive(GaimConnection *gc) {{{ */ |
| 1795 | static void ggp_keepalive(GaimConnection *gc) | |
| 1796 | { | |
| 1797 | GGPInfo *info = gc->proto_data; | |
| 1798 | ||
| 1799 | /* gaim_debug_info("gg", "Keeping connection alive....\n"); */ | |
| 1800 | ||
| 1801 | if (gg_ping(info->session) < 0) { | |
| 1802 | gaim_debug_info("gg", "Not connected to the server " | |
| 1803 | "or gg_session is not correct\n"); | |
| 1804 | gaim_connection_error(gc, _("Not connected to the server.")); | |
| 4916 | 1805 | } |
| 2393 | 1806 | } |
| 11360 | 1807 | /* }}} */ |
| 1808 | ||
| 1809 | /* static void ggp_register_user(GaimAccount *account) {{{ */ | |
| 1810 | static void ggp_register_user(GaimAccount *account) | |
| 1811 | { | |
|
11542
fabce19a4ccf
[gaim-migrate @ 13797]
Daniel Atallah <datallah@pidgin.im>
parents:
11541
diff
changeset
|
1812 | GaimConnection *gc = gaim_account_get_connection(account); |
| 11360 | 1813 | GGPInfo *info; |
| 1814 | ||
| 12007 | 1815 | info = gc->proto_data = g_new0(GGPInfo, 1); |
| 11360 | 1816 | |
| 12007 | 1817 | ggp_token_request(gc, ggp_register_user_dialog); |
| 2393 | 1818 | } |
| 11360 | 1819 | /* }}} */ |
| 2393 | 1820 | |
| 11360 | 1821 | /* static GList *ggp_actions(GaimPlugin *plugin, gpointer context) {{{ */ |
| 1822 | static GList *ggp_actions(GaimPlugin *plugin, gpointer context) | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1823 | { |
| 11360 | 1824 | GList *m = NULL; |
| 1825 | GaimPluginAction *act; | |
| 1826 | ||
| 12220 | 1827 | act = gaim_plugin_action_new(_("Find buddies..."), |
| 12007 | 1828 | ggp_find_buddies); |
| 11360 | 1829 | m = g_list_append(m, act); |
| 1830 | ||
| 1831 | m = g_list_append(m, NULL); | |
| 1832 | ||
| 12220 | 1833 | act = gaim_plugin_action_new(_("Change password..."), |
| 12007 | 1834 | ggp_change_passwd); |
| 11360 | 1835 | m = g_list_append(m, act); |
| 1836 | ||
| 1837 | m = g_list_append(m, NULL); | |
| 1838 | ||
| 12007 | 1839 | act = gaim_plugin_action_new(_("Upload buddylist to Server"), |
| 1840 | ggp_action_buddylist_put); | |
| 11360 | 1841 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1842 | |
| 12007 | 1843 | act = gaim_plugin_action_new(_("Download buddylist from Server"), |
| 1844 | ggp_action_buddylist_get); | |
| 11360 | 1845 | m = g_list_append(m, act); |
| 1846 | ||
| 12007 | 1847 | act = gaim_plugin_action_new(_("Delete buddylist from Server"), |
| 1848 | ggp_action_buddylist_delete); | |
| 11360 | 1849 | m = g_list_append(m, act); |
| 1850 | ||
| 12220 | 1851 | act = gaim_plugin_action_new(_("Save buddylist to file..."), |
| 12007 | 1852 | ggp_action_buddylist_save); |
| 11360 | 1853 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1854 | |
| 12220 | 1855 | act = gaim_plugin_action_new(_("Load buddylist from file..."), |
| 12007 | 1856 | ggp_action_buddylist_load); |
| 11360 | 1857 | m = g_list_append(m, act); |
| 1858 | ||
| 1859 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1860 | } |
| 11360 | 1861 | /* }}} */ |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1862 | |
| 11360 | 1863 | /* prpl_info setup {{{ */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1864 | static GaimPluginProtocolInfo prpl_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1865 | { |
| 11360 | 1866 | OPT_PROTO_REGISTER_NOSCREENNAME, |
| 12007 | 1867 | NULL, /* user_splits */ |
| 1868 | NULL, /* protocol_options */ | |
| 9950 | 1869 | NO_BUDDY_ICONS, /* icon_spec */ |
| 11360 | 1870 | ggp_list_icon, /* list_icon */ |
| 1871 | ggp_list_emblems, /* list_emblems */ | |
| 1872 | ggp_status_text, /* status_text */ | |
| 1873 | ggp_tooltip_text, /* tooltip_text */ | |
| 1874 | ggp_status_types, /* status_types */ | |
| 12007 | 1875 | ggp_blist_node_menu, /* blist_node_menu */ |
| 11394 | 1876 | ggp_chat_info, /* chat_info */ |
| 12007 | 1877 | NULL, /* chat_info_defaults */ |
| 1878 | ggp_login, /* login */ | |
| 1879 | ggp_close, /* close */ | |
| 11360 | 1880 | ggp_send_im, /* send_im */ |
| 12007 | 1881 | NULL, /* set_info */ |
| 1882 | NULL, /* send_typing */ | |
| 11360 | 1883 | ggp_get_info, /* get_info */ |
| 1884 | ggp_set_status, /* set_away */ | |
| 12007 | 1885 | NULL, /* set_idle */ |
| 1886 | NULL, /* change_passwd */ | |
| 11360 | 1887 | ggp_add_buddy, /* add_buddy */ |
| 12007 | 1888 | NULL, /* add_buddies */ |
| 11360 | 1889 | ggp_remove_buddy, /* remove_buddy */ |
| 12007 | 1890 | NULL, /* remove_buddies */ |
| 1891 | NULL, /* add_permit */ | |
| 1892 | NULL, /* add_deny */ | |
| 1893 | NULL, /* rem_permit */ | |
| 1894 | NULL, /* rem_deny */ | |
| 1895 | NULL, /* set_permit_deny */ | |
| 11394 | 1896 | ggp_join_chat, /* join_chat */ |
| 12007 | 1897 | NULL, /* reject_chat */ |
| 11394 | 1898 | ggp_get_chat_name, /* get_chat_name */ |
| 12007 | 1899 | NULL, /* chat_invite */ |
| 1900 | NULL, /* chat_leave */ | |
| 1901 | NULL, /* chat_whisper */ | |
| 11394 | 1902 | ggp_chat_send, /* chat_send */ |
| 11360 | 1903 | ggp_keepalive, /* keepalive */ |
| 1904 | ggp_register_user, /* register_user */ | |
| 12007 | 1905 | NULL, /* get_cb_info */ |
| 1906 | NULL, /* get_cb_away */ | |
| 1907 | NULL, /* alias_buddy */ | |
| 1908 | NULL, /* group_buddy */ | |
| 1909 | NULL, /* rename_group */ | |
| 1910 | NULL, /* buddy_free */ | |
| 1911 | NULL, /* convo_closed */ | |
| 1912 | NULL, /* normalize */ | |
| 1913 | NULL, /* set_buddy_icon */ | |
| 1914 | NULL, /* remove_group */ | |
| 1915 | NULL, /* get_cb_real_name */ | |
| 1916 | NULL, /* set_chat_topic */ | |
| 1917 | NULL, /* find_blist_chat */ | |
| 1918 | NULL, /* roomlist_get_list */ | |
| 1919 | NULL, /* roomlist_cancel */ | |
| 1920 | NULL, /* roomlist_expand_category */ | |
| 1921 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12007
diff
changeset
|
1922 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1923 | NULL, /* new_xfer */ |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12641
diff
changeset
|
1924 | NULL, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1925 | NULL, /* whiteboard_prpl_ops */ |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1926 | NULL, /* media_prpl_ops */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1927 | }; |
| 11360 | 1928 | /* }}} */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1929 | |
| 11360 | 1930 | /* GaimPluginInfo setup {{{ */ |
| 1931 | static GaimPluginInfo info = { | |
| 1932 | GAIM_PLUGIN_MAGIC, /* magic */ | |
| 1933 | GAIM_MAJOR_VERSION, /* major_version */ | |
| 1934 | GAIM_MINOR_VERSION, /* minor_version */ | |
| 1935 | GAIM_PLUGIN_PROTOCOL, /* plugin type */ | |
| 1936 | NULL, /* ui_requirement */ | |
| 1937 | 0, /* flags */ | |
| 1938 | NULL, /* dependencies */ | |
| 1939 | GAIM_PRIORITY_DEFAULT, /* priority */ | |
| 1940 | ||
| 1941 | "prpl-gg", /* id */ | |
| 1942 | "Gadu-Gadu", /* name */ | |
| 1943 | VERSION, /* version */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1944 | |
| 11360 | 1945 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 1946 | N_("Polish popular IM"), /* description */ | |
| 1947 | "boler@sourceforge.net", /* author */ | |
| 1948 | GAIM_WEBSITE, /* homepage */ | |
| 1949 | ||
| 1950 | NULL, /* load */ | |
| 1951 | NULL, /* unload */ | |
| 1952 | NULL, /* destroy */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1953 | |
| 11360 | 1954 | NULL, /* ui_info */ |
| 1955 | &prpl_info, /* extra_info */ | |
| 1956 | NULL, /* prefs_info */ | |
| 1957 | ggp_actions /* actions */ | |
| 1958 | }; | |
| 1959 | /* }}} */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1960 | |
| 11565 | 1961 | /* 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
|
1962 | 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
|
1963 | GaimDebugLevel gaim_level; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1964 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1965 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1966 | /* 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
|
1967 | * the gaim ones */ |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1968 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1969 | case GG_DEBUG_FUNCTION: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1970 | gaim_level = GAIM_DEBUG_INFO; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1971 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1972 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1973 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1974 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1975 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1976 | default: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1977 | gaim_level = GAIM_DEBUG_MISC; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1978 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1979 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1980 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1981 | gaim_debug(gaim_level, "gg", msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1982 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1983 | } |
| 11565 | 1984 | /* }}} */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1985 | |
| 11360 | 1986 | /* |
| 1987 | */ | |
| 1988 | /* static void init_plugin(GaimPlugin *plugin) {{{ */ | |
| 1989 | static void init_plugin(GaimPlugin *plugin) | |
| 2393 | 1990 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1991 | GaimAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1992 | |
| 12007 | 1993 | option = gaim_account_option_string_new(_("Nickname"), |
| 1994 | "nick", _("Gadu-Gadu User")); | |
| 1995 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1996 | option); | |
| 3572 | 1997 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1998 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1999 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2000 | gg_debug_handler = gaim_gg_debug_handler; |
| 2393 | 2001 | } |
| 11360 | 2002 | /* }}} */ |
| 2393 | 2003 | |
|
11909
a0a7331365e1
[gaim-migrate @ 14200]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2004 | GAIM_INIT_PLUGIN(gg, init_plugin, info); |
| 11360 | 2005 | |
| 12007 | 2006 | /* vim: set ts=8 sts=0 sw=8 noet: */ |