Changeset 2510
- Timestamp:
- 07/27/07 13:20:00
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/pvanhoof/sessionwork/ChangeLog
r2506 r2510 1 2007-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 7 2007-07-27 Philip Van Hoof <pvanhoof@gnome.org> 8 9 * Branchpoint "devel/sessionwork" 10 1 11 2007-07-26 Philip Van Hoof <pvanhoof@gnome.org> 2 12 devel/pvanhoof/sessionwork/libtinymail-camel/tny-camel-folder.c
r2500 r2510 4039 4039 execute_callback (info->depth, G_PRIORITY_DEFAULT, 4040 4040 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); 4042 4042 } 4043 4043 g_error_free (err); … … 4145 4145 4146 4146 4147 static GStaticMutex poke_folders_lock = G_STATIC_MUTEX_INIT;4148 static GList *poke_folders = NULL;4149 static GThread *poke_folders_thread = NULL;4150 4151 4147 static 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 } 4148 tny_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; 4191 4168 } 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; 4195 4171 } 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) 4204 4188 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 */4225 4189 4226 4190 return NULL; … … 4238 4202 { 4239 4203 info = g_slice_new (PokeStatusInfo); 4240 /*g_static_rec_mutex_lock (priv->folder_lock);*/4241 4204 info->unread = camel_folder_get_unread_message_count (priv->folder); 4242 4205 info->total = camel_folder_get_message_count (priv->folder); 4243 /*g_static_rec_mutex_unlock (priv->folder_lock);*/ 4206 4244 4207 } else { 4245 /*g_static_rec_mutex_lock (priv->folder_lock);*/4246 4208 4247 4209 if (store && CAMEL_IS_DISCO_STORE (store) && priv->folder_name 4248 4210 && camel_disco_store_status (CAMEL_DISCO_STORE (store)) == CAMEL_DISCO_STORE_ONLINE) 4249 4211 { 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 4257 4220 } else { 4258 4221 if (priv->iter) { … … 4262 4225 } 4263 4226 } 4264 4265 /*g_static_rec_mutex_unlock (priv->folder_lock);*/4266 4227 } 4267 4228 devel/pvanhoof/sessionwork/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c
r2509 r2510 65 65 GtkTreeIter miter; 66 66 gboolean found = FALSE; 67 GObject *mark_for_removal = NULL; 67 68 68 69 if (TNY_IS_FOLDER (instance)) … … 80 81 { 81 82 GObject *citem = NULL; 83 TnyIterator *niter = NULL; 84 82 85 gtk_tree_model_get (mmodel, &miter, 83 86 TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN, 84 87 &citem, -1); 88 85 89 if (citem == instance) 86 90 { … … 90 94 if (citem) 91 95 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 92 113 } while (gtk_tree_model_iter_next (mmodel, &miter)); 93 114 … … 157 178 if (folder) 158 179 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 } 159 186 } 160 187
