Wed, 31 Aug 2005 21:18:27 +0000
[gaim-migrate @ 13629]
warning: ISO C90 forbids mixed declarations and code
| 11394 | 1 | /** |
| 2 | * @file gg.c Gadu-Gadu protocol plugin | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
| 6 | * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> | |
| 7 | * | |
| 8 | * Some parts of the code are adapted or taken for the previous implementation | |
| 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 | |
| 11360 | 51 | static GaimPlugin *my_protocol = NULL; |
| 2393 | 52 | |
| 11360 | 53 | typedef struct |
| 54 | { | |
| 11394 | 55 | char *name; |
| 56 | GList *participants; | |
| 57 | ||
| 58 | } GGPChat; | |
| 59 | ||
| 60 | typedef struct | |
| 61 | { | |
| 11360 | 62 | char *token_id; |
| 2393 | 63 | |
| 11360 | 64 | } GGPToken; |
| 65 | ||
| 66 | typedef struct { | |
| 2393 | 67 | |
| 11360 | 68 | char *uin; |
| 69 | char *lastname; | |
| 70 | char *firstname; | |
| 71 | char *nickname; | |
| 72 | char *city; | |
| 73 | char *birthyear; | |
| 74 | char *gender; | |
| 75 | char *active; | |
| 76 | char *offset; | |
| 2393 | 77 | |
| 11360 | 78 | char *last_uin; |
| 79 | ||
| 80 | } GGPSearchForm; | |
| 81 | ||
| 82 | typedef struct { | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
83 | |
| 11360 | 84 | struct gg_session *session; |
| 85 | GGPSearchForm *search_form; | |
| 86 | GGPToken *register_token; | |
| 87 | GGPToken *chpasswd_token; | |
| 11394 | 88 | GList *chats; |
| 11360 | 89 | void *searchresults_window; |
|
2501
5e1fa4926c93
[gaim-migrate @ 2514]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2423
diff
changeset
|
90 | |
| 11394 | 91 | char *tmp_buddy; |
| 92 | int chats_count; | |
| 93 | ||
| 11360 | 94 | } GGPInfo; |
| 2393 | 95 | |
| 11360 | 96 | /** |
| 97 | * Convert enconding of a given string. | |
| 98 | * | |
| 99 | * @param locstr Input string. | |
| 100 | * @param encsrc Current encoding of the string. | |
| 101 | * @param encdst Target encoding of the string. | |
| 102 | * | |
| 103 | * @return Converted string (it must be g_free()ed when not used. Or NULL if | |
| 104 | * locstr is NULL. | |
| 105 | */ | |
| 106 | /* static gchar *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) {{{ */ | |
| 3466 | 107 | static gchar *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) |
| 2393 | 108 | { |
| 10407 | 109 | gchar *msg; |
| 110 | GError *err = NULL; | |
| 111 | ||
| 11360 | 112 | if (locstr == NULL) |
| 113 | return NULL; | |
| 114 | ||
| 10407 | 115 | msg = g_convert_with_fallback(locstr, strlen(locstr), encdst, encsrc, "?", NULL, NULL, &err); |
| 116 | if (err != NULL) { | |
| 117 | gaim_debug_error("gg", "Error converting from %s to %s: %s\n", | |
| 118 | encsrc, encdst, err->message); | |
| 119 | g_error_free(err); | |
| 120 | } | |
| 121 | ||
| 122 | /* Just in case? */ | |
| 123 | if (msg == NULL) | |
| 124 | msg = g_strdup(locstr); | |
| 125 | ||
| 126 | return msg; | |
| 2393 | 127 | } |
| 11360 | 128 | /* }}} */ |
| 2393 | 129 | |
| 11360 | 130 | /* |
| 131 | * Convert string to number. Check wheter a given | |
| 132 | * string is a correct UIN. | |
| 133 | * | |
| 134 | * Return UIN or 0 if an error occurred. | |
| 135 | */ | |
| 136 | /* static uin_t ggp_str_to_uin(const char *text) {{{ */ | |
| 137 | static uin_t ggp_str_to_uin(const char *text) | |
| 2393 | 138 | { |
| 11360 | 139 | char *tmp; |
| 140 | long num; | |
| 9950 | 141 | |
| 11360 | 142 | if (!text) |
| 143 | return 0; | |
| 9950 | 144 | |
| 11360 | 145 | errno = 0; |
| 146 | num = strtol(text, &tmp, 0); | |
| 9950 | 147 | |
| 11360 | 148 | if (*text == '\0' || *tmp != '\0') |
| 149 | return 0; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
150 | |
| 11360 | 151 | if ((errno == ERANGE || (num == LONG_MAX || num == LONG_MIN)) || num > UINT_MAX || num < 0) |
| 152 | return 0; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
153 | |
| 11360 | 154 | return (uin_t) num; |
| 155 | } | |
| 156 | /* }}} */ | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
157 | |
| 11360 | 158 | /** |
| 159 | * Get UIN of a given account. | |
| 160 | * | |
| 161 | * @param account Current account. | |
| 162 | * | |
| 163 | * @return UIN of an account. | |
| 164 | */ | |
| 165 | /* static ggp_get_uin(GaimAccount *account) {{{ */ | |
| 166 | static uin_t ggp_get_uin(GaimAccount *account) | |
| 167 | { | |
| 168 | return ggp_str_to_uin(gaim_account_get_username(account)); | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
169 | } |
| 11360 | 170 | /* }}} */ |
| 8996 | 171 | |
| 11360 | 172 | /** |
| 173 | * Create a new GGPSearchForm structure, and set the fields | |
| 174 | * to the sane defaults. | |
| 175 | * | |
| 176 | * @return Newly allocated GGPSearchForm. | |
| 177 | */ | |
| 178 | /* GGPSearchForm *ggp_searchform_new() {{{ */ | |
| 179 | GGPSearchForm *ggp_searchform_new() | |
| 2393 | 180 | { |
| 11360 | 181 | GGPSearchForm *form; |
| 2393 | 182 | |
| 11360 | 183 | form = g_new0(GGPSearchForm, 1); |
| 184 | form->uin = NULL; | |
| 185 | form->lastname = NULL; | |
| 186 | form->firstname = NULL; | |
| 187 | form->nickname = NULL; | |
| 188 | form->city = NULL; | |
| 189 | form->birthyear = NULL; | |
| 190 | form->gender = NULL; | |
| 191 | form->active = NULL; | |
| 192 | form->offset = NULL; | |
| 9950 | 193 | |
| 11360 | 194 | form->last_uin = NULL; |
| 2393 | 195 | |
| 11360 | 196 | return form; |
| 197 | } | |
| 198 | /* }}} */ | |
|
9415
fbcb89b007bb
[gaim-migrate @ 10230]
Andrew Wellington <proton@users.sourceforge.net>
parents:
9308
diff
changeset
|
199 | |
| 11394 | 200 | /** |
| 201 | * Returns the best name of a buddy from the buddylist. | |
| 202 | * | |
| 203 | * @param gc GaimConnection instance. | |
| 204 | * @param uin UIN of the buddy. | |
| 205 | * | |
| 206 | * @return Name of the buddy, or UIN converted to string. | |
| 207 | */ | |
| 208 | /* static const *char ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) {{{ */ | |
| 209 | static const char *ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) | |
| 210 | { | |
| 211 | GaimBuddy *buddy; | |
| 212 | gchar *str_uin; | |
| 213 | ||
| 214 | str_uin = g_strdup_printf("%lu", (unsigned long int)uin); | |
| 215 | ||
| 216 | buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); | |
| 217 | if (buddy != NULL) { | |
| 218 | g_free(str_uin); | |
| 219 | return gaim_buddy_get_alias(buddy); | |
| 220 | } else { | |
| 221 | return str_uin; | |
| 222 | } | |
| 223 | } | |
| 224 | /* }}} */ | |
| 225 | ||
| 226 | /* ---------------------------------------------------------------------- */ | |
| 227 | /* ----- CONFERENCES ---------------------------------------------------- */ | |
| 228 | /* ---------------------------------------------------------------------- */ | |
| 229 | ||
| 230 | /** | |
| 231 | * Finds a CHAT conversation for the current account with the specified name. | |
| 232 | * | |
| 233 | * @param gc GaimConnection instance. | |
| 234 | * @param name Name of the conversation. | |
| 235 | * | |
| 236 | * @return GaimConversation or NULL if not found. | |
| 237 | */ | |
| 238 | /* static GaimConversation *ggp_chat_find_conversation(GaimConnection *gc, const gchar *name) {{{ */ | |
| 239 | static GaimConversation *ggp_chat_find_conversation(GaimConnection *gc, const gchar *name) | |
| 240 | { | |
| 241 | g_return_val_if_fail(gc != NULL, NULL); | |
| 242 | g_return_val_if_fail(name != NULL, NULL); | |
| 243 | ||
| 244 | return gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, name, | |
| 245 | gaim_connection_get_account(gc)); | |
| 246 | } | |
| 247 | /* }}} */ | |
| 248 | ||
| 249 | /** | |
| 250 | * Adds the specified UIN to the specified conversation. | |
| 251 | * | |
| 252 | * @param gc GaimConnection. | |
| 253 | * @param chat_name Name of the conversation. | |
| 254 | */ | |
| 255 | /* static void ggp_chat_participants_add_uin(GaimConnection *gc, const gchar *chat_name, const uin_t uin) {{{ */ | |
| 256 | static void ggp_chat_participants_add_uin(GaimConnection *gc, const gchar *chat_name, | |
| 257 | const uin_t uin) | |
| 258 | { | |
| 259 | GaimConversation *conv; | |
| 260 | GGPInfo *info = gc->proto_data; | |
| 261 | GGPChat *chat; | |
| 262 | GList *l; | |
| 263 | gchar *str_uin; | |
| 264 | ||
| 265 | str_uin = g_strdup_printf("%lu", (unsigned long int)uin); | |
| 266 | ||
| 267 | for (l = info->chats; l != NULL; l = l->next) { | |
| 268 | chat = l->data; | |
| 269 | ||
| 270 | if (g_utf8_collate(chat->name, chat_name) == 0) { | |
| 271 | if (g_list_find(chat->participants, str_uin) == NULL) { | |
| 272 | chat->participants = g_list_append(chat->participants, str_uin); | |
| 273 | conv = ggp_chat_find_conversation(gc, chat_name); | |
| 274 | ||
| 275 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | |
| 276 | ggp_buddy_get_name(gc, uin), NULL, GAIM_CBFLAGS_NONE, TRUE); | |
| 277 | } | |
| 278 | break; | |
| 279 | } | |
| 280 | } | |
| 281 | } | |
| 282 | /* }}} */ | |
| 283 | ||
| 284 | /** | |
| 285 | * Add the specified UINs to the specified conversation. | |
| 286 | * | |
| 287 | * @param gc GaimConnection. | |
| 288 | * @param chat_name Name of the conversation. | |
| 289 | * @param recipients List of the UINs. | |
| 290 | * @param count Number of the UINs. | |
| 291 | */ | |
| 292 | /* static void ggp_chat_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */ | |
| 293 | static void ggp_chat_participants_add(GaimConnection *gc, const gchar *chat_name, | |
| 294 | const uin_t *recipients, int count) | |
| 295 | { | |
| 296 | GaimConversation *conv; | |
| 297 | GGPInfo *info = gc->proto_data; | |
| 298 | GGPChat *chat; | |
| 299 | GList *l; | |
| 300 | int i; | |
| 301 | gchar *uin; | |
| 302 | ||
| 303 | for (l = info->chats; l != NULL; l = l->next) { | |
| 304 | chat = l->data; | |
| 305 | ||
| 306 | if (g_utf8_collate(chat->name, chat_name) == 0) { | |
| 307 | ||
| 308 | for (i = 0; i < count; i++) { | |
| 309 | uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); | |
| 310 | if (g_list_find(chat->participants, uin) == NULL) { | |
| 311 | chat->participants = g_list_append(chat->participants, uin); | |
| 312 | conv = ggp_chat_find_conversation(gc, chat_name); | |
| 313 | ||
| 314 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | |
| 315 | ggp_buddy_get_name(gc, recipients[i]), | |
| 316 | NULL, GAIM_CBFLAGS_NONE, TRUE); | |
| 317 | } | |
| 318 | g_free(uin); | |
| 319 | } | |
| 320 | break; | |
| 321 | } | |
| 322 | } | |
| 323 | } | |
| 324 | /* }}} */ | |
| 325 | ||
| 326 | /** | |
| 327 | * Finds a conversation in which all the specified recipients participate. | |
| 328 | * | |
| 329 | * TODO: This function should be rewritten to better handle situations when | |
| 330 | * somobody adds more people to the converation. | |
| 331 | * | |
| 332 | * @param gc GaimConnection. | |
| 333 | * @param recipients List of the people in the conversation. | |
| 334 | * @param count Number of people. | |
| 335 | * | |
| 336 | * @return Name of the conversation. | |
| 337 | */ | |
| 338 | /* static const char *ggp_find_chat_by_recipients(GaimConnection *gc, const uin_t *recipients, int count) {{{ */ | |
| 339 | static const char *ggp_find_chat_by_recipients(GaimConnection *gc, | |
| 340 | const uin_t *recipients, int count) | |
| 341 | { | |
| 342 | GGPInfo *info = gc->proto_data; | |
| 343 | GGPChat *chat = NULL; | |
| 344 | GList *l, *m; | |
| 345 | int i; | |
| 346 | int maches; | |
| 347 | ||
| 348 | g_return_val_if_fail(info->chats != NULL, NULL); | |
| 349 | ||
| 350 | for (l = info->chats; l != NULL; l = l->next) { | |
| 351 | chat = l->data; | |
| 352 | maches = 0; | |
| 353 | ||
| 354 | for (m = chat->participants; m != NULL; m = m->next) { | |
| 355 | uin_t p = ggp_str_to_uin(m->data); | |
| 356 | ||
| 357 | for (i = 0; i < count; i++) | |
| 358 | if (p == recipients[i]) | |
| 359 | maches++; | |
| 360 | } | |
| 361 | ||
| 362 | if (maches == count) | |
| 363 | break; | |
| 364 | ||
| 365 | chat = NULL; | |
| 366 | } | |
| 367 | ||
| 368 | if (chat == NULL) | |
| 369 | return NULL; | |
| 370 | else | |
| 371 | return chat->name; | |
| 372 | } | |
| 373 | /* }}} */ | |
| 374 | ||
| 375 | /** | |
| 376 | * Adds a new conversation to the internal list of conversations. | |
| 377 | * If name is NULL then it will be automagically generated. | |
| 378 | * | |
| 379 | * @param gc GaimConnection. | |
| 380 | * @param name Name of the conversation. | |
| 381 | * | |
| 382 | * @return Name of the conversation. | |
| 383 | */ | |
| 384 | /* static const char *ggp_chat_add_new(GaimConnection *gc, const char *name) {{{ */ | |
| 385 | static const char *ggp_chat_add_new(GaimConnection *gc, const char *name) | |
| 386 | { | |
| 387 | GGPInfo *info = gc->proto_data; | |
| 388 | GGPChat *chat; | |
| 389 | ||
| 390 | chat = g_new0(GGPChat, 1); | |
| 391 | ||
| 392 | if (name == NULL) | |
| 393 | chat->name = g_strdup_printf("conf#%d", info->chats_count++); | |
| 394 | else | |
| 395 | chat->name = g_strdup(name); | |
| 396 | ||
| 397 | chat->participants = NULL; | |
| 398 | ||
| 399 | info->chats = g_list_append(info->chats, chat); | |
| 400 | ||
| 401 | return chat->name; | |
| 402 | } | |
| 403 | /* }}} */ | |
| 404 | ||
| 405 | /** | |
| 406 | * Dispatch a message received from a buddy. | |
| 407 | * | |
| 408 | * @param gc GaimConnection. | |
| 409 | * @param ev Gadu-Gadu event structure. | |
| 410 | */ | |
| 411 | /* static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) {{{ */ | |
| 412 | static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) | |
| 413 | { | |
| 414 | GGPInfo *info = gc->proto_data; | |
| 415 | GaimConversation *conv; | |
| 416 | gchar *from; | |
| 417 | gchar *msg; | |
| 418 | gchar *tmp; | |
| 419 | const char *chat_name; | |
| 420 | int chat_id; | |
| 421 | ||
| 422 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 423 | ||
| 424 | msg = charset_convert((const char *)ev->event.msg.message, | |
| 425 | "CP1250", "UTF-8"); | |
| 426 | gaim_str_strip_cr(msg); | |
| 427 | tmp = g_markup_escape_text(msg, -1); | |
| 428 | ||
| 429 | gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", | |
| 430 | from, tmp, ev->event.msg.msgclass, ev->event.msg.recipients_count); | |
| 431 | ||
| 432 | /* | |
| 433 | * Chat between only two presons will be treated as a private message. | |
| 434 | * It's due to some broken clients that send private messages | |
| 435 | * with msgclass == CHAT | |
| 436 | */ | |
| 437 | if (ev->event.msg.recipients_count == 0) { | |
| 438 | serv_got_im(gc, from, tmp, 0, ev->event.msg.time); | |
| 439 | } else { | |
| 440 | chat_name = ggp_find_chat_by_recipients(gc, | |
| 441 | ev->event.msg.recipients, | |
| 442 | ev->event.msg.recipients_count); | |
| 443 | if (chat_name == NULL) { | |
| 444 | chat_name = ggp_chat_add_new(gc, NULL); | |
| 445 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 446 | ggp_chat_participants_add_uin(gc, chat_name, ev->event.msg.sender); | |
| 447 | ggp_chat_participants_add(gc, chat_name, ev->event.msg.recipients, | |
| 448 | ev->event.msg.recipients_count); | |
| 449 | } | |
| 450 | conv = ggp_chat_find_conversation(gc, chat_name); | |
| 451 | chat_id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
| 452 | serv_got_chat_in(gc, chat_id, ggp_buddy_get_name(gc, ev->event.msg.sender), | |
| 453 | 0, msg, ev->event.msg.time); | |
| 454 | } | |
| 455 | g_free(msg); | |
| 456 | g_free(tmp); | |
| 457 | g_free(from); | |
| 458 | } | |
| 459 | /* }}} */ | |
| 460 | ||
| 11360 | 461 | /* ---------------------------------------------------------------------- */ |
| 462 | /* ----- BUDDYLIST STUFF ------------------------------------------------ */ | |
| 463 | /* ---------------------------------------------------------------------- */ | |
| 9950 | 464 | |
| 11360 | 465 | /* static void ggp_buddylist_send(GaimConnection *gc) {{{ */ |
| 466 | static void ggp_buddylist_send(GaimConnection *gc) | |
| 467 | { | |
| 468 | GGPInfo *info = gc->proto_data; | |
| 8996 | 469 | |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
470 | GaimBuddyList *blist; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
471 | GaimBlistNode *gnode, *cnode, *bnode; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
472 | GaimBuddy *buddy; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
473 | uin_t *userlist = NULL; |
| 11360 | 474 | gchar *types = NULL; |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
475 | int userlist_size = 0; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
476 | |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
477 | if ((blist = gaim_get_blist()) != NULL) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
478 | { |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
479 | for (gnode = blist->root; gnode != NULL; gnode = gnode->next) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
480 | { |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
481 | if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
482 | continue; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
483 | for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
484 | { |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
485 | if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
486 | continue; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
487 | for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
488 | { |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
489 | if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
490 | continue; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
491 | buddy = (GaimBuddy *)bnode; |
| 11360 | 492 | |
| 493 | if (buddy->account != gc->account) | |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
494 | continue; |
| 11360 | 495 | |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
496 | userlist_size++; |
| 11360 | 497 | userlist = (uin_t *) g_renew(uin_t, userlist, userlist_size); |
| 498 | types = (gchar *) g_renew(gchar, types, userlist_size); | |
| 499 | userlist[userlist_size - 1] = ggp_str_to_uin(buddy->name); | |
| 500 | types[userlist_size - 1] = GG_USER_NORMAL; | |
| 501 | gaim_debug_info("gg", "ggp_buddylist_send: adding %d\n", userlist[userlist_size - 1]); | |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
502 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
503 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
504 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
505 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
506 | |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
507 | if (userlist) { |
| 11360 | 508 | int ret = gg_notify_ex(info->session, userlist, types, userlist_size); |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10868
diff
changeset
|
509 | g_free(userlist); |
| 11360 | 510 | g_free(types); |
| 4634 | 511 | |
| 11360 | 512 | gaim_debug_info("gg", "send: ret=%d; size=%d\n", ret, userlist_size); |
| 2393 | 513 | } |
| 514 | } | |
| 11360 | 515 | /* }}} */ |
| 2393 | 516 | |
| 11360 | 517 | /** |
| 518 | * Load buddylist from server into the rooster. | |
| 519 | * | |
| 520 | * @param gc GaimConnection | |
| 521 | * @param buddylist Pointer to the buddylist that will be loaded. | |
| 522 | */ | |
| 523 | /* static void ggp_buddylist_load(GaimConnection *gc, char *buddylist) {{{ */ | |
| 524 | static void ggp_buddylist_load(GaimConnection *gc, char *buddylist) | |
|
7063
4bfe512a4b8c
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
525 | { |
| 11360 | 526 | GaimBuddy *buddy; |
| 527 | GaimGroup *group; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
528 | gchar **users_tbl; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
529 | int i; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
530 | |
| 11360 | 531 | users_tbl = g_strsplit(buddylist, "\r\n", 200); |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
532 | |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
533 | for (i = 0; users_tbl[i] != NULL; i++) { |
|
4520
c31da57f5e7f
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
534 | gchar **data_tbl; |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
535 | gchar *name, *show, *g; |
|
4520
c31da57f5e7f
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
536 | |
| 11360 | 537 | if (strlen(users_tbl[i]) == 0) |
| 4530 | 538 | continue; |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
539 | |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
540 | data_tbl = g_strsplit(users_tbl[i], ";", 8); |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
541 | |
| 4437 | 542 | show = charset_convert(data_tbl[3], "CP1250", "UTF-8"); |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
543 | name = data_tbl[6]; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
544 | |
| 11360 | 545 | gaim_debug_info("gg", "got buddy: name=%s show=%s\n", name, show); |
| 546 | ||
| 547 | if (gaim_find_buddy(gaim_connection_get_account(gc), name)) { | |
| 548 | g_free(show); | |
| 549 | g_strfreev(data_tbl); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
550 | continue; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
551 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
552 | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
553 | g = g_strdup("Gadu-Gadu"); |
| 11360 | 554 | |
| 555 | if (strlen(data_tbl[5])) { | |
| 556 | /* Hard limit to at most 50 groups */ | |
| 557 | gchar **group_tbl = g_strsplit(data_tbl[5], ",", 50); | |
| 558 | if (strlen(group_tbl[0]) > 0) { | |
| 559 | g_free(g); | |
| 560 | g = g_strdup(group_tbl[0]); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
561 | } |
| 11360 | 562 | g_strfreev(group_tbl); |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
563 | } |
| 11360 | 564 | |
| 565 | buddy = gaim_buddy_new(gaim_connection_get_account(gc), name, strlen(show) ? show : NULL); | |
| 566 | if (!(group = gaim_find_group(g))) { | |
| 567 | group = gaim_group_new(g); | |
| 568 | gaim_blist_add_group(group, NULL); | |
| 569 | } | |
| 570 | ||
| 571 | gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
| 572 | g_free(g); | |
| 573 | ||
| 4437 | 574 | g_free(show); |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
575 | g_strfreev(data_tbl); |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
576 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
577 | g_strfreev(users_tbl); |
| 11360 | 578 | |
| 579 | ggp_buddylist_send(gc); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
580 | |
| 11360 | 581 | } |
| 582 | /* }}} */ | |
| 583 | ||
| 11394 | 584 | /** |
| 585 | * Handle change of the status of the buddy. | |
| 586 | * | |
| 587 | * @param gc GaimConnection | |
| 588 | * @param uin UIN of the buddy. | |
| 589 | * @param status ID of the status. | |
| 590 | * @param descr Description. | |
| 11360 | 591 | */ |
| 592 | /* static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, int status, const char *descr) {{{ */ | |
| 593 | static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, int status, const char *descr) | |
| 2393 | 594 | { |
| 11360 | 595 | gchar *from; |
| 596 | const char *st; | |
| 597 | gchar *msg; | |
| 598 | ||
| 599 | from = g_strdup_printf("%ld", (unsigned long int)uin); | |
| 600 | switch (status) { | |
| 601 | case GG_STATUS_NOT_AVAIL: | |
| 602 | case GG_STATUS_NOT_AVAIL_DESCR: | |
| 603 | st = "offline"; | |
| 604 | break; | |
| 605 | case GG_STATUS_AVAIL: | |
| 606 | case GG_STATUS_AVAIL_DESCR: | |
| 607 | st = "online"; | |
| 608 | break; | |
| 609 | case GG_STATUS_BUSY: | |
| 610 | case GG_STATUS_BUSY_DESCR: | |
| 611 | st = "away"; | |
| 612 | break; | |
| 613 | case GG_STATUS_BLOCKED: | |
| 614 | /* user is blocking us.... */ | |
| 615 | st = "blocked"; | |
| 616 | break; | |
| 617 | default: | |
| 618 | st = "online"; | |
| 619 | gaim_debug_info("gg", "GG_EVENT_NOTIFY: Unknown status: %d\n", status); | |
| 620 | break; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
621 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
622 | |
| 11360 | 623 | gaim_debug_info("gg", "st = %s\n", st); |
| 624 | msg = charset_convert(descr, "CP1250", "UTF-8"); | |
| 625 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), from, st, "message", msg, NULL); | |
| 626 | g_free(from); | |
| 627 | g_free(msg); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
628 | } |
| 11360 | 629 | /* }}} */ |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
630 | |
| 11394 | 631 | /** |
| 632 | * Initiate a search in the public directory. | |
| 633 | * | |
| 634 | * @param gc GaimConnection. | |
| 635 | * @param form Filled in GGPSearchForm. | |
| 11360 | 636 | */ |
| 637 | /* static void ggp_pubdir_start_search(GaimConnection *gc, GGPSearchForm *form) {{{ */ | |
| 638 | static void ggp_pubdir_start_search(GaimConnection *gc, GGPSearchForm *form) | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
639 | { |
| 11360 | 640 | GGPInfo *info = gc->proto_data; |
| 641 | gg_pubdir50_t req; | |
| 642 | ||
| 643 | gaim_debug_info("gg", "It's time to perform a search...\n"); | |
| 644 | ||
| 645 | if ((req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)) == NULL) { | |
| 646 | gaim_debug_error("gg", "ggp_bmenu_show_details: Unable to create req variable.\n"); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
647 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
648 | } |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
649 | |
| 11360 | 650 | if (form->uin != NULL) { |
| 651 | gaim_debug_info("gg", " uin: %s\n", form->uin); | |
| 652 | gg_pubdir50_add(req, GG_PUBDIR50_UIN, form->uin); | |
| 653 | } else { | |
| 654 | if (form->lastname != NULL) { | |
| 655 | gaim_debug_info("gg", " lastname: %s\n", form->lastname); | |
| 656 | gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, form->lastname); | |
| 657 | } | |
| 658 | ||
| 659 | if (form->firstname != NULL) { | |
| 660 | gaim_debug_info("gg", " firstname: %s\n", form->firstname); | |
| 661 | gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, form->firstname); | |
| 662 | } | |
| 663 | ||
| 664 | if (form->nickname != NULL) { | |
| 665 | gaim_debug_info("gg", " nickname: %s\n", form->nickname); | |
| 666 | gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, form->nickname); | |
| 667 | } | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
668 | |
| 11360 | 669 | if (form->city != NULL) { |
| 670 | gaim_debug_info("gg", " city: %s\n", form->city); | |
| 671 | gg_pubdir50_add(req, GG_PUBDIR50_CITY, form->city); | |
| 672 | } | |
| 673 | ||
| 674 | if (form->birthyear != NULL) { | |
| 675 | gaim_debug_info("gg", " birthyear: %s\n", form->birthyear); | |
| 676 | gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, form->birthyear); | |
| 677 | } | |
| 678 | ||
| 679 | if (form->gender != NULL) { | |
| 680 | gaim_debug_info("gg", " gender: %s\n", form->gender); | |
| 681 | gg_pubdir50_add(req, GG_PUBDIR50_GENDER, form->gender); | |
| 682 | } | |
| 683 | ||
| 684 | if (form->active != NULL) { | |
| 685 | gaim_debug_info("gg", " active: %s\n", form->active); | |
| 686 | gg_pubdir50_add(req, GG_PUBDIR50_ACTIVE, form->active); | |
| 687 | } | |
| 688 | } | |
| 689 | ||
| 690 | gaim_debug_info("gg", "offset: %s\n", form->offset); | |
| 691 | gg_pubdir50_add(req, GG_PUBDIR50_START, g_strdup(form->offset)); | |
| 692 | ||
| 693 | if (gg_pubdir50(info->session, req) == 0) { | |
| 694 | gaim_debug_warning("gg", "ggp_bmenu_show_details: Search failed.\n"); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
695 | return; |
|
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
696 | } |
|
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
697 | |
| 11360 | 698 | gg_pubdir50_free(req); |
| 699 | } | |
| 700 | /* }}} */ | |
| 701 | ||
| 702 | /* | |
| 703 | * Return converted to the UTF-8 value of the specified field. | |
| 704 | * | |
| 705 | * @param res Public directory look-up result | |
| 706 | * @param num Id of the record | |
| 707 | * @param fileld Name of the field | |
| 708 | * | |
| 709 | * @return UTF-8 encoded value of the field | |
| 710 | */ | |
| 711 | /* static char *ggp_get_pubdir_info(gg_pubdir50_t res, int num, const char *field) {{{ */ | |
| 712 | static char *ggp_get_pubdir_info(gg_pubdir50_t res, int num, const char *field) | |
| 713 | { | |
| 714 | char *tmp; | |
| 715 | ||
| 716 | tmp = charset_convert(gg_pubdir50_get(res, num, field), "CP1250", "UTF-8"); | |
| 717 | ||
| 718 | return (tmp == NULL) ? g_strdup("") : tmp; | |
| 719 | } | |
| 720 | /* }}} */ | |
| 721 | ||
| 11394 | 722 | /* |
| 723 | */ | |
| 724 | /* static void ggp_callback_show_next(GaimConnection *gc, GList *row) {{{ */ | |
| 11360 | 725 | static void ggp_callback_show_next(GaimConnection *gc, GList *row) |
| 726 | { | |
| 727 | GGPInfo *info = gc->proto_data; | |
| 728 | ||
| 729 | g_free(info->search_form->offset); | |
| 730 | info->search_form->offset = g_strdup(info->search_form->last_uin); | |
| 731 | ggp_pubdir_start_search(gc, info->search_form); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
732 | } |
| 11394 | 733 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
734 | |
| 11394 | 735 | /* |
| 736 | */ | |
| 737 | /* static void ggp_callback_add_buddy(GaimConnection *gc, GList *row) {{{ */ | |
| 11360 | 738 | static void ggp_callback_add_buddy(GaimConnection *gc, GList *row) |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
739 | { |
| 11360 | 740 | gaim_blist_request_add_buddy(gaim_connection_get_account(gc), |
| 741 | g_list_nth_data(row, 0), NULL, NULL); | |
| 742 | } | |
| 11394 | 743 | /* }}} */ |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
744 | |
| 11360 | 745 | /* |
| 746 | */ | |
| 747 | /* static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 748 | static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 749 | { | |
| 750 | GaimConnection *gc = _gc; | |
| 751 | GGPInfo *info = gc->proto_data; | |
| 752 | struct gg_event *ev; | |
| 753 | int i; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
754 | |
| 11360 | 755 | if (!(ev = gg_watch_fd(info->session))) { |
| 756 | gaim_debug_error("gg", "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); | |
| 757 | gaim_connection_error(gc, _("Unable to read socket")); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
758 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
759 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
760 | |
| 11360 | 761 | switch (ev->type) { |
| 762 | case GG_EVENT_NONE: | |
| 763 | /* Nothing happened. */ | |
| 764 | break; | |
| 765 | case GG_EVENT_MSG: | |
| 11394 | 766 | ggp_recv_message_handler(gc, ev); |
| 11360 | 767 | break; |
| 768 | case GG_EVENT_ACK: | |
| 769 | gaim_debug_info("gg", "message sent to: %ld, delivery status=%d, seq=%d\n", | |
| 770 | ev->event.ack.recipient, ev->event.ack.status, ev->event.ack.seq); | |
| 771 | break; | |
| 772 | case GG_EVENT_NOTIFY: | |
| 773 | case GG_EVENT_NOTIFY_DESCR: | |
| 774 | { | |
| 775 | struct gg_notify_reply *n; | |
| 776 | char *descr; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
777 | |
| 11360 | 778 | gaim_debug_info("gg", "notify_pre: (%d) status: %d\n", |
| 779 | ev->event.notify->uin, | |
| 780 | ev->event.notify->status); | |
| 781 | ||
| 782 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 783 | : ev->event.notify_descr.notify; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
784 | |
| 11360 | 785 | for (; n->uin; n++) { |
| 786 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 787 | : ev->event.notify_descr.descr; | |
| 788 | gaim_debug_info("gg", "notify: (%d) status: %d; descr: %s\n", | |
| 789 | n->uin, n->status, descr); | |
| 790 | ||
| 791 | ggp_generic_status_handler(gc, | |
| 792 | n->uin, n->status, descr); | |
| 793 | } | |
| 794 | } | |
| 795 | break; | |
| 796 | case GG_EVENT_NOTIFY60: | |
| 797 | gaim_debug_info("gg", "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", | |
| 798 | ev->event.notify60->uin, ev->event.notify60->status, | |
| 799 | ev->event.notify60->version, ev->event.notify60->descr); | |
| 800 | ||
| 801 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 802 | gaim_debug_info("gg", "notify60: (%d) status=%d; version=%d; descr=%s\n", | |
| 803 | ev->event.notify60[i].uin, ev->event.notify60[i].status, | |
| 804 | ev->event.notify60[i].version, ev->event.notify60[i].descr); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
805 | |
| 11360 | 806 | ggp_generic_status_handler(gc, |
| 807 | ev->event.notify60[i].uin, | |
| 808 | ev->event.notify60[i].status, | |
| 809 | ev->event.notify60[i].descr); | |
| 810 | } | |
| 811 | break; | |
| 812 | case GG_EVENT_STATUS: | |
| 813 | gaim_debug_info("gg", "status: (%d) status=%d; descr=%s\n", | |
| 814 | ev->event.status.uin, ev->event.status.status, | |
| 815 | ev->event.status.descr); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
816 | |
| 11360 | 817 | ggp_generic_status_handler(gc, |
| 818 | ev->event.status.uin, | |
| 819 | ev->event.status.status, | |
| 820 | ev->event.status.descr); | |
| 821 | break; | |
| 822 | case GG_EVENT_STATUS60: | |
| 823 | gaim_debug_info("gg", "status60: (%d) status=%d; version=%d; descr=%s\n", | |
| 824 | ev->event.status60.uin, | |
| 825 | ev->event.status60.status, | |
| 826 | ev->event.status60.version, | |
| 827 | ev->event.status60.descr); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
828 | |
| 11360 | 829 | ggp_generic_status_handler(gc, |
| 830 | ev->event.status60.uin, | |
| 831 | ev->event.status60.status, | |
| 832 | ev->event.status60.descr); | |
| 833 | break; | |
| 834 | case GG_EVENT_USERLIST: | |
| 835 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 836 | gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); | |
| 837 | if (ev->event.userlist.reply != NULL) { | |
| 838 | ggp_buddylist_load(gc, ev->event.userlist.reply); | |
| 839 | } | |
| 840 | break; | |
| 841 | } else { | |
| 842 | gaim_debug_info("gg", "GG_USERLIST_PUT_REPLY. Userlist stored on the server.\n"); | |
| 843 | } | |
| 844 | break; | |
| 845 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 846 | { | |
| 847 | GaimNotifySearchResults *results; | |
| 848 | GaimNotifySearchColumn *column; | |
| 849 | gg_pubdir50_t req = ev->event.pubdir50; | |
| 850 | int res_count = 0; | |
| 851 | int start; | |
| 852 | int i; | |
| 853 | ||
| 854 | res_count = gg_pubdir50_count(req); | |
| 855 | if (res_count < 1) { | |
| 856 | gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); | |
| 857 | return; | |
| 858 | } | |
| 859 | res_count = (res_count > 20) ? 20 : res_count; | |
| 860 | ||
| 861 | results = gaim_notify_searchresults_new(); | |
| 862 | ||
| 863 | column = gaim_notify_searchresults_column_new("UIN"); | |
| 864 | gaim_notify_searchresults_column_add(results, column); | |
| 865 | ||
| 866 | column = gaim_notify_searchresults_column_new("First name"); | |
| 867 | gaim_notify_searchresults_column_add(results, column); | |
| 868 | ||
| 869 | column = gaim_notify_searchresults_column_new("Nick name"); | |
| 870 | gaim_notify_searchresults_column_add(results, column); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
871 | |
| 11360 | 872 | column = gaim_notify_searchresults_column_new("City"); |
| 873 | gaim_notify_searchresults_column_add(results, column); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
874 | |
| 11360 | 875 | column = gaim_notify_searchresults_column_new("Birth year"); |
| 876 | gaim_notify_searchresults_column_add(results, column); | |
| 2393 | 877 | |
| 11360 | 878 | gaim_debug_info("gg", "Going with %d entries\n", res_count); |
| 879 | ||
| 880 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 881 | gaim_debug_info("gg", "start = %d\n", start); | |
| 2393 | 882 | |
| 11360 | 883 | for (i = 0; i < res_count; i++) { |
| 884 | GList *row = NULL; | |
| 885 | char *birth = ggp_get_pubdir_info(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 886 | ||
| 887 | /* TODO: Status will be displayed as an icon. */ | |
| 888 | /* row = g_list_append(row, ggp_get_pubdir_info(req, i, GG_PUBDIR50_STATUS)); */ | |
| 889 | row = g_list_append(row, ggp_get_pubdir_info(req, i, GG_PUBDIR50_UIN)); | |
| 890 | row = g_list_append(row, ggp_get_pubdir_info(req, i, GG_PUBDIR50_FIRSTNAME)); | |
| 891 | row = g_list_append(row, ggp_get_pubdir_info(req, i, GG_PUBDIR50_NICKNAME)); | |
| 892 | row = g_list_append(row, ggp_get_pubdir_info(req, i, GG_PUBDIR50_CITY)); | |
| 893 | row = g_list_append(row, (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 894 | gaim_notify_searchresults_row_add(results, row); | |
| 895 | if (i == res_count - 1) { | |
| 896 | g_free(info->search_form->last_uin); | |
| 897 | info->search_form->last_uin = ggp_get_pubdir_info(req, i, GG_PUBDIR50_UIN); | |
| 898 | } | |
| 899 | } | |
| 2393 | 900 | |
| 11360 | 901 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_CONTINUE, ggp_callback_show_next); |
| 902 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD_BUDDY, ggp_callback_add_buddy); | |
| 903 | if (info->searchresults_window == NULL) { | |
| 904 | void *h = gaim_notify_searchresults(gc, _("Gadu-Gadu Public Directory"), | |
| 905 | _("Search results"), NULL, results, NULL, NULL); | |
| 906 | info->searchresults_window = h; | |
| 907 | } else { | |
| 908 | gaim_notify_searchresults_new_rows(gc, results, info->searchresults_window, NULL); | |
| 909 | } | |
| 910 | } | |
| 911 | break; | |
| 912 | default: | |
| 913 | gaim_debug_error("gg", "unsupported event type=%d\n", ev->type); | |
| 914 | break; | |
| 2393 | 915 | } |
| 916 | ||
| 11360 | 917 | gg_free_event(ev); |
| 918 | } | |
| 919 | /* }}} */ | |
| 2393 | 920 | |
| 11360 | 921 | /** |
| 922 | * Set offline status for all buddies. | |
| 923 | * | |
| 924 | * @param gc Connection handler | |
| 925 | */ | |
| 926 | /* static void ggp_buddylist_offline(GaimConnection *gc) {{{ */ | |
| 927 | static void ggp_buddylist_offline(GaimConnection *gc) | |
| 928 | { | |
| 929 | GaimBuddyList *blist; | |
| 930 | GaimBlistNode *gnode, *cnode, *bnode; | |
| 931 | GaimBuddy *buddy; | |
| 2393 | 932 | |
| 11360 | 933 | if ((blist = gaim_get_blist()) != NULL) |
| 934 | { | |
| 935 | for (gnode = blist->root; gnode != NULL; gnode = gnode->next) | |
| 936 | { | |
| 937 | if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 938 | continue; | |
| 939 | for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) | |
| 940 | { | |
| 941 | if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 942 | continue; | |
| 943 | for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) | |
| 944 | { | |
| 945 | if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 946 | continue; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
947 | |
| 11360 | 948 | buddy = (GaimBuddy *)bnode; |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
949 | |
| 11360 | 950 | if (buddy->account != gc->account) |
| 951 | continue; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
952 | |
| 11360 | 953 | gaim_prpl_got_user_status( |
| 954 | gaim_connection_get_account(gc), | |
| 955 | buddy->name, "offline", NULL); | |
| 956 | gaim_debug_info("gg", "ggp_buddylist_offline: gone: %s\n", buddy->name); | |
| 957 | } | |
| 958 | } | |
| 959 | } | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
960 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
961 | } |
| 11360 | 962 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
963 | |
| 11360 | 964 | /** |
| 965 | * Get all the buddies in the current account. | |
| 966 | * | |
| 967 | * @param account Current account. | |
| 968 | * | |
| 969 | * @return List of buddies. | |
| 970 | */ | |
| 971 | /* static char *ggp_buddylist_dump(GaimAccount *account) {{{ */ | |
| 972 | static char *ggp_buddylist_dump(GaimAccount *account) | |
| 973 | { | |
| 974 | GaimBuddyList *blist; | |
| 6695 | 975 | GaimBlistNode *gnode, *cnode, *bnode; |
| 11360 | 976 | GaimGroup *group; |
| 977 | GaimBuddy *buddy; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
978 | |
| 11360 | 979 | char *buddylist = g_strdup(""); |
| 980 | char *ptr; | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
981 | |
| 11360 | 982 | if ((blist = gaim_get_blist()) == NULL) |
| 983 | return NULL; | |
| 984 | ||
| 985 | for (gnode = blist->root; gnode != NULL; gnode = gnode->next) { | |
| 986 | if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 4785 | 987 | continue; |
| 11360 | 988 | |
| 989 | group = (GaimGroup *)gnode; | |
| 990 | ||
| 991 | for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) { | |
| 992 | if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 6695 | 993 | continue; |
| 4785 | 994 | |
| 11360 | 995 | for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) { |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
996 | gchar *newdata, *name, *show, *gname; |
|
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
997 | |
| 11360 | 998 | if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
| 6695 | 999 | continue; |
| 4349 | 1000 | |
| 11360 | 1001 | buddy = (GaimBuddy *)bnode; |
| 1002 | if (buddy->account != account) | |
| 1003 | continue; | |
| 4516 | 1004 | |
| 11360 | 1005 | /* GG Number */ |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1006 | name = buddy->name; |
| 11360 | 1007 | /* GG Pseudo */ |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1008 | show = buddy->alias ? buddy->alias : buddy->name; |
| 11360 | 1009 | /* Group Name */ |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1010 | gname = group->name; |
| 6695 | 1011 | |
| 11360 | 1012 | newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s;%s%s\r\n", |
| 1013 | show, show, show, show, "", gname, name, "", ""); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1014 | |
| 11360 | 1015 | ptr = buddylist; |
| 1016 | buddylist = g_strconcat(ptr, newdata, NULL); | |
| 1017 | ||
| 1018 | g_free(newdata); | |
| 1019 | g_free(ptr); | |
| 4349 | 1020 | } |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
1021 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
1022 | } |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
1023 | |
| 11360 | 1024 | return buddylist; |
| 1025 | } | |
| 1026 | /* }}} */ | |
| 1027 | ||
| 1028 | /** | |
| 1029 | * Request buddylist from the server. | |
| 1030 | * Buddylist is received in the ggp_callback_recv(). | |
| 1031 | * | |
| 1032 | * @param Current action handler. | |
| 1033 | */ | |
| 1034 | /* static void ggp_action_buddylist_get(GaimPluginAction *action) {{{ */ | |
| 1035 | static void ggp_action_buddylist_get(GaimPluginAction *action) | |
| 1036 | { | |
| 1037 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1038 | GGPInfo *info = gc->proto_data; | |
| 1039 | ||
| 1040 | gaim_debug_info("gg", "Downloading...\n"); | |
| 1041 | ||
| 1042 | gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | |
| 1043 | } | |
| 1044 | /* }}} */ | |
| 1045 | ||
| 1046 | /** | |
| 1047 | * Upload the buddylist to the server. | |
| 1048 | * | |
| 1049 | * @param action Current action handler. | |
| 1050 | */ | |
| 1051 | /* static void ggp_action_buddylist_put(GaimPluginAction *action) {{{ */ | |
| 1052 | static void ggp_action_buddylist_put(GaimPluginAction *action) | |
| 1053 | { | |
| 1054 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1055 | GGPInfo *info = gc->proto_data; | |
| 1056 | ||
| 1057 | char *buddylist = ggp_buddylist_dump(gaim_connection_get_account(gc)); | |
| 1058 | ||
| 1059 | gaim_debug_info("gg", "Uploading...\n"); | |
| 1060 | ||
| 1061 | if (buddylist == NULL) | |
| 1062 | return; | |
| 1063 | ||
| 1064 | gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist); | |
| 1065 | g_free(buddylist); | |
| 1066 | } | |
| 1067 | /* }}} */ | |
| 1068 | ||
| 1069 | /** | |
| 1070 | * Delete buddylist from the server. | |
| 1071 | * | |
| 1072 | * @param action Current action handler. | |
| 1073 | */ | |
| 1074 | /* static void ggp_action_buddylist_delete(GaimPluginAction *action) {{{ */ | |
| 1075 | static void ggp_action_buddylist_delete(GaimPluginAction *action) | |
| 1076 | { | |
| 1077 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1078 | GGPInfo *info = gc->proto_data; | |
| 1079 | ||
| 1080 | gaim_debug_info("gg", "Deleting...\n"); | |
| 1081 | ||
| 1082 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 1083 | } | |
| 1084 | /* }}} */ | |
| 1085 | ||
| 1086 | /* | |
| 1087 | */ | |
| 1088 | /* static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 1089 | static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) | |
| 1090 | { | |
| 1091 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 1092 | ||
| 1093 | FILE *fh; | |
| 1094 | char *buddylist = ggp_buddylist_dump(account); | |
| 1095 | gchar *msg; | |
| 1096 | ||
| 1097 | gaim_debug_info("gg", "Saving...\n"); | |
| 1098 | gaim_debug_info("gg", "file = %s\n", file); | |
| 1099 | ||
| 1100 | if (buddylist == NULL) { | |
| 1101 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 1102 | _("Your buddylist is empty, nothing was written to the file."), | |
| 1103 | NULL); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
1104 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
1105 | } |
| 2393 | 1106 | |
| 11360 | 1107 | if ((fh = g_fopen(file, "wb")) == NULL) { |
| 1108 | msg = g_strconcat(_("Couldn't open file"), ": ", file, "\n", NULL); | |
| 1109 | gaim_debug_error("gg", "Could not open file: %s\n", file); | |
| 1110 | gaim_notify_error(account, _("Couldn't open file"), msg, NULL); | |
| 1111 | g_free(msg); | |
| 1112 | g_free(file); | |
| 1113 | return; | |
| 1114 | } | |
| 1115 | ||
| 1116 | fwrite(buddylist, sizeof(char), g_utf8_strlen(buddylist, -1), fh); | |
| 1117 | fclose(fh); | |
| 1118 | g_free(buddylist); | |
| 1119 | ||
| 1120 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 1121 | _("Buddylist saved successfully!"), NULL); | |
| 1122 | } | |
| 1123 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
1124 | |
| 11360 | 1125 | /* |
| 1126 | */ | |
| 1127 | /* static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 1128 | static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) | |
| 1129 | { | |
| 1130 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 1131 | char *buddylist, *tmp, *ptr; | |
| 1132 | FILE *fh; | |
| 1133 | gchar *msg; | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
1134 | |
| 11360 | 1135 | buddylist = g_strdup(""); |
| 1136 | tmp = g_new0(gchar, 50); | |
| 1137 | ||
| 1138 | gaim_debug_info("gg", "file_name = %s\n", file); | |
| 1139 | ||
| 1140 | if ((fh = g_fopen(file, "rb")) == NULL) { | |
| 1141 | msg = g_strconcat(_("Couldn't open file"), ": ", file, "\n", NULL); | |
| 1142 | gaim_debug_error("gg", "Could not open file: %s\n", file); | |
| 1143 | gaim_notify_error(account, _("Could't open file"), msg, NULL); | |
| 1144 | g_free(msg); | |
| 1145 | g_free(file); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
1146 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
1147 | } |
| 11360 | 1148 | |
| 1149 | while (fread(tmp, sizeof(gchar), 49, fh) == 49) { | |
| 1150 | tmp[49] = '\0'; | |
| 1151 | /* gaim_debug_info("gg", "read: %s\n", tmp); */ | |
| 1152 | ptr = g_strconcat(buddylist, tmp, NULL); | |
| 1153 | memset(tmp, '\0', 50); | |
| 1154 | g_free(buddylist); | |
| 1155 | buddylist = ptr; | |
| 1156 | } | |
| 1157 | fclose(fh); | |
| 1158 | g_free(tmp); | |
| 1159 | ||
| 1160 | ggp_buddylist_load(gc, buddylist); | |
| 1161 | g_free(buddylist); | |
| 1162 | ||
| 1163 | gaim_notify_info(account, | |
| 1164 | _("Load Buddylist..."), | |
| 1165 | _("Buddylist loaded successfully!"), NULL); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
1166 | } |
| 11360 | 1167 | /* }}} */ |
| 1168 | ||
| 1169 | /* | |
| 1170 | */ | |
| 1171 | /* static void ggp_action_buddylist_save(GaimPluginAction *action) {{{ */ | |
| 1172 | static void ggp_action_buddylist_save(GaimPluginAction *action) | |
| 1173 | { | |
| 1174 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1175 | ||
| 1176 | gaim_request_file(action, _("Save buddylist..."), NULL, TRUE, | |
| 1177 | G_CALLBACK(ggp_callback_buddylist_save_ok), NULL, gc); | |
| 1178 | } | |
| 1179 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
1180 | |
| 11360 | 1181 | /* |
| 1182 | */ | |
| 1183 | /* static void ggp_action_buddylist_load(GaimPluginAction *action) {{{ */ | |
| 1184 | static void ggp_action_buddylist_load(GaimPluginAction *action) | |
| 1185 | { | |
| 1186 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1187 | ||
| 1188 | gaim_request_file(action, "Load buddylist from file...", NULL, FALSE, | |
| 1189 | G_CALLBACK(ggp_callback_buddylist_load_ok), NULL, gc); | |
| 1190 | } | |
| 1191 | /* }}} */ | |
| 1192 | ||
| 1193 | /* | |
| 1194 | */ | |
| 1195 | /* static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 1196 | static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 2393 | 1197 | { |
| 11360 | 1198 | GaimAccount *account; |
| 1199 | GGPInfo *info = gc->proto_data; | |
| 1200 | struct gg_http *h; | |
| 1201 | gchar *cur, *p1, *p2, *t; | |
| 1202 | ||
| 1203 | cur = charset_convert(gaim_request_fields_get_string(fields, "password_cur"), | |
| 1204 | "UTF-8", "CP1250"); | |
| 1205 | p1 = charset_convert(gaim_request_fields_get_string(fields, "password1"), | |
| 1206 | "UTF-8", "CP1250"); | |
| 1207 | p2 = charset_convert(gaim_request_fields_get_string(fields, "password2"), | |
| 1208 | "UTF-8", "CP1250"); | |
| 1209 | t = charset_convert(gaim_request_fields_get_string(fields, "token"), | |
| 1210 | "UTF-8", "CP1250"); | |
| 1211 | ||
| 1212 | account = gaim_connection_get_account(gc); | |
| 1213 | ||
| 1214 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 1215 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 1216 | gaim_notify_error(account, NULL, _("Fill in the fields."), NULL); | |
| 1217 | goto exit_err; | |
| 1218 | } | |
| 1219 | ||
| 1220 | if (g_utf8_collate(p1, p2) != 0) { | |
| 1221 | gaim_notify_error(account, NULL, _("New passwords do not match."), NULL); | |
| 1222 | goto exit_err; | |
| 1223 | } | |
| 2393 | 1224 | |
| 11360 | 1225 | if (g_utf8_collate(cur, gaim_account_get_password(account)) != 0) { |
| 1226 | gaim_notify_error(account, NULL, | |
| 1227 | _("Your current password is different from the one that you specified."), | |
| 1228 | NULL); | |
| 1229 | goto exit_err; | |
| 1230 | } | |
| 1231 | ||
| 1232 | gaim_debug_info("gg", "change_passwd: old=%s; p1=%s; token=%s\n", | |
| 1233 | cur, p1, info->chpasswd_token->token_id); | |
| 1234 | ||
| 1235 | /* XXX: this e-mail should be a pref... */ | |
| 1236 | h = gg_change_passwd4(ggp_get_uin(account), | |
| 1237 | "user@example.net", gaim_account_get_password(account), | |
| 1238 | p1, info->chpasswd_token->token_id, t, 0); | |
| 2393 | 1239 | |
| 11360 | 1240 | if (h == NULL) { |
| 1241 | gaim_notify_error(account, NULL, | |
| 1242 | _("Unable to change password. Error occured.\n"), | |
| 1243 | NULL); | |
| 1244 | goto exit_err; | |
| 1245 | } | |
| 1246 | ||
| 1247 | gaim_account_set_password(account, p1); | |
| 1248 | ||
| 1249 | gg_change_passwd_free(h); | |
| 1250 | ||
| 1251 | gaim_notify_info(account, _("Change password for the Gadu-Gadu account"), | |
| 1252 | _("Password was changed successfully!"), NULL); | |
| 1253 | ||
| 1254 | exit_err: | |
| 1255 | g_free(cur); | |
| 1256 | g_free(p1); | |
| 1257 | g_free(p2); | |
| 1258 | g_free(t); | |
| 1259 | g_free(info->chpasswd_token->token_id); | |
| 1260 | g_free(info->chpasswd_token); | |
| 1261 | } | |
| 1262 | /* }}} */ | |
| 2393 | 1263 | |
| 11360 | 1264 | /* |
| 1265 | */ | |
| 1266 | /* static void ggp_callback_register_account_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 1267 | static void ggp_callback_register_account_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 1268 | { | |
| 1269 | GaimAccount *account; | |
| 1270 | GGPInfo *info = gc->proto_data; | |
| 1271 | struct gg_http *h = NULL; | |
| 1272 | struct gg_pubdir *s; | |
| 1273 | uin_t uin; | |
| 1274 | gchar *email, *p1, *p2, *t; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1275 | |
| 11360 | 1276 | email = charset_convert(gaim_request_fields_get_string(fields, "email"), |
| 1277 | "UTF-8", "CP1250"); | |
| 1278 | p1 = charset_convert(gaim_request_fields_get_string(fields, "password1"), | |
| 1279 | "UTF-8", "CP1250"); | |
| 1280 | p2 = charset_convert(gaim_request_fields_get_string(fields, "password2"), | |
| 1281 | "UTF-8", "CP1250"); | |
| 1282 | t = charset_convert(gaim_request_fields_get_string(fields, "token"), | |
| 1283 | "UTF-8", "CP1250"); | |
| 1284 | ||
| 1285 | account = gaim_connection_get_account(gc); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1286 | |
| 11360 | 1287 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || |
| 1288 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 1289 | gaim_notify_error(account, NULL, _("Fill in the fields."), NULL); | |
| 1290 | goto exit_err; | |
| 1291 | } | |
| 1292 | ||
| 1293 | if (g_utf8_collate(p1, p2) != 0) { | |
| 1294 | gaim_notify_error(account, NULL, _("Passwords do not match."), NULL); | |
| 1295 | goto exit_err; | |
| 1296 | } | |
| 1297 | ||
| 1298 | h = gg_register3(email, p1, info->register_token->token_id, t, 0); | |
| 1299 | if (h == NULL || !(s = h->data) || !s->success) { | |
| 1300 | gaim_notify_error(account, NULL, | |
| 1301 | _("Unable to register new account. Error occured.\n"), | |
| 1302 | NULL); | |
| 1303 | goto exit_err; | |
| 2393 | 1304 | } |
| 1305 | ||
| 11360 | 1306 | uin = s->uin; |
| 1307 | gaim_debug_info("gg", "registered uin: %d\n", uin); | |
| 1308 | ||
| 1309 | gaim_notify_info(NULL, _("New Gadu-Gadu Account Registered"), | |
| 1310 | _("Registration completed successfully!"), NULL); | |
| 1311 | ||
| 1312 | exit_err: | |
| 1313 | gg_register_free(h); | |
| 1314 | g_free(email); | |
| 1315 | g_free(p1); | |
| 1316 | g_free(p2); | |
| 1317 | g_free(t); | |
| 1318 | g_free(info->register_token->token_id); | |
| 1319 | g_free(info->register_token); | |
| 1320 | } | |
| 1321 | /* }}} */ | |
| 1322 | ||
| 1323 | /* | |
| 1324 | */ | |
| 1325 | /* static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 1326 | static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) | |
| 1327 | { | |
| 1328 | GGPInfo *info = gc->proto_data; | |
| 1329 | GGPSearchForm *form; | |
| 1330 | ||
| 1331 | form = ggp_searchform_new(); | |
| 1332 | /* | |
| 1333 | * TODO: Fail if we have already a form attached. Only one search | |
| 1334 | * at a time will be allowed for now. | |
| 1335 | */ | |
| 1336 | info->search_form = form; | |
| 1337 | ||
| 1338 | form->lastname = charset_convert(gaim_request_fields_get_string(fields, "lastname"), | |
| 1339 | "UTF-8", "CP1250"); | |
| 1340 | form->firstname = charset_convert(gaim_request_fields_get_string(fields, "firstname"), | |
| 1341 | "UTF-8", "CP1250"); | |
| 1342 | form->nickname = charset_convert(gaim_request_fields_get_string(fields, "nickname"), | |
| 1343 | "UTF-8", "CP1250"); | |
| 1344 | form->city = charset_convert(gaim_request_fields_get_string(fields, "city"), | |
| 1345 | "UTF-8", "CP1250"); | |
| 1346 | form->birthyear = charset_convert(gaim_request_fields_get_string(fields, "year"), | |
| 1347 | "UTF-8", "CP1250"); | |
| 1348 | ||
| 1349 | switch (gaim_request_fields_get_choice(fields, "gender")) { | |
| 1350 | case 1: | |
| 1351 | form->gender = g_strdup(GG_PUBDIR50_GENDER_MALE); | |
| 1352 | break; | |
| 1353 | case 2: | |
| 1354 | form->gender = g_strdup(GG_PUBDIR50_GENDER_FEMALE); | |
| 1355 | break; | |
| 1356 | default: | |
| 1357 | form->gender = NULL; | |
| 1358 | break; | |
| 1359 | } | |
| 1360 | ||
| 1361 | form->active = gaim_request_fields_get_bool(fields, "active") | |
| 1362 | ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL; | |
| 1363 | ||
| 1364 | form->offset = g_strdup("0"); | |
| 1365 | ||
| 1366 | ggp_pubdir_start_search(gc, form); | |
| 1367 | } | |
| 1368 | /* }}} */ | |
| 1369 | ||
| 1370 | /* | |
| 1371 | */ | |
| 1372 | /* static void ggp_find_buddies(GaimPluginAction *action) {{{ */ | |
| 1373 | static void ggp_find_buddies(GaimPluginAction *action) | |
| 1374 | { | |
| 1375 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1376 | ||
| 1377 | GaimRequestFields *fields; | |
| 1378 | GaimRequestFieldGroup *group; | |
| 1379 | GaimRequestField *field; | |
| 1380 | ||
| 1381 | fields = gaim_request_fields_new(); | |
| 1382 | group = gaim_request_field_group_new(NULL); | |
| 1383 | gaim_request_fields_add_group(fields, group); | |
| 1384 | ||
| 1385 | field = gaim_request_field_string_new("lastname", _("Last name"), NULL, FALSE); | |
| 1386 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1387 | gaim_request_field_group_add_field(group, field); | |
| 1388 | ||
| 1389 | field = gaim_request_field_string_new("firstname", _("First name"), NULL, FALSE); | |
| 1390 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1391 | gaim_request_field_group_add_field(group, field); | |
| 1392 | ||
| 1393 | field = gaim_request_field_string_new("nickname", _("Nickname"), NULL, FALSE); | |
| 1394 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1395 | gaim_request_field_group_add_field(group, field); | |
| 1396 | ||
| 1397 | field = gaim_request_field_string_new("city", _("City"), NULL, FALSE); | |
| 1398 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1399 | gaim_request_field_group_add_field(group, field); | |
| 1400 | ||
| 1401 | field = gaim_request_field_string_new("year", _("Year of birth"), NULL, FALSE); | |
| 1402 | gaim_request_field_group_add_field(group, field); | |
| 1403 | ||
| 1404 | field = gaim_request_field_choice_new("gender", "Gender", 0); | |
| 1405 | gaim_request_field_choice_add(field, "Male or female"); | |
| 1406 | gaim_request_field_choice_add(field, "Male"); | |
| 1407 | gaim_request_field_choice_add(field, "Female"); | |
| 1408 | gaim_request_field_group_add_field(group, field); | |
| 1409 | ||
| 1410 | field = gaim_request_field_bool_new("active", _("Only online"), FALSE); | |
| 1411 | gaim_request_field_group_add_field(group, field); | |
| 1412 | ||
| 1413 | gaim_request_fields(gc, | |
| 1414 | _("Find buddies"), | |
| 1415 | _("Find buddies"), | |
| 1416 | _("Please, enter your search criteria below"), | |
| 1417 | fields, | |
| 1418 | _("OK"), G_CALLBACK(ggp_callback_find_buddies), | |
| 1419 | _("Cancel"), NULL, | |
| 1420 | gc); | |
| 1421 | } | |
| 1422 | /* }}} */ | |
| 1423 | ||
| 1424 | /* | |
| 1425 | */ | |
| 1426 | /* static void ggp_change_passwd(GaimPluginAction *action) {{{ */ | |
| 1427 | static void ggp_change_passwd(GaimPluginAction *action) | |
| 1428 | { | |
| 1429 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 1430 | GGPInfo *info = gc->proto_data; | |
| 1431 | GGPToken *token; | |
| 1432 | ||
| 1433 | GaimRequestFields *fields; | |
| 1434 | GaimRequestFieldGroup *group; | |
| 1435 | GaimRequestField *field; | |
| 1436 | ||
| 1437 | struct gg_http *req; | |
| 1438 | struct gg_token *t; | |
| 1439 | gchar *msg; | |
| 1440 | ||
| 1441 | gaim_debug_info("gg", "token: requested.\n"); | |
| 1442 | ||
| 1443 | /* TODO: This should be async. */ | |
| 1444 | if ((req = gg_token(0)) == NULL) { | |
| 1445 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 1446 | _("Token Error"), | |
| 1447 | _("Unable to fetch the token.\n"), NULL); | |
| 2393 | 1448 | return; |
| 1449 | } | |
| 11360 | 1450 | |
| 1451 | t = req->data; | |
| 1452 | ||
| 1453 | token = g_new0(GGPToken, 1); | |
| 1454 | token->token_id = g_strdup(t->tokenid); | |
| 1455 | info->chpasswd_token = token; | |
| 1456 | ||
| 1457 | ||
| 1458 | fields = gaim_request_fields_new(); | |
| 1459 | group = gaim_request_field_group_new(NULL); | |
| 1460 | gaim_request_fields_add_group(fields, group); | |
| 1461 | ||
| 1462 | field = gaim_request_field_string_new("password_cur", _("Current password"), "", FALSE); | |
| 1463 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1464 | gaim_request_field_group_add_field(group, field); | |
| 1465 | ||
| 1466 | field = gaim_request_field_string_new("password1", _("Password"), "", FALSE); | |
| 1467 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1468 | gaim_request_field_group_add_field(group, field); | |
| 1469 | ||
| 1470 | field = gaim_request_field_string_new("password2", _("Password (retype)"), "", FALSE); | |
| 1471 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1472 | gaim_request_field_group_add_field(group, field); | |
| 1473 | ||
| 1474 | field = gaim_request_field_string_new("token", _("Enter current token"), "", FALSE); | |
| 1475 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1476 | gaim_request_field_group_add_field(group, field); | |
| 1477 | ||
| 1478 | /* original size: 60x24 */ | |
| 1479 | field = gaim_request_field_image_new("token_img", _("Current token"), req->body, req->body_size); | |
| 1480 | gaim_request_field_group_add_field(group, field); | |
| 1481 | ||
| 1482 | gg_token_free(req); | |
| 1483 | ||
| 1484 | msg = g_strdup_printf("%s %d", | |
| 1485 | _("Please, enter your current password and your new password for UIN: "), | |
| 1486 | ggp_get_uin(gaim_connection_get_account(gc))); | |
| 1487 | ||
| 1488 | gaim_request_fields(gc, | |
| 1489 | _("Change Gadu-Gadu Password"), | |
| 1490 | _("Change Gadu-Gadu Password"), | |
| 1491 | msg, | |
| 1492 | fields, _("OK"), G_CALLBACK(ggp_callback_change_passwd_ok), | |
| 1493 | _("Cancel"), NULL, gc); | |
| 1494 | ||
| 1495 | g_free(msg); | |
| 1496 | } | |
| 1497 | /* }}} */ | |
| 1498 | ||
| 11394 | 1499 | /* |
| 1500 | */ | |
| 1501 | /* static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 1502 | static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 1503 | { | |
| 1504 | GGPInfo *info = gc->proto_data; | |
| 1505 | GaimRequestField *field; | |
| 1506 | const GList *sel, *l; | |
| 1507 | ||
| 1508 | field = gaim_request_fields_get_field(fields, "name"); | |
| 1509 | sel = gaim_request_field_list_get_selected(field); | |
| 1510 | gaim_debug_info("gg", "selected chat %s for buddy %s\n", sel->data, info->tmp_buddy); | |
| 1511 | ||
| 1512 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1513 | GGPChat *chat = l->data; | |
| 1514 | ||
| 1515 | if (g_utf8_collate(chat->name, sel->data) == 0) { | |
| 1516 | chat->participants = g_list_append(chat->participants, info->tmp_buddy); | |
| 1517 | break; | |
| 1518 | } | |
| 1519 | } | |
| 1520 | } | |
| 1521 | /* }}} */ | |
| 1522 | ||
| 1523 | /* | |
| 1524 | */ | |
| 1525 | /* static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 1526 | static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) | |
| 1527 | { | |
| 1528 | GaimBuddy *buddy; | |
| 1529 | GaimConnection *gc; | |
| 1530 | GGPInfo *info; | |
| 1531 | ||
| 1532 | GaimRequestFields *fields; | |
| 1533 | GaimRequestFieldGroup *group; | |
| 1534 | GaimRequestField *field; | |
| 1535 | ||
| 1536 | GList *l; | |
| 1537 | gchar *msg; | |
| 1538 | ||
| 1539 | buddy = (GaimBuddy *)node; | |
| 1540 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 1541 | info = gc->proto_data; | |
| 1542 | ||
| 1543 | /* TODO: It tmp_buddy != NULL then stop! */ | |
| 1544 | info->tmp_buddy = g_strdup(gaim_buddy_get_name(buddy)); | |
| 1545 | ||
| 1546 | fields = gaim_request_fields_new(); | |
| 1547 | group = gaim_request_field_group_new(NULL); | |
| 1548 | gaim_request_fields_add_group(fields, group); | |
| 1549 | ||
| 1550 | field = gaim_request_field_list_new("name", "Chat name"); | |
| 1551 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1552 | GGPChat *chat = l->data; | |
| 1553 | gaim_debug_info("gg", "adding chat %s\n", chat->name); | |
| 1554 | gaim_request_field_list_add(field, g_strdup(chat->name), g_strdup(chat->name)); | |
| 1555 | } | |
| 1556 | gaim_request_field_group_add_field(group, field); | |
| 1557 | ||
| 1558 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), gaim_buddy_get_name(buddy)); | |
| 1559 | gaim_request_fields(gc, | |
| 1560 | _("Add to chat..."), | |
| 1561 | _("Add to chat..."), | |
| 1562 | msg, | |
| 1563 | fields, | |
| 1564 | _("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok), | |
| 1565 | _("Cancel"), NULL, gc); | |
| 1566 | g_free(msg); | |
| 1567 | } | |
| 1568 | /* }}} */ | |
| 1569 | ||
| 11360 | 1570 | /* ---------------------------------------------------------------------- */ |
| 1571 | /* ----- GaimPluginProtocolInfo ----------------------------------------- */ | |
| 1572 | /* ---------------------------------------------------------------------- */ | |
| 1573 | ||
| 1574 | /* | |
| 1575 | */ | |
| 1576 | /* static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) {{{ */ | |
| 1577 | static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) | |
| 1578 | { | |
| 1579 | return "gadu-gadu"; | |
| 1580 | } | |
| 1581 | /* }}} */ | |
| 1582 | ||
| 1583 | /* static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) {{{ */ | |
| 1584 | static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) | |
| 1585 | { | |
| 1586 | GaimPresence *presence = gaim_buddy_get_presence(b); | |
| 1587 | ||
| 1588 | /* | |
| 1589 | * Note to myself: | |
| 1590 | * The only valid status types are those defined | |
| 1591 | * in prpl_info->status_types. | |
| 1592 | * | |
| 1593 | * Usable icons: away, blocked, dnd, extendedaway, | |
| 1594 | * freeforchat, ignored, invisible, na, offline. | |
| 1595 | */ | |
| 1596 | ||
| 1597 | if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 1598 | *se = "offline"; | |
| 1599 | } else if (gaim_presence_is_status_active(presence, "away")) { | |
| 1600 | *se = "away"; | |
| 1601 | } else if (gaim_presence_is_status_active(presence, "online")) { | |
| 1602 | *se = "online"; | |
| 1603 | } else if (gaim_presence_is_status_active(presence, "offline")) { | |
| 1604 | *se = "offline"; | |
| 1605 | } else if (gaim_presence_is_status_active(presence, "blocked")) { | |
| 1606 | *se = "blocked"; | |
| 1607 | } else { | |
| 1608 | *se = "offline"; | |
| 1609 | gaim_debug_info("gg", "ggp_list_emblems: unknown status\n"); | |
| 1610 | } | |
| 2393 | 1611 | } |
| 11360 | 1612 | /* }}} */ |
| 2393 | 1613 | |
| 11360 | 1614 | /* static char *ggp_status_text(GaimBuddy *b) {{{ */ |
| 1615 | static char *ggp_status_text(GaimBuddy *b) | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1616 | { |
| 11360 | 1617 | GaimStatus *status; |
| 1618 | const char *msg; | |
| 1619 | char *text; | |
| 1620 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1621 | |
| 11360 | 1622 | 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
|
1623 | |
| 11360 | 1624 | msg = gaim_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1625 | |
| 11360 | 1626 | if (msg != NULL) { |
| 1627 | tmp = gaim_markup_strip_html(msg); | |
| 1628 | text = g_markup_escape_text(tmp, -1); | |
| 1629 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1630 | |
| 11360 | 1631 | return text; |
| 1632 | } else { | |
| 1633 | tmp = g_strdup(gaim_status_get_name(status)); | |
| 1634 | text = g_markup_escape_text(tmp, -1); | |
| 1635 | g_free(tmp); | |
| 1636 | ||
| 1637 | return text; | |
| 8997 | 1638 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1639 | } |
| 11360 | 1640 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1641 | |
| 11360 | 1642 | /* static char *ggp_tooltip_text(GaimBuddy *b) {{{ */ |
| 1643 | static char *ggp_tooltip_text(GaimBuddy *b) | |
| 1644 | { | |
| 1645 | GaimStatus *status; | |
| 1646 | char *text; | |
| 1647 | gchar *ret; | |
| 1648 | const char *msg, *name; | |
| 1649 | ||
| 1650 | status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
| 1651 | msg = gaim_status_get_attr_string(status, "message"); | |
| 1652 | name = gaim_status_get_name(status); | |
| 1653 | ||
| 1654 | if (msg != NULL) { | |
| 1655 | char *tmp = gaim_markup_strip_html(msg); | |
| 1656 | text = g_markup_escape_text(tmp, -1); | |
| 1657 | g_free(tmp); | |
| 1658 | ||
| 1659 | ret = g_strdup_printf("\n<b>%s:</b> %s: %s", | |
| 1660 | _("Status"), name, text); | |
| 1661 | ||
| 1662 | g_free(text); | |
| 1663 | } else { | |
| 1664 | ret = g_strdup_printf("\n<b>%s:</b> %s", | |
| 1665 | _("Status"), name); | |
| 1666 | } | |
| 1667 | ||
| 1668 | return ret; | |
| 1669 | } | |
| 1670 | /* }}} */ | |
| 1671 | ||
| 1672 | /* static GList *ggp_status_types(GaimAccount *account) {{{ */ | |
| 1673 | static GList *ggp_status_types(GaimAccount *account) | |
| 1674 | { | |
| 1675 | GaimStatusType *type; | |
| 1676 | GList *types = NULL; | |
| 1677 | ||
| 1678 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, "offline", _("Offline"), | |
| 1679 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1680 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1681 | types = g_list_append(types, type); | |
| 1682 | ||
| 1683 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_ONLINE, "online", _("Online"), | |
| 1684 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1685 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1686 | types = g_list_append(types, type); | |
| 1687 | ||
| 1688 | /* | |
| 1689 | * Without this selecting Available or Invisible as own status doesn't | |
| 1690 | * work. It's not used and not needed to show status of buddies. | |
| 1691 | */ | |
| 1692 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, "available", _("Available"), | |
| 1693 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1694 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1695 | types = g_list_append(types, type); | |
| 1696 | ||
| 1697 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_HIDDEN, "invisible", _("Invisible"), | |
| 1698 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1699 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1700 | types = g_list_append(types, type); | |
| 1701 | ||
| 1702 | /* type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, "not-available", "Not Available", */ | |
| 1703 | /* TRUE, TRUE, FALSE, "message", _("Message"), */ | |
| 1704 | /* gaim_value_new(GAIM_TYPE_STRING), NULL); */ | |
| 1705 | /* types = g_list_append(types, type); */ | |
| 1706 | ||
| 1707 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, "away", _("Busy"), | |
| 1708 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1709 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1710 | types = g_list_append(types, type); | |
| 1711 | ||
| 1712 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_HIDDEN, "blocked", _("Blocked"), | |
| 1713 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1714 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1715 | types = g_list_append(types, type); | |
| 1716 | ||
| 1717 | return types; | |
| 1718 | } | |
| 1719 | /* }}} */ | |
| 1720 | ||
| 1721 | /* static GList *ggp_blist_node_menu(GaimBlistNode *node) {{{ */ | |
| 1722 | static GList *ggp_blist_node_menu(GaimBlistNode *node) | |
| 2393 | 1723 | { |
| 11394 | 1724 | GaimBlistNodeAction *act; |
| 2393 | 1725 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1726 | |
| 11360 | 1727 | if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 1728 | return NULL; | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1729 | |
| 11394 | 1730 | act = gaim_blist_node_action_new("Add to chat", ggp_bmenu_add_to_chat, NULL, NULL); |
| 1731 | m = g_list_append(m, act); | |
| 2393 | 1732 | |
| 1733 | return m; | |
| 1734 | } | |
| 11360 | 1735 | /* }}} */ |
| 2393 | 1736 | |
| 11394 | 1737 | /* static GList *ggp_chat_info(GaimConnection *gc) {{{ */ |
| 1738 | static GList *ggp_chat_info(GaimConnection *gc) | |
| 1739 | { | |
| 1740 | GList *m = NULL; | |
| 1741 | struct proto_chat_entry *pce; | |
| 1742 | ||
| 1743 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1744 | pce->label = _("Chat _name:"); | |
| 1745 | pce->identifier = "name"; | |
| 1746 | pce->required = TRUE; | |
| 1747 | m = g_list_append(m, pce); | |
| 1748 | ||
| 1749 | return m; | |
| 1750 | } | |
| 1751 | /* }}} */ | |
| 1752 | ||
| 11360 | 1753 | /* static void ggp_login(GaimAccount *account, GaimStatus *status) {{{ */ |
| 1754 | static void ggp_login(GaimAccount *account, GaimStatus *status) | |
| 2393 | 1755 | { |
| 11360 | 1756 | GaimConnection *gc = gaim_account_get_connection(account); |
| 1757 | struct gg_login_params *glp = g_new0(struct gg_login_params, 1); | |
| 1758 | GGPInfo *info = g_new0(GGPInfo, 1); | |
| 1759 | ||
| 11394 | 1760 | /* Probably this should be move to some *_new() function. */ |
| 11360 | 1761 | info->session = NULL; |
| 1762 | info->searchresults_window = NULL; | |
| 11394 | 1763 | info->chats = NULL; |
| 1764 | info->chats_count = 0; | |
| 11360 | 1765 | |
| 1766 | gc->proto_data = info; | |
| 1767 | ||
| 1768 | glp->uin = ggp_get_uin(account); | |
| 1769 | glp->password = (char *)gaim_account_get_password(account); | |
| 1770 | ||
| 1771 | glp->async = 0; | |
| 1772 | glp->status = GG_STATUS_AVAIL; | |
| 1773 | glp->tls = 0; | |
| 1774 | ||
| 1775 | info->session = gg_login(glp); | |
| 1776 | if (info->session == NULL) { | |
| 1777 | gaim_connection_error(gc, _("Connection failed.")); | |
| 1778 | g_free(glp); | |
| 1779 | return; | |
| 1780 | } | |
| 1781 | gaim_debug_info("gg", "ggp_login: so far so good.\n"); | |
| 1782 | ||
| 1783 | gc->inpa = gaim_input_add(info->session->fd, GAIM_INPUT_READ, ggp_callback_recv, gc); | |
| 2393 | 1784 | |
| 11360 | 1785 | gg_change_status(info->session, GG_STATUS_AVAIL); |
| 1786 | gaim_connection_set_state(gc, GAIM_CONNECTED); | |
| 1787 | ggp_buddylist_send(gc); | |
| 1788 | } | |
| 1789 | /* }}} */ | |
| 1790 | ||
| 1791 | /* static void ggp_close(GaimConnection *gc) {{{ */ | |
| 1792 | static void ggp_close(GaimConnection *gc) | |
| 1793 | { | |
| 1794 | GGPInfo *info; | |
| 8997 | 1795 | |
| 11360 | 1796 | if (gc == NULL) { |
| 1797 | gaim_debug_info("gg", "gc == NULL\n"); | |
| 1798 | return; | |
| 1799 | } | |
| 1800 | ||
| 1801 | info = gc->proto_data; | |
| 1802 | ||
| 1803 | /* XXX: Any way to pass description here? */ | |
| 1804 | if (info->session != NULL) | |
| 1805 | gg_change_status(info->session, GG_STATUS_NOT_AVAIL); | |
| 1806 | ||
| 1807 | if (gc->inpa > 0) | |
| 1808 | gaim_input_remove(gc->inpa); | |
| 1809 | ||
| 1810 | gg_logoff(info->session); | |
| 1811 | gg_free_session(info->session); | |
| 1812 | ggp_buddylist_offline(gc); | |
| 2393 | 1813 | |
| 11360 | 1814 | gaim_debug_info("gg", "Connection closed.\n"); |
| 1815 | } | |
| 1816 | /* }}} */ | |
| 1817 | ||
| 1818 | /* static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, GaimConvImFlags flags) {{{ */ | |
| 1819 | static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, GaimConvImFlags flags) | |
| 1820 | { | |
| 1821 | GGPInfo *info = gc->proto_data; | |
| 11394 | 1822 | char *tmp; |
| 11360 | 1823 | |
| 1824 | if (strlen(msg) == 0) | |
| 1825 | return 1; | |
| 1826 | ||
| 1827 | tmp = charset_convert(msg, "UTF-8", "CP1250"); | |
| 2393 | 1828 | |
| 11360 | 1829 | if (tmp != NULL && strlen(tmp) > 0) { |
| 11394 | 1830 | if (gg_send_message(info->session, GG_CLASS_MSG, ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { |
| 11360 | 1831 | return -1; |
| 1832 | } | |
| 1833 | } | |
| 1834 | ||
| 1835 | return 1; | |
| 1836 | } | |
| 1837 | /* }}} */ | |
| 1838 | ||
| 1839 | /* static void ggp_get_info(GaimConnection *gc, const char *name) { {{{ */ | |
| 1840 | static void ggp_get_info(GaimConnection *gc, const char *name) | |
| 1841 | { | |
| 1842 | GGPInfo *info = gc->proto_data; | |
| 1843 | GGPSearchForm *form; | |
| 2393 | 1844 | |
| 11360 | 1845 | form = ggp_searchform_new(); |
| 1846 | info->search_form = form; | |
| 1847 | ||
| 1848 | form->uin = g_strdup(name); | |
| 1849 | form->offset = g_strdup("0"); | |
| 1850 | form->last_uin = g_strdup("0"); | |
| 1851 | ||
| 1852 | ggp_pubdir_start_search(gc, form); | |
| 1853 | } | |
| 1854 | /* }}} */ | |
| 1855 | ||
| 1856 | /* static void ggp_set_status(GaimAccount *account, GaimStatus *status) {{{ */ | |
| 1857 | static void ggp_set_status(GaimAccount *account, GaimStatus *status) | |
| 1858 | { | |
| 1859 | GaimStatusPrimitive prim; | |
| 1860 | GaimConnection *gc; | |
| 1861 | GGPInfo *info; | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1862 | const char *status_id, *msg; |
| 11360 | 1863 | int new_status, new_status_descr; |
| 1864 | ||
| 1865 | prim = gaim_status_type_get_primitive(gaim_status_get_type(status)); | |
| 1866 | ||
| 1867 | if (!gaim_status_is_active(status)) | |
| 1868 | return; | |
| 1869 | ||
| 1870 | if (prim == GAIM_STATUS_OFFLINE) { | |
| 1871 | gaim_account_disconnect(account); | |
| 1872 | return; | |
| 1873 | } | |
| 1874 | ||
| 1875 | if (!gaim_account_is_connected(account)) { | |
| 1876 | gaim_account_connect(account); | |
| 2393 | 1877 | return; |
| 1878 | } | |
| 11360 | 1879 | |
| 1880 | gc = gaim_account_get_connection(account); | |
| 1881 | info = gc->proto_data; | |
| 1882 | ||
| 1883 | status_id = gaim_status_get_id(status); | |
| 1884 | ||
| 1885 | gaim_debug_info("gg", "ggp_set_status: Requested status = %s\n", status_id); | |
| 2393 | 1886 | |
| 11360 | 1887 | if (strcmp(status_id, "available") == 0) { |
| 1888 | new_status = GG_STATUS_AVAIL; | |
| 1889 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1890 | } else if (strcmp(status_id, "away") == 0) { | |
| 1891 | new_status = GG_STATUS_BUSY; | |
| 1892 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1893 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1894 | new_status = GG_STATUS_INVISIBLE; | |
| 1895 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 1896 | } else { | |
| 1897 | new_status = GG_STATUS_AVAIL; | |
| 1898 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1899 | gaim_debug_info("gg", "ggp_set_status: uknown status requested (status_id=%s)\n", status_id); | |
| 1900 | } | |
| 4916 | 1901 | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1902 | msg = gaim_status_get_attr_string(status, "message"); |
| 11360 | 1903 | |
| 1904 | if (msg == NULL) { | |
| 1905 | gaim_debug_info("gg", "ggp_set_status: msg == NULL\n"); | |
| 1906 | gg_change_status(info->session, new_status); | |
| 1907 | } else { | |
| 1908 | char *tmp = charset_convert(msg, "UTF-8", "CP1250"); | |
| 1909 | gaim_debug_info("gg", "ggp_set_status: msg != NULL. msg = %s\n", tmp); | |
| 1910 | gaim_debug_info("gg", "ggp_set_status: gg_change_status_descr() = %d\n", | |
| 1911 | gg_change_status_descr(info->session, new_status_descr, tmp)); | |
| 1912 | g_free(tmp); | |
| 1913 | } | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
1914 | |
| 11360 | 1915 | } |
| 1916 | /* }}} */ | |
| 1917 | ||
| 1918 | /* static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 1919 | static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
| 1920 | { | |
| 1921 | GGPInfo *info = gc->proto_data; | |
| 1922 | ||
| 1923 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1924 | } | |
| 1925 | /* }}} */ | |
| 1926 | ||
| 1927 | /* static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 1928 | static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
| 1929 | { | |
| 1930 | GGPInfo *info = gc->proto_data; | |
| 1931 | ||
| 1932 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1933 | } | |
| 1934 | /* }}} */ | |
| 1935 | ||
| 11394 | 1936 | /* static void ggp_join_chat(GaimConnection *gc, GHashTable *data) {{{ */ |
| 1937 | static void ggp_join_chat(GaimConnection *gc, GHashTable *data) | |
| 1938 | { | |
| 1939 | GGPInfo *info = gc->proto_data; | |
| 1940 | GGPChat *chat; | |
| 1941 | char *chat_name; | |
| 1942 | GList *l; | |
| 1943 | ||
| 1944 | chat_name = g_hash_table_lookup(data, "name"); | |
| 1945 | ||
| 1946 | if (chat_name == NULL) | |
| 1947 | return; | |
| 1948 | ||
| 1949 | gaim_debug_info("gg", "joined %s chat\n", chat_name); | |
| 1950 | ||
| 1951 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1952 | chat = l->data; | |
| 1953 | ||
| 1954 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 1955 | gaim_notify_error(gc, _("Chat error"), | |
| 1956 | _("This chat name is already in use"), NULL); | |
| 1957 | return; | |
| 1958 | } | |
| 1959 | } | |
| 1960 | ||
| 1961 | ggp_chat_add_new(gc, chat_name); | |
| 1962 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 1963 | } | |
| 1964 | /* }}} */ | |
| 1965 | ||
| 1966 | /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | |
| 1967 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 1968 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 1969 | } | |
| 1970 | /* }}} */ | |
| 1971 | ||
| 1972 | /* static int ggp_chat_send(GaimConnection *gc, int id, const char *message) {{{ */ | |
| 1973 | static int ggp_chat_send(GaimConnection *gc, int id, const char *message) | |
| 1974 | { | |
| 1975 | GaimConversation *conv; | |
| 1976 | GGPInfo *info = gc->proto_data; | |
| 1977 | GGPChat *chat = NULL; | |
| 1978 | GList *l; | |
| 1979 | char *msg; | |
| 1980 | uin_t *uins; | |
| 1981 | int count = 0; | |
| 1982 | ||
| 1983 | if ((conv = gaim_find_chat(gc, id)) == NULL) | |
| 1984 | return -EINVAL; | |
| 1985 | ||
| 1986 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1987 | chat = l->data; | |
| 1988 | ||
| 1989 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 1990 | gaim_debug_info("gg", "found conv!\n"); | |
| 1991 | break; | |
| 1992 | } | |
| 1993 | ||
| 1994 | chat = NULL; | |
| 1995 | } | |
| 1996 | ||
| 1997 | if (chat == NULL) { | |
| 1998 | gaim_debug_error("gg", "ggp_chat_send: Hm... that's strange. No such chat?\n"); | |
| 1999 | return -EINVAL; | |
| 2000 | } | |
| 2001 | ||
| 2002 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 2003 | for (l = chat->participants; l != NULL; l = l->next) { | |
| 2004 | gchar *name = l->data; | |
| 2005 | uin_t uin; | |
| 2006 | ||
| 2007 | if ((uin = ggp_str_to_uin(name)) != 0) | |
| 2008 | uins[count++] = uin; | |
| 2009 | } | |
| 2010 | ||
| 2011 | msg = charset_convert(message, "UTF-8", "CP1250"); | |
| 2012 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, (unsigned char *)msg); | |
| 2013 | g_free(msg); | |
| 2014 | g_free(uins); | |
| 2015 | ||
| 2016 | serv_got_chat_in(gc, id, gaim_account_get_username(gaim_connection_get_account(gc)), | |
| 2017 | 0, message, time(NULL)); | |
| 2018 | ||
| 2019 | return 0; | |
| 2020 | } | |
| 2021 | /* }}} */ | |
| 2022 | ||
| 11360 | 2023 | /* static void ggp_keepalive(GaimConnection *gc) {{{ */ |
| 2024 | static void ggp_keepalive(GaimConnection *gc) | |
| 2025 | { | |
| 2026 | GGPInfo *info = gc->proto_data; | |
| 2027 | ||
| 2028 | /* gaim_debug_info("gg", "Keeping connection alive....\n"); */ | |
| 2029 | ||
| 2030 | if (gg_ping(info->session) < 0) { | |
| 2031 | gaim_debug_info("gg", "Not connected to the server " | |
| 2032 | "or gg_session is not correct\n"); | |
| 2033 | gaim_connection_error(gc, _("Not connected to the server.")); | |
| 4916 | 2034 | } |
| 2393 | 2035 | } |
| 11360 | 2036 | /* }}} */ |
| 2037 | ||
| 2038 | /* static void ggp_register_user(GaimAccount *account) {{{ */ | |
| 2039 | static void ggp_register_user(GaimAccount *account) | |
| 2040 | { | |
| 2041 | GaimConnection *gc; | |
| 2042 | GaimRequestFields *fields; | |
| 2043 | GaimRequestFieldGroup *group; | |
| 2044 | GaimRequestField *field; | |
| 2045 | GGPInfo *info; | |
| 2046 | GGPToken *token; | |
| 2047 | ||
| 2048 | struct gg_http *req; | |
| 2049 | struct gg_token *t; | |
| 2050 | ||
| 2051 | gaim_debug_info("gg", "token: requested.\n"); | |
| 2052 | ||
| 2053 | if ((req = gg_token(0)) == NULL) { | |
| 2054 | gaim_notify_error(account, _("Token Error"), | |
| 2055 | _("Unable to fetch the token.\n"), NULL); | |
| 2056 | return; | |
| 2057 | } | |
| 2058 | t = req->data; | |
| 2059 | ||
| 2060 | gc = gaim_account_get_connection(account); | |
| 2061 | ||
| 2062 | info = g_new0(GGPInfo, 1); | |
| 2063 | gc->proto_data = info; | |
| 2064 | ||
| 2065 | token = g_new0(GGPToken, 1); | |
| 2066 | token->token_id = g_strdup(t->tokenid); | |
| 2067 | info->register_token = token; | |
| 2068 | ||
| 2069 | fields = gaim_request_fields_new(); | |
| 2070 | group = gaim_request_field_group_new(NULL); | |
| 2071 | gaim_request_fields_add_group(fields, group); | |
| 2072 | ||
| 2073 | field = gaim_request_field_string_new("email", _("e-Mail"), "", FALSE); | |
| 2074 | gaim_request_field_string_set_masked(field, FALSE); | |
| 2075 | gaim_request_field_group_add_field(group, field); | |
| 2076 | ||
| 2077 | field = gaim_request_field_string_new("password1", _("Password"), "", FALSE); | |
| 2078 | gaim_request_field_string_set_masked(field, TRUE); | |
| 2079 | gaim_request_field_group_add_field(group, field); | |
| 2080 | ||
| 2081 | field = gaim_request_field_string_new("password2", _("Password (retype)"), "", FALSE); | |
| 2082 | gaim_request_field_string_set_masked(field, TRUE); | |
| 2083 | gaim_request_field_group_add_field(group, field); | |
| 2084 | ||
| 2085 | field = gaim_request_field_string_new("token", _("Enter current token"), "", FALSE); | |
| 2086 | gaim_request_field_string_set_masked(field, FALSE); | |
| 2087 | gaim_request_field_group_add_field(group, field); | |
| 2088 | ||
| 2089 | /* original size: 60x24 */ | |
| 2090 | field = gaim_request_field_image_new("token_img", _("Current token"), req->body, req->body_size); | |
| 2091 | gaim_request_field_group_add_field(group, field); | |
| 2092 | ||
| 2093 | gg_token_free(req); | |
| 4916 | 2094 | |
| 2393 | 2095 | |
| 11360 | 2096 | gaim_request_fields(account, |
| 2097 | _("Register New Gadu-Gadu Account"), | |
| 2098 | _("Register New Gadu-Gadu Account"), | |
| 2099 | _("Please, fill in the following fields"), | |
| 2100 | fields, _("OK"), G_CALLBACK(ggp_callback_register_account_ok), | |
| 2101 | _("Cancel"), NULL, gc); | |
| 2393 | 2102 | } |
| 11360 | 2103 | /* }}} */ |
| 2393 | 2104 | |
| 11360 | 2105 | /* static GList *ggp_actions(GaimPlugin *plugin, gpointer context) {{{ */ |
| 2106 | static GList *ggp_actions(GaimPlugin *plugin, gpointer context) | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2107 | { |
| 11360 | 2108 | GList *m = NULL; |
| 2109 | GaimPluginAction *act; | |
| 2110 | ||
| 2111 | act = gaim_plugin_action_new(_("Find buddies"), ggp_find_buddies); | |
| 2112 | m = g_list_append(m, act); | |
| 2113 | ||
| 2114 | m = g_list_append(m, NULL); | |
| 2115 | ||
| 2116 | act = gaim_plugin_action_new(_("Change password"), ggp_change_passwd); | |
| 2117 | m = g_list_append(m, act); | |
| 2118 | ||
| 2119 | m = g_list_append(m, NULL); | |
| 2120 | ||
| 2121 | act = gaim_plugin_action_new(_("Upload buddylist to Server"), ggp_action_buddylist_put); | |
| 2122 | m = g_list_append(m, act); | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2123 | |
| 11360 | 2124 | act = gaim_plugin_action_new(_("Download buddylist from Server"), ggp_action_buddylist_get); |
| 2125 | m = g_list_append(m, act); | |
| 2126 | ||
| 2127 | act = gaim_plugin_action_new(_("Delete buddylist from Server"), ggp_action_buddylist_delete); | |
| 2128 | m = g_list_append(m, act); | |
| 2129 | ||
| 2130 | act = gaim_plugin_action_new(_("Save buddylist to file"), ggp_action_buddylist_save); | |
| 2131 | m = g_list_append(m, act); | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2132 | |
| 11360 | 2133 | act = gaim_plugin_action_new(_("Load buddylist from file"), ggp_action_buddylist_load); |
| 2134 | m = g_list_append(m, act); | |
| 2135 | ||
| 2136 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2137 | } |
| 11360 | 2138 | /* }}} */ |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2139 | |
| 11360 | 2140 | /* prpl_info setup {{{ */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2141 | static GaimPluginProtocolInfo prpl_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2142 | { |
| 11360 | 2143 | OPT_PROTO_REGISTER_NOSCREENNAME, |
| 2144 | NULL, /* user_splits */ | |
| 2145 | NULL, /* protocol_options */ | |
| 9950 | 2146 | NO_BUDDY_ICONS, /* icon_spec */ |
| 11360 | 2147 | ggp_list_icon, /* list_icon */ |
| 2148 | ggp_list_emblems, /* list_emblems */ | |
| 2149 | ggp_status_text, /* status_text */ | |
| 2150 | ggp_tooltip_text, /* tooltip_text */ | |
| 2151 | ggp_status_types, /* status_types */ | |
| 2152 | ggp_blist_node_menu, /* blist_node_menu */ | |
| 11394 | 2153 | ggp_chat_info, /* chat_info */ |
| 11360 | 2154 | NULL, /* chat_info_defaults */ |
| 2155 | ggp_login, /* login */ | |
| 2156 | ggp_close, /* close */ | |
| 2157 | ggp_send_im, /* send_im */ | |
| 2158 | NULL, /* set_info */ | |
| 2159 | NULL, /* send_typing */ | |
| 2160 | ggp_get_info, /* get_info */ | |
| 2161 | ggp_set_status, /* set_away */ | |
| 2162 | NULL, /* set_idle */ | |
| 2163 | NULL, /* change_passwd */ | |
| 2164 | ggp_add_buddy, /* add_buddy */ | |
| 2165 | NULL, /* add_buddies */ | |
| 2166 | ggp_remove_buddy, /* remove_buddy */ | |
| 2167 | NULL, /* remove_buddies */ | |
| 2168 | NULL, /* add_permit */ | |
| 2169 | NULL, /* add_deny */ | |
| 2170 | NULL, /* rem_permit */ | |
| 2171 | NULL, /* rem_deny */ | |
| 2172 | NULL, /* set_permit_deny */ | |
| 11394 | 2173 | ggp_join_chat, /* join_chat */ |
| 11360 | 2174 | NULL, /* reject_chat */ |
| 11394 | 2175 | ggp_get_chat_name, /* get_chat_name */ |
| 11360 | 2176 | NULL, /* chat_invite */ |
| 2177 | NULL, /* chat_leave */ | |
| 2178 | NULL, /* chat_whisper */ | |
| 11394 | 2179 | ggp_chat_send, /* chat_send */ |
| 11360 | 2180 | ggp_keepalive, /* keepalive */ |
| 2181 | ggp_register_user, /* register_user */ | |
| 2182 | NULL, /* get_cb_info */ | |
| 2183 | NULL, /* get_cb_away */ | |
| 2184 | NULL, /* alias_buddy */ | |
| 2185 | NULL, /* group_buddy */ | |
| 2186 | NULL, /* rename_group */ | |
| 2187 | NULL, /* buddy_free */ | |
| 2188 | NULL, /* convo_closed */ | |
| 2189 | NULL, /* normalize */ | |
| 2190 | NULL, /* set_buddy_icon */ | |
| 2191 | NULL, /* remove_group */ | |
| 2192 | NULL, /* get_cb_real_name */ | |
| 2193 | NULL, /* set_chat_topic */ | |
| 2194 | NULL, /* find_blist_chat */ | |
| 2195 | NULL, /* roomlist_get_list */ | |
| 2196 | NULL, /* roomlist_cancel */ | |
| 2197 | NULL, /* roomlist_expand_category */ | |
| 2198 | NULL, /* can_receive_file */ | |
| 2199 | NULL /* send_file */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2200 | }; |
| 11360 | 2201 | /* }}} */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2202 | |
| 11360 | 2203 | /* GaimPluginInfo setup {{{ */ |
| 2204 | static GaimPluginInfo info = { | |
| 2205 | GAIM_PLUGIN_MAGIC, /* magic */ | |
| 2206 | GAIM_MAJOR_VERSION, /* major_version */ | |
| 2207 | GAIM_MINOR_VERSION, /* minor_version */ | |
| 2208 | GAIM_PLUGIN_PROTOCOL, /* plugin type */ | |
| 2209 | NULL, /* ui_requirement */ | |
| 2210 | 0, /* flags */ | |
| 2211 | NULL, /* dependencies */ | |
| 2212 | GAIM_PRIORITY_DEFAULT, /* priority */ | |
| 2213 | ||
| 2214 | "prpl-gg", /* id */ | |
| 2215 | "Gadu-Gadu", /* name */ | |
| 2216 | VERSION, /* version */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2217 | |
| 11360 | 2218 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 2219 | N_("Polish popular IM"), /* description */ | |
| 2220 | "boler@sourceforge.net", /* author */ | |
| 2221 | GAIM_WEBSITE, /* homepage */ | |
| 2222 | ||
| 2223 | NULL, /* load */ | |
| 2224 | NULL, /* unload */ | |
| 2225 | NULL, /* destroy */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2226 | |
| 11360 | 2227 | NULL, /* ui_info */ |
| 2228 | &prpl_info, /* extra_info */ | |
| 2229 | NULL, /* prefs_info */ | |
| 2230 | ggp_actions /* actions */ | |
| 2231 | }; | |
| 2232 | /* }}} */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2233 | |
| 11360 | 2234 | /* |
| 2235 | */ | |
| 2236 | /* static void init_plugin(GaimPlugin *plugin) {{{ */ | |
| 2237 | static void init_plugin(GaimPlugin *plugin) | |
| 2393 | 2238 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
2239 | GaimAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2240 | |
| 11360 | 2241 | option = gaim_account_option_string_new(_("Nickname"), "nick", _("Gadu-Gadu User")); |
| 2242 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3572 | 2243 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2244 | my_protocol = plugin; |
| 2393 | 2245 | } |
| 11360 | 2246 | /* }}} */ |
| 2393 | 2247 | |
| 11360 | 2248 | GAIM_INIT_PLUGIN(gadu-gadu, init_plugin, info); |
| 2249 | ||
| 2250 | /* vim: set ts=4 sts=0 sw=4 noet: */ | |
| 11394 | 2251 |