libpurple/protocols/gg/image-prpl.c

Wed, 17 Mar 2021 04:13:27 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 17 Mar 2021 04:13:27 -0500
changeset 40819
54b2a95ac176
parent 40439
e9838d634d5e
child 40997
997ab408c113
permissions
-rw-r--r--

Cleanup deprecated libsoup usage

* Use `soup_session_add_feature_by_type` instead of the option.
* Use strings instead of defines for libsoup properties.
The former are deprecated and removed from libsoup 3.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/574/

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
5 * source distribution.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
6 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
7 * Rewritten from scratch during Google Summer of Code 2012
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
9 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
11 * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001);
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
12 * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005;
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
13 * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
14 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
15 * This program is free software; you can redistribute it and/or modify
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
16 * it under the terms of the GNU General Public License as published by
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
17 * the Free Software Foundation; either version 2 of the License, or
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
18 * (at your option) any later version.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
19 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
20 * This program is distributed in the hope that it will be useful,
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
23 * GNU General Public License for more details.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
24 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
25 * You should have received a copy of the GNU General Public License
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
26 * along with this program; if not, write to the Free Software
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
28 */
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33313
diff changeset
29
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
30 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
31
35819
cc375b914104 imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35360
diff changeset
32 #include "image-prpl.h"
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
33
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
34 #include "gg.h"
33299
b3c4ab3aeb7f Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33298
diff changeset
35 #include "utils.h"
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
36
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
37 #include <purple.h>
35819
cc375b914104 imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35360
diff changeset
38
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
39 struct _ggp_image_session_data
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
40 {
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
41 GHashTable *recv_images;
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
42 GHashTable *sent_images;
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
43 };
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
44
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
45 typedef struct
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
46 {
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
47 PurpleImage *image;
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
48 gchar *conv_name; /* TODO: callback */
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
49 } ggp_image_sent;
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
50
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
51 static void ggp_image_sent_free(gpointer _sent_image)
35819
cc375b914104 imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35360
diff changeset
52 {
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
53 ggp_image_sent *sent_image = _sent_image;
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
54 g_object_unref(sent_image->image);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
55 g_free(sent_image->conv_name);
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
56 g_free(sent_image);
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
57 }
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
58
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
59 static uint64_t ggp_image_params_to_id(uint32_t crc32, uint32_t size)
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
60 {
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
61 return ((uint64_t)crc32 << 32) | size;
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
62 }
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
63
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
64 static inline ggp_image_session_data *
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
65 ggp_image_get_sdata(PurpleConnection *gc)
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
66 {
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
67 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
68 return accdata->image_data;
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
69 }
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
70
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
71 void ggp_image_setup(PurpleConnection *gc)
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
72 {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
73 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
74 ggp_image_session_data *sdata = g_new0(ggp_image_session_data, 1);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
75
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
76 accdata->image_data = sdata;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
77
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
78 sdata->recv_images = g_hash_table_new_full(
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
79 g_int64_hash, g_int64_equal, g_free, g_object_unref);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
80 sdata->sent_images = g_hash_table_new_full(
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
81 g_int64_hash, g_int64_equal, g_free,
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
82 ggp_image_sent_free);
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
83 }
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
84
33313
5a0c6582d5b1 Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33302
diff changeset
85 void ggp_image_cleanup(PurpleConnection *gc)
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
86 {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
87 ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
88
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
89 g_hash_table_destroy(sdata->recv_images);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
90 g_hash_table_destroy(sdata->sent_images);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
91 g_free(sdata);
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
92 }
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
93
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
94 ggp_image_prepare_result
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
95 ggp_image_prepare(PurpleConversation *conv, PurpleImage *image, uint64_t *id)
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
96 {
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
97 PurpleConnection *gc = purple_conversation_get_connection(conv);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
98 ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
99 size_t image_size;
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
100 gconstpointer image_data;
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
101 uint32_t image_crc;
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
102 ggp_image_sent *sent_image;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
103
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
104 g_return_val_if_fail(image, GGP_IMAGE_PREPARE_FAILURE);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
105
38298
f0a8f63f9312 rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents: 38281
diff changeset
106 image_size = purple_image_get_data_size(image);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
107
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
108 if (image_size > GGP_IMAGE_SIZE_MAX) {
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
109 purple_debug_warning("gg", "ggp_image_prepare: image "
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
110 "is too big (max bytes: %d)\n", GGP_IMAGE_SIZE_MAX);
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
111 return GGP_IMAGE_PREPARE_TOO_BIG;
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
112 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
113
35819
cc375b914104 imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35360
diff changeset
114 g_object_ref(image);
cc375b914104 imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35360
diff changeset
115 image_data = purple_image_get_data(image);
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
116 image_crc = gg_crc32(0, image_data, image_size);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
117
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
118 purple_debug_info("gg", "ggp_image_prepare: image prepared "
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
119 "[crc=%u, size=%" G_GSIZE_FORMAT "]",
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
120 image_crc, image_size);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
121
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
122 *id = ggp_image_params_to_id(image_crc, image_size);
34367
cb229d301bb4 Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34366
diff changeset
123
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
124 g_object_ref(image);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
125 sent_image = g_new(ggp_image_sent, 1);
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
126 sent_image->image = image;
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
127 sent_image->conv_name = g_strdup(purple_conversation_get_name(conv));
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
128 g_hash_table_insert(sdata->sent_images, ggp_uint64dup(*id),
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
129 sent_image);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
130
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
131 return GGP_IMAGE_PREPARE_OK;
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
132 }
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
133
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
134 void ggp_image_recv(PurpleConnection *gc,
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
135 const struct gg_event_image_reply *image_reply)
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
136 {
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
137 ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
35819
cc375b914104 imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35360
diff changeset
138 PurpleImage *img;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
139 uint64_t id;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
140
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
141 id = ggp_image_params_to_id(image_reply->crc32, image_reply->size);
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
142 img = g_hash_table_lookup(sdata->recv_images, &id);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
143 if (!img) {
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
144 purple_debug_warning("gg", "ggp_image_recv: "
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
145 "image " GGP_IMAGE_ID_FORMAT " wasn't requested\n",
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
146 id);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
147 return;
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
148 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
149
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
150 purple_debug_info("gg", "ggp_image_recv: got image "
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
151 "[crc=%u, size=%u, filename=%s, id=" GGP_IMAGE_ID_FORMAT "]",
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
152 image_reply->crc32, image_reply->size,
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
153 image_reply->filename, id);
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
154
38281
df274be2afa2 A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents: 37148
diff changeset
155 img = purple_image_new_from_data(
df274be2afa2 A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents: 37148
diff changeset
156 (const guint8 *)image_reply->image,
df274be2afa2 A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents: 37148
diff changeset
157 image_reply->size
df274be2afa2 A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents: 37148
diff changeset
158 );
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
159 purple_image_set_friendly_filename(img, image_reply->filename);
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
160
38281
df274be2afa2 A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents: 37148
diff changeset
161 g_hash_table_insert(sdata->recv_images, &id, img);
33298
519acf37d16e Gadu-Gadu: fix receiving of inline images after 3.x changes; code refactoring here as well
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
162 }
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
163
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
164 void ggp_image_send(PurpleConnection *gc,
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
165 const struct gg_event_image_request *image_request)
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
166 {
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
167 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
168 ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
169 ggp_image_sent *sent_image;
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
170 PurpleConversation *conv;
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
171 uint64_t id;
34366
62528926bcd2 Handle inline image filenames in the same way as GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
172 gchar *gg_filename;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
173
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
174 purple_debug_info("gg", "ggp_image_send: got image request "
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
175 "[uin=%u, crc=%u, size=%u]\n",
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
176 image_request->sender,
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
177 image_request->crc32,
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
178 image_request->size);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
179
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
180 id = ggp_image_params_to_id(image_request->crc32, image_request->size);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
181
34365
25e4187ea5a7 Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34362
diff changeset
182 sent_image = g_hash_table_lookup(sdata->sent_images, &id);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
183
34371
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
184 if (sent_image == NULL && image_request->sender == ggp_str_to_uin(
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
185 purple_account_get_username(purple_connection_get_account(gc))))
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
186 {
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
187 purple_debug_misc("gg", "ggp_image_send: requested image "
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
188 "not found, but this may be another session request\n");
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
189 return;
75f5a3c3cd67 Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34367
diff changeset
190 }
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
191 if (sent_image == NULL) {
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
192 purple_debug_warning("gg", "ggp_image_send: requested image "
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
193 "not found\n");
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
194 return;
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
195 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
196
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
197 purple_debug_misc("gg", "ggp_image_send: requested image found "
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
198 "[id=" GGP_IMAGE_ID_FORMAT ", conv=%s]\n",
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
199 id, sent_image->conv_name);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
200
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
201 g_return_if_fail(sent_image->image);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
202
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
203 /* TODO: check allowed recipients */
34418
c27e31267e8d Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34415
diff changeset
204 gg_filename = g_strdup_printf(GGP_IMAGE_ID_FORMAT, id);
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
205 gg_image_reply(accdata->session, image_request->sender,
34366
62528926bcd2 Handle inline image filenames in the same way as GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
206 gg_filename,
35820
9b4fccc8ceac GG: reference images, not their ids
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35819
diff changeset
207 purple_image_get_data(sent_image->image),
38298
f0a8f63f9312 rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents: 38281
diff changeset
208 purple_image_get_data_size(sent_image->image));
34366
62528926bcd2 Handle inline image filenames in the same way as GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34365
diff changeset
209 g_free(gg_filename);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
210
34946
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34632 34423
diff changeset
211 conv = purple_conversations_find_with_account(
76aa2e0f8701 Merged default branch
Ankit Vani <a@nevitus.org>
parents: 34632 34423
diff changeset
212 sent_image->conv_name,
33302
e094fcb98670 Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33301
diff changeset
213 purple_connection_get_account(gc));
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
214 if (conv != NULL) {
34367
cb229d301bb4 Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34366
diff changeset
215 gchar *msg = g_strdup_printf(_("Image delivered to %u."),
cb229d301bb4 Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34366
diff changeset
216 image_request->sender);
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35843
diff changeset
217 purple_conversation_write_system_message(conv, msg,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35843
diff changeset
218 PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_NOTIFY);
34367
cb229d301bb4 Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34366
diff changeset
219 g_free(msg);
cb229d301bb4 Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34366
diff changeset
220 }
33301
3f18ba8aed0f Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33299
diff changeset
221 }
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
222
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
223 PurpleImage *
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
224 ggp_image_request(PurpleConnection *gc, uin_t uin, uint64_t id)
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
225 {
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
226 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
227 ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
228 PurpleImage *img;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
229 uint32_t crc = id >> 32;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
230 uint32_t size = id;
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
231
35360
29d788c72350 Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35355
diff changeset
232 if (size > GGP_IMAGE_SIZE_MAX && crc <= GGP_IMAGE_SIZE_MAX) {
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
233 uint32_t tmp;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
234 purple_debug_warning("gg", "ggp_image_request: "
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
235 "crc and size are swapped!\n");
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
236 tmp = crc;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
237 crc = size;
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
238 size = tmp;
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
239 id = ggp_image_params_to_id(crc, size);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
240 }
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
241
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
242 img = g_hash_table_lookup(sdata->recv_images, &id);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
243 if (img) {
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
244 purple_debug_info("gg", "ggp_image_request: "
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
245 "image " GGP_IMAGE_ID_FORMAT " got from cache", id);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
246 return img;
34361
ddcc82637afa Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
247 }
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
248
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
249
38281
df274be2afa2 A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents: 37148
diff changeset
250 g_hash_table_insert(sdata->recv_images, ggp_uint64dup(id), NULL);
35355
3be5d45ba972 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34946
diff changeset
251
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
252 purple_debug_info("gg", "ggp_image_request: requesting image "
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
253 GGP_IMAGE_ID_FORMAT, id);
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
254 if (gg_image_request(accdata->session, uin, size, crc) != 0)
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
255 purple_debug_error("gg", "ggp_image_request: failed");
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
256
35843
b5d03ca6a680 Gadu-Gadu: use remote features of PurpleImage instead of handling image queue
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35820
diff changeset
257 return img;
34362
758e72362ca4 Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34361
diff changeset
258 }

mercurial