Changeset 3710

Show
Ignore:
Timestamp:
07/01/08 15:47:45
Author:
jdapena
Message:

Merge of trunk patches r3664, r3665, r3704 and r3705.
* libtinymail-camel/tny-camel-queue.c: Letting the thread wait for

more items instead of exiting
* libtinymail-camel/tny-camel-folder.c:

        • Fix camel operation references

* libtinymail-camel/tny-camel-bs-mime-part.c:

        • Fix camel operation references

* libtinymail-camel/tny-camel-queue.c:

        • Make queue reference to account be weak.

* libtinymail-camel/tny-camel-account.c:

        • More camel operation reference fixes.

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

        • Don't set in_idle to false so that join works properly.
        • On disconnecting we forze a stop_idle so we warrant idle
          thread has died when we disconnect.
        • Send let idle die commands on disconnecting.
        • It's very important to make the idle thread die on time as it
          keeps a reference to the folder. Folder keeps a reference to
          this store, and then store should finish idle soon to be able
          to finalize (cycle reference).

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

        • On finishing the idle thread we state we're out of it.

* libtinymail-camel/camel-lite/camel.c:

        • Avoid running internal methods of camel_shutdown two times if
          we can call shutdown two times.

* libtinymail-camel/tny-session-camel.c:

* libtinymail-camel/tny-camel-store-account.c:

        • Free the iter store reference on finalising.

* libtinymail-camel/tny-camel-account.c:

        • Set service to null after unreffing it.

