Thu, 30 May 2013 11:23:51 +0200
Merge with main
|
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 | |
|
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
|
30 | #include "image.h" |
|
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
|
31 | |
|
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
|
32 | #include <debug.h> |
|
33368
6aa16fdab83f
Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33351
diff
changeset
|
33 | #include <glibcompat.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
|
34 | |
|
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
|
35 | #include "gg.h" |
|
33299
b3c4ab3aeb7f
Gadu-Gadu: utils refactoring, (partially) fix new account registration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33298
diff
changeset
|
36 | #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
|
37 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
38 | 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
|
39 | { |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
40 | GHashTable *got_images; |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
41 | GHashTable *incoming_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 | { |
|
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
47 | int id; |
|
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 | |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
51 | typedef struct |
|
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
|
52 | { |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
53 | GList *listeners; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
54 | } ggp_image_requested; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
55 | |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
56 | typedef struct |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
57 | { |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
58 | ggp_image_request_cb cb; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
59 | gpointer user_data; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
60 | } ggp_image_requested_listener; |
|
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
|
61 | |
|
34367
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
62 | static void ggp_image_got_free(gpointer data) |
|
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
63 | { |
|
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
64 | int id = GPOINTER_TO_INT(data); |
|
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
65 | purple_imgstore_unref_by_id(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
|
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 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
68 | static void ggp_image_sent_free(gpointer data) |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
69 | { |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
70 | ggp_image_sent *sent_image = (ggp_image_sent*)data; |
|
34367
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
71 | purple_imgstore_unref_by_id(sent_image->id); |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
72 | 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
|
73 | g_free(sent_image); |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
74 | } |
|
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
75 | |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
76 | static void ggp_image_requested_free(gpointer data) |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
77 | { |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
78 | ggp_image_requested *req = data; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
79 | g_list_free_full(req->listeners, g_free); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
80 | g_free(req); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
81 | } |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
82 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
83 | 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
|
84 | { |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
85 | 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
|
86 | } |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
87 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
88 | static inline ggp_image_session_data * |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
89 | 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
|
90 | { |
|
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
|
91 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
92 | 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
|
93 | } |
|
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
|
94 | |
|
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
|
95 | 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
|
96 | { |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
97 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
98 | ggp_image_session_data *sdata = g_new0(ggp_image_session_data, 1); |
|
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
|
99 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
100 | accdata->image_data = 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
|
101 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
102 | sdata->got_images = g_hash_table_new_full( |
|
34367
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
103 | g_int64_hash, g_int64_equal, g_free, |
|
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
104 | ggp_image_got_free); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
105 | sdata->incoming_images = g_hash_table_new_full( |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
106 | 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
|
107 | ggp_image_requested_free); |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | } |
|
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
|
112 | |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33302
diff
changeset
|
113 | 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
|
114 | { |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
115 | ggp_image_session_data *sdata = ggp_image_get_sdata(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
|
116 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
117 | g_hash_table_destroy(sdata->got_images); |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
118 | g_hash_table_destroy(sdata->incoming_images); |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
119 | g_hash_table_destroy(sdata->sent_images); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
120 | 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
|
121 | } |
|
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
|
122 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
123 | ggp_image_prepare_result ggp_image_prepare(PurpleConversation *conv, |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
124 | const int stored_id, 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
|
125 | { |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
126 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
127 | 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
|
128 | PurpleStoredImage *image = purple_imgstore_find_by_id(stored_id); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
129 | 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
|
130 | gconstpointer image_data; |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
131 | 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
|
132 | ggp_image_sent *sent_image; |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
133 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
134 | if (!image) |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
135 | { |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
136 | purple_debug_error("gg", "ggp_image_prepare: image %d " |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
137 | "not found in image store\n", stored_id); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
138 | return GGP_IMAGE_PREPARE_FAILURE; |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
139 | } |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
140 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
141 | image_size = purple_imgstore_get_size(image); |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
142 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
143 | if (image_size > 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
|
144 | { |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
145 | 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
|
146 | "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
|
147 | 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
|
148 | } |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
149 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
150 | purple_imgstore_ref(image); |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
151 | image_data = purple_imgstore_get_data(image); |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
152 | image_crc = gg_crc32(0, image_data, image_size); |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
153 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
154 | purple_debug_info("gg", "ggp_image_prepare: image prepared " |
| 34423 | 155 | "[id=%d, crc=%u, size=%" G_GSIZE_FORMAT "]\n", |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
156 | stored_id, image_crc, image_size); |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
157 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
158 | *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
|
159 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
160 | sent_image = g_new(ggp_image_sent, 1); |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
161 | sent_image->id = stored_id; |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
162 | 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
|
163 | 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
|
164 | sent_image); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
165 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
166 | 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
|
167 | } |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
168 | |
|
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
|
169 | 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
|
170 | 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
|
171 | { |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
172 | ggp_image_session_data *sdata = ggp_image_get_sdata(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
|
173 | int stored_id; |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
174 | ggp_image_requested *req; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
175 | GList *it; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
176 | 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
|
177 | |
|
33762
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
178 | /* TODO: This PurpleStoredImage will be rendered within the IM window |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
179 | and right-clicking the image will allow the user to save the image |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
180 | to disk. The default filename used in this dialog is the filename |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
181 | that we pass to purple_imgstore_new_with_id(), so we should call |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
182 | g_path_get_basename() and purple_escape_filename() on it before |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
183 | passing it in. This is easy, but it's not clear if there might be |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
184 | other implications because this filename is used elsewhere within |
|
7415482377b5
Add TODOs to escape filenames. I don't think these are severe problems,
Mark Doliner <mark@kingant.net>
parents:
33661
diff
changeset
|
185 | this PRPL. */ |
| 33661 | 186 | stored_id = purple_imgstore_new_with_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
|
187 | g_memdup(image_reply->image, image_reply->size), |
|
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
|
188 | image_reply->size, |
|
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
|
189 | image_reply->filename); |
|
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
|
190 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
191 | id = ggp_image_params_to_id(image_reply->crc32, image_reply->size); |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
192 | |
|
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
|
193 | purple_debug_info("gg", "ggp_image_recv: got image " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
194 | "[stored_id=%d, crc=%u, size=%u, filename=%s, id=" |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
195 | GGP_IMAGE_ID_FORMAT "]\n", |
|
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
|
196 | stored_id, |
|
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
|
197 | image_reply->crc32, |
|
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
|
198 | image_reply->size, |
|
34366
62528926bcd2
Handle inline image filenames in the same way as GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
199 | image_reply->filename, |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
200 | 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
|
201 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
202 | g_hash_table_insert(sdata->got_images, ggp_uint64dup(id), |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
203 | GINT_TO_POINTER(stored_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
|
204 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
205 | req = g_hash_table_lookup(sdata->incoming_images, &id); |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
206 | if (!req) |
|
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
|
207 | { |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
208 | purple_debug_warning("gg", "ggp_image_recv: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
209 | "image " GGP_IMAGE_ID_FORMAT " wasn't requested\n", |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
210 | id); |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
211 | return; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
212 | } |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
213 | |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
214 | it = g_list_first(req->listeners); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
215 | while (it) |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
216 | { |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
217 | ggp_image_requested_listener *listener = it->data; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
218 | it = g_list_next(it); |
|
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
|
219 | |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
220 | listener->cb(gc, id, stored_id, listener->user_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
|
221 | } |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
222 | g_hash_table_remove(sdata->incoming_images, &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
|
223 | } |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
224 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
225 | 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
|
226 | 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
|
227 | { |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
228 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
229 | 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
|
230 | ggp_image_sent *sent_image; |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
231 | PurpleStoredImage *image; |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
232 | PurpleConversation *conv; |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
233 | 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
|
234 | gchar *gg_filename; |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
235 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
236 | 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
|
237 | "[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
|
238 | image_request->sender, |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
239 | image_request->crc32, |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
240 | image_request->size); |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
241 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
242 | id = ggp_image_params_to_id(image_request->crc32, image_request->size); |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
243 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
244 | sent_image = g_hash_table_lookup(sdata->sent_images, &id); |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
245 | |
|
34371
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
246 | 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
|
247 | 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
|
248 | { |
|
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
249 | 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
|
250 | "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
|
251 | return; |
|
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
252 | } |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
253 | 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
|
254 | { |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
255 | 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
|
256 | "not found\n"); |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
257 | return; |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
258 | } |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
259 | |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
260 | purple_debug_misc("gg", "ggp_image_send: requested image found " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
261 | "[id=" GGP_IMAGE_ID_FORMAT ", stored id=%d, conv=%s]\n", |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
262 | id, |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
263 | sent_image->id, |
|
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
264 | sent_image->conv_name); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
265 | |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
266 | image = purple_imgstore_find_by_id(sent_image->id); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
267 | |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
268 | if (!image) |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
269 | { |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
270 | purple_debug_error("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
|
271 | "found, but doesn't exists in image store\n"); |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
272 | g_hash_table_remove(sdata->sent_images, |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
273 | GINT_TO_POINTER(image_request->crc32)); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
274 | return; |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
275 | } |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
276 | |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
277 | //TODO: check allowed recipients |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
278 | 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
|
279 | 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
|
280 | gg_filename, |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
281 | purple_imgstore_get_data(image), |
|
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
282 | purple_imgstore_get_size(image)); |
|
34366
62528926bcd2
Handle inline image filenames in the same way as GG11
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34365
diff
changeset
|
283 | g_free(gg_filename); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
284 | |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
285 | conv = purple_find_conversation_with_account( |
|
34365
25e4187ea5a7
Gadu-Gadu: outgoing images works again (not in conferences, yet)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34362
diff
changeset
|
286 | PURPLE_CONV_TYPE_ANY, sent_image->conv_name, |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
287 | purple_connection_get_account(gc)); |
|
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
288 | 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
|
289 | { |
|
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
290 | 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
|
291 | image_request->sender); |
|
cb229d301bb4
Gadu-Gadu: don't unref images after sending it to first recipient
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34366
diff
changeset
|
292 | purple_conversation_write(conv, "", msg, |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
293 | PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_NOTIFY, |
|
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
294 | time(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
|
295 | 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
|
296 | } |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
297 | } |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
298 | |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
299 | void ggp_image_request(PurpleConnection *gc, uin_t uin, uint64_t id, |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
300 | ggp_image_request_cb cb, gpointer user_data) |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
301 | { |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
302 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
303 | ggp_image_session_data *sdata = ggp_image_get_sdata(gc); |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
304 | ggp_image_requested *req; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
305 | ggp_image_requested_listener *listener; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
306 | uint32_t crc = id >> 32; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
307 | uint32_t size = id; |
|
33302
e094fcb98670
Gadu-Gadu: acknowledgment for sent images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33301
diff
changeset
|
308 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
309 | 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
|
310 | { |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
311 | uint32_t tmp; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
312 | purple_debug_warning("gg", "ggp_image_request: " |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
313 | "crc and size are swapped!\n"); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
314 | tmp = crc; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
315 | crc = size; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
316 | size = tmp; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
317 | } |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
318 | |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
319 | req = g_hash_table_lookup(sdata->incoming_images, &id); |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
320 | if (!req) |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
321 | { |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
322 | req = g_new0(ggp_image_requested, 1); |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
323 | g_hash_table_insert(sdata->incoming_images, |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
324 | ggp_uint64dup(id), req); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
325 | purple_debug_info("gg", "ggp_image_request: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
326 | "requesting image " GGP_IMAGE_ID_FORMAT "\n", id); |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
327 | if (gg_image_request(accdata->session, uin, size, crc) != 0) |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
328 | purple_debug_error("gg", "ggp_image_request: failed\n"); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
329 | } |
|
34371
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
330 | else |
|
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
331 | { |
|
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
332 | purple_debug_info("gg", "ggp_image_request: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
333 | "image " GGP_IMAGE_ID_FORMAT " already requested\n", |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34415
diff
changeset
|
334 | id); |
|
34371
75f5a3c3cd67
Gadu-Gadu: more debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34367
diff
changeset
|
335 | } |
|
34361
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
336 | |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
337 | listener = g_new0(ggp_image_requested_listener, 1); |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
338 | listener->cb = cb; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
339 | listener->user_data = user_data; |
|
ddcc82637afa
Gadu-Gadu: incoming images works again
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33368
diff
changeset
|
340 | req->listeners = g_list_append(req->listeners, listener); |
|
33301
3f18ba8aed0f
Gadu-Gadu sending images refactoring; notify about too large images
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33299
diff
changeset
|
341 | } |
|
34362
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
342 | |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
343 | int ggp_image_get_cached(PurpleConnection *gc, uint64_t id) |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
344 | { |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
345 | ggp_image_session_data *sdata = ggp_image_get_sdata(gc); |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
346 | |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
347 | return GPOINTER_TO_INT(g_hash_table_lookup(sdata->got_images, &id)); |
|
758e72362ca4
Gadu-Gadu: code polishing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
348 | } |