Changeset 3687

Show
Ignore:
Timestamp:
06/03/08 18:03:34
Author:
jdapena
Message:

* libtinymail/tny-msg.[ch]:

        • New virtual methods get/set allow external images, to store
          user acceptation to allow mail client to fetch external images
          referenced in a message.

* libtinymail-camel/tny-camel-msg.[ch]:

        • Implement new public methods get/set allow external images
          available in TnyMsg interface. It uses TnyCamelFolder for
          implementation of storage of the flag.

* libtinymail-camel/tny-camel-folder.c,

libtinymail-camel/tny-camel-folder-priv.h:

        • In camel we delegate on folder for storing the "get external
          images" flag. Then we expose a private method for this, that
          will be called in TnyMsg public implementation.

* libtinymail-camel/camel-lite/camel/camel-folder.[ch]:

        • Add new virtual methods (not implemented here) for getting
          and setting "get external images" flag for each message.

* libtinymail-camel/camel-lite/camel/camel-data-cache.[ch]:

        • Implementation of storage of "get external images" flag in
          data cache. It stores a file with extension getimages in the
          same folder the message contents are retrieved.

* libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-folder.c:

        • Implement get/set allow external images methods. It stores
          it in the camel data cache using the methods the cache
          exposes for this.

* libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c:

        • Implement get/set allow external images methods. It also uses
          the data cache as nntp provider.

* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c:

        • Implement get/set allow external images methods. It relies on
          proper implementation in imap messages cache.

* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.[ch]:

        • Add storage of allow external images flag. It saves an empty
          file with extension getimages per allowed file (similar to
          is partial flag approach).

* libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c:

        • Implement get/set allow external images methods. It stores
          an empty file for each message in the folder maildir metadata
          directory (the one on top of cur, new and tmp).
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3683 r3687  
     12008-06-03  Jose Dapena Paz  <jdapena@igalia.com> 
     2 
     3        * libtinymail/tny-msg.[ch]: 
     4        New virtual methods get/set allow external images, to store 
     5        user acceptation to allow mail client to fetch external images 
     6        referenced in a message. 
     7 
     8        * libtinymail-camel/tny-camel-msg.[ch]: 
     9        Implement new public methods get/set allow external images 
     10        available in TnyMsg interface. It uses TnyCamelFolder for 
     11        implementation of storage of the flag. 
     12 
     13        * libtinymail-camel/tny-camel-folder.c, 
     14        libtinymail-camel/tny-camel-folder-priv.h: 
     15        In camel we delegate on folder for storing the "get external 
     16        images" flag. Then we expose a private method for this, that 
     17        will be called in TnyMsg public implementation. 
     18 
     19        * libtinymail-camel/camel-lite/camel/camel-folder.[ch]: 
     20        Add new virtual methods (not implemented here) for getting 
     21        and setting "get external images" flag for each message. 
     22 
     23        * libtinymail-camel/camel-lite/camel/camel-data-cache.[ch]: 
     24        Implementation of storage of "get external images" flag in 
     25        data cache. It stores a file with extension getimages in the 
     26        same folder the message contents are retrieved. 
     27 
     28        * libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-folder.c: 
     29        Implement get/set allow external images methods. It stores 
     30        it in the camel data cache using the methods the cache 
     31        exposes for this. 
     32 
     33        * libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c: 
     34        Implement get/set allow external images methods. It also uses 
     35        the data cache as nntp provider. 
     36 
     37        * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c: 
     38        Implement get/set allow external images methods. It relies on 
     39        proper implementation in imap messages cache. 
     40 
     41        * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.[ch]: 
     42        Add storage of allow external images flag. It saves an empty 
     43        file with extension getimages per allowed file (similar to 
     44        is partial flag approach). 
     45 
     46        * libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c: 
     47        Implement get/set allow external images methods. It stores 
     48        an empty file for each message in the folder maildir metadata 
     49        directory (the one on top of cur, new and tmp). 
     50 
    1512008-05-26  Philip Van Hoof <pvanhoof@gnome.org> 
    252 
  • trunk/libtinymail-camel/camel-lite/camel/camel-data-cache.c

    r3300 r3687  
    315315} 
    316316 
     317gboolean 
     318camel_data_cache_get_allow_external_images (CamelDataCache *cdc, const char *path, 
     319                                            const char *uid) 
     320{ 
     321        gboolean retval = FALSE; 
     322        gchar *mpath; char *dir; 
     323        guint32 hash; 
     324        hash = g_str_hash(uid); 
     325        hash = (hash>>5)&CAMEL_DATA_CACHE_MASK; 
     326        dir = alloca(strlen(cdc->path) + strlen(path) + 8); 
     327        sprintf(dir, "%s/%s/%02x", cdc->path, path, hash); 
     328 
     329        mpath = g_strdup_printf ("%s/%s.getimages", dir, uid); 
     330 
     331        retval = g_file_test (mpath, G_FILE_TEST_IS_REGULAR); 
     332 
     333        g_free (mpath); 
     334 
     335        return retval; 
     336} 
     337 
     338 
     339void 
     340camel_data_cache_set_allow_external_images (CamelDataCache *cdc, const char *path, 
     341                                            const char *uid, gboolean allow) 
     342{ 
     343        int fd; char *dir; 
     344        gchar *mpath; 
     345        guint32 hash; 
     346        hash = g_str_hash(uid); 
     347        hash = (hash>>5)&CAMEL_DATA_CACHE_MASK; 
     348        dir = alloca(strlen(cdc->path) + strlen(path) + 8); 
     349        sprintf(dir, "%s/%s/%02x", cdc->path, path, hash); 
     350 
     351        mpath = g_strdup_printf ("%s/%s.getimages", dir, uid); 
     352 
     353        if (!allow) 
     354        { 
     355                if (g_file_test (mpath, G_FILE_TEST_IS_REGULAR)) 
     356                        g_unlink (mpath); 
     357        } else { 
     358                if (!g_file_test (mpath, G_FILE_TEST_IS_REGULAR)) 
     359                { 
     360                    fd = g_open (mpath, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600); 
     361                    if (fd != -1) 
     362                        close (fd); 
     363                } 
     364        } 
     365 
     366        g_free (mpath); 
     367 
     368} 
     369 
    317370 
    318371/* Since we have to stat the directory anyway, we use this opportunity to 
  • trunk/libtinymail-camel/camel-lite/camel/camel-data-cache.h

    r2950 r3687  
    9696void         camel_data_cache_set_partial (CamelDataCache *cache, const char *path, 
    9797                                              const char *uid, gboolean partial); 
     98gboolean     camel_data_cache_get_allow_external_images (CamelDataCache *cache, const char *path, 
     99                                                         const char *uid); 
     100void         camel_data_cache_set_allow_external_images (CamelDataCache *cache, const char *path, 
     101                                                         const char *uid, gboolean allow); 
    98102void         camel_data_cache_delete_attachments (CamelDataCache *cdc, const char *path, 
    99103                                              const char *key); 
  • trunk/libtinymail-camel/camel-lite/camel/camel-folder.c

    r3635 r3687  
    181181static void 
    182182rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg) 
     183{ 
     184} 
     185 
     186static gboolean 
     187get_allow_external_images (CamelFolder *folder, const char *uid) 
     188{ 
     189        return FALSE; 
     190} 
     191 
     192static void 
     193set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow) 
    183194{ 
    184195} 
     
    247258        camel_folder_class->delete_attachments = delete_attachments; 
    248259        camel_folder_class->rewrite_cache = rewrite_cache; 
     260        camel_folder_class->get_allow_external_images = get_allow_external_images; 
     261        camel_folder_class->set_allow_external_images = set_allow_external_images; 
    249262 
    250263        /* virtual method overload */ 
     
    413426 
    414427        CF_CLASS (folder)->rewrite_cache (folder, uid, msg); 
     428 
     429        return; 
     430} 
     431 
     432gboolean 
     433camel_folder_get_allow_external_images (CamelFolder *folder, const char *uid) 
     434{ 
     435        g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); 
     436      
     437        return CF_CLASS (folder)->get_allow_external_images (folder, uid); 
     438} 
     439 
     440void 
     441camel_folder_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow) 
     442{ 
     443        g_return_if_fail (CAMEL_IS_FOLDER (folder)); 
     444      
     445        CF_CLASS (folder)->set_allow_external_images (folder, uid, allow); 
    415446 
    416447        return; 
  • trunk/libtinymail-camel/camel-lite/camel/camel-folder.h

    r3070 r3687  
    217217        void (*rewrite_cache) (CamelFolder *folder, const char *uid, CamelMimeMessage *msg); 
    218218 
     219        gboolean (*get_allow_external_images) (CamelFolder *folder, const char *uid); 
     220        void (*set_allow_external_images) (CamelFolder *folder, const char *uid, gboolean allow); 
     221 
    219222        char* (*get_cache_filename) (CamelFolder *folder, const char *uid, const char *spec, CamelFolderPartState *state); 
    220223        char* (*fetch) (CamelFolder *folder, const char *uid, const char *spec, gboolean *binary, CamelException *ex); 
     
    381384void camel_folder_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg); 
    382385 
     386gboolean camel_folder_get_allow_external_images (CamelFolder *folder, const char *uid); 
     387void camel_folder_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow); 
     388 
    383389char* camel_folder_fetch (CamelFolder *folder, const char *uid, const char *spec, gboolean *binary, CamelException *ex); 
    384390char* camel_folder_fetch_structure (CamelFolder *folder, const char *uid, CamelException *ex); 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c

    r3682 r3687  
    177177static void imap_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg); 
    178178 
     179static gboolean imap_get_allow_external_images (CamelFolder *folder, const char *uid); 
     180static void imap_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow); 
    179181 
    180182static void stop_gmsgstore_from_idle (CamelImapFolder *imap_folder); 
     
    215217        camel_folder_class->delete_attachments = imap_delete_attachments; 
    216218        camel_folder_class->rewrite_cache = imap_rewrite_cache; 
     219        camel_folder_class->get_allow_external_images = imap_get_allow_external_images; 
     220        camel_folder_class->set_allow_external_images = imap_set_allow_external_images; 
    217221 
    218222        camel_disco_folder_class->refresh_info_online = imap_refresh_info; 
     
    377381/*      camel_imap_message_cache_remove (cache, uid); */ 
    378382/*      camel_imap_message_cache_replace_cache (cache, uid, NULL, uid, ".purgetmp"); */ 
     383        return; 
     384} 
     385 
     386static gboolean 
     387imap_get_allow_external_images (CamelFolder *folder, const char *uid) 
     388{ 
     389        CamelImapMessageCache *cache = CAMEL_IMAP_FOLDER (folder)->cache; 
     390 
     391        return camel_imap_message_cache_get_allow_external_images (cache, uid); 
     392} 
     393 
     394static void 
     395imap_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow) 
     396{ 
     397        CamelImapMessageCache *cache = CAMEL_IMAP_FOLDER (folder)->cache; 
     398 
     399        camel_imap_message_cache_set_allow_external_images (cache, uid, allow); 
     400 
    379401        return; 
    380402} 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.c

    r3300 r3687  
    3333 
    3434#include <string.h> 
     35#include <sys/stat.h> 
    3536#include <sys/types.h> 
    3637 
     
    395396 
    396397        g_free (path); 
     398} 
     399 
     400gboolean 
     401camel_imap_message_cache_get_allow_external_images (CamelImapMessageCache *cache, const char *uid) 
     402{ 
     403        gchar *path = g_strdup_printf ("%s/%s.getimages", cache->path, uid); 
     404        gboolean retval = FALSE; 
     405 
     406        retval = g_file_test (path, G_FILE_TEST_IS_REGULAR); 
     407 
     408        g_free (path); 
     409 
     410        return retval; 
     411} 
     412 
     413void 
     414camel_imap_message_cache_set_allow_external_images (CamelImapMessageCache *cache, const char *uid, gboolean allow) 
     415{ 
     416        gchar *path = g_strdup_printf ("%s/%s.getimages", cache->path, uid); 
     417        int fd; 
     418 
     419        if (!allow) 
     420        { 
     421                if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) 
     422                        g_unlink (path); 
     423        } else { 
     424                if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) 
     425                { 
     426                    fd = g_open (path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600); 
     427                    if (fd != -1) 
     428                        close (fd); 
     429                } 
     430        } 
     431 
     432        g_free (path);   
    397433} 
    398434 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-message-cache.h

    r2950 r3687  
    111111                                             const char *dest_uid, const char *dest_part_spec); 
    112112 
     113gboolean camel_imap_message_cache_get_allow_external_images (CamelImapMessageCache *cache, const char *uid); 
     114void camel_imap_message_cache_set_allow_external_images (CamelImapMessageCache *cache, const char *uid, gboolean allow); 
     115 
    113116void 
    114117camel_imap_message_cache_replace_with_wrapper (CamelImapMessageCache *cache, 
  • trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c

    r3523 r3687  
    3434 
    3535#include <glib/gi18n-lib.h> 
     36#include <glib/gstdio.h> 
    3637 
    3738#include "camel-data-wrapper.h" 
     
    3940#include "camel-mime-message.h" 
    4041#include "camel-stream-fs.h" 
     42#include "camel-file-utils.h" 
    4143 
    4244#include "camel-maildir-folder.h" 
     
    6062 
    6163static void maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex); 
     64 
     65static gboolean maildir_get_allow_external_images (CamelFolder *folder, const char *uid); 
     66static void maildir_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow); 
    6267 
    6368 
     
    108113        camel_folder_class->get_message = maildir_get_message; 
    109114        camel_folder_class->rewrite_cache = maildir_rewrite_cache; 
     115        camel_folder_class->get_allow_external_images = maildir_get_allow_external_images; 
     116        camel_folder_class->set_allow_external_images = maildir_set_allow_external_images; 
    110117 
    111118        //camel_folder_class->transfer_messages_to = maildir_transfer_messages_to; 
     
    408415        g_free (dest); 
    409416} 
     417 
     418static gboolean 
     419maildir_get_allow_external_images (CamelFolder *folder, const char *uid) 
     420{ 
     421        CamelLocalFolder *lf = (CamelLocalFolder *) folder; 
     422        char *name = NULL; 
     423        gboolean retval; 
     424 
     425        /* write it out to tmp, use the uid we got from the summary */ 
     426        name = g_strdup_printf("%s/%s.getimages", lf->folder_path, uid); 
     427        retval = g_file_test (name, G_FILE_TEST_IS_REGULAR); 
     428        g_free (name); 
     429        return retval; 
     430} 
     431 
     432static void 
     433maildir_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow) 
     434{ 
     435        CamelLocalFolder *lf = (CamelLocalFolder *) folder; 
     436        char *name = NULL; 
     437        int fd; 
     438 
     439        /* write it out to tmp, use the uid we got from the summary */ 
     440        name = g_strdup_printf("%s/%s.getimages", lf->folder_path, uid); 
     441 
     442        if (!allow) 
     443        { 
     444                if (g_file_test (name, G_FILE_TEST_IS_REGULAR)) 
     445                        g_unlink (name); 
     446        } else { 
     447                if (!g_file_test (name, G_FILE_TEST_IS_REGULAR)) 
     448                { 
     449                    fd = g_open (name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600); 
     450                    if (fd != -1) 
     451                        close (fd); 
     452                } 
     453        } 
     454 
     455        g_free (name);   
     456} 
     457 
  • trunk/libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-folder.c

    r2950 r3687  
    407407} 
    408408 
     409static gboolean 
     410nntp_folder_get_allow_external_images (CamelFolder *folder, const char *uid) 
     411{ 
     412        gboolean retval; 
     413        CamelNNTPStore *nntp_store; 
     414 
     415        nntp_store = (CamelNNTPStore *) folder->parent_store; 
     416        retval = camel_data_cache_get_allow_external_images (nntp_store->cache, "cache", uid); 
     417         
     418        return retval; 
     419} 
     420 
     421static gboolean 
     422nntp_folder_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow) 
     423{ 
     424        CamelNNTPStore *nntp_store; 
     425 
     426        nntp_store = (CamelNNTPStore *) folder->parent_store; 
     427        camel_data_cache_set_allow_external_images (nntp_store->cache, "cache", uid, allow); 
     428         
     429        return; 
     430} 
     431 
    409432static void 
    410433nntp_folder_init (CamelNNTPFolder *nntp_folder, CamelNNTPFolderClass *klass) 
     
    461484        camel_folder_class->search_by_uids = nntp_folder_search_by_uids; 
    462485        camel_folder_class->search_free = nntp_folder_search_free; 
     486        camel_folder_class->get_allow_external_images = nntp_folder_get_allow_external_images; 
     487        camel_folder_class->set_allow_external_images = nntp_folder_set_allow_external_images; 
    463488} 
    464489 
  • trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c

    r3670 r3687  
    8181 
    8282static void pop3_delete_attachments (CamelFolder *folder, const char *uid); 
     83static gboolean pop3_get_allow_external_images (CamelFolder *folder, const char *uid); 
     84static void pop3_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow); 
    8385 
    8486static void 
     
    10701072} 
    10711073 
     1074static gboolean 
     1075pop3_get_allow_external_images (CamelFolder *folder, const char *uid) 
     1076{ 
     1077        gboolean retval; 
     1078        CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store); 
     1079        retval = camel_data_cache_get_allow_external_images (pop3_store->cache, "cache", uid); 
     1080        return retval; 
     1081} 
     1082 
     1083static void 
     1084pop3_set_allow_external_images (CamelFolder *folder, const char *uid, gboolean allow) 
     1085{ 
     1086        gboolean retval; 
     1087        CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store); 
     1088        camel_data_cache_set_allow_external_images (pop3_store->cache, "cache", uid, allow); 
     1089        return; 
     1090} 
     1091 
    10721092static CamelMimeMessage * 
    10731093pop3_get_message (CamelFolder *folder, const char *uid, CamelFolderReceiveType type, gint param, CamelException *ex) 
     
    18221842        camel_folder_class->set_message_flags = pop3_set_message_flags; 
    18231843        camel_folder_class->delete_attachments = pop3_delete_attachments; 
     1844        camel_folder_class->get_allow_external_images = pop3_get_allow_external_images; 
     1845        camel_folder_class->set_allow_external_images = pop3_set_allow_external_images; 
    18241846 
    18251847        camel_disco_folder_class->refresh_info_online = pop3_refresh_info; 
  • trunk/libtinymail-camel/tny-camel-folder-priv.h

    r3574 r3687  
    7979void _tny_camel_folder_rewrite_cache (TnyCamelFolder *self, const gchar *uid, CamelMimeMessage *msg); 
    8080 
     81gboolean _tny_camel_folder_get_allow_external_images (TnyCamelFolder *self, const gchar *uid); 
     82void _tny_camel_folder_set_allow_external_images (TnyCamelFolder *self, const gchar *uid, gboolean allow); 
     83 
    8184void _tny_camel_folder_remove_folder_actual (TnyFolderStore *self, TnyFolder *folder, TnyFolderStoreChange *change, GError **err); 
    8285 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r3672 r3687  
    667667} 
    668668 
    669  
     669gboolean 
     670_tny_camel_folder_get_allow_external_images (TnyCamelFolder *self, const gchar *uid) 
     671
     672        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
     673        gboolean retval; 
     674 
     675        g_static_rec_mutex_lock (priv->folder_lock); 
     676 
     677        if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 
     678                if (!load_folder_no_lock (priv)) 
     679                { 
     680                        g_static_rec_mutex_unlock (priv->folder_lock); 
     681                        return FALSE; 
     682                } 
     683 
     684        retval = camel_folder_get_allow_external_images (priv->folder, uid); 
     685 
     686        g_static_rec_mutex_unlock (priv->folder_lock); 
     687        return retval; 
     688
     689 
     690void 
     691_tny_camel_folder_set_allow_external_images (TnyCamelFolder *self, const gchar *uid, gboolean allow) 
     692
     693        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
     694        gboolean retval; 
     695 
     696        g_static_rec_mutex_lock (priv->folder_lock); 
     697 
     698        if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 
     699                if (!load_folder_no_lock (priv)) 
     700                { 
     701                        g_static_rec_mutex_unlock (priv->folder_lock); 
     702                        return; 
     703                } 
     704 
     705        camel_folder_set_allow_external_images (priv->folder, uid, allow); 
     706 
     707        g_static_rec_mutex_unlock (priv->folder_lock); 
     708
    670709 
    671710static gboolean 
  • trunk/libtinymail-camel/tny-camel-msg.c

    r3666 r3687  
    229229} 
    230230 
     231static gboolean 
     232tny_camel_msg_get_allow_external_images_default (TnyMsg *self) 
     233{ 
     234        TnyCamelMsgPriv *priv = TNY_CAMEL_MSG_GET_PRIVATE (self); 
     235        gboolean allow = FALSE; 
     236         
     237        if (priv->folder && priv->header) { 
     238                gchar *uid; 
     239                uid = tny_header_dup_uid (priv->header); 
     240                allow = _tny_camel_folder_get_allow_external_images (TNY_CAMEL_FOLDER(priv->folder), 
     241                                                                     uid); 
     242                g_free (uid); 
     243        } 
     244        return allow; 
     245} 
     246 
     247static gboolean 
     248tny_camel_msg_get_allow_external_images (TnyMsg *self) 
     249{ 
     250        return TNY_CAMEL_MSG_GET_CLASS (self)->get_allow_external_images (self); 
     251} 
     252 
     253static void 
     254tny_camel_msg_set_allow_external_images_default (TnyMsg *self, gboolean allow) 
     255{ 
     256        TnyCamelMsgPriv *priv = TNY_CAMEL_MSG_GET_PRIVATE (self); 
     257 
     258        if (priv->folder && priv->header) { 
     259                gchar *uid; 
     260                uid = tny_header_dup_uid (priv->header); 
     261                _tny_camel_folder_set_allow_external_images (TNY_CAMEL_FOLDER(priv->folder), 
     262                                                             uid, allow); 
     263                g_free (uid); 
     264        } 
     265        return; 
     266} 
     267 
     268static void 
     269tny_camel_msg_set_allow_external_images (TnyMsg *self, gboolean allow) 
     270{ 
     271        TNY_CAMEL_MSG_GET_CLASS (self)->set_allow_external_images (self, allow); 
     272        return; 
     273} 
     274 
    231275static TnyHeader* 
    232276tny_camel_msg_get_header_default (TnyMsg *self) 
     
    360404        klass->uncache_attachments= tny_camel_msg_uncache_attachments; 
    361405        klass->rewrite_cache= tny_camel_msg_rewrite_cache; 
     406        klass->get_allow_external_images = tny_camel_msg_get_allow_external_images; 
     407        klass->set_allow_external_images = tny_camel_msg_set_allow_external_images; 
    362408 
    363409        return; 
     
    377423        class->uncache_attachments= tny_camel_msg_uncache_attachments_default; 
    378424        class->rewrite_cache= tny_camel_msg_rewrite_cache_default; 
     425        class->get_allow_external_images = tny_camel_msg_get_allow_external_images_default; 
     426        class->set_allow_external_images = tny_camel_msg_set_allow_external_images_default; 
    379427         
    380428        object_class->finalize = tny_camel_msg_finalize; 
  • trunk/libtinymail-camel/tny-camel-msg.h

    r3304 r3687  
    5757        void (*uncache_attachments) (TnyMsg *self); 
    5858        void (*rewrite_cache) (TnyMsg *self); 
     59        gboolean (*get_allow_external_images) (TnyMsg *self); 
     60        void (*set_allow_external_images) (TnyMsg *self, gboolean allow); 
    5961}; 
    6062 
  • trunk/libtinymail/tny-msg.c

    r3666 r3687  
    8989 
    9090        return; 
     91} 
     92 
     93/** 
     94 * tny_msg_set_allow_external_images: 
     95 * @self: a #TnyMsg 
     96 * @allow: a #gboolean 
     97 *  
     98 * API WARNING: This API might change 
     99 *  
     100 * Set if views should fetch external images referenced 
     101 * in this message or not. 
     102 * 
     103 * since: 1.0 
     104 * audience: application-developer 
     105 **/ 
     106void 
     107tny_msg_set_allow_external_images (TnyMsg *self, gboolean allow) 
     108{ 
     109#ifdef DBC /* require */ 
     110        g_assert (TNY_IS_MSG (self)); 
     111        g_assert (TNY_MSG_GET_IFACE (self)->get_allow_external_images != NULL); 
     112#endif 
     113 
     114        TNY_MSG_GET_IFACE (self)->set_allow_external_images (self, allow); 
     115 
     116#ifdef DBC /* ensure */ 
     117#endif 
     118 
     119        return; 
     120} 
     121 
     122 
     123/** 
     124 * tny_msg_get_allow_external_images: 
     125 * @self: a #TnyMsg 
     126 *  
     127 * API WARNING: This API might change 
     128 *  
     129 * Get if views should fetch external images into message. 
     130 * 
     131 * Returns: a #gboolean 
     132 * 
     133 * since: 1.0 
     134 * audience: application-developer 
     135 **/ 
     136gboolean 
     137tny_msg_get_allow_external_images (TnyMsg *self) 
     138{ 
     139        gboolean retval; 
     140#ifdef DBC /* require */ 
     141        g_assert (TNY_IS_MSG (self)); 
     142        g_assert (TNY_MSG_GET_IFACE (self)->get_allow_external_images != NULL); 
     143#endif 
     144 
     145        retval = TNY_MSG_GET_IFACE (self)->get_allow_external_images (self); 
     146 
     147#ifdef DBC /* ensure */ 
     148#endif 
     149 
     150        return retval; 
    91151} 
    92152 
  • trunk/libtinymail/tny-msg.h

    r3304 r3687  
    4848        void (*uncache_attachments) (TnyMsg *self); 
    4949        void (*rewrite_cache) (TnyMsg *self); 
     50        gboolean (*get_allow_external_images) (TnyMsg *self); 
     51        void (*set_allow_external_images) (TnyMsg *self, gboolean allow); 
    5052 
    5153}; 
     
    5860void tny_msg_uncache_attachments (TnyMsg *self); 
    5961void tny_msg_rewrite_cache (TnyMsg *self); 
     62gboolean tny_msg_get_allow_external_images (TnyMsg *self); 
     63void tny_msg_set_allow_external_images (TnyMsg *self, gboolean allow); 
    6064 
    6165G_END_DECLS