Changeset 2069

Show
Ignore:
Timestamp:
06/03/07 13:34:36
Author:
pvanhoof
Message:

Support for removing messages from POP after retrieval and tny_header_get_uid changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2068 r2069  
     12007-06-03  Philip Van Hoof  <pvanhoof@gnome.org> 
     2 
     3        * Support for removing messages from a POP server after retrieval 
     4        * Support for tny_header_get_uid on TnyMsg's header instance 
     5 
     6        * This was a major API change 
     7 
    182007-06-01  Murray Cumming  <murrayc@murrayc.com> 
    29 
     
    1522        the on_connection_event() signal handler. This always seems to indicate  
    1623        failure on Maemo Bora, but maybe it works properly in later versions. 
    17         It is OK for this to block because the Maemo connection dialog is totally  
    18         modal anyway, and because most applications will not be able to do anything  
    19         sensible while waiting, because the user is already waiting for an operation  
    20         that he has initiated. 
     24        It is OK for this to block because the Maemo connection dialog is  
     25        totally modal anyway, and because most applications will not be able  
     26        to do anything sensible while waiting, because the user is already  
     27        waiting for an operation that he has initiated. 
    2128 
    2229        * libtinymail/tny-folder.c: (tny_folder_get_all_count): Warn when this  
    23         is not implemented. Maybe not very necessary, but I seem to have had this  
    24         in my local checkout and maybe things crash without the check. Can be removed  
    25         later if you like. 
     30        is not implemented. Maybe not very necessary, but I seem to have had  
     31        this in my local checkout and maybe things crash without the check.  
     32        Can be removed later if you like. 
    2633 
    27342007-05-29  Philip Van Hoof  <pvanhoof@gnome.org> 
  • trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c

    r2037 r2069  
    840840                camel_object_unref((CamelObject *)message); 
    841841                message = NULL; 
     842        } else { 
     843                if (type & CAMEL_FOLDER_RECEIVE_FULL && pop3_store->immediate_delete_after) 
     844                { 
     845                        struct _CamelPOP3Command *cmd = NULL; 
     846                        cmd = camel_pop3_engine_command_new(pop3_store->engine, 0, NULL, NULL, "DELE %u\r\n", uid); 
     847                        while (camel_pop3_engine_iterate(pop3_store->engine, cmd) > 0); 
     848                        camel_pop3_engine_command_free(pop3_store->engine, cmd); 
     849                } 
    842850        } 
    843851 
  • trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c

    r2063 r2069  
    879879camel_pop3_store_init (gpointer object, gpointer klass) 
    880880{ 
     881        CamelPOP3Store *store = (CamelPOP3Store *) object; 
     882 
     883        store->immediate_delete_after = FALSE; 
    881884 
    882885        return; 
  • trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.h

    r1943 r2069  
    4747        struct _CamelDataCache *cache; 
    4848        guint delete_after; 
     49        gboolean immediate_delete_after; 
    4950        gchar *storage_path, *base_url; 
    5051        gboolean connected; 
  • trunk/libtinymail-camel/tny-camel-full-msg-receive-strategy.c

    r1920 r2069  
    8282                        message = tny_camel_msg_new (); 
    8383                        _tny_camel_msg_set_folder (TNY_CAMEL_MSG (message), folder); 
     84                        TNY_CAMEL_MSG_HEADER (nheader)->old_uid = g_strdup (tny_header_get_uid (header)); 
    8485                        _tny_camel_msg_set_header (TNY_CAMEL_MSG (message), nheader); 
    8586                        _tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message),  
  • trunk/libtinymail-camel/tny-camel-msg-header-priv.h

    r1700 r2069  
    4949        TnyFolder *folder; 
    5050        CamelMimeMessage *msg; 
    51         gchar *mime_from
     51        gchar *mime_from, *old_uid
    5252}; 
    5353 
  • trunk/libtinymail-camel/tny-camel-msg-header.c

    r1920 r2069  
    322322tny_camel_msg_header_get_uid (TnyHeader *self) 
    323323{ 
    324         return NULL; 
     324        TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self); 
     325 
     326        if (!me->old_uid) 
     327        { 
     328                g_warning ("tny_header_get_uid: This is a header instance for a new message. " 
     329                        "The uid of it is therefore not available. This indicates a problem " 
     330                        "in the software."); 
     331        } 
     332 
     333        return me->old_uid; 
    325334} 
    326335 
     
    328337tny_camel_msg_header_finalize (GObject *object) 
    329338{ 
     339        TnyCamelMsgHeader *me = (TnyCamelMsgHeader *) object; 
     340 
     341        if (me->old_uid) 
     342                g_free (me->old_uid); 
     343 
    330344        (*parent_class->finalize) (object); 
    331345 
     
    353367                and remove it in the finalize. Same for folder. */ 
    354368 
     369        self->old_uid = NULL; 
    355370        self->msg = msg;  
    356371        self->folder = folder; 
  • trunk/libtinymail-camel/tny-camel-partial-msg-receive-strategy.c

    r1926 r2069  
    8282                        message = tny_camel_msg_new (); 
    8383                        _tny_camel_msg_set_folder (TNY_CAMEL_MSG (message), folder); 
     84                        TNY_CAMEL_MSG_HEADER (nheader)->old_uid = g_strdup (tny_header_get_uid (header)); 
    8485                        _tny_camel_msg_set_header (TNY_CAMEL_MSG (message), nheader); 
    8586                        _tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message),  
  • trunk/libtinymail-camel/tny-camel-pop-store-account-priv.h

    r1383 r2069  
    2727        TnyFolder *inbox; 
    2828        GMutex *lock; 
    29         gboolean delete_originals; 
    3029}; 
    3130 
  • trunk/libtinymail-camel/tny-camel-pop-store-account.c

    r1997 r2069  
    3737#include <camel/camel-session.h> 
    3838#include <camel/camel-store.h> 
     39#include <camel/providers/pop3/camel-pop3-store.h> 
    3940 
    4041#ifndef CAMEL_FOLDER_TYPE_SENT 
     
    166167} 
    167168 
     169 
    168170/** 
    169  * tny_camel_pop_store_account_get_delete_originals
     171 * tny_camel_pop_store_account_set_leave_messages_on_server
    170172 * @self: a TnyCamelPOPStoreAccount 
    171  * 
    172  * Get the delete originals property of @self. 
    173  * 
    174  * Return value: Whether or not to delete original messages from the service 
    175  **/ 
    176 gboolean  
    177 tny_camel_pop_store_account_get_delete_originals (TnyCamelPOPStoreAccount *self) 
    178 
    179         TnyCamelPopStoreAccountPriv *priv = TNY_CAMEL_POP_STORE_ACCOUNT_GET_PRIVATE (self); 
    180  
    181         return priv->delete_originals; 
    182 
    183  
    184 /** 
    185  * tny_camel_pop_store_account_set_delete_originals: 
    186  * @self: a TnyCamelPOPStoreAccount 
    187  * @delete_originals: Whether or not to delete original messages from the service 
    188  * 
    189  * Set the delete originals property of @self. 
    190  * 
     173 * @enabled: whether to leave messages on the server 
     174 * 
     175 * Set whether messages should be left on the server. The initialization value 
     176 * of @enabled is TRUE (so by default, messages are left on the server). 
    191177 **/ 
    192178void  
    193 tny_camel_pop_store_account_set_delete_originals (TnyCamelPOPStoreAccount *self, gboolean delete_originals
    194 { 
    195         TnyCamelPopStoreAccountPriv *priv = TNY_CAMEL_POP_STORE_ACCOUNT_GET_PRIVATE (self); 
    196  
    197         g_warning ("tny_camel_pop_store_account_set_delete_originals is not yet supported\n"); 
    198  
    199         priv->delete_originals = delete_originals; 
    200 
     179tny_camel_pop_store_account_set_leave_messages_on_server (TnyCamelPOPStoreAccount *self, gboolean enabled
     180{ 
     181        const CamelService *service = _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (self)); 
     182        CamelPOP3Store *pop3_store = (CamelPOP3Store *) service; 
     183 
     184        pop3_store->immediate_delete_after = !enabled; 
     185
     186 
    201187 
    202188static void 
     
    204190{ 
    205191        TnyCamelPopStoreAccountPriv *priv = TNY_CAMEL_POP_STORE_ACCOUNT_GET_PRIVATE (instance); 
    206  
     192        const CamelService *service = _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (instance)); 
     193        CamelPOP3Store *pop3_store = (CamelPOP3Store *) service; 
     194 
     195        pop3_store->immediate_delete_after = FALSE; 
    207196        priv->lock = g_mutex_new (); 
    208197        priv->inbox = NULL; 
    209         priv->delete_originals = FALSE; 
    210198 
    211199        return; 
  • trunk/libtinymail-camel/tny-camel-pop-store-account.h

    r1383 r2069  
    5252TnyStoreAccount* tny_camel_pop_store_account_new (void); 
    5353 
    54 gboolean tny_camel_pop_store_account_get_delete_originals (TnyCamelPOPStoreAccount *self); 
    55 void tny_camel_pop_store_account_set_delete_originals (TnyCamelPOPStoreAccount *self, gboolean delete_originals); 
     54void tny_camel_pop_store_account_set_leave_messages_on_server (TnyCamelPOPStoreAccount *self, gboolean enabled); 
    5655 
    5756G_END_DECLS 
  • trunk/libtinymail-camel/tny-camel-send-queue-priv.h

    r1407 r2069  
    3434        GMutex *todo_lock, *sending_lock;  
    3535        gboolean creating_spin; 
    36         gboolean do_continue
     36        gboolean do_continue, is_running
    3737}; 
    3838 
  • trunk/libtinymail-camel/tny-camel-send-queue.c

    r2047 r2069  
    102102        TnyList *list; 
    103103 
     104        priv->is_running = TRUE; 
    104105        priv->creating_spin = FALSE; 
    105106 
     
    233234errorhandler: 
    234235 
     236        priv->is_running = FALSE; 
     237 
    235238        g_object_unref (G_OBJECT (sentbox)); 
    236239        g_object_unref (G_OBJECT (outbox)); 
     
    248251        TnyCamelSendQueuePriv *priv = TNY_CAMEL_SEND_QUEUE_GET_PRIVATE (self); 
    249252 
    250         while (priv->creating_spin); 
    251  
    252         priv->creating_spin = TRUE; 
    253  
    254         priv->thread = g_thread_create (thread_main, g_object_ref (self), 
    255                 TRUE, NULL); 
     253        if (!priv->is_running) 
     254        { 
     255                while (priv->creating_spin); 
     256                priv->creating_spin = TRUE; 
     257                priv->thread = g_thread_create (thread_main,  
     258                        g_object_ref (self), TRUE, NULL); 
     259        } 
    256260 
    257261        return; 
     
    609613 * @self: a valid #TnyCamelSendQueue instance 
    610614 * 
    611  * (try to) flush the messages which are currently in this send queue 
    612  *  (persisted in the outbox folder) 
    613  *  
     615 * Flush the messages which are currently in this send queue 
    614616 **/ 
    615617void 
     
    617619{ 
    618620        TnyCamelSendQueuePriv *priv; 
    619          
     621 
    620622        g_return_if_fail (TNY_IS_CAMEL_SEND_QUEUE(self)); 
    621623 
     
    690692        priv->sending_lock = g_mutex_new (); 
    691693        priv->do_continue = FALSE; 
     694        priv->is_running = FALSE; 
    692695 
    693696        return;