Changeset 2287
- Timestamp:
- 06/27/07 14:53:39
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/camel-folder.c (modified) (3 diffs)
- trunk/libtinymail-camel/camel-lite/camel/camel-folder.h (modified) (2 diffs)
- trunk/libtinymail-camel/camel-lite/camel/camel-mime-part.c (modified) (2 diffs)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c (modified) (3 diffs)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.c (modified) (2 diffs)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-folder-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-folder.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-mime-part.c (modified) (4 diffs)
- trunk/libtinymail-camel/tny-camel-mime-part.h (modified) (2 diffs)
- trunk/libtinymail-camel/tny-camel-msg.c (modified) (5 diffs)
- trunk/libtinymail-camel/tny-camel-msg.h (modified) (1 diff)
- trunk/libtinymail/tny-mime-part.c (modified) (2 diffs)
- trunk/libtinymail/tny-mime-part.h (modified) (4 diffs)
- trunk/libtinymail/tny-msg.c (modified) (1 diff)
- trunk/libtinymail/tny-msg.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2283 r2287 1 2007-06-27 Jose Dapena Paz <jdapena@igalia.com> 2 3 These changes add support for purging specific attachments 4 from cache, with an implementation in the IMAP backend. This 5 is a major API change. 6 7 * libtinymail/tny-msg.[ch]: 8 (tny_msg_rewrite_cache): added new method to rewrite cache 9 and expunge purged attachments if supported. 10 11 * libtinymail/tny-mime-part.[ch]: 12 (tny_mime_part_is_purged, tny_mime_part_set_purte): added two 13 methods that mark a mime part to be purged in cache (in 14 storages that support this). 15 16 * libtinymail-camel/tny-camel-folder.c: 17 (tny_camel_folder_rewrite_cache): new method that calls 18 the new Camel rewrite cache api for a message. 19 20 * libtinymail-camel/tny-camel-mime-part.[ch]: 21 implementation of tny_mime_part_is_purged and 22 tny_mime_part_set_purged, to mark parts to be purged 23 in IMAP. 24 25 * lintinymail-camel/camel-lite/camel/providers/camel-imap-folder.c: 26 (imap_rewrite_cache): new method that rewrites the cache representation 27 of a message purging attachments marked to be purged. 28 29 * libtinymail-camel/camel-lite/camel/providers/camel-imap-message-cache.[ch]: 30 (camel_imap_message_cache_replace_with_wrapper): replaces the cache 31 entry for a message with a new representation from wrapper. This should 32 purge attachments marked as purge, in collaboration with mime part. 33 34 * libtinymail-camel/camel-lite/camel/camel-folder.[ch]: 35 (rewrite_cache): added default empty implementation and virtual. 36 37 * libtinymail-camel/camel-lite/camel/camel-mime-part.c: 38 now, if message disposition is "purged", output for the attachment is 39 disabled. This should let user purge attachments on recaching. 40 41 * libtinymail-camel/tny-camel-msg.[ch]: 42 (tny_camel_msg_rewrite_cache_default, tny_camel_msg_rewrite_cache): implementation 43 of rewrite method using camel new methods to rewrite cache. 44 1 45 2007-06-27 Sergio Villar Senin <svillar@igalia.com> 2 46 trunk/libtinymail-camel/camel-lite/camel/camel-folder.c
r2267 r2287 120 120 static void 121 121 delete_attachments (CamelFolder *folder, const char *uid) 122 { 123 } 124 125 static void 126 rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg) 122 127 { 123 128 } … … 178 183 camel_folder_class->is_frozen = is_frozen; 179 184 camel_folder_class->delete_attachments = delete_attachments; 185 camel_folder_class->rewrite_cache = rewrite_cache; 180 186 181 187 /* virtual method overload */ … … 332 338 333 339 return CF_CLASS (folder)->delete_attachments (folder, uid); 340 } 341 342 void 343 camel_folder_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg) 344 { 345 g_return_if_fail (CAMEL_IS_FOLDER (folder)); 346 347 return CF_CLASS (folder)->rewrite_cache (folder, uid, msg); 334 348 } 335 349 trunk/libtinymail-camel/camel-lite/camel/camel-folder.h
r2268 r2287 207 207 208 208 void (*delete_attachments) (CamelFolder *folder, const char *uid); 209 void (*rewrite_cache) (CamelFolder *folder, const char *uid, CamelMimeMessage *msg); 209 210 210 211 } CamelFolderClass; … … 365 366 366 367 void camel_folder_delete_attachments (CamelFolder *folder, const char *uid); 368 void camel_folder_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg); 367 369 368 370 G_END_DECLS trunk/libtinymail-camel/camel-lite/camel/camel-mime-part.c
r2030 r2287 780 780 ssize_t count; 781 781 int errnosav; 782 const gchar *disposition; 782 783 783 784 d(printf("mime_part::write_to_stream\n")); … … 816 817 return -1; 817 818 total += count; 818 819 820 disposition = camel_mime_part_get_disposition (mp); 821 822 if (disposition != NULL && !strcmp (disposition, "purged")) { 823 camel_mime_part_set_content (mp, " ", 1, "text/plain"); 824 } 825 819 826 content = camel_medium_get_content_object(medium); 820 827 if (content) { trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
r2268 r2287 163 163 164 164 static void imap_delete_attachments (CamelFolder *folder, const char *uid); 165 static void imap_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg); 165 166 166 167 … … 195 196 camel_folder_class->thaw = imap_thaw; 196 197 camel_folder_class->delete_attachments = imap_delete_attachments; 198 camel_folder_class->rewrite_cache = imap_rewrite_cache; 197 199 198 200 camel_disco_folder_class->refresh_info_online = imap_refresh_info; … … 344 346 CamelImapMessageCache *cache = CAMEL_IMAP_FOLDER (folder)->cache; 345 347 camel_imap_message_cache_delete_attachments (cache, uid); 348 return; 349 } 350 351 static void 352 imap_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg) 353 { 354 CamelImapMessageCache *cache = CAMEL_IMAP_FOLDER (folder)->cache; 355 356 camel_imap_message_cache_replace_with_wrapper (cache, uid, CAMEL_DATA_WRAPPER (msg), NULL); 357 /* camel_imap_message_cache_remove (cache, uid); */ 358 /* camel_imap_message_cache_replace_cache (cache, uid, NULL, uid, ".purgetmp"); */ 346 359 return; 347 360 } trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.c
r2274 r2287 449 449 insert_finish (cache, uid, path, key, stream); 450 450 camel_object_unref (CAMEL_OBJECT (stream)); 451 } 452 } 453 454 /** 455 * camel_imap_message_cache_replace_with_wrapper: 456 * @cache: the cache 457 * @uid: UID of the message data to cache 458 * @part_spec: the IMAP part_spec of the data 459 * @wrapper: the wrapper to cache 460 * 461 * Caches the provided data into @cache. 462 **/ 463 void 464 camel_imap_message_cache_replace_with_wrapper (CamelImapMessageCache *cache, 465 const char *uid, 466 CamelDataWrapper *wrapper, CamelException *ex) 467 { 468 char *path, *key; 469 CamelStream *stream; 470 gchar *real = g_strdup_printf("%s/%s.purgetmp", cache->path, uid); 471 472 stream = camel_stream_fs_new_with_name (real, O_RDWR|O_CREAT|O_TRUNC, 0600); 473 g_free (real); 474 if (!stream) 475 return; 476 477 if (camel_data_wrapper_write_to_stream (wrapper, stream) == -1) { 478 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 479 _("Failed to cache message %s: %s"), 480 uid, g_strerror (errno)); 481 } else { 482 camel_object_unref (CAMEL_OBJECT (stream)); 483 camel_imap_message_cache_remove (cache, uid); 484 camel_imap_message_cache_replace_cache (cache, uid, NULL, uid, "purgetmp"); 485 camel_imap_message_cache_set_partial (cache, uid, TRUE); 451 486 } 452 487 } … … 648 683 } 649 684 685 void camel_imap_message_cache_replace_cache (CamelImapMessageCache *cache, const char *uid, const char *part_spec, 686 const char *dest_uid, const char *dest_part_spec) 687 { 688 gchar *real = g_strdup_printf ("%s/%s.%s", cache->path, uid, (part_spec)?part_spec:""); 689 gchar *dest_real = g_strdup_printf ("%s/%s.%s", cache->path, dest_uid, (dest_part_spec)?dest_part_spec:""); 690 691 rename (dest_real, real); 692 693 g_free (real); 694 g_free (dest_real); 695 696 } 650 697 void 651 698 camel_imap_message_cache_delete_attachments (CamelImapMessageCache *cache, const char *uid) trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.h
r2267 r2287 108 108 void camel_imap_message_cache_delete_attachments (CamelImapMessageCache *cache, const char *uid); 109 109 110 void camel_imap_message_cache_replace_cache (CamelImapMessageCache *cache, const char *uid, const char *part_spec, 111 const char *dest_uid, const char *dest_part_spec); 112 110 113 111 114 /* Standard Camel function */ trunk/libtinymail-camel/tny-camel-folder-priv.h
r2276 r2287 74 74 75 75 void _tny_camel_folder_uncache_attachments (TnyCamelFolder *self, const gchar *uid); 76 void _tny_camel_folder_rewrite_cache (TnyCamelFolder *self, const gchar *uid, CamelMimeMessage *msg); 76 77 77 78 void _tny_camel_folder_remove_folder_actual (TnyFolderStore *self, TnyFolder *folder, GError **err); trunk/libtinymail-camel/tny-camel-folder.c
r2286 r2287 453 453 454 454 camel_folder_delete_attachments (priv->folder, uid); 455 456 g_static_rec_mutex_unlock (priv->folder_lock); 457 } 458 459 void 460 _tny_camel_folder_rewrite_cache (TnyCamelFolder *self, const gchar *uid, CamelMimeMessage *msg) 461 { 462 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 463 464 g_static_rec_mutex_lock (priv->folder_lock); 465 466 if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 467 if (!load_folder_no_lock (priv)) 468 { 469 g_static_rec_mutex_unlock (priv->folder_lock); 470 return; 471 } 472 473 camel_folder_rewrite_cache (priv->folder, uid, msg); 455 474 456 475 g_static_rec_mutex_unlock (priv->folder_lock); trunk/libtinymail-camel/tny-camel-mime-part.c
r2225 r2287 589 589 } 590 590 591 static gboolean 592 tny_camel_mime_part_is_purged (TnyMimePart *self) 593 { 594 return TNY_CAMEL_MIME_PART_GET_CLASS (self)->is_purged_func (self); 595 } 596 597 static gboolean 598 tny_camel_mime_part_is_purged_default (TnyMimePart *self) 599 { 600 TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self); 601 const gchar *disposition; 602 603 disposition = camel_mime_part_get_disposition (priv->part); 604 return (disposition != NULL) && (!strcmp (disposition, "purged")); 605 } 606 591 607 static gboolean 592 608 tny_camel_mime_part_content_type_is (TnyMimePart *self, const gchar *type) … … 835 851 } 836 852 853 static void 854 tny_camel_mime_part_set_purged_default (TnyMimePart *self) 855 { 856 TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self); 857 858 g_mutex_lock (priv->part_lock); 859 camel_mime_part_set_disposition (priv->part, "purged"); 860 g_mutex_unlock (priv->part_lock); 861 } 862 863 static void 864 tny_camel_mime_part_set_purged (TnyMimePart *self) 865 { 866 TNY_CAMEL_MIME_PART_GET_CLASS (self)->set_purged_func (self); 867 return; 868 } 869 837 870 static void 838 871 tny_camel_mime_part_set_content_type_default (TnyMimePart *self, const gchar *content_type) … … 934 967 klass->get_description_func = tny_camel_mime_part_get_description; 935 968 klass->get_content_location_func = tny_camel_mime_part_get_content_location; 969 klass->is_purged_func = tny_camel_mime_part_is_purged; 936 970 klass->set_content_location_func = tny_camel_mime_part_set_content_location; 937 971 klass->set_description_func = tny_camel_mime_part_set_description; 972 klass->set_purged_func = tny_camel_mime_part_set_purged; 938 973 klass->set_content_id_func = tny_camel_mime_part_set_content_id; 939 974 klass->set_filename_func = tny_camel_mime_part_set_filename; … … 968 1003 class->get_description_func = tny_camel_mime_part_get_description_default; 969 1004 class->get_content_location_func = tny_camel_mime_part_get_content_location_default; 1005 class->is_purged_func = tny_camel_mime_part_is_purged_default; 1006 class->set_purged_func = tny_camel_mime_part_set_purged_default; 970 1007 class->set_content_location_func = tny_camel_mime_part_set_content_location_default; 971 1008 class->set_description_func = tny_camel_mime_part_set_description_default; trunk/libtinymail-camel/tny-camel-mime-part.h
r2129 r2287 60 60 const gchar* (*get_description_func) (TnyMimePart *self); 61 61 const gchar* (*get_content_location_func) (TnyMimePart *self); 62 gboolean (*is_purged_func) (TnyMimePart *self); 62 63 void (*set_content_location_func) (TnyMimePart *self, const gchar *content_location); 63 64 void (*set_description_func) (TnyMimePart *self, const gchar *description); … … 65 66 void (*set_filename_func) (TnyMimePart *self, const gchar *filename); 66 67 void (*set_content_type_func) (TnyMimePart *self, const gchar *contenttype); 68 void (*set_purged_func) (TnyMimePart *self); 67 69 gboolean (*is_attachment_func) (TnyMimePart *self); 68 70 void (*get_parts_func) (TnyMimePart *self, TnyList *list); trunk/libtinymail-camel/tny-camel-msg.c
r2285 r2287 202 202 } 203 203 204 static void 205 tny_camel_msg_rewrite_cache_default (TnyMsg *self) 206 { 207 TnyCamelMsgPriv *priv = TNY_CAMEL_MSG_GET_PRIVATE (self); 208 CamelMimeMessage *msg; 209 210 if (priv->folder && priv->header) { 211 msg = _tny_camel_msg_get_camel_mime_message (TNY_CAMEL_MSG (self)); 212 _tny_camel_folder_rewrite_cache (TNY_CAMEL_FOLDER(priv->folder), 213 tny_header_get_uid (priv->header), 214 msg); 215 } 216 return; 217 } 218 219 static void 220 tny_camel_msg_rewrite_cache (TnyMsg *self) 221 { 222 TNY_CAMEL_MSG_GET_CLASS (self)->rewrite_cache_func (self); 223 return; 224 } 225 204 226 static TnyHeader* 205 227 tny_camel_msg_get_header_default (TnyMsg *self) … … 327 349 klass->get_url_string_func = tny_camel_msg_get_url_string; 328 350 klass->uncache_attachments_func = tny_camel_msg_uncache_attachments; 351 klass->rewrite_cache_func = tny_camel_msg_rewrite_cache; 329 352 330 353 return; … … 335 358 { 336 359 GObjectClass *object_class; 337 360 338 361 parent_class = g_type_class_peek_parent (class); 339 362 object_class = (GObjectClass*) class; 340 363 341 364 class->get_header_func = tny_camel_msg_get_header_default; 342 365 class->get_folder_func = tny_camel_msg_get_folder_default; 343 366 class->get_url_string_func = tny_camel_msg_get_url_string_default; 344 367 class->uncache_attachments_func = tny_camel_msg_uncache_attachments_default; 345 368 class->rewrite_cache_func = tny_camel_msg_rewrite_cache_default; 369 346 370 object_class->finalize = tny_camel_msg_finalize; 347 371 348 372 g_type_class_add_private (object_class, sizeof (TnyCamelMsgPriv)); 349 373 … … 389 413 390 414 if (G_UNLIKELY(type == 0)) 391 {392 static const GTypeInfo info =393 {415 { 416 static const GTypeInfo info = 417 { 394 418 sizeof (TnyCamelMsgClass), 395 419 NULL, /* base_init */ … … 403 427 NULL 404 428 }; 405 429 406 430 static const GInterfaceInfo tny_msg_info = 407 {431 { 408 432 (GInterfaceInitFunc) tny_msg_init, /* interface_init */ 409 433 NULL, /* interface_finalize */ 410 434 NULL /* interface_data */ 411 435 }; 412 436 413 437 type = g_type_register_static (TNY_TYPE_CAMEL_MIME_PART, 414 "TnyCamelMsg",415 &info, 0);416 438 "TnyCamelMsg", 439 &info, 0); 440 417 441 g_type_add_interface_static (type, TNY_TYPE_MSG, 418 &tny_msg_info);419 442 &tny_msg_info); 443 420 444 } 421 445 trunk/libtinymail-camel/tny-camel-msg.h
r2267 r2287 56 56 gchar* (*get_url_string_func) (TnyMsg *self); 57 57 void (*uncache_attachments_func) (TnyMsg *self); 58 void (*rewrite_cache_func) (TnyMsg *self); 58 59 }; 59 60 trunk/libtinymail/tny-mime-part.c
r2129 r2287 293 293 294 294 /** 295 * tny_mime_part_set_purged: 296 * @self: a #TnyMimePart object 297 * 298 * Set the message as purged in cache 299 * 300 **/ 301 void 302 tny_mime_part_set_purged (TnyMimePart *self) 303 { 304 #ifdef DBC /* require */ 305 g_assert (TNY_IS_MIME_PART (self)); 306 g_assert (TNY_MIME_PART_GET_IFACE (self)->set_purged_func != NULL); 307 #endif 308 309 TNY_MIME_PART_GET_IFACE (self)->set_purged_func (self); 310 return; 311 } 312 313 /** 295 314 * tny_mime_part_set_filename: 296 315 * @self: a #TnyMimePart object … … 388 407 g_assert (retval == NULL || strlen (retval) > 0); 389 408 #endif 409 410 return retval; 411 } 412 413 /** 414 * tny_mime_part_is_purged: 415 * @self: a #TnyMimePart object 416 * 417 * Get if this attachment has been purged from cache. 418 * 419 * Return value: a #gboolean 420 * 421 **/ 422 gboolean 423 tny_mime_part_is_purged (TnyMimePart *self) 424 { 425 gboolean retval; 426 427 #ifdef DBC /* require */ 428 g_assert (TNY_IS_MIME_PART (self)); 429 g_assert (TNY_MIME_PART_GET_IFACE (self)->is_purged_func != NULL); 430 #endif 431 432 retval = TNY_MIME_PART_GET_IFACE (self)->is_purged_func (self); 390 433 391 434 return retval; trunk/libtinymail/tny-mime-part.h
r2129 r2287 54 54 const gchar* (*get_description_func) (TnyMimePart *self); 55 55 const gchar* (*get_content_location_func) (TnyMimePart *self); 56 gboolean (*is_purged_func) (TnyMimePart *self); 57 56 58 void (*set_content_location_func) (TnyMimePart *self, const gchar *content_location); 57 59 void (*set_description_func) (TnyMimePart *self, const gchar *description); … … 59 61 void (*set_filename_func) (TnyMimePart *self, const gchar *filename); 60 62 void (*set_content_type_func) (TnyMimePart *self, const gchar *contenttype); 63 void (*set_purged_func) (TnyMimePart *self); 61 64 gboolean (*is_attachment_func) (TnyMimePart *self); 62 65 void (*get_parts_func) (TnyMimePart *self, TnyList *list); … … 78 81 const gchar* tny_mime_part_get_description (TnyMimePart *self); 79 82 const gchar* tny_mime_part_get_content_location (TnyMimePart *self); 83 gboolean tny_mime_part_is_purged (TnyMimePart *self); 80 84 void tny_mime_part_set_content_location (TnyMimePart *self, const gchar *content_location); 81 85 void tny_mime_part_set_description (TnyMimePart *self, const gchar *description); … … 83 87 void tny_mime_part_set_filename (TnyMimePart *self, const gchar *filename); 84 88 void tny_mime_part_set_content_type (TnyMimePart *self, const gchar *contenttype); 89 void tny_mime_part_set_purged (TnyMimePart *self); 85 90 gboolean tny_mime_part_is_attachment (TnyMimePart *self); 86 91 void tny_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream); trunk/libtinymail/tny-msg.c
r2268 r2287 47 47 48 48 TNY_MSG_GET_IFACE (self)->uncache_attachments_func (self); 49 50 #ifdef DBC /* ensure */ 51 #endif 52 53 return; 54 } 55 56 /** 57 * tny_msg_rewrite_cache: 58 * @self: a #TnyMsg object 59 * 60 * API WARNING: This API might change 61 * 62 * Rewrite the message to cache, purging mime parts marked for purge. 63 * 64 **/ 65 void 66 tny_msg_rewrite_cache (TnyMsg *self) 67 { 68 #ifdef DBC /* require */ 69 g_assert (TNY_IS_MSG (self)); 70 g_assert (TNY_MSG_GET_IFACE (self)->rewrite_cache_func != NULL); 71 #endif 72 73 TNY_MSG_GET_IFACE (self)->rewrite_cache_func (self); 49 74 50 75 #ifdef DBC /* ensure */ trunk/libtinymail/tny-msg.h
r2267 r2287 47 47 gchar* (*get_url_string_func) (TnyMsg *self); 48 48 void (*uncache_attachments_func) (TnyMsg *self); 49 void (*rewrite_cache_func) (TnyMsg *self); 49 50 50 51 }; … … 56 57 gchar* tny_msg_get_url_string (TnyMsg *self); 57 58 void tny_msg_uncache_attachments (TnyMsg *self); 59 void tny_msg_rewrite_cache (TnyMsg *self); 58 60 59 61 G_END_DECLS
