[evolution-kolab/ek-wip-acl] EPlugin: minor code cleanup



commit 3be14b5fd02b56ca57544f7380d9abe47831036d
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Jul 31 18:46:58 2012 +0200

    EPlugin: minor code cleanup
    
    * straightened out the function which gets the selected path
      from an email EShellView

 src/eplugin/e-kolab-plugin-ui.c |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/src/eplugin/e-kolab-plugin-ui.c b/src/eplugin/e-kolab-plugin-ui.c
index d74422a..5d69c5c 100644
--- a/src/eplugin/e-kolab-plugin-ui.c
+++ b/src/eplugin/e-kolab-plugin-ui.c
@@ -280,25 +280,38 @@ kolab_plugin_ui_path_from_mail_view (EShellView *shell_view,
 	EShellSidebar *shell_sidebar = NULL;
 	EMFolderTree *folder_tree = NULL;
 	CamelStore *selected_store = NULL;
+	CamelProvider *provider = NULL;
 	gchar *selected_path = NULL;
+	gboolean have_sel = FALSE;
 
 	g_assert (E_IS_SHELL_VIEW (shell_view));
 
 	shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
 	g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
-	if (em_folder_tree_get_selected (folder_tree, &selected_store, &selected_path) ||
-	    em_folder_tree_store_root_selected (folder_tree, &selected_store)) {
-		if (selected_store) {
-			CamelProvider *provider = camel_service_get_provider (CAMEL_SERVICE (selected_store));
-
-			if (provider && g_ascii_strcasecmp (provider->protocol, KOLAB_CAMEL_PROVIDER_PROTOCOL) == 0) {
-				*is_kolab_account_node = !selected_path || !*selected_path;
-				*is_kolab_folder_node = !*is_kolab_account_node;
-			}
-
-			g_object_unref (selected_store);
-		}
+
+	have_sel = (em_folder_tree_get_selected (folder_tree, &selected_store, &selected_path) ||
+	            em_folder_tree_store_root_selected (folder_tree, &selected_store));
+
+	if (! have_sel)
+		goto exit;
+
+	if (selected_store == NULL)
+		goto exit;
+
+	provider = camel_service_get_provider (CAMEL_SERVICE (selected_store));
+
+	if (provider == NULL)
+		goto skip;
+
+	if (g_ascii_strcasecmp (provider->protocol, KOLAB_CAMEL_PROVIDER_PROTOCOL) == 0) {
+		*is_kolab_account_node = !selected_path || !*selected_path;
+		*is_kolab_folder_node = !*is_kolab_account_node;
 	}
+
+ skip:
+	g_object_unref (selected_store);
+
+ exit:
 	g_object_unref (folder_tree);
 
 	return selected_path;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]