Sat, 22 Oct 2005 20:09:24 +0000
[gaim-migrate @ 14009]
PRPLs are no longer required to call gaim_account_connect() and
gaim_account_disconnect()--it is done in the core. Having the PRPLs
do it was kind of silly. And this should allow me to improve the
auto-reconnect plugin some. I think.
| 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 | |
| 11414 | 51 | #include "gg.h" |
| 52 | #include "confer.h" | |
| 53 | #include "search.h" | |
| 54 | #include "buddylist.h" | |
| 55 | #include "utils.h" | |
| 11394 | 56 | |
| 11414 | 57 | static GaimPlugin *my_protocol = NULL; |
| 11394 | 58 | |
| 11360 | 59 | /* ---------------------------------------------------------------------- */ |
| 11414 | 60 | /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ |
| 11360 | 61 | /* ---------------------------------------------------------------------- */ |
| 9950 | 62 | |
| 11360 | 63 | /** |
| 64 | * Request buddylist from the server. | |
| 65 | * Buddylist is received in the ggp_callback_recv(). | |
| 66 | * | |
| 67 | * @param Current action handler. | |
| 68 | */ | |
| 69 | /* static void ggp_action_buddylist_get(GaimPluginAction *action) {{{ */ | |
| 70 | static void ggp_action_buddylist_get(GaimPluginAction *action) | |
| 71 | { | |
| 72 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 73 | GGPInfo *info = gc->proto_data; | |
| 74 | ||
| 75 | gaim_debug_info("gg", "Downloading...\n"); | |
| 76 | ||
| 77 | gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | |
| 78 | } | |
| 79 | /* }}} */ | |
| 80 | ||
| 81 | /** | |
| 82 | * Upload the buddylist to the server. | |
| 83 | * | |
| 84 | * @param action Current action handler. | |
| 85 | */ | |
| 86 | /* static void ggp_action_buddylist_put(GaimPluginAction *action) {{{ */ | |
| 87 | static void ggp_action_buddylist_put(GaimPluginAction *action) | |
| 88 | { | |
| 89 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 90 | GGPInfo *info = gc->proto_data; | |
| 91 | ||
| 92 | char *buddylist = ggp_buddylist_dump(gaim_connection_get_account(gc)); | |
| 93 | ||
| 94 | gaim_debug_info("gg", "Uploading...\n"); | |
| 95 | ||
| 96 | if (buddylist == NULL) | |
| 97 | return; | |
| 98 | ||
| 99 | gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist); | |
| 100 | g_free(buddylist); | |
| 101 | } | |
| 102 | /* }}} */ | |
| 103 | ||
| 104 | /** | |
| 105 | * Delete buddylist from the server. | |
| 106 | * | |
| 107 | * @param action Current action handler. | |
| 108 | */ | |
| 109 | /* static void ggp_action_buddylist_delete(GaimPluginAction *action) {{{ */ | |
| 110 | static void ggp_action_buddylist_delete(GaimPluginAction *action) | |
| 111 | { | |
| 112 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 113 | GGPInfo *info = gc->proto_data; | |
| 114 | ||
| 115 | gaim_debug_info("gg", "Deleting...\n"); | |
| 116 | ||
| 117 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 118 | } | |
| 119 | /* }}} */ | |
| 120 | ||
| 121 | /* | |
| 122 | */ | |
| 123 | /* static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 124 | static void ggp_callback_buddylist_save_ok(GaimConnection *gc, gchar *file) | |
| 125 | { | |
| 126 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 127 | ||
| 128 | FILE *fh; | |
| 129 | char *buddylist = ggp_buddylist_dump(account); | |
| 130 | gchar *msg; | |
| 131 | ||
| 132 | gaim_debug_info("gg", "Saving...\n"); | |
| 133 | gaim_debug_info("gg", "file = %s\n", file); | |
| 134 | ||
| 135 | if (buddylist == NULL) { | |
| 136 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 137 | _("Your buddylist is empty, nothing was written to the file."), | |
| 138 | NULL); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
139 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
140 | } |
| 2393 | 141 | |
| 11360 | 142 | if ((fh = g_fopen(file, "wb")) == NULL) { |
| 143 | msg = g_strconcat(_("Couldn't open file"), ": ", file, "\n", NULL); | |
| 144 | gaim_debug_error("gg", "Could not open file: %s\n", file); | |
| 145 | gaim_notify_error(account, _("Couldn't open file"), msg, NULL); | |
| 146 | g_free(msg); | |
| 147 | g_free(file); | |
| 148 | return; | |
| 149 | } | |
| 150 | ||
| 151 | fwrite(buddylist, sizeof(char), g_utf8_strlen(buddylist, -1), fh); | |
| 152 | fclose(fh); | |
| 153 | g_free(buddylist); | |
| 154 | ||
| 155 | gaim_notify_info(account, _("Save Buddylist..."), | |
| 156 | _("Buddylist saved successfully!"), NULL); | |
| 157 | } | |
| 158 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
159 | |
| 11360 | 160 | /* |
| 161 | */ | |
| 162 | /* static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) {{{ */ | |
| 163 | static void ggp_callback_buddylist_load_ok(GaimConnection *gc, gchar *file) | |
| 164 | { | |
| 165 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 166 | char *buddylist, *tmp, *ptr; | |
| 167 | FILE *fh; | |
| 168 | gchar *msg; | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
169 | |
| 11360 | 170 | buddylist = g_strdup(""); |
| 171 | tmp = g_new0(gchar, 50); | |
| 172 | ||
| 173 | gaim_debug_info("gg", "file_name = %s\n", file); | |
| 174 | ||
| 175 | if ((fh = g_fopen(file, "rb")) == NULL) { | |
| 176 | msg = g_strconcat(_("Couldn't open file"), ": ", file, "\n", NULL); | |
| 177 | gaim_debug_error("gg", "Could not open file: %s\n", file); | |
| 178 | gaim_notify_error(account, _("Could't open file"), msg, NULL); | |
| 179 | g_free(msg); | |
| 180 | g_free(file); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
181 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
182 | } |
| 11360 | 183 | |
| 184 | while (fread(tmp, sizeof(gchar), 49, fh) == 49) { | |
| 185 | tmp[49] = '\0'; | |
| 186 | /* gaim_debug_info("gg", "read: %s\n", tmp); */ | |
| 187 | ptr = g_strconcat(buddylist, tmp, NULL); | |
| 188 | memset(tmp, '\0', 50); | |
| 189 | g_free(buddylist); | |
| 190 | buddylist = ptr; | |
| 191 | } | |
| 192 | fclose(fh); | |
| 193 | g_free(tmp); | |
| 194 | ||
| 195 | ggp_buddylist_load(gc, buddylist); | |
| 196 | g_free(buddylist); | |
| 197 | ||
| 198 | gaim_notify_info(account, | |
| 199 | _("Load Buddylist..."), | |
| 200 | _("Buddylist loaded successfully!"), NULL); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
201 | } |
| 11360 | 202 | /* }}} */ |
| 203 | ||
| 204 | /* | |
| 205 | */ | |
| 206 | /* static void ggp_action_buddylist_save(GaimPluginAction *action) {{{ */ | |
| 207 | static void ggp_action_buddylist_save(GaimPluginAction *action) | |
| 208 | { | |
| 209 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 210 | ||
| 211 | gaim_request_file(action, _("Save buddylist..."), NULL, TRUE, | |
| 212 | G_CALLBACK(ggp_callback_buddylist_save_ok), NULL, gc); | |
| 213 | } | |
| 214 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
215 | |
| 11360 | 216 | /* |
| 217 | */ | |
| 218 | /* static void ggp_action_buddylist_load(GaimPluginAction *action) {{{ */ | |
| 219 | static void ggp_action_buddylist_load(GaimPluginAction *action) | |
| 220 | { | |
| 221 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 222 | ||
| 223 | gaim_request_file(action, "Load buddylist from file...", NULL, FALSE, | |
| 224 | G_CALLBACK(ggp_callback_buddylist_load_ok), NULL, gc); | |
| 225 | } | |
| 226 | /* }}} */ | |
| 227 | ||
| 228 | /* | |
| 229 | */ | |
| 11414 | 230 | /* static void ggp_callback_register_account_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 231 | static void ggp_callback_register_account_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 232 | { | |
| 233 | GaimAccount *account; | |
| 234 | GGPInfo *info = gc->proto_data; | |
| 235 | struct gg_http *h = NULL; | |
| 236 | struct gg_pubdir *s; | |
| 237 | uin_t uin; | |
| 238 | gchar *email, *p1, *p2, *t; | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
239 | GGPToken *token = info->register_token; |
| 11414 | 240 | |
| 241 | email = charset_convert(gaim_request_fields_get_string(fields, "email"), | |
| 242 | "UTF-8", "CP1250"); | |
| 243 | p1 = charset_convert(gaim_request_fields_get_string(fields, "password1"), | |
| 244 | "UTF-8", "CP1250"); | |
| 245 | p2 = charset_convert(gaim_request_fields_get_string(fields, "password2"), | |
| 246 | "UTF-8", "CP1250"); | |
| 247 | t = charset_convert(gaim_request_fields_get_string(fields, "token"), | |
| 248 | "UTF-8", "CP1250"); | |
| 249 | ||
| 250 | account = gaim_connection_get_account(gc); | |
| 251 | ||
| 252 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 253 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
254 | gaim_connection_error(gc, _("Fill in the registration fields.")); |
| 11414 | 255 | goto exit_err; |
| 256 | } | |
| 257 | ||
| 258 | if (g_utf8_collate(p1, p2) != 0) { | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
259 | gaim_connection_error(gc, _("Passwords do not match.")); |
| 11414 | 260 | goto exit_err; |
| 261 | } | |
| 262 | ||
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
263 | h = gg_register3(email, p1, token->token_id, t, 0); |
| 11414 | 264 | if (h == NULL || !(s = h->data) || !s->success) { |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
265 | gaim_connection_error(gc, |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
266 | _("Unable to register new account. Error occurred.\n")); |
| 11414 | 267 | goto exit_err; |
| 268 | } | |
| 269 | ||
| 270 | uin = s->uin; | |
| 271 | gaim_debug_info("gg", "registered uin: %d\n", uin); | |
| 272 | ||
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
273 | g_free(t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
274 | t = g_strdup_printf("%u", uin); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
275 | gaim_account_set_username(account, t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
276 | /* Save the password if remembering passwords for the account */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
277 | gaim_account_set_password(account, p1); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
278 | |
| 11414 | 279 | gaim_notify_info(NULL, _("New Gadu-Gadu Account Registered"), |
| 280 | _("Registration completed successfully!"), NULL); | |
| 281 | ||
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
282 | /* TODO: the currently open Accounts Window will not be updated withthe new username and etc, we need to somehow have it refresh at this point */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
283 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
284 | /* Need to disconnect or actually log in. For now, we disconnect. */ |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
285 | gaim_connection_destroy(gc); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
286 | |
| 11414 | 287 | exit_err: |
| 288 | gg_register_free(h); | |
| 289 | g_free(email); | |
| 290 | g_free(p1); | |
| 291 | g_free(p2); | |
| 292 | g_free(t); | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
293 | g_free(token->token_id); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
294 | g_free(token); |
| 11414 | 295 | } |
| 296 | /* }}} */ | |
| 297 | ||
| 11565 | 298 | /* |
| 299 | */ | |
| 300 | /* static void ggp_callback_register_account_cancel(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
301 | static void ggp_callback_register_account_cancel(GaimConnection *gc, GaimRequestFields *fields) |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
302 | { |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
303 | GGPInfo *info = gc->proto_data; |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
304 | GGPToken *token = info->register_token; |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
305 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
306 | gaim_connection_destroy(gc); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
307 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
308 | g_free(token->token_id); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
309 | g_free(token); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
310 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
311 | } |
| 11565 | 312 | /* }}} */ |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
313 | |
| 11414 | 314 | /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ |
| 315 | ||
| 316 | /* | |
| 317 | */ | |
| 318 | /* static void ggp_callback_show_next(GaimConnection *gc, GList *row) {{{ */ | |
| 319 | static void ggp_callback_show_next(GaimConnection *gc, GList *row) | |
| 320 | { | |
| 321 | GGPInfo *info = gc->proto_data; | |
| 322 | ||
| 323 | g_free(info->search_form->offset); | |
| 324 | info->search_form->offset = g_strdup(info->search_form->last_uin); | |
| 325 | ggp_search_start(gc, info->search_form); | |
| 326 | } | |
| 327 | /* }}} */ | |
| 328 | ||
| 329 | /* | |
| 330 | */ | |
| 331 | /* static void ggp_callback_add_buddy(GaimConnection *gc, GList *row) {{{ */ | |
| 332 | static void ggp_callback_add_buddy(GaimConnection *gc, GList *row) | |
| 333 | { | |
| 334 | gaim_blist_request_add_buddy(gaim_connection_get_account(gc), | |
| 335 | g_list_nth_data(row, 0), NULL, NULL); | |
| 336 | } | |
| 337 | /* }}} */ | |
| 338 | ||
| 339 | /* | |
| 340 | */ | |
| 341 | /* static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 342 | static void ggp_callback_find_buddies(GaimConnection *gc, GaimRequestFields *fields) | |
| 343 | { | |
| 344 | GGPInfo *info = gc->proto_data; | |
| 345 | GGPSearchForm *form; | |
| 346 | ||
| 347 | form = ggp_search_form_new(); | |
| 348 | /* | |
| 349 | * TODO: Fail if we have already a form attached. Only one search | |
| 350 | * at a time will be allowed for now. | |
| 351 | */ | |
| 352 | info->search_form = form; | |
| 353 | ||
| 354 | form->lastname = charset_convert(gaim_request_fields_get_string(fields, "lastname"), | |
| 355 | "UTF-8", "CP1250"); | |
| 356 | form->firstname = charset_convert(gaim_request_fields_get_string(fields, "firstname"), | |
| 357 | "UTF-8", "CP1250"); | |
| 358 | form->nickname = charset_convert(gaim_request_fields_get_string(fields, "nickname"), | |
| 359 | "UTF-8", "CP1250"); | |
| 360 | form->city = charset_convert(gaim_request_fields_get_string(fields, "city"), | |
| 361 | "UTF-8", "CP1250"); | |
| 362 | form->birthyear = charset_convert(gaim_request_fields_get_string(fields, "year"), | |
| 363 | "UTF-8", "CP1250"); | |
| 364 | ||
| 365 | switch (gaim_request_fields_get_choice(fields, "gender")) { | |
| 366 | case 1: | |
| 367 | form->gender = g_strdup(GG_PUBDIR50_GENDER_MALE); | |
| 368 | break; | |
| 369 | case 2: | |
| 370 | form->gender = g_strdup(GG_PUBDIR50_GENDER_FEMALE); | |
| 371 | break; | |
| 372 | default: | |
| 373 | form->gender = NULL; | |
| 374 | break; | |
| 375 | } | |
| 376 | ||
| 377 | form->active = gaim_request_fields_get_bool(fields, "active") | |
| 378 | ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL; | |
| 379 | ||
| 380 | form->offset = g_strdup("0"); | |
| 381 | ||
| 382 | ggp_search_start(gc, form); | |
| 383 | } | |
| 384 | /* }}} */ | |
| 385 | ||
| 386 | /* | |
| 387 | */ | |
| 388 | /* static void ggp_find_buddies(GaimPluginAction *action) {{{ */ | |
| 389 | static void ggp_find_buddies(GaimPluginAction *action) | |
| 390 | { | |
| 391 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 392 | ||
| 393 | GaimRequestFields *fields; | |
| 394 | GaimRequestFieldGroup *group; | |
| 395 | GaimRequestField *field; | |
| 396 | ||
| 397 | fields = gaim_request_fields_new(); | |
| 398 | group = gaim_request_field_group_new(NULL); | |
| 399 | gaim_request_fields_add_group(fields, group); | |
| 400 | ||
| 401 | field = gaim_request_field_string_new("lastname", _("Last name"), NULL, FALSE); | |
| 402 | gaim_request_field_string_set_masked(field, FALSE); | |
| 403 | gaim_request_field_group_add_field(group, field); | |
| 404 | ||
| 405 | field = gaim_request_field_string_new("firstname", _("First name"), NULL, FALSE); | |
| 406 | gaim_request_field_string_set_masked(field, FALSE); | |
| 407 | gaim_request_field_group_add_field(group, field); | |
| 408 | ||
| 409 | field = gaim_request_field_string_new("nickname", _("Nickname"), NULL, FALSE); | |
| 410 | gaim_request_field_string_set_masked(field, FALSE); | |
| 411 | gaim_request_field_group_add_field(group, field); | |
| 412 | ||
| 413 | field = gaim_request_field_string_new("city", _("City"), NULL, FALSE); | |
| 414 | gaim_request_field_string_set_masked(field, FALSE); | |
| 415 | gaim_request_field_group_add_field(group, field); | |
| 416 | ||
| 417 | field = gaim_request_field_string_new("year", _("Year of birth"), NULL, FALSE); | |
| 418 | gaim_request_field_group_add_field(group, field); | |
| 419 | ||
| 420 | field = gaim_request_field_choice_new("gender", "Gender", 0); | |
| 421 | gaim_request_field_choice_add(field, "Male or female"); | |
| 422 | gaim_request_field_choice_add(field, "Male"); | |
| 423 | gaim_request_field_choice_add(field, "Female"); | |
| 424 | gaim_request_field_group_add_field(group, field); | |
| 425 | ||
| 426 | field = gaim_request_field_bool_new("active", _("Only online"), FALSE); | |
| 427 | gaim_request_field_group_add_field(group, field); | |
| 428 | ||
| 429 | gaim_request_fields(gc, | |
| 430 | _("Find buddies"), | |
| 431 | _("Find buddies"), | |
| 432 | _("Please, enter your search criteria below"), | |
| 433 | fields, | |
| 434 | _("OK"), G_CALLBACK(ggp_callback_find_buddies), | |
| 435 | _("Cancel"), NULL, | |
| 436 | gc); | |
| 437 | } | |
| 438 | /* }}} */ | |
| 439 | ||
| 440 | /* ----- CHANGE PASSWORD ------------------------------------------------ */ | |
| 441 | ||
| 442 | /* | |
| 443 | */ | |
| 11360 | 444 | /* static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
| 445 | static void ggp_callback_change_passwd_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 2393 | 446 | { |
| 11360 | 447 | GaimAccount *account; |
| 448 | GGPInfo *info = gc->proto_data; | |
| 449 | struct gg_http *h; | |
| 450 | gchar *cur, *p1, *p2, *t; | |
| 451 | ||
| 452 | cur = charset_convert(gaim_request_fields_get_string(fields, "password_cur"), | |
| 453 | "UTF-8", "CP1250"); | |
| 454 | p1 = charset_convert(gaim_request_fields_get_string(fields, "password1"), | |
| 455 | "UTF-8", "CP1250"); | |
| 456 | p2 = charset_convert(gaim_request_fields_get_string(fields, "password2"), | |
| 457 | "UTF-8", "CP1250"); | |
| 458 | t = charset_convert(gaim_request_fields_get_string(fields, "token"), | |
| 459 | "UTF-8", "CP1250"); | |
| 460 | ||
| 461 | account = gaim_connection_get_account(gc); | |
| 462 | ||
| 463 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 464 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 465 | gaim_notify_error(account, NULL, _("Fill in the fields."), NULL); | |
| 466 | goto exit_err; | |
| 467 | } | |
| 468 | ||
| 469 | if (g_utf8_collate(p1, p2) != 0) { | |
| 470 | gaim_notify_error(account, NULL, _("New passwords do not match."), NULL); | |
| 471 | goto exit_err; | |
| 472 | } | |
| 2393 | 473 | |
| 11360 | 474 | if (g_utf8_collate(cur, gaim_account_get_password(account)) != 0) { |
| 475 | gaim_notify_error(account, NULL, | |
| 476 | _("Your current password is different from the one that you specified."), | |
| 477 | NULL); | |
| 478 | goto exit_err; | |
| 479 | } | |
| 480 | ||
| 481 | gaim_debug_info("gg", "change_passwd: old=%s; p1=%s; token=%s\n", | |
| 482 | cur, p1, info->chpasswd_token->token_id); | |
| 483 | ||
| 484 | /* XXX: this e-mail should be a pref... */ | |
| 485 | h = gg_change_passwd4(ggp_get_uin(account), | |
| 486 | "user@example.net", gaim_account_get_password(account), | |
| 487 | p1, info->chpasswd_token->token_id, t, 0); | |
| 2393 | 488 | |
| 11360 | 489 | if (h == NULL) { |
| 490 | gaim_notify_error(account, NULL, | |
| 491 | _("Unable to change password. Error occured.\n"), | |
| 492 | NULL); | |
| 493 | goto exit_err; | |
| 494 | } | |
| 495 | ||
| 496 | gaim_account_set_password(account, p1); | |
| 497 | ||
| 498 | gg_change_passwd_free(h); | |
| 499 | ||
| 500 | gaim_notify_info(account, _("Change password for the Gadu-Gadu account"), | |
| 501 | _("Password was changed successfully!"), NULL); | |
| 502 | ||
| 503 | exit_err: | |
| 504 | g_free(cur); | |
| 505 | g_free(p1); | |
| 506 | g_free(p2); | |
| 507 | g_free(t); | |
| 508 | g_free(info->chpasswd_token->token_id); | |
| 509 | g_free(info->chpasswd_token); | |
| 510 | } | |
| 511 | /* }}} */ | |
| 2393 | 512 | |
| 11360 | 513 | /* |
| 514 | */ | |
| 515 | /* static void ggp_change_passwd(GaimPluginAction *action) {{{ */ | |
| 516 | static void ggp_change_passwd(GaimPluginAction *action) | |
| 517 | { | |
| 518 | GaimConnection *gc = (GaimConnection *)action->context; | |
| 519 | GGPInfo *info = gc->proto_data; | |
| 520 | GGPToken *token; | |
| 521 | ||
| 522 | GaimRequestFields *fields; | |
| 523 | GaimRequestFieldGroup *group; | |
| 524 | GaimRequestField *field; | |
| 525 | ||
| 526 | struct gg_http *req; | |
| 527 | struct gg_token *t; | |
| 528 | gchar *msg; | |
| 529 | ||
| 530 | gaim_debug_info("gg", "token: requested.\n"); | |
| 531 | ||
| 532 | /* TODO: This should be async. */ | |
| 533 | if ((req = gg_token(0)) == NULL) { | |
| 534 | gaim_notify_error(gaim_connection_get_account(gc), | |
| 535 | _("Token Error"), | |
| 536 | _("Unable to fetch the token.\n"), NULL); | |
| 2393 | 537 | return; |
| 538 | } | |
| 11360 | 539 | |
| 540 | t = req->data; | |
| 541 | ||
| 542 | token = g_new0(GGPToken, 1); | |
| 543 | token->token_id = g_strdup(t->tokenid); | |
| 544 | info->chpasswd_token = token; | |
| 545 | ||
| 546 | ||
| 547 | fields = gaim_request_fields_new(); | |
| 548 | group = gaim_request_field_group_new(NULL); | |
| 549 | gaim_request_fields_add_group(fields, group); | |
| 550 | ||
| 551 | field = gaim_request_field_string_new("password_cur", _("Current password"), "", FALSE); | |
| 552 | gaim_request_field_string_set_masked(field, TRUE); | |
| 553 | gaim_request_field_group_add_field(group, field); | |
| 554 | ||
| 555 | field = gaim_request_field_string_new("password1", _("Password"), "", FALSE); | |
| 556 | gaim_request_field_string_set_masked(field, TRUE); | |
| 557 | gaim_request_field_group_add_field(group, field); | |
| 558 | ||
| 559 | field = gaim_request_field_string_new("password2", _("Password (retype)"), "", FALSE); | |
| 560 | gaim_request_field_string_set_masked(field, TRUE); | |
| 561 | gaim_request_field_group_add_field(group, field); | |
| 562 | ||
| 563 | field = gaim_request_field_string_new("token", _("Enter current token"), "", FALSE); | |
| 564 | gaim_request_field_string_set_masked(field, FALSE); | |
| 565 | gaim_request_field_group_add_field(group, field); | |
| 566 | ||
| 567 | /* original size: 60x24 */ | |
| 568 | field = gaim_request_field_image_new("token_img", _("Current token"), req->body, req->body_size); | |
| 569 | gaim_request_field_group_add_field(group, field); | |
| 570 | ||
| 571 | gg_token_free(req); | |
| 572 | ||
| 573 | msg = g_strdup_printf("%s %d", | |
| 574 | _("Please, enter your current password and your new password for UIN: "), | |
| 575 | ggp_get_uin(gaim_connection_get_account(gc))); | |
| 576 | ||
| 577 | gaim_request_fields(gc, | |
| 578 | _("Change Gadu-Gadu Password"), | |
| 579 | _("Change Gadu-Gadu Password"), | |
| 580 | msg, | |
| 581 | fields, _("OK"), G_CALLBACK(ggp_callback_change_passwd_ok), | |
| 582 | _("Cancel"), NULL, gc); | |
| 583 | ||
| 584 | g_free(msg); | |
| 585 | } | |
| 586 | /* }}} */ | |
| 587 | ||
| 11414 | 588 | /* ----- CONFERENCES ---------------------------------------------------- */ |
| 589 | ||
| 11394 | 590 | /* |
| 591 | */ | |
| 592 | /* static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | |
| 593 | static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) | |
| 594 | { | |
| 595 | GGPInfo *info = gc->proto_data; | |
| 596 | GaimRequestField *field; | |
| 597 | const GList *sel, *l; | |
| 598 | ||
| 599 | field = gaim_request_fields_get_field(fields, "name"); | |
| 600 | sel = gaim_request_field_list_get_selected(field); | |
| 601 | gaim_debug_info("gg", "selected chat %s for buddy %s\n", sel->data, info->tmp_buddy); | |
| 602 | ||
| 603 | for (l = info->chats; l != NULL; l = l->next) { | |
| 604 | GGPChat *chat = l->data; | |
| 605 | ||
| 606 | if (g_utf8_collate(chat->name, sel->data) == 0) { | |
| 607 | chat->participants = g_list_append(chat->participants, info->tmp_buddy); | |
| 608 | break; | |
| 609 | } | |
| 610 | } | |
| 611 | } | |
| 612 | /* }}} */ | |
| 613 | ||
| 614 | /* | |
| 615 | */ | |
| 616 | /* static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 617 | static void ggp_bmenu_add_to_chat(GaimBlistNode *node, gpointer ignored) | |
| 618 | { | |
| 619 | GaimBuddy *buddy; | |
| 620 | GaimConnection *gc; | |
| 621 | GGPInfo *info; | |
| 622 | ||
| 623 | GaimRequestFields *fields; | |
| 624 | GaimRequestFieldGroup *group; | |
| 625 | GaimRequestField *field; | |
| 626 | ||
| 627 | GList *l; | |
| 628 | gchar *msg; | |
| 629 | ||
| 630 | buddy = (GaimBuddy *)node; | |
| 631 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 632 | info = gc->proto_data; | |
| 633 | ||
| 634 | /* TODO: It tmp_buddy != NULL then stop! */ | |
| 635 | info->tmp_buddy = g_strdup(gaim_buddy_get_name(buddy)); | |
| 636 | ||
| 637 | fields = gaim_request_fields_new(); | |
| 638 | group = gaim_request_field_group_new(NULL); | |
| 639 | gaim_request_fields_add_group(fields, group); | |
| 640 | ||
| 641 | field = gaim_request_field_list_new("name", "Chat name"); | |
| 642 | for (l = info->chats; l != NULL; l = l->next) { | |
| 643 | GGPChat *chat = l->data; | |
| 644 | gaim_debug_info("gg", "adding chat %s\n", chat->name); | |
| 645 | gaim_request_field_list_add(field, g_strdup(chat->name), g_strdup(chat->name)); | |
| 646 | } | |
| 647 | gaim_request_field_group_add_field(group, field); | |
| 648 | ||
| 649 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), gaim_buddy_get_name(buddy)); | |
| 650 | gaim_request_fields(gc, | |
| 651 | _("Add to chat..."), | |
| 652 | _("Add to chat..."), | |
| 653 | msg, | |
| 654 | fields, | |
| 655 | _("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok), | |
| 656 | _("Cancel"), NULL, gc); | |
| 657 | g_free(msg); | |
| 658 | } | |
| 659 | /* }}} */ | |
| 660 | ||
| 11414 | 661 | /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
| 662 | ||
| 11410 | 663 | /* |
| 664 | */ | |
| 665 | /* static void ggp_bmenu_block(GaimBlistNode *node, gpointer ignored) {{{ */ | |
| 666 | static void ggp_bmenu_block(GaimBlistNode *node, gpointer ignored) | |
| 667 | { | |
| 668 | GaimConnection *gc; | |
| 669 | GaimBuddy *buddy; | |
| 670 | GGPInfo *info; | |
| 671 | uin_t uin; | |
| 672 | ||
| 673 | buddy = (GaimBuddy *)node; | |
| 674 | gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | |
| 675 | info = gc->proto_data; | |
| 676 | ||
| 677 | uin = ggp_str_to_uin(gaim_buddy_get_name(buddy)); | |
| 678 | ||
| 679 | if (gaim_blist_node_get_bool(node, "blocked")) { | |
| 680 | gaim_blist_node_set_bool(node, "blocked", FALSE); | |
| 681 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 682 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 683 | gaim_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); | |
| 684 | } else { | |
| 685 | gaim_blist_node_set_bool(node, "blocked", TRUE); | |
| 686 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 687 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 688 | gaim_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); | |
| 689 | } | |
| 690 | } | |
| 691 | /* }}} */ | |
| 692 | ||
| 11360 | 693 | /* ---------------------------------------------------------------------- */ |
| 11414 | 694 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 695 | /* ---------------------------------------------------------------------- */ | |
| 696 | ||
| 697 | /** | |
| 698 | * Handle change of the status of the buddy. | |
| 699 | * | |
| 700 | * @param gc GaimConnection | |
| 701 | * @param uin UIN of the buddy. | |
| 702 | * @param status ID of the status. | |
| 703 | * @param descr Description. | |
| 704 | */ | |
| 705 | /* static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, int status, const char *descr) {{{ */ | |
| 706 | static void ggp_generic_status_handler(GaimConnection *gc, uin_t uin, int status, const char *descr) | |
| 707 | { | |
| 708 | gchar *from; | |
| 709 | const char *st; | |
| 710 | gchar *msg; | |
| 711 | ||
| 712 | from = g_strdup_printf("%ld", (unsigned long int)uin); | |
| 713 | switch (status) { | |
| 714 | case GG_STATUS_NOT_AVAIL: | |
| 715 | case GG_STATUS_NOT_AVAIL_DESCR: | |
| 716 | st = "offline"; | |
| 717 | break; | |
| 718 | case GG_STATUS_AVAIL: | |
| 719 | case GG_STATUS_AVAIL_DESCR: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
720 | st = "available"; |
| 11414 | 721 | break; |
| 722 | case GG_STATUS_BUSY: | |
| 723 | case GG_STATUS_BUSY_DESCR: | |
| 724 | st = "away"; | |
| 725 | break; | |
| 726 | case GG_STATUS_BLOCKED: | |
| 727 | /* user is blocking us.... */ | |
| 728 | st = "blocked"; | |
| 729 | break; | |
| 730 | default: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
731 | st = "available"; |
| 11414 | 732 | gaim_debug_info("gg", "GG_EVENT_NOTIFY: Unknown status: %d\n", status); |
| 733 | break; | |
| 734 | } | |
| 735 | ||
| 736 | gaim_debug_info("gg", "st = %s\n", st); | |
| 737 | msg = charset_convert(descr, "CP1250", "UTF-8"); | |
| 738 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), from, st, "message", msg, NULL); | |
| 739 | g_free(from); | |
| 740 | g_free(msg); | |
| 741 | } | |
| 742 | /* }}} */ | |
| 743 | ||
| 744 | /** | |
| 745 | * Dispatch a message received from a buddy. | |
| 746 | * | |
| 747 | * @param gc GaimConnection. | |
| 748 | * @param ev Gadu-Gadu event structure. | |
| 749 | */ | |
| 750 | /* static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) {{{ */ | |
| 751 | static void ggp_recv_message_handler(GaimConnection *gc, const struct gg_event *ev) | |
| 752 | { | |
| 753 | GGPInfo *info = gc->proto_data; | |
| 754 | GaimConversation *conv; | |
| 755 | gchar *from; | |
| 756 | gchar *msg; | |
| 757 | gchar *tmp; | |
| 758 | const char *chat_name; | |
| 759 | int chat_id; | |
| 760 | ||
| 761 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 762 | ||
| 763 | msg = charset_convert((const char *)ev->event.msg.message, | |
| 764 | "CP1250", "UTF-8"); | |
| 765 | gaim_str_strip_cr(msg); | |
| 766 | tmp = g_markup_escape_text(msg, -1); | |
| 767 | ||
| 768 | gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", | |
| 769 | from, tmp, ev->event.msg.msgclass, ev->event.msg.recipients_count); | |
| 770 | ||
| 771 | /* | |
| 772 | * Chat between only two presons will be treated as a private message. | |
| 773 | * It's due to some broken clients that send private messages | |
| 774 | * with msgclass == CHAT | |
| 775 | */ | |
| 776 | if (ev->event.msg.recipients_count == 0) { | |
| 777 | serv_got_im(gc, from, tmp, 0, ev->event.msg.time); | |
| 778 | } else { | |
| 779 | chat_name = ggp_confer_find_by_participants(gc, | |
| 780 | ev->event.msg.recipients, | |
| 781 | ev->event.msg.recipients_count); | |
| 782 | if (chat_name == NULL) { | |
| 783 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 784 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 785 | ggp_confer_participants_add_uin(gc, chat_name, ev->event.msg.sender); | |
| 786 | ggp_confer_participants_add(gc, chat_name, ev->event.msg.recipients, | |
| 787 | ev->event.msg.recipients_count); | |
| 788 | } | |
| 789 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 790 | chat_id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
| 791 | serv_got_chat_in(gc, chat_id, ggp_buddy_get_name(gc, ev->event.msg.sender), | |
| 792 | 0, msg, ev->event.msg.time); | |
| 793 | } | |
| 794 | g_free(msg); | |
| 795 | g_free(tmp); | |
| 796 | g_free(from); | |
| 797 | } | |
| 798 | /* }}} */ | |
| 799 | ||
| 800 | /* | |
| 801 | */ | |
| 802 | /* static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ | |
| 803 | static void ggp_callback_recv(gpointer _gc, gint fd, GaimInputCondition cond) | |
| 804 | { | |
| 805 | GaimConnection *gc = _gc; | |
| 806 | GGPInfo *info = gc->proto_data; | |
| 807 | struct gg_event *ev; | |
| 808 | int i; | |
| 809 | ||
| 810 | if (!(ev = gg_watch_fd(info->session))) { | |
| 811 | gaim_debug_error("gg", "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); | |
| 812 | gaim_connection_error(gc, _("Unable to read socket")); | |
| 813 | return; | |
| 814 | } | |
| 815 | ||
| 816 | switch (ev->type) { | |
| 817 | case GG_EVENT_NONE: | |
| 818 | /* Nothing happened. */ | |
| 819 | break; | |
| 820 | case GG_EVENT_MSG: | |
| 821 | ggp_recv_message_handler(gc, ev); | |
| 822 | break; | |
| 823 | case GG_EVENT_ACK: | |
| 824 | gaim_debug_info("gg", "message sent to: %ld, delivery status=%d, seq=%d\n", | |
| 825 | ev->event.ack.recipient, ev->event.ack.status, ev->event.ack.seq); | |
| 826 | break; | |
| 827 | case GG_EVENT_NOTIFY: | |
| 828 | case GG_EVENT_NOTIFY_DESCR: | |
| 829 | { | |
| 830 | struct gg_notify_reply *n; | |
| 831 | char *descr; | |
| 832 | ||
| 833 | gaim_debug_info("gg", "notify_pre: (%d) status: %d\n", | |
| 834 | ev->event.notify->uin, | |
| 835 | ev->event.notify->status); | |
| 836 | ||
| 837 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 838 | : ev->event.notify_descr.notify; | |
| 839 | ||
| 840 | for (; n->uin; n++) { | |
| 841 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 842 | : ev->event.notify_descr.descr; | |
| 843 | gaim_debug_info("gg", "notify: (%d) status: %d; descr: %s\n", | |
| 844 | n->uin, n->status, descr); | |
| 845 | ||
| 846 | ggp_generic_status_handler(gc, | |
| 847 | n->uin, n->status, descr); | |
| 848 | } | |
| 849 | } | |
| 850 | break; | |
| 851 | case GG_EVENT_NOTIFY60: | |
| 852 | gaim_debug_info("gg", "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", | |
| 853 | ev->event.notify60->uin, ev->event.notify60->status, | |
| 854 | ev->event.notify60->version, ev->event.notify60->descr); | |
| 855 | ||
| 856 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 857 | gaim_debug_info("gg", "notify60: (%d) status=%d; version=%d; descr=%s\n", | |
| 858 | ev->event.notify60[i].uin, ev->event.notify60[i].status, | |
| 859 | ev->event.notify60[i].version, ev->event.notify60[i].descr); | |
| 860 | ||
| 861 | ggp_generic_status_handler(gc, | |
| 862 | ev->event.notify60[i].uin, | |
| 863 | ev->event.notify60[i].status, | |
| 864 | ev->event.notify60[i].descr); | |
| 865 | } | |
| 866 | break; | |
| 867 | case GG_EVENT_STATUS: | |
| 868 | gaim_debug_info("gg", "status: (%d) status=%d; descr=%s\n", | |
| 869 | ev->event.status.uin, ev->event.status.status, | |
| 870 | ev->event.status.descr); | |
| 871 | ||
| 872 | ggp_generic_status_handler(gc, | |
| 873 | ev->event.status.uin, | |
| 874 | ev->event.status.status, | |
| 875 | ev->event.status.descr); | |
| 876 | break; | |
| 877 | case GG_EVENT_STATUS60: | |
| 878 | gaim_debug_info("gg", "status60: (%d) status=%d; version=%d; descr=%s\n", | |
| 879 | ev->event.status60.uin, | |
| 880 | ev->event.status60.status, | |
| 881 | ev->event.status60.version, | |
| 882 | ev->event.status60.descr); | |
| 883 | ||
| 884 | ggp_generic_status_handler(gc, | |
| 885 | ev->event.status60.uin, | |
| 886 | ev->event.status60.status, | |
| 887 | ev->event.status60.descr); | |
| 888 | break; | |
| 889 | case GG_EVENT_USERLIST: | |
| 890 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 891 | gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); | |
| 892 | if (ev->event.userlist.reply != NULL) { | |
| 893 | ggp_buddylist_load(gc, ev->event.userlist.reply); | |
| 894 | } | |
| 895 | break; | |
| 896 | } else { | |
| 897 | gaim_debug_info("gg", "GG_USERLIST_PUT_REPLY. Userlist stored on the server.\n"); | |
| 898 | } | |
| 899 | break; | |
| 900 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 901 | { | |
| 902 | GaimNotifySearchResults *results; | |
| 903 | GaimNotifySearchColumn *column; | |
| 904 | gg_pubdir50_t req = ev->event.pubdir50; | |
| 905 | int res_count = 0; | |
| 906 | int start; | |
| 907 | int i; | |
| 908 | ||
| 909 | res_count = gg_pubdir50_count(req); | |
| 910 | if (res_count < 1) { | |
| 911 | gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); | |
| 912 | return; | |
| 913 | } | |
| 914 | res_count = (res_count > 20) ? 20 : res_count; | |
| 915 | ||
| 916 | results = gaim_notify_searchresults_new(); | |
| 917 | ||
| 918 | column = gaim_notify_searchresults_column_new("UIN"); | |
| 919 | gaim_notify_searchresults_column_add(results, column); | |
| 920 | ||
| 921 | column = gaim_notify_searchresults_column_new("First name"); | |
| 922 | gaim_notify_searchresults_column_add(results, column); | |
| 923 | ||
| 924 | column = gaim_notify_searchresults_column_new("Nick name"); | |
| 925 | gaim_notify_searchresults_column_add(results, column); | |
| 926 | ||
| 927 | column = gaim_notify_searchresults_column_new("City"); | |
| 928 | gaim_notify_searchresults_column_add(results, column); | |
| 929 | ||
| 930 | column = gaim_notify_searchresults_column_new("Birth year"); | |
| 931 | gaim_notify_searchresults_column_add(results, column); | |
| 932 | ||
| 933 | gaim_debug_info("gg", "Going with %d entries\n", res_count); | |
| 934 | ||
| 935 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 936 | gaim_debug_info("gg", "start = %d\n", start); | |
| 937 | ||
| 938 | for (i = 0; i < res_count; i++) { | |
| 939 | GList *row = NULL; | |
| 940 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 941 | ||
| 942 | /* TODO: Status will be displayed as an icon. */ | |
| 943 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 944 | row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_UIN)); | |
| 945 | row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_FIRSTNAME)); | |
| 946 | row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_NICKNAME)); | |
| 947 | row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_CITY)); | |
| 948 | row = g_list_append(row, (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 949 | gaim_notify_searchresults_row_add(results, row); | |
| 950 | if (i == res_count - 1) { | |
| 951 | g_free(info->search_form->last_uin); | |
| 952 | info->search_form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN); | |
| 953 | } | |
| 954 | } | |
| 955 | ||
| 956 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_CONTINUE, ggp_callback_show_next); | |
| 957 | gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD_BUDDY, ggp_callback_add_buddy); | |
| 958 | if (info->searchresults_window == NULL) { | |
| 959 | void *h = gaim_notify_searchresults(gc, _("Gadu-Gadu Public Directory"), | |
| 960 | _("Search results"), NULL, results, NULL, NULL); | |
| 961 | info->searchresults_window = h; | |
| 962 | } else { | |
| 963 | gaim_notify_searchresults_new_rows(gc, results, info->searchresults_window, NULL); | |
| 964 | } | |
| 965 | } | |
| 966 | break; | |
| 967 | default: | |
| 968 | gaim_debug_error("gg", "unsupported event type=%d\n", ev->type); | |
| 969 | break; | |
| 970 | } | |
| 971 | ||
| 972 | gg_free_event(ev); | |
| 973 | } | |
| 974 | /* }}} */ | |
| 975 | ||
| 976 | /* ---------------------------------------------------------------------- */ | |
| 11360 | 977 | /* ----- GaimPluginProtocolInfo ----------------------------------------- */ |
| 978 | /* ---------------------------------------------------------------------- */ | |
| 979 | ||
| 980 | /* static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) {{{ */ | |
| 981 | static const char *ggp_list_icon(GaimAccount *account, GaimBuddy *buddy) | |
| 982 | { | |
| 983 | return "gadu-gadu"; | |
| 984 | } | |
| 985 | /* }}} */ | |
| 986 | ||
| 987 | /* static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) {{{ */ | |
| 988 | static void ggp_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) | |
| 989 | { | |
| 990 | GaimPresence *presence = gaim_buddy_get_presence(b); | |
| 991 | ||
| 992 | /* | |
| 993 | * Note to myself: | |
| 994 | * The only valid status types are those defined | |
| 995 | * in prpl_info->status_types. | |
| 996 | * | |
| 997 | * Usable icons: away, blocked, dnd, extendedaway, | |
| 998 | * freeforchat, ignored, invisible, na, offline. | |
| 999 | */ | |
| 1000 | ||
| 1001 | if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 1002 | *se = "offline"; | |
| 1003 | } else if (gaim_presence_is_status_active(presence, "away")) { | |
| 1004 | *se = "away"; | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1005 | } else if (gaim_presence_is_status_active(presence, "available")) { |
| 11360 | 1006 | *se = "online"; |
| 1007 | } else if (gaim_presence_is_status_active(presence, "offline")) { | |
| 1008 | *se = "offline"; | |
| 1009 | } else if (gaim_presence_is_status_active(presence, "blocked")) { | |
| 1010 | *se = "blocked"; | |
| 1011 | } else { | |
| 1012 | *se = "offline"; | |
| 1013 | gaim_debug_info("gg", "ggp_list_emblems: unknown status\n"); | |
| 1014 | } | |
| 2393 | 1015 | } |
| 11360 | 1016 | /* }}} */ |
| 2393 | 1017 | |
| 11360 | 1018 | /* static char *ggp_status_text(GaimBuddy *b) {{{ */ |
| 1019 | static char *ggp_status_text(GaimBuddy *b) | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1020 | { |
| 11360 | 1021 | GaimStatus *status; |
| 1022 | const char *msg; | |
| 1023 | char *text; | |
| 1024 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1025 | |
| 11360 | 1026 | 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
|
1027 | |
| 11360 | 1028 | msg = gaim_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1029 | |
| 11360 | 1030 | if (msg != NULL) { |
| 1031 | tmp = gaim_markup_strip_html(msg); | |
| 1032 | text = g_markup_escape_text(tmp, -1); | |
| 1033 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1034 | |
| 11360 | 1035 | return text; |
| 1036 | } else { | |
| 1037 | tmp = g_strdup(gaim_status_get_name(status)); | |
| 1038 | text = g_markup_escape_text(tmp, -1); | |
| 1039 | g_free(tmp); | |
| 1040 | ||
| 1041 | return text; | |
| 8997 | 1042 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1043 | } |
| 11360 | 1044 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1045 | |
| 11360 | 1046 | /* static char *ggp_tooltip_text(GaimBuddy *b) {{{ */ |
| 1047 | static char *ggp_tooltip_text(GaimBuddy *b) | |
| 1048 | { | |
| 1049 | GaimStatus *status; | |
| 1050 | char *text; | |
| 1051 | gchar *ret; | |
| 1052 | const char *msg, *name; | |
| 1053 | ||
| 1054 | status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
| 1055 | msg = gaim_status_get_attr_string(status, "message"); | |
| 1056 | name = gaim_status_get_name(status); | |
| 1057 | ||
| 1058 | if (msg != NULL) { | |
| 1059 | char *tmp = gaim_markup_strip_html(msg); | |
| 1060 | text = g_markup_escape_text(tmp, -1); | |
| 1061 | g_free(tmp); | |
| 1062 | ||
| 1063 | ret = g_strdup_printf("\n<b>%s:</b> %s: %s", | |
| 1064 | _("Status"), name, text); | |
| 1065 | ||
| 1066 | g_free(text); | |
| 1067 | } else { | |
| 1068 | ret = g_strdup_printf("\n<b>%s:</b> %s", | |
| 1069 | _("Status"), name); | |
| 1070 | } | |
| 1071 | ||
| 1072 | return ret; | |
| 1073 | } | |
| 1074 | /* }}} */ | |
| 1075 | ||
| 1076 | /* static GList *ggp_status_types(GaimAccount *account) {{{ */ | |
| 1077 | static GList *ggp_status_types(GaimAccount *account) | |
| 1078 | { | |
| 1079 | GaimStatusType *type; | |
| 1080 | GList *types = NULL; | |
| 1081 | ||
| 1082 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, "offline", _("Offline"), | |
| 1083 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1084 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1085 | types = g_list_append(types, type); | |
| 1086 | ||
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1087 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, "available", _("Online"), |
| 11360 | 1088 | TRUE, TRUE, FALSE, "message", _("Message"), |
| 1089 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1090 | types = g_list_append(types, type); | |
| 1091 | ||
| 1092 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1093 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1094 | * work. It's not used and not needed to show status of buddies. |
| 1095 | */ | |
| 1096 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_HIDDEN, "invisible", _("Invisible"), | |
| 1097 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1098 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1099 | types = g_list_append(types, type); | |
| 1100 | ||
| 1101 | /* type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, "not-available", "Not Available", */ | |
| 1102 | /* TRUE, TRUE, FALSE, "message", _("Message"), */ | |
| 1103 | /* gaim_value_new(GAIM_TYPE_STRING), NULL); */ | |
| 1104 | /* types = g_list_append(types, type); */ | |
| 1105 | ||
| 1106 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, "away", _("Busy"), | |
| 1107 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1108 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1109 | types = g_list_append(types, type); | |
| 1110 | ||
| 1111 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_HIDDEN, "blocked", _("Blocked"), | |
| 1112 | TRUE, TRUE, FALSE, "message", _("Message"), | |
| 1113 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 1114 | types = g_list_append(types, type); | |
| 1115 | ||
| 1116 | return types; | |
| 1117 | } | |
| 1118 | /* }}} */ | |
| 1119 | ||
| 1120 | /* static GList *ggp_blist_node_menu(GaimBlistNode *node) {{{ */ | |
| 1121 | static GList *ggp_blist_node_menu(GaimBlistNode *node) | |
| 2393 | 1122 | { |
| 11394 | 1123 | GaimBlistNodeAction *act; |
| 2393 | 1124 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1125 | |
| 11360 | 1126 | if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 1127 | return NULL; | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1128 | |
| 11410 | 1129 | act = gaim_blist_node_action_new(_("Add to chat"), ggp_bmenu_add_to_chat, NULL, NULL); |
| 1130 | m = g_list_append(m, act); | |
| 1131 | ||
| 1132 | if (gaim_blist_node_get_bool(node, "blocked")) | |
| 1133 | act = gaim_blist_node_action_new(_("Unblock"), ggp_bmenu_block, NULL, NULL); | |
| 1134 | else | |
| 1135 | act = gaim_blist_node_action_new(_("Block"), ggp_bmenu_block, NULL, NULL); | |
| 11394 | 1136 | m = g_list_append(m, act); |
| 2393 | 1137 | |
| 1138 | return m; | |
| 1139 | } | |
| 11360 | 1140 | /* }}} */ |
| 2393 | 1141 | |
| 11394 | 1142 | /* static GList *ggp_chat_info(GaimConnection *gc) {{{ */ |
| 1143 | static GList *ggp_chat_info(GaimConnection *gc) | |
| 1144 | { | |
| 1145 | GList *m = NULL; | |
| 1146 | struct proto_chat_entry *pce; | |
| 1147 | ||
| 1148 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1149 | pce->label = _("Chat _name:"); | |
| 1150 | pce->identifier = "name"; | |
| 1151 | pce->required = TRUE; | |
| 1152 | m = g_list_append(m, pce); | |
| 1153 | ||
| 1154 | return m; | |
| 1155 | } | |
| 1156 | /* }}} */ | |
| 1157 | ||
| 11360 | 1158 | /* static void ggp_login(GaimAccount *account, GaimStatus *status) {{{ */ |
| 1159 | static void ggp_login(GaimAccount *account, GaimStatus *status) | |
| 2393 | 1160 | { |
| 11360 | 1161 | GaimConnection *gc = gaim_account_get_connection(account); |
| 1162 | struct gg_login_params *glp = g_new0(struct gg_login_params, 1); | |
| 1163 | GGPInfo *info = g_new0(GGPInfo, 1); | |
| 1164 | ||
| 11394 | 1165 | /* Probably this should be move to some *_new() function. */ |
| 11360 | 1166 | info->session = NULL; |
| 1167 | info->searchresults_window = NULL; | |
| 11394 | 1168 | info->chats = NULL; |
| 1169 | info->chats_count = 0; | |
| 11360 | 1170 | |
| 1171 | gc->proto_data = info; | |
| 1172 | ||
| 1173 | glp->uin = ggp_get_uin(account); | |
| 1174 | glp->password = (char *)gaim_account_get_password(account); | |
| 1175 | ||
| 1176 | glp->async = 0; | |
| 1177 | glp->status = GG_STATUS_AVAIL; | |
| 1178 | glp->tls = 0; | |
| 1179 | ||
| 1180 | info->session = gg_login(glp); | |
| 1181 | if (info->session == NULL) { | |
| 1182 | gaim_connection_error(gc, _("Connection failed.")); | |
| 1183 | g_free(glp); | |
| 1184 | return; | |
| 1185 | } | |
| 1186 | gaim_debug_info("gg", "ggp_login: so far so good.\n"); | |
| 1187 | ||
| 1188 | gc->inpa = gaim_input_add(info->session->fd, GAIM_INPUT_READ, ggp_callback_recv, gc); | |
| 2393 | 1189 | |
| 11360 | 1190 | gg_change_status(info->session, GG_STATUS_AVAIL); |
| 1191 | gaim_connection_set_state(gc, GAIM_CONNECTED); | |
| 1192 | ggp_buddylist_send(gc); | |
| 1193 | } | |
| 1194 | /* }}} */ | |
| 1195 | ||
| 1196 | /* static void ggp_close(GaimConnection *gc) {{{ */ | |
| 1197 | static void ggp_close(GaimConnection *gc) | |
| 1198 | { | |
| 8997 | 1199 | |
| 11360 | 1200 | if (gc == NULL) { |
| 1201 | gaim_debug_info("gg", "gc == NULL\n"); | |
| 1202 | return; | |
| 1203 | } | |
| 1204 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1205 | if (gc->proto_data) { |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1206 | GGPInfo *info = gc->proto_data; |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1207 | /* XXX: Any way to pass description here? */ |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1208 | if (info->session != NULL) { |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1209 | gg_change_status(info->session, GG_STATUS_NOT_AVAIL); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1210 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1211 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1212 | } |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1213 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1214 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1215 | } |
| 11360 | 1216 | |
| 1217 | if (gc->inpa > 0) | |
| 1218 | gaim_input_remove(gc->inpa); | |
| 1219 | ||
| 1220 | ggp_buddylist_offline(gc); | |
| 2393 | 1221 | |
| 11360 | 1222 | gaim_debug_info("gg", "Connection closed.\n"); |
| 1223 | } | |
| 1224 | /* }}} */ | |
| 1225 | ||
| 1226 | /* static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, GaimConvImFlags flags) {{{ */ | |
| 1227 | static int ggp_send_im(GaimConnection *gc, const char *who, const char *msg, GaimConvImFlags flags) | |
| 1228 | { | |
| 1229 | GGPInfo *info = gc->proto_data; | |
| 11394 | 1230 | char *tmp; |
| 11360 | 1231 | |
| 1232 | if (strlen(msg) == 0) | |
| 1233 | return 1; | |
| 1234 | ||
| 11565 | 1235 | gaim_debug_info("gg", "ggp_send_im: msg = %s\n", msg); |
| 11360 | 1236 | tmp = charset_convert(msg, "UTF-8", "CP1250"); |
| 2393 | 1237 | |
| 11360 | 1238 | if (tmp != NULL && strlen(tmp) > 0) { |
| 11565 | 1239 | if (gg_send_message(info->session, GG_CLASS_CHAT, ggp_str_to_uin(who), |
| 1240 | (unsigned char *)tmp) < 0) { | |
| 11360 | 1241 | return -1; |
| 1242 | } | |
| 1243 | } | |
| 11565 | 1244 | g_free(tmp); |
| 11360 | 1245 | |
| 1246 | return 1; | |
| 1247 | } | |
| 1248 | /* }}} */ | |
| 1249 | ||
| 1250 | /* static void ggp_get_info(GaimConnection *gc, const char *name) { {{{ */ | |
| 1251 | static void ggp_get_info(GaimConnection *gc, const char *name) | |
| 1252 | { | |
| 1253 | GGPInfo *info = gc->proto_data; | |
| 1254 | GGPSearchForm *form; | |
| 2393 | 1255 | |
| 11414 | 1256 | form = ggp_search_form_new(); |
| 11360 | 1257 | info->search_form = form; |
| 1258 | ||
| 1259 | form->uin = g_strdup(name); | |
| 1260 | form->offset = g_strdup("0"); | |
| 1261 | form->last_uin = g_strdup("0"); | |
| 1262 | ||
| 11414 | 1263 | ggp_search_start(gc, form); |
| 11360 | 1264 | } |
| 1265 | /* }}} */ | |
| 1266 | ||
| 1267 | /* static void ggp_set_status(GaimAccount *account, GaimStatus *status) {{{ */ | |
| 1268 | static void ggp_set_status(GaimAccount *account, GaimStatus *status) | |
| 1269 | { | |
| 1270 | GaimStatusPrimitive prim; | |
| 1271 | GaimConnection *gc; | |
| 1272 | GGPInfo *info; | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1273 | const char *status_id, *msg; |
| 11360 | 1274 | int new_status, new_status_descr; |
| 1275 | ||
| 1276 | prim = gaim_status_type_get_primitive(gaim_status_get_type(status)); | |
| 1277 | ||
| 1278 | if (!gaim_status_is_active(status)) | |
| 1279 | return; | |
| 1280 | ||
| 1281 | gc = gaim_account_get_connection(account); | |
| 1282 | info = gc->proto_data; | |
| 1283 | ||
| 1284 | status_id = gaim_status_get_id(status); | |
| 1285 | ||
| 1286 | gaim_debug_info("gg", "ggp_set_status: Requested status = %s\n", status_id); | |
| 2393 | 1287 | |
| 11360 | 1288 | if (strcmp(status_id, "available") == 0) { |
| 1289 | new_status = GG_STATUS_AVAIL; | |
| 1290 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1291 | } else if (strcmp(status_id, "away") == 0) { | |
| 1292 | new_status = GG_STATUS_BUSY; | |
| 1293 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1294 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1295 | new_status = GG_STATUS_INVISIBLE; | |
| 1296 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 1297 | } else { | |
| 1298 | new_status = GG_STATUS_AVAIL; | |
| 1299 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1300 | gaim_debug_info("gg", "ggp_set_status: uknown status requested (status_id=%s)\n", status_id); | |
| 1301 | } | |
| 4916 | 1302 | |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1303 | msg = gaim_status_get_attr_string(status, "message"); |
| 11360 | 1304 | |
| 1305 | if (msg == NULL) { | |
| 1306 | gaim_debug_info("gg", "ggp_set_status: msg == NULL\n"); | |
| 1307 | gg_change_status(info->session, new_status); | |
| 1308 | } else { | |
| 1309 | char *tmp = charset_convert(msg, "UTF-8", "CP1250"); | |
| 1310 | gaim_debug_info("gg", "ggp_set_status: msg != NULL. msg = %s\n", tmp); | |
| 1311 | gaim_debug_info("gg", "ggp_set_status: gg_change_status_descr() = %d\n", | |
| 1312 | gg_change_status_descr(info->session, new_status_descr, tmp)); | |
| 1313 | g_free(tmp); | |
| 1314 | } | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
1315 | |
| 11360 | 1316 | } |
| 1317 | /* }}} */ | |
| 1318 | ||
| 1319 | /* static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 1320 | static void ggp_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
| 1321 | { | |
| 1322 | GGPInfo *info = gc->proto_data; | |
| 1323 | ||
| 1324 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1325 | } | |
| 1326 | /* }}} */ | |
| 1327 | ||
| 1328 | /* static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {{{ */ | |
| 1329 | static void ggp_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
| 1330 | { | |
| 1331 | GGPInfo *info = gc->proto_data; | |
| 1332 | ||
| 1333 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1334 | } | |
| 1335 | /* }}} */ | |
| 1336 | ||
| 11394 | 1337 | /* static void ggp_join_chat(GaimConnection *gc, GHashTable *data) {{{ */ |
| 1338 | static void ggp_join_chat(GaimConnection *gc, GHashTable *data) | |
| 1339 | { | |
| 1340 | GGPInfo *info = gc->proto_data; | |
| 1341 | GGPChat *chat; | |
| 1342 | char *chat_name; | |
| 1343 | GList *l; | |
| 1344 | ||
| 1345 | chat_name = g_hash_table_lookup(data, "name"); | |
| 1346 | ||
| 1347 | if (chat_name == NULL) | |
| 1348 | return; | |
| 1349 | ||
| 1350 | gaim_debug_info("gg", "joined %s chat\n", chat_name); | |
| 1351 | ||
| 1352 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1353 | chat = l->data; | |
| 1354 | ||
| 1355 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 1356 | gaim_notify_error(gc, _("Chat error"), | |
| 1357 | _("This chat name is already in use"), NULL); | |
| 1358 | return; | |
| 1359 | } | |
| 1360 | } | |
| 1361 | ||
| 11414 | 1362 | ggp_confer_add_new(gc, chat_name); |
| 11394 | 1363 | serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 1364 | } | |
| 1365 | /* }}} */ | |
| 1366 | ||
| 1367 | /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | |
| 1368 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 1369 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 1370 | } | |
| 1371 | /* }}} */ | |
| 1372 | ||
| 1373 | /* static int ggp_chat_send(GaimConnection *gc, int id, const char *message) {{{ */ | |
| 1374 | static int ggp_chat_send(GaimConnection *gc, int id, const char *message) | |
| 1375 | { | |
| 1376 | GaimConversation *conv; | |
| 1377 | GGPInfo *info = gc->proto_data; | |
| 1378 | GGPChat *chat = NULL; | |
| 1379 | GList *l; | |
| 1380 | char *msg; | |
| 1381 | uin_t *uins; | |
| 1382 | int count = 0; | |
| 1383 | ||
| 1384 | if ((conv = gaim_find_chat(gc, id)) == NULL) | |
| 1385 | return -EINVAL; | |
| 1386 | ||
| 1387 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1388 | chat = l->data; | |
| 1389 | ||
| 1390 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 1391 | gaim_debug_info("gg", "found conv!\n"); | |
| 1392 | break; | |
| 1393 | } | |
| 1394 | ||
| 1395 | chat = NULL; | |
| 1396 | } | |
| 1397 | ||
| 1398 | if (chat == NULL) { | |
| 1399 | gaim_debug_error("gg", "ggp_chat_send: Hm... that's strange. No such chat?\n"); | |
| 1400 | return -EINVAL; | |
| 1401 | } | |
| 1402 | ||
| 1403 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 1404 | for (l = chat->participants; l != NULL; l = l->next) { | |
| 1405 | gchar *name = l->data; | |
| 1406 | uin_t uin; | |
| 1407 | ||
| 1408 | if ((uin = ggp_str_to_uin(name)) != 0) | |
| 1409 | uins[count++] = uin; | |
| 1410 | } | |
| 1411 | ||
| 1412 | msg = charset_convert(message, "UTF-8", "CP1250"); | |
| 1413 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, (unsigned char *)msg); | |
| 1414 | g_free(msg); | |
| 1415 | g_free(uins); | |
| 1416 | ||
| 1417 | serv_got_chat_in(gc, id, gaim_account_get_username(gaim_connection_get_account(gc)), | |
| 1418 | 0, message, time(NULL)); | |
| 1419 | ||
| 1420 | return 0; | |
| 1421 | } | |
| 1422 | /* }}} */ | |
| 1423 | ||
| 11360 | 1424 | /* static void ggp_keepalive(GaimConnection *gc) {{{ */ |
| 1425 | static void ggp_keepalive(GaimConnection *gc) | |
| 1426 | { | |
| 1427 | GGPInfo *info = gc->proto_data; | |
| 1428 | ||
| 1429 | /* gaim_debug_info("gg", "Keeping connection alive....\n"); */ | |
| 1430 | ||
| 1431 | if (gg_ping(info->session) < 0) { | |
| 1432 | gaim_debug_info("gg", "Not connected to the server " | |
| 1433 | "or gg_session is not correct\n"); | |
| 1434 | gaim_connection_error(gc, _("Not connected to the server.")); | |
| 4916 | 1435 | } |
| 2393 | 1436 | } |
| 11360 | 1437 | /* }}} */ |
| 1438 | ||
| 1439 | /* static void ggp_register_user(GaimAccount *account) {{{ */ | |
| 1440 | static void ggp_register_user(GaimAccount *account) | |
| 1441 | { | |
|
11542
fabce19a4ccf
[gaim-migrate @ 13797]
Daniel Atallah <datallah@pidgin.im>
parents:
11541
diff
changeset
|
1442 | GaimConnection *gc = gaim_account_get_connection(account); |
| 11360 | 1443 | GaimRequestFields *fields; |
| 1444 | GaimRequestFieldGroup *group; | |
| 1445 | GaimRequestField *field; | |
| 1446 | GGPInfo *info; | |
| 1447 | GGPToken *token; | |
| 1448 | ||
| 1449 | struct gg_http *req; | |
| 1450 | struct gg_token *t; | |
| 1451 | ||
| 1452 | gaim_debug_info("gg", "token: requested.\n"); | |
| 1453 | ||
| 1454 | if ((req = gg_token(0)) == NULL) { | |
|
11544
b51e660d4b43
[gaim-migrate @ 13799]
Mark Doliner <markdoliner@pidgin.im>
parents:
11542
diff
changeset
|
1455 | gaim_connection_error(gc, _("Token Error: Unable to fetch the token.\n")); |
| 11360 | 1456 | return; |
| 1457 | } | |
| 1458 | t = req->data; | |
| 1459 | ||
| 1460 | info = g_new0(GGPInfo, 1); | |
| 1461 | gc->proto_data = info; | |
| 1462 | ||
| 1463 | token = g_new0(GGPToken, 1); | |
| 1464 | token->token_id = g_strdup(t->tokenid); | |
| 1465 | info->register_token = token; | |
| 1466 | ||
| 1467 | fields = gaim_request_fields_new(); | |
| 1468 | group = gaim_request_field_group_new(NULL); | |
| 1469 | gaim_request_fields_add_group(fields, group); | |
| 1470 | ||
| 1471 | field = gaim_request_field_string_new("email", _("e-Mail"), "", FALSE); | |
| 1472 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1473 | gaim_request_field_group_add_field(group, field); | |
| 1474 | ||
| 1475 | field = gaim_request_field_string_new("password1", _("Password"), "", FALSE); | |
| 1476 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1477 | gaim_request_field_group_add_field(group, field); | |
| 1478 | ||
| 1479 | field = gaim_request_field_string_new("password2", _("Password (retype)"), "", FALSE); | |
| 1480 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1481 | gaim_request_field_group_add_field(group, field); | |
| 1482 | ||
| 1483 | field = gaim_request_field_string_new("token", _("Enter current token"), "", FALSE); | |
| 1484 | gaim_request_field_string_set_masked(field, FALSE); | |
| 1485 | gaim_request_field_group_add_field(group, field); | |
| 1486 | ||
| 1487 | /* original size: 60x24 */ | |
| 1488 | field = gaim_request_field_image_new("token_img", _("Current token"), req->body, req->body_size); | |
| 1489 | gaim_request_field_group_add_field(group, field); | |
| 1490 | ||
| 1491 | gg_token_free(req); | |
| 4916 | 1492 | |
| 11360 | 1493 | gaim_request_fields(account, |
| 1494 | _("Register New Gadu-Gadu Account"), | |
| 1495 | _("Register New Gadu-Gadu Account"), | |
| 1496 | _("Please, fill in the following fields"), | |
| 1497 | fields, _("OK"), G_CALLBACK(ggp_callback_register_account_ok), | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1498 | _("Cancel"), G_CALLBACK(ggp_callback_register_account_cancel), |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1499 | gc); |
| 2393 | 1500 | } |
| 11360 | 1501 | /* }}} */ |
| 2393 | 1502 | |
| 11360 | 1503 | /* static GList *ggp_actions(GaimPlugin *plugin, gpointer context) {{{ */ |
| 1504 | static GList *ggp_actions(GaimPlugin *plugin, gpointer context) | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1505 | { |
| 11360 | 1506 | GList *m = NULL; |
| 1507 | GaimPluginAction *act; | |
| 1508 | ||
| 1509 | act = gaim_plugin_action_new(_("Find buddies"), ggp_find_buddies); | |
| 1510 | m = g_list_append(m, act); | |
| 1511 | ||
| 1512 | m = g_list_append(m, NULL); | |
| 1513 | ||
| 1514 | act = gaim_plugin_action_new(_("Change password"), ggp_change_passwd); | |
| 1515 | m = g_list_append(m, act); | |
| 1516 | ||
| 1517 | m = g_list_append(m, NULL); | |
| 1518 | ||
| 1519 | act = gaim_plugin_action_new(_("Upload buddylist to Server"), ggp_action_buddylist_put); | |
| 1520 | m = g_list_append(m, act); | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1521 | |
| 11360 | 1522 | act = gaim_plugin_action_new(_("Download buddylist from Server"), ggp_action_buddylist_get); |
| 1523 | m = g_list_append(m, act); | |
| 1524 | ||
| 1525 | act = gaim_plugin_action_new(_("Delete buddylist from Server"), ggp_action_buddylist_delete); | |
| 1526 | m = g_list_append(m, act); | |
| 1527 | ||
| 1528 | act = gaim_plugin_action_new(_("Save buddylist to file"), ggp_action_buddylist_save); | |
| 1529 | m = g_list_append(m, act); | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1530 | |
| 11360 | 1531 | act = gaim_plugin_action_new(_("Load buddylist from file"), ggp_action_buddylist_load); |
| 1532 | m = g_list_append(m, act); | |
| 1533 | ||
| 1534 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1535 | } |
| 11360 | 1536 | /* }}} */ |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
1537 | |
| 11360 | 1538 | /* prpl_info setup {{{ */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1539 | static GaimPluginProtocolInfo prpl_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1540 | { |
| 11360 | 1541 | OPT_PROTO_REGISTER_NOSCREENNAME, |
| 1542 | NULL, /* user_splits */ | |
| 1543 | NULL, /* protocol_options */ | |
| 9950 | 1544 | NO_BUDDY_ICONS, /* icon_spec */ |
| 11360 | 1545 | ggp_list_icon, /* list_icon */ |
| 1546 | ggp_list_emblems, /* list_emblems */ | |
| 1547 | ggp_status_text, /* status_text */ | |
| 1548 | ggp_tooltip_text, /* tooltip_text */ | |
| 1549 | ggp_status_types, /* status_types */ | |
| 1550 | ggp_blist_node_menu, /* blist_node_menu */ | |
| 11394 | 1551 | ggp_chat_info, /* chat_info */ |
| 11360 | 1552 | NULL, /* chat_info_defaults */ |
| 1553 | ggp_login, /* login */ | |
| 1554 | ggp_close, /* close */ | |
| 1555 | ggp_send_im, /* send_im */ | |
| 1556 | NULL, /* set_info */ | |
| 1557 | NULL, /* send_typing */ | |
| 1558 | ggp_get_info, /* get_info */ | |
| 1559 | ggp_set_status, /* set_away */ | |
| 1560 | NULL, /* set_idle */ | |
| 1561 | NULL, /* change_passwd */ | |
| 1562 | ggp_add_buddy, /* add_buddy */ | |
| 1563 | NULL, /* add_buddies */ | |
| 1564 | ggp_remove_buddy, /* remove_buddy */ | |
| 1565 | NULL, /* remove_buddies */ | |
| 1566 | NULL, /* add_permit */ | |
| 1567 | NULL, /* add_deny */ | |
| 1568 | NULL, /* rem_permit */ | |
| 1569 | NULL, /* rem_deny */ | |
| 1570 | NULL, /* set_permit_deny */ | |
| 11394 | 1571 | ggp_join_chat, /* join_chat */ |
| 11360 | 1572 | NULL, /* reject_chat */ |
| 11394 | 1573 | ggp_get_chat_name, /* get_chat_name */ |
| 11360 | 1574 | NULL, /* chat_invite */ |
| 1575 | NULL, /* chat_leave */ | |
| 1576 | NULL, /* chat_whisper */ | |
| 11394 | 1577 | ggp_chat_send, /* chat_send */ |
| 11360 | 1578 | ggp_keepalive, /* keepalive */ |
| 1579 | ggp_register_user, /* register_user */ | |
| 1580 | NULL, /* get_cb_info */ | |
| 1581 | NULL, /* get_cb_away */ | |
| 1582 | NULL, /* alias_buddy */ | |
| 1583 | NULL, /* group_buddy */ | |
| 1584 | NULL, /* rename_group */ | |
| 1585 | NULL, /* buddy_free */ | |
| 1586 | NULL, /* convo_closed */ | |
| 1587 | NULL, /* normalize */ | |
| 1588 | NULL, /* set_buddy_icon */ | |
| 1589 | NULL, /* remove_group */ | |
| 1590 | NULL, /* get_cb_real_name */ | |
| 1591 | NULL, /* set_chat_topic */ | |
| 1592 | NULL, /* find_blist_chat */ | |
| 1593 | NULL, /* roomlist_get_list */ | |
| 1594 | NULL, /* roomlist_cancel */ | |
| 1595 | NULL, /* roomlist_expand_category */ | |
| 1596 | NULL, /* can_receive_file */ | |
| 1597 | NULL /* send_file */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1598 | }; |
| 11360 | 1599 | /* }}} */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1600 | |
| 11360 | 1601 | /* GaimPluginInfo setup {{{ */ |
| 1602 | static GaimPluginInfo info = { | |
| 1603 | GAIM_PLUGIN_MAGIC, /* magic */ | |
| 1604 | GAIM_MAJOR_VERSION, /* major_version */ | |
| 1605 | GAIM_MINOR_VERSION, /* minor_version */ | |
| 1606 | GAIM_PLUGIN_PROTOCOL, /* plugin type */ | |
| 1607 | NULL, /* ui_requirement */ | |
| 1608 | 0, /* flags */ | |
| 1609 | NULL, /* dependencies */ | |
| 1610 | GAIM_PRIORITY_DEFAULT, /* priority */ | |
| 1611 | ||
| 1612 | "prpl-gg", /* id */ | |
| 1613 | "Gadu-Gadu", /* name */ | |
| 1614 | VERSION, /* version */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1615 | |
| 11360 | 1616 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 1617 | N_("Polish popular IM"), /* description */ | |
| 1618 | "boler@sourceforge.net", /* author */ | |
| 1619 | GAIM_WEBSITE, /* homepage */ | |
| 1620 | ||
| 1621 | NULL, /* load */ | |
| 1622 | NULL, /* unload */ | |
| 1623 | NULL, /* destroy */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1624 | |
| 11360 | 1625 | NULL, /* ui_info */ |
| 1626 | &prpl_info, /* extra_info */ | |
| 1627 | NULL, /* prefs_info */ | |
| 1628 | ggp_actions /* actions */ | |
| 1629 | }; | |
| 1630 | /* }}} */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1631 | |
| 11565 | 1632 | /* static void gaim_gg_debug_handler(int level, const char * format, va_list args) {{{ */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1633 | static void gaim_gg_debug_handler(int level, const char * format, va_list args) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1634 | GaimDebugLevel gaim_level; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1635 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1636 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1637 | /* This is pretty pointless since the GG_DEBUG levels don't correspond to |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1638 | * the gaim ones */ |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1639 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1640 | case GG_DEBUG_FUNCTION: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1641 | gaim_level = GAIM_DEBUG_INFO; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1642 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1643 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1644 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1645 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1646 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1647 | default: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1648 | gaim_level = GAIM_DEBUG_MISC; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1649 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1650 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1651 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1652 | gaim_debug(gaim_level, "gg", msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1653 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1654 | } |
| 11565 | 1655 | /* }}} */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1656 | |
| 11360 | 1657 | /* |
| 1658 | */ | |
| 1659 | /* static void init_plugin(GaimPlugin *plugin) {{{ */ | |
| 1660 | static void init_plugin(GaimPlugin *plugin) | |
| 2393 | 1661 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1662 | GaimAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1663 | |
| 11360 | 1664 | option = gaim_account_option_string_new(_("Nickname"), "nick", _("Gadu-Gadu User")); |
| 1665 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3572 | 1666 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1667 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1668 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
1669 | gg_debug_handler = gaim_gg_debug_handler; |
| 2393 | 1670 | } |
| 11360 | 1671 | /* }}} */ |
| 2393 | 1672 | |
| 11360 | 1673 | GAIM_INIT_PLUGIN(gadu-gadu, init_plugin, info); |
| 1674 | ||
| 1675 | /* vim: set ts=4 sts=0 sw=4 noet: */ | |
| 11394 | 1676 |