Wed, 28 Apr 2010 22:13:51 +0000
gadu-gadu: Fix a crash due to uninitialized data. Closes #11746.
This is a different fix, based on feedback on the libgadu mailing list.
"It's a feature, not a bug. You're supposed to iterate through the array
until there's uin == 0."
| 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> |
|
27388
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
10 | * Some parts Copyright (C) 2009 Krzysztof Klinikowski <grommasher@gmail.com> |
| 11394 | 11 | * |
| 12 | * Thanks to Google's Summer of Code Program. | |
| 13 | * | |
| 14 | * This program is free software; you can redistribute it and/or modify | |
| 15 | * it under the terms of the GNU General Public License as published by | |
| 16 | * the Free Software Foundation; either version 2 of the License, or | |
| 17 | * (at your option) any later version. | |
| 18 | * | |
| 19 | * This program is distributed in the hope that it will be useful, | |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 22 | * GNU General Public License for more details. | |
| 23 | * | |
| 24 | * You should have received a copy of the GNU General Public License | |
| 25 | * 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
|
26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11394 | 27 | */ |
| 28 | ||
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
29 | #include "internal.h" |
| 2393 | 30 | |
| 11360 | 31 | #include "plugin.h" |
| 32 | #include "version.h" | |
| 33 | #include "notify.h" | |
| 34 | #include "status.h" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
35 | #include "blist.h" |
| 11360 | 36 | #include "accountopt.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
37 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
38 | #include "util.h" |
| 11360 | 39 | #include "request.h" |
|
27388
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
40 | #include "xmlnode.h" |
| 2393 | 41 | |
| 13318 | 42 | #include <libgadu.h> |
| 5603 | 43 | |
| 11414 | 44 | #include "gg.h" |
| 45 | #include "confer.h" | |
| 46 | #include "search.h" | |
| 47 | #include "buddylist.h" | |
|
13627
44233a1064f9
[gaim-migrate @ 16013]
Evan Schoenberg <evands@pidgin.im>
parents:
13573
diff
changeset
|
48 | #include "gg-utils.h" |
| 11394 | 49 | |
| 15884 | 50 | static PurplePlugin *my_protocol = NULL; |
| 11394 | 51 | |
| 11360 | 52 | /* ---------------------------------------------------------------------- */ |
| 11414 | 53 | /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ |
| 11360 | 54 | /* ---------------------------------------------------------------------- */ |
| 9950 | 55 | |
| 12007 | 56 | |
| 57 | /* ----- HELPERS -------------------------------------------------------- */ | |
| 58 | ||
| 13515 | 59 | /** |
| 60 | * Set up libgadu's proxy. | |
| 61 | * | |
| 62 | * @param account Account for which to set up the proxy. | |
| 63 | * | |
| 64 | * @return Zero if proxy setup is valid, otherwise -1. | |
| 65 | */ | |
| 15884 | 66 | static int ggp_setup_proxy(PurpleAccount *account) |
| 13515 | 67 | { |
| 15884 | 68 | PurpleProxyInfo *gpi; |
| 13515 | 69 | |
| 15884 | 70 | gpi = purple_proxy_get_setup(account); |
| 13515 | 71 | |
| 15884 | 72 | if ((purple_proxy_info_get_type(gpi) != PURPLE_PROXY_NONE) && |
| 73 | (purple_proxy_info_get_host(gpi) == NULL || | |
| 74 | purple_proxy_info_get_port(gpi) <= 0)) { | |
| 13515 | 75 | |
| 76 | gg_proxy_enabled = 0; | |
| 15884 | 77 | purple_notify_error(NULL, NULL, _("Invalid proxy settings"), |
| 13515 | 78 | _("Either the host name or port number specified for your given proxy type is invalid.")); |
| 79 | return -1; | |
| 15884 | 80 | } else if (purple_proxy_info_get_type(gpi) != PURPLE_PROXY_NONE) { |
| 13515 | 81 | gg_proxy_enabled = 1; |
| 15884 | 82 | gg_proxy_host = g_strdup(purple_proxy_info_get_host(gpi)); |
| 83 | gg_proxy_port = purple_proxy_info_get_port(gpi); | |
| 84 | gg_proxy_username = g_strdup(purple_proxy_info_get_username(gpi)); | |
| 85 | gg_proxy_password = g_strdup(purple_proxy_info_get_password(gpi)); | |
| 13515 | 86 | } else { |
| 87 | gg_proxy_enabled = 0; | |
| 88 | } | |
| 89 | ||
| 90 | return 0; | |
| 91 | } | |
| 92 | ||
| 15884 | 93 | static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) |
| 12007 | 94 | { |
| 15884 | 95 | PurpleConnection *gc = _gc; |
| 12007 | 96 | GGPInfo *info = gc->proto_data; |
| 97 | GGPToken *token = info->token; | |
| 98 | GGPTokenCallback cb; | |
| 99 | ||
| 100 | struct gg_token *t = NULL; | |
| 101 | ||
| 15884 | 102 | purple_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n", |
| 12007 | 103 | token->req->check, token->req->state); |
| 104 | ||
| 105 | if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) { | |
| 15884 | 106 | purple_debug_error("gg", "token error (1): %d\n", token->req->error); |
| 107 | purple_input_remove(token->inpa); | |
| 12007 | 108 | gg_token_free(token->req); |
| 109 | token->req = NULL; | |
| 110 | ||
| 15884 | 111 | purple_notify_error(purple_connection_get_account(gc), |
| 12007 | 112 | _("Token Error"), |
| 113 | _("Unable to fetch the token.\n"), NULL); | |
| 114 | return; | |
| 115 | } | |
| 116 | ||
| 117 | if (token->req->state != GG_STATE_DONE) { | |
| 15884 | 118 | purple_input_remove(token->inpa); |
| 119 | token->inpa = purple_input_add(token->req->fd, | |
| 12007 | 120 | (token->req->check == 1) |
| 15884 | 121 | ? PURPLE_INPUT_WRITE |
| 122 | : PURPLE_INPUT_READ, | |
| 12007 | 123 | ggp_async_token_handler, gc); |
| 124 | return; | |
| 125 | } | |
| 126 | ||
| 127 | if (!(t = token->req->data) || !token->req->body) { | |
| 15884 | 128 | purple_debug_error("gg", "token error (2): %d\n", token->req->error); |
| 129 | purple_input_remove(token->inpa); | |
| 12007 | 130 | gg_token_free(token->req); |
| 131 | token->req = NULL; | |
| 132 | ||
| 15884 | 133 | purple_notify_error(purple_connection_get_account(gc), |
| 12007 | 134 | _("Token Error"), |
| 135 | _("Unable to fetch the token.\n"), NULL); | |
| 136 | return; | |
| 137 | } | |
| 138 | ||
| 15884 | 139 | purple_input_remove(token->inpa); |
| 12007 | 140 | |
| 141 | token->id = g_strdup(t->tokenid); | |
| 142 | token->size = token->req->body_size; | |
| 143 | token->data = g_new0(char, token->size); | |
| 144 | memcpy(token->data, token->req->body, token->size); | |
| 145 | ||
| 15884 | 146 | purple_debug_info("gg", "TOKEN! tokenid = %s; size = %d\n", |
| 12007 | 147 | token->id, token->size); |
| 148 | ||
| 149 | gg_token_free(token->req); | |
| 150 | token->req = NULL; | |
| 151 | token->inpa = 0; | |
| 152 | ||
| 153 | cb = token->cb; | |
| 154 | token->cb = NULL; | |
| 155 | cb(gc); | |
| 156 | } | |
| 157 | ||
| 15884 | 158 | static void ggp_token_request(PurpleConnection *gc, GGPTokenCallback cb) |
| 12007 | 159 | { |
| 15884 | 160 | PurpleAccount *account; |
| 12007 | 161 | struct gg_http *req; |
| 13515 | 162 | GGPInfo *info; |
| 163 | ||
| 15884 | 164 | account = purple_connection_get_account(gc); |
| 13515 | 165 | |
| 166 | if (ggp_setup_proxy(account) == -1) | |
| 167 | return; | |
| 168 | ||
| 169 | info = gc->proto_data; | |
| 12007 | 170 | |
| 171 | if ((req = gg_token(1)) == NULL) { | |
| 15884 | 172 | purple_notify_error(account, |
| 12007 | 173 | _("Token Error"), |
| 174 | _("Unable to fetch the token.\n"), NULL); | |
| 175 | return; | |
| 176 | } | |
| 177 | ||
| 178 | info->token = g_new(GGPToken, 1); | |
| 179 | info->token->cb = cb; | |
| 180 | ||
| 181 | info->token->req = req; | |
| 15884 | 182 | info->token->inpa = purple_input_add(req->fd, PURPLE_INPUT_READ, |
| 12007 | 183 | ggp_async_token_handler, gc); |
| 184 | } | |
| 185 | /* }}} */ | |
| 186 | ||
| 187 | /* ---------------------------------------------------------------------- */ | |
| 188 | ||
| 11360 | 189 | /** |
| 190 | * Request buddylist from the server. | |
| 191 | * Buddylist is received in the ggp_callback_recv(). | |
| 192 | * | |
| 193 | * @param Current action handler. | |
| 194 | */ | |
| 15884 | 195 | static void ggp_action_buddylist_get(PurplePluginAction *action) |
| 11360 | 196 | { |
| 15884 | 197 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 198 | GGPInfo *info = gc->proto_data; |
| 199 | ||
| 15884 | 200 | purple_debug_info("gg", "Downloading...\n"); |
| 11360 | 201 | |
| 202 | gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | |
| 203 | } | |
| 204 | ||
| 205 | /** | |
| 206 | * Upload the buddylist to the server. | |
| 207 | * | |
| 208 | * @param action Current action handler. | |
| 209 | */ | |
| 15884 | 210 | static void ggp_action_buddylist_put(PurplePluginAction *action) |
| 11360 | 211 | { |
| 15884 | 212 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 213 | GGPInfo *info = gc->proto_data; |
| 214 | ||
| 15884 | 215 | char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc)); |
| 11360 | 216 | |
| 15884 | 217 | purple_debug_info("gg", "Uploading...\n"); |
| 11360 | 218 | |
| 219 | if (buddylist == NULL) | |
| 220 | return; | |
| 221 | ||
| 222 | gg_userlist_request(info->session, GG_USERLIST_PUT, buddylist); | |
| 223 | g_free(buddylist); | |
| 224 | } | |
| 225 | ||
| 226 | /** | |
| 227 | * Delete buddylist from the server. | |
| 228 | * | |
| 229 | * @param action Current action handler. | |
| 230 | */ | |
| 15884 | 231 | static void ggp_action_buddylist_delete(PurplePluginAction *action) |
| 11360 | 232 | { |
| 15884 | 233 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 234 | GGPInfo *info = gc->proto_data; |
| 235 | ||
| 15884 | 236 | purple_debug_info("gg", "Deleting...\n"); |
| 11360 | 237 | |
| 238 | gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | |
| 239 | } | |
| 240 | ||
|
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
|
241 | static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *filename) |
| 11360 | 242 | { |
| 15884 | 243 | PurpleAccount *account = purple_connection_get_account(gc); |
| 11360 | 244 | |
| 245 | char *buddylist = ggp_buddylist_dump(account); | |
| 246 | ||
| 15884 | 247 | 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
|
248 | purple_debug_info("gg", "file = %s\n", filename); |
| 11360 | 249 | |
| 250 | if (buddylist == NULL) { | |
| 15884 | 251 | purple_notify_info(account, _("Save Buddylist..."), |
| 12007 | 252 | _("Your buddylist is empty, nothing was written to the file."), |
| 253 | NULL); | |
|
2792
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
254 | return; |
|
f40db99e87c7
[gaim-migrate @ 2805]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2791
diff
changeset
|
255 | } |
| 2393 | 256 | |
|
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 | 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
|
258 | 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
|
259 | _("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
|
260 | } 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
|
261 | 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
|
262 | _("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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | g_free(primary); |
| 11360 | 267 | } |
| 268 | ||
| 269 | g_free(buddylist); | |
| 270 | } | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
271 | |
| 15884 | 272 | static void ggp_callback_buddylist_load_ok(PurpleConnection *gc, gchar *file) |
| 11360 | 273 | { |
| 15884 | 274 | PurpleAccount *account = purple_connection_get_account(gc); |
| 12007 | 275 | GError *error = NULL; |
| 276 | char *buddylist = NULL; | |
| 277 | gsize length; | |
| 11360 | 278 | |
| 15884 | 279 | purple_debug_info("gg", "file_name = %s\n", file); |
| 11360 | 280 | |
| 12007 | 281 | if (!g_file_get_contents(file, &buddylist, &length, &error)) { |
| 15884 | 282 | purple_notify_error(account, |
| 12007 | 283 | _("Couldn't load buddylist"), |
| 284 | _("Couldn't load buddylist"), | |
| 285 | error->message); | |
| 286 | ||
| 15884 | 287 | purple_debug_error("gg", |
| 12007 | 288 | "Couldn't load buddylist. file = %s; error = %s\n", |
| 289 | file, error->message); | |
| 290 | ||
| 291 | g_error_free(error); | |
| 292 | ||
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
293 | return; |
|
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
294 | } |
| 11360 | 295 | |
| 296 | ggp_buddylist_load(gc, buddylist); | |
| 297 | g_free(buddylist); | |
| 298 | ||
| 15884 | 299 | purple_notify_info(account, |
| 11360 | 300 | _("Load Buddylist..."), |
| 301 | _("Buddylist loaded successfully!"), NULL); | |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
302 | } |
| 11360 | 303 | /* }}} */ |
| 304 | ||
| 305 | /* | |
| 306 | */ | |
| 15884 | 307 | /* static void ggp_action_buddylist_save(PurplePluginAction *action) {{{ */ |
| 308 | static void ggp_action_buddylist_save(PurplePluginAction *action) | |
| 11360 | 309 | { |
| 15884 | 310 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 311 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
312 | 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
|
313 | 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
|
314 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
315 | gc); |
| 11360 | 316 | } |
|
2806
1576edefc75a
[gaim-migrate @ 2819]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2792
diff
changeset
|
317 | |
| 15884 | 318 | static void ggp_action_buddylist_load(PurplePluginAction *action) |
| 11360 | 319 | { |
| 15884 | 320 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 321 | |
|
23379
536450c4f7f9
Mark a string as translatable in prpl-gg. References #5693.
Will Thompson <resiak@pidgin.im>
parents:
23325
diff
changeset
|
322 | purple_request_file(action, _("Load buddylist from file..."), NULL, |
|
536450c4f7f9
Mark a string as translatable in prpl-gg. References #5693.
Will Thompson <resiak@pidgin.im>
parents:
23325
diff
changeset
|
323 | 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
|
324 | 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
|
325 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
326 | gc); |
| 11360 | 327 | } |
| 328 | ||
| 15884 | 329 | static void ggp_callback_register_account_ok(PurpleConnection *gc, |
| 330 | PurpleRequestFields *fields) | |
| 11414 | 331 | { |
| 15884 | 332 | PurpleAccount *account; |
| 11414 | 333 | GGPInfo *info = gc->proto_data; |
| 334 | struct gg_http *h = NULL; | |
| 335 | struct gg_pubdir *s; | |
| 336 | uin_t uin; | |
| 337 | gchar *email, *p1, *p2, *t; | |
| 12007 | 338 | GGPToken *token = info->token; |
| 11414 | 339 | |
| 15884 | 340 | email = charset_convert(purple_request_fields_get_string(fields, "email"), |
| 11414 | 341 | "UTF-8", "CP1250"); |
| 15884 | 342 | p1 = charset_convert(purple_request_fields_get_string(fields, "password1"), |
| 11414 | 343 | "UTF-8", "CP1250"); |
| 15884 | 344 | p2 = charset_convert(purple_request_fields_get_string(fields, "password2"), |
| 11414 | 345 | "UTF-8", "CP1250"); |
| 15884 | 346 | t = charset_convert(purple_request_fields_get_string(fields, "token"), |
| 11414 | 347 | "UTF-8", "CP1250"); |
| 348 | ||
| 15884 | 349 | account = purple_connection_get_account(gc); |
| 11414 | 350 | |
| 351 | if (email == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 352 | *email == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 21279 | 353 | purple_connection_error_reason (gc, |
| 354 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, | |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
355 | _("You must fill in all registration fields")); |
| 11414 | 356 | goto exit_err; |
| 357 | } | |
| 358 | ||
| 359 | 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
|
360 | purple_connection_error_reason (gc, |
| 21279 | 361 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
362 | _("Passwords do not match")); |
| 11414 | 363 | goto exit_err; |
| 364 | } | |
| 365 | ||
|
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
|
366 | purple_debug_info("gg", "register_account_ok: token_id = %s; t = %s\n", |
| 12007 | 367 | token->id, t); |
| 368 | h = gg_register3(email, p1, token->id, t, 0); | |
| 11414 | 369 | if (h == NULL || !(s = h->data) || !s->success) { |
| 21279 | 370 | purple_connection_error_reason (gc, |
| 371 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, | |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
372 | _("Unable to register new account. An unknown error occurred.")); |
| 11414 | 373 | goto exit_err; |
| 374 | } | |
| 375 | ||
| 376 | uin = s->uin; | |
| 15884 | 377 | purple_debug_info("gg", "registered uin: %d\n", uin); |
| 11414 | 378 | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
379 | g_free(t); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
380 | t = g_strdup_printf("%u", uin); |
| 15884 | 381 | purple_account_set_username(account, t); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
382 | /* Save the password if remembering passwords for the account */ |
| 15884 | 383 | purple_account_set_password(account, p1); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
384 | |
| 15884 | 385 | purple_notify_info(NULL, _("New Gadu-Gadu Account Registered"), |
| 11414 | 386 | _("Registration completed successfully!"), NULL); |
| 387 | ||
|
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
|
388 | 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
|
389 | (account->registration_cb)(account, TRUE, account->registration_cb_user_data); |
| 12007 | 390 | /* TODO: the currently open Accounts Window will not be updated withthe |
| 391 | * new username and etc, we need to somehow have it refresh at this | |
| 392 | * point | |
| 393 | */ | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
394 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
395 | /* Need to disconnect or actually log in. For now, we disconnect. */ |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24043
diff
changeset
|
396 | purple_account_disconnect(account); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
397 | |
| 11414 | 398 | 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
|
399 | 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
|
400 | (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
|
401 | |
| 11414 | 402 | gg_register_free(h); |
| 403 | g_free(email); | |
| 404 | g_free(p1); | |
| 405 | g_free(p2); | |
| 406 | g_free(t); | |
| 12007 | 407 | g_free(token->id); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
408 | g_free(token); |
| 11414 | 409 | } |
| 410 | ||
| 15884 | 411 | static void ggp_callback_register_account_cancel(PurpleConnection *gc, |
| 412 | PurpleRequestFields *fields) | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
413 | { |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
414 | GGPInfo *info = gc->proto_data; |
| 12007 | 415 | GGPToken *token = info->token; |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
416 | |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24043
diff
changeset
|
417 | purple_account_disconnect(gc->account); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
418 | |
| 12007 | 419 | g_free(token->id); |
| 420 | g_free(token->data); | |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
421 | g_free(token); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
422 | |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
423 | } |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
424 | |
| 15884 | 425 | static void ggp_register_user_dialog(PurpleConnection *gc) |
| 12007 | 426 | { |
| 15884 | 427 | PurpleAccount *account; |
| 428 | PurpleRequestFields *fields; | |
| 429 | PurpleRequestFieldGroup *group; | |
| 430 | PurpleRequestField *field; | |
| 12007 | 431 | |
| 432 | GGPInfo *info = gc->proto_data; | |
| 433 | GGPToken *token = info->token; | |
| 434 | ||
| 435 | ||
| 15884 | 436 | account = purple_connection_get_account(gc); |
| 12007 | 437 | |
| 15884 | 438 | fields = purple_request_fields_new(); |
| 439 | group = purple_request_field_group_new(NULL); | |
| 440 | purple_request_fields_add_group(fields, group); | |
| 12007 | 441 | |
| 15884 | 442 | field = purple_request_field_string_new("email", |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23295
diff
changeset
|
443 | _("Email"), "", FALSE); |
| 15884 | 444 | purple_request_field_string_set_masked(field, FALSE); |
| 445 | purple_request_field_group_add_field(group, field); | |
| 12007 | 446 | |
| 15884 | 447 | field = purple_request_field_string_new("password1", |
| 12007 | 448 | _("Password"), "", FALSE); |
| 15884 | 449 | purple_request_field_string_set_masked(field, TRUE); |
| 450 | purple_request_field_group_add_field(group, field); | |
| 12007 | 451 | |
| 15884 | 452 | field = purple_request_field_string_new("password2", |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
453 | _("Password (again)"), "", FALSE); |
| 15884 | 454 | purple_request_field_string_set_masked(field, TRUE); |
| 455 | purple_request_field_group_add_field(group, field); | |
| 12007 | 456 | |
| 15884 | 457 | field = purple_request_field_string_new("token", |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
458 | _("Enter captcha text"), "", FALSE); |
| 15884 | 459 | purple_request_field_string_set_masked(field, FALSE); |
| 460 | purple_request_field_group_add_field(group, field); | |
| 12007 | 461 | |
| 462 | /* original size: 60x24 */ | |
| 15884 | 463 | field = purple_request_field_image_new("token_img", |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
464 | _("Captcha"), token->data, token->size); |
| 15884 | 465 | purple_request_field_group_add_field(group, field); |
| 12007 | 466 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
467 | purple_request_fields(account, |
| 12007 | 468 | _("Register New Gadu-Gadu Account"), |
| 469 | _("Register New Gadu-Gadu Account"), | |
| 470 | _("Please, fill in the following fields"), | |
| 471 | fields, | |
| 472 | _("OK"), G_CALLBACK(ggp_callback_register_account_ok), | |
| 473 | _("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
|
474 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
475 | gc); |
| 12007 | 476 | } |
| 477 | ||
| 11414 | 478 | /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ |
| 479 | ||
| 15884 | 480 | static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) |
| 11414 | 481 | { |
| 482 | GGPInfo *info = gc->proto_data; | |
| 13641 | 483 | GGPSearchForm *form = user_data; |
| 484 | guint32 seq; | |
| 11414 | 485 | |
| 13641 | 486 | g_free(form->offset); |
| 487 | form->offset = g_strdup(form->last_uin); | |
| 488 | ||
| 489 | ggp_search_remove(info->searches, form->seq); | |
|
23584
886e1611b952
Gadu-Gadu Get Info isn't behaving properly. Added debug logging to its traking
Evan Schoenberg <evands@pidgin.im>
parents:
23382
diff
changeset
|
490 | purple_debug_info("gg", "ggp_callback_show_next(): Removed seq %u", form->seq); |
| 13641 | 491 | |
| 492 | seq = ggp_search_start(gc, form); | |
| 493 | ggp_search_add(info->searches, seq, form); | |
|
23584
886e1611b952
Gadu-Gadu Get Info isn't behaving properly. Added debug logging to its traking
Evan Schoenberg <evands@pidgin.im>
parents:
23382
diff
changeset
|
494 | purple_debug_info("gg", "ggp_callback_show_next(): Added seq %u", seq); |
| 11414 | 495 | } |
| 496 | ||
| 15884 | 497 | static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data) |
| 11414 | 498 | { |
| 15884 | 499 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
| 12007 | 500 | g_list_nth_data(row, 0), NULL, NULL); |
| 11414 | 501 | } |
| 502 | ||
| 15884 | 503 | static void ggp_callback_im(PurpleConnection *gc, GList *row, gpointer user_data) |
| 13642 | 504 | { |
| 15884 | 505 | PurpleAccount *account; |
| 506 | PurpleConversation *conv; | |
| 13642 | 507 | char *name; |
| 508 | ||
| 15884 | 509 | account = purple_connection_get_account(gc); |
| 13642 | 510 | |
| 511 | name = g_list_nth_data(row, 0); | |
| 15884 | 512 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name); |
| 513 | purple_conversation_present(conv); | |
| 13642 | 514 | } |
| 515 | ||
| 15884 | 516 | static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) |
| 11414 | 517 | { |
| 518 | GGPInfo *info = gc->proto_data; | |
| 519 | GGPSearchForm *form; | |
| 13641 | 520 | guint32 seq; |
| 11414 | 521 | |
| 13641 | 522 | form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL); |
| 11414 | 523 | |
| 13641 | 524 | form->user_data = info; |
| 12007 | 525 | form->lastname = charset_convert( |
| 15884 | 526 | purple_request_fields_get_string(fields, "lastname"), |
| 12007 | 527 | "UTF-8", "CP1250"); |
| 528 | form->firstname = charset_convert( | |
| 15884 | 529 | purple_request_fields_get_string(fields, "firstname"), |
| 12007 | 530 | "UTF-8", "CP1250"); |
| 531 | form->nickname = charset_convert( | |
| 15884 | 532 | purple_request_fields_get_string(fields, "nickname"), |
| 12007 | 533 | "UTF-8", "CP1250"); |
| 534 | form->city = charset_convert( | |
| 15884 | 535 | purple_request_fields_get_string(fields, "city"), |
| 12007 | 536 | "UTF-8", "CP1250"); |
| 537 | form->birthyear = charset_convert( | |
| 15884 | 538 | purple_request_fields_get_string(fields, "year"), |
| 12007 | 539 | "UTF-8", "CP1250"); |
| 11414 | 540 | |
| 15884 | 541 | switch (purple_request_fields_get_choice(fields, "gender")) { |
| 11414 | 542 | case 1: |
| 543 | form->gender = g_strdup(GG_PUBDIR50_GENDER_MALE); | |
| 544 | break; | |
| 545 | case 2: | |
| 546 | form->gender = g_strdup(GG_PUBDIR50_GENDER_FEMALE); | |
| 547 | break; | |
| 548 | default: | |
| 549 | form->gender = NULL; | |
| 550 | break; | |
| 551 | } | |
| 552 | ||
| 15884 | 553 | form->active = purple_request_fields_get_bool(fields, "active") |
| 11414 | 554 | ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL; |
| 555 | ||
| 556 | form->offset = g_strdup("0"); | |
| 557 | ||
| 13641 | 558 | seq = ggp_search_start(gc, form); |
| 559 | ggp_search_add(info->searches, seq, form); | |
|
23584
886e1611b952
Gadu-Gadu Get Info isn't behaving properly. Added debug logging to its traking
Evan Schoenberg <evands@pidgin.im>
parents:
23382
diff
changeset
|
560 | purple_debug_info("gg", "ggp_callback_find_buddies(): Added seq %u", seq); |
| 11414 | 561 | } |
| 562 | ||
| 15884 | 563 | static void ggp_find_buddies(PurplePluginAction *action) |
| 11414 | 564 | { |
| 15884 | 565 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11414 | 566 | |
| 15884 | 567 | PurpleRequestFields *fields; |
| 568 | PurpleRequestFieldGroup *group; | |
| 569 | PurpleRequestField *field; | |
| 11414 | 570 | |
| 15884 | 571 | fields = purple_request_fields_new(); |
| 572 | group = purple_request_field_group_new(NULL); | |
| 573 | purple_request_fields_add_group(fields, group); | |
| 11414 | 574 | |
| 15884 | 575 | field = purple_request_field_string_new("lastname", |
| 12007 | 576 | _("Last name"), NULL, FALSE); |
| 15884 | 577 | purple_request_field_string_set_masked(field, FALSE); |
| 578 | purple_request_field_group_add_field(group, field); | |
| 11414 | 579 | |
| 15884 | 580 | field = purple_request_field_string_new("firstname", |
| 12007 | 581 | _("First name"), NULL, FALSE); |
| 15884 | 582 | purple_request_field_string_set_masked(field, FALSE); |
| 583 | purple_request_field_group_add_field(group, field); | |
| 11414 | 584 | |
| 15884 | 585 | field = purple_request_field_string_new("nickname", |
| 12007 | 586 | _("Nickname"), NULL, FALSE); |
| 15884 | 587 | purple_request_field_string_set_masked(field, FALSE); |
| 588 | purple_request_field_group_add_field(group, field); | |
| 11414 | 589 | |
| 15884 | 590 | field = purple_request_field_string_new("city", |
| 12007 | 591 | _("City"), NULL, FALSE); |
| 15884 | 592 | purple_request_field_string_set_masked(field, FALSE); |
| 593 | purple_request_field_group_add_field(group, field); | |
| 11414 | 594 | |
| 15884 | 595 | field = purple_request_field_string_new("year", |
| 12007 | 596 | _("Year of birth"), NULL, FALSE); |
| 15884 | 597 | purple_request_field_group_add_field(group, field); |
| 11414 | 598 | |
| 15884 | 599 | field = purple_request_field_choice_new("gender", _("Gender"), 0); |
| 600 | purple_request_field_choice_add(field, _("Male or female")); | |
| 601 | purple_request_field_choice_add(field, _("Male")); | |
| 602 | purple_request_field_choice_add(field, _("Female")); | |
| 603 | purple_request_field_group_add_field(group, field); | |
| 11414 | 604 | |
| 15884 | 605 | field = purple_request_field_bool_new("active", |
| 12007 | 606 | _("Only online"), FALSE); |
| 15884 | 607 | purple_request_field_group_add_field(group, field); |
| 11414 | 608 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
609 | purple_request_fields(gc, |
| 11414 | 610 | _("Find buddies"), |
| 611 | _("Find buddies"), | |
| 612 | _("Please, enter your search criteria below"), | |
| 613 | fields, | |
| 614 | _("OK"), G_CALLBACK(ggp_callback_find_buddies), | |
| 615 | _("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
|
616 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
617 | gc); |
| 11414 | 618 | } |
| 619 | ||
| 620 | /* ----- CHANGE PASSWORD ------------------------------------------------ */ | |
| 621 | ||
| 15884 | 622 | static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) |
| 2393 | 623 | { |
| 15884 | 624 | PurpleAccount *account; |
| 11360 | 625 | GGPInfo *info = gc->proto_data; |
| 626 | struct gg_http *h; | |
| 627 | gchar *cur, *p1, *p2, *t; | |
| 628 | ||
| 12007 | 629 | cur = charset_convert( |
| 15884 | 630 | purple_request_fields_get_string(fields, "password_cur"), |
| 12007 | 631 | "UTF-8", "CP1250"); |
| 632 | p1 = charset_convert( | |
| 15884 | 633 | purple_request_fields_get_string(fields, "password1"), |
| 12007 | 634 | "UTF-8", "CP1250"); |
| 635 | p2 = charset_convert( | |
| 15884 | 636 | purple_request_fields_get_string(fields, "password2"), |
| 12007 | 637 | "UTF-8", "CP1250"); |
| 638 | t = charset_convert( | |
| 15884 | 639 | purple_request_fields_get_string(fields, "token"), |
| 12007 | 640 | "UTF-8", "CP1250"); |
| 11360 | 641 | |
| 15884 | 642 | account = purple_connection_get_account(gc); |
| 11360 | 643 | |
| 644 | if (cur == NULL || p1 == NULL || p2 == NULL || t == NULL || | |
| 645 | *cur == '\0' || *p1 == '\0' || *p2 == '\0' || *t == '\0') { | |
| 15884 | 646 | purple_notify_error(account, NULL, _("Fill in the fields."), NULL); |
| 11360 | 647 | goto exit_err; |
| 648 | } | |
| 649 | ||
| 650 | if (g_utf8_collate(p1, p2) != 0) { | |
| 15884 | 651 | purple_notify_error(account, NULL, |
| 12007 | 652 | _("New passwords do not match."), NULL); |
| 11360 | 653 | goto exit_err; |
| 654 | } | |
| 2393 | 655 | |
| 15884 | 656 | if (g_utf8_collate(cur, purple_account_get_password(account)) != 0) { |
| 657 | purple_notify_error(account, NULL, | |
| 11360 | 658 | _("Your current password is different from the one that you specified."), |
| 659 | NULL); | |
| 660 | goto exit_err; | |
| 661 | } | |
| 662 | ||
| 15884 | 663 | purple_debug_info("gg", "Changing password\n"); |
| 11360 | 664 | |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23295
diff
changeset
|
665 | /* XXX: this email should be a pref... */ |
| 11360 | 666 | h = gg_change_passwd4(ggp_get_uin(account), |
| 15884 | 667 | "user@example.net", purple_account_get_password(account), |
| 12007 | 668 | p1, info->token->id, t, 0); |
| 2393 | 669 | |
| 11360 | 670 | if (h == NULL) { |
| 15884 | 671 | purple_notify_error(account, NULL, |
| 14754 | 672 | _("Unable to change password. Error occurred.\n"), |
| 11360 | 673 | NULL); |
| 674 | goto exit_err; | |
| 675 | } | |
| 676 | ||
| 15884 | 677 | purple_account_set_password(account, p1); |
| 11360 | 678 | |
| 679 | gg_change_passwd_free(h); | |
| 680 | ||
| 15884 | 681 | purple_notify_info(account, _("Change password for the Gadu-Gadu account"), |
| 11360 | 682 | _("Password was changed successfully!"), NULL); |
| 683 | ||
| 684 | exit_err: | |
| 685 | g_free(cur); | |
| 686 | g_free(p1); | |
| 687 | g_free(p2); | |
| 688 | g_free(t); | |
| 12007 | 689 | g_free(info->token->id); |
| 690 | g_free(info->token->data); | |
| 691 | g_free(info->token); | |
| 692 | } | |
| 693 | ||
| 15884 | 694 | static void ggp_change_passwd_dialog(PurpleConnection *gc) |
| 12007 | 695 | { |
| 15884 | 696 | PurpleRequestFields *fields; |
| 697 | PurpleRequestFieldGroup *group; | |
| 698 | PurpleRequestField *field; | |
| 12007 | 699 | |
| 700 | GGPInfo *info = gc->proto_data; | |
| 701 | GGPToken *token = info->token; | |
| 702 | ||
| 703 | char *msg; | |
| 704 | ||
| 705 | ||
| 15884 | 706 | fields = purple_request_fields_new(); |
| 707 | group = purple_request_field_group_new(NULL); | |
| 708 | purple_request_fields_add_group(fields, group); | |
| 12007 | 709 | |
| 15884 | 710 | field = purple_request_field_string_new("password_cur", |
| 12007 | 711 | _("Current password"), "", FALSE); |
| 15884 | 712 | purple_request_field_string_set_masked(field, TRUE); |
| 713 | purple_request_field_group_add_field(group, field); | |
| 12007 | 714 | |
| 15884 | 715 | field = purple_request_field_string_new("password1", |
| 12007 | 716 | _("Password"), "", FALSE); |
| 15884 | 717 | purple_request_field_string_set_masked(field, TRUE); |
| 718 | purple_request_field_group_add_field(group, field); | |
| 12007 | 719 | |
| 15884 | 720 | field = purple_request_field_string_new("password2", |
| 12007 | 721 | _("Password (retype)"), "", FALSE); |
| 15884 | 722 | purple_request_field_string_set_masked(field, TRUE); |
| 723 | purple_request_field_group_add_field(group, field); | |
| 12007 | 724 | |
| 15884 | 725 | field = purple_request_field_string_new("token", |
| 12007 | 726 | _("Enter current token"), "", FALSE); |
| 15884 | 727 | purple_request_field_string_set_masked(field, FALSE); |
| 728 | purple_request_field_group_add_field(group, field); | |
| 12007 | 729 | |
| 730 | /* original size: 60x24 */ | |
| 15884 | 731 | field = purple_request_field_image_new("token_img", |
| 12007 | 732 | _("Current token"), token->data, token->size); |
| 15884 | 733 | purple_request_field_group_add_field(group, field); |
| 12007 | 734 | |
| 735 | msg = g_strdup_printf("%s %d", | |
| 736 | _("Please, enter your current password and your new password for UIN: "), | |
| 15884 | 737 | ggp_get_uin(purple_connection_get_account(gc))); |
| 12007 | 738 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
739 | purple_request_fields(gc, |
| 12007 | 740 | _("Change Gadu-Gadu Password"), |
| 741 | _("Change Gadu-Gadu Password"), | |
| 742 | msg, | |
| 743 | 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
|
744 | _("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
|
745 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
746 | gc); |
| 12007 | 747 | |
| 748 | g_free(msg); | |
| 11360 | 749 | } |
| 2393 | 750 | |
| 15884 | 751 | static void ggp_change_passwd(PurplePluginAction *action) |
| 11360 | 752 | { |
| 15884 | 753 | PurpleConnection *gc = (PurpleConnection *)action->context; |
| 11360 | 754 | |
| 12007 | 755 | ggp_token_request(gc, ggp_change_passwd_dialog); |
| 11360 | 756 | } |
| 757 | ||
| 11414 | 758 | /* ----- CONFERENCES ---------------------------------------------------- */ |
| 759 | ||
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
760 | static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields) |
| 11394 | 761 | { |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
762 | GGPInfo *info; |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
763 | PurpleConnection *conn; |
| 15884 | 764 | PurpleRequestField *field; |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17455
diff
changeset
|
765 | GList *sel; |
| 11394 | 766 | |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
767 | conn = purple_account_get_connection(purple_buddy_get_account(buddy)); |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
768 | |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
769 | g_return_if_fail(conn != NULL); |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
770 | |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
771 | info = conn->proto_data; |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
772 | |
| 15884 | 773 | field = purple_request_fields_get_field(fields, "name"); |
| 774 | sel = purple_request_field_list_get_selected(field); | |
| 11394 | 775 | |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
776 | if (sel == NULL) { |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
777 | purple_debug_error("gg", "No chat selected\n"); |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
778 | return; |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
779 | } |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
780 | |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
781 | ggp_confer_participants_add_uin(conn, sel->data, |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
782 | ggp_str_to_uin(purple_buddy_get_name(buddy))); |
| 11394 | 783 | } |
| 784 | ||
| 15884 | 785 | static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored) |
| 11394 | 786 | { |
| 15884 | 787 | PurpleBuddy *buddy; |
| 788 | PurpleConnection *gc; | |
| 11394 | 789 | GGPInfo *info; |
| 790 | ||
| 15884 | 791 | PurpleRequestFields *fields; |
| 792 | PurpleRequestFieldGroup *group; | |
| 793 | PurpleRequestField *field; | |
| 11394 | 794 | |
| 795 | GList *l; | |
| 796 | gchar *msg; | |
| 797 | ||
| 15884 | 798 | buddy = (PurpleBuddy *)node; |
| 799 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11394 | 800 | info = gc->proto_data; |
| 801 | ||
| 15884 | 802 | fields = purple_request_fields_new(); |
| 803 | group = purple_request_field_group_new(NULL); | |
| 804 | purple_request_fields_add_group(fields, group); | |
| 11394 | 805 | |
| 15884 | 806 | field = purple_request_field_list_new("name", "Chat name"); |
| 11394 | 807 | for (l = info->chats; l != NULL; l = l->next) { |
| 808 | GGPChat *chat = l->data; | |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
809 | purple_request_field_list_add(field, chat->name, chat->name); |
| 11394 | 810 | } |
| 15884 | 811 | purple_request_field_group_add_field(group, field); |
| 11394 | 812 | |
| 12007 | 813 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
| 15884 | 814 | purple_buddy_get_alias(buddy)); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
815 | purple_request_fields(gc, |
| 11394 | 816 | _("Add to chat..."), |
| 817 | _("Add to chat..."), | |
| 818 | msg, | |
| 819 | fields, | |
| 820 | _("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
|
821 | _("Cancel"), NULL, |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
822 | purple_connection_get_account(gc), NULL, NULL, |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
823 | buddy); |
| 11394 | 824 | g_free(msg); |
| 825 | } | |
| 826 | ||
| 11414 | 827 | /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
| 828 | ||
| 15884 | 829 | static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored) |
| 11410 | 830 | { |
| 15884 | 831 | PurpleConnection *gc; |
| 832 | PurpleBuddy *buddy; | |
| 11410 | 833 | GGPInfo *info; |
| 834 | uin_t uin; | |
| 835 | ||
| 15884 | 836 | buddy = (PurpleBuddy *)node; |
| 837 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11410 | 838 | info = gc->proto_data; |
| 839 | ||
| 15884 | 840 | uin = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11410 | 841 | |
| 15884 | 842 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 843 | purple_blist_node_set_bool(node, "blocked", FALSE); | |
| 11410 | 844 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); |
| 845 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 15884 | 846 | purple_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); |
| 11410 | 847 | } else { |
| 15884 | 848 | purple_blist_node_set_bool(node, "blocked", TRUE); |
| 11410 | 849 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); |
| 850 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 15884 | 851 | purple_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); |
| 11410 | 852 | } |
| 853 | } | |
| 854 | ||
| 11360 | 855 | /* ---------------------------------------------------------------------- */ |
| 11414 | 856 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 857 | /* ---------------------------------------------------------------------- */ | |
| 858 | ||
|
23381
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
859 | /* Prototypes */ |
| 15884 | 860 | static void ggp_set_status(PurpleAccount *account, PurpleStatus *status); |
|
23381
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
861 | static int ggp_to_gg_status(PurpleStatus *status, char **msg); |
|
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
862 | |
|
27388
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
863 | struct gg_fetch_avatar_data |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
864 | { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
865 | PurpleConnection *gc; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
866 | gchar *uin; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
867 | gchar *avatar_url; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
868 | }; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
869 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
870 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
871 | static void gg_fetch_avatar_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
872 | const gchar *data, size_t len, const gchar *error_message) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
873 | struct gg_fetch_avatar_data *d = user_data; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
874 | PurpleAccount *account; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
875 | PurpleBuddy *buddy; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
876 | gpointer buddy_icon_data; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
877 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
878 | /* FIXME: This shouldn't be necessary */ |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
879 | if (!PURPLE_CONNECTION_IS_VALID(d->gc)) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
880 | g_free(d->uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
881 | g_free(d->avatar_url); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
882 | g_free(d); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
883 | g_return_if_reached(); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
884 | } |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
885 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
886 | account = purple_connection_get_account(d->gc); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
887 | buddy = purple_find_buddy(account, d->uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
888 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
889 | if (buddy == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
890 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
891 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
892 | buddy_icon_data = g_memdup(data, len); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
893 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
894 | purple_buddy_icons_set_for_user(account, purple_buddy_get_name(buddy), |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
895 | buddy_icon_data, len, d->avatar_url); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
896 | purple_debug_info("gg", "UIN: %s should have avatar now\n", d->uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
897 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
898 | out: |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
899 | g_free(d->uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
900 | g_free(d->avatar_url); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
901 | g_free(d); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
902 | } |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
903 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
904 | static void gg_get_avatar_url_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
905 | const gchar *url_text, size_t len, const gchar *error_message) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
906 | struct gg_fetch_avatar_data *data; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
907 | PurpleConnection *gc = user_data; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
908 | PurpleAccount *account; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
909 | PurpleBuddy *buddy; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
910 | const char *uin; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
911 | const char *is_blank; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
912 | const char *checksum; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
913 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
914 | gchar *bigavatar = NULL; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
915 | xmlnode *xml = NULL; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
916 | xmlnode *xmlnode_users; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
917 | xmlnode *xmlnode_user; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
918 | xmlnode *xmlnode_avatars; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
919 | xmlnode *xmlnode_avatar; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
920 | xmlnode *xmlnode_bigavatar; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
921 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
922 | g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
923 | account = purple_connection_get_account(gc); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
924 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
925 | if (error_message != NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
926 | purple_debug_error("gg", "gg_get_avatars_cb error: %s\n", error_message); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
927 | else if (len > 0 && url_text && *url_text) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
928 | xml = xmlnode_from_str(url_text, -1); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
929 | if (xml == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
930 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
931 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
932 | xmlnode_users = xmlnode_get_child(xml, "users"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
933 | if (xmlnode_users == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
934 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
935 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
936 | xmlnode_user = xmlnode_get_child(xmlnode_users, "user"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
937 | if (xmlnode_user == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
938 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
939 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
940 | uin = xmlnode_get_attrib(xmlnode_user, "uin"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
941 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
942 | xmlnode_avatars = xmlnode_get_child(xmlnode_user, "avatars"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
943 | if (xmlnode_avatars == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
944 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
945 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
946 | xmlnode_avatar = xmlnode_get_child(xmlnode_avatars, "avatar"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
947 | if (xmlnode_avatar == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
948 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
949 | |
|
29182
f11475f964ac
Fix Gadu-Gadu avatars. The server's response format has changed. Fixes #11050.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27642
diff
changeset
|
950 | xmlnode_bigavatar = xmlnode_get_child(xmlnode_avatar, "originBigAvatar"); |
|
27388
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
951 | if (xmlnode_bigavatar == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
952 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
953 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
954 | is_blank = xmlnode_get_attrib(xmlnode_avatar, "blank"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
955 | bigavatar = xmlnode_get_data(xmlnode_bigavatar); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
956 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
957 | purple_debug_info("gg", "gg_get_avatar_url_cb: UIN %s, IS_BLANK %s, " |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
958 | "URL %s\n", |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
959 | uin ? uin : "(null)", is_blank ? is_blank : "(null)", |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
960 | bigavatar ? bigavatar : "(null)"); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
961 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
962 | if (uin != NULL && bigavatar != NULL) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
963 | buddy = purple_find_buddy(account, uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
964 | if (buddy == NULL) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
965 | goto out; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
966 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
967 | checksum = purple_buddy_icons_get_checksum_for_user(buddy); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
968 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
969 | if (purple_strequal(is_blank, "1")) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
970 | purple_buddy_icons_set_for_user(account, |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
971 | purple_buddy_get_name(buddy), NULL, 0, NULL); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
972 | } else if (!purple_strequal(checksum, bigavatar)) { |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
973 | data = g_new0(struct gg_fetch_avatar_data, 1); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
974 | data->gc = gc; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
975 | data->uin = g_strdup(uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
976 | data->avatar_url = g_strdup(bigavatar); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
977 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
978 | url_data = purple_util_fetch_url_request_len_with_account(account, |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
979 | bigavatar, TRUE, "Mozilla/4.0 (compatible; MSIE 5.0)", |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
980 | FALSE, NULL, FALSE, -1, gg_fetch_avatar_cb, data); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
981 | } |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
982 | } |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
983 | } |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
984 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
985 | out: |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
986 | if (xml) |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
987 | xmlnode_free(xml); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
988 | g_free(bigavatar); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
989 | } |
| 12964 | 990 | |
| 11414 | 991 | /** |
| 992 | * Handle change of the status of the buddy. | |
| 993 | * | |
| 15884 | 994 | * @param gc PurpleConnection |
| 11414 | 995 | * @param uin UIN of the buddy. |
| 996 | * @param status ID of the status. | |
| 997 | * @param descr Description. | |
| 998 | */ | |
| 15884 | 999 | static void ggp_generic_status_handler(PurpleConnection *gc, uin_t uin, |
| 12007 | 1000 | int status, const char *descr) |
| 11414 | 1001 | { |
| 1002 | gchar *from; | |
| 1003 | const char *st; | |
|
27388
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1004 | gchar *avatarurl; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1005 | PurpleUtilFetchUrlData *url_data; |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1006 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1007 | from = g_strdup_printf("%u", uin); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1008 | avatarurl = g_strdup_printf("http://api.gadu-gadu.pl/avatars/%s/0.xml", from); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1009 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1010 | url_data = purple_util_fetch_url_request_len_with_account( |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1011 | purple_connection_get_account(gc), avatarurl, TRUE, |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1012 | "Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, NULL, FALSE, -1, |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1013 | gg_get_avatar_url_cb, gc); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1014 | |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1015 | g_free(avatarurl); |
|
e72ccf802d25
Support fetching Gadu-Gadu avatars. Closes #9371.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27371
diff
changeset
|
1016 | |
| 11414 | 1017 | switch (status) { |
| 1018 | case GG_STATUS_NOT_AVAIL: | |
| 1019 | case GG_STATUS_NOT_AVAIL_DESCR: | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1020 | st = purple_primitive_get_id_from_type(PURPLE_STATUS_OFFLINE); |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1021 | break; |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1022 | case GG_STATUS_FFC: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1023 | case GG_STATUS_FFC_DESCR: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1024 | st = purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE); |
| 11414 | 1025 | break; |
| 1026 | case GG_STATUS_AVAIL: | |
| 1027 | case GG_STATUS_AVAIL_DESCR: | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1028 | st = purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE); |
| 11414 | 1029 | break; |
| 1030 | case GG_STATUS_BUSY: | |
| 1031 | case GG_STATUS_BUSY_DESCR: | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1032 | st = purple_primitive_get_id_from_type(PURPLE_STATUS_AWAY); |
| 11414 | 1033 | break; |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1034 | case GG_STATUS_DND: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1035 | case GG_STATUS_DND_DESCR: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1036 | st = purple_primitive_get_id_from_type(PURPLE_STATUS_UNAVAILABLE); |
|
30055
1aa76ed6cda6
gadu-gadu: Add a missing 'break;'
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
30006
diff
changeset
|
1037 | break; |
| 11414 | 1038 | case GG_STATUS_BLOCKED: |
| 1039 | /* user is blocking us.... */ | |
| 1040 | st = "blocked"; | |
| 1041 | break; | |
| 1042 | default: | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1043 | st = purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE); |
| 15884 | 1044 | purple_debug_info("gg", |
| 12007 | 1045 | "GG_EVENT_NOTIFY: Unknown status: %d\n", status); |
| 11414 | 1046 | break; |
| 1047 | } | |
| 1048 | ||
| 15884 | 1049 | purple_debug_info("gg", "st = %s\n", st); |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1050 | //msg = charset_convert(descr, "CP1250", "UTF-8"); |
|
30006
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1051 | if (descr == NULL) { |
|
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1052 | purple_prpl_got_user_status(purple_connection_get_account(gc), |
|
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1053 | from, st, NULL); |
|
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1054 | } else { |
|
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1055 | purple_prpl_got_user_status(purple_connection_get_account(gc), |
|
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1056 | from, st, "message", descr, NULL); |
|
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1057 | } |
| 11414 | 1058 | g_free(from); |
| 1059 | } | |
| 1060 | ||
| 13643 | 1061 | static void ggp_sr_close_cb(gpointer user_data) |
| 12220 | 1062 | { |
| 13643 | 1063 | GGPSearchForm *form = user_data; |
| 13641 | 1064 | GGPInfo *info = form->user_data; |
| 12220 | 1065 | |
| 13641 | 1066 | ggp_search_remove(info->searches, form->seq); |
|
23584
886e1611b952
Gadu-Gadu Get Info isn't behaving properly. Added debug logging to its traking
Evan Schoenberg <evands@pidgin.im>
parents:
23382
diff
changeset
|
1067 | purple_debug_info("gg", "ggp_sr_close_cb(): Removed seq %u", form->seq); |
| 13641 | 1068 | ggp_search_form_destroy(form); |
| 12220 | 1069 | } |
| 1070 | ||
| 13645 | 1071 | /** |
| 1072 | * Translate a status' ID to a more user-friendly name. | |
| 1073 | * | |
| 1074 | * @param id The ID of the status. | |
| 1075 | * | |
| 1076 | * @return The user-friendly name of the status. | |
| 1077 | */ | |
| 1078 | static const char *ggp_status_by_id(unsigned int id) | |
| 1079 | { | |
| 1080 | const char *st; | |
| 1081 | ||
| 15884 | 1082 | purple_debug_info("gg", "ggp_status_by_id: %d\n", id); |
| 13645 | 1083 | switch (id) { |
| 1084 | case GG_STATUS_NOT_AVAIL: | |
|
27371
6f8830d73092
Correctly show status in tooltips for GG contacts with status messages.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27255
diff
changeset
|
1085 | case GG_STATUS_NOT_AVAIL_DESCR: |
| 13645 | 1086 | st = _("Offline"); |
| 1087 | break; | |
| 1088 | case GG_STATUS_AVAIL: | |
|
27371
6f8830d73092
Correctly show status in tooltips for GG contacts with status messages.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27255
diff
changeset
|
1089 | case GG_STATUS_AVAIL_DESCR: |
| 13645 | 1090 | st = _("Available"); |
| 1091 | break; | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1092 | case GG_STATUS_FFC: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1093 | case GG_STATUS_FFC_DESCR: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1094 | return _("Chatty"); |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1095 | case GG_STATUS_DND: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1096 | case GG_STATUS_DND_DESCR: |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1097 | return _("Do Not Disturb"); |
| 13645 | 1098 | case GG_STATUS_BUSY: |
|
27371
6f8830d73092
Correctly show status in tooltips for GG contacts with status messages.
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
27255
diff
changeset
|
1099 | case GG_STATUS_BUSY_DESCR: |
| 13645 | 1100 | st = _("Away"); |
| 1101 | break; | |
| 1102 | default: | |
| 1103 | st = _("Unknown"); | |
| 1104 | break; | |
| 1105 | } | |
| 1106 | ||
| 1107 | return st; | |
| 1108 | } | |
| 1109 | ||
| 15884 | 1110 | static void ggp_pubdir_handle_info(PurpleConnection *gc, gg_pubdir50_t req, |
| 13643 | 1111 | GGPSearchForm *form) |
| 12007 | 1112 | { |
| 15884 | 1113 | PurpleNotifyUserInfo *user_info; |
| 1114 | PurpleBuddy *buddy; | |
| 13643 | 1115 | char *val, *who; |
| 1116 | ||
| 15884 | 1117 | user_info = purple_notify_user_info_new(); |
| 13643 | 1118 | |
| 1119 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_STATUS); | |
| 13645 | 1120 | /* XXX: Use of ggp_str_to_uin() is an ugly hack! */ |
| 15884 | 1121 | purple_notify_user_info_add_pair(user_info, _("Status"), ggp_status_by_id(ggp_str_to_uin(val))); |
| 13643 | 1122 | g_free(val); |
| 1123 | ||
| 1124 | who = ggp_search_get_result(req, 0, GG_PUBDIR50_UIN); | |
| 15884 | 1125 | purple_notify_user_info_add_pair(user_info, _("UIN"), who); |
| 13643 | 1126 | |
| 1127 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_FIRSTNAME); | |
| 15884 | 1128 | purple_notify_user_info_add_pair(user_info, _("First Name"), val); |
| 13643 | 1129 | g_free(val); |
| 1130 | ||
| 1131 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_NICKNAME); | |
| 15884 | 1132 | purple_notify_user_info_add_pair(user_info, _("Nickname"), val); |
| 13643 | 1133 | g_free(val); |
| 1134 | ||
| 1135 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_CITY); | |
| 15884 | 1136 | purple_notify_user_info_add_pair(user_info, _("City"), val); |
| 13643 | 1137 | g_free(val); |
| 1138 | ||
| 1139 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_BIRTHYEAR); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1140 | if (strncmp(val, "0", 1)) { |
| 15884 | 1141 | purple_notify_user_info_add_pair(user_info, _("Birth Year"), val); |
| 13643 | 1142 | } |
| 1143 | g_free(val); | |
| 1144 | ||
| 15294 | 1145 | /* |
| 1146 | * Include a status message, if exists and buddy is in the blist. | |
| 1147 | */ | |
| 15884 | 1148 | buddy = purple_find_buddy(purple_connection_get_account(gc), who); |
| 15294 | 1149 | if (NULL != buddy) { |
| 15884 | 1150 | PurpleStatus *status; |
| 15294 | 1151 | const char *msg; |
| 1152 | char *text; | |
| 13643 | 1153 | |
| 15884 | 1154 | status = purple_presence_get_active_status(purple_buddy_get_presence(buddy)); |
| 1155 | msg = purple_status_get_attr_string(status, "message"); | |
| 13643 | 1156 | |
| 15294 | 1157 | if (msg != NULL) { |
| 1158 | text = g_markup_escape_text(msg, -1); | |
| 15884 | 1159 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15294 | 1160 | g_free(text); |
| 1161 | } | |
| 1162 | } | |
| 1163 | ||
|
18629
9e78088bfc46
Close temporary Get Info window when showing the real one. Fixes #1720.
Bartosz Oler <bartosz@pidgin.im>
parents:
18190
diff
changeset
|
1164 | purple_notify_userinfo(gc, who, user_info, ggp_sr_close_cb, form); |
| 15294 | 1165 | g_free(who); |
| 15884 | 1166 | purple_notify_user_info_destroy(user_info); |
| 13643 | 1167 | } |
| 1168 | ||
| 15884 | 1169 | static void ggp_pubdir_handle_full(PurpleConnection *gc, gg_pubdir50_t req, |
| 13643 | 1170 | GGPSearchForm *form) |
| 1171 | { | |
| 15884 | 1172 | PurpleNotifySearchResults *results; |
| 1173 | PurpleNotifySearchColumn *column; | |
| 13643 | 1174 | int res_count; |
| 12007 | 1175 | int start; |
| 1176 | int i; | |
| 13641 | 1177 | |
| 13643 | 1178 | g_return_if_fail(form != NULL); |
| 12007 | 1179 | |
| 1180 | res_count = gg_pubdir50_count(req); | |
| 13643 | 1181 | res_count = (res_count > PUBDIR_RESULTS_MAX) ? PUBDIR_RESULTS_MAX : res_count; |
| 12007 | 1182 | |
| 15884 | 1183 | results = purple_notify_searchresults_new(); |
| 12007 | 1184 | |
| 12257 | 1185 | if (results == NULL) { |
| 15884 | 1186 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
| 12257 | 1187 | "Unable to display the search results.\n"); |
| 15884 | 1188 | purple_notify_error(gc, NULL, |
| 12257 | 1189 | _("Unable to display the search results."), |
| 1190 | NULL); | |
| 13641 | 1191 | ggp_sr_close_cb(form); |
| 12257 | 1192 | return; |
| 1193 | } | |
| 1194 | ||
| 15884 | 1195 | column = purple_notify_searchresults_column_new(_("UIN")); |
| 1196 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1197 | |
| 15884 | 1198 | column = purple_notify_searchresults_column_new(_("First Name")); |
| 1199 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1200 | |
| 15884 | 1201 | column = purple_notify_searchresults_column_new(_("Nickname")); |
| 1202 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1203 | |
| 15884 | 1204 | column = purple_notify_searchresults_column_new(_("City")); |
| 1205 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1206 | |
| 15884 | 1207 | column = purple_notify_searchresults_column_new(_("Birth Year")); |
| 1208 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1209 | |
| 15884 | 1210 | purple_debug_info("gg", "Going with %d entries\n", res_count); |
| 12007 | 1211 | |
| 1212 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 15884 | 1213 | purple_debug_info("gg", "start = %d\n", start); |
| 12007 | 1214 | |
| 1215 | for (i = 0; i < res_count; i++) { | |
| 1216 | GList *row = NULL; | |
| 1217 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 1218 | ||
| 1219 | /* TODO: Status will be displayed as an icon. */ | |
| 1220 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 1221 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1222 | GG_PUBDIR50_UIN)); | |
| 1223 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1224 | GG_PUBDIR50_FIRSTNAME)); | |
| 1225 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1226 | GG_PUBDIR50_NICKNAME)); | |
| 1227 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1228 | GG_PUBDIR50_CITY)); | |
| 1229 | row = g_list_append(row, | |
| 1230 | (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 1231 | ||
| 15884 | 1232 | purple_notify_searchresults_row_add(results, row); |
| 12007 | 1233 | |
| 1234 | if (i == res_count - 1) { | |
| 13641 | 1235 | g_free(form->last_uin); |
| 1236 | form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN); | |
| 12007 | 1237 | } |
| 1238 | } | |
| 1239 | ||
| 15884 | 1240 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_CONTINUE, |
| 12007 | 1241 | ggp_callback_show_next); |
| 15884 | 1242 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 12007 | 1243 | ggp_callback_add_buddy); |
| 15884 | 1244 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_IM, |
| 13642 | 1245 | ggp_callback_im); |
| 13643 | 1246 | |
| 13641 | 1247 | if (form->window == NULL) { |
| 15884 | 1248 | void *h = purple_notify_searchresults(gc, |
| 12007 | 1249 | _("Gadu-Gadu Public Directory"), |
| 12220 | 1250 | _("Search results"), NULL, results, |
| 15884 | 1251 | (PurpleNotifyCloseCallback)ggp_sr_close_cb, |
| 13641 | 1252 | form); |
| 12257 | 1253 | |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1254 | if (h == NULL) { |
| 15884 | 1255 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1256 | "Unable to display the search results.\n"); |
| 15884 | 1257 | purple_notify_error(gc, NULL, |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1258 | _("Unable to display the search results."), |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1259 | NULL); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1260 | return; |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1261 | } |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1262 | |
| 13641 | 1263 | form->window = h; |
| 12007 | 1264 | } else { |
| 15884 | 1265 | purple_notify_searchresults_new_rows(gc, results, form->window); |
| 12007 | 1266 | } |
| 1267 | } | |
| 1268 | ||
| 15884 | 1269 | static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) |
| 13643 | 1270 | { |
| 1271 | GGPInfo *info = gc->proto_data; | |
| 1272 | GGPSearchForm *form; | |
| 1273 | int res_count; | |
| 1274 | guint32 seq; | |
| 1275 | ||
| 1276 | seq = gg_pubdir50_seq(req); | |
| 1277 | form = ggp_search_get(info->searches, seq); | |
|
23584
886e1611b952
Gadu-Gadu Get Info isn't behaving properly. Added debug logging to its traking
Evan Schoenberg <evands@pidgin.im>
parents:
23382
diff
changeset
|
1278 | purple_debug_info("gg", "ggp_pubdir_reply_handler(): seq %u --> form %p", seq, form); |
| 13643 | 1279 | /* |
| 1280 | * this can happen when user will request more results | |
| 1281 | * and close the results window before they arrive. | |
| 1282 | */ | |
| 1283 | g_return_if_fail(form != NULL); | |
| 1284 | ||
| 1285 | res_count = gg_pubdir50_count(req); | |
| 1286 | if (res_count < 1) { | |
| 15884 | 1287 | purple_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); |
| 1288 | purple_notify_error(gc, NULL, | |
| 13643 | 1289 | _("No matching users found"), |
| 1290 | _("There are no users matching your search criteria.")); | |
| 1291 | ggp_sr_close_cb(form); | |
| 1292 | return; | |
| 1293 | } | |
| 1294 | ||
| 1295 | switch (form->search_type) { | |
| 1296 | case GGP_SEARCH_TYPE_INFO: | |
| 1297 | ggp_pubdir_handle_info(gc, req, form); | |
| 1298 | break; | |
| 1299 | case GGP_SEARCH_TYPE_FULL: | |
| 1300 | ggp_pubdir_handle_full(gc, req, form); | |
| 1301 | break; | |
| 1302 | default: | |
| 15884 | 1303 | purple_debug_warning("gg", "Unknown search_type!\n"); |
| 13643 | 1304 | break; |
| 1305 | } | |
| 1306 | } | |
| 1307 | ||
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1308 | static void ggp_recv_image_handler(PurpleConnection *gc, const struct gg_event *ev) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1309 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1310 | gint imgid = 0; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1311 | GGPInfo *info = gc->proto_data; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1312 | GList *entry = g_list_first(info->pending_richtext_messages); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1313 | gchar *handlerid = g_strdup_printf("IMGID_HANDLER-%i", ev->event.image_reply.crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1314 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1315 | imgid = purple_imgstore_add_with_id( |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1316 | g_memdup(ev->event.image_reply.image, ev->event.image_reply.size), |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1317 | ev->event.image_reply.size, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1318 | ev->event.image_reply.filename); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1319 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1320 | purple_debug_info("gg", "ggp_recv_image_handler: got image with crc32: %u\n", ev->event.image_reply.crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1321 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1322 | while(entry) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1323 | if (strstr((gchar *)entry->data, handlerid) != NULL) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1324 | gchar **split = g_strsplit((gchar *)entry->data, handlerid, 3); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1325 | gchar *text = g_strdup_printf("%s%i%s", split[0], imgid, split[1]); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1326 | purple_debug_info("gg", "ggp_recv_image_handler: found message matching crc32: %s\n", (gchar *)entry->data); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1327 | g_strfreev(split); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1328 | info->pending_richtext_messages = g_list_remove(info->pending_richtext_messages, entry->data); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1329 | /* We don't have any more images to download */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1330 | if (strstr(text, "<IMG ID=\"IMGID_HANDLER") == NULL) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1331 | gchar *buf = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1332 | serv_got_im(gc, buf, text, PURPLE_MESSAGE_IMAGES, ev->event.msg.time); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1333 | g_free(buf); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1334 | purple_debug_info("gg", "ggp_recv_image_handler: richtext message: %s\n", text); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1335 | g_free(text); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1336 | break; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1337 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1338 | info->pending_richtext_messages = g_list_append(info->pending_richtext_messages, text); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1339 | break; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1340 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1341 | entry = g_list_next(entry); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1342 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1343 | g_free(handlerid); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1344 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1345 | return; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1346 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1347 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1348 | |
| 11414 | 1349 | /** |
| 1350 | * Dispatch a message received from a buddy. | |
| 1351 | * | |
| 15884 | 1352 | * @param gc PurpleConnection. |
| 11414 | 1353 | * @param ev Gadu-Gadu event structure. |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1354 | * |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1355 | * Image receiving, some code borrowed from Kadu http://www.kadu.net |
| 11414 | 1356 | */ |
| 15884 | 1357 | static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) |
| 11414 | 1358 | { |
| 1359 | GGPInfo *info = gc->proto_data; | |
| 15884 | 1360 | PurpleConversation *conv; |
| 11414 | 1361 | gchar *from; |
| 1362 | gchar *msg; | |
| 1363 | gchar *tmp; | |
| 1364 | ||
| 1365 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 1366 | ||
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1367 | /* |
| 12961 | 1368 | tmp = charset_convert((const char *)ev->event.msg.message, |
| 12007 | 1369 | "CP1250", "UTF-8"); |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1370 | */ |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1371 | tmp = g_strdup_printf("%s", ev->event.msg.message); |
| 15884 | 1372 | purple_str_strip_char(tmp, '\r'); |
| 12961 | 1373 | msg = g_markup_escape_text(tmp, -1); |
| 1374 | g_free(tmp); | |
| 11414 | 1375 | |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1376 | /* We got richtext message */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1377 | if (ev->event.msg.formats_length) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1378 | { |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
1379 | gboolean got_image = FALSE, bold = FALSE, italic = FALSE, under = FALSE; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1380 | char *cformats = (char *)ev->event.msg.formats; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1381 | char *cformats_end = cformats + ev->event.msg.formats_length; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1382 | gint increased_len = 0; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1383 | struct gg_msg_richtext_format *actformat; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1384 | struct gg_msg_richtext_image *actimage; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1385 | GString *message = g_string_new(msg); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1386 | gchar *handlerid; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1387 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1388 | purple_debug_info("gg", "ggp_recv_message_handler: richtext msg from (%s): %s %i formats\n", from, msg, ev->event.msg.formats_length); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1389 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1390 | while (cformats < cformats_end) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1391 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1392 | gint byteoffset; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1393 | actformat = (struct gg_msg_richtext_format *)cformats; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1394 | cformats += sizeof(struct gg_msg_richtext_format); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1395 | byteoffset = g_utf8_offset_to_pointer(message->str, actformat->position + increased_len) - message->str; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1396 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1397 | if(actformat->position == 0 && actformat->font == 0) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1398 | purple_debug_warning("gg", "ggp_recv_message_handler: bogus formatting (inc: %i)\n", increased_len); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1399 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1400 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1401 | purple_debug_info("gg", "ggp_recv_message_handler: format at pos: %i, image:%i, bold:%i, italic: %i, under:%i (inc: %i)\n", |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1402 | actformat->position, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1403 | (actformat->font & GG_FONT_IMAGE) != 0, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1404 | (actformat->font & GG_FONT_BOLD) != 0, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1405 | (actformat->font & GG_FONT_ITALIC) != 0, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1406 | (actformat->font & GG_FONT_UNDERLINE) != 0, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1407 | increased_len); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1408 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1409 | if (actformat->font & GG_FONT_IMAGE) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1410 | got_image = TRUE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1411 | actimage = (struct gg_msg_richtext_image*)(cformats); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1412 | cformats += sizeof(struct gg_msg_richtext_image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1413 | purple_debug_info("gg", "ggp_recv_message_handler: image received, size: %d, crc32: %i\n", actimage->size, actimage->crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1414 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1415 | /* Checking for errors, image size shouldn't be |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1416 | * larger than 255.000 bytes */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1417 | if (actimage->size > 255000) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1418 | purple_debug_warning("gg", "ggp_recv_message_handler: received image large than 255 kb\n"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1419 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1420 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1421 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1422 | gg_image_request(info->session, ev->event.msg.sender, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1423 | actimage->size, actimage->crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1424 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1425 | handlerid = g_strdup_printf("<IMG ID=\"IMGID_HANDLER-%i\">", actimage->crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1426 | g_string_insert(message, byteoffset, handlerid); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1427 | increased_len += strlen(handlerid); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1428 | g_free(handlerid); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1429 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1430 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1431 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1432 | if (actformat->font & GG_FONT_BOLD) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1433 | if (bold == FALSE) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1434 | g_string_insert(message, byteoffset, "<b>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1435 | increased_len += 3; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1436 | bold = TRUE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1437 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1438 | } else if (bold) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1439 | g_string_insert(message, byteoffset, "</b>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1440 | increased_len += 4; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1441 | bold = FALSE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1442 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1443 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1444 | if (actformat->font & GG_FONT_ITALIC) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1445 | if (italic == FALSE) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1446 | g_string_insert(message, byteoffset, "<i>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1447 | increased_len += 3; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1448 | italic = TRUE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1449 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1450 | } else if (italic) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1451 | g_string_insert(message, byteoffset, "</i>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1452 | increased_len += 4; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1453 | italic = FALSE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1454 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1455 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1456 | if (actformat->font & GG_FONT_UNDERLINE) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1457 | if (under == FALSE) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1458 | g_string_insert(message, byteoffset, "<u>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1459 | increased_len += 3; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1460 | under = TRUE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1461 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1462 | } else if (under) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1463 | g_string_insert(message, byteoffset, "</u>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1464 | increased_len += 4; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1465 | under = FALSE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1466 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1467 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1468 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1469 | msg = message->str; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1470 | g_string_free(message, FALSE); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1471 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1472 | if (got_image) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1473 | info->pending_richtext_messages = g_list_append(info->pending_richtext_messages, msg); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1474 | return; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1475 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1476 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1477 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1478 | purple_debug_info("gg", "ggp_recv_message_handler: msg from (%s): %s (class = %d; rcpt_count = %d)\n", |
| 12961 | 1479 | from, msg, ev->event.msg.msgclass, |
| 12007 | 1480 | ev->event.msg.recipients_count); |
| 11414 | 1481 | |
| 1482 | if (ev->event.msg.recipients_count == 0) { | |
| 12961 | 1483 | serv_got_im(gc, from, msg, 0, ev->event.msg.time); |
| 11414 | 1484 | } else { |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1485 | const char *chat_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1486 | int chat_id; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1487 | char *buddy_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1488 | |
| 11414 | 1489 | chat_name = ggp_confer_find_by_participants(gc, |
| 12007 | 1490 | ev->event.msg.recipients, |
| 1491 | ev->event.msg.recipients_count); | |
| 12961 | 1492 | |
| 11414 | 1493 | if (chat_name == NULL) { |
| 1494 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 1495 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 12007 | 1496 | |
| 1497 | ggp_confer_participants_add_uin(gc, chat_name, | |
| 1498 | ev->event.msg.sender); | |
| 1499 | ||
| 1500 | ggp_confer_participants_add(gc, chat_name, | |
| 1501 | ev->event.msg.recipients, | |
| 1502 | ev->event.msg.recipients_count); | |
| 11414 | 1503 | } |
| 1504 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 15884 | 1505 | 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
|
1506 | |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1507 | buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1508 | serv_got_chat_in(gc, chat_id, buddy_name, |
| 15884 | 1509 | PURPLE_MESSAGE_RECV, msg, ev->event.msg.time); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1510 | g_free(buddy_name); |
| 11414 | 1511 | } |
| 12961 | 1512 | g_free(msg); |
| 11414 | 1513 | g_free(from); |
| 1514 | } | |
| 1515 | ||
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1516 | static void ggp_send_image_handler(PurpleConnection *gc, const struct gg_event *ev) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1517 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1518 | GGPInfo *info = gc->proto_data; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1519 | PurpleStoredImage *image; |
|
24747
498c6dda6e48
Fix two warnings introduced by the image patch I committed earlier and make
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24746
diff
changeset
|
1520 | gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, &ev->event.image_request.crc32)); |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1521 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1522 | purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u\n", ev->event.image_request.crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1523 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1524 | if(imgid) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1525 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1526 | if((image = purple_imgstore_find_by_id(imgid))) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1527 | gint image_size = purple_imgstore_get_size(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1528 | gconstpointer image_bin = purple_imgstore_get_data(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1529 | const char *image_filename = purple_imgstore_get_filename(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1530 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1531 | purple_debug_info("gg", "ggp_send_image_handler: sending image imgid: %i, crc: %u\n", imgid, ev->event.image_request.crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1532 | gg_image_reply(info->session, (unsigned long int)ev->event.image_request.sender, image_filename, image_bin, image_size); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1533 | purple_imgstore_unref(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1534 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1535 | purple_debug_error("gg", "ggp_send_image_handler: image imgid: %i, crc: %u in hash but not found in imgstore!\n", imgid, ev->event.image_request.crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1536 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1537 | g_hash_table_remove(info->pending_images, &ev->event.image_request.crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1538 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1539 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1540 | |
| 15884 | 1541 | static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) |
| 11414 | 1542 | { |
| 15884 | 1543 | PurpleConnection *gc = _gc; |
| 11414 | 1544 | GGPInfo *info = gc->proto_data; |
| 1545 | struct gg_event *ev; | |
| 1546 | int i; | |
| 1547 | ||
| 1548 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1549 | purple_debug_error("gg", |
| 12007 | 1550 | "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); |
| 21279 | 1551 | purple_connection_error_reason (gc, |
| 1552 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1553 | _("Unable to read from socket")); |
| 11414 | 1554 | return; |
| 1555 | } | |
|
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
|
1556 | gc->last_received = time(NULL); |
| 11414 | 1557 | switch (ev->type) { |
| 1558 | case GG_EVENT_NONE: | |
| 1559 | /* Nothing happened. */ | |
| 1560 | break; | |
| 1561 | case GG_EVENT_MSG: | |
| 1562 | ggp_recv_message_handler(gc, ev); | |
| 1563 | break; | |
| 1564 | case GG_EVENT_ACK: | |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1565 | /* Changing %u to %i fixes compiler warning */ |
| 15884 | 1566 | purple_debug_info("gg", |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1567 | "ggp_callback_recv: message sent to: %i, delivery status=%d, seq=%d\n", |
| 12007 | 1568 | ev->event.ack.recipient, ev->event.ack.status, |
| 1569 | ev->event.ack.seq); | |
| 11414 | 1570 | break; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1571 | case GG_EVENT_IMAGE_REPLY: |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1572 | ggp_recv_image_handler(gc, ev); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1573 | break; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1574 | case GG_EVENT_IMAGE_REQUEST: |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1575 | ggp_send_image_handler(gc, ev); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1576 | break; |
| 11414 | 1577 | case GG_EVENT_NOTIFY: |
| 1578 | case GG_EVENT_NOTIFY_DESCR: | |
| 1579 | { | |
| 1580 | struct gg_notify_reply *n; | |
| 1581 | char *descr; | |
| 1582 | ||
| 15884 | 1583 | purple_debug_info("gg", "notify_pre: (%d) status: %d\n", |
| 11414 | 1584 | ev->event.notify->uin, |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1585 | GG_S(ev->event.notify->status)); |
| 11414 | 1586 | |
| 1587 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 1588 | : ev->event.notify_descr.notify; | |
| 1589 | ||
| 1590 | for (; n->uin; n++) { | |
| 1591 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 12007 | 1592 | : ev->event.notify_descr.descr; |
| 1593 | ||
| 15884 | 1594 | purple_debug_info("gg", |
| 12007 | 1595 | "notify: (%d) status: %d; descr: %s\n", |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1596 | n->uin, GG_S(n->status), descr ? descr : "(null)"); |
| 11414 | 1597 | |
| 1598 | ggp_generic_status_handler(gc, | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1599 | n->uin, GG_S(n->status), descr); |
| 11414 | 1600 | } |
| 1601 | } | |
| 1602 | break; | |
| 1603 | case GG_EVENT_NOTIFY60: | |
| 1604 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 15884 | 1605 | purple_debug_info("gg", |
| 12007 | 1606 | "notify60: (%d) status=%d; version=%d; descr=%s\n", |
| 1607 | ev->event.notify60[i].uin, | |
|
30006
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1608 | GG_S(ev->event.notify60[i].status), |
| 12007 | 1609 | ev->event.notify60[i].version, |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1610 | ev->event.notify60[i].descr ? ev->event.notify60[i].descr : "(null)"); |
| 11414 | 1611 | |
| 12007 | 1612 | ggp_generic_status_handler(gc, ev->event.notify60[i].uin, |
|
30006
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1613 | GG_S(ev->event.notify60[i].status), |
| 12007 | 1614 | ev->event.notify60[i].descr); |
| 11414 | 1615 | } |
| 1616 | break; | |
| 1617 | case GG_EVENT_STATUS: | |
| 15884 | 1618 | purple_debug_info("gg", "status: (%d) status=%d; descr=%s\n", |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1619 | ev->event.status.uin, GG_S(ev->event.status.status), |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1620 | ev->event.status.descr ? ev->event.status.descr : "(null)"); |
| 11414 | 1621 | |
| 12007 | 1622 | ggp_generic_status_handler(gc, ev->event.status.uin, |
|
30006
3587e1e5fbe5
gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29824
diff
changeset
|
1623 | GG_S(ev->event.status.status), ev->event.status.descr); |
| 11414 | 1624 | break; |
| 1625 | case GG_EVENT_STATUS60: | |
| 15884 | 1626 | purple_debug_info("gg", |
| 12007 | 1627 | "status60: (%d) status=%d; version=%d; descr=%s\n", |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1628 | ev->event.status60.uin, GG_S(ev->event.status60.status), |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1629 | ev->event.status60.version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1630 | ev->event.status60.descr ? ev->event.status60.descr : "(null)"); |
| 11414 | 1631 | |
| 12007 | 1632 | ggp_generic_status_handler(gc, ev->event.status60.uin, |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1633 | GG_S(ev->event.status60.status), ev->event.status60.descr); |
| 11414 | 1634 | break; |
| 1635 | case GG_EVENT_USERLIST: | |
| 1636 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 15884 | 1637 | purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); |
| 1638 | purple_notify_info(gc, NULL, | |
| 12220 | 1639 | _("Buddy list downloaded"), |
| 1640 | _("Your buddy list was downloaded from the server.")); | |
| 11414 | 1641 | if (ev->event.userlist.reply != NULL) { |
| 12007 | 1642 | ggp_buddylist_load(gc, ev->event.userlist.reply); |
| 11414 | 1643 | } |
| 1644 | } else { | |
| 15884 | 1645 | purple_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
| 1646 | purple_notify_info(gc, NULL, | |
| 12220 | 1647 | _("Buddy list uploaded"), |
| 1648 | _("Your buddy list was stored on the server.")); | |
| 11414 | 1649 | } |
| 1650 | break; | |
| 1651 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 12007 | 1652 | ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
| 1653 | break; | |
| 1654 | default: | |
| 15884 | 1655 | purple_debug_error("gg", |
| 12007 | 1656 | "unsupported event type=%d\n", ev->type); |
| 1657 | break; | |
| 1658 | } | |
| 11414 | 1659 | |
| 12007 | 1660 | gg_free_event(ev); |
| 1661 | } | |
| 11414 | 1662 | |
| 15884 | 1663 | static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) |
| 12007 | 1664 | { |
| 15884 | 1665 | PurpleConnection *gc = _gc; |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1666 | GGPInfo *info; |
| 12007 | 1667 | struct gg_event *ev; |
| 11414 | 1668 | |
| 15884 | 1669 | g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1670 | |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1671 | info = gc->proto_data; |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1672 | |
| 15884 | 1673 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
| 12007 | 1674 | info->session->check, info->session->state); |
| 11414 | 1675 | |
| 12007 | 1676 | switch (info->session->state) { |
| 1677 | case GG_STATE_RESOLVING: | |
| 15884 | 1678 | purple_debug_info("gg", "GG_STATE_RESOLVING\n"); |
| 12007 | 1679 | break; |
| 1680 | case GG_STATE_CONNECTING_HUB: | |
| 15884 | 1681 | purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); |
| 12007 | 1682 | break; |
| 1683 | case GG_STATE_READING_DATA: | |
| 15884 | 1684 | purple_debug_info("gg", "GG_STATE_READING_DATA\n"); |
| 12007 | 1685 | break; |
| 1686 | case GG_STATE_CONNECTING_GG: | |
| 15884 | 1687 | purple_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); |
| 12007 | 1688 | break; |
| 1689 | case GG_STATE_READING_KEY: | |
| 15884 | 1690 | purple_debug_info("gg", "GG_STATE_READING_KEY\n"); |
| 12007 | 1691 | break; |
| 1692 | case GG_STATE_READING_REPLY: | |
| 15884 | 1693 | purple_debug_info("gg", "GG_STATE_READING_REPLY\n"); |
| 11414 | 1694 | break; |
| 1695 | default: | |
| 15884 | 1696 | purple_debug_error("gg", "unknown state = %d\n", |
| 12007 | 1697 | info->session->state); |
| 1698 | break; | |
| 1699 | } | |
| 1700 | ||
| 1701 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1702 | purple_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); |
| 21279 | 1703 | purple_connection_error_reason (gc, |
| 1704 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1705 | _("Unable to read from socket")); |
| 12007 | 1706 | return; |
| 1707 | } | |
| 15884 | 1708 | purple_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); |
| 1709 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | |
| 12007 | 1710 | info->session->check, info->session->state); |
| 1711 | ||
| 15884 | 1712 | purple_input_remove(gc->inpa); |
| 12007 | 1713 | |
| 1714 | /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ | |
| 15884 | 1715 | gc->inpa = purple_input_add(info->session->fd, |
| 1716 | (info->session->check == 1) ? PURPLE_INPUT_WRITE | |
| 1717 | : PURPLE_INPUT_READ, | |
| 12007 | 1718 | ggp_async_login_handler, gc); |
| 1719 | ||
| 1720 | switch (ev->type) { | |
| 1721 | case GG_EVENT_NONE: | |
| 1722 | /* Nothing happened. */ | |
| 15884 | 1723 | purple_debug_info("gg", "GG_EVENT_NONE\n"); |
| 12007 | 1724 | break; |
| 1725 | case GG_EVENT_CONN_SUCCESS: | |
| 12964 | 1726 | { |
| 15884 | 1727 | purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); |
| 1728 | purple_input_remove(gc->inpa); | |
| 1729 | gc->inpa = purple_input_add(info->session->fd, | |
| 1730 | PURPLE_INPUT_READ, | |
| 12964 | 1731 | ggp_callback_recv, gc); |
|
27642
6ae79601ad84
Patch from kkszysiu to make the GG prpl support
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27626
diff
changeset
|
1732 | |
|
6ae79601ad84
Patch from kkszysiu to make the GG prpl support
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27626
diff
changeset
|
1733 | ggp_buddylist_send(gc); |
|
6ae79601ad84
Patch from kkszysiu to make the GG prpl support
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27626
diff
changeset
|
1734 | purple_connection_update_progress(gc, _("Connected"), 2, 2); |
| 15884 | 1735 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
| 12964 | 1736 | } |
| 12007 | 1737 | break; |
| 1738 | case GG_EVENT_CONN_FAILED: | |
| 15884 | 1739 | purple_input_remove(gc->inpa); |
| 12007 | 1740 | 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
|
1741 | purple_connection_error_reason (gc, |
| 21279 | 1742 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1743 | _("Connection failed")); |
| 12007 | 1744 | break; |
| 1745 | default: | |
| 15884 | 1746 | purple_debug_error("gg", "strange event: %d\n", ev->type); |
| 11414 | 1747 | break; |
| 1748 | } | |
| 1749 | ||
| 1750 | gg_free_event(ev); | |
| 1751 | } | |
| 1752 | ||
| 1753 | /* ---------------------------------------------------------------------- */ | |
| 15884 | 1754 | /* ----- PurplePluginProtocolInfo ----------------------------------------- */ |
| 11360 | 1755 | /* ---------------------------------------------------------------------- */ |
| 1756 | ||
| 15884 | 1757 | static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) |
| 11360 | 1758 | { |
| 1759 | return "gadu-gadu"; | |
| 1760 | } | |
| 1761 | ||
| 15884 | 1762 | static char *ggp_status_text(PurpleBuddy *b) |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1763 | { |
| 15884 | 1764 | PurpleStatus *status; |
| 11360 | 1765 | const char *msg; |
| 1766 | char *text; | |
| 1767 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1768 | |
| 15884 | 1769 | 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
|
1770 | |
| 15884 | 1771 | msg = purple_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1772 | |
| 11360 | 1773 | if (msg != NULL) { |
| 15884 | 1774 | tmp = purple_markup_strip_html(msg); |
| 11360 | 1775 | text = g_markup_escape_text(tmp, -1); |
| 1776 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1777 | |
| 11360 | 1778 | return text; |
| 1779 | } else { | |
| 15884 | 1780 | tmp = purple_utf8_salvage(purple_status_get_name(status)); |
| 11360 | 1781 | text = g_markup_escape_text(tmp, -1); |
| 1782 | g_free(tmp); | |
| 1783 | ||
| 1784 | return text; | |
| 8997 | 1785 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1786 | } |
|
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1787 | |
| 15884 | 1788 | static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 11360 | 1789 | { |
| 15884 | 1790 | PurpleStatus *status; |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1791 | char *text, *tmp; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1792 | const char *msg, *name, *alias; |
| 11360 | 1793 | |
| 15005 | 1794 | g_return_if_fail(b != NULL); |
| 1795 | ||
| 15884 | 1796 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
| 1797 | msg = purple_status_get_attr_string(status, "message"); | |
| 1798 | name = purple_status_get_name(status); | |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1799 | alias = purple_buddy_get_alias(b); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1800 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1801 | purple_notify_user_info_add_pair (user_info, _("Alias"), alias); |
| 11360 | 1802 | |
| 1803 | if (msg != NULL) { | |
| 13455 | 1804 | text = g_markup_escape_text(msg, -1); |
| 15884 | 1805 | if (PURPLE_BUDDY_IS_ONLINE(b)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1806 | tmp = g_strdup_printf("%s: %s", name, text); |
| 15884 | 1807 | purple_notify_user_info_add_pair(user_info, _("Status"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1808 | g_free(tmp); |
| 15196 | 1809 | } else { |
| 15884 | 1810 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15196 | 1811 | } |
| 11360 | 1812 | g_free(text); |
| 15227 | 1813 | /* We don't want to duplicate 'Status: Offline'. */ |
| 15884 | 1814 | } else if (PURPLE_BUDDY_IS_ONLINE(b)) { |
| 1815 | purple_notify_user_info_add_pair(user_info, _("Status"), name); | |
| 11360 | 1816 | } |
| 1817 | } | |
| 1818 | ||
| 15884 | 1819 | static GList *ggp_status_types(PurpleAccount *account) |
| 11360 | 1820 | { |
| 15884 | 1821 | PurpleStatusType *type; |
| 11360 | 1822 | GList *types = NULL; |
| 1823 | ||
| 15884 | 1824 | type = purple_status_type_new_with_attrs( |
| 1825 | PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1826 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1827 | NULL); |
| 11360 | 1828 | types = g_list_append(types, type); |
| 1829 | ||
| 1830 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1831 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1832 | * work. It's not used and not needed to show status of buddies. |
| 1833 | */ | |
| 15884 | 1834 | type = purple_status_type_new_with_attrs( |
| 1835 | PURPLE_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1836 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1837 | NULL); |
| 11360 | 1838 | types = g_list_append(types, type); |
| 1839 | ||
| 15884 | 1840 | type = purple_status_type_new_with_attrs( |
| 1841 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1842 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1843 | NULL); |
| 11360 | 1844 | types = g_list_append(types, type); |
| 1845 | ||
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1846 | /* |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1847 | * New statuses for GG 8.0 like PoGGadaj ze mna (not yet because |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1848 | * libpurple can't support Chatty status) and Nie przeszkadzac |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1849 | */ |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1850 | type = purple_status_type_new_with_attrs( |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1851 | PURPLE_STATUS_UNAVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1852 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1853 | NULL); |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1854 | types = g_list_append(types, type); |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1855 | |
| 12964 | 1856 | /* |
| 1857 | * This status is necessary to display guys who are blocking *us*. | |
| 1858 | */ | |
| 15884 | 1859 | type = purple_status_type_new_with_attrs( |
| 1860 | PURPLE_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, | |
| 1861 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); | |
| 11360 | 1862 | types = g_list_append(types, type); |
| 1863 | ||
| 15884 | 1864 | type = purple_status_type_new_with_attrs( |
| 1865 | PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1866 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1867 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1868 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1869 | |
| 11360 | 1870 | return types; |
| 1871 | } | |
| 1872 | ||
| 15884 | 1873 | static GList *ggp_blist_node_menu(PurpleBlistNode *node) |
| 2393 | 1874 | { |
| 15884 | 1875 | PurpleMenuAction *act; |
| 2393 | 1876 | GList *m = NULL; |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1877 | PurpleAccount *account; |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1878 | GGPInfo *info; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1879 | |
| 15884 | 1880 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
| 11360 | 1881 | return NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1882 | |
|
25430
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1883 | account = purple_buddy_get_account((PurpleBuddy *) node); |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1884 | info = purple_account_get_connection(account)->proto_data; |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1885 | if (info->chats) { |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1886 | act = purple_menu_action_new(_("Add to chat"), |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1887 | PURPLE_CALLBACK(ggp_bmenu_add_to_chat), |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1888 | NULL, NULL); |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1889 | m = g_list_append(m, act); |
|
78be70c986d3
Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
Daniel Atallah <datallah@pidgin.im>
parents:
24747
diff
changeset
|
1890 | } |
| 11410 | 1891 | |
| 12641 | 1892 | /* Using a blist node boolean here is also wrong. |
| 1893 | * Once the Block and Unblock actions are added to the core, | |
| 1894 | * this will have to go. -- rlaager */ | |
| 15884 | 1895 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 1896 | act = purple_menu_action_new(_("Unblock"), | |
| 1897 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1898 | NULL, NULL); |
| 12007 | 1899 | } else { |
| 15884 | 1900 | act = purple_menu_action_new(_("Block"), |
| 1901 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1902 | NULL, NULL); |
| 12007 | 1903 | } |
| 11394 | 1904 | m = g_list_append(m, act); |
| 2393 | 1905 | |
| 1906 | return m; | |
| 1907 | } | |
| 1908 | ||
| 15884 | 1909 | static GList *ggp_chat_info(PurpleConnection *gc) |
| 11394 | 1910 | { |
| 1911 | GList *m = NULL; | |
| 1912 | struct proto_chat_entry *pce; | |
| 1913 | ||
| 1914 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1915 | pce->label = _("Chat _name:"); | |
| 1916 | pce->identifier = "name"; | |
| 1917 | pce->required = TRUE; | |
| 1918 | m = g_list_append(m, pce); | |
| 1919 | ||
| 1920 | return m; | |
| 1921 | } | |
| 1922 | ||
| 15884 | 1923 | static void ggp_login(PurpleAccount *account) |
| 2393 | 1924 | { |
| 15884 | 1925 | PurpleConnection *gc; |
|
23382
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1926 | PurplePresence *presence; |
|
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1927 | PurpleStatus *status; |
| 13515 | 1928 | struct gg_login_params *glp; |
| 1929 | GGPInfo *info; | |
|
27255
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1930 | const char *address; |
| 13515 | 1931 | |
| 1932 | if (ggp_setup_proxy(account) == -1) | |
| 1933 | return; | |
| 1934 | ||
| 15884 | 1935 | gc = purple_account_get_connection(account); |
| 13515 | 1936 | glp = g_new0(struct gg_login_params, 1); |
| 1937 | info = g_new0(GGPInfo, 1); | |
| 11360 | 1938 | |
| 12007 | 1939 | /* Probably this should be moved to *_new() function. */ |
| 11360 | 1940 | info->session = NULL; |
| 11394 | 1941 | info->chats = NULL; |
| 1942 | info->chats_count = 0; | |
| 12007 | 1943 | info->token = NULL; |
| 13641 | 1944 | info->searches = ggp_search_new(); |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1945 | info->pending_richtext_messages = NULL; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1946 | info->pending_images = g_hash_table_new(g_int_hash, g_int_equal); |
| 11360 | 1947 | |
| 1948 | gc->proto_data = info; | |
| 1949 | ||
| 1950 | glp->uin = ggp_get_uin(account); | |
| 15884 | 1951 | glp->password = (char *)purple_account_get_password(account); |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1952 | glp->image_size = 255; |
| 11360 | 1953 | |
|
23382
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1954 | presence = purple_account_get_presence(account); |
|
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1955 | status = purple_presence_get_active_status(presence); |
|
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1956 | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1957 | glp->encoding = GG_ENCODING_UTF8; |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1958 | glp->protocol_features = (GG_FEATURE_STATUS80|GG_FEATURE_DND_FFC); |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
1959 | |
| 12007 | 1960 | glp->async = 1; |
|
23382
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1961 | glp->status = ggp_to_gg_status(status, &glp->status_descr); |
| 11360 | 1962 | glp->tls = 0; |
| 1963 | ||
|
27255
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1964 | address = purple_account_get_string(account, "gg_server", ""); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1965 | if (address && *address) { |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1966 | /* TODO: Make this non-blocking */ |
|
27255
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1967 | struct in_addr *addr = gg_gethostbyname(address); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1968 | |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1969 | purple_debug_info("gg", "Using gg server given by user (%s)\n", address); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1970 | |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1971 | if (addr == NULL) { |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1972 | gchar *tmp = g_strdup_printf(_("Unable to resolve hostname '%s': %s"), |
|
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1973 | address, g_strerror(errno)); |
|
27255
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1974 | purple_connection_error_reason(gc, |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1975 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, /* should this be a settings error? */ |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1976 | tmp); |
|
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1977 | g_free(tmp); |
|
27255
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1978 | return; |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1979 | } |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1980 | |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1981 | glp->server_addr = inet_addr(inet_ntoa(*addr)); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1982 | glp->server_port = 8074; |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1983 | } else |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1984 | purple_debug_info("gg", "Trying to retrieve address from gg appmsg service\n"); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
1985 | |
| 11360 | 1986 | info->session = gg_login(glp); |
|
27642
6ae79601ad84
Patch from kkszysiu to make the GG prpl support
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27626
diff
changeset
|
1987 | purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
| 11360 | 1988 | if (info->session == NULL) { |
| 21279 | 1989 | purple_connection_error_reason (gc, |
| 1990 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
1991 | _("Connection failed")); |
| 11360 | 1992 | g_free(glp); |
| 1993 | return; | |
| 1994 | } | |
| 15884 | 1995 | gc->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ, |
| 12007 | 1996 | ggp_async_login_handler, gc); |
| 11360 | 1997 | } |
| 1998 | ||
| 15884 | 1999 | static void ggp_close(PurpleConnection *gc) |
| 11360 | 2000 | { |
| 8997 | 2001 | |
| 11360 | 2002 | if (gc == NULL) { |
| 15884 | 2003 | purple_debug_info("gg", "gc == NULL\n"); |
| 11360 | 2004 | return; |
| 2005 | } | |
| 2006 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2007 | if (gc->proto_data) { |
| 15884 | 2008 | PurpleAccount *account = purple_connection_get_account(gc); |
| 2009 | PurpleStatus *status; | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2010 | GGPInfo *info = gc->proto_data; |
| 12964 | 2011 | |
| 15884 | 2012 | status = purple_account_get_active_status(account); |
| 12964 | 2013 | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2014 | if (info->session != NULL) { |
| 12964 | 2015 | ggp_set_status(account, status); |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2016 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2017 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2018 | } |
| 13641 | 2019 | |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
2020 | /* Immediately close any notifications on this handle since that process depends |
|
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
2021 | * 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
|
2022 | */ |
| 15884 | 2023 | purple_notify_close_with_handle(gc); |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
2024 | |
| 13641 | 2025 | ggp_search_destroy(info->searches); |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2026 | g_list_free(info->pending_richtext_messages); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2027 | g_hash_table_destroy(info->pending_images); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
2028 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
2029 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
2030 | } |
| 11360 | 2031 | |
| 2032 | if (gc->inpa > 0) | |
| 15884 | 2033 | purple_input_remove(gc->inpa); |
| 11360 | 2034 | |
| 15884 | 2035 | purple_debug_info("gg", "Connection closed.\n"); |
| 11360 | 2036 | } |
| 2037 | ||
| 15884 | 2038 | static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, |
| 2039 | PurpleMessageFlags flags) | |
| 11360 | 2040 | { |
| 2041 | GGPInfo *info = gc->proto_data; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2042 | char *tmp, *plain; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2043 | int ret = 1; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2044 | unsigned char format[1024]; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2045 | unsigned int format_length = sizeof(struct gg_msg_richtext); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2046 | gint pos = 0; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2047 | GData *attribs; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2048 | const char *start, *end = NULL, *last; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2049 | |
|
24747
498c6dda6e48
Fix two warnings introduced by the image patch I committed earlier and make
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24746
diff
changeset
|
2050 | if (msg == NULL || *msg == '\0') { |
| 15287 | 2051 | return 0; |
| 2052 | } | |
| 2053 | ||
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2054 | last = msg; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2055 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2056 | /* Check if the message is richtext */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2057 | /* TODO: Check formatting, too */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2058 | if(purple_markup_find_tag("img", last, &start, &end, &attribs)) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2059 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2060 | GString *string_buffer = g_string_new(NULL); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2061 | struct gg_msg_richtext fmt; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2062 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2063 | do { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2064 | PurpleStoredImage *image; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2065 | const char *id; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2066 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2067 | /* Add text before the image */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2068 | if(start - last) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2069 | pos = pos + g_utf8_strlen(last, start - last); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2070 | g_string_append_len(string_buffer, last, start - last); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2071 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2072 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2073 | if((id = g_datalist_get_data(&attribs, "id")) && (image = purple_imgstore_find_by_id(atoi(id)))) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2074 | struct gg_msg_richtext_format actformat; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2075 | struct gg_msg_richtext_image actimage; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2076 | gint image_size = purple_imgstore_get_size(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2077 | gconstpointer image_bin = purple_imgstore_get_data(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2078 | const char *image_filename = purple_imgstore_get_filename(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2079 | uint32_t crc32 = gg_crc32(0, image_bin, image_size); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2080 | |
|
24747
498c6dda6e48
Fix two warnings introduced by the image patch I committed earlier and make
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24746
diff
changeset
|
2081 | g_hash_table_insert(info->pending_images, &crc32, GINT_TO_POINTER(atoi(id))); |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2082 | purple_imgstore_ref(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2083 | purple_debug_info("gg", "ggp_send_im_richtext: got crc: %i for imgid: %i\n", crc32, atoi(id)); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2084 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2085 | actformat.font = GG_FONT_IMAGE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2086 | actformat.position = pos; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2087 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2088 | actimage.unknown1 = 0x0109; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2089 | actimage.size = gg_fix32(image_size); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2090 | actimage.crc32 = gg_fix32(crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2091 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2092 | if (actimage.size > 255000) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2093 | purple_debug_warning("gg", "ggp_send_im_richtext: image over 255kb!\n"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2094 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2095 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2096 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2097 | purple_debug_info("gg", "ggp_send_im_richtext: adding images to richtext, size: %i, crc32: %u, name: %s\n", actimage.size, actimage.crc32, image_filename); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2098 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2099 | memcpy(format + format_length, &actformat, sizeof(actformat)); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2100 | format_length += sizeof(actformat); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2101 | memcpy(format + format_length, &actimage, sizeof(actimage)); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2102 | format_length += sizeof(actimage); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2103 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2104 | purple_debug_error("gg", "ggp_send_im_richtext: image not found in the image store!"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2105 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2106 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2107 | last = end + 1; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2108 | g_datalist_clear(&attribs); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2109 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2110 | } while(purple_markup_find_tag("img", last, &start, &end, &attribs)); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2111 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2112 | /* Add text after the images */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2113 | if(last && *last) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2114 | pos = pos + g_utf8_strlen(last, -1); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2115 | g_string_append(string_buffer, last); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2116 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2117 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2118 | fmt.flag = 2; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2119 | fmt.length = format_length - sizeof(fmt); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2120 | memcpy(format, &fmt, sizeof(fmt)); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2121 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2122 | purple_debug_info("gg", "ggp_send_im: richtext msg = %s\n", string_buffer->str); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2123 | plain = purple_unescape_html(string_buffer->str); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2124 | g_string_free(string_buffer, TRUE); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2125 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2126 | purple_debug_info("gg", "ggp_send_im: msg = %s\n", msg); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2127 | plain = purple_unescape_html(msg); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2128 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2129 | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2130 | /* |
| 15287 | 2131 | tmp = charset_convert(plain, "UTF-8", "CP1250"); |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2132 | */ |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2133 | tmp = g_strdup_printf("%s", plain); |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2134 | |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2135 | if (tmp && (format_length - sizeof(struct gg_msg_richtext))) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2136 | if(gg_send_message_richtext(info->session, GG_CLASS_CHAT, ggp_str_to_uin(who), (unsigned char *)tmp, format, format_length) < 0) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2137 | ret = -1; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2138 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2139 | ret = 1; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2140 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2141 | } else if (NULL == tmp || *tmp == 0) { |
| 15287 | 2142 | ret = 0; |
| 2143 | } else if (strlen(tmp) > GG_MSG_MAXSIZE) { | |
| 2144 | ret = -E2BIG; | |
| 2145 | } else if (gg_send_message(info->session, GG_CLASS_CHAT, | |
| 2146 | ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { | |
| 2147 | ret = -1; | |
| 2148 | } else { | |
| 2149 | ret = 1; | |
| 2150 | } | |
| 2151 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2152 | g_free(plain); |
| 11565 | 2153 | g_free(tmp); |
| 11360 | 2154 | |
| 15287 | 2155 | return ret; |
| 11360 | 2156 | } |
| 2157 | ||
| 15884 | 2158 | static void ggp_get_info(PurpleConnection *gc, const char *name) |
| 11360 | 2159 | { |
| 2160 | GGPInfo *info = gc->proto_data; | |
| 2161 | GGPSearchForm *form; | |
| 13641 | 2162 | guint32 seq; |
| 2393 | 2163 | |
| 13641 | 2164 | form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); |
| 12220 | 2165 | |
| 13641 | 2166 | form->user_data = info; |
| 11360 | 2167 | form->uin = g_strdup(name); |
| 2168 | form->offset = g_strdup("0"); | |
| 2169 | form->last_uin = g_strdup("0"); | |
| 2170 | ||
| 13641 | 2171 | seq = ggp_search_start(gc, form); |
| 2172 | ggp_search_add(info->searches, seq, form); | |
|
23584
886e1611b952
Gadu-Gadu Get Info isn't behaving properly. Added debug logging to its traking
Evan Schoenberg <evands@pidgin.im>
parents:
23382
diff
changeset
|
2173 | purple_debug_info("gg", "ggp_get_info(): Added seq %u", seq); |
| 11360 | 2174 | } |
| 2175 | ||
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2176 | static int ggp_to_gg_status(PurpleStatus *status, char **msg) |
| 11360 | 2177 | { |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2178 | const char *status_id = purple_status_get_id(status); |
| 11360 | 2179 | int new_status, new_status_descr; |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2180 | const char *new_msg; |
| 11360 | 2181 | |
|
24043
47da129e16d1
Fixed an inverted g_return_val_if_fail() which caused gadu-gadu to always set an available status with no status message
Evan Schoenberg <evands@pidgin.im>
parents:
23584
diff
changeset
|
2182 | g_return_val_if_fail(msg != NULL, 0); |
| 11360 | 2183 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2184 | purple_debug_info("gg", "ggp_to_gg_status: Requested status = %s\n", |
| 12007 | 2185 | status_id); |
| 2393 | 2186 | |
| 11360 | 2187 | if (strcmp(status_id, "available") == 0) { |
| 2188 | new_status = GG_STATUS_AVAIL; | |
| 2189 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 2190 | } else if (strcmp(status_id, "away") == 0) { | |
| 2191 | new_status = GG_STATUS_BUSY; | |
| 2192 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2193 | } else if (strcmp(status_id, "unavailable") == 0) { |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2194 | new_status = GG_STATUS_DND; |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2195 | new_status_descr = GG_STATUS_DND_DESCR; |
| 11360 | 2196 | } else if (strcmp(status_id, "invisible") == 0) { |
| 2197 | new_status = GG_STATUS_INVISIBLE; | |
| 2198 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 12964 | 2199 | } else if (strcmp(status_id, "offline") == 0) { |
| 2200 | new_status = GG_STATUS_NOT_AVAIL; | |
| 2201 | new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; | |
| 11360 | 2202 | } else { |
| 2203 | new_status = GG_STATUS_AVAIL; | |
| 2204 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 15884 | 2205 | purple_debug_info("gg", |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2206 | "ggp_set_status: unknown status requested (status_id=%s)\n", |
| 12007 | 2207 | status_id); |
| 11360 | 2208 | } |
| 4916 | 2209 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2210 | new_msg = purple_status_get_attr_string(status, "message"); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2211 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2212 | if(new_msg) { |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2213 | /* |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2214 | char *tmp = purple_markup_strip_html(new_msg); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2215 | *msg = charset_convert(tmp, "UTF-8", "CP1250"); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2216 | g_free(tmp); |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2217 | */ |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2218 | *msg = purple_markup_strip_html(new_msg); |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2219 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2220 | return new_status_descr; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2221 | } else { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2222 | *msg = NULL; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2223 | return new_status; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2224 | } |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2225 | } |
| 11360 | 2226 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2227 | static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2228 | { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2229 | PurpleConnection *gc; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2230 | GGPInfo *info; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2231 | int new_status; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2232 | char *new_msg = NULL; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2233 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2234 | if (!purple_status_is_active(status)) |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2235 | return; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2236 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2237 | gc = purple_account_get_connection(account); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2238 | info = gc->proto_data; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2239 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2240 | new_status = ggp_to_gg_status(status, &new_msg); |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2241 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2242 | if (new_msg == NULL) { |
| 11360 | 2243 | gg_change_status(info->session, new_status); |
| 2244 | } else { | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2245 | gg_change_status_descr(info->session, new_status, new_msg); |
| 12964 | 2246 | g_free(new_msg); |
| 11360 | 2247 | } |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2248 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2249 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2250 | |
| 11360 | 2251 | } |
| 2252 | ||
| 15884 | 2253 | static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 11360 | 2254 | { |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2255 | PurpleAccount *account; |
| 11360 | 2256 | GGPInfo *info = gc->proto_data; |
|
24939
d25fdf62ae92
moved gg to use the api rather than structs directly
Gary Kramlich <grim@reaperworld.com>
parents:
24043
diff
changeset
|
2257 | const gchar *name = purple_buddy_get_name(buddy); |
| 11360 | 2258 | |
|
24939
d25fdf62ae92
moved gg to use the api rather than structs directly
Gary Kramlich <grim@reaperworld.com>
parents:
24043
diff
changeset
|
2259 | gg_add_notify(info->session, ggp_str_to_uin(name)); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2260 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2261 | account = purple_connection_get_account(gc); |
|
24939
d25fdf62ae92
moved gg to use the api rather than structs directly
Gary Kramlich <grim@reaperworld.com>
parents:
24043
diff
changeset
|
2262 | if (strcmp(purple_account_get_username(account), name) == 0) { |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2263 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2264 | } |
| 11360 | 2265 | } |
| 2266 | ||
| 15884 | 2267 | static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 2268 | PurpleGroup *group) | |
| 11360 | 2269 | { |
| 2270 | GGPInfo *info = gc->proto_data; | |
| 2271 | ||
|
24939
d25fdf62ae92
moved gg to use the api rather than structs directly
Gary Kramlich <grim@reaperworld.com>
parents:
24043
diff
changeset
|
2272 | gg_remove_notify(info->session, ggp_str_to_uin(purple_buddy_get_name(buddy))); |
| 11360 | 2273 | } |
| 2274 | ||
| 15884 | 2275 | static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) |
| 11394 | 2276 | { |
| 2277 | GGPInfo *info = gc->proto_data; | |
| 2278 | GGPChat *chat; | |
| 2279 | char *chat_name; | |
| 2280 | GList *l; | |
| 15884 | 2281 | PurpleConversation *conv; |
| 2282 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 11394 | 2283 | |
| 2284 | chat_name = g_hash_table_lookup(data, "name"); | |
| 2285 | ||
| 2286 | if (chat_name == NULL) | |
| 2287 | return; | |
| 2288 | ||
| 15884 | 2289 | purple_debug_info("gg", "joined %s chat\n", chat_name); |
| 11394 | 2290 | |
| 2291 | for (l = info->chats; l != NULL; l = l->next) { | |
| 2292 | chat = l->data; | |
| 2293 | ||
| 2294 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 15884 | 2295 | purple_notify_error(gc, _("Chat error"), |
| 12007 | 2296 | _("This chat name is already in use"), NULL); |
| 11394 | 2297 | return; |
| 2298 | } | |
| 2299 | } | |
| 2300 | ||
| 11414 | 2301 | ggp_confer_add_new(gc, chat_name); |
| 12961 | 2302 | conv = serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 15884 | 2303 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(conv), |
| 2304 | purple_account_get_username(account), NULL, | |
| 2305 | PURPLE_CBFLAGS_NONE, TRUE); | |
| 11394 | 2306 | } |
| 2307 | ||
| 2308 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 2309 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 2310 | } | |
| 2311 | ||
| 15884 | 2312 | static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) |
| 11394 | 2313 | { |
| 15884 | 2314 | PurpleConversation *conv; |
| 11394 | 2315 | GGPInfo *info = gc->proto_data; |
| 2316 | GGPChat *chat = NULL; | |
| 2317 | GList *l; | |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2318 | /* char *msg, *plain; */ |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2319 | gchar *msg; |
| 11394 | 2320 | uin_t *uins; |
| 2321 | int count = 0; | |
| 2322 | ||
| 15884 | 2323 | if ((conv = purple_find_chat(gc, id)) == NULL) |
| 11394 | 2324 | return -EINVAL; |
| 2325 | ||
| 2326 | for (l = info->chats; l != NULL; l = l->next) { | |
| 2327 | chat = l->data; | |
| 2328 | ||
| 2329 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 2330 | break; | |
| 2331 | } | |
| 2332 | ||
| 2333 | chat = NULL; | |
| 2334 | } | |
| 2335 | ||
| 2336 | if (chat == NULL) { | |
| 15884 | 2337 | purple_debug_error("gg", |
| 12007 | 2338 | "ggp_chat_send: Hm... that's strange. No such chat?\n"); |
| 11394 | 2339 | return -EINVAL; |
| 2340 | } | |
| 2341 | ||
| 2342 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 12961 | 2343 | |
| 11394 | 2344 | for (l = chat->participants; l != NULL; l = l->next) { |
| 12961 | 2345 | uin_t uin = GPOINTER_TO_INT(l->data); |
| 11394 | 2346 | |
| 12961 | 2347 | uins[count++] = uin; |
| 11394 | 2348 | } |
| 2349 | ||
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2350 | /* |
| 15884 | 2351 | plain = purple_unescape_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2352 | msg = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2353 | g_free(plain); |
|
29824
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2354 | */ |
|
9878119b5d78
Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents:
29404
diff
changeset
|
2355 | msg = purple_unescape_html(message); |
| 12007 | 2356 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
| 12961 | 2357 | (unsigned char *)msg); |
| 11394 | 2358 | g_free(msg); |
| 2359 | g_free(uins); | |
| 2360 | ||
| 12007 | 2361 | serv_got_chat_in(gc, id, |
| 15884 | 2362 | purple_account_get_username(purple_connection_get_account(gc)), |
|
23295
5d3a2fd59439
When calling serv_got_chat_in() after sending a group chat message (to let
Evan Schoenberg <evands@pidgin.im>
parents:
23277
diff
changeset
|
2363 | flags, message, time(NULL)); |
| 11394 | 2364 | |
| 2365 | return 0; | |
| 2366 | } | |
| 2367 | ||
| 15884 | 2368 | static void ggp_keepalive(PurpleConnection *gc) |
| 11360 | 2369 | { |
| 2370 | GGPInfo *info = gc->proto_data; | |
| 2371 | ||
| 15884 | 2372 | /* purple_debug_info("gg", "Keeping connection alive....\n"); */ |
| 11360 | 2373 | |
| 2374 | if (gg_ping(info->session) < 0) { | |
| 15884 | 2375 | purple_debug_info("gg", "Not connected to the server " |
| 11360 | 2376 | "or gg_session is not correct\n"); |
| 21279 | 2377 | purple_connection_error_reason (gc, |
| 2378 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27626
62fbae50be08
Connection error message changes for gg, and a few other strings changes.
Mark Doliner <markdoliner@pidgin.im>
parents:
27388
diff
changeset
|
2379 | _("Not connected to the server")); |
| 4916 | 2380 | } |
| 2393 | 2381 | } |
| 11360 | 2382 | |
| 15884 | 2383 | static void ggp_register_user(PurpleAccount *account) |
| 11360 | 2384 | { |
| 15884 | 2385 | PurpleConnection *gc = purple_account_get_connection(account); |
| 11360 | 2386 | GGPInfo *info; |
| 2387 | ||
| 12007 | 2388 | info = gc->proto_data = g_new0(GGPInfo, 1); |
| 11360 | 2389 | |
| 12007 | 2390 | ggp_token_request(gc, ggp_register_user_dialog); |
| 2393 | 2391 | } |
| 2392 | ||
| 15884 | 2393 | static GList *ggp_actions(PurplePlugin *plugin, gpointer context) |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2394 | { |
| 11360 | 2395 | GList *m = NULL; |
| 15884 | 2396 | PurplePluginAction *act; |
| 11360 | 2397 | |
| 15884 | 2398 | act = purple_plugin_action_new(_("Find buddies..."), |
| 12007 | 2399 | ggp_find_buddies); |
| 11360 | 2400 | m = g_list_append(m, act); |
| 2401 | ||
| 2402 | m = g_list_append(m, NULL); | |
| 2403 | ||
| 15884 | 2404 | act = purple_plugin_action_new(_("Change password..."), |
| 12007 | 2405 | ggp_change_passwd); |
| 11360 | 2406 | m = g_list_append(m, act); |
| 2407 | ||
| 2408 | m = g_list_append(m, NULL); | |
| 2409 | ||
| 15884 | 2410 | act = purple_plugin_action_new(_("Upload buddylist to Server"), |
| 12007 | 2411 | ggp_action_buddylist_put); |
| 11360 | 2412 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2413 | |
| 15884 | 2414 | act = purple_plugin_action_new(_("Download buddylist from Server"), |
| 12007 | 2415 | ggp_action_buddylist_get); |
| 11360 | 2416 | m = g_list_append(m, act); |
| 2417 | ||
| 15884 | 2418 | act = purple_plugin_action_new(_("Delete buddylist from Server"), |
| 12007 | 2419 | ggp_action_buddylist_delete); |
| 11360 | 2420 | m = g_list_append(m, act); |
| 2421 | ||
| 15884 | 2422 | act = purple_plugin_action_new(_("Save buddylist to file..."), |
| 12007 | 2423 | ggp_action_buddylist_save); |
| 11360 | 2424 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2425 | |
| 15884 | 2426 | act = purple_plugin_action_new(_("Load buddylist from file..."), |
| 12007 | 2427 | ggp_action_buddylist_load); |
| 11360 | 2428 | m = g_list_append(m, act); |
| 2429 | ||
| 2430 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2431 | } |
|
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2432 | |
| 15884 | 2433 | static gboolean ggp_offline_message(const PurpleBuddy *buddy) |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2434 | { |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2435 | return TRUE; |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2436 | } |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2437 | |
| 15884 | 2438 | static PurplePluginProtocolInfo prpl_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2439 | { |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2440 | OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_IM_IMAGE, |
| 12007 | 2441 | NULL, /* user_splits */ |
| 2442 | 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
|
2443 | {"png", 32, 32, 96, 96, 0, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ |
| 11360 | 2444 | ggp_list_icon, /* list_icon */ |
| 15524 | 2445 | NULL, /* list_emblem */ |
| 11360 | 2446 | ggp_status_text, /* status_text */ |
| 2447 | ggp_tooltip_text, /* tooltip_text */ | |
| 2448 | ggp_status_types, /* status_types */ | |
| 12007 | 2449 | ggp_blist_node_menu, /* blist_node_menu */ |
| 11394 | 2450 | ggp_chat_info, /* chat_info */ |
| 12007 | 2451 | NULL, /* chat_info_defaults */ |
| 2452 | ggp_login, /* login */ | |
| 2453 | ggp_close, /* close */ | |
| 11360 | 2454 | ggp_send_im, /* send_im */ |
| 12007 | 2455 | NULL, /* set_info */ |
| 2456 | NULL, /* send_typing */ | |
| 11360 | 2457 | ggp_get_info, /* get_info */ |
| 2458 | ggp_set_status, /* set_away */ | |
| 12007 | 2459 | NULL, /* set_idle */ |
| 2460 | NULL, /* change_passwd */ | |
| 11360 | 2461 | ggp_add_buddy, /* add_buddy */ |
| 12007 | 2462 | NULL, /* add_buddies */ |
| 11360 | 2463 | ggp_remove_buddy, /* remove_buddy */ |
| 12007 | 2464 | NULL, /* remove_buddies */ |
| 2465 | NULL, /* add_permit */ | |
| 2466 | NULL, /* add_deny */ | |
| 2467 | NULL, /* rem_permit */ | |
| 2468 | NULL, /* rem_deny */ | |
| 2469 | NULL, /* set_permit_deny */ | |
| 11394 | 2470 | ggp_join_chat, /* join_chat */ |
| 12007 | 2471 | NULL, /* reject_chat */ |
| 11394 | 2472 | ggp_get_chat_name, /* get_chat_name */ |
| 12007 | 2473 | NULL, /* chat_invite */ |
| 2474 | NULL, /* chat_leave */ | |
| 2475 | NULL, /* chat_whisper */ | |
| 11394 | 2476 | ggp_chat_send, /* chat_send */ |
| 11360 | 2477 | ggp_keepalive, /* keepalive */ |
| 2478 | ggp_register_user, /* register_user */ | |
| 12007 | 2479 | NULL, /* get_cb_info */ |
| 2480 | NULL, /* get_cb_away */ | |
| 2481 | NULL, /* alias_buddy */ | |
| 2482 | NULL, /* group_buddy */ | |
| 2483 | NULL, /* rename_group */ | |
| 2484 | NULL, /* buddy_free */ | |
| 2485 | NULL, /* convo_closed */ | |
| 2486 | NULL, /* normalize */ | |
| 2487 | NULL, /* set_buddy_icon */ | |
| 2488 | NULL, /* remove_group */ | |
| 2489 | NULL, /* get_cb_real_name */ | |
| 2490 | NULL, /* set_chat_topic */ | |
| 2491 | NULL, /* find_blist_chat */ | |
| 2492 | NULL, /* roomlist_get_list */ | |
| 2493 | NULL, /* roomlist_cancel */ | |
| 2494 | NULL, /* roomlist_expand_category */ | |
| 2495 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12007
diff
changeset
|
2496 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2497 | NULL, /* new_xfer */ |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2498 | ggp_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2499 | NULL, /* whiteboard_prpl_ops */ |
| 14604 | 2500 | NULL, /* send_raw */ |
| 15185 | 2501 | NULL, /* roomlist_room_serialize */ |
|
22071
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
2502 | NULL, /* unregister_user */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
2503 | NULL, /* send_attention */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
2504 | NULL, /* get_attention_types */ |
|
23276
f4944cfaa1ff
Use up the last padding for PurplePluginProtocolInfo in a way that allows
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22622
diff
changeset
|
2505 | sizeof(PurplePluginProtocolInfo), /* struct_size */ |
|
23707
480f94157418
propagate from branch 'im.pidgin.pidgin' (head bd5f7f61d9349053ee4738efc0d17453f0574057)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
2506 | NULL, /* get_account_text_table */ |
|
480f94157418
propagate from branch 'im.pidgin.pidgin' (head bd5f7f61d9349053ee4738efc0d17453f0574057)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
2507 | NULL, /* initiate_media */ |
| 29404 | 2508 | NULL, /* can_do_media */ |
| 2509 | NULL /* get_moods */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2510 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2511 | |
| 15884 | 2512 | static PurplePluginInfo info = { |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2513 | PURPLE_PLUGIN_MAGIC, /* magic */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2514 | PURPLE_MAJOR_VERSION, /* major_version */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2515 | PURPLE_MINOR_VERSION, /* minor_version */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2516 | PURPLE_PLUGIN_PROTOCOL, /* plugin type */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2517 | NULL, /* ui_requirement */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2518 | 0, /* flags */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2519 | NULL, /* dependencies */ |
| 15884 | 2520 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
| 11360 | 2521 | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2522 | "prpl-gg", /* id */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2523 | "Gadu-Gadu", /* name */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2524 | DISPLAY_VERSION, /* version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2525 | |
| 11360 | 2526 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 2527 | N_("Polish popular IM"), /* description */ | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2528 | "boler@sourceforge.net", /* author */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2529 | PURPLE_WEBSITE, /* homepage */ |
| 11360 | 2530 | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2531 | NULL, /* load */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2532 | NULL, /* unload */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2533 | NULL, /* destroy */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2534 | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2535 | NULL, /* ui_info */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2536 | &prpl_info, /* extra_info */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2537 | NULL, /* prefs_info */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2538 | ggp_actions, /* actions */ |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2539 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2540 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2541 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2542 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2543 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2544 | NULL |
| 11360 | 2545 | }; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2546 | |
| 15884 | 2547 | static void purple_gg_debug_handler(int level, const char * format, va_list args) { |
| 2548 | PurpleDebugLevel purple_level; | |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2549 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2550 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2551 | /* This is pretty pointless since the GG_DEBUG levels don't correspond to |
| 15884 | 2552 | * the purple ones */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2553 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2554 | case GG_DEBUG_FUNCTION: |
| 15884 | 2555 | purple_level = PURPLE_DEBUG_INFO; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2556 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2557 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2558 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2559 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2560 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2561 | default: |
| 15884 | 2562 | purple_level = PURPLE_DEBUG_MISC; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2563 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2564 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2565 | |
|
24683
3481a3320313
Backport the 'purple_debug_*(msg)' -> 'purple_debug_*("%s", msg);' fixes.
Richard Laager <rlaager@pidgin.im>
parents:
24569
diff
changeset
|
2566 | purple_debug(purple_level, "gg", "%s", msg); |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2567 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2568 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2569 | |
| 15884 | 2570 | static void init_plugin(PurplePlugin *plugin) |
| 2393 | 2571 | { |
| 15884 | 2572 | PurpleAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2573 | |
| 15884 | 2574 | option = purple_account_option_string_new(_("Nickname"), |
| 12007 | 2575 | "nick", _("Gadu-Gadu User")); |
| 2576 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2577 | option); | |
| 3572 | 2578 | |
|
27255
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
2579 | option = purple_account_option_string_new(_("GG server"), |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
2580 | "gg_server", ""); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
2581 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
2582 | option); |
|
d2284774cfed
Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691.
Paul Aurich <darkrain42@pidgin.im>
parents:
27197
diff
changeset
|
2583 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2584 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2585 | |
| 15884 | 2586 | gg_debug_handler = purple_gg_debug_handler; |
| 2393 | 2587 | } |
| 2588 | ||
| 15884 | 2589 | PURPLE_INIT_PLUGIN(gg, init_plugin, info); |
| 11360 | 2590 | |
| 12007 | 2591 | /* vim: set ts=8 sts=0 sw=8 noet: */ |