Changeset 2510

Show
Ignore:
Timestamp:
07/27/07 13:20:00
Author:
pvanhoof
Message:

Moving the poke status to the same queue as the other operations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/pvanhoof/sessionwork/ChangeLog

    r2506 r2510  
     12007-07-27  Philip Van Hoof  <pvanhoof@gnome.org> 
     2 
     3        * Dealing with remotely removed folders 
     4        * The poke status calls are now on the same queue as the other 
     5        operations 
     6 
     72007-07-27  Philip Van Hoof  <pvanhoof@gnome.org> 
     8 
     9        * Branchpoint "devel/sessionwork" 
     10 
    1112007-07-26  Philip Van Hoof  <pvanhoof@gnome.org> 
    212 
  • devel/pvanhoof/sessionwork/libtinymail-camel/tny-camel-folder.c

    r2500 r2510  
    40394039                        execute_callback (info->depth, G_PRIORITY_DEFAULT, 
    40404040                                          tny_camel_folder_get_folders_async_cancelled_callback, info,  
    4041                                           tny_camel_folder_get_folders_async_cancelled_destroyer);                      
     4041                                          tny_camel_folder_get_folders_async_cancelled_destroyer); 
    40424042                } 
    40434043                g_error_free (err); 
     
    41454145 
    41464146 
    4147 static GStaticMutex poke_folders_lock = G_STATIC_MUTEX_INIT; 
    4148 static GList *poke_folders = NULL; 
    4149 static GThread *poke_folders_thread = NULL; 
    4150  
    41514147static gpointer 
    4152 tny_camel_folder_poke_status_thread (gpointer data) 
    4153 
    4154         GList *mypoke_folders; 
    4155  
    4156         g_static_mutex_lock (&poke_folders_lock); 
    4157         mypoke_folders = poke_folders; 
    4158         g_static_mutex_unlock (&poke_folders_lock); 
    4159  
    4160         while (mypoke_folders) 
    4161         { 
    4162                 PokeStatusInfo *info = NULL; 
    4163                 TnyFolder *folder = NULL; 
    4164                 TnyCamelFolderPriv *priv = NULL; 
    4165                 CamelStore *store = NULL; 
    4166                 int newlen = -1, newurlen = -1, uidnext = -1; 
    4167  
    4168                 g_static_mutex_lock (&poke_folders_lock); 
    4169  
    4170                 folder = poke_folders->data; 
    4171  
    4172                 if (folder == NULL) 
    4173                         goto mycont; 
    4174  
    4175                 priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 
    4176                 store = priv->store; 
    4177  
    4178                 camel_store_get_folder_status (store, priv->folder_name,  
    4179                         &newurlen, &newlen, &uidnext); 
    4180  
    4181                 if (newurlen == -1 || newlen == -1) 
    4182                 { 
    4183                         if (priv->iter) { 
    4184                                 info = g_slice_new (PokeStatusInfo); 
    4185                                 info->unread = priv->iter->unread; 
    4186                                 info->total = priv->iter->total; 
    4187                         } else { 
    4188                                 info->unread = priv->unread_length; 
    4189                                 info->total = priv->cached_length; 
    4190                         } 
     4148tny_camel_folder_poke_status_thread (gpointer user_data) 
     4149
     4150        PokeStatusInfo *info = NULL; 
     4151        TnyFolder *folder = (TnyFolder *) user_data; 
     4152        TnyCamelFolderPriv *priv = NULL; 
     4153        CamelStore *store = NULL; 
     4154        int newlen = -1, newurlen = -1, uidnext = -1; 
     4155 
     4156        priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 
     4157        store = priv->store; 
     4158 
     4159        camel_store_get_folder_status (store, priv->folder_name,  
     4160                &newurlen, &newlen, &uidnext); 
     4161 
     4162        if (newurlen == -1 || newlen == -1) 
     4163        { 
     4164                if (priv->iter) { 
     4165                        info = g_slice_new (PokeStatusInfo); 
     4166                        info->unread = priv->iter->unread; 
     4167                        info->total = priv->iter->total; 
    41914168                } else { 
    4192                         info = g_slice_new (PokeStatusInfo); 
    4193                         info->unread = newurlen; 
    4194                         info->total = newlen; 
     4169                        info->unread = priv->unread_length; 
     4170                        info->total = priv->cached_length; 
    41954171                } 
    4196  
    4197                 if (info && folder) 
    4198                 { 
    4199                         info->self = TNY_FOLDER (g_object_ref (folder)); 
    4200                         g_idle_add_full (G_PRIORITY_HIGH,  
    4201                                 tny_camel_folder_poke_status_callback,  
    4202                                 info, tny_camel_folder_poke_status_destroyer); 
    4203                 } 
     4172        } else { 
     4173                info = g_slice_new (PokeStatusInfo); 
     4174                info->unread = newurlen; 
     4175                info->total = newlen; 
     4176        } 
     4177 
     4178        if (info && folder) 
     4179        { 
     4180                info->self = TNY_FOLDER (g_object_ref (folder)); 
     4181                g_idle_add_full (G_PRIORITY_HIGH,  
     4182                        tny_camel_folder_poke_status_callback,  
     4183                        info, tny_camel_folder_poke_status_destroyer); 
     4184        } 
     4185 
     4186        /* Thread reference */ 
     4187        if (folder) 
    42044188                g_object_unref (folder); 
    4205                 poke_folders->data = NULL; 
    4206  
    4207 mycont: 
    4208                 poke_folders = g_list_next (poke_folders); 
    4209                 mypoke_folders = poke_folders; 
    4210  
    4211                 if (!poke_folders) 
    4212                 { 
    4213                         poke_folders_thread = NULL; 
    4214                         break; /* Reason for A */ 
    4215                 } else { 
    4216                         g_static_mutex_unlock (&poke_folders_lock); 
    4217                         usleep (50000); /* Allow other folders to be added */ 
    4218                 } 
    4219         } 
    4220  
    4221         g_list_free (poke_folders); 
    4222         poke_folders = NULL; 
    4223  
    4224         g_static_mutex_unlock (&poke_folders_lock); /* A */ 
    42254189 
    42264190        return NULL; 
     
    42384202        { 
    42394203                info = g_slice_new (PokeStatusInfo); 
    4240                 /*g_static_rec_mutex_lock (priv->folder_lock);*/ 
    42414204                info->unread = camel_folder_get_unread_message_count (priv->folder); 
    42424205                info->total = camel_folder_get_message_count (priv->folder); 
    4243                 /*g_static_rec_mutex_unlock (priv->folder_lock);*/ 
     4206 
    42444207        } else { 
    4245                 /*g_static_rec_mutex_lock (priv->folder_lock);*/ 
    42464208 
    42474209                if (store && CAMEL_IS_DISCO_STORE (store)  && priv->folder_name  
    42484210                        && camel_disco_store_status (CAMEL_DISCO_STORE (store)) == CAMEL_DISCO_STORE_ONLINE) 
    42494211                { 
    4250                         g_static_mutex_lock (&poke_folders_lock); 
    4251  
    4252                         poke_folders = g_list_append (poke_folders, g_object_ref (self)); 
    4253                         if (!poke_folders_thread) 
    4254                                 poke_folders_thread = g_thread_create (tny_camel_folder_poke_status_thread, self, TRUE, NULL); 
    4255  
    4256                         g_static_mutex_unlock (&poke_folders_lock); 
     4212                        /* Thread reference */ 
     4213                        g_object_ref (self); 
     4214 
     4215                        _tny_camel_queue_launch (TNY_FOLDER_PRIV_GET_QUEUE (priv),  
     4216                                tny_camel_folder_poke_status_thread, self); 
     4217 
     4218                        info = NULL; 
     4219 
    42574220                } else { 
    42584221                        if (priv->iter) { 
     
    42624225                        } 
    42634226                } 
    4264  
    4265                 /*g_static_rec_mutex_unlock (priv->folder_lock);*/ 
    42664227        } 
    42674228 
  • devel/pvanhoof/sessionwork/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c

    r2509 r2510  
    6565                GtkTreeIter miter; 
    6666                gboolean found = FALSE; 
     67                GObject *mark_for_removal = NULL; 
    6768 
    6869                if (TNY_IS_FOLDER (instance)) 
     
    8081                  { 
    8182                        GObject *citem = NULL; 
     83                        TnyIterator *niter = NULL; 
     84                         
    8285                        gtk_tree_model_get (mmodel, &miter,  
    8386                                TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN,  
    8487                                &citem, -1); 
     88 
    8589                        if (citem == instance) 
    8690                        { 
     
    9094                        if (citem) 
    9195                                g_object_unref (citem); 
     96 
     97                        /* We search whether this folder that we have in the  
     98                         * model, still exists in the actual list. Because if 
     99                         * not, it probably got removed remotely (and we need 
     100                         * to get rid of it in the model now) */ 
     101 
     102                        niter = tny_list_create_iterator (folders); 
     103                        while (!tny_iterator_is_done (niter)) 
     104                        { 
     105                                TnyFolder *ifound = TNY_FOLDER (tny_iterator_get_current (niter)); 
     106                                if (citem == (GObject *) ifound) 
     107                                        mark_for_removal = g_object_ref (ifound); 
     108                                g_object_unref (ifound); 
     109                                tny_iterator_next (niter); 
     110                        } 
     111                        g_object_unref (niter); 
     112 
    92113                  } while (gtk_tree_model_iter_next (mmodel, &miter)); 
    93114 
     
    157178                        if (folder) 
    158179                                tny_folder_poke_status (TNY_FOLDER (folder)); 
     180                } else { 
     181                        if (mark_for_removal) 
     182                        { 
     183                                printf ("We need to remove %s\n",  
     184                                        tny_folder_get_id (TNY_FOLDER (mark_for_removal))); 
     185                        } 
    159186                } 
    160187