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