libpurple/protocols/sametime/im_mime.c

changeset 39529
025cbbc9e5ae
parent 39528
0fa64a08fd5b
child 40196
7690a049a466
equal deleted inserted replaced
39528:0fa64a08fd5b 39529:025cbbc9e5ae
83 purple_markup_find_tag("img", tmp, 83 purple_markup_find_tag("img", tmp,
84 (const char **) &start, (const char **) &end, 84 (const char **) &start, (const char **) &end,
85 &attribs)) { 85 &attribs)) {
86 86
87 char *alt, *align, *border, *src; 87 char *alt, *align, *border, *src;
88 int img = 0; 88 guint img = 0;
89 89
90 alt = g_datalist_get_data(&attribs, "alt"); 90 alt = g_datalist_get_data(&attribs, "alt");
91 align = g_datalist_get_data(&attribs, "align"); 91 align = g_datalist_get_data(&attribs, "align");
92 border = g_datalist_get_data(&attribs, "border"); 92 border = g_datalist_get_data(&attribs, "border");
93 src = g_datalist_get_data(&attribs, "src"); 93 src = g_datalist_get_data(&attribs, "src");
94 94
95 if (src) { 95 if (src) {
96 img = GPOINTER_TO_INT(g_hash_table_lookup(img_by_cid, src)); 96 img = GPOINTER_TO_UINT(g_hash_table_lookup(img_by_cid, src));
97 } 97 }
98 98
99 if (img) { 99 if (img) {
100 GString *atstr; 100 GString *atstr;
101 gsize len = (end - start); 101 gsize len = (end - start);
134 134
135 GMimeParser *parser; 135 GMimeParser *parser;
136 GMimeObject *doc; 136 GMimeObject *doc;
137 int i, count; 137 int i, count;
138 138
139 img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, 139 img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
140 g_object_unref);
141 140
142 /* don't want the contained string to ever be NULL */ 141 /* don't want the contained string to ever be NULL */
143 str = g_string_new(""); 142 str = g_string_new("");
144 143
145 parser = create_parser(data); 144 parser = create_parser(data);
167 GMimeStream *stream; 166 GMimeStream *stream;
168 GByteArray *bytearray; 167 GByteArray *bytearray;
169 GBytes *data; 168 GBytes *data;
170 char *cid; 169 char *cid;
171 PurpleImage *image; 170 PurpleImage *image;
171 guint imgid;
172 172
173 /* obtain and unencode the data */ 173 /* obtain and unencode the data */
174 bytearray = g_byte_array_new(); 174 bytearray = g_byte_array_new();
175 stream = g_mime_stream_mem_new_with_byte_array(bytearray); 175 stream = g_mime_stream_mem_new_with_byte_array(bytearray);
176 g_mime_stream_mem_set_owner(GMIME_STREAM_MEM(stream), FALSE); 176 g_mime_stream_mem_set_owner(GMIME_STREAM_MEM(stream), FALSE);
186 image = purple_image_new_from_bytes(data); 186 image = purple_image_new_from_bytes(data);
187 purple_image_set_friendly_filename(image, cid); 187 purple_image_set_friendly_filename(image, cid);
188 g_bytes_unref(data); 188 g_bytes_unref(data);
189 189
190 /* map the cid to the image store identifier */ 190 /* map the cid to the image store identifier */
191 g_hash_table_insert(img_by_cid, cid, image); 191 imgid = purple_image_store_add(image);
192 g_hash_table_insert(img_by_cid, cid, GUINT_TO_POINTER(imgid));
192 193
193 } else if (GMIME_IS_TEXT_PART(obj)) { 194 } else if (GMIME_IS_TEXT_PART(obj)) {
194 /* concatenate all the text parts together */ 195 /* concatenate all the text parts together */
195 char *data; 196 char *data;
196 197

mercurial