Sun, 23 Nov 2008 04:46:55 +0000
Kill off a bajillion comments that just needlessly duplicate function
signatures. I'm sure this will probably make someone angry, so I tried to
make this as easily disapproved as possible.
| 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 | ||
| 15884 | 758 | static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields) |
| 11394 | 759 | { |
| 760 | GGPInfo *info = gc->proto_data; | |
| 15884 | 761 | PurpleRequestField *field; |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
762 | /* TODO: sel may be null. */ |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17455
diff
changeset
|
763 | GList *sel; |
| 11394 | 764 | |
| 15884 | 765 | field = purple_request_fields_get_field(fields, "name"); |
| 766 | sel = purple_request_field_list_get_selected(field); | |
| 11394 | 767 | |
| 12961 | 768 | ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy); |
| 769 | info->tmp_buddy = 0; | |
| 11394 | 770 | } |
| 771 | ||
| 15884 | 772 | static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored) |
| 11394 | 773 | { |
| 15884 | 774 | PurpleBuddy *buddy; |
| 775 | PurpleConnection *gc; | |
| 11394 | 776 | GGPInfo *info; |
| 777 | ||
| 15884 | 778 | PurpleRequestFields *fields; |
| 779 | PurpleRequestFieldGroup *group; | |
| 780 | PurpleRequestField *field; | |
| 11394 | 781 | |
| 782 | GList *l; | |
| 783 | gchar *msg; | |
| 784 | ||
| 15884 | 785 | buddy = (PurpleBuddy *)node; |
| 786 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11394 | 787 | info = gc->proto_data; |
| 788 | ||
| 12961 | 789 | /* TODO: It tmp_buddy != 0 then stop! */ |
| 15884 | 790 | info->tmp_buddy = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11394 | 791 | |
| 15884 | 792 | fields = purple_request_fields_new(); |
| 793 | group = purple_request_field_group_new(NULL); | |
| 794 | purple_request_fields_add_group(fields, group); | |
| 11394 | 795 | |
| 15884 | 796 | field = purple_request_field_list_new("name", "Chat name"); |
| 11394 | 797 | for (l = info->chats; l != NULL; l = l->next) { |
| 798 | GGPChat *chat = l->data; | |
| 15884 | 799 | purple_request_field_list_add(field, g_strdup(chat->name), |
| 12007 | 800 | g_strdup(chat->name)); |
| 11394 | 801 | } |
| 15884 | 802 | purple_request_field_group_add_field(group, field); |
| 11394 | 803 | |
| 12007 | 804 | msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
| 15884 | 805 | purple_buddy_get_alias(buddy)); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
806 | purple_request_fields(gc, |
| 11394 | 807 | _("Add to chat..."), |
| 808 | _("Add to chat..."), | |
| 809 | msg, | |
| 810 | fields, | |
| 811 | _("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
|
812 | _("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
|
813 | purple_connection_get_account(gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
814 | gc); |
| 11394 | 815 | g_free(msg); |
| 816 | } | |
| 817 | ||
| 11414 | 818 | /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
| 819 | ||
| 15884 | 820 | static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored) |
| 11410 | 821 | { |
| 15884 | 822 | PurpleConnection *gc; |
| 823 | PurpleBuddy *buddy; | |
| 11410 | 824 | GGPInfo *info; |
| 825 | uin_t uin; | |
| 826 | ||
| 15884 | 827 | buddy = (PurpleBuddy *)node; |
| 828 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | |
| 11410 | 829 | info = gc->proto_data; |
| 830 | ||
| 15884 | 831 | uin = ggp_str_to_uin(purple_buddy_get_name(buddy)); |
| 11410 | 832 | |
| 15884 | 833 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 834 | purple_blist_node_set_bool(node, "blocked", FALSE); | |
| 11410 | 835 | gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); |
| 836 | gg_add_notify_ex(info->session, uin, GG_USER_NORMAL); | |
| 15884 | 837 | purple_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin); |
| 11410 | 838 | } else { |
| 15884 | 839 | purple_blist_node_set_bool(node, "blocked", TRUE); |
| 11410 | 840 | gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); |
| 841 | gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | |
| 15884 | 842 | purple_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin); |
| 11410 | 843 | } |
| 844 | } | |
| 845 | ||
| 11360 | 846 | /* ---------------------------------------------------------------------- */ |
| 11414 | 847 | /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
| 848 | /* ---------------------------------------------------------------------- */ | |
| 849 | ||
|
23381
2f5146434176
Add a prototype for ggp_to_gg_status.
Will Thompson <resiak@pidgin.im>
parents:
23380
diff
changeset
|
850 | /* Prototypes */ |
| 15884 | 851 | 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
|
852 | 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
|
853 | |
| 12964 | 854 | |
| 11414 | 855 | /** |
| 856 | * Handle change of the status of the buddy. | |
| 857 | * | |
| 15884 | 858 | * @param gc PurpleConnection |
| 11414 | 859 | * @param uin UIN of the buddy. |
| 860 | * @param status ID of the status. | |
| 861 | * @param descr Description. | |
| 862 | */ | |
| 15884 | 863 | static void ggp_generic_status_handler(PurpleConnection *gc, uin_t uin, |
| 12007 | 864 | int status, const char *descr) |
| 11414 | 865 | { |
| 866 | gchar *from; | |
| 867 | const char *st; | |
| 868 | gchar *msg; | |
| 869 | ||
| 870 | from = g_strdup_printf("%ld", (unsigned long int)uin); | |
| 871 | switch (status) { | |
| 872 | case GG_STATUS_NOT_AVAIL: | |
| 873 | case GG_STATUS_NOT_AVAIL_DESCR: | |
| 874 | st = "offline"; | |
| 875 | break; | |
| 876 | case GG_STATUS_AVAIL: | |
| 877 | case GG_STATUS_AVAIL_DESCR: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
878 | st = "available"; |
| 11414 | 879 | break; |
| 880 | case GG_STATUS_BUSY: | |
| 881 | case GG_STATUS_BUSY_DESCR: | |
|
12718
34152a2d35fc
[gaim-migrate @ 15062]
Richard Laager <rlaager@pidgin.im>
parents:
12717
diff
changeset
|
882 | st = "away"; |
| 11414 | 883 | break; |
| 884 | case GG_STATUS_BLOCKED: | |
| 885 | /* user is blocking us.... */ | |
| 886 | st = "blocked"; | |
| 887 | break; | |
| 888 | default: | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
889 | st = "available"; |
| 15884 | 890 | purple_debug_info("gg", |
| 12007 | 891 | "GG_EVENT_NOTIFY: Unknown status: %d\n", status); |
| 11414 | 892 | break; |
| 893 | } | |
| 894 | ||
| 15884 | 895 | purple_debug_info("gg", "st = %s\n", st); |
| 11414 | 896 | msg = charset_convert(descr, "CP1250", "UTF-8"); |
| 15884 | 897 | purple_prpl_got_user_status(purple_connection_get_account(gc), |
| 12007 | 898 | from, st, "message", msg, NULL); |
| 11414 | 899 | g_free(from); |
| 900 | g_free(msg); | |
| 901 | } | |
| 902 | ||
| 13643 | 903 | static void ggp_sr_close_cb(gpointer user_data) |
| 12220 | 904 | { |
| 13643 | 905 | GGPSearchForm *form = user_data; |
| 13641 | 906 | GGPInfo *info = form->user_data; |
| 12220 | 907 | |
| 13641 | 908 | 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
|
909 | purple_debug_info("gg", "ggp_sr_close_cb(): Removed seq %u", form->seq); |
| 13641 | 910 | ggp_search_form_destroy(form); |
| 12220 | 911 | } |
| 912 | ||
| 13645 | 913 | /** |
| 914 | * Translate a status' ID to a more user-friendly name. | |
| 915 | * | |
| 916 | * @param id The ID of the status. | |
| 917 | * | |
| 918 | * @return The user-friendly name of the status. | |
| 919 | */ | |
| 920 | static const char *ggp_status_by_id(unsigned int id) | |
| 921 | { | |
| 922 | const char *st; | |
| 923 | ||
| 15884 | 924 | purple_debug_info("gg", "ggp_status_by_id: %d\n", id); |
| 13645 | 925 | switch (id) { |
| 926 | case GG_STATUS_NOT_AVAIL: | |
| 927 | st = _("Offline"); | |
| 928 | break; | |
| 929 | case GG_STATUS_AVAIL: | |
| 930 | st = _("Available"); | |
| 931 | break; | |
| 932 | case GG_STATUS_BUSY: | |
| 933 | st = _("Away"); | |
| 934 | break; | |
| 935 | default: | |
| 936 | st = _("Unknown"); | |
| 937 | break; | |
| 938 | } | |
| 939 | ||
| 940 | return st; | |
| 941 | } | |
| 942 | ||
| 15884 | 943 | static void ggp_pubdir_handle_info(PurpleConnection *gc, gg_pubdir50_t req, |
| 13643 | 944 | GGPSearchForm *form) |
| 12007 | 945 | { |
| 15884 | 946 | PurpleNotifyUserInfo *user_info; |
| 947 | PurpleBuddy *buddy; | |
| 13643 | 948 | char *val, *who; |
| 949 | ||
| 15884 | 950 | user_info = purple_notify_user_info_new(); |
| 13643 | 951 | |
| 952 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_STATUS); | |
| 13645 | 953 | /* XXX: Use of ggp_str_to_uin() is an ugly hack! */ |
| 15884 | 954 | purple_notify_user_info_add_pair(user_info, _("Status"), ggp_status_by_id(ggp_str_to_uin(val))); |
| 13643 | 955 | g_free(val); |
| 956 | ||
| 957 | who = ggp_search_get_result(req, 0, GG_PUBDIR50_UIN); | |
| 15884 | 958 | purple_notify_user_info_add_pair(user_info, _("UIN"), who); |
| 13643 | 959 | |
| 960 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_FIRSTNAME); | |
| 15884 | 961 | purple_notify_user_info_add_pair(user_info, _("First Name"), val); |
| 13643 | 962 | g_free(val); |
| 963 | ||
| 964 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_NICKNAME); | |
| 15884 | 965 | purple_notify_user_info_add_pair(user_info, _("Nickname"), val); |
| 13643 | 966 | g_free(val); |
| 967 | ||
| 968 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_CITY); | |
| 15884 | 969 | purple_notify_user_info_add_pair(user_info, _("City"), val); |
| 13643 | 970 | g_free(val); |
| 971 | ||
| 972 | val = ggp_search_get_result(req, 0, GG_PUBDIR50_BIRTHYEAR); | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
973 | if (strncmp(val, "0", 1)) { |
| 15884 | 974 | purple_notify_user_info_add_pair(user_info, _("Birth Year"), val); |
| 13643 | 975 | } |
| 976 | g_free(val); | |
| 977 | ||
| 15294 | 978 | /* |
| 979 | * Include a status message, if exists and buddy is in the blist. | |
| 980 | */ | |
| 15884 | 981 | buddy = purple_find_buddy(purple_connection_get_account(gc), who); |
| 15294 | 982 | if (NULL != buddy) { |
| 15884 | 983 | PurpleStatus *status; |
| 15294 | 984 | const char *msg; |
| 985 | char *text; | |
| 13643 | 986 | |
| 15884 | 987 | status = purple_presence_get_active_status(purple_buddy_get_presence(buddy)); |
| 988 | msg = purple_status_get_attr_string(status, "message"); | |
| 13643 | 989 | |
| 15294 | 990 | if (msg != NULL) { |
| 991 | text = g_markup_escape_text(msg, -1); | |
| 15884 | 992 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15294 | 993 | g_free(text); |
| 994 | } | |
| 995 | } | |
| 996 | ||
|
18629
9e78088bfc46
Close temporary Get Info window when showing the real one. Fixes #1720.
Bartosz Oler <bartosz@pidgin.im>
parents:
18190
diff
changeset
|
997 | purple_notify_userinfo(gc, who, user_info, ggp_sr_close_cb, form); |
| 15294 | 998 | g_free(who); |
| 15884 | 999 | purple_notify_user_info_destroy(user_info); |
| 13643 | 1000 | } |
| 1001 | ||
| 15884 | 1002 | static void ggp_pubdir_handle_full(PurpleConnection *gc, gg_pubdir50_t req, |
| 13643 | 1003 | GGPSearchForm *form) |
| 1004 | { | |
| 15884 | 1005 | PurpleNotifySearchResults *results; |
| 1006 | PurpleNotifySearchColumn *column; | |
| 13643 | 1007 | int res_count; |
| 12007 | 1008 | int start; |
| 1009 | int i; | |
| 13641 | 1010 | |
| 13643 | 1011 | g_return_if_fail(form != NULL); |
| 12007 | 1012 | |
| 1013 | res_count = gg_pubdir50_count(req); | |
| 13643 | 1014 | res_count = (res_count > PUBDIR_RESULTS_MAX) ? PUBDIR_RESULTS_MAX : res_count; |
| 12007 | 1015 | |
| 15884 | 1016 | results = purple_notify_searchresults_new(); |
| 12007 | 1017 | |
| 12257 | 1018 | if (results == NULL) { |
| 15884 | 1019 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
| 12257 | 1020 | "Unable to display the search results.\n"); |
| 15884 | 1021 | purple_notify_error(gc, NULL, |
| 12257 | 1022 | _("Unable to display the search results."), |
| 1023 | NULL); | |
| 13641 | 1024 | ggp_sr_close_cb(form); |
| 12257 | 1025 | return; |
| 1026 | } | |
| 1027 | ||
| 15884 | 1028 | column = purple_notify_searchresults_column_new(_("UIN")); |
| 1029 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1030 | |
| 15884 | 1031 | column = purple_notify_searchresults_column_new(_("First Name")); |
| 1032 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1033 | |
| 15884 | 1034 | column = purple_notify_searchresults_column_new(_("Nickname")); |
| 1035 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1036 | |
| 15884 | 1037 | column = purple_notify_searchresults_column_new(_("City")); |
| 1038 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1039 | |
| 15884 | 1040 | column = purple_notify_searchresults_column_new(_("Birth Year")); |
| 1041 | purple_notify_searchresults_column_add(results, column); | |
| 12007 | 1042 | |
| 15884 | 1043 | purple_debug_info("gg", "Going with %d entries\n", res_count); |
| 12007 | 1044 | |
| 1045 | start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | |
| 15884 | 1046 | purple_debug_info("gg", "start = %d\n", start); |
| 12007 | 1047 | |
| 1048 | for (i = 0; i < res_count; i++) { | |
| 1049 | GList *row = NULL; | |
| 1050 | char *birth = ggp_search_get_result(req, i, GG_PUBDIR50_BIRTHYEAR); | |
| 1051 | ||
| 1052 | /* TODO: Status will be displayed as an icon. */ | |
| 1053 | /* row = g_list_append(row, ggp_search_get_result(req, i, GG_PUBDIR50_STATUS)); */ | |
| 1054 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1055 | GG_PUBDIR50_UIN)); | |
| 1056 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1057 | GG_PUBDIR50_FIRSTNAME)); | |
| 1058 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1059 | GG_PUBDIR50_NICKNAME)); | |
| 1060 | row = g_list_append(row, ggp_search_get_result(req, i, | |
| 1061 | GG_PUBDIR50_CITY)); | |
| 1062 | row = g_list_append(row, | |
| 1063 | (birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-")); | |
| 1064 | ||
| 15884 | 1065 | purple_notify_searchresults_row_add(results, row); |
| 12007 | 1066 | |
| 1067 | if (i == res_count - 1) { | |
| 13641 | 1068 | g_free(form->last_uin); |
| 1069 | form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN); | |
| 12007 | 1070 | } |
| 1071 | } | |
| 1072 | ||
| 15884 | 1073 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_CONTINUE, |
| 12007 | 1074 | ggp_callback_show_next); |
| 15884 | 1075 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 12007 | 1076 | ggp_callback_add_buddy); |
| 15884 | 1077 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_IM, |
| 13642 | 1078 | ggp_callback_im); |
| 13643 | 1079 | |
| 13641 | 1080 | if (form->window == NULL) { |
| 15884 | 1081 | void *h = purple_notify_searchresults(gc, |
| 12007 | 1082 | _("Gadu-Gadu Public Directory"), |
| 12220 | 1083 | _("Search results"), NULL, results, |
| 15884 | 1084 | (PurpleNotifyCloseCallback)ggp_sr_close_cb, |
| 13641 | 1085 | form); |
| 12257 | 1086 | |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1087 | if (h == NULL) { |
| 15884 | 1088 | purple_debug_error("gg", "ggp_pubdir_reply_handler: " |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1089 | "Unable to display the search results.\n"); |
| 15884 | 1090 | purple_notify_error(gc, NULL, |
|
12277
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1091 | _("Unable to display the search results."), |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1092 | NULL); |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1093 | return; |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1094 | } |
|
6e45a609022c
[gaim-migrate @ 14581]
Richard Laager <rlaager@pidgin.im>
parents:
12258
diff
changeset
|
1095 | |
| 13641 | 1096 | form->window = h; |
| 12007 | 1097 | } else { |
| 15884 | 1098 | purple_notify_searchresults_new_rows(gc, results, form->window); |
| 12007 | 1099 | } |
| 1100 | } | |
| 1101 | ||
| 15884 | 1102 | static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) |
| 13643 | 1103 | { |
| 1104 | GGPInfo *info = gc->proto_data; | |
| 1105 | GGPSearchForm *form; | |
| 1106 | int res_count; | |
| 1107 | guint32 seq; | |
| 1108 | ||
| 1109 | seq = gg_pubdir50_seq(req); | |
| 1110 | 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
|
1111 | purple_debug_info("gg", "ggp_pubdir_reply_handler(): seq %u --> form %p", seq, form); |
| 13643 | 1112 | /* |
| 1113 | * this can happen when user will request more results | |
| 1114 | * and close the results window before they arrive. | |
| 1115 | */ | |
| 1116 | g_return_if_fail(form != NULL); | |
| 1117 | ||
| 1118 | res_count = gg_pubdir50_count(req); | |
| 1119 | if (res_count < 1) { | |
| 15884 | 1120 | purple_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); |
| 1121 | purple_notify_error(gc, NULL, | |
| 13643 | 1122 | _("No matching users found"), |
| 1123 | _("There are no users matching your search criteria.")); | |
| 1124 | ggp_sr_close_cb(form); | |
| 1125 | return; | |
| 1126 | } | |
| 1127 | ||
| 1128 | switch (form->search_type) { | |
| 1129 | case GGP_SEARCH_TYPE_INFO: | |
| 1130 | ggp_pubdir_handle_info(gc, req, form); | |
| 1131 | break; | |
| 1132 | case GGP_SEARCH_TYPE_FULL: | |
| 1133 | ggp_pubdir_handle_full(gc, req, form); | |
| 1134 | break; | |
| 1135 | default: | |
| 15884 | 1136 | purple_debug_warning("gg", "Unknown search_type!\n"); |
| 13643 | 1137 | break; |
| 1138 | } | |
| 1139 | } | |
| 1140 | ||
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1141 | 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
|
1142 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1143 | gint imgid = 0; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1144 | 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
|
1145 | 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
|
1146 | 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
|
1147 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1148 | 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
|
1149 | 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
|
1150 | 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
|
1151 | 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
|
1152 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1153 | 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
|
1154 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1155 | while(entry) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1156 | 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
|
1157 | 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
|
1158 | 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
|
1159 | 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
|
1160 | g_strfreev(split); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1161 | 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
|
1162 | /* 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
|
1163 | 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
|
1164 | 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
|
1165 | 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
|
1166 | g_free(buf); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1167 | 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
|
1168 | g_free(text); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1169 | break; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1170 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1171 | 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
|
1172 | break; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1173 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1174 | 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
|
1175 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1176 | g_free(handlerid); |
|
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 | return; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1179 | } |
|
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 | |
| 11414 | 1182 | /** |
| 1183 | * Dispatch a message received from a buddy. | |
| 1184 | * | |
| 15884 | 1185 | * @param gc PurpleConnection. |
| 11414 | 1186 | * @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
|
1187 | * |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1188 | * Image receiving, some code borrowed from Kadu http://www.kadu.net |
| 11414 | 1189 | */ |
| 15884 | 1190 | static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) |
| 11414 | 1191 | { |
| 1192 | GGPInfo *info = gc->proto_data; | |
| 15884 | 1193 | PurpleConversation *conv; |
| 11414 | 1194 | gchar *from; |
| 1195 | gchar *msg; | |
| 1196 | gchar *tmp; | |
| 1197 | ||
| 1198 | from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | |
| 1199 | ||
| 12961 | 1200 | tmp = charset_convert((const char *)ev->event.msg.message, |
| 12007 | 1201 | "CP1250", "UTF-8"); |
| 15884 | 1202 | purple_str_strip_char(tmp, '\r'); |
| 12961 | 1203 | msg = g_markup_escape_text(tmp, -1); |
| 1204 | g_free(tmp); | |
| 11414 | 1205 | |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1206 | /* We got richtext message */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1207 | 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
|
1208 | { |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
1209 | 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
|
1210 | 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
|
1211 | 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
|
1212 | gint increased_len = 0; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1213 | 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
|
1214 | 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
|
1215 | 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
|
1216 | gchar *handlerid; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1217 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1218 | 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
|
1219 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1220 | while (cformats < cformats_end) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1221 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1222 | gint byteoffset; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1223 | 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
|
1224 | 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
|
1225 | 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
|
1226 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1227 | 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
|
1228 | 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
|
1229 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1230 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1231 | 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
|
1232 | actformat->position, |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1233 | (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
|
1234 | (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
|
1235 | (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
|
1236 | (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
|
1237 | increased_len); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1238 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1239 | 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
|
1240 | got_image = TRUE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1241 | 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
|
1242 | 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
|
1243 | 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
|
1244 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1245 | /* 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
|
1246 | * 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
|
1247 | if (actimage->size > 255000) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1248 | 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
|
1249 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1250 | } |
|
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 | 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
|
1253 | actimage->size, actimage->crc32); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1254 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1255 | 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
|
1256 | 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
|
1257 | increased_len += strlen(handlerid); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1258 | g_free(handlerid); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1259 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1260 | } |
|
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 | 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
|
1263 | if (bold == FALSE) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1264 | 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
|
1265 | increased_len += 3; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1266 | bold = TRUE; |
|
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 | } else if (bold) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1269 | 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
|
1270 | increased_len += 4; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1271 | bold = FALSE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1272 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1273 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1274 | 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
|
1275 | if (italic == FALSE) { |
|
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, "<i>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1277 | increased_len += 3; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1278 | italic = TRUE; |
|
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 | } else if (italic) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1281 | 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
|
1282 | increased_len += 4; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1283 | italic = FALSE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1284 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1285 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1286 | 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
|
1287 | if (under == FALSE) { |
|
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, "<u>"); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1289 | increased_len += 3; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1290 | under = TRUE; |
|
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 | } else if (under) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1293 | 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
|
1294 | increased_len += 4; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1295 | under = FALSE; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1296 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1297 | } |
|
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 | msg = message->str; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1300 | 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
|
1301 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1302 | if (got_image) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1303 | 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
|
1304 | return; |
|
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 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1307 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1308 | purple_debug_info("gg", "ggp_recv_message_handler: msg from (%s): %s (class = %d; rcpt_count = %d)\n", |
| 12961 | 1309 | from, msg, ev->event.msg.msgclass, |
| 12007 | 1310 | ev->event.msg.recipients_count); |
| 11414 | 1311 | |
| 1312 | if (ev->event.msg.recipients_count == 0) { | |
| 12961 | 1313 | serv_got_im(gc, from, msg, 0, ev->event.msg.time); |
| 11414 | 1314 | } else { |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1315 | const char *chat_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1316 | int chat_id; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1317 | char *buddy_name; |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1318 | |
| 11414 | 1319 | chat_name = ggp_confer_find_by_participants(gc, |
| 12007 | 1320 | ev->event.msg.recipients, |
| 1321 | ev->event.msg.recipients_count); | |
| 12961 | 1322 | |
| 11414 | 1323 | if (chat_name == NULL) { |
| 1324 | chat_name = ggp_confer_add_new(gc, NULL); | |
| 1325 | serv_got_joined_chat(gc, info->chats_count, chat_name); | |
| 12007 | 1326 | |
| 1327 | ggp_confer_participants_add_uin(gc, chat_name, | |
| 1328 | ev->event.msg.sender); | |
| 1329 | ||
| 1330 | ggp_confer_participants_add(gc, chat_name, | |
| 1331 | ev->event.msg.recipients, | |
| 1332 | ev->event.msg.recipients_count); | |
| 11414 | 1333 | } |
| 1334 | conv = ggp_confer_find_by_name(gc, chat_name); | |
| 15884 | 1335 | 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
|
1336 | |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1337 | buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
|
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1338 | serv_got_chat_in(gc, chat_id, buddy_name, |
| 15884 | 1339 | PURPLE_MESSAGE_RECV, msg, ev->event.msg.time); |
|
12373
a8f71f73576d
[gaim-migrate @ 14677]
Richard Laager <rlaager@pidgin.im>
parents:
12277
diff
changeset
|
1340 | g_free(buddy_name); |
| 11414 | 1341 | } |
| 12961 | 1342 | g_free(msg); |
| 11414 | 1343 | g_free(from); |
| 1344 | } | |
| 1345 | ||
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1346 | 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
|
1347 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1348 | 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
|
1349 | PurpleStoredImage *image; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1350 | gint imgid = (gint) g_hash_table_lookup(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
|
1351 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1352 | 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
|
1353 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1354 | if(imgid) |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1355 | { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1356 | 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
|
1357 | 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
|
1358 | 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
|
1359 | 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
|
1360 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1361 | 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
|
1362 | 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
|
1363 | purple_imgstore_unref(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1364 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1365 | 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
|
1366 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1367 | 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
|
1368 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1369 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1370 | |
| 15884 | 1371 | static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) |
| 11414 | 1372 | { |
| 15884 | 1373 | PurpleConnection *gc = _gc; |
| 11414 | 1374 | GGPInfo *info = gc->proto_data; |
| 1375 | struct gg_event *ev; | |
| 1376 | int i; | |
| 1377 | ||
| 1378 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1379 | purple_debug_error("gg", |
| 12007 | 1380 | "ggp_callback_recv: gg_watch_fd failed -- CRITICAL!\n"); |
| 21279 | 1381 | purple_connection_error_reason (gc, |
| 1382 | 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
|
1383 | _("Unable to read socket")); |
| 11414 | 1384 | return; |
| 1385 | } | |
|
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
|
1386 | gc->last_received = time(NULL); |
| 11414 | 1387 | switch (ev->type) { |
| 1388 | case GG_EVENT_NONE: | |
| 1389 | /* Nothing happened. */ | |
| 1390 | break; | |
| 1391 | case GG_EVENT_MSG: | |
| 1392 | ggp_recv_message_handler(gc, ev); | |
| 1393 | break; | |
| 1394 | 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
|
1395 | /* Changing %u to %i fixes compiler warning */ |
| 15884 | 1396 | 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
|
1397 | "ggp_callback_recv: message sent to: %i, delivery status=%d, seq=%d\n", |
| 12007 | 1398 | ev->event.ack.recipient, ev->event.ack.status, |
| 1399 | ev->event.ack.seq); | |
| 11414 | 1400 | break; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1401 | 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
|
1402 | 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
|
1403 | break; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1404 | 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
|
1405 | 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
|
1406 | break; |
| 11414 | 1407 | case GG_EVENT_NOTIFY: |
| 1408 | case GG_EVENT_NOTIFY_DESCR: | |
| 1409 | { | |
| 1410 | struct gg_notify_reply *n; | |
| 1411 | char *descr; | |
| 1412 | ||
| 15884 | 1413 | purple_debug_info("gg", "notify_pre: (%d) status: %d\n", |
| 11414 | 1414 | ev->event.notify->uin, |
| 1415 | ev->event.notify->status); | |
| 1416 | ||
| 1417 | n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify | |
| 1418 | : ev->event.notify_descr.notify; | |
| 1419 | ||
| 1420 | for (; n->uin; n++) { | |
| 1421 | descr = (ev->type == GG_EVENT_NOTIFY) ? NULL | |
| 12007 | 1422 | : ev->event.notify_descr.descr; |
| 1423 | ||
| 15884 | 1424 | purple_debug_info("gg", |
| 12007 | 1425 | "notify: (%d) status: %d; descr: %s\n", |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1426 | n->uin, n->status, descr ? descr : "(null)"); |
| 11414 | 1427 | |
| 1428 | ggp_generic_status_handler(gc, | |
| 12007 | 1429 | n->uin, n->status, descr); |
| 11414 | 1430 | } |
| 1431 | } | |
| 1432 | break; | |
| 1433 | case GG_EVENT_NOTIFY60: | |
| 15884 | 1434 | purple_debug_info("gg", |
| 12007 | 1435 | "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", |
| 1436 | ev->event.notify60->uin, ev->event.notify60->status, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1437 | ev->event.notify60->version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1438 | ev->event.notify60->descr ? ev->event.notify60->descr : "(null)"); |
| 11414 | 1439 | |
| 1440 | for (i = 0; ev->event.notify60[i].uin; i++) { | |
| 15884 | 1441 | purple_debug_info("gg", |
| 12007 | 1442 | "notify60: (%d) status=%d; version=%d; descr=%s\n", |
| 1443 | ev->event.notify60[i].uin, | |
| 1444 | ev->event.notify60[i].status, | |
| 1445 | ev->event.notify60[i].version, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1446 | ev->event.notify60[i].descr ? ev->event.notify60[i].descr : "(null)"); |
| 11414 | 1447 | |
| 12007 | 1448 | ggp_generic_status_handler(gc, ev->event.notify60[i].uin, |
| 1449 | ev->event.notify60[i].status, | |
| 1450 | ev->event.notify60[i].descr); | |
| 11414 | 1451 | } |
| 1452 | break; | |
| 1453 | case GG_EVENT_STATUS: | |
| 15884 | 1454 | purple_debug_info("gg", "status: (%d) status=%d; descr=%s\n", |
| 11414 | 1455 | ev->event.status.uin, ev->event.status.status, |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1456 | ev->event.status.descr ? ev->event.status.descr : "(null)"); |
| 11414 | 1457 | |
| 12007 | 1458 | ggp_generic_status_handler(gc, ev->event.status.uin, |
| 1459 | ev->event.status.status, ev->event.status.descr); | |
| 11414 | 1460 | break; |
| 1461 | case GG_EVENT_STATUS60: | |
| 15884 | 1462 | purple_debug_info("gg", |
| 12007 | 1463 | "status60: (%d) status=%d; version=%d; descr=%s\n", |
| 1464 | ev->event.status60.uin, ev->event.status60.status, | |
|
14524
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1465 | ev->event.status60.version, |
|
9637518e9703
[gaim-migrate @ 17176]
Daniel Atallah <datallah@pidgin.im>
parents:
14521
diff
changeset
|
1466 | ev->event.status60.descr ? ev->event.status60.descr : "(null)"); |
| 11414 | 1467 | |
| 12007 | 1468 | ggp_generic_status_handler(gc, ev->event.status60.uin, |
| 1469 | ev->event.status60.status, ev->event.status60.descr); | |
| 11414 | 1470 | break; |
| 1471 | case GG_EVENT_USERLIST: | |
| 1472 | if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | |
| 15884 | 1473 | purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); |
| 1474 | purple_notify_info(gc, NULL, | |
| 12220 | 1475 | _("Buddy list downloaded"), |
| 1476 | _("Your buddy list was downloaded from the server.")); | |
| 11414 | 1477 | if (ev->event.userlist.reply != NULL) { |
| 12007 | 1478 | ggp_buddylist_load(gc, ev->event.userlist.reply); |
| 11414 | 1479 | } |
| 1480 | } else { | |
| 15884 | 1481 | purple_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
| 1482 | purple_notify_info(gc, NULL, | |
| 12220 | 1483 | _("Buddy list uploaded"), |
| 1484 | _("Your buddy list was stored on the server.")); | |
| 11414 | 1485 | } |
| 1486 | break; | |
| 1487 | case GG_EVENT_PUBDIR50_SEARCH_REPLY: | |
| 12007 | 1488 | ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
| 1489 | break; | |
| 1490 | default: | |
| 15884 | 1491 | purple_debug_error("gg", |
| 12007 | 1492 | "unsupported event type=%d\n", ev->type); |
| 1493 | break; | |
| 1494 | } | |
| 11414 | 1495 | |
| 12007 | 1496 | gg_free_event(ev); |
| 1497 | } | |
| 11414 | 1498 | |
| 15884 | 1499 | static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) |
| 12007 | 1500 | { |
| 15884 | 1501 | PurpleConnection *gc = _gc; |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1502 | GGPInfo *info; |
| 12007 | 1503 | struct gg_event *ev; |
| 11414 | 1504 | |
| 15884 | 1505 | g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
|
15419
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1506 | |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1507 | info = gc->proto_data; |
|
c8f83c72739d
[gaim-migrate @ 18150]
Evan Schoenberg <evands@pidgin.im>
parents:
15294
diff
changeset
|
1508 | |
| 15884 | 1509 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
| 12007 | 1510 | info->session->check, info->session->state); |
| 11414 | 1511 | |
| 12007 | 1512 | switch (info->session->state) { |
| 1513 | case GG_STATE_RESOLVING: | |
| 15884 | 1514 | purple_debug_info("gg", "GG_STATE_RESOLVING\n"); |
| 12007 | 1515 | break; |
| 1516 | case GG_STATE_CONNECTING_HUB: | |
| 15884 | 1517 | purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); |
| 12007 | 1518 | break; |
| 1519 | case GG_STATE_READING_DATA: | |
| 15884 | 1520 | purple_debug_info("gg", "GG_STATE_READING_DATA\n"); |
| 12007 | 1521 | break; |
| 1522 | case GG_STATE_CONNECTING_GG: | |
| 15884 | 1523 | purple_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); |
| 12007 | 1524 | break; |
| 1525 | case GG_STATE_READING_KEY: | |
| 15884 | 1526 | purple_debug_info("gg", "GG_STATE_READING_KEY\n"); |
| 12007 | 1527 | break; |
| 1528 | case GG_STATE_READING_REPLY: | |
| 15884 | 1529 | purple_debug_info("gg", "GG_STATE_READING_REPLY\n"); |
| 11414 | 1530 | break; |
| 1531 | default: | |
| 15884 | 1532 | purple_debug_error("gg", "unknown state = %d\n", |
| 12007 | 1533 | info->session->state); |
| 1534 | break; | |
| 1535 | } | |
| 1536 | ||
| 1537 | if (!(ev = gg_watch_fd(info->session))) { | |
| 15884 | 1538 | purple_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); |
| 21279 | 1539 | purple_connection_error_reason (gc, |
| 1540 | 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
|
1541 | _("Unable to read socket")); |
| 12007 | 1542 | return; |
| 1543 | } | |
| 15884 | 1544 | purple_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); |
| 1545 | purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | |
| 12007 | 1546 | info->session->check, info->session->state); |
| 1547 | ||
| 15884 | 1548 | purple_input_remove(gc->inpa); |
| 12007 | 1549 | |
| 1550 | /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ | |
| 15884 | 1551 | gc->inpa = purple_input_add(info->session->fd, |
| 1552 | (info->session->check == 1) ? PURPLE_INPUT_WRITE | |
| 1553 | : PURPLE_INPUT_READ, | |
| 12007 | 1554 | ggp_async_login_handler, gc); |
| 1555 | ||
| 1556 | switch (ev->type) { | |
| 1557 | case GG_EVENT_NONE: | |
| 1558 | /* Nothing happened. */ | |
| 15884 | 1559 | purple_debug_info("gg", "GG_EVENT_NONE\n"); |
| 12007 | 1560 | break; |
| 1561 | case GG_EVENT_CONN_SUCCESS: | |
| 12964 | 1562 | { |
| 15884 | 1563 | purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); |
| 1564 | purple_input_remove(gc->inpa); | |
| 1565 | gc->inpa = purple_input_add(info->session->fd, | |
| 1566 | PURPLE_INPUT_READ, | |
| 12964 | 1567 | ggp_callback_recv, gc); |
| 12007 | 1568 | |
| 15884 | 1569 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
| 12964 | 1570 | ggp_buddylist_send(gc); |
| 1571 | } | |
| 12007 | 1572 | break; |
| 1573 | case GG_EVENT_CONN_FAILED: | |
| 15884 | 1574 | purple_input_remove(gc->inpa); |
| 12007 | 1575 | 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
|
1576 | purple_connection_error_reason (gc, |
| 21279 | 1577 | 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
|
1578 | _("Connection failed.")); |
| 12007 | 1579 | break; |
| 1580 | default: | |
| 15884 | 1581 | purple_debug_error("gg", "strange event: %d\n", ev->type); |
| 11414 | 1582 | break; |
| 1583 | } | |
| 1584 | ||
| 1585 | gg_free_event(ev); | |
| 1586 | } | |
| 1587 | ||
| 1588 | /* ---------------------------------------------------------------------- */ | |
| 15884 | 1589 | /* ----- PurplePluginProtocolInfo ----------------------------------------- */ |
| 11360 | 1590 | /* ---------------------------------------------------------------------- */ |
| 1591 | ||
| 15884 | 1592 | static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) |
| 11360 | 1593 | { |
| 1594 | return "gadu-gadu"; | |
| 1595 | } | |
| 1596 | ||
| 15884 | 1597 | static char *ggp_status_text(PurpleBuddy *b) |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1598 | { |
| 15884 | 1599 | PurpleStatus *status; |
| 11360 | 1600 | const char *msg; |
| 1601 | char *text; | |
| 1602 | char *tmp; | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1603 | |
| 15884 | 1604 | 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
|
1605 | |
| 15884 | 1606 | msg = purple_status_get_attr_string(status, "message"); |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1607 | |
| 11360 | 1608 | if (msg != NULL) { |
| 15884 | 1609 | tmp = purple_markup_strip_html(msg); |
| 11360 | 1610 | text = g_markup_escape_text(tmp, -1); |
| 1611 | g_free(tmp); | |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1612 | |
| 11360 | 1613 | return text; |
| 1614 | } else { | |
| 15884 | 1615 | tmp = purple_utf8_salvage(purple_status_get_name(status)); |
| 11360 | 1616 | text = g_markup_escape_text(tmp, -1); |
| 1617 | g_free(tmp); | |
| 1618 | ||
| 1619 | return text; | |
| 8997 | 1620 | } |
|
2846
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1621 | } |
|
4f0435806f95
[gaim-migrate @ 2859]
Arkadiusz Miskiewicz <arekm@maven.pl>
parents:
2835
diff
changeset
|
1622 | |
| 15884 | 1623 | static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 11360 | 1624 | { |
| 15884 | 1625 | PurpleStatus *status; |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1626 | char *text, *tmp; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1627 | const char *msg, *name, *alias; |
| 11360 | 1628 | |
| 15005 | 1629 | g_return_if_fail(b != NULL); |
| 1630 | ||
| 15884 | 1631 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
| 1632 | msg = purple_status_get_attr_string(status, "message"); | |
| 1633 | 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
|
1634 | 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
|
1635 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1636 | purple_notify_user_info_add_pair (user_info, _("Alias"), alias); |
| 11360 | 1637 | |
| 1638 | if (msg != NULL) { | |
| 13455 | 1639 | text = g_markup_escape_text(msg, -1); |
| 15884 | 1640 | if (PURPLE_BUDDY_IS_ONLINE(b)) { |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1641 | tmp = g_strdup_printf("%s: %s", name, text); |
| 15884 | 1642 | purple_notify_user_info_add_pair(user_info, _("Status"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15196
diff
changeset
|
1643 | g_free(tmp); |
| 15196 | 1644 | } else { |
| 15884 | 1645 | purple_notify_user_info_add_pair(user_info, _("Message"), text); |
| 15196 | 1646 | } |
| 11360 | 1647 | g_free(text); |
| 15227 | 1648 | /* We don't want to duplicate 'Status: Offline'. */ |
| 15884 | 1649 | } else if (PURPLE_BUDDY_IS_ONLINE(b)) { |
| 1650 | purple_notify_user_info_add_pair(user_info, _("Status"), name); | |
| 11360 | 1651 | } |
| 1652 | } | |
| 1653 | ||
| 15884 | 1654 | static GList *ggp_status_types(PurpleAccount *account) |
| 11360 | 1655 | { |
| 15884 | 1656 | PurpleStatusType *type; |
| 11360 | 1657 | GList *types = NULL; |
| 1658 | ||
| 15884 | 1659 | type = purple_status_type_new_with_attrs( |
| 1660 | PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1661 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1662 | NULL); |
| 11360 | 1663 | types = g_list_append(types, type); |
| 1664 | ||
| 1665 | /* | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11565
diff
changeset
|
1666 | * Without this selecting Invisible as own status doesn't |
| 11360 | 1667 | * work. It's not used and not needed to show status of buddies. |
| 1668 | */ | |
| 15884 | 1669 | type = purple_status_type_new_with_attrs( |
| 1670 | PURPLE_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1671 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1672 | NULL); |
| 11360 | 1673 | types = g_list_append(types, type); |
| 1674 | ||
| 15884 | 1675 | type = purple_status_type_new_with_attrs( |
| 1676 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1677 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
1678 | NULL); |
| 11360 | 1679 | types = g_list_append(types, type); |
| 1680 | ||
| 12964 | 1681 | /* |
| 1682 | * This status is necessary to display guys who are blocking *us*. | |
| 1683 | */ | |
| 15884 | 1684 | type = purple_status_type_new_with_attrs( |
| 1685 | PURPLE_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, | |
| 1686 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); | |
| 11360 | 1687 | types = g_list_append(types, type); |
| 1688 | ||
| 15884 | 1689 | type = purple_status_type_new_with_attrs( |
| 1690 | PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 1691 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1692 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1693 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1694 | |
| 11360 | 1695 | return types; |
| 1696 | } | |
| 1697 | ||
| 15884 | 1698 | static GList *ggp_blist_node_menu(PurpleBlistNode *node) |
| 2393 | 1699 | { |
| 15884 | 1700 | PurpleMenuAction *act; |
| 2393 | 1701 | GList *m = NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1702 | |
| 15884 | 1703 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
| 11360 | 1704 | return NULL; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4229
diff
changeset
|
1705 | |
| 15884 | 1706 | act = purple_menu_action_new(_("Add to chat"), |
| 1707 | PURPLE_CALLBACK(ggp_bmenu_add_to_chat), | |
| 12919 | 1708 | NULL, NULL); |
| 11410 | 1709 | m = g_list_append(m, act); |
| 1710 | ||
| 12641 | 1711 | /* Using a blist node boolean here is also wrong. |
| 1712 | * Once the Block and Unblock actions are added to the core, | |
| 1713 | * this will have to go. -- rlaager */ | |
| 15884 | 1714 | if (purple_blist_node_get_bool(node, "blocked")) { |
| 1715 | act = purple_menu_action_new(_("Unblock"), | |
| 1716 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1717 | NULL, NULL); |
| 12007 | 1718 | } else { |
| 15884 | 1719 | act = purple_menu_action_new(_("Block"), |
| 1720 | PURPLE_CALLBACK(ggp_bmenu_block), | |
| 12919 | 1721 | NULL, NULL); |
| 12007 | 1722 | } |
| 11394 | 1723 | m = g_list_append(m, act); |
| 2393 | 1724 | |
| 1725 | return m; | |
| 1726 | } | |
| 1727 | ||
| 15884 | 1728 | static GList *ggp_chat_info(PurpleConnection *gc) |
| 11394 | 1729 | { |
| 1730 | GList *m = NULL; | |
| 1731 | struct proto_chat_entry *pce; | |
| 1732 | ||
| 1733 | pce = g_new0(struct proto_chat_entry, 1); | |
| 1734 | pce->label = _("Chat _name:"); | |
| 1735 | pce->identifier = "name"; | |
| 1736 | pce->required = TRUE; | |
| 1737 | m = g_list_append(m, pce); | |
| 1738 | ||
| 1739 | return m; | |
| 1740 | } | |
| 1741 | ||
| 15884 | 1742 | static void ggp_login(PurpleAccount *account) |
| 2393 | 1743 | { |
| 15884 | 1744 | PurpleConnection *gc; |
|
23382
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1745 | PurplePresence *presence; |
|
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1746 | PurpleStatus *status; |
| 13515 | 1747 | struct gg_login_params *glp; |
| 1748 | GGPInfo *info; | |
| 1749 | ||
| 1750 | if (ggp_setup_proxy(account) == -1) | |
| 1751 | return; | |
| 1752 | ||
| 15884 | 1753 | gc = purple_account_get_connection(account); |
| 13515 | 1754 | glp = g_new0(struct gg_login_params, 1); |
| 1755 | info = g_new0(GGPInfo, 1); | |
| 11360 | 1756 | |
| 12007 | 1757 | /* Probably this should be moved to *_new() function. */ |
| 11360 | 1758 | info->session = NULL; |
| 11394 | 1759 | info->chats = NULL; |
| 1760 | info->chats_count = 0; | |
| 12007 | 1761 | info->token = NULL; |
| 13641 | 1762 | 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
|
1763 | 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
|
1764 | info->pending_images = g_hash_table_new(g_int_hash, g_int_equal); |
| 11360 | 1765 | |
| 1766 | gc->proto_data = info; | |
| 1767 | ||
| 1768 | glp->uin = ggp_get_uin(account); | |
| 15884 | 1769 | 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
|
1770 | glp->image_size = 255; |
| 11360 | 1771 | |
|
23382
8dfecaa62e66
Restore status on login on GG, rather than setting Available first.
Will Thompson <resiak@pidgin.im>
parents:
23381
diff
changeset
|
1772 | 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
|
1773 | 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
|
1774 | |
| 12007 | 1775 | 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
|
1776 | glp->status = ggp_to_gg_status(status, &glp->status_descr); |
| 11360 | 1777 | glp->tls = 0; |
| 1778 | ||
| 1779 | info->session = gg_login(glp); | |
| 1780 | if (info->session == NULL) { | |
| 21279 | 1781 | purple_connection_error_reason (gc, |
| 1782 | 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
|
1783 | _("Connection failed.")); |
| 11360 | 1784 | g_free(glp); |
| 1785 | return; | |
| 1786 | } | |
| 15884 | 1787 | gc->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ, |
| 12007 | 1788 | ggp_async_login_handler, gc); |
| 11360 | 1789 | } |
| 1790 | ||
| 15884 | 1791 | static void ggp_close(PurpleConnection *gc) |
| 11360 | 1792 | { |
| 8997 | 1793 | |
| 11360 | 1794 | if (gc == NULL) { |
| 15884 | 1795 | purple_debug_info("gg", "gc == NULL\n"); |
| 11360 | 1796 | return; |
| 1797 | } | |
| 1798 | ||
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1799 | if (gc->proto_data) { |
| 15884 | 1800 | PurpleAccount *account = purple_connection_get_account(gc); |
| 1801 | PurpleStatus *status; | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1802 | GGPInfo *info = gc->proto_data; |
| 12964 | 1803 | |
| 15884 | 1804 | status = purple_account_get_active_status(account); |
| 12964 | 1805 | |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1806 | if (info->session != NULL) { |
| 12964 | 1807 | ggp_set_status(account, status); |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1808 | gg_logoff(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1809 | gg_free_session(info->session); |
|
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1810 | } |
| 13641 | 1811 | |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1812 | /* Immediately close any notifications on this handle since that process depends |
|
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1813 | * 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
|
1814 | */ |
| 15884 | 1815 | purple_notify_close_with_handle(gc); |
|
14060
e1a87aabd80c
[gaim-migrate @ 16583]
Evan Schoenberg <evands@pidgin.im>
parents:
13645
diff
changeset
|
1816 | |
| 13641 | 1817 | 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
|
1818 | 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
|
1819 | g_hash_table_destroy(info->pending_images); |
|
11545
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1820 | g_free(info); |
|
df2f9bb3fd6e
[gaim-migrate @ 13800]
Daniel Atallah <datallah@pidgin.im>
parents:
11544
diff
changeset
|
1821 | gc->proto_data = NULL; |
|
11538
d87f3717d5a5
[gaim-migrate @ 13792]
Daniel Atallah <datallah@pidgin.im>
parents:
11522
diff
changeset
|
1822 | } |
| 11360 | 1823 | |
| 1824 | if (gc->inpa > 0) | |
| 15884 | 1825 | purple_input_remove(gc->inpa); |
| 11360 | 1826 | |
| 1827 | ggp_buddylist_offline(gc); | |
| 2393 | 1828 | |
| 15884 | 1829 | purple_debug_info("gg", "Connection closed.\n"); |
| 11360 | 1830 | } |
| 1831 | ||
| 15884 | 1832 | static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, |
| 1833 | PurpleMessageFlags flags) | |
| 11360 | 1834 | { |
| 1835 | GGPInfo *info = gc->proto_data; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1836 | char *tmp, *plain; |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1837 | int ret = 1; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1838 | unsigned char format[1024]; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1839 | 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
|
1840 | gint pos = 0; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1841 | GData *attribs; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1842 | 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
|
1843 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1844 | if (msg == NULL || *msg == 0) { |
| 15287 | 1845 | return 0; |
| 1846 | } | |
| 1847 | ||
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1848 | last = msg; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1849 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1850 | /* 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
|
1851 | /* TODO: Check formatting, too */ |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1852 | 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
|
1853 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1854 | 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
|
1855 | 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
|
1856 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1857 | do { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1858 | PurpleStoredImage *image; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1859 | const char *id; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1860 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1861 | /* 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
|
1862 | if(start - last) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1863 | 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
|
1864 | 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
|
1865 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1866 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1867 | 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
|
1868 | 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
|
1869 | 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
|
1870 | 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
|
1871 | 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
|
1872 | 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
|
1873 | 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
|
1874 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1875 | g_hash_table_insert(info->pending_images, &crc32, (gpointer)atoi(id)); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1876 | purple_imgstore_ref(image); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1877 | 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
|
1878 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1879 | 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
|
1880 | actformat.position = pos; |
|
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 | actimage.unknown1 = 0x0109; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1883 | 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
|
1884 | 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
|
1885 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1886 | if (actimage.size > 255000) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1887 | 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
|
1888 | continue; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1889 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1890 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1891 | 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
|
1892 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1893 | 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
|
1894 | format_length += sizeof(actformat); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1895 | 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
|
1896 | format_length += sizeof(actimage); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1897 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1898 | 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
|
1899 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1900 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1901 | last = end + 1; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1902 | g_datalist_clear(&attribs); |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1903 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1904 | } 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
|
1905 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1906 | /* 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
|
1907 | if(last && *last) { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1908 | 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
|
1909 | 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
|
1910 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1911 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1912 | fmt.flag = 2; |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1913 | 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
|
1914 | 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
|
1915 | |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1916 | 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
|
1917 | 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
|
1918 | 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
|
1919 | } else { |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1920 | 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
|
1921 | 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
|
1922 | } |
|
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1923 | |
| 15287 | 1924 | tmp = charset_convert(plain, "UTF-8", "CP1250"); |
| 11360 | 1925 | |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
1926 | 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
|
1927 | 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
|
1928 | ret = -1; |
|
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 | ret = 1; |
|
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 | } else if (NULL == tmp || *tmp == 0) { |
| 15287 | 1933 | ret = 0; |
| 1934 | } else if (strlen(tmp) > GG_MSG_MAXSIZE) { | |
| 1935 | ret = -E2BIG; | |
| 1936 | } else if (gg_send_message(info->session, GG_CLASS_CHAT, | |
| 1937 | ggp_str_to_uin(who), (unsigned char *)tmp) < 0) { | |
| 1938 | ret = -1; | |
| 1939 | } else { | |
| 1940 | ret = 1; | |
| 1941 | } | |
| 1942 | ||
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
1943 | g_free(plain); |
| 11565 | 1944 | g_free(tmp); |
| 11360 | 1945 | |
| 15287 | 1946 | return ret; |
| 11360 | 1947 | } |
| 1948 | ||
| 15884 | 1949 | static void ggp_get_info(PurpleConnection *gc, const char *name) |
| 11360 | 1950 | { |
| 1951 | GGPInfo *info = gc->proto_data; | |
| 1952 | GGPSearchForm *form; | |
| 13641 | 1953 | guint32 seq; |
| 2393 | 1954 | |
| 13641 | 1955 | form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); |
| 12220 | 1956 | |
| 13641 | 1957 | form->user_data = info; |
| 11360 | 1958 | form->uin = g_strdup(name); |
| 1959 | form->offset = g_strdup("0"); | |
| 1960 | form->last_uin = g_strdup("0"); | |
| 1961 | ||
| 13641 | 1962 | seq = ggp_search_start(gc, form); |
| 1963 | 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
|
1964 | purple_debug_info("gg", "ggp_get_info(): Added seq %u", seq); |
| 11360 | 1965 | } |
| 1966 | ||
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1967 | static int ggp_to_gg_status(PurpleStatus *status, char **msg) |
| 11360 | 1968 | { |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1969 | const char *status_id = purple_status_get_id(status); |
| 11360 | 1970 | 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
|
1971 | const char *new_msg; |
| 11360 | 1972 | |
|
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
|
1973 | g_return_val_if_fail(msg != NULL, 0); |
| 11360 | 1974 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1975 | purple_debug_info("gg", "ggp_to_gg_status: Requested status = %s\n", |
| 12007 | 1976 | status_id); |
| 2393 | 1977 | |
| 11360 | 1978 | if (strcmp(status_id, "available") == 0) { |
| 1979 | new_status = GG_STATUS_AVAIL; | |
| 1980 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 1981 | } else if (strcmp(status_id, "away") == 0) { | |
| 1982 | new_status = GG_STATUS_BUSY; | |
| 1983 | new_status_descr = GG_STATUS_BUSY_DESCR; | |
| 1984 | } else if (strcmp(status_id, "invisible") == 0) { | |
| 1985 | new_status = GG_STATUS_INVISIBLE; | |
| 1986 | new_status_descr = GG_STATUS_INVISIBLE_DESCR; | |
| 12964 | 1987 | } else if (strcmp(status_id, "offline") == 0) { |
| 1988 | new_status = GG_STATUS_NOT_AVAIL; | |
| 1989 | new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; | |
| 11360 | 1990 | } else { |
| 1991 | new_status = GG_STATUS_AVAIL; | |
| 1992 | new_status_descr = GG_STATUS_AVAIL_DESCR; | |
| 15884 | 1993 | 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
|
1994 | "ggp_set_status: unknown status requested (status_id=%s)\n", |
| 12007 | 1995 | status_id); |
| 11360 | 1996 | } |
| 4916 | 1997 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
1998 | 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
|
1999 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2000 | 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
|
2001 | 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
|
2002 | *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
|
2003 | 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
|
2004 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2005 | 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
|
2006 | } else { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2007 | *msg = NULL; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2008 | 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
|
2009 | } |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2010 | } |
| 11360 | 2011 | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2012 | 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
|
2013 | { |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2014 | PurpleConnection *gc; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2015 | GGPInfo *info; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2016 | 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
|
2017 | 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
|
2018 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2019 | 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
|
2020 | return; |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2021 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2022 | 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
|
2023 | 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
|
2024 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2025 | 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
|
2026 | |
|
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2027 | if (new_msg == NULL) { |
| 11360 | 2028 | gg_change_status(info->session, new_status); |
| 2029 | } else { | |
|
23380
1f2dda5756b9
Extract converting a PurpleStatus to GG's format to its own function.
Will Thompson <resiak@pidgin.im>
parents:
23379
diff
changeset
|
2030 | gg_change_status_descr(info->session, new_status, new_msg); |
| 12964 | 2031 | g_free(new_msg); |
| 11360 | 2032 | } |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2033 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2034 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2035 | |
| 11360 | 2036 | } |
| 2037 | ||
| 15884 | 2038 | static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 11360 | 2039 | { |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2040 | PurpleAccount *account; |
| 11360 | 2041 | GGPInfo *info = gc->proto_data; |
| 2042 | ||
| 2043 | gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2044 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2045 | account = purple_connection_get_account(gc); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2046 | if (strcmp(purple_account_get_username(account), buddy->name) == 0) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2047 | ggp_status_fake_to_self(account); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
2048 | } |
| 11360 | 2049 | } |
| 2050 | ||
| 15884 | 2051 | static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 2052 | PurpleGroup *group) | |
| 11360 | 2053 | { |
| 2054 | GGPInfo *info = gc->proto_data; | |
| 2055 | ||
| 2056 | gg_remove_notify(info->session, ggp_str_to_uin(buddy->name)); | |
| 2057 | } | |
| 2058 | ||
| 15884 | 2059 | static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) |
| 11394 | 2060 | { |
| 2061 | GGPInfo *info = gc->proto_data; | |
| 2062 | GGPChat *chat; | |
| 2063 | char *chat_name; | |
| 2064 | GList *l; | |
| 15884 | 2065 | PurpleConversation *conv; |
| 2066 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 11394 | 2067 | |
| 2068 | chat_name = g_hash_table_lookup(data, "name"); | |
| 2069 | ||
| 2070 | if (chat_name == NULL) | |
| 2071 | return; | |
| 2072 | ||
| 15884 | 2073 | purple_debug_info("gg", "joined %s chat\n", chat_name); |
| 11394 | 2074 | |
| 2075 | for (l = info->chats; l != NULL; l = l->next) { | |
| 2076 | chat = l->data; | |
| 2077 | ||
| 2078 | if (chat != NULL && g_utf8_collate(chat->name, chat_name) == 0) { | |
| 15884 | 2079 | purple_notify_error(gc, _("Chat error"), |
| 12007 | 2080 | _("This chat name is already in use"), NULL); |
| 11394 | 2081 | return; |
| 2082 | } | |
| 2083 | } | |
| 2084 | ||
| 11414 | 2085 | ggp_confer_add_new(gc, chat_name); |
| 12961 | 2086 | conv = serv_got_joined_chat(gc, info->chats_count, chat_name); |
| 15884 | 2087 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(conv), |
| 2088 | purple_account_get_username(account), NULL, | |
| 2089 | PURPLE_CBFLAGS_NONE, TRUE); | |
| 11394 | 2090 | } |
| 2091 | ||
| 2092 | static char *ggp_get_chat_name(GHashTable *data) { | |
| 2093 | return g_strdup(g_hash_table_lookup(data, "name")); | |
| 2094 | } | |
| 2095 | ||
| 15884 | 2096 | static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) |
| 11394 | 2097 | { |
| 15884 | 2098 | PurpleConversation *conv; |
| 11394 | 2099 | GGPInfo *info = gc->proto_data; |
| 2100 | GGPChat *chat = NULL; | |
| 2101 | GList *l; | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2102 | char *msg, *plain; |
| 11394 | 2103 | uin_t *uins; |
| 2104 | int count = 0; | |
| 2105 | ||
| 15884 | 2106 | if ((conv = purple_find_chat(gc, id)) == NULL) |
| 11394 | 2107 | return -EINVAL; |
| 2108 | ||
| 2109 | for (l = info->chats; l != NULL; l = l->next) { | |
| 2110 | chat = l->data; | |
| 2111 | ||
| 2112 | if (g_utf8_collate(chat->name, conv->name) == 0) { | |
| 2113 | break; | |
| 2114 | } | |
| 2115 | ||
| 2116 | chat = NULL; | |
| 2117 | } | |
| 2118 | ||
| 2119 | if (chat == NULL) { | |
| 15884 | 2120 | purple_debug_error("gg", |
| 12007 | 2121 | "ggp_chat_send: Hm... that's strange. No such chat?\n"); |
| 11394 | 2122 | return -EINVAL; |
| 2123 | } | |
| 2124 | ||
| 2125 | uins = g_new0(uin_t, g_list_length(chat->participants)); | |
| 12961 | 2126 | |
| 11394 | 2127 | for (l = chat->participants; l != NULL; l = l->next) { |
| 12961 | 2128 | uin_t uin = GPOINTER_TO_INT(l->data); |
| 11394 | 2129 | |
| 12961 | 2130 | uins[count++] = uin; |
| 11394 | 2131 | } |
| 2132 | ||
| 15884 | 2133 | plain = purple_unescape_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2134 | msg = charset_convert(plain, "UTF-8", "CP1250"); |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
2135 | g_free(plain); |
| 12007 | 2136 | gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
| 12961 | 2137 | (unsigned char *)msg); |
| 11394 | 2138 | g_free(msg); |
| 2139 | g_free(uins); | |
| 2140 | ||
| 12007 | 2141 | serv_got_chat_in(gc, id, |
| 15884 | 2142 | 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
|
2143 | flags, message, time(NULL)); |
| 11394 | 2144 | |
| 2145 | return 0; | |
| 2146 | } | |
| 2147 | ||
| 15884 | 2148 | static void ggp_keepalive(PurpleConnection *gc) |
| 11360 | 2149 | { |
| 2150 | GGPInfo *info = gc->proto_data; | |
| 2151 | ||
| 15884 | 2152 | /* purple_debug_info("gg", "Keeping connection alive....\n"); */ |
| 11360 | 2153 | |
| 2154 | if (gg_ping(info->session) < 0) { | |
| 15884 | 2155 | purple_debug_info("gg", "Not connected to the server " |
| 11360 | 2156 | "or gg_session is not correct\n"); |
| 21279 | 2157 | purple_connection_error_reason (gc, |
| 2158 | 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
|
2159 | _("Not connected to the server.")); |
| 4916 | 2160 | } |
| 2393 | 2161 | } |
| 11360 | 2162 | |
| 15884 | 2163 | static void ggp_register_user(PurpleAccount *account) |
| 11360 | 2164 | { |
| 15884 | 2165 | PurpleConnection *gc = purple_account_get_connection(account); |
| 11360 | 2166 | GGPInfo *info; |
| 2167 | ||
| 12007 | 2168 | info = gc->proto_data = g_new0(GGPInfo, 1); |
| 11360 | 2169 | |
| 12007 | 2170 | ggp_token_request(gc, ggp_register_user_dialog); |
| 2393 | 2171 | } |
| 2172 | ||
| 15884 | 2173 | static GList *ggp_actions(PurplePlugin *plugin, gpointer context) |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2174 | { |
| 11360 | 2175 | GList *m = NULL; |
| 15884 | 2176 | PurplePluginAction *act; |
| 11360 | 2177 | |
| 15884 | 2178 | act = purple_plugin_action_new(_("Find buddies..."), |
| 12007 | 2179 | ggp_find_buddies); |
| 11360 | 2180 | m = g_list_append(m, act); |
| 2181 | ||
| 2182 | m = g_list_append(m, NULL); | |
| 2183 | ||
| 15884 | 2184 | act = purple_plugin_action_new(_("Change password..."), |
| 12007 | 2185 | ggp_change_passwd); |
| 11360 | 2186 | m = g_list_append(m, act); |
| 2187 | ||
| 2188 | m = g_list_append(m, NULL); | |
| 2189 | ||
| 15884 | 2190 | act = purple_plugin_action_new(_("Upload buddylist to Server"), |
| 12007 | 2191 | ggp_action_buddylist_put); |
| 11360 | 2192 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2193 | |
| 15884 | 2194 | act = purple_plugin_action_new(_("Download buddylist from Server"), |
| 12007 | 2195 | ggp_action_buddylist_get); |
| 11360 | 2196 | m = g_list_append(m, act); |
| 2197 | ||
| 15884 | 2198 | act = purple_plugin_action_new(_("Delete buddylist from Server"), |
| 12007 | 2199 | ggp_action_buddylist_delete); |
| 11360 | 2200 | m = g_list_append(m, act); |
| 2201 | ||
| 15884 | 2202 | act = purple_plugin_action_new(_("Save buddylist to file..."), |
| 12007 | 2203 | ggp_action_buddylist_save); |
| 11360 | 2204 | m = g_list_append(m, act); |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2205 | |
| 15884 | 2206 | act = purple_plugin_action_new(_("Load buddylist from file..."), |
| 12007 | 2207 | ggp_action_buddylist_load); |
| 11360 | 2208 | m = g_list_append(m, act); |
| 2209 | ||
| 2210 | return m; | |
|
8775
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2211 | } |
|
6cb5dddaad4f
[gaim-migrate @ 9537]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8749
diff
changeset
|
2212 | |
| 15884 | 2213 | static gboolean ggp_offline_message(const PurpleBuddy *buddy) |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2214 | { |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2215 | return TRUE; |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2216 | } |
|
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2217 | |
| 15884 | 2218 | static PurplePluginProtocolInfo prpl_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2219 | { |
|
24745
511df62cb366
Support displaying buddy icons from Gadu-Gadu buddies. Fixes #220.
Adam Strzelecki <ono@java.pl>
parents:
24683
diff
changeset
|
2220 | OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_IM_IMAGE, |
| 12007 | 2221 | NULL, /* user_splits */ |
| 2222 | 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
|
2223 | {"png", 32, 32, 96, 96, 0, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ |
| 11360 | 2224 | ggp_list_icon, /* list_icon */ |
| 15524 | 2225 | NULL, /* list_emblem */ |
| 11360 | 2226 | ggp_status_text, /* status_text */ |
| 2227 | ggp_tooltip_text, /* tooltip_text */ | |
| 2228 | ggp_status_types, /* status_types */ | |
| 12007 | 2229 | ggp_blist_node_menu, /* blist_node_menu */ |
| 11394 | 2230 | ggp_chat_info, /* chat_info */ |
| 12007 | 2231 | NULL, /* chat_info_defaults */ |
| 2232 | ggp_login, /* login */ | |
| 2233 | ggp_close, /* close */ | |
| 11360 | 2234 | ggp_send_im, /* send_im */ |
| 12007 | 2235 | NULL, /* set_info */ |
| 2236 | NULL, /* send_typing */ | |
| 11360 | 2237 | ggp_get_info, /* get_info */ |
| 2238 | ggp_set_status, /* set_away */ | |
| 12007 | 2239 | NULL, /* set_idle */ |
| 2240 | NULL, /* change_passwd */ | |
| 11360 | 2241 | ggp_add_buddy, /* add_buddy */ |
| 12007 | 2242 | NULL, /* add_buddies */ |
| 11360 | 2243 | ggp_remove_buddy, /* remove_buddy */ |
| 12007 | 2244 | NULL, /* remove_buddies */ |
| 2245 | NULL, /* add_permit */ | |
| 2246 | NULL, /* add_deny */ | |
| 2247 | NULL, /* rem_permit */ | |
| 2248 | NULL, /* rem_deny */ | |
| 2249 | NULL, /* set_permit_deny */ | |
| 11394 | 2250 | ggp_join_chat, /* join_chat */ |
| 12007 | 2251 | NULL, /* reject_chat */ |
| 11394 | 2252 | ggp_get_chat_name, /* get_chat_name */ |
| 12007 | 2253 | NULL, /* chat_invite */ |
| 2254 | NULL, /* chat_leave */ | |
| 2255 | NULL, /* chat_whisper */ | |
| 11394 | 2256 | ggp_chat_send, /* chat_send */ |
| 11360 | 2257 | ggp_keepalive, /* keepalive */ |
| 2258 | ggp_register_user, /* register_user */ | |
| 12007 | 2259 | NULL, /* get_cb_info */ |
| 2260 | NULL, /* get_cb_away */ | |
| 2261 | NULL, /* alias_buddy */ | |
| 2262 | NULL, /* group_buddy */ | |
| 2263 | NULL, /* rename_group */ | |
| 2264 | NULL, /* buddy_free */ | |
| 2265 | NULL, /* convo_closed */ | |
| 2266 | NULL, /* normalize */ | |
| 2267 | NULL, /* set_buddy_icon */ | |
| 2268 | NULL, /* remove_group */ | |
| 2269 | NULL, /* get_cb_real_name */ | |
| 2270 | NULL, /* set_chat_topic */ | |
| 2271 | NULL, /* find_blist_chat */ | |
| 2272 | NULL, /* roomlist_get_list */ | |
| 2273 | NULL, /* roomlist_cancel */ | |
| 2274 | NULL, /* roomlist_expand_category */ | |
| 2275 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12007
diff
changeset
|
2276 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2277 | NULL, /* new_xfer */ |
|
13298
7a41e676010b
[gaim-migrate @ 15663]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
2278 | ggp_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2279 | NULL, /* whiteboard_prpl_ops */ |
| 14604 | 2280 | NULL, /* send_raw */ |
| 15185 | 2281 | NULL, /* roomlist_room_serialize */ |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2282 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2283 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2284 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2285 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2286 | NULL, |
|
23276
f4944cfaa1ff
Use up the last padding for PurplePluginProtocolInfo in a way that allows
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22622
diff
changeset
|
2287 | sizeof(PurplePluginProtocolInfo), /* struct_size */ |
|
23277
ea315a8d5bad
Patch from Jaywalker to let prpls add some helpful text for some account
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23276
diff
changeset
|
2288 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2289 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2290 | |
| 15884 | 2291 | static PurplePluginInfo info = { |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2292 | PURPLE_PLUGIN_MAGIC, /* magic */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2293 | 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
|
2294 | 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
|
2295 | 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
|
2296 | NULL, /* ui_requirement */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2297 | 0, /* flags */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2298 | NULL, /* dependencies */ |
| 15884 | 2299 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
| 11360 | 2300 | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2301 | "prpl-gg", /* id */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2302 | "Gadu-Gadu", /* name */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2303 | DISPLAY_VERSION, /* version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2304 | |
| 11360 | 2305 | N_("Gadu-Gadu Protocol Plugin"), /* summary */ |
| 2306 | 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
|
2307 | "boler@sourceforge.net", /* author */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2308 | PURPLE_WEBSITE, /* homepage */ |
| 11360 | 2309 | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2310 | NULL, /* load */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2311 | NULL, /* unload */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2312 | NULL, /* destroy */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2313 | |
|
24746
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2314 | NULL, /* ui_info */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2315 | &prpl_info, /* extra_info */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2316 | NULL, /* prefs_info */ |
|
ffee942a34b2
Kill off a bajillion comments that just needlessly duplicate function
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24745
diff
changeset
|
2317 | ggp_actions, /* actions */ |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2318 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2319 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2320 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2321 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2322 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16490
diff
changeset
|
2323 | NULL |
| 11360 | 2324 | }; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2325 | |
| 15884 | 2326 | static void purple_gg_debug_handler(int level, const char * format, va_list args) { |
| 2327 | PurpleDebugLevel purple_level; | |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2328 | char *msg = g_strdup_vprintf(format, args); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2329 | |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2330 | /* This is pretty pointless since the GG_DEBUG levels don't correspond to |
| 15884 | 2331 | * the purple ones */ |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2332 | switch (level) { |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2333 | case GG_DEBUG_FUNCTION: |
| 15884 | 2334 | purple_level = PURPLE_DEBUG_INFO; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2335 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2336 | case GG_DEBUG_MISC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2337 | case GG_DEBUG_NET: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2338 | case GG_DEBUG_DUMP: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2339 | case GG_DEBUG_TRAFFIC: |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2340 | default: |
| 15884 | 2341 | purple_level = PURPLE_DEBUG_MISC; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2342 | break; |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2343 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2344 | |
|
24683
3481a3320313
Backport the 'purple_debug_*(msg)' -> 'purple_debug_*("%s", msg);' fixes.
Richard Laager <rlaager@pidgin.im>
parents:
24569
diff
changeset
|
2345 | purple_debug(purple_level, "gg", "%s", msg); |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2346 | g_free(msg); |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2347 | } |
|
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2348 | |
| 15884 | 2349 | static void init_plugin(PurplePlugin *plugin) |
| 2393 | 2350 | { |
| 15884 | 2351 | PurpleAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2352 | |
| 15884 | 2353 | option = purple_account_option_string_new(_("Nickname"), |
| 12007 | 2354 | "nick", _("Gadu-Gadu User")); |
| 2355 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 2356 | option); | |
| 3572 | 2357 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2358 | my_protocol = plugin; |
|
11541
b1468184879c
[gaim-migrate @ 13796]
Daniel Atallah <datallah@pidgin.im>
parents:
11538
diff
changeset
|
2359 | |
| 15884 | 2360 | gg_debug_handler = purple_gg_debug_handler; |
| 2393 | 2361 | } |
| 2362 | ||
| 15884 | 2363 | PURPLE_INIT_PLUGIN(gg, init_plugin, info); |
| 11360 | 2364 | |
| 12007 | 2365 | /* vim: set ts=8 sts=0 sw=8 noet: */ |