| 33 static GHashTable *local_data_by_cid = NULL; |
33 static GHashTable *local_data_by_cid = NULL; |
| 34 static GHashTable *remote_data_by_cid = NULL; |
34 static GHashTable *remote_data_by_cid = NULL; |
| 35 |
35 |
| 36 JabberData * |
36 JabberData * |
| 37 jabber_data_create_from_data(gconstpointer rawdata, gsize size, const char *type, |
37 jabber_data_create_from_data(gconstpointer rawdata, gsize size, const char *type, |
| 38 JabberStream *js) |
38 gboolean ephemeral, JabberStream *js) |
| 39 { |
39 { |
| 40 JabberData *data = g_new0(JabberData, 1); |
40 JabberData *data = g_new0(JabberData, 1); |
| 41 gchar *checksum = purple_util_get_image_checksum(rawdata, size); |
41 gchar *checksum = purple_util_get_image_checksum(rawdata, size); |
| 42 gchar cid[256]; |
42 gchar cid[256]; |
| 43 |
43 |
| 176 } |
183 } |
| 177 |
184 |
| 178 const JabberData * |
185 const JabberData * |
| 179 jabber_data_find_local_by_alt(const gchar *alt) |
186 jabber_data_find_local_by_alt(const gchar *alt) |
| 180 { |
187 { |
| 181 purple_debug_info("jabber", "looking up local smiley with alt = %s\n", alt); |
188 purple_debug_info("jabber", "looking up local data object with alt = %s\n", alt); |
| 182 return g_hash_table_lookup(local_data_by_alt, alt); |
189 return g_hash_table_lookup(local_data_by_alt, alt); |
| 183 } |
190 } |
| 184 |
191 |
| 185 const JabberData * |
192 const JabberData * |
| 186 jabber_data_find_local_by_cid(const gchar *cid) |
193 jabber_data_find_local_by_cid(const gchar *cid) |
| 187 { |
194 { |
| 188 purple_debug_info("jabber", "lookup local smiley with cid = %s\n", cid); |
195 purple_debug_info("jabber", "lookup local data object with cid = %s\n", cid); |
| 189 return g_hash_table_lookup(local_data_by_cid, cid); |
196 return g_hash_table_lookup(local_data_by_cid, cid); |
| 190 } |
197 } |
| 191 |
198 |
| 192 const JabberData * |
199 const JabberData * |
| 193 jabber_data_find_remote_by_cid(const gchar *cid) |
200 jabber_data_find_remote_by_cid(const gchar *cid) |
| 194 { |
201 { |
| 195 purple_debug_info("jabber", "lookup remote smiley with cid = %s\n", cid); |
202 purple_debug_info("jabber", "lookup remote data object with cid = %s\n", cid); |
| 196 |
203 |
| 197 return g_hash_table_lookup(remote_data_by_cid, cid); |
204 return g_hash_table_lookup(remote_data_by_cid, cid); |
| 198 } |
205 } |
| 199 |
206 |
| 200 void |
207 void |
| 201 jabber_data_associate_local(JabberData *data, const gchar *alt) |
208 jabber_data_associate_local(JabberData *data, const gchar *alt) |
| 202 { |
209 { |
| 203 purple_debug_info("jabber", "associating local smiley\n alt = %s, cid = %s\n", |
210 purple_debug_info("jabber", "associating local data object\n alt = %s, cid = %s\n", |
| 204 alt, jabber_data_get_cid(data)); |
211 alt , jabber_data_get_cid(data)); |
| 205 g_hash_table_insert(local_data_by_alt, g_strdup(alt), data); |
212 if (alt) |
| |
213 g_hash_table_insert(local_data_by_alt, g_strdup(alt), data); |
| 206 g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
214 g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
| 207 data); |
215 data); |
| 208 } |
216 } |
| 209 |
217 |
| 210 void |
218 void |
| 211 jabber_data_associate_remote(JabberData *data) |
219 jabber_data_associate_remote(JabberData *data) |
| 212 { |
220 { |
| 213 purple_debug_info("jabber", "associating remote smiley, cid = %s\n", |
221 purple_debug_info("jabber", "associating remote data object, cid = %s\n", |
| 214 jabber_data_get_cid(data)); |
222 jabber_data_get_cid(data)); |
| 215 g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
223 g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
| 216 data); |
224 data); |
| 217 } |
225 } |
| 218 |
226 |
| 237 if (who) |
245 if (who) |
| 238 xmlnode_set_attrib(result->node, "to", who); |
246 xmlnode_set_attrib(result->node, "to", who); |
| 239 xmlnode_set_attrib(result->node, "id", id); |
247 xmlnode_set_attrib(result->node, "id", id); |
| 240 xmlnode_insert_child(result->node, |
248 xmlnode_insert_child(result->node, |
| 241 jabber_data_get_xml_definition(data)); |
249 jabber_data_get_xml_definition(data)); |
| |
250 /* if the data object is temporary, destroy it and remove the references |
| |
251 to it */ |
| |
252 if (data->ephemeral) { |
| |
253 g_hash_table_remove(local_data_by_cid, cid); |
| |
254 } |
| 242 } |
255 } |
| 243 jabber_iq_send(result); |
256 jabber_iq_send(result); |
| 244 } |
257 } |
| 245 |
258 |
| 246 void |
259 void |