aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-04-08 23:27:57 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-04-09 02:54:01 +0800
commit842f25deadc0d45ace850e6fb05b61dc228c47a3 (patch)
treea8dc2a74080ede7c2dcc69a5d9f0361f5b47683a /mail
parentbadaccb764e06533511395e721d967b6f478e50f (diff)
downloadgsoc2013-evolution-842f25deadc0d45ace850e6fb05b61dc228c47a3.tar.gz
gsoc2013-evolution-842f25deadc0d45ace850e6fb05b61dc228c47a3.tar.zst
gsoc2013-evolution-842f25deadc0d45ace850e6fb05b61dc228c47a3.zip
Rewrite em_folder_tree_model_lookup_uri() to not use uri_index.
Instead we parse the 'folder_uri' string into CamelStore and folder name components using e_mail_folder_uri_parse(). Then we query the internal 'store_index' table with our CamelStore for an EMFolderTreeModelStoreInfo struct. Then we query the info struct's 'full_hash' table with our folder name for the GtkTreeRowReference. It's a little more complicated, but it allows us to drop the internal 'uri_index' table so it's a net simplification for EMFolderTreeModel.
Diffstat (limited to 'mail')
-rw-r--r--mail/em-folder-tree-model.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 623fd55edd..cd79927ff7 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -1268,14 +1268,46 @@ GtkTreeRowReference *
em_folder_tree_model_lookup_uri (EMFolderTreeModel *model,
const gchar *folder_uri)
{
- GtkTreeRowReference *reference;
+ GtkTreeRowReference *reference = NULL;
+ EMFolderTreeModelStoreInfo *si;
+ EMailSession *session;
+ CamelStore *store = NULL;
+ gchar *folder_name = NULL;
+ GError *error = NULL;
g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL);
g_return_val_if_fail (folder_uri != NULL, NULL);
- reference = g_hash_table_lookup (model->priv->uri_index, folder_uri);
+ session = em_folder_tree_model_get_session (model);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+
+ e_mail_folder_uri_parse (
+ CAMEL_SESSION (session),
+ folder_uri, &store, &folder_name, &error);
+
+ if (error != NULL) {
+ g_warn_if_fail (store == NULL);
+ g_warn_if_fail (folder_name == NULL);
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+ g_return_val_if_fail (folder_name != NULL, NULL);
+
+ si = g_hash_table_lookup (model->priv->store_index, store);
+
+ if (si != NULL)
+ reference = g_hash_table_lookup (si->full_hash, folder_name);
+
+ if (!gtk_tree_row_reference_valid (reference))
+ reference = NULL;
+
+ g_object_unref (store);
+ g_free (folder_name);
- return gtk_tree_row_reference_valid (reference) ? reference : NULL;
+ return reference;
}
void