* libtinymailui-gtk/tny-gtk-folder-store-tree-model.c:

        • Don't get folders again when we change status to disconnected.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • releases/modest/diablo-pe2/ChangeLog

    r3709 r3710  
     12008-07-01  Jose Dapena Paz  <jdapena@igalia.com> 
     2 
     3        * libtinymail-camel/tny-camel-folder.c: 
     4        Fix camel operation references 
     5 
     6        * libtinymail-camel/tny-camel-bs-mime-part.c: 
     7        Fix camel operation references 
     8 
     9        * libtinymail-camel/tny-camel-queue.c: 
     10        Make queue reference to account be weak. 
     11 
     12        * libtinymail-camel/tny-camel-account.c: 
     13        More camel operation reference fixes 
     14 
     152008-07-01  Philip Van Hoof <pvanhoof@gnome.org> 
     16 
     17        * libtinymail-camel/tny-camel-queue.c: Letting the thread wait for 
     18        more items instead of exiting 
     19 
    1202008-06-26  Philip Van Hoof <pvanhoof@gnome.org> 
    221 
     
    593612 
    594613        * Attempt at making mime parsing use the seekable capability of 
    595         streams in stead of copying them in memory. This is experimental! 
     614        streams instead of copying them in memory. This is experimental! 
    596615 
    5976162008-03-04  Philip Van Hoof <pvanhoof@gnome.org> 
     
    10151034 
    10161035        * Code robustness 
    1017         * Changed the account item of a folder to be hard referenced in stead 
     1036        * Changed the account item of a folder to be hard referenced instead 
    10181037        of weakly 
    10191038 
     
    114211612007-12-12  Philip Van Hoof <pvanhoof@gnome.org> 
    11431162 
    1144         * Experimental appending in stead of rewriting the summary.mmap 
     1163        * Experimental appending instead of rewriting the summary.mmap 
    11451164 
    114611652007-12-11  Philip Van Hoof <pvanhoof@gnome.org> 
     
    14431462        observers 
    14441463        * Cyclic references fix. tny_folder_store_add_observer and 
    1445         tny_folder_add_observer no longer add strong references, in stead they 
     1464        tny_folder_add_observer no longer add strong references, instead they 
    14461465        add weak references 
    14471466 
     
    14491468        root folder C, and then move A into B, that A would only become a 
    14501469        subfolder of B after you restart the application. The problem was that 
    1451         A and B got created with _tny_camel_folder_new in stead of the 
     1470        A and B got created with _tny_camel_folder_new instead of the 
    14521471        tny_camel_store_account_factor_folder. This made the observers 
    14531472        infrastructure of the model confuse when a new list of folder was 
     
    14571476 
    14581477        For future, let's be extremely careful not to use 
    1459         _tny_camel_folder_new but in stead to make sure that the factory is 
     1478        _tny_camel_folder_new but instead to make sure that the factory is 
    14601479        always used. 
    14611480 
     
    16351654 
    16361655        * Fixed regression on the regression fix of a few days ago :) 
    1637         * Renamed Maildir filenames to have '!' in stead of '_' or ':' in 
     1656        * Renamed Maildir filenames to have '!' instead of '_' or ':' in 
    16381657        their filenames 
    16391658 
     
    32583277        * Support for tny_header_get_uid on TnyMsg's header instance 
    32593278        * Removed the warning in libtinymail/tny-folder.c: please use the 
    3260         support for DBC in stead. It's specifically designed for this. Read 
     3279        support for DBC instead. It's specifically designed for this. Read 
    32613280        the documentation in building.txt to find out how to enable it. 
    32623281 
     
    48844903        consumption on initial download of both IMAP and NNTP folders. 
    48854904        * libtinymail-gnome-desktop: Default status of the device is now 
    4886         offline in stead of online (for example in case network manager 
     4905        offline instead of online (for example in case network manager 
    48874906        installation was invalid or not found) 
    48884907        * Bugfix reported by Nitin.Mahajan@nokia.com 
     
    48974916 
    48984917        * libtinymail-camel/camel-lite: Allocation of the CamelFolderInfo is 
    4899         now with GSlice in stead of many different malloc ways. This one needs 
     4918        now with GSlice instead of many different malloc ways. This one needs 
    49004919        testing! 
    49014920 
  • releases/modest/diablo-pe2/libtinymail-camel/camel-lite/camel/camel.c

    r3365 r3710  
    5555                return; 
    5656 
     57        initialised = FALSE; 
    5758        certdb = camel_certdb_get_default (); 
    5859        if (certdb) { 
     
    6667#endif /* HAVE_NSS */ 
    6768 
    68         initialised = FALSE; 
    6969} 
    7070 
  • releases/modest/diablo-pe2/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c

    r3677 r3710  
    41494149        } 
    41504150 
     4151        store->in_idle = FALSE; 
    41514152        camel_object_unref (folder); 
    41524153 
  • releases/modest/diablo-pe2/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c

    r3709 r3710  
    235235                CAMEL_SERVICE_REC_LOCK (store, connect_lock); 
    236236                nwritten = camel_stream_printf (store->ostream, "DONE\r\n"); 
    237                 store->in_idle = FALSE; 
    238237                if (nwritten != -1) { 
    239238                        resp = NULL; 
     
    397396 
    398397        let_idle_die (imap_store, TRUE); 
     398 
     399        camel_imap_store_stop_idle (imap_store); 
    399400 
    400401        if (imap_store->current_folder) { 
     
    21012102        imap_debug ("imap_connect_offline\n"); 
    21022103 
    2103         /* let_idle_die (store, TRUE); */ 
     2104        let_idle_die (store, TRUE); 
     2105        camel_imap_store_stop_idle (store); 
    21042106 
    21052107        if (!disco_store->diary) 
     
    21182120        imap_debug ("imap_disconnect_offline\n"); 
    21192121 
    2120         /*let_idle_die (store, TRUE);*/ 
     2122        let_idle_die (store, TRUE); 
     2123        camel_imap_store_stop_idle (store); 
    21212124 
    21222125        if (store->istream) { 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-camel-account.c

    r3667 r3710  
    775775        priv->inuse_spin = TRUE; 
    776776 
    777         if (priv->cancel) 
     777        if (priv->cancel) { 
    778778                _tny_camel_account_actual_uncancel (self); 
     779                camel_operation_unregister (priv->cancel); 
     780        } 
    779781 
    780782        priv->cancel = camel_operation_new (func, user_data); 
    781783 
    782         camel_operation_ref (priv->cancel); 
    783         camel_operation_register (priv->cancel); 
    784784        camel_operation_start (priv->cancel, (char*)what); 
    785785 
     
    21632163                } 
    21642164                camel_object_unref (CAMEL_OBJECT (priv->service)); 
     2165                priv->service = NULL; 
    21652166        } 
    21662167 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-camel-bs-mime-part.c

    r3684 r3710  
    557557                if (fpriv->account && TNY_IS_CAMEL_ACCOUNT (fpriv->account)) { 
    558558                        TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (fpriv->account); 
     559                        camel_operation_ref (cancel); 
    559560                        apriv->getmsg_cancel = cancel; 
    560561                } 
    561562        } 
    562563 
    563         camel_operation_ref (cancel); 
    564564        camel_operation_register (cancel); 
    565565        camel_operation_start (cancel, (char *) "Getting message part"); 
     
    589589                        TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (fpriv->account); 
    590590                        apriv->getmsg_cancel = NULL; 
     591                        camel_operation_unref (cancel); 
    591592                } 
    592593        } 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-camel-folder.c

    r3685 r3710  
    24702470                TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (priv->account); 
    24712471                apriv->getmsg_cancel = cancel; 
     2472                camel_operation_ref (cancel); 
    24722473        } 
    24732474 
     
    24762477        /* g_static_rec_mutex_lock (priv->folder_lock); */ 
    24772478 
    2478         camel_operation_ref (cancel); 
    24792479        camel_operation_register (cancel); 
    24802480        camel_operation_start (cancel, (char *) "Getting message"); 
     
    24972497                TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (priv->account); 
    24982498                apriv->getmsg_cancel = NULL; 
     2499                camel_operation_unref (cancel); 
    24992500        } 
    25002501 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-camel-queue-priv.h

    r3685 r3710  
    4646        GList *list; 
    4747        GThread *thread; 
     48        GCond *condition; 
     49        GMutex *mutex; 
     50        gboolean is_waiting; 
    4851        GStaticRecMutex *lock; 
    4952        gboolean stopped, next_uncancel; 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-camel-queue.c

    r3667 r3710  
    4040        (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_CAMEL_QUEUE, TnyCamelQueuePriv)) 
    4141 
     42static void account_finalized (TnyCamelQueue *queue, GObject *finalized_account); 
    4243 
    4344static void 
     
    4748 
    4849        self->stopped = TRUE; 
     50 
     51        g_mutex_lock (self->mutex); 
     52        if (self->account) 
     53                g_object_weak_unref (G_OBJECT (self->account), (GWeakNotify) account_finalized, self); 
     54        g_mutex_unlock (self->mutex); 
    4955 
    5056        g_static_rec_mutex_lock (self->lock); 
     
    5359        g_static_rec_mutex_unlock (self->lock); 
    5460 
     61        g_cond_free (self->condition); 
     62        g_mutex_free (self->mutex); 
     63 
    5564        /* g_static_rec_mutex_free (self->lock); */ 
    5665        g_free (self->lock); 
     
    6069 
    6170        return; 
     71} 
     72 
     73static void 
     74account_finalized (TnyCamelQueue *queue, GObject *finalized_account) 
     75{ 
     76        g_mutex_lock (queue->mutex); 
     77        queue->account = NULL; 
     78        queue->stopped = TRUE; 
     79        if (queue->is_waiting) { 
     80                g_cond_broadcast (queue->condition); 
     81        } 
     82        g_mutex_unlock (queue->mutex); 
    6283} 
    6384 
     
    7697 
    7798        self->account = account; 
     99        g_object_weak_ref (G_OBJECT (account), (GWeakNotify) account_finalized, self); 
    78100 
    79101        return TNY_CAMEL_QUEUE (self); 
     
    167189                GList *first = NULL; 
    168190                QueueItem *item = NULL; 
    169                 gboolean deleted = FALSE
     191                gboolean deleted = FALSE, wait = FALSE
    170192 
    171193                g_static_rec_mutex_lock (queue->lock); 
     
    173195                if (queue->next_uncancel) 
    174196                { 
    175                         _tny_camel_account_actual_uncancel (TNY_CAMEL_ACCOUNT (queue->account)); 
     197                        g_mutex_lock (queue->mutex); 
     198                        if (queue->account) { 
     199                                g_object_ref (queue->account); 
     200                                g_mutex_unlock (queue->mutex); 
     201                                _tny_camel_account_actual_uncancel (TNY_CAMEL_ACCOUNT (queue->account)); 
     202                                g_object_unref (queue->account); 
     203                        } else { 
     204                                g_mutex_unlock (queue->mutex); 
     205                        } 
    176206                        queue->next_uncancel = FALSE; 
    177207                } 
     
    184214                        queue->current = item; 
    185215                } else 
    186                         queue->stopped = TRUE; 
     216                        wait = TRUE; 
    187217                g_static_rec_mutex_unlock (queue->lock); 
    188218 
     
    234264                queue->current = NULL; 
    235265 
    236                 if (g_list_length (queue->list) == 0) { 
    237                         queue->thread = NULL; 
    238                         queue->stopped = TRUE; 
    239                 } 
     266                if (g_list_length (queue->list) == 0) 
     267                        wait = TRUE; 
    240268                g_static_rec_mutex_unlock (queue->lock); 
    241269 
    242270                if (item) 
    243271                        g_slice_free (QueueItem, item); 
     272 
     273                if (wait) { 
     274                        g_mutex_lock (queue->mutex); 
     275                        queue->is_waiting = TRUE; 
     276                        g_cond_wait (queue->condition, queue->mutex); 
     277                        queue->is_waiting = FALSE; 
     278                        g_mutex_unlock (queue->mutex); 
     279                } 
    244280        } 
    245281 
     
    247283        queue->stopped = TRUE; 
    248284 
    249         g_object_unref (queue->account); 
    250285        g_object_unref (queue); 
    251286 
     
    326361                if (item->flags & TNY_CAMEL_QUEUE_CANCELLABLE_ITEM) { 
    327362                        if (!(item->flags & TNY_CAMEL_QUEUE_SYNC_ITEM)) { 
    328                                 _tny_camel_account_actual_cancel (TNY_CAMEL_ACCOUNT (queue->account)); 
     363                                if (queue->account) 
     364                                        _tny_camel_account_actual_cancel (TNY_CAMEL_ACCOUNT (queue->account)); 
    329365                                queue->next_uncancel = TRUE; 
    330366                        } 
     
    379415 
    380416        g_static_rec_mutex_lock (queue->lock); 
     417 
     418        if (queue->account == NULL) 
     419                g_assert ("We should never be running tny_camel_queue_launch_wflags if account was unreferenced"); 
    381420 
    382421        if (flags & TNY_CAMEL_QUEUE_PRIORITY_ITEM)  
     
    404443                queue->stopped = FALSE; 
    405444                g_object_ref (queue); 
    406                 g_object_ref (queue->account); 
    407445                queue->thread = g_thread_create (tny_camel_queue_thread_main_func,  
    408446                        queue, FALSE, &err); 
     
    410448                        queue->stopped = TRUE; 
    411449                } 
     450        } else { 
     451                g_mutex_lock (queue->mutex); 
     452                if (queue->is_waiting) 
     453                        g_cond_broadcast (queue->condition); 
     454                g_mutex_unlock (queue->mutex); 
    412455        } 
    413456 
     
    465508        TnyCamelQueue *self = (TnyCamelQueue*)instance; 
    466509 
     510        self->is_waiting = FALSE; 
     511        self->mutex = g_mutex_new (); 
     512        self->condition = g_cond_new (); 
    467513        self->account = NULL; 
    468514        self->stopped = TRUE; 
    469515        self->list = NULL; 
     516 
     517        /* We don't use a GThreadPool because we need control over the queued 
     518         * items: we must remove them sometimes for example. */ 
     519 
    470520        self->thread = NULL; 
    471521        self->lock = g_new0 (GStaticRecMutex, 1); 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-camel-store-account.c

    r3667 r3710  
    14121412        priv->iter = iter; 
    14131413        priv->cant_reuse_iter = FALSE; 
     1414 
     1415        if (priv->iter_store) { 
     1416                camel_object_unref (CAMEL_OBJECT (store)); 
     1417        } 
    14141418 
    14151419        camel_object_ref (CAMEL_OBJECT (store)); 
  • releases/modest/diablo-pe2/libtinymail-camel/tny-session-camel.c

    r3306 r3710  
    983983         * have embraced references either. So be careful! */ 
    984984 
    985         priv->device = device
     985        priv->device = g_object_ref (device)
    986986 
    987987        return; 
     
    10901090                g_signal_handler_disconnect (G_OBJECT (priv->device),  
    10911091                        priv->connchanged_signal); 
     1092        } 
     1093 
     1094        if (priv->device) { 
     1095                g_object_unref (priv->device); 
    10921096        } 
    10931097 
  • releases/modest/diablo-pe2/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c

    r3667 r3710  
    339339         * start asking the account about its folders. */ 
    340340 
    341         if (status == TNY_CONNECTION_STATUS_RECONNECTING
     341        if (status == TNY_CONNECTION_STATUS_RECONNECTING || status == TNY_CONNECTION_STATUS_DISCONNECTED
    342342                return; 
    343343