aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-03-05 04:46:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-06-03 11:00:39 +0800
commit3e05d86173c12420db661fc80292252fe720b8d9 (patch)
treee34d31e2e36790957a4d8889aa5c25a49cad9538
parentc6b67831e8029d7c53a4c5b4057b19251cba6bb1 (diff)
downloadgsoc2013-evolution-3e05d86173c12420db661fc80292252fe720b8d9.tar.gz
gsoc2013-evolution-3e05d86173c12420db661fc80292252fe720b8d9.tar.zst
gsoc2013-evolution-3e05d86173c12420db661fc80292252fe720b8d9.zip
Adapt libeshell to the new ESource API.
-rw-r--r--shell/e-shell-migrate.c113
-rw-r--r--shell/e-shell-view.c64
-rw-r--r--shell/e-shell-view.h6
-rw-r--r--shell/e-shell-window-actions.c28
-rw-r--r--shell/e-shell-window-actions.h2
-rw-r--r--shell/e-shell.c56
-rw-r--r--shell/e-shell.h4
-rw-r--r--shell/shell.error.xml7
-rw-r--r--ui/evolution-shell.ui1
9 files changed, 129 insertions, 152 deletions
diff --git a/shell/e-shell-migrate.c b/shell/e-shell-migrate.c
index 69929a14b1..faf40275e9 100644
--- a/shell/e-shell-migrate.c
+++ b/shell/e-shell-migrate.c
@@ -792,115 +792,11 @@ fix_folder_permissions (const gchar *data_dir)
change_dir_modes (data_dir);
}
-static void
-merge_duplicate_local_sources (GConfClient *client,
- const gchar *gconf_key)
-{
- ESourceList *source_list;
- GSList *iter, *to_remove = NULL;
- ESourceGroup *first_local = NULL;
-
- g_return_if_fail (client != NULL);
- g_return_if_fail (gconf_key != NULL);
-
- source_list = e_source_list_new_for_gconf (client, gconf_key);
-
- for (iter = e_source_list_peek_groups (source_list); iter; iter = iter->next) {
- GSList *sources;
- ESourceGroup *group = iter->data;
-
- if (!group || !e_source_group_peek_base_uri (group) ||
- g_ascii_strncasecmp (
- e_source_group_peek_base_uri (group), "local:", 6) != 0)
- continue;
-
- if (!first_local) {
- first_local = group;
- continue;
- }
-
- /* merging respective sources */
- for (sources = e_source_group_peek_sources (group);
- sources != NULL; sources = sources->next) {
- GSList *liter;
- ESource *dupe_source = sources->data;
-
- if (!dupe_source)
- continue;
-
- for (liter = e_source_group_peek_sources (first_local);
- liter != NULL; liter = liter->next) {
- ESource *my_source = liter->data;
- const gchar *val1, *val2;
-
- if (!my_source)
- continue;
-
- /* pretty unlikely, but just in case */
- val1 = e_source_get_uid (dupe_source);
- val2 = e_source_get_uid (my_source);
- if (g_strcmp0 (val1, val2) == 0)
- break;
-
- /* relative uri should not be empty
- * (but adressbook can have it empty) */
- val1 = e_source_peek_relative_uri (dupe_source);
- val2 = e_source_peek_relative_uri (my_source);
- if (g_strcmp0 (val1, val2) == 0 && val1 && *val1)
- break;
- }
-
- /* didn't find matching source, thus add its copy */
- if (liter == NULL) {
- ESource *copy;
-
- copy = e_source_copy (dupe_source);
- e_source_group_add_source (first_local, copy, -1);
- g_object_unref (copy);
- }
- }
-
- to_remove = g_slist_prepend (to_remove, group);
- }
-
- if (first_local) {
- GSList *sources;
-
- for (sources = e_source_group_peek_sources (first_local);
- sources != NULL; sources = sources->next) {
- ESource *source = sources->data;
- const gchar *relative_uri;
-
- if (!source)
- continue;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (!relative_uri || !*relative_uri)
- e_source_set_relative_uri (source, e_source_get_uid (source));
- }
- }
-
- if (!to_remove) {
- g_object_unref (source_list);
- return;
- }
-
- for (iter = to_remove; iter; iter = iter->next) {
- e_source_list_remove_group (source_list, iter->data);
- }
-
- e_source_list_sync (source_list, NULL);
-
- g_object_unref (source_list);
- g_slist_free (to_remove);
-}
-
gboolean
e_shell_migrate_attempt (EShell *shell)
{
ESEvent *ese;
GSettings *settings;
- GConfClient *client;
gint major, minor, micro;
gint last_major, last_minor, last_micro;
gint curr_major, curr_minor, curr_micro;
@@ -933,15 +829,6 @@ e_shell_migrate_attempt (EShell *shell)
if (!shell_migrate_attempt (shell, major, minor, micro))
_exit (EXIT_SUCCESS);
- /* The 2.32.x (except of 2.32.2) lefts duplicate
- * On This Computer/Personal sources, thus clean the mess up */
- client = gconf_client_get_default ();
- merge_duplicate_local_sources (client, "/apps/evolution/addressbook/sources");
- merge_duplicate_local_sources (client, "/apps/evolution/calendar/sources");
- merge_duplicate_local_sources (client, "/apps/evolution/tasks/sources");
- merge_duplicate_local_sources (client, "/apps/evolution/memos/sources");
- g_object_unref (client);
-
/* Record a successful migration. */
string = g_strdup_printf (
"%d.%d.%d", curr_major, curr_minor, curr_micro);
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index cdd8a212ed..bd66ce2897 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -37,6 +37,7 @@
#include "e-util/e-file-utils.h"
#include "e-util/e-plugin-ui.h"
+#include "e-util/e-source-util.h"
#include "e-util/e-ui-manager.h"
#include "e-util/e-util-private.h"
#include "e-util/e-util.h"
@@ -1884,3 +1885,66 @@ e_shell_view_new_view_instance (EShellView *shell_view,
return view_instance;
}
+
+/**
+ * e_shell_view_write_source:
+ * @shell_view: an #EShellView
+ * @source: an #ESource
+ *
+ * Submits the current contents of @source to the D-Bus service to be
+ * written to disk and broadcast to other clients.
+ *
+ * This function does not block: @shell_view will dispatch the operation
+ * asynchronously and handle any errors.
+ **/
+void
+e_shell_view_write_source (EShellView *shell_view,
+ ESource *source)
+{
+ EActivity *activity;
+ EAlertSink *alert_sink;
+ EShellBackend *shell_backend;
+ EShellContent *shell_content;
+
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ alert_sink = E_ALERT_SINK (shell_content);
+ activity = e_source_util_write (source, alert_sink);
+ e_shell_backend_add_activity (shell_backend, activity);
+}
+
+/**
+ * e_shell_view_remove_source:
+ * @shell_view: an #EShellView
+ * @source: the #ESource to be removed
+ *
+ * Requests the D-Bus service to delete the key files for @source and all of
+ * its descendants and broadcast their removal to all clients.
+ *
+ * This function does not block: @shell_view will dispatch the operation
+ * asynchronously and handle any errors.
+ **/
+void
+e_shell_view_remove_source (EShellView *shell_view,
+ ESource *source)
+{
+ EActivity *activity;
+ EAlertSink *alert_sink;
+ EShellBackend *shell_backend;
+ EShellContent *shell_content;
+
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ alert_sink = E_ALERT_SINK (shell_content);
+ activity = e_source_util_remove (source, alert_sink);
+ e_shell_backend_add_activity (shell_backend, activity);
+}
+
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index ad311ec7aa..0d7aee01ae 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -22,6 +22,8 @@
#ifndef E_SHELL_VIEW_H
#define E_SHELL_VIEW_H
+#include <libedataserver/e-source.h>
+
#include <shell/e-shell-common.h>
#include <shell/e-shell-backend.h>
#include <shell/e-shell-content.h>
@@ -228,6 +230,10 @@ GtkWidget * e_shell_view_show_popup_menu (EShellView *shell_view,
GalViewInstance *
e_shell_view_new_view_instance (EShellView *shell_view,
const gchar *instance_id);
+void e_shell_view_write_source (EShellView *shell_view,
+ ESource *source);
+void e_shell_view_remove_source (EShellView *shell_view,
+ ESource *source);
G_END_DECLS
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index f2b0ab65c2..e05b24b700 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -736,27 +736,6 @@ action_custom_rule_cb (GtkAction *action,
}
/**
- * E_SHELL_WINDOW_ACTION_FORGET_PASSWORDS:
- * @window: an #EShellWindow
- *
- * Activation of this action deletes all stored passwords.
- *
- * Main menu item: File -> Forget Passwords
- **/
-static void
-action_forget_passwords_cb (GtkAction *action,
- EShellWindow *shell_window)
-{
- gint response;
-
- response = e_alert_run_dialog_for_args (
- GTK_WINDOW (shell_window), "shell:forget-passwords", NULL);
-
- if (response == GTK_RESPONSE_OK)
- e_passwords_forget_passwords ();
-}
-
-/**
* E_SHELL_WINDOW_ACTION_GAL_DEFINE_VIEWS:
* @window: an #EShellWindow
*
@@ -1482,13 +1461,6 @@ static GtkActionEntry shell_entries[] = {
N_("Delete the selection"),
NULL }, /* Handled by EFocusTracker */
- { "forget-passwords",
- NULL,
- N_("_Forget Passwords"),
- NULL,
- N_("Forget all remembered passwords"),
- G_CALLBACK (action_forget_passwords_cb) },
-
{ "import",
"stock_mail-import",
N_("I_mport..."),
diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h
index 42618ee89f..aefae2f747 100644
--- a/shell/e-shell-window-actions.h
+++ b/shell/e-shell-window-actions.h
@@ -41,8 +41,6 @@
E_SHELL_WINDOW_ACTION ((window), "cut-clipboard")
#define E_SHELL_WINDOW_ACTION_DELETE_SELECTION(window) \
E_SHELL_WINDOW_ACTION ((window), "delete-selection")
-#define E_SHELL_WINDOW_ACTION_FORGET_PASSWORDS(window) \
- E_SHELL_WINDOW_ACTION ((window), "forget-passwords")
#define E_SHELL_WINDOW_ACTION_GAL_CUSTOM_VIEW(window) \
E_SHELL_WINDOW_ACTION ((window), "gal-custom-view")
#define E_SHELL_WINDOW_ACTION_GAL_DEFINE_VIEWS(window) \
diff --git a/shell/e-shell.c b/shell/e-shell.c
index bc252845cd..ae2641fac4 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -53,6 +53,7 @@
struct _EShellPrivate {
GQueue alerts;
EShellSettings *settings;
+ ESourceRegistry *registry;
GActionGroup *action_group;
GtkWidget *preferences_window;
@@ -90,6 +91,7 @@ enum {
PROP_MODULE_DIRECTORY,
PROP_NETWORK_AVAILABLE,
PROP_ONLINE,
+ PROP_REGISTRY,
PROP_SHELL_SETTINGS
};
@@ -683,6 +685,12 @@ shell_get_property (GObject *object,
E_SHELL (object)));
return;
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value, e_shell_get_registry (
+ E_SHELL (object)));
+ return;
+
case PROP_SHELL_SETTINGS:
g_value_set_object (
value, e_shell_get_shell_settings (
@@ -723,6 +731,11 @@ shell_dispose (GObject *object)
priv->settings = NULL;
}
+ if (priv->registry != NULL) {
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
+
if (priv->action_group != NULL) {
g_object_unref (priv->action_group);
priv->action_group = NULL;
@@ -857,10 +870,20 @@ shell_initable_init (GInitable *initable,
GError **error)
{
GApplication *application = G_APPLICATION (initable);
+ EShellPrivate *priv;
+
+ priv = E_SHELL_GET_PRIVATE (initable);
shell_add_actions (application);
- return g_application_register (application, cancellable, error);
+ priv->registry = e_source_registry_new_sync (cancellable, error);
+ if (priv->registry == NULL)
+ return FALSE;
+
+ if (!g_application_register (application, cancellable, error))
+ return FALSE;
+
+ return TRUE;
}
static void
@@ -1002,6 +1025,21 @@ e_shell_class_init (EShellClass *class)
G_PARAM_CONSTRUCT));
/**
+ * EShell:registry
+ *
+ * The #ESourceRegistry manages #ESource instances.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Data source registry",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READABLE));
+
+ /**
* EShell:settings
*
* The #EShellSettings object stores application settings.
@@ -1397,6 +1435,22 @@ e_shell_get_shell_settings (EShell *shell)
}
/**
+ * e_shell_get_registry:
+ * @shell: an #EShell
+ *
+ * Returns the shell's #ESourceRegistry which holds all #ESource instances.
+ *
+ * Returns: the #ESourceRegistry
+ **/
+ESourceRegistry *
+e_shell_get_registry (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ return shell->priv->registry;
+}
+
+/**
* e_shell_create_shell_window:
* @shell: an #EShell
* @view_name: name of the initial shell view, or %NULL
diff --git a/shell/e-shell.h b/shell/e-shell.h
index ffff239f6f..786e6c8d44 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -22,6 +22,8 @@
#ifndef E_SHELL_H
#define E_SHELL_H
+#include <libedataserver/e-source-registry.h>
+
#include <e-util/e-activity.h>
#include <libevolution-utils/e-alert.h>
@@ -117,6 +119,8 @@ EShellBackend * e_shell_get_backend_by_name (EShell *shell,
EShellBackend * e_shell_get_backend_by_scheme (EShell *shell,
const gchar *scheme);
EShellSettings *e_shell_get_shell_settings (EShell *shell);
+ESourceRegistry *
+ e_shell_get_registry (EShell *shell);
GtkWidget * e_shell_create_shell_window (EShell *shell,
const gchar *view_name);
guint e_shell_handle_uris (EShell *shell,
diff --git a/shell/shell.error.xml b/shell/shell.error.xml
index 6c75baa9df..8c5a2e6921 100644
--- a/shell/shell.error.xml
+++ b/shell/shell.error.xml
@@ -26,11 +26,4 @@ If you choose to continue, you may not have access to some of your old data.
<button _label="Quit Now" response="GTK_RESPONSE_CANCEL"/>
</error>
- <error id="forget-passwords" type="question" default="GTK_RESPONSE_CANCEL">
- <_primary>Are you sure you want to forget all remembered passwords?</_primary>
- <_secondary xml:space="preserve">Forgetting your passwords will clear all remembered passwords. You will be reprompted next time they are needed.</_secondary>
- <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
- <button _label="_Forget" response="GTK_RESPONSE_OK"/>
- </error>
-
</error-list>
diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui
index ae7ce84eb3..7a30947060 100644
--- a/ui/evolution-shell.ui
+++ b/ui/evolution-shell.ui
@@ -17,7 +17,6 @@
<placeholder name='print-actions'/>
<separator/>
<placeholder name='long-running-actions'/>
- <menuitem action='forget-passwords'/>
<menuitem action='work-online'/>
<menuitem action='work-offline'/>
<menuitem action='close'/>