Sun, 16 Mar 2008 20:36:52 +0000
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
to our debug functions (I really thought we had added that in a while ago?)
I didn't fix all of them... just most of them.
Oh, see these pages for a little info:
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
http://library.gnome.org/devel/glib/unstable/glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS
| 11394 | 1 | /** |
| 2 | * @file gg.c Gadu-Gadu protocol plugin | |
| 3 | * | |
| 15884 | 4 | * purple |
| 11394 | 5 | * |
| 6 | * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> | |
| 7 | * | |
| 12007 | 8 | * Some parts of the code are adapted or taken from the previous implementation |
| 11394 | 9 | * of this plugin written by Arkadiusz Miskiewicz <misiek@pld.org.pl> |
| 10 | * | |
| 11 | * Thanks to Google's Summer of Code Program. | |
| 12 | * | |
| 13 | * This program is free software; you can redistribute it and/or modify | |
| 14 | * it under the terms of the GNU General Public License as published by | |
| 15 | * the Free Software Foundation; either version 2 of the License, or | |
| 16 | * (at your option) any later version. | |
| 17 | * | |
| 18 | * This program is distributed in the hope that it will be useful, | |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | * GNU General Public License for more details. | |
| 22 | * | |
| 23 | * You should have received a copy of the GNU General Public License | |
| 24 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18629
diff
changeset
|
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11394 | 26 | */ |
| 27 | ||
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
28 | #include "internal.h" |
| 2393 | 29 | |
| 11360 | 30 | #include "plugin.h" |
| 31 | #include "version.h" | |
| 32 | #include "notify.h" | |
| 33 | #include "status.h" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
34 | #include "blist.h" |
| 11360 | 35 | #include "accountopt.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
36 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
37 | #include "util.h" |
| 11360 | 38 | #include "request.h" |
| 2393 | 39 | |
| 13318 | 40 | #include <libgadu.h> |
| 5603 | 41 | |
| 11414 | 42 | #include "gg.h" |
| 43 | #include "confer.h" | |
| 44 | #include "search.h" | |
| 45 | #include "buddylist.h" | |
|
13627
44233a1064f9
[gaim-migrate @ 16013]
Evan Schoenberg <evands@pidgin.im>
parents:
13573
diff
changeset
|
46 | #include "gg-utils.h" |
| 11394 | 47 | |
| 15884 | 48 | static PurplePlugin *my_protocol = NULL; |
| 11394 | 49 | |
| 11360 | 50 | /* ---------------------------------------------------------------------- */ |
| 11414 | 51 | /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ |
| 11360 | 52 | /* ---------------------------------------------------------------------- */ |
| 9950 | 53 | |
| 12007 | 54 | |
| 55 | /* ----- HELPERS -------------------------------------------------------- */ | |
| 56 | ||
| 13515 | 57 | /** |
| 58 | * Set up libgadu's proxy. | |
| 59 | * | |
| 60 | * @param account Account for which to set up the proxy. | |
| 61 | * | |
| 62 | * @return Zero if proxy setup is valid, otherwise -1. | |
| 63 | */ | |
| 15884 | 64 | /* static int ggp_setup_proxy(PurpleAccount *account) {{{ */ |
| 65 | static int ggp_setup_proxy(PurpleAccount *account) | |
| 13515 | 66 | { |
| 15884 | 67 | PurpleProxyInfo *gpi; |
| 13515 | 68 | |
| 15884 | 69 | gpi = purple_proxy_get_setup(account); |
| 13515 | 70 | |
| 15884 | 71 | if ((purple_proxy_info_get_type(gpi) != PURPLE_PROXY_NONE) && |
| 72 | (purple_proxy_info_get_host(gpi) == NULL || | |
| 73 | purple_proxy_info_get_port(gpi) <= 0)) { | |
| 13515 | 74 | |
| 75 | gg_proxy_enabled = 0; | |
| 15884 | 76 | purple_notify_error(NULL, NULL, _("Invalid proxy settings"), |
| 13515 | 77 | _("Either the host name or port number specified for your given proxy type is invalid.")); |
| 78 | return -1; | |
| 15884 | 79 | } else if (purple_proxy_info_get_type(gpi) != PURPLE_PROXY_NONE) { |
| 13515 | 80 | gg_proxy_enabled = 1; |
| 15884 | 81 | gg_proxy_host = g_strdup(purple_proxy_info_get_host(gpi)); |
| 82 | gg_proxy_port = purple_proxy_info_get_port(gpi); | |
| 83 | gg_proxy_username = g_strdup(purple_proxy_info_get_username(gpi)); | |
| 84 | gg_proxy_password = g_strdup(purple_proxy_info_get_password(gpi)); | |
| 13515 | 85 | } else { |
| 86 | gg_proxy_enabled = 0; | |
| 87 | } | |
| 88 | ||
| 89 | return 0; | |
| 90 | } | |
| 91 | /* }}} */ | |
| 92 | ||
| 12007 | 93 | /* |
| 94 | */ | |
| 15884 | 95 | /* static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */ |
| 96 | static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) | |
| 12007 | 97 | { |
| 15884 | 98 | PurpleConnection *gc = _gc; |
| 12007 | 99 | GGPInfo *info = gc->proto_data; |
| 100 | GGPToken *token = info->token; | |
| 101 | GGPTokenCallback cb; | |
| 102 | ||
| 103 | struct gg_token *t = NULL; | |
| 104 | ||
| 15884 | 105 | purple_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n", |
| 12007 | 106 | token->req->check, token->req->state); |
| 107 | ||
| 108 | if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) { | |
| 15884 | 109 | purple_debug_error("gg", "token error (1): %d\n", token->req->error); |
| 110 | purple_input_remove(token->inpa); | |
| 12007 | 111 | gg_token_free(token->req); |
| 112 | token->req = NULL; | |
| 113 | ||
| 15884 | 114 | purple_notify_error(purple_connection_get_account(gc), |
| 12007 | 115 | _("Token Error"), |
| 116 | _("Unable to fetch the token.\n"), NULL); | |
| 117 | return; | |
| 118 | } | |
| 119 | ||
| 120 | if (token->req->state != GG_STATE_DONE) { | |
| 15884 | 121 | purple_input_remove(token->inpa); |
| 122 | token->inpa = purple_input_add(token->req->fd, | |
| 12007 | 123 | (token->req->check == 1) |
| 15884 | 124 | ? PURPLE_INPUT_WRITE |
| 125 | : PURPLE_INPUT_READ, | |
| 12007 | 126 | ggp_async_token_handler, gc); |
| 127 | return; | |
| 128 | } | |
| 129 | ||
| 130 | if (!(t = token->req->data) || !token->req->body) { | |
| 15884 | 131 | purple_debug_error("gg", "token error (2): %d\n", token->req->error); |
| 132 | purple_input_remove(token->inpa); | |
| 12007 | 133 | gg_token_free(token->req); |
| 134 | token->req = NULL; | |
| 135 | ||
| 15884 | 136 | purple_notify_error(purple_connection_get_account(gc), |
| 12007 | 137 | _("Token Error"), |
| 138 | _("Unable to fetch the token.\n"), NULL); | |
| 139 | return; | |
| 140 | } | |
| 141 | ||
| 15884 | 142 | purple_input_remove(token->inpa); |
| 12007 | 143 | |
| 144 | token->id = g_strdup(t->tokenid); | |
| 145 | token->size = token->req->body_size; | |
| 146 | token->data = g_new0(char, token->size); | |
| 147 | memcpy(token->data, token->req->body, token->size); | |
| 148 | ||
| 15884 | 149 | purple_debug_info("gg", "TOKEN! tokenid = %s; size = %d\n", |
| 12007 | 150 | token->id, token->size); |
| 151 | ||
| 152 | gg_token_free(token->req); | |
| 153 | token->req = NULL; | |
| 154 | token->inpa = 0; | |
| 155 | ||
| 156 | cb = token->cb; | |
| 157 | token->cb = NULL; | |
| 158 | cb(gc); | |
| 159 | } | |
| 160 | /* }}} */ | |
| 161 | ||
| 162 | /* | |
| 163 | */ | |
| 15884 | 164 | /* static void ggp_token_request(PurpleConnection *gc, GGPTokenCallback cb) {{{ */ |
| 165 | static void ggp_token_request(PurpleConnection *gc, GGPTokenCallback cb) | |
| 12007 | 166 | { |
| 15884 | 167 | PurpleAccount *account; |
| 12007 | 168 | struct gg_http *req; |
| 13515 | 169 | GGPInfo *info; |
| 170 | ||
| 15884 | 171 | account = purple_connection_get_account(gc); |
| 13515 | 172 | |
| 173 | if (ggp_setup_proxy(account) == -1) | |
| 174 | return; | |
| 175 | ||
| 176 | info = gc->proto_data; | |
| 12007 | 177 | |
| 178 | if ((req = gg_token(1)) == NULL) { | |
| 15884 | 179 | purple_notify_error(account, |
| 12007 | 180 | _("Token Error"), |
| 181 | _("Unable to fetch the token.\n"), NULL); | |
| 182 | return; | |
| 183 | } | |
| 184 | ||
| 185 | info->token = g_new(GGPToken, 1); | |
| 186 | info->token->cb = cb; | |
| 187 | ||
| 188 | info->token->req = req; | |
| 15884 | 189 | info->token->inpa = purple_input_add(req->fd, PURPLE_INPUT_READ, |
| 12007 | 190 | ggp_async_token_handler, gc); |
| 191 | } | |
| 192 | /* }}} */ | |
| 193 | ||
| 194 | /* ---------------------------------------------------------------------- */ | |
| 195 | ||
| 11360 | 196 | /** |
| 197 | * Request buddylist from the server. | |
| 198 | * Buddylist is received in the ggp_callback_recv(). | |
| 199 | * | |
| 200 | * @param Current action handler. | |
| 201 | */ | |
| 15884 | 202 | /* static void ggp_action_buddylist_get(PurplePluginAction *action) {{{ */ |
| 203 | static void ggp_action_buddylist_get(PurplePluginAction *action) | |
| 11360 | 204 | { |
| 15884 | 205 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 206 | GGPInfo *info = gc->proto_data; |
| 207 | ||
| 15884 | 208 | purple_debug_info("gg", "Downloading...\n"); |
| 11360 | 209 | |
| 210 | gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | |
| 211 | } | |
| 212 | /* }}} */ | |
| 213 | ||
| 214 | /** | |
| 215 | * Upload the buddylist to the server. | |
| 216 | * | |
| 217 | * @param action Current action handler. | |
| 218 | */ | |
| 15884 | 219 | /* static void ggp_action_buddylist_put(PurplePluginAction *action) {{{ */ |
| 220 | static void ggp_action_buddylist_put(PurplePluginAction *action) | |
| 11360 | 221 | { |
| 15884 | 222 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 223 | GGPInfo *info = gc->proto_data; |
| 224 | ||
| 15884 | 225 | char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc)); |
| 11360 | 226 | |
| 15884 | 227 | purple_debug_info("gg", "Uploading...\n"); |
| 11360 | 228 | |
| 229 | if (buddylist == NULL) | |
| 230 | return; | |
| 231 | ||
| 232 | gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist); | |
| 233 | g_free(buddylist); | |
| 234 | } | |
| 235 | /* }}} */ | |
| 236 | ||
| 237 | /** | |
| 238 | * Delete buddylist from the server. | |
| 239 | * | |
| 240 | * @param action Current action handler. | |
| 241 | */ | |
| 15884 | 242 | /* static void ggp_action_buddylist_delete(PurplePluginAction *action) {{{ */ |
| 243 | static void ggp_action_buddylist_delete(PurplePluginAction *action) | |
| 11360 | 244 | { |
| 15884 | 245 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 246 | GGPInfo *info = gc->proto_data; |
| 247 | ||
| 15884 | 248 | purple_debug_info("gg", "Deleting...\n"); |
| 11360 | 249 | |
| 250 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 251 | } | |
| 252 | /* }}} */ | |
| 253 | ||
| 254 | /* | |
| 255 | */ | |
|
17455
18680c136815
Fix a small memory leak and eliminate a double-free.
Richard Laager <rlaager@pidgin.im>
parents:
16746
diff
changeset
|
256 | /* static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *file) {{{ */ |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
257 | static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *filename) |
| 11360 | 258 | { |
| 15884 | 259 | PurpleAccount *account = purple_connection_get_account(gc); |
| 11360 | 260 | |
| 261 | char *buddylist = ggp_buddylist_dump(account); | |
| 262 | ||
| 15884 | 263 | purple_debug_info("gg", "Saving...\n"); |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
264 | purple_debug_info("gg", "file = %s\n", filename); |
| 11360 | 265 | |
| 266 | if (buddylist == NULL) { | |
| 15884 | 267 | purple_notify_info(account, _("Save Buddylist..."), |
| 12007 | 268 | _("Your buddylist is empty, nothing was written to the file."), |
| 269 | NULL); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
270 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
271 | } |
| 2393 | 272 | |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
273 | if(purple_util_write_data_to_file_absolute(filename, buddylist, -1)) { |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
274 | purple_notify_info(account, _("Save Buddylist..."), |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
275 | _("Buddylist saved successfully!"), NULL); |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
276 | } else { |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
277 | gchar *primary = g_strdup_printf( |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
278 | _("Couldn't write buddy list for %s to %s"), |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
279 | purple_account_get_username(account), filename); |
|
21497
8187406f2043
May as well use an existing string as the title for the error notification.
Will Thompson <resiak@pidgin.im>
parents:
21496
diff
changeset
|
280 | purple_notify_error(account, _("Save Buddylist..."), |
|
21496
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
281 | primary, NULL); |
|
32972bf7cd4e
Actually properly fix this gg "write my buddy list to a file" callback by just
Will Thompson <resiak@pidgin.im>
parents:
21485
diff
changeset
|
282 | g_free(primary); |
| 11360 | 283 | } |
| 284 | ||
| 285 | g_free(buddylist); | |
| 286 | } | |
| 287 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
288 | |
| 11360 | 289 | /* |
| 290 | */ | |
| 15884 | 291 | /* static void ggp_callback_buddylist_load_ok(PurpleConnection *gc, gchar *file) {{{ */ |
| 292 | static void ggp_callback_buddylist_load_ok(PurpleConnection *gc, gchar *file) | |
| 11360 | 293 | { |
| 15884 | 294 | PurpleAccount *account = purple_connection_get_account(gc); |
| 12007 | 295 | GError *error = NULL; |
| 296 | char *buddylist = NULL; | |
| 297 | gsize length; | |
| 11360 | 298 | |
| 15884 | 299 | purple_debug_info("gg", "file_name = %s\n", file); |
| 11360 | 300 | |
| 12007 | 301 | if (!g_file_get_contents(file, &buddylist, &length, &error)) { |
| 15884 | 302 | purple_notify_error(account, |
| 12007 | 303 | _("Couldn't load buddylist"), |
| 304 | _("Couldn't load buddylist"), | |
| 305 | error->message); | |
| 306 | ||
| 15884 | 307 | purple_debug_error("gg", |
| 12007 | 308 | "Couldn't load buddylist. file = %s; error = %s\n", |
| 309 | file, error->message); | |
| 310 | ||
| 311 | g_error_free(error); | |
| 312 | ||
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
313 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
314 | } |
| 11360 | 315 | |
| 316 | ggp_buddylist_load(gc, buddylist); | |
| 317 | g_free(buddylist); | |
| 318 | ||
| 15884 | 319 | purple_notify_info(account, |
| 11360 | 320 | _("Load Buddylist..."), |
| 321 | _("Buddylist loaded successfully!"), NULL); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
322 | } |
| 11360 | 323 | /* }}} */ |
| 324 | ||
| 325 | /* | |
| 326 | */ | |
| 15884 | 327 | /* static void ggp_action_buddylist_save(PurplePluginAction *action) {{{ */ |
| 328 | static void ggp_action_buddylist_save(PurplePluginAction *action) | |
| 11360 | 329 | { |
| 15884 | 330 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 331 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
332 | purple_request_file(action, _("Save buddylist..."), NULL, TRUE, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
333 | G_CALLBACK(ggp_callback_buddylist_save_ok), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
334 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
335 | gc); |
| 11360 | 336 | } |
| 337 | /* }}} */ | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
338 | |
| 11360 | 339 | /* |
| 340 | */ | |
| 15884 | 341 | /* static void ggp_action_buddylist_load(PurplePluginAction *action) {{{ */ |
| 342 | static void ggp_action_buddylist_load(PurplePluginAction *action) | |
| 11360 | 343 | { |
| 15884 | 344 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 345 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
346 | purple_request_file(action, "Load buddylist from file...", NULL, FALSE, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
347 | G_CALLBACK(ggp_callback_buddylist_load_ok), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
348 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
349 | gc); |
| 11360 | 350 | } |
| 351 | /* }}} */ | |
| 352 | ||
| 353 | /* | |
| 354 | */ | |
| 15884 | 355 | /* static void ggp_callback_register_account_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 356 | static void ggp_callback_register_account_ok(PurpleConnection *gc, | |
| 357 | PurpleRequestFields *fields) | |
| 11414 | 358 | { |
| 15884 | 359 | PurpleAccount *account; |
| 11414 | 360 | GGPInfo *info = gc->proto_data; |
| 361 | struct gg_http *h = NULL; | |
| 362 | struct gg_pubdir *s; | |
| 363 | uin_t uin; | |
| 364 | gchar *email, *p1, *p2, *t; | |
| 12007 | 365 | GGPToken *token = info->token; |
| 11414 | 366 | |
| 15884 | 367 | email = charset_convert(purple_request_fields_get_string(fields, "email"), |
| 11414 | 368 | "UTF-8", "CP1250"); |
| 15884 | 369 | p1 = charset_convert(purple_request_fields_get_string(fields, "password1"), |
| 11414 | 370 | "UTF-8", "CP1250"); |
| 15884 | 371 | p2 = charset_convert(purple_request_fields_get_string(fields, "password2"), |
| 11414 | 372 | "UTF-8", "CP1250"); |
| 15884 | 373 | t = charset_convert(purple_request_fields_get_string(fields, "token"), |
| 11414 | 374 | "UTF-8", "CP1250"); |
| 375 | ||
| 15884 | 376 | account = purple_connection_get_account(gc); |
| 11414 | 377 | |
| 378 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 379 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 21279 | 380 | purple_connection_error_reason (gc, |
| 381 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
382 | _("Fill in the registration fields.")); |
| 11414 | 383 | goto exit_err; |
| 384 | } | |
| 385 | ||
| 386 | if (g_utf8_collate(p1, p2) != 0) { | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
387 | purple_connection_error_reason (gc, |
| 21279 | 388 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
389 | _("Passwords do not match.")); |
| 11414 | 390 | goto exit_err; |
| 391 | } | |
| 392 | ||
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22546
diff
changeset
|
393 | purple_debug_info("gg", "register_account_ok: token_id = %s; t = %s\n", |
| 12007 | 394 | token->id, t); |
| 395 | h = gg_register3(email, p1, token->id, t, 0); | |
| 11414 | 396 | if (h == NULL || !(s = h->data) || !s->success) { |
| 21279 | 397 | purple_connection_error_reason (gc, |
| 398 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
399 | _("Unable to register new account. Error occurred.\n")); |
| 11414 | 400 | goto exit_err; |
| 401 | } | |
| 402 | ||
| 403 | uin = s->uin; | |
| 15884 | 404 | purple_debug_info("gg", "registered uin: %d\n", uin); |
| 11414 | 405 | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
406 | g_free(t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
407 | t = g_strdup_printf("%u", uin); |
| 15884 | 408 | purple_account_set_username(account, t); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
409 | /* Save the password if remembering passwords for the account */ |
| 15884 | 410 | purple_account_set_password(account, p1); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
411 | |
| 15884 | 412 | purple_notify_info(NULL, _("New Gadu-Gadu Account Registered"), |
| 11414 | 413 | _("Registration completed successfully!"), NULL); |
| 414 | ||
|
18997
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
415 | if(account->registration_cb) |
|
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
416 | (account->registration_cb)(account, TRUE, account->registration_cb_user_data); |
| 12007 | 417 | /* TODO: the currently open Accounts Window will not be updated withthe |
| 418 | * new username and etc, we need to somehow have it refresh at this | |
| 419 | * point | |
| 420 | */ | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
421 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
422 | /* Need to disconnect or actually log in. For now, we disconnect. */ |
| 15884 | 423 | purple_connection_destroy(gc); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
424 | |
| 11414 | 425 | exit_err: |
|
18997
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
426 | if(account->registration_cb) |
|
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
427 | (account->registration_cb)(account, FALSE, account->registration_cb_user_data); |
|
072dcd2ed1b3
Gadu-Gadu now calls the registration_cb for the account if it is set after performing a registration
Evan Schoenberg <evands@pidgin.im>
parents:
18629
diff
changeset
|
428 | |
| 11414 | 429 | gg_register_free(h); |
| 430 | g_free(email); | |
| 431 | g_free(p1); | |
| 432 | g_free(p2); | |
| 433 | g_free(t); | |
| 12007 | 434 | g_free(token->id); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
435 | g_free(token); |
| 11414 | 436 | } |
| 437 | /* }}} */ | |
| 438 | ||
| 11565 | 439 | /* |
| 440 | */ | |
| 15884 | 441 | /* static void ggp_callback_register_account_cancel(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 442 | static void ggp_callback_register_account_cancel(PurpleConnection *gc, | |
| 443 | PurpleRequestFields *fields) | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
444 | { |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
445 | GGPInfo *info = gc->proto_data; |
| 12007 | 446 | GGPToken *token = info->token; |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
447 | |
| 15884 | 448 | purple_connection_destroy(gc); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
449 | |
| 12007 | 450 | g_free(token->id); |
| 451 | g_free(token->data); | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
452 | g_free(token); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
453 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
454 | } |
| 11565 | 455 | /* }}} */ |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
456 | |
| 12007 | 457 | /* |
| 458 | */ | |
| 15884 | 459 | /* static void ggp_register_user_dialog(PurpleConnection *gc) {{{ */ |
| 460 | static void ggp_register_user_dialog(PurpleConnection *gc) | |
| 12007 | 461 | { |
| 15884 | 462 | PurpleAccount *account; |
| 463 | PurpleRequestFields *fields; | |
| 464 | PurpleRequestFieldGroup *group; | |
| 465 | PurpleRequestField *field; | |
| 12007 | 466 | |
| 467 | GGPInfo *info = gc->proto_data; | |
| 468 | GGPToken *token = info->token; | |
| 469 | ||
| 470 | ||
| 15884 | 471 | account = purple_connection_get_account(gc); |
| 12007 | 472 | |
| 15884 | 473 | fields = purple_request_fields_new(); |
| 474 | group = purple_request_field_group_new(NULL); | |
| 475 | purple_request_fields_add_group(fields, group); | |
| 12007 | 476 | |
| 15884 | 477 | field = purple_request_field_string_new("email", |
|
13546
0700f0c29e14
[gaim-migrate @ 15922]
Richard Laager <rlaager@pidgin.im>
parents:
13518
diff
changeset
|
478 | _("E-mail"), "", FALSE); |
| 15884 | 479 | purple_request_field_string_set_masked(field, FALSE); |
| 480 | purple_request_field_group_add_field(group, field); | |
| 12007 | 481 | |
| 15884 | 482 | field = purple_request_field_string_new("password1", |
| 12007 | 483 | _("Password"), "", FALSE); |
| 15884 | 484 | purple_request_field_string_set_masked(field, TRUE); |
| 485 | purple_request_field_group_add_field(group, field); | |
| 12007 | 486 | |
| 15884 | 487 | field = purple_request_field_string_new("password2", |
| 12007 | 488 | _("Password (retype)"), "", FALSE); |
| 15884 | 489 | purple_request_field_string_set_masked(field, TRUE); |
| 490 | purple_request_field_group_add_field(group, field); | |
| 12007 | 491 | |
| 15884 | 492 | field = purple_request_field_string_new("token", |
| 12007 | 493 | _("Enter current token"), "", FALSE); |
| 15884 | 494 | purple_request_field_string_set_masked(field, FALSE); |
| 495 | purple_request_field_group_add_field(group, field); | |
| 12007 | 496 | |
| 497 | /* original size: 60x24 */ | |
| 15884 | 498 | field = purple_request_field_image_new("token_img", |
| 12007 | 499 | _("Current token"), token->data, token->size); |
| 15884 | 500 | purple_request_field_group_add_field(group, field); |
| 12007 | 501 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
502 | purple_request_fields(account, |
| 12007 | 503 | _("Register New Gadu-Gadu Account"), |
| 504 | _("Register New Gadu-Gadu Account"), | |
| 505 | _("Please, fill in the following fields"), | |
| 506 | fields, | |
| 507 | _("OK"), G_CALLBACK(ggp_callback_register_account_ok), | |
| 508 | _("Cancel"), G_CALLBACK(ggp_callback_register_account_cancel), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
509 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
510 | gc); |
| 12007 | 511 | } |
| 512 | /* }}} */ | |
| 513 | ||
| 11414 | 514 | /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ |
| 515 | ||
| 516 | /* | |
| 517 | */ | |
| 15884 | 518 | /* static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 519 | static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) | |
| 11414 | 520 | { |
| 521 | GGPInfo *info = gc->proto_data; | |
| 13641 | 522 | GGPSearchForm *form = user_data; |
| 523 | guint32 seq; | |
| 11414 | 524 | |
| 13641 | 525 | g_free(form->offset); |
| 526 | form->offset = g_strdup(form->last_uin); | |
| 527 | ||
| 528 | ggp_search_remove(info->searches, form->seq); | |
| 529 | ||
| 530 | seq = ggp_search_start(gc, form); | |
| 531 | ggp_search_add(info->searches, seq, form); | |
| 11414 | 532 | } |
| 533 | /* }}} */ | |
| 534 | ||
| 535 | /* | |
| 536 | */ | |
| 15884 | 537 | /* static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 538 | static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data) | |
| 11414 | 539 | { |
| 15884 | 540 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
| 12007 | 541 | g_list_nth_data(row, 0), NULL, NULL); |
| 11414 | 542 | } |
| 543 | /* }}} */ | |
| 544 | ||
| 545 | /* | |
| 546 | */ | |
| 15884 | 547 | /* static void ggp_callback_im(PurpleConnection *gc, GList *row, gpointer user_data) {{{ */ |
| 548 | static void ggp_callback_im(PurpleConnection *gc, GList *row, gpointer user_data) | |
| 13642 | 549 | { |
| 15884 | 550 | PurpleAccount *account; |
| 551 | PurpleConversation *conv; | |
| 13642 | 552 | char *name; |
| 553 | ||
| 15884 | 554 | account = purple_connection_get_account(gc); |
| 13642 | 555 | |
| 556 | name = g_list_nth_data(row, 0); | |
| 15884 | 557 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name); |
| 558 | purple_conversation_present(conv); | |
| 13642 | 559 | } |
| 560 | /* }}} */ | |
| 561 | ||
| 562 | /* | |
| 563 | */ | |
| 15884 | 564 | /* static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 565 | static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) | |
| 11414 | 566 | { |
| 567 | GGPInfo *info = gc->proto_data; | |
| 568 | GGPSearchForm *form; | |
| 13641 | 569 | guint32 seq; |
| 11414 | 570 | |
| 13641 | 571 | form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL); |
| 11414 | 572 | |
| 13641 | 573 | form->user_data = info; |
| 12007 | 574 | form->lastname = charset_convert( |
| 15884 | 575 | purple_request_fields_get_string(fields, "lastname"), |
| 12007 | 576 | "UTF-8", "CP1250"); |
| 577 | form->firstname = charset_convert( | |
| 15884 | 578 | purple_request_fields_get_string(fields, "firstname"), |
| 12007 | 579 | "UTF-8", "CP1250"); |
| 580 | form->nickname = charset_convert( | |
| 15884 | 581 | purple_request_fields_get_string(fields, "nickname"), |
| 12007 | 582 | "UTF-8", "CP1250"); |
| 583 | form->city = charset_convert( | |
| 15884 | 584 | purple_request_fields_get_string(fields, "city"), |
| 12007 | 585 | "UTF-8", "CP1250"); |
| 586 | form->birthyear = charset_convert( | |
| 15884 | 587 | purple_request_fields_get_string(fields, "year"), |
| 12007 | 588 | "UTF-8", "CP1250"); |
| 11414 | 589 | |
| 15884 | 590 | switch (purple_request_fields_get_choice(fields, "gender")) { |
| 11414 | 591 | case 1: |
| 592 | form->gender = g_strdup(GG_PUBDIR50_GENDER_MALE); | |
| 593 | break; | |
| 594 | case 2: | |
| 595 | form->gender = g_strdup(GG_PUBDIR50_GENDER_FEMALE); | |
| 596 | break; | |
| 597 | default: | |
| 598 | form->gender = NULL; | |
| 599 | break; | |
| 600 | } | |
| 601 | ||
| 15884 | 602 | form->active = purple_request_fields_get_bool(fields, "active") |
| 11414 | 603 | ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL; |
| 604 | ||
| 605 | form->offset = g_strdup("0"); | |
| 606 | ||
| 13641 | 607 | seq = ggp_search_start(gc, form); |
| 608 | ggp_search_add(info->searches, seq, form); | |
| 11414 | 609 | } |
| 610 | /* }}} */ | |
| 611 | ||
| 612 | /* | |
| 613 | */ | |
| 15884 | 614 | /* static void ggp_find_buddies(PurplePluginAction *action) {{{ */ |
| 615 | static void ggp_find_buddies(PurplePluginAction *action) | |
| 11414 | 616 | { |
| 15884 | 617 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11414 | 618 | |
| 15884 | 619 | PurpleRequestFields *fields; |
| 620 | PurpleRequestFieldGroup *group; | |
| 621 | PurpleRequestField *field; | |
| 11414 | 622 | |
| 15884 | 623 | fields = purple_request_fields_new(); |
| 624 | group = purple_request_field_group_new(NULL); | |
| 625 | purple_request_fields_add_group(fields, group); | |
| 11414 | 626 | |
| 15884 | 627 | field = purple_request_field_string_new("lastname", |
| 12007 | 628 | _("Last name"), NULL, FALSE); |
| 15884 | 629 | purple_request_field_string_set_masked(field, FALSE); |
| 630 | purple_request_field_group_add_field(group, field); | |
| 11414 | 631 | |
| 15884 | 632 | field = purple_request_field_string_new("firstname", |
| 12007 | 633 | _("First name"), NULL, FALSE); |
| 15884 | 634 | purple_request_field_string_set_masked(field, FALSE); |
| 635 | purple_request_field_group_add_field(group, field); | |
| 11414 | 636 | |
| 15884 | 637 | field = purple_request_field_string_new("nickname", |
| 12007 | 638 | _("Nickname"), NULL, FALSE); |
| 15884 | 639 | purple_request_field_string_set_masked(field, FALSE); |
| 640 | purple_request_field_group_add_field(group, field); | |
| 11414 | 641 | |
| 15884 | 642 | field = purple_request_field_string_new("city", |
| 12007 | 643 | _("City"), NULL, FALSE); |
| 15884 | 644 | purple_request_field_string_set_masked(field, FALSE); |
| 645 | purple_request_field_group_add_field(group, field); | |
| 11414 | 646 | |
| 15884 | 647 | field = purple_request_field_string_new("year", |
| 12007 | 648 | _("Year of birth"), NULL, FALSE); |
| 15884 | 649 | purple_request_field_group_add_field(group, field); |
| 11414 | 650 | |
| 15884 | 651 | field = purple_request_field_choice_new("gender", _("Gender"), 0); |
| 652 | purple_request_field_choice_add(field, _("Male or female")); | |
| 653 | purple_request_field_choice_add(field, _("Male")); | |
| 654 | purple_request_field_choice_add(field, _("Female")); | |
| 655 | purple_request_field_group_add_field(group, field); | |
| 11414 | 656 | |
| 15884 | 657 | field = purple_request_field_bool_new("active", |
| 12007 | 658 | _("Only online"), FALSE); |
| 15884 | 659 | purple_request_field_group_add_field(group, field); |
| 11414 | 660 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
661 | purple_request_fields(gc, |
| 11414 | 662 | _("Find buddies"), |
| 663 | _("Find buddies"), | |
| 664 | _("Please, enter your search criteria below"), | |
| 665 | fields, | |
| 666 | _("OK"), G_CALLBACK(ggp_callback_find_buddies), | |
| 667 | _("Cancel"), NULL, | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
668 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
669 | gc); |
| 11414 | 670 | } |
| 671 | /* }}} */ | |
| 672 | ||
| 673 | /* ----- CHANGE PASSWORD ------------------------------------------------ */ | |
| 674 | ||
| 675 | /* | |
| 676 | */ | |
| 15884 | 677 | /* static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 678 | static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) | |
| 2393 | 679 | { |
| 15884 | 680 | PurpleAccount *account; |
| 11360 | 681 | GGPInfo *info = gc->proto_data; |
| 682 | struct gg_http *h; | |
| 683 | gchar *cur, *p1, *p2, *t; | |
| 684 | ||
| 12007 | 685 | cur = charset_convert( |
| 15884 | 686 | purple_request_fields_get_string(fields, "password_cur"), |
| 12007 | 687 | "UTF-8", "CP1250"); |
| 688 | p1 = charset_convert( | |
| 15884 | 689 | purple_request_fields_get_string(fields, "password1"), |
| 12007 | 690 | "UTF-8", "CP1250"); |
| 691 | p2 = charset_convert( | |
| 15884 | 692 | purple_request_fields_get_string(fields, "password2"), |
| 12007 | 693 | "UTF-8", "CP1250"); |
| 694 | t = charset_convert( | |
| 15884 | 695 | purple_request_fields_get_string(fields, "token"), |
| 12007 | 696 | "UTF-8", "CP1250"); |
| 11360 | 697 | |
| 15884 | 698 | account = purple_connection_get_account(gc); |
| 11360 | 699 | |
| 700 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 701 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 15884 | 702 | purple_notify_error(account, NULL, _("Fill in the fields."), NULL); |
| 11360 | 703 | goto exit_err; |
| 704 | } | |
| 705 | ||
| 706 | if (g_utf8_collate(p1, p2) != 0) { | |
| 15884 | 707 | purple_notify_error(account, NULL, |
| 12007 | 708 | _("New passwords do not match."), NULL); |
| 11360 | 709 | goto exit_err; |
| 710 | } | |
| 2393 | 711 | |
| 15884 | 712 | if (g_utf8_collate(cur, purple_account_get_password(account)) != 0) { |
| 713 | purple_notify_error(account, NULL, | |
| 11360 | 714 | _("Your current password is different from the one that you specified."), |
| 715 | NULL); | |
| 716 | goto exit_err; | |
| 717 | } | |
| 718 | ||
| 15884 | 719 | purple_debug_info("gg", "Changing password\n"); |
| 11360 | 720 | |
| 721 | /* XXX: this e-mail should be a pref... */ | |
| 722 | h = gg_change_passwd4(ggp_get_uin(account), | |
| 15884 | 723 | "user@example.net", purple_account_get_password(account), |
| 12007 | 724 | p1, info->token->id, t, 0); |
| 2393 | 725 | |
| 11360 | 726 | if (h == NULL) { |
| 15884 | 727 | purple_notify_error(account, NULL, |
| 14754 | 728 | _("Unable to change password. Error occurred.\n"), |
| 11360 | 729 | NULL); |
| 730 | goto exit_err; | |
| 731 | } | |
| 732 | ||
| 15884 | 733 | purple_account_set_password(account, p1); |
| 11360 | 734 | |
| 735 | gg_change_passwd_free(h); | |
| 736 | ||
| 15884 | 737 | purple_notify_info(account, _("Change password for the Gadu-Gadu account"), |
| 11360 | 738 | _("Password was changed successfully!"), NULL); |
| 739 | ||
| 740 | exit_err: | |
| 741 | g_free(cur); | |
| 742 | g_free(p1); | |
| 743 | g_free(p2); | |
| 744 | g_free(t); | |
| 12007 | 745 | g_free(info->token->id); |
| 746 | g_free(info->token->data); | |
| 747 | g_free(info->token); | |
| 748 | } | |
| 749 | /* }}} */ | |
| 750 | ||
| 751 | /* | |
| 752 | */ | |
| 15884 | 753 | /* static void ggp_change_passwd_dialog(PurpleConnection *gc) {{{ */ |
| 754 | static void ggp_change_passwd_dialog(PurpleConnection *gc) | |
| 12007 | 755 | { |
| 15884 | 756 | PurpleRequestFields *fields; |
| 757 | PurpleRequestFieldGroup *group; | |
| 758 | PurpleRequestField *field; | |
| 12007 | 759 | |
| 760 | GGPInfo *info = gc->proto_data; | |
| 761 | GGPToken *token = info->token; | |
| 762 | ||
| 763 | char *msg; | |
| 764 | ||
| 765 | ||
| 15884 | 766 | fields = purple_request_fields_new(); |
| 767 | group = purple_request_field_group_new(NULL); | |
| 768 | purple_request_fields_add_group(fields, group); | |
| 12007 | 769 | |
| 15884 | 770 | field = purple_request_field_string_new("password_cur", |
| 12007 | 771 | _("Current password"), "", FALSE); |
| 15884 | 772 | purple_request_field_string_set_masked(field, TRUE); |
| 773 | purple_request_field_group_add_field(group, field); | |
| 12007 | 774 | |
| 15884 | 775 | field = purple_request_field_string_new("password1", |
| 12007 | 776 | _("Password"), "", FALSE); |
| 15884 | 777 | purple_request_field_string_set_masked(field, TRUE); |
| 778 | purple_request_field_group_add_field(group, field); | |
| 12007 | 779 | |
| 15884 | 780 | field = purple_request_field_string_new("password2", |
| 12007 | 781 | _("Password (retype)"), "", FALSE); |
| 15884 | 782 | purple_request_field_string_set_masked(field, TRUE); |
| 783 | purple_request_field_group_add_field(group, field); | |
| 12007 | 784 | |
| 15884 | 785 | field = purple_request_field_string_new("token", |
| 12007 | 786 | _("Enter current token"), "", FALSE); |
| 15884 | 787 | purple_request_field_string_set_masked(field, FALSE); |
| 788 | purple_request_field_group_add_field(group, field); | |
| 12007 | 789 | |
| 790 | /* original size: 60x24 */ | |
| 15884 | 791 | field = purple_request_field_image_new("token_img", |
| 12007 | 792 | _("Current token"), token->data, token->size); |
| 15884 | 793 | purple_request_field_group_add_field(group, field); |
| 12007 | 794 | |
| 795 | msg = g_strdup_printf("%s %d", | |
| 796 | _("Please, enter your current password and your new password for UIN: "), | |
| 15884 | 797 | ggp_get_uin(purple_connection_get_account(gc))); |
| 12007 | 798 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
799 | purple_request_fields(gc, |
| 12007 | 800 | _("Change Gadu-Gadu Password"), |
| 801 | _("Change Gadu-Gadu Password"), | |
| 802 | msg, | |
| 803 | fields, _("OK"), G_CALLBACK(ggp_callback_change_passwd_ok), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
804 | _("Cancel"), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
805 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
806 | gc); |
| 12007 | 807 | |
| 808 | g_free(msg); | |
| 11360 | 809 | } |
| 810 | /* }}} */ | |
| 2393 | 811 | |
| 11360 | 812 | /* |
| 813 | */ | |
| 15884 | 814 | /* static void ggp_change_passwd(PurplePluginAction *action) {{{ */ |
| 815 | static void ggp_change_passwd(PurplePluginAction *action) | |
| 11360 | 816 | { |
| 15884 | 817 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 818 | |
| 12007 | 819 | ggp_token_request(gc, ggp_change_passwd_dialog); |
| 11360 | 820 | } |
| 821 | /* }}} */ | |
| 822 | ||
| 11414 | 823 | /* ----- CONFERENCES ---------------------------------------------------- */ |
| 824 | ||
| 11394 | 825 | /* |
| 826 | */ | |
| 15884 | 827 | /* static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */ |
| 828 | static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields) | |
| 11394 | 829 | { |
| 830 | GGPInfo *info = gc->proto_data; | |
| 15884 | 831 | PurpleRequestField *field; |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
832 | /* TODO: sel may be null. */ |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17455
diff
changeset
|
833 | GList *sel; |
| 11394 | 834 | |
| 15884 | 835 | field = purple_request_fields_get_field(fields, "name"); |
| 836 | sel = purple_request_field_list_get_selected(field); | |
| 11394 | 837 | |
| 12961 | 838 | ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy); |
| 839 | info->tmp_buddy = 0; | |
| 11394 | 840 | } |
| 841 | /* }}} */ | |
| 842 | ||
| 843 | /* | |
| 844 | */ | |
| 15884 | 845 | /* static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored) {{{ */ |
| 846 | static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored) | |
| 11394 | 847 | { |
| 15884 | 848 | PurpleBuddy *buddy; |
| 849 | PurpleConnection *gc; | |
| 11394 | 850 | GGPInfo *info; |
| 851 | ||
| 15884 | 852 | PurpleRequestFields *fields; |
| 853 | PurpleRequestFieldGroup *group; | |
| 854 | PurpleRequestField *field; | |
| 11394 | 855 | |
| 856 | GList *l; | |
| 857 | gchar *msg; | |
| 858 | ||
| 15884 | 859 | buddy = (PurpleBuddy *)node; |
| 860 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11394 | 861 | info = gc->proto_data; |
| 862 | ||
| 12961 | 863 | /* TODO: It tmp_buddy != 0 then stop! */ |
| 15884 | 864 | info->tmp_buddy = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11394 | 865 | |
| 15884 | 866 | fields = purple_request_fields_new(); |
| 867 | group = purple_request_field_group_new(NULL); | |
| 868 | purple_request_fields_add_group(fields, group); | |
| 11394 | 869 | |
| 15884 | 870 | field = purple_request_field_list_new("name", "Chat name"); |
| 11394 | 871 | for (l = info->chats; l != NULL; l = l->next) { |
| 872 | GGPChat *chat = l->data; | |
| 15884 | 873 | purple_request_field_list_add(field, g_strdup(chat->name), |
| 12007 | 874 | g_strdup(chat->name)); |
| 11394 | 875 | } |
| 15884 | 876 | purple_request_field_group_add_field(group, field); |
| 11394 | 877 | |
| 12007 | 878 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
| 15884 | 879 | purple_buddy_get_alias(buddy)); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
880 | purple_request_fields(gc, |
| 11394 | 881 | _("Add to chat..."), |
| 882 | _("Add to chat..."), | |
| 883 | msg, | |
| 884 | fields, | |
| 885 | _("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
886 | _("Cancel"), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
887 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
888 | gc); |
| 11394 | 889 | g_free(msg); |
| 890 | } | |
| 891 | /* }}} */ | |
| 892 | ||
| 11414 | 893 | /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
| 894 | ||
| 11410 | 895 | /* |
| 896 | */ | |
| 15884 | 897 | /* static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored) {{{ */ |
| 898 | static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored) | |
| 11410 | 899 | { |
| 15884 | 900 | PurpleConnection *gc; |
| 901 | PurpleBuddy *buddy; | |
| 11410 | 902 | GGPInfo *info; |
| 903 | uin_t uin; | |
| 904 | ||
| 15884 | 905 | buddy = (PurpleBuddy *)node; |
| 906 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11410 | 907 | info = gc->proto_data; |
| 908 | ||
| 15884 | 909 | uin = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11410 | 910 | |
| 15884 | 911 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 912 | purple_blist_node_set_bool(node, "blocked", FALSE); | |
| 11410 | 913 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); |
| 914 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 15884 | 915 | purple_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); |
| 11410 | 916 | } else { |
| 15884 | 917 | purple_blist_node_set_bool(node, "blocked", TRUE); |
| 11410 | 918 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); |
| 919 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 15884 | 920 | purple_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); |
| 11410 | 921 | } |
| 922 | } | |
| 923 | /* }}} */ | |
| 924 | ||
| 11360 | 925 | /* ---------------------------------------------------------------------- */ |
| 11414 | 926 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 927 | /* ---------------------------------------------------------------------- */ | |
| 928 | ||
| 12964 | 929 | /* just a prototype */ |
| 15884 | 930 | static void ggp_set_status(PurpleAccount *account, PurpleStatus *status); |
| 12964 | 931 | |
| 11414 | 932 | /** |
| 933 | * Handle change of the status of the buddy. | |
| 934 | * | |
| 15884 | 935 | * @param gc PurpleConnection |
| 11414 | 936 | * @param uin UIN of the buddy. |
| 937 | * @param status ID of the status. | |
| 938 | * @param descr Description. | |
| 939 | */ | |
| 15884 | 940 | /* static void ggp_generic_status_handler(PurpleConnection *gc, uin_t uin, int status, const char *descr) {{{ */ |
| 941 | static void ggp_generic_status_handler(PurpleConnection *gc, uin_t uin, | |
| 12007 | 942 | int status, const char *descr) |
| 11414 | 943 | { |
| 944 | gchar *from; | |
| 945 | const char *st; | |
| 946 | gchar *msg; | |
| 947 | ||
| 948 | from = g_strdup_printf("%ld", (unsigned long int)uin); | |
| 949 | switch (status) { | |
| 950 | case GG_STATUS_NOT_AVAIL: | |
| 951 | case GG_STATUS_NOT_AVAIL_DESCR: | |
| 952 | st = "offline"; | |
| 953 | break; | |
| 954 | case GG_STATUS_AVAIL: | |
| 955 | case GG_STATUS_AVAIL_DESCR: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
956 | st = "available"; |
| 11414 | 957 | break; |
| 958 | case GG_STATUS_BUSY: | |
| 959 | case GG_STATUS_BUSY_DESCR: | |
|
12718
34152a2d35fc
[gaim-migrate @ 15062]
Richard Laager <rlaager@pidgin.im>
parents:
12717
diff
changeset
|
960 | st = "away"; |
| 11414 | 961 | break; |
| 962 | case GG_STATUS_BLOCKED: | |
| 963 | /* user is blocking us.... */ | |
| 964 | st = "blocked"; | |
| 965 | break; | |
| 966 | default: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
967 | st = "available"; |
| 15884 | 968 | purple_debug_info("gg", |
| 12007 | 969 | "GG_EVENT_NOTIFY: Unknown status: %d\n", status); |
| 11414 | 970 | break; |
| 971 | } | |
| 972 | ||
| 15884 | 973 | purple_debug_info("gg", "st = %s\n", st); |
| 11414 | 974 | msg = charset_convert(descr, "CP1250", "UTF-8"); |
| 15884 | 975 | purple_prpl_got_user_status(purple_connection_get_account(gc), |
| 12007 | 976 | from, st, "message", msg, NULL); |
| 11414 | 977 | g_free(from); |
| 978 | g_free(msg); | |
| 979 | } | |
| 980 | /* }}} */ | |
| 981 | ||
| 12007 | 982 | /* |
| 983 | */ | |
| 13643 | 984 | /* static void ggp_sr_close_cb(gpointer user_data) {{{ */ |
| 985 | static void ggp_sr_close_cb(gpointer user_data) | |
| 12220 | 986 | { |
| 13643 | 987 | GGPSearchForm *form = user_data; |
| 13641 | 988 | GGPInfo *info = form->user_data; |
| 12220 | 989 | |
| 13641 | 990 | ggp_search_remove(info->searches, form->seq); |
| 991 | ggp_search_form_destroy(form); | |
| 12220 | 992 | } |
| 993 | /* }}} */ | |
| 994 | ||
| 13645 | 995 | /** |
| 996 | * Translate a status' ID to a more user-friendly name. | |
| 997 | * | |
| 998 | * @param id The ID of the status. | |
| 999 | * | |
| 1000 | * @return The user-friendly name of the status. | |
| 1001 | */ | |
| 1002 | /* static const char *ggp_status_by_id(unsigned int id) {{{ */ | |
| 1003 | static const char *ggp_status_by_id(unsigned int id) | |
| 1004 | { | |
| 1005 | const char *st; | |
| 1006 | ||
| 15884 | 1007 | purple_debug_info("gg", "ggp_status_by_id: %d\n", id); |
| 13645 | 1008 | switch (id) { |
| 1009 | case GG_STATUS_NOT_AVAIL: | |
| 1010 | st = _("Offline"); | |
| 1011 | break; | |
| 1012 | case GG_STATUS_AVAIL: | |
| 1013 | st = _("Available"); | |
| 1014 | break; | |
| 1015 | case GG_STATUS_BUSY: | |
| 1016 | st = _("Away"); | |
| 1017 | break; | |
| 1018 | default: | |
| 1019 | st = _("Unknown"); | |
| 1020 | break; | |
| 1021 | } | |
| 1022 | ||
| 1023 | return st; | |
| 1024 | } | |
| 1025 | /* }}} */ | |
| 1026 | ||
| 12220 | 1027 | /* |
| 1028 | */ | |
| 15884 | 1029 | /* static void ggp_pubdir_handle_info(PurpleConnection *gc, gg_pubdir50_t req, GGPSearchForm *form) {{{ */ |
| 1030 | static void ggp_pubdir_handle_info(PurpleConnection *gc, gg_pubdir50_t req, | |
| 13643 | 1031 | GGPSearchForm *form) |
| 12007 | 1032 | { |
| 15884 | 1033 | PurpleNotifyUserInfo *user_info; |
| 1034 | PurpleBuddy *buddy; | |
| 13643 | 1035 | char *val, *who; |
| 1036 | ||
| 15884 | 1037 | user_info = purple_notify_user_info_new(); |
| 13643 | 1038 | |
| 1039 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_STATUS); | |
| 13645 | 1040 | /* XXX: Use of ggp_str_to_uin() is an ugly hack! */ |
| 15884 | 1041 | purple_notify_user_info_add_pair(user_info, _("Status"), ggp_status_by_id(ggp_str_to_uin(val))); |
| 13643 | 1042 | g_free(val); |
| 1043 | ||
| 1044 | who = ggp_search_get_result(req, 0, GG_PUBDIR50_UIN); | |
| 15884 | 1045 | purple_notify_user_info_add_pair(user_info, _("UIN"), who); |
| 13643 | 1046 | |
| 1047 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_FIRSTNAME); | |
| 15884 | 1048 | purple_notify_user_info_add_pair(user_info, _("First Name"), val); |
| 13643 | 1049 | g_free(val); |
| 1050 | ||
| 1051 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_NICKNAME); | |
| 15884 | 1052 | purple_notify_user_info_add_pair(user_info, _("Nickname"), val); |
| 13643 | 1053 | g_free(val); |
| 1054 | ||
| 1055 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_CITY); | |
| 15884 | 1056 | purple_notify_user_info_add_pair(user_info, _("City"), val); |
| 13643 | 1057 | g_free(val); |
| 1058 | ||
| 1059 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_BIRTHYEAR); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1060 | if (strncmp(val, "0", 1)) { |
| 15884 | 1061 | purple_notify_user_info_add_pair(user_info, _("Birth Year"), val); |
| 13643 | 1062 | } |
| 1063 | g_free(val); | |
| 1064 | ||
| 15294 | 1065 | /* |
| 1066 | * Include a status message, if exists and buddy is in the blist. | |
| 1067 | */ | |
| 15884 | 1068 | buddy = purple_find_buddy(purple_connection_get_account(gc), who); |
| 15294 | 1069 | if (NULL != buddy) { |
| 15884 | 1070 | PurpleStatus *status; |
| 15294 | 1071 | const char *msg; |
| 1072 | char *text; | |
| 13643 | 1073 | |
| 15884 | 1074 | status = purple_presence_get_active_status(purple_buddy_get_presence(buddy)); |
| 1075 | msg = purple_status_get_attr_string(status, "message"); | |
| 13643 | 1076 | |
| 15294 | 1077 | if (msg != NULL) { |
| 1078 | text = g_markup_escape_text(msg, -1); | |
| 15884 | 1079 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15294 | 1080 | g_free(text); |
| 1081 | } | |
| 1082 | } | |
| 1083 | ||
|
18629
9e78088bfc46
Close temporary Get Info window when showing the real one. Fixes #1720.
Bartosz Oler <bartosz@pidgin.im>
parents:
18190
diff
changeset
|
1084 | purple_notify_userinfo(gc, who, user_info, ggp_sr_close_cb, form); |
| 15294 | 1085 | g_free(who); |
| 15884 | 1086 | purple_notify_user_info_destroy(user_info); |
| 13643 | 1087 | } |
| 1088 | /* }}} */ | |
| 1089 | ||
| 1090 | /* | |
| 1091 | */ | |
| 15884 | 1092 | /* static void ggp_pubdir_handle_full(PurpleConnection *gc, gg_pubdir50_t req, GGPSearchForm *form) {{{ */ |
| 1093 | static void ggp_pubdir_handle_full(PurpleConnection *gc, gg_pubdir50_t req, | |
| 13643 | 1094 | GGPSearchForm *form) |
| 1095 | { | |
| 15884 | 1096 | PurpleNotifySearchResults *results; |
| 1097 | PurpleNotifySearchColumn *column; | |
| 13643 | 1098 | int res_count; |
| 12007 | 1099 | int start; |
| 1100 | int i; | |
| 13641 | 1101 | |
| 13643 | 1102 | g_return_if_fail(form != NULL); |
| 12007 | 1103 | |
| 1104 | res_count = gg_pubdir50_count(req); | |
| 13643 | 1105 | res_count = (res_count > PUBDIR_RESULTS_MAX) ? PUBDIR_RESULTS_MAX : res_count; |
| 12007 | 1106 | |
| 15884 | 1107 | results = purple_notify_searchresults_new(); |
| 12007 | 1108 | |
| 12257 | 1109 | if (results == NULL) { |
| 15884 | 1110 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
| 12257 | 1111 | "Unable to display the search results.\n"); |
| 15884 | 1112 | purple_notify_error(gc, NULL, |
| 12257 | 1113 | _("Unable to display the search results."), |
| 1114 | NULL); | |
| 13641 | 1115 | ggp_sr_close_cb(form); |
| 12257 | 1116 | return; |
| 1117 | } | |
| 1118 | ||
| 15884 | 1119 | column = purple_notify_searchresults_column_new(_("UIN")); |
| 1120 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1121 | |
| 15884 | 1122 | column = purple_notify_searchresults_column_new(_("First Name")); |
| 1123 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1124 | |
| 15884 | 1125 | column = purple_notify_searchresults_column_new(_("Nickname")); |
| 1126 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1127 | |
| 15884 | 1128 | column = purple_notify_searchresults_column_new(_("City")); |
| 1129 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1130 | |
| 15884 | 1131 | column = purple_notify_searchresults_column_new(_("Birth Year")); |
| 1132 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1133 | |
| 15884 | 1134 | purple_debug_info("gg", "Going with %d entries\n", res_count); |
| 12007 | 1135 | |
| 1136 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 15884 | 1137 | purple_debug_info("gg", "start = %d\n", start); |
| 12007 | 1138 | |
| 1139 | for (i = 0; i < res_count; i++) { | |
| 1140 | GList *row = NULL; | |
| 1141 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 1142 | ||
| 1143 | /* TODO: Status will be displayed as an icon. */ | |
| 1144 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 1145 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1146 | GG_PUBDIR50_UIN)); | |
| 1147 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1148 | GG_PUBDIR50_FIRSTNAME)); | |
| 1149 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1150 | GG_PUBDIR50_NICKNAME)); | |
| 1151 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1152 | GG_PUBDIR50_CITY)); | |
| 1153 | row = g_list_append(row, | |
| 1154 | (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 1155 | ||
| 15884 | 1156 | purple_notify_searchresults_row_add(results, row); |
| 12007 | 1157 | |
| 1158 | if (i == res_count - 1) { | |
| 13641 | 1159 | g_free(form->last_uin); |
| 1160 | form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN); | |
| 12007 | 1161 | } |
| 1162 | } | |
| 1163 | ||
| 15884 | 1164 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_CONTINUE, |
| 12007 | 1165 | ggp_callback_show_next); |
| 15884 | 1166 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 12007 | 1167 | ggp_callback_add_buddy); |
| 15884 | 1168 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_IM, |
| 13642 | 1169 | ggp_callback_im); |
| 13643 | 1170 | |
| 13641 | 1171 | if (form->window == NULL) { |
| 15884 | 1172 | void *h = purple_notify_searchresults(gc, |
| 12007 | 1173 | _("Gadu-Gadu Public Directory"), |
| 12220 | 1174 | _("Search results"), NULL, results, |
| 15884 | 1175 | (PurpleNotifyCloseCallback)ggp_sr_close_cb, |
| 13641 | 1176 | form); |
| 12257 | 1177 | |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1178 | if (h == NULL) { |
| 15884 | 1179 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1180 | "Unable to display the search results.\n"); |
| 15884 | 1181 | purple_notify_error(gc, NULL, |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1182 | _("Unable to display the search results."), |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1183 | NULL); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1184 | return; |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1185 | } |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1186 | |
| 13641 | 1187 | form->window = h; |
| 12007 | 1188 | } else { |
| 15884 | 1189 | purple_notify_searchresults_new_rows(gc, results, form->window); |
| 12007 | 1190 | } |
| 1191 | } | |
| 1192 | /* }}} */ | |
| 1193 | ||
| 13643 | 1194 | /* |
| 1195 | */ | |
| 15884 | 1196 | /* static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) {{{ */ |
| 1197 | static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) | |
| 13643 | 1198 | { |
| 1199 | GGPInfo *info = gc->proto_data; | |
| 1200 | GGPSearchForm *form; | |
| 1201 | int res_count; | |
| 1202 | guint32 seq; | |
| 1203 | ||
| 1204 | seq = gg_pubdir50_seq(req); | |
| 1205 | form = ggp_search_get(info->searches, seq); | |
| 1206 | ||
| 1207 | /* | |
| 1208 | * this can happen when user will request more results | |
| 1209 | * and close the results window before they arrive. | |
| 1210 | */ | |
| 1211 | g_return_if_fail(form != NULL); | |
| 1212 | ||
| 1213 | res_count = gg_pubdir50_count(req); | |
| 1214 | if (res_count < 1) { | |
| 15884 | 1215 | purple_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); |
| 1216 | purple_notify_error(gc, NULL, | |
| 13643 | 1217 | _("No matching users found"), |
| 1218 | _("There are no users matching your search criteria.")); | |
| 1219 | ggp_sr_close_cb(form); | |
| 1220 | return; | |
| 1221 | } | |
| 1222 | ||
| 1223 | switch (form->search_type) { | |
| 1224 | case GGP_SEARCH_TYPE_INFO: | |
| 1225 | ggp_pubdir_handle_info(gc, req, form); | |
| 1226 | break; | |
| 1227 | case GGP_SEARCH_TYPE_FULL: | |
| 1228 | ggp_pubdir_handle_full(gc, req, form); | |
| 1229 | break; | |
| 1230 | default: | |
| 15884 | 1231 | purple_debug_warning("gg", "Unknown search_type!\n"); |
| 13643 | 1232 | break; |
| 1233 | } | |
| 1234 | } | |
| 1235 | /* }}} */ | |
| 1236 | ||
| 11414 | 1237 | /** |
| 1238 | * Dispatch a message received from a buddy. | |
| 1239 | * | |
| 15884 | 1240 | * @param gc PurpleConnection. |
| 11414 | 1241 | * @param ev Gadu-Gadu event structure. |
| 1242 | */ | |
| 15884 | 1243 | /* static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) {{{ */ |
| 1244 | static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) | |
| 11414 | 1245 | { |
| 1246 | GGPInfo *info = gc->proto_data; | |
| 15884 | 1247 | PurpleConversation *conv; |
| 11414 | 1248 | gchar *from; |
| 1249 | gchar *msg; | |
| 1250 | gchar *tmp; | |
| 1251 | ||
| 1252 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 1253 | ||
| 12961 | 1254 | tmp = charset_convert((const char *)ev->event.msg.message, |
| 12007 | 1255 | "CP1250", "UTF-8"); |
| 15884 | 1256 | purple_str_strip_char(tmp, '\r'); |
| 12961 | 1257 | msg = g_markup_escape_text(tmp, -1); |
| 1258 | g_free(tmp); | |
| 11414 | 1259 | |
| 15884 | 1260 | purple_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", |
| 12961 | 1261 | from, msg, ev->event.msg.msgclass, |
| 12007 | 1262 | ev->event.msg.recipients_count); |
| 11414 | 1263 | |
| 1264 | if (ev->event.msg.recipients_count == 0) { | |
| 12961 | 1265 | serv_got_im(gc, from, msg, 0, ev->event.msg.time); |
| 11414 | 1266 | } else { |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1267 | const char *chat_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1268 | int chat_id; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1269 | char *buddy_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1270 | |
| 11414 | 1271 | chat_name = ggp_confer_find_by_participants(gc, |
| 12007 | 1272 | ev->event.msg.recipients, |
| 1273 | ev->event.msg.recipients_count); | |
| 12961 | 1274 | |
| 11414 | 1275 | if (chat_name == NULL) { |
| 1276 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 1277 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 12007 | 1278 | |
| 1279 | ggp_confer_participants_add_uin(gc, chat_name, | |
| 1280 | ev->event.msg.sender); | |
| 1281 | ||
| 1282 | ggp_confer_participants_add(gc, chat_name, | |
| 1283 | ev->event.msg.recipients, | |
| 1284 | ev->event.msg.recipients_count); | |
| 11414 | 1285 | } |
| 1286 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 15884 | 1287 | chat_id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1288 | |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1289 | buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1290 | serv_got_chat_in(gc, chat_id, buddy_name, |
| 15884 | 1291 | PURPLE_MESSAGE_RECV, msg, ev->event.msg.time); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1292 | g_free(buddy_name); |
| 11414 | 1293 | } |
| 12961 | 1294 | g_free(msg); |
| 11414 | 1295 | g_free(from); |
| 1296 | } | |
| 1297 | /* }}} */ | |
| 1298 | ||
| 1299 | /* | |
| 1300 | */ | |
| 15884 | 1301 | /* static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */ |
| 1302 | static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) | |
| 11414 | 1303 | { |
| 15884 | 1304 | PurpleConnection *gc = _gc; |
| 11414 | 1305 | GGPInfo *info = gc->proto_data; |
| 1306 | struct gg_event *ev; | |
| 1307 | int i; | |
| 1308 | ||
| 1309 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1310 | purple_debug_error("gg", |
| 12007 | 1311 | "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); |
| 21279 | 1312 | purple_connection_error_reason (gc, |
| 1313 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1314 | _("Unable to read socket")); |
| 11414 | 1315 | return; |
| 1316 | } | |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
21630
diff
changeset
|
1317 | gc->last_received = time(NULL); |
| 11414 | 1318 | switch (ev->type) { |
| 1319 | case GG_EVENT_NONE: | |
| 1320 | /* Nothing happened. */ | |
| 1321 | break; | |
| 1322 | case GG_EVENT_MSG: | |
| 1323 | ggp_recv_message_handler(gc, ev); | |
| 1324 | break; | |
| 1325 | case GG_EVENT_ACK: | |
| 15884 | 1326 | purple_debug_info("gg", |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22546
diff
changeset
|
1327 | "message sent to: %u, delivery status=%d, seq=%d\n", |
| 12007 | 1328 | ev->event.ack.recipient, ev->event.ack.status, |
| 1329 | ev->event.ack.seq); | |
| 11414 | 1330 | break; |
| 1331 | case GG_EVENT_NOTIFY: | |
| 1332 | case GG_EVENT_NOTIFY_DESCR: | |
| 1333 | { | |
| 1334 | struct gg_notify_reply *n; | |
| 1335 | char *descr; | |
| 1336 | ||
| 15884 | 1337 | purple_debug_info("gg", "notify_pre: (%d) status: %d\n", |
| 11414 | 1338 | ev->event.notify->uin, |
| 1339 | ev->event.notify->status); | |
| 1340 | ||
| 1341 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 1342 | : ev->event.notify_descr.notify; | |
| 1343 | ||
| 1344 | for (; n->uin; n++) { | |
| 1345 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 12007 | 1346 | : ev->event.notify_descr.descr; |
| 1347 | ||
| 15884 | 1348 | purple_debug_info("gg", |
| 12007 | 1349 | "notify: (%d) status: %d; descr: %s\n", |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1350 | n->uin, n->status, descr ? descr : "(null)"); |
| 11414 | 1351 | |
| 1352 | ggp_generic_status_handler(gc, | |
| 12007 | 1353 | n->uin, n->status, descr); |
| 11414 | 1354 | } |
| 1355 | } | |
| 1356 | break; | |
| 1357 | case GG_EVENT_NOTIFY60: | |
| 15884 | 1358 | purple_debug_info("gg", |
| 12007 | 1359 | "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", |
| 1360 | ev->event.notify60->uin, ev->event.notify60->status, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1361 | ev->event.notify60->version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1362 | ev->event.notify60->descr ? ev->event.notify60->descr : "(null)"); |
| 11414 | 1363 | |
| 1364 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 15884 | 1365 | purple_debug_info("gg", |
| 12007 | 1366 | "notify60: (%d) status=%d; version=%d; descr=%s\n", |
| 1367 | ev->event.notify60[i].uin, | |
| 1368 | ev->event.notify60[i].status, | |
| 1369 | ev->event.notify60[i].version, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1370 | ev->event.notify60[i].descr ? ev->event.notify60[i].descr : "(null)"); |
| 11414 | 1371 | |
| 12007 | 1372 | ggp_generic_status_handler(gc, ev->event.notify60[i].uin, |
| 1373 | ev->event.notify60[i].status, | |
| 1374 | ev->event.notify60[i].descr); | |
| 11414 | 1375 | } |
| 1376 | break; | |
| 1377 | case GG_EVENT_STATUS: | |
| 15884 | 1378 | purple_debug_info("gg", "status: (%d) status=%d; descr=%s\n", |
| 11414 | 1379 | ev->event.status.uin, ev->event.status.status, |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1380 | ev->event.status.descr ? ev->event.status.descr : "(null)"); |
| 11414 | 1381 | |
| 12007 | 1382 | ggp_generic_status_handler(gc, ev->event.status.uin, |
| 1383 | ev->event.status.status, ev->event.status.descr); | |
| 11414 | 1384 | break; |
| 1385 | case GG_EVENT_STATUS60: | |
| 15884 | 1386 | purple_debug_info("gg", |
| 12007 | 1387 | "status60: (%d) status=%d; version=%d; descr=%s\n", |
| 1388 | ev->event.status60.uin, ev->event.status60.status, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1389 | ev->event.status60.version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1390 | ev->event.status60.descr ? ev->event.status60.descr : "(null)"); |
| 11414 | 1391 | |
| 12007 | 1392 | ggp_generic_status_handler(gc, ev->event.status60.uin, |
| 1393 | ev->event.status60.status, ev->event.status60.descr); | |
| 11414 | 1394 | break; |
| 1395 | case GG_EVENT_USERLIST: | |
| 1396 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 15884 | 1397 | purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); |
| 1398 | purple_notify_info(gc, NULL, | |
| 12220 | 1399 | _("Buddy list downloaded"), |
| 1400 | _("Your buddy list was downloaded from the server.")); | |
| 11414 | 1401 | if (ev->event.userlist.reply != NULL) { |
| 12007 | 1402 | ggp_buddylist_load(gc, ev->event.userlist.reply); |
| 11414 | 1403 | } |
| 1404 | } else { | |
| 15884 | 1405 | purple_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
| 1406 | purple_notify_info(gc, NULL, | |
| 12220 | 1407 | _("Buddy list uploaded"), |
| 1408 | _("Your buddy list was stored on the server.")); | |
| 11414 | 1409 | } |
| 1410 | break; | |
| 1411 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 12007 | 1412 | ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
| 1413 | break; | |
| 1414 | default: | |
| 15884 | 1415 | purple_debug_error("gg", |
| 12007 | 1416 | "unsupported event type=%d\n", ev->type); |
| 1417 | break; | |
| 1418 | } | |
| 11414 | 1419 | |
| 12007 | 1420 | gg_free_event(ev); |
| 1421 | } | |
| 1422 | /* }}} */ | |
| 11414 | 1423 | |
| 12007 | 1424 | /* |
| 1425 | */ | |
| 15884 | 1426 | /* static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */ |
| 1427 | static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) | |
| 12007 | 1428 | { |
| 15884 | 1429 | PurpleConnection *gc = _gc; |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1430 | GGPInfo *info; |
| 12007 | 1431 | struct gg_event *ev; |
| 11414 | 1432 | |
| 15884 | 1433 | g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1434 | |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1435 | info = gc->proto_data; |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1436 | |
| 15884 | 1437 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
| 12007 | 1438 | info->session->check, info->session->state); |
| 11414 | 1439 | |
| 12007 | 1440 | switch (info->session->state) { |
| 1441 | case GG_STATE_RESOLVING: | |
| 15884 | 1442 | purple_debug_info("gg", "GG_STATE_RESOLVING\n"); |
| 12007 | 1443 | break; |
| 1444 | case GG_STATE_CONNECTING_HUB: | |
| 15884 | 1445 | purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); |
| 12007 | 1446 | break; |
| 1447 | case GG_STATE_READING_DATA: | |
| 15884 | 1448 | purple_debug_info("gg", "GG_STATE_READING_DATA\n"); |
| 12007 | 1449 | break; |
| 1450 | case GG_STATE_CONNECTING_GG: | |
| 15884 | 1451 | purple_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); |
| 12007 | 1452 | break; |
| 1453 | case GG_STATE_READING_KEY: | |
| 15884 | 1454 | purple_debug_info("gg", "GG_STATE_READING_KEY\n"); |
| 12007 | 1455 | break; |
| 1456 | case GG_STATE_READING_REPLY: | |
| 15884 | 1457 | purple_debug_info("gg", "GG_STATE_READING_REPLY\n"); |
| 11414 | 1458 | break; |
| 1459 | default: | |
| 15884 | 1460 | purple_debug_error("gg", "unknown state = %d\n", |
| 12007 | 1461 | info->session->state); |
| 1462 | break; | |
| 1463 | } | |
| 1464 | ||
| 1465 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1466 | purple_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); |
| 21279 | 1467 | purple_connection_error_reason (gc, |
| 1468 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1469 | _("Unable to read socket")); |
| 12007 | 1470 | return; |
| 1471 | } | |
| 15884 | 1472 | purple_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); |
| 1473 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | |
| 12007 | 1474 | info->session->check, info->session->state); |
| 1475 | ||
| 15884 | 1476 | purple_input_remove(gc->inpa); |
| 12007 | 1477 | |
| 1478 | /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ | |
| 15884 | 1479 | gc->inpa = purple_input_add(info->session->fd, |
| 1480 | (info->session->check == 1) ? PURPLE_INPUT_WRITE | |
| 1481 | : PURPLE_INPUT_READ, | |
| 12007 | 1482 | ggp_async_login_handler, gc); |
| 1483 | ||
| 1484 | switch (ev->type) { | |
| 1485 | case GG_EVENT_NONE: | |
| 1486 | /* Nothing happened. */ | |
| 15884 | 1487 | purple_debug_info("gg", "GG_EVENT_NONE\n"); |
| 12007 | 1488 | break; |
| 1489 | case GG_EVENT_CONN_SUCCESS: | |
| 12964 | 1490 | { |
| 15884 | 1491 | PurpleAccount *account; |
| 1492 | PurplePresence *presence; | |
| 1493 | PurpleStatus *status; | |
| 12964 | 1494 | |
| 15884 | 1495 | purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); |
| 1496 | purple_input_remove(gc->inpa); | |
| 1497 | gc->inpa = purple_input_add(info->session->fd, | |
| 1498 | PURPLE_INPUT_READ, | |
| 12964 | 1499 | ggp_callback_recv, gc); |
| 12007 | 1500 | |
| 12964 | 1501 | /* gg_change_status(info->session, GG_STATUS_AVAIL); */ |
| 1502 | ||
| 15884 | 1503 | account = purple_connection_get_account(gc); |
| 1504 | presence = purple_account_get_presence(account); | |
| 1505 | status = purple_presence_get_active_status(presence); | |
| 12964 | 1506 | |
| 1507 | ggp_set_status(account, status); | |
| 15884 | 1508 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
| 12964 | 1509 | ggp_buddylist_send(gc); |
| 1510 | } | |
| 12007 | 1511 | break; |
| 1512 | case GG_EVENT_CONN_FAILED: | |
| 15884 | 1513 | purple_input_remove(gc->inpa); |
| 12007 | 1514 | gc->inpa = 0; |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1515 | purple_connection_error_reason (gc, |
| 21279 | 1516 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1517 | _("Connection failed.")); |
| 12007 | 1518 | break; |
| 1519 | default: | |
| 15884 | 1520 | purple_debug_error("gg", "strange event: %d\n", ev->type); |
| 11414 | 1521 | break; |
| 1522 | } | |
| 1523 | ||
| 1524 | gg_free_event(ev); | |
| 1525 | } | |
| 1526 | /* }}} */ | |
| 1527 | ||
| 1528 | /* ---------------------------------------------------------------------- */ | |
| 15884 | 1529 | /* ----- PurplePluginProtocolInfo ----------------------------------------- */ |
| 11360 | 1530 | /* ---------------------------------------------------------------------- */ |
| 1531 | ||
| 15884 | 1532 | /* static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) {{{ */ |
| 1533 | static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) | |
| 11360 | 1534 | { |
| 1535 | return "gadu-gadu"; | |
| 1536 | } | |
| 1537 | /* }}} */ | |
| 1538 | ||
| 15884 | 1539 | /* static char *ggp_status_text(PurpleBuddy *b) {{{ */ |
| 1540 | static char *ggp_status_text(PurpleBuddy *b) | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1541 | { |
| 15884 | 1542 | PurpleStatus *status; |
| 11360 | 1543 | const char *msg; |
| 1544 | char *text; | |
| 1545 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1546 | |
| 15884 | 1547 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1548 | |
| 15884 | 1549 | msg = purple_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1550 | |
| 11360 | 1551 | if (msg != NULL) { |
| 15884 | 1552 | tmp = purple_markup_strip_html(msg); |
| 11360 | 1553 | text = g_markup_escape_text(tmp, -1); |
| 1554 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1555 | |
| 11360 | 1556 | return text; |
| 1557 | } else { | |
| 15884 | 1558 | tmp = purple_utf8_salvage(purple_status_get_name(status)); |
| 11360 | 1559 | text = g_markup_escape_text(tmp, -1); |
| 1560 | g_free(tmp); | |
| 1561 | ||
| 1562 | return text; | |
| 8997 | 1563 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1564 | } |
| 11360 | 1565 | /* }}} */ |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1566 | |
| 15884 | 1567 | /* static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) {{{ */ |
| 1568 | static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) | |
| 11360 | 1569 | { |
| 15884 | 1570 | PurpleStatus *status; |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1571 | char *text, *tmp; |
| 11360 | 1572 | const char *msg, *name; |
| 1573 | ||
| 15005 | 1574 | g_return_if_fail(b != NULL); |
| 1575 | ||
| 15884 | 1576 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
| 1577 | msg = purple_status_get_attr_string(status, "message"); | |
| 1578 | name = purple_status_get_name(status); | |
| 11360 | 1579 | |
| 1580 | if (msg != NULL) { | |
| 13455 | 1581 | text = g_markup_escape_text(msg, -1); |
| 15884 | 1582 | if (PURPLE_BUDDY_IS_ONLINE(b)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1583 | tmp = g_strdup_printf("%s: %s", name, text); |
| 15884 | 1584 | purple_notify_user_info_add_pair(user_info, _("Status"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1585 | g_free(tmp); |
| 15196 | 1586 | } else { |
| 15884 | 1587 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15196 | 1588 | } |
| 11360 | 1589 | g_free(text); |
| 15227 | 1590 | /* We don't want to duplicate 'Status: Offline'. */ |
| 15884 | 1591 | } else if (PURPLE_BUDDY_IS_ONLINE(b)) { |
| 1592 | purple_notify_user_info_add_pair(user_info, _("Status"), name); | |
| 11360 | 1593 | } |
| 1594 | } | |
| 1595 | /* }}} */ | |
| 1596 | ||
| 15884 | 1597 | /* static GList *ggp_status_types(PurpleAccount *account) {{{ */ |
| 1598 | static GList *ggp_status_types(PurpleAccount *account) | |
| 11360 | 1599 | { |
| 15884 | 1600 | PurpleStatusType *type; |
| 11360 | 1601 | GList *types = NULL; |
| 1602 | ||
| 15884 | 1603 | type = purple_status_type_new_with_attrs( |
| 1604 | PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1605 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1606 | NULL); |
| 11360 | 1607 | types = g_list_append(types, type); |
| 1608 | ||
| 1609 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1610 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1611 | * work. It's not used and not needed to show status of buddies. |
| 1612 | */ | |
| 15884 | 1613 | type = purple_status_type_new_with_attrs( |
| 1614 | PURPLE_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1615 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1616 | NULL); |
| 11360 | 1617 | types = g_list_append(types, type); |
| 1618 | ||
| 15884 | 1619 | type = purple_status_type_new_with_attrs( |
| 1620 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1621 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1622 | NULL); |
| 11360 | 1623 | types = g_list_append(types, type); |
| 1624 | ||
| 12964 | 1625 | /* |
| 1626 | * This status is necessary to display guys who are blocking *us*. | |
| 1627 | */ | |
| 15884 | 1628 | type = purple_status_type_new_with_attrs( |
| 1629 | PURPLE_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, | |
| 1630 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); | |
| 11360 | 1631 | types = g_list_append(types, type); |
| 1632 | ||
| 15884 | 1633 | type = purple_status_type_new_with_attrs( |
| 1634 | PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1635 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1636 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1637 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1638 | |
| 11360 | 1639 | return types; |
| 1640 | } | |
| 1641 | /* }}} */ | |
| 1642 | ||
| 15884 | 1643 | /* static GList *ggp_blist_node_menu(PurpleBlistNode *node) {{{ */ |
| 1644 | static GList *ggp_blist_node_menu(PurpleBlistNode *node) | |
| 2393 | 1645 | { |
| 15884 | 1646 | PurpleMenuAction *act; |
| 2393 | 1647 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1648 | |
| 15884 | 1649 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
| 11360 | 1650 | return NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1651 | |
| 15884 | 1652 | act = purple_menu_action_new(_("Add to chat"), |
| 1653 | PURPLE_CALLBACK(ggp_bmenu_add_to_chat), | |
| 12919 | 1654 | NULL, NULL); |
| 11410 | 1655 | m = g_list_append(m, act); |
| 1656 | ||
| 12641 | 1657 | /* Using a blist node boolean here is also wrong. |
| 1658 | * Once the Block and Unblock actions are added to the core, | |
| 1659 | * this will have to go. -- rlaager */ | |
| 15884 | 1660 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 1661 | act = purple_menu_action_new(_("Unblock"), | |
| 1662 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1663 | NULL, NULL); |
| 12007 | 1664 | } else { |
| 15884 | 1665 | act = purple_menu_action_new(_("Block"), |
| 1666 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1667 | NULL, NULL); |
| 12007 | 1668 | } |
| 11394 | 1669 | m = g_list_append(m, act); |
| 2393 | 1670 | |
| 1671 | return m; | |
| 1672 | } | |
| 11360 | 1673 | /* }}} */ |
| 2393 | 1674 | |
| 15884 | 1675 | /* static GList *ggp_chat_info(PurpleConnection *gc) {{{ */ |
| 1676 | static GList *ggp_chat_info(PurpleConnection *gc) | |
| 11394 | 1677 | { |
| 1678 | GList *m = NULL; | |
| 1679 | struct proto_chat_entry *pce; | |
| 1680 | ||
| 1681 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1682 | pce->label = _("Chat _name:"); | |
| 1683 | pce->identifier = "name"; | |
| 1684 | pce->required = TRUE; | |
| 1685 | m = g_list_append(m, pce); | |
| 1686 | ||
| 1687 | return m; | |
| 1688 | } | |
| 1689 | /* }}} */ | |
| 1690 | ||
| 15884 | 1691 | /* static void ggp_login(PurpleAccount *account) {{{ */ |
| 1692 | static void ggp_login(PurpleAccount *account) | |
| 2393 | 1693 | { |
| 15884 | 1694 | PurpleConnection *gc; |
| 13515 | 1695 | struct gg_login_params *glp; |
| 1696 | GGPInfo *info; | |
| 1697 | ||
| 1698 | if (ggp_setup_proxy(account) == -1) | |
| 1699 | return; | |
| 1700 | ||
| 15884 | 1701 | gc = purple_account_get_connection(account); |
| 13515 | 1702 | glp = g_new0(struct gg_login_params, 1); |
| 1703 | info = g_new0(GGPInfo, 1); | |
| 11360 | 1704 | |
| 12007 | 1705 | /* Probably this should be moved to *_new() function. */ |
| 11360 | 1706 | info->session = NULL; |
| 11394 | 1707 | info->chats = NULL; |
| 1708 | info->chats_count = 0; | |
| 12007 | 1709 | info->token = NULL; |
| 13641 | 1710 | info->searches = ggp_search_new(); |
| 11360 | 1711 | |
| 1712 | gc->proto_data = info; | |
| 1713 | ||
| 1714 | glp->uin = ggp_get_uin(account); | |
| 15884 | 1715 | glp->password = (char *)purple_account_get_password(account); |
| 11360 | 1716 | |
| 12007 | 1717 | glp->async = 1; |
| 11360 | 1718 | glp->status = GG_STATUS_AVAIL; |
| 1719 | glp->tls = 0; | |
| 1720 | ||
| 1721 | info->session = gg_login(glp); | |
| 1722 | if (info->session == NULL) { | |
| 21279 | 1723 | purple_connection_error_reason (gc, |
| 1724 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
1725 | _("Connection failed.")); |
| 11360 | 1726 | g_free(glp); |
| 1727 | return; | |
| 1728 | } | |
| 15884 | 1729 | gc->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ, |
| 12007 | 1730 | ggp_async_login_handler, gc); |
| 11360 | 1731 | } |
| 1732 | /* }}} */ | |
| 1733 | ||
| 15884 | 1734 | /* static void ggp_close(PurpleConnection *gc) {{{ */ |
| 1735 | static void ggp_close(PurpleConnection *gc) | |
| 11360 | 1736 | { |
| 8997 | 1737 | |
| 11360 | 1738 | if (gc == NULL) { |
| 15884 | 1739 | purple_debug_info("gg", "gc == NULL\n"); |
| 11360 | 1740 | return; |
| 1741 | } | |
| 1742 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1743 | if (gc->proto_data) { |
| 15884 | 1744 | PurpleAccount *account = purple_connection_get_account(gc); |
| 1745 | PurpleStatus *status; | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1746 | GGPInfo *info = gc->proto_data; |
| 12964 | 1747 | |
| 15884 | 1748 | status = purple_account_get_active_status(account); |
| 12964 | 1749 | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1750 | if (info->session != NULL) { |
| 12964 | 1751 | ggp_set_status(account, status); |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1752 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1753 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1754 | } |
| 13641 | 1755 | |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1756 | /* Immediately close any notifications on this handle since that process depends |
|
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1757 | * upon the contents of info->searches, which we are about to destroy. |
|
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1758 | */ |
| 15884 | 1759 | purple_notify_close_with_handle(gc); |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1760 | |
| 13641 | 1761 | ggp_search_destroy(info->searches); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1762 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1763 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1764 | } |
| 11360 | 1765 | |
| 1766 | if (gc->inpa > 0) | |
| 15884 | 1767 | purple_input_remove(gc->inpa); |
| 11360 | 1768 | |
| 1769 | ggp_buddylist_offline(gc); | |
| 2393 | 1770 | |
| 15884 | 1771 | purple_debug_info("gg", "Connection closed.\n"); |
| 11360 | 1772 | } |
| 1773 | /* }}} */ | |
| 1774 | ||
| 15884 | 1775 | /* static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, PurpleMessageFlags flags) {{{ */ |
| 1776 | static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, | |
| 1777 | PurpleMessageFlags flags) | |
| 11360 | 1778 | { |
| 1779 | GGPInfo *info = gc->proto_data; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1780 | char *tmp, *plain; |
| 15287 | 1781 | int ret = 0; |
| 11360 | 1782 | |
| 15287 | 1783 | if (strlen(msg) == 0) { |
| 1784 | return 0; | |
| 1785 | } | |
| 1786 | ||
| 15884 | 1787 | purple_debug_info("gg", "ggp_send_im: msg = %s\n", msg); |
| 1788 | plain = purple_unescape_html(msg); | |
| 15287 | 1789 | tmp = charset_convert(plain, "UTF-8", "CP1250"); |
| 11360 | 1790 | |
| 15287 | 1791 | if (NULL == tmp || strlen(tmp) == 0) { |
| 1792 | ret = 0; | |
| 1793 | } else if (strlen(tmp) > GG_MSG_MAXSIZE) { | |
| 1794 | ret = -E2BIG; | |
| 1795 | } else if (gg_send_message(info->session, GG_CLASS_CHAT, | |
| 1796 | ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { | |
| 1797 | ret = -1; | |
| 1798 | } else { | |
| 1799 | ret = 1; | |
| 1800 | } | |
| 1801 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1802 | g_free(plain); |
| 11565 | 1803 | g_free(tmp); |
| 11360 | 1804 | |
| 15287 | 1805 | return ret; |
| 11360 | 1806 | } |
| 1807 | /* }}} */ | |
| 1808 | ||
| 15884 | 1809 | /* static void ggp_get_info(PurpleConnection *gc, const char *name) { {{{ */ |
| 1810 | static void ggp_get_info(PurpleConnection *gc, const char *name) | |
| 11360 | 1811 | { |
| 1812 | GGPInfo *info = gc->proto_data; | |
| 1813 | GGPSearchForm *form; | |
| 13641 | 1814 | guint32 seq; |
| 2393 | 1815 | |
| 13641 | 1816 | form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); |
| 12220 | 1817 | |
| 13641 | 1818 | form->user_data = info; |
| 11360 | 1819 | form->uin = g_strdup(name); |
| 1820 | form->offset = g_strdup("0"); | |
| 1821 | form->last_uin = g_strdup("0"); | |
| 1822 | ||
| 13641 | 1823 | seq = ggp_search_start(gc, form); |
| 1824 | ggp_search_add(info->searches, seq, form); | |
| 11360 | 1825 | } |
| 1826 | /* }}} */ | |
| 1827 | ||
| 15884 | 1828 | /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */ |
| 1829 | static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) | |
| 11360 | 1830 | { |
| 15884 | 1831 | PurpleConnection *gc; |
| 11360 | 1832 | GGPInfo *info; |
|
11397
5347ffe54c17
[gaim-migrate @ 13629]
Mark Doliner <markdoliner@pidgin.im>
parents:
11394
diff
changeset
|
1833 | const char *status_id, *msg; |
| 11360 | 1834 | int new_status, new_status_descr; |
| 1835 | ||
| 15884 | 1836 | if (!purple_status_is_active(status)) |
| 11360 | 1837 | return; |
| 1838 | ||
| 15884 | 1839 | gc = purple_account_get_connection(account); |
| 11360 | 1840 | info = gc->proto_data; |
| 1841 | ||
| 15884 | 1842 | status_id = purple_status_get_id(status); |
| 11360 | 1843 | |
| 15884 | 1844 | purple_debug_info("gg", "ggp_set_status: Requested status = %s\n", |
| 12007 | 1845 | status_id); |
| 2393 | 1846 | |
| 11360 | 1847 | if (strcmp(status_id, "available") == 0) { |
| 1848 | new_status = GG_STATUS_AVAIL; | |
| 1849 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1850 | } else if (strcmp(status_id, "away") == 0) { | |
| 1851 | new_status = GG_STATUS_BUSY; | |
| 1852 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1853 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1854 | new_status = GG_STATUS_INVISIBLE; | |
| 1855 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 12964 | 1856 | } else if (strcmp(status_id, "offline") == 0) { |
| 1857 | new_status = GG_STATUS_NOT_AVAIL; | |
| 1858 | new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; | |
| 11360 | 1859 | } else { |
| 1860 | new_status = GG_STATUS_AVAIL; | |
| 1861 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 15884 | 1862 | purple_debug_info("gg", |
| 12007 | 1863 | "ggp_set_status: uknown status requested (status_id=%s)\n", |
| 1864 | status_id); | |
| 11360 | 1865 | } |
| 4916 | 1866 | |
| 15884 | 1867 | msg = purple_status_get_attr_string(status, "message"); |
| 11360 | 1868 | |
| 1869 | if (msg == NULL) { | |
| 1870 | gg_change_status(info->session, new_status); | |
| 1871 | } else { | |
| 12964 | 1872 | gchar *tmp, *new_msg; |
| 1873 | ||
| 13455 | 1874 | tmp = charset_convert(msg, "UTF-8", "CP1250"); |
| 15884 | 1875 | new_msg = purple_markup_strip_html(tmp); |
| 12964 | 1876 | g_free(tmp); |
| 1877 | ||
| 13455 | 1878 | gg_change_status_descr(info->session, new_status_descr, new_msg); |
| 12964 | 1879 | g_free(new_msg); |
| 11360 | 1880 | } |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1881 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1882 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1883 | |
| 11360 | 1884 | } |
| 1885 | /* }}} */ | |
| 1886 | ||
| 15884 | 1887 | /* static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {{{ */ |
| 1888 | static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | |
| 11360 | 1889 | { |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1890 | PurpleAccount *account; |
| 11360 | 1891 | GGPInfo *info = gc->proto_data; |
| 1892 | ||
| 1893 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1894 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1895 | account = purple_connection_get_account(gc); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1896 | if (strcmp(purple_account_get_username(account), buddy->name) == 0) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1897 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
1898 | } |
| 11360 | 1899 | } |
| 1900 | /* }}} */ | |
| 1901 | ||
| 15884 | 1902 | /* static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {{{ */ |
| 1903 | static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, | |
| 1904 | PurpleGroup *group) | |
| 11360 | 1905 | { |
| 1906 | GGPInfo *info = gc->proto_data; | |
| 1907 | ||
| 1908 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 1909 | } | |
| 1910 | /* }}} */ | |
| 1911 | ||
| 15884 | 1912 | /* static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) {{{ */ |
| 1913 | static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) | |
| 11394 | 1914 | { |
| 1915 | GGPInfo *info = gc->proto_data; | |
| 1916 | GGPChat *chat; | |
| 1917 | char *chat_name; | |
| 1918 | GList *l; | |
| 15884 | 1919 | PurpleConversation *conv; |
| 1920 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 11394 | 1921 | |
| 1922 | chat_name = g_hash_table_lookup(data, "name"); | |
| 1923 | ||
| 1924 | if (chat_name == NULL) | |
| 1925 | return; | |
| 1926 | ||
| 15884 | 1927 | purple_debug_info("gg", "joined %s chat\n", chat_name); |
| 11394 | 1928 | |
| 1929 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1930 | chat = l->data; | |
| 1931 | ||
| 1932 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 15884 | 1933 | purple_notify_error(gc, _("Chat error"), |
| 12007 | 1934 | _("This chat name is already in use"), NULL); |
| 11394 | 1935 | return; |
| 1936 | } | |
| 1937 | } | |
| 1938 | ||
| 11414 | 1939 | ggp_confer_add_new(gc, chat_name); |
| 12961 | 1940 | conv = serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 15884 | 1941 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(conv), |
| 1942 | purple_account_get_username(account), NULL, | |
| 1943 | PURPLE_CBFLAGS_NONE, TRUE); | |
| 11394 | 1944 | } |
| 1945 | /* }}} */ | |
| 1946 | ||
| 1947 | /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | |
| 1948 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 1949 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 1950 | } | |
| 1951 | /* }}} */ | |
| 1952 | ||
| 15884 | 1953 | /* static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) {{{ */ |
| 1954 | static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) | |
| 11394 | 1955 | { |
| 15884 | 1956 | PurpleConversation *conv; |
| 11394 | 1957 | GGPInfo *info = gc->proto_data; |
| 1958 | GGPChat *chat = NULL; | |
| 1959 | GList *l; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1960 | char *msg, *plain; |
| 11394 | 1961 | uin_t *uins; |
| 1962 | int count = 0; | |
| 1963 | ||
| 15884 | 1964 | if ((conv = purple_find_chat(gc, id)) == NULL) |
| 11394 | 1965 | return -EINVAL; |
| 1966 | ||
| 1967 | for (l = info->chats; l != NULL; l = l->next) { | |
| 1968 | chat = l->data; | |
| 1969 | ||
| 1970 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 1971 | break; | |
| 1972 | } | |
| 1973 | ||
| 1974 | chat = NULL; | |
| 1975 | } | |
| 1976 | ||
| 1977 | if (chat == NULL) { | |
| 15884 | 1978 | purple_debug_error("gg", |
| 12007 | 1979 | "ggp_chat_send: Hm... that's strange. No such chat?\n"); |
| 11394 | 1980 | return -EINVAL; |
| 1981 | } | |
| 1982 | ||
| 1983 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 12961 | 1984 | |
| 11394 | 1985 | for (l = chat->participants; l != NULL; l = l->next) { |
| 12961 | 1986 | uin_t uin = GPOINTER_TO_INT(l->data); |
| 11394 | 1987 | |
| 12961 | 1988 | uins[count++] = uin; |
| 11394 | 1989 | } |
| 1990 | ||
| 15884 | 1991 | plain = purple_unescape_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1992 | msg = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1993 | g_free(plain); |
| 12007 | 1994 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
| 12961 | 1995 | (unsigned char *)msg); |
| 11394 | 1996 | g_free(msg); |
| 1997 | g_free(uins); | |
| 1998 | ||
| 12007 | 1999 | serv_got_chat_in(gc, id, |
| 15884 | 2000 | purple_account_get_username(purple_connection_get_account(gc)), |
| 12007 | 2001 | 0, message, time(NULL)); |
| 11394 | 2002 | |
| 2003 | return 0; | |
| 2004 | } | |
| 2005 | /* }}} */ | |
| 2006 | ||
| 15884 | 2007 | /* static void ggp_keepalive(PurpleConnection *gc) {{{ */ |
| 2008 | static void ggp_keepalive(PurpleConnection *gc) | |
| 11360 | 2009 | { |
| 2010 | GGPInfo *info = gc->proto_data; | |
| 2011 | ||
| 15884 | 2012 | /* purple_debug_info("gg", "Keeping connection alive....\n"); */ |
| 11360 | 2013 | |
| 2014 | if (gg_ping(info->session) < 0) { | |
| 15884 | 2015 | purple_debug_info("gg", "Not connected to the server " |
| 11360 | 2016 | "or gg_session is not correct\n"); |
| 21279 | 2017 | purple_connection_error_reason (gc, |
| 2018 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20437
6596f4984a50
Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
Will Thompson <resiak@pidgin.im>
parents:
19897
diff
changeset
|
2019 | _("Not connected to the server.")); |
| 4916 | 2020 | } |
| 2393 | 2021 | } |
| 11360 | 2022 | /* }}} */ |
| 2023 | ||
| 15884 | 2024 | /* static void ggp_register_user(PurpleAccount *account) {{{ */ |
| 2025 | static void ggp_register_user(PurpleAccount *account) | |
| 11360 | 2026 | { |
| 15884 | 2027 | PurpleConnection *gc = purple_account_get_connection(account); |
| 11360 | 2028 | GGPInfo *info; |
| 2029 | ||
| 12007 | 2030 | info = gc->proto_data = g_new0(GGPInfo, 1); |
| 11360 | 2031 | |
| 12007 | 2032 | ggp_token_request(gc, ggp_register_user_dialog); |
| 2393 | 2033 | } |
| 11360 | 2034 | /* }}} */ |
| 2393 | 2035 | |
| 15884 | 2036 | /* static GList *ggp_actions(PurplePlugin *plugin, gpointer context) {{{ */ |
| 2037 | static GList *ggp_actions(PurplePlugin *plugin, gpointer context) | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2038 | { |
| 11360 | 2039 | GList *m = NULL; |
| 15884 | 2040 | PurplePluginAction *act; |
| 11360 | 2041 | |
| 15884 | 2042 | act = purple_plugin_action_new(_("Find buddies..."), |
| 12007 | 2043 | ggp_find_buddies); |
| 11360 | 2044 | m = g_list_append(m, act); |
| 2045 | ||
| 2046 | m = g_list_append(m, NULL); | |
| 2047 | ||
| 15884 | 2048 | act = purple_plugin_action_new(_("Change password..."), |
| 12007 | 2049 | ggp_change_passwd); |
| 11360 | 2050 | m = g_list_append(m, act); |
| 2051 | ||
| 2052 | m = g_list_append(m, NULL); | |
| 2053 | ||
| 15884 | 2054 | act = purple_plugin_action_new(_("Upload buddylist to Server"), |
| 12007 | 2055 | ggp_action_buddylist_put); |
| 11360 | 2056 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2057 | |
| 15884 | 2058 | act = purple_plugin_action_new(_("Download buddylist from Server"), |
| 12007 | 2059 | ggp_action_buddylist_get); |
| 11360 | 2060 | m = g_list_append(m, act); |
| 2061 | ||
| 15884 | 2062 | act = purple_plugin_action_new(_("Delete buddylist from Server"), |
| 12007 | 2063 | ggp_action_buddylist_delete); |
| 11360 | 2064 | m = g_list_append(m, act); |
| 2065 | ||
| 15884 | 2066 | act = purple_plugin_action_new(_("Save buddylist to file..."), |
| 12007 | 2067 | ggp_action_buddylist_save); |
| 11360 | 2068 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2069 | |
| 15884 | 2070 | act = purple_plugin_action_new(_("Load buddylist from file..."), |
| 12007 | 2071 | ggp_action_buddylist_load); |
| 11360 | 2072 | m = g_list_append(m, act); |
| 2073 | ||
| 2074 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2075 | } |
| 11360 | 2076 | /* }}} */ |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2077 | |
| 15884 | 2078 | /* static gboolean ggp_offline_message(const PurpleBuddy *buddy) {{{ */ |
| 2079 | static gboolean ggp_offline_message(const PurpleBuddy *buddy) | |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2080 | { |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2081 | return TRUE; |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2082 | } |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2083 | /* }}} */ |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2084 | |
| 11360 | 2085 | /* prpl_info setup {{{ */ |
| 15884 | 2086 | static PurplePluginProtocolInfo prpl_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2087 | { |
| 11360 | 2088 | OPT_PROTO_REGISTER_NOSCREENNAME, |
| 12007 | 2089 | NULL, /* user_splits */ |
| 2090 | NULL, /* protocol_options */ | |
|
22546
3f7e366741a3
Patch from Tomasz Salacinski to allow setting buddy icons in GG prpl.
Bartosz Oler <bartosz@pidgin.im>
parents:
22277
diff
changeset
|
2091 | {"png", 32, 32, 96, 96, 0, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ |
| 11360 | 2092 | ggp_list_icon, /* list_icon */ |
| 15524 | 2093 | NULL, /* list_emblem */ |
| 11360 | 2094 | ggp_status_text, /* status_text */ |
| 2095 | ggp_tooltip_text, /* tooltip_text */ | |
| 2096 | ggp_status_types, /* status_types */ | |
| 12007 | 2097 | ggp_blist_node_menu, /* blist_node_menu */ |
| 11394 | 2098 | ggp_chat_info, /* chat_info */ |
| 12007 | 2099 | NULL, /* chat_info_defaults */ |
| 2100 | ggp_login, /* login */ | |
| 2101 | ggp_close, /* close */ | |
| 11360 | 2102 | ggp_send_im, /* send_im */ |
| 12007 | 2103 | NULL, /* set_info */ |
| 2104 | NULL, /* send_typing */ | |
| 11360 | 2105 | ggp_get_info, /* get_info */ |
| 2106 | ggp_set_status, /* set_away */ | |
| 12007 | 2107 | NULL, /* set_idle */ |
| 2108 | NULL, /* change_passwd */ | |
| 11360 | 2109 | ggp_add_buddy, /* add_buddy */ |
| 12007 | 2110 | NULL, /* add_buddies */ |
| 11360 | 2111 | ggp_remove_buddy, /* remove_buddy */ |
| 12007 | 2112 | NULL, /* remove_buddies */ |
| 2113 | NULL, /* add_permit */ | |
| 2114 | NULL, /* add_deny */ | |
| 2115 | NULL, /* rem_permit */ | |
| 2116 | NULL, /* rem_deny */ | |
| 2117 | NULL, /* set_permit_deny */ | |
| 11394 | 2118 | ggp_join_chat, /* join_chat */ |
| 12007 | 2119 | NULL, /* reject_chat */ |
| 11394 | 2120 | ggp_get_chat_name, /* get_chat_name */ |
| 12007 | 2121 | NULL, /* chat_invite */ |
| 2122 | NULL, /* chat_leave */ | |
| 2123 | NULL, /* chat_whisper */ | |
| 11394 | 2124 | ggp_chat_send, /* chat_send */ |
| 11360 | 2125 | ggp_keepalive, /* keepalive */ |
| 2126 | ggp_register_user, /* register_user */ | |
| 12007 | 2127 | NULL, /* get_cb_info */ |
| 2128 | NULL, /* get_cb_away */ | |
| 2129 | NULL, /* alias_buddy */ | |
| 2130 | NULL, /* group_buddy */ | |
| 2131 | NULL, /* rename_group */ | |
| 2132 | NULL, /* buddy_free */ | |
| 2133 | NULL, /* convo_closed */ | |
| 2134 | NULL, /* normalize */ | |
| 2135 | NULL, /* set_buddy_icon */ | |
| 2136 | NULL, /* remove_group */ | |
| 2137 | NULL, /* get_cb_real_name */ | |
| 2138 | NULL, /* set_chat_topic */ | |
| 2139 | NULL, /* find_blist_chat */ | |
| 2140 | NULL, /* roomlist_get_list */ | |
| 2141 | NULL, /* roomlist_cancel */ | |
| 2142 | NULL, /* roomlist_expand_category */ | |
| 2143 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12007
diff
changeset
|
2144 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2145 | NULL, /* new_xfer */ |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2146 | ggp_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2147 | NULL, /* whiteboard_prpl_ops */ |
| 14604 | 2148 | NULL, /* send_raw */ |
| 15185 | 2149 | NULL, /* roomlist_room_serialize */ |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2150 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2151 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2152 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2153 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2154 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2155 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2156 | }; |
| 11360 | 2157 | /* }}} */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2158 | |
| 15884 | 2159 | /* PurplePluginInfo setup {{{ */ |
| 2160 | static PurplePluginInfo info = { | |
| 2161 | PURPLE_PLUGIN_MAGIC, /* magic */ | |
| 2162 | PURPLE_MAJOR_VERSION, /* major_version */ | |
| 2163 | PURPLE_MINOR_VERSION, /* minor_version */ | |
| 2164 | PURPLE_PLUGIN_PROTOCOL, /* plugin type */ | |
| 11360 | 2165 | NULL, /* ui_requirement */ |
| 2166 | 0, /* flags */ | |
| 2167 | NULL, /* dependencies */ | |
| 15884 | 2168 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
| 11360 | 2169 | |
| 2170 | "prpl-gg", /* id */ | |
| 2171 | "Gadu-Gadu", /* name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19897
diff
changeset
|
2172 | DISPLAY_VERSION, /* version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2173 | |
| 11360 | 2174 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 2175 | N_("Polish popular IM"), /* description */ | |
| 2176 | "boler@sourceforge.net", /* author */ | |
| 15884 | 2177 | PURPLE_WEBSITE, /* homepage */ |
| 11360 | 2178 | |
| 2179 | NULL, /* load */ | |
| 2180 | NULL, /* unload */ | |
| 2181 | NULL, /* destroy */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2182 | |
| 11360 | 2183 | NULL, /* ui_info */ |
| 2184 | &prpl_info, /* extra_info */ | |
| 2185 | NULL, /* prefs_info */ | |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2186 | ggp_actions, /* actions */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2187 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2188 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2189 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2190 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2191 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2192 | NULL |
| 11360 | 2193 | }; |
| 2194 | /* }}} */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2195 | |
| 15884 | 2196 | /* static void purple_gg_debug_handler(int level, const char * format, va_list args) {{{ */ |
| 2197 | static void purple_gg_debug_handler(int level, const char * format, va_list args) { | |
| 2198 | PurpleDebugLevel purple_level; | |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2199 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2200 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2201 | /* This is pretty pointless since the GG_DEBUG levels don't correspond to |
| 15884 | 2202 | * the purple ones */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2203 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2204 | case GG_DEBUG_FUNCTION: |
| 15884 | 2205 | purple_level = PURPLE_DEBUG_INFO; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2206 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2207 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2208 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2209 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2210 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2211 | default: |
| 15884 | 2212 | purple_level = PURPLE_DEBUG_MISC; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2213 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2214 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2215 | |
| 15884 | 2216 | purple_debug(purple_level, "gg", msg); |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2217 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2218 | } |
| 11565 | 2219 | /* }}} */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2220 | |
| 11360 | 2221 | /* |
| 2222 | */ | |
| 15884 | 2223 | /* static void init_plugin(PurplePlugin *plugin) {{{ */ |
| 2224 | static void init_plugin(PurplePlugin *plugin) | |
| 2393 | 2225 | { |
| 15884 | 2226 | PurpleAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2227 | |
| 15884 | 2228 | option = purple_account_option_string_new(_("Nickname"), |
| 12007 | 2229 | "nick", _("Gadu-Gadu User")); |
| 2230 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2231 | option); | |
| 3572 | 2232 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2233 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2234 | |
| 15884 | 2235 | gg_debug_handler = purple_gg_debug_handler; |
| 2393 | 2236 | } |
| 11360 | 2237 | /* }}} */ |
| 2393 | 2238 | |
| 15884 | 2239 | PURPLE_INIT_PLUGIN(gg, init_plugin, info); |
| 11360 | 2240 | |
| 12007 | 2241 | /* vim: set ts=8 sts=0 sw=8 noet: */ |