aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-12-14 12:06:26 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-12-14 12:06:26 +0800
commit22638789fafe044f3c25a5ddbbc371e5da727293 (patch)
tree23900ef688d52a40421fb7469f6454a7cfeb5f24 /shell
parentb7333387e8bd19299794e6485e3407d03c2eb73f (diff)
downloadgsoc2013-evolution-22638789fafe044f3c25a5ddbbc371e5da727293.tar.gz
gsoc2013-evolution-22638789fafe044f3c25a5ddbbc371e5da727293.tar.zst
gsoc2013-evolution-22638789fafe044f3c25a5ddbbc371e5da727293.zip
- Get offline synchronization working in the mailer (I think).
svn path=/branches/kill-bonobo/; revision=36876
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell.c111
1 files changed, 87 insertions, 24 deletions
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 57118a4e14..95303b8b39 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -46,7 +46,7 @@ struct _EShellPrivate {
GHashTable *modules_by_name;
GHashTable *modules_by_scheme;
- gpointer preparing_for_offline; /* weak pointer */
+ gpointer preparing_for_line_change; /* weak pointer */
guint auto_reconnect : 1;
guint network_available : 1;
@@ -65,6 +65,7 @@ enum {
EVENT,
HANDLE_URI,
PREPARE_FOR_OFFLINE,
+ PREPARE_FOR_ONLINE,
SEND_RECEIVE,
WINDOW_CREATED,
WINDOW_DESTROYED,
@@ -164,27 +165,74 @@ static void
shell_prepare_for_offline (EShell *shell)
{
/* Are preparations already in progress? */
- if (shell->priv->preparing_for_offline != NULL)
+ if (shell->priv->preparing_for_line_change != NULL)
return;
g_message ("Preparing for offline mode...");
- shell->priv->preparing_for_offline =
+ shell->priv->preparing_for_line_change =
e_activity_new (_("Preparing to go offline..."));
g_object_add_toggle_ref (
- G_OBJECT (shell->priv->preparing_for_offline),
+ G_OBJECT (shell->priv->preparing_for_line_change),
(GToggleNotify) shell_ready_for_offline, shell);
g_object_add_weak_pointer (
- G_OBJECT (shell->priv->preparing_for_offline),
- &shell->priv->preparing_for_offline);
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ &shell->priv->preparing_for_line_change);
g_signal_emit (
shell, signals[PREPARE_FOR_OFFLINE], 0,
- shell->priv->preparing_for_offline);
+ shell->priv->preparing_for_line_change);
- g_object_unref (shell->priv->preparing_for_offline);
+ g_object_unref (shell->priv->preparing_for_line_change);
+}
+
+static void
+shell_ready_for_online (EShell *shell,
+ EActivity *activity,
+ gboolean is_last_ref)
+{
+ if (!is_last_ref)
+ return;
+
+ e_activity_complete (activity);
+
+ g_object_remove_toggle_ref (
+ G_OBJECT (activity), (GToggleNotify)
+ shell_ready_for_online, shell);
+
+ shell->priv->online_mode = TRUE;
+ g_object_notify (G_OBJECT (shell), "online-mode");
+
+ g_message ("Online preparations complete.");
+}
+
+static void
+shell_prepare_for_online (EShell *shell)
+{
+ /* Are preparations already in progress? */
+ if (shell->priv->preparing_for_line_change != NULL)
+ return;
+
+ g_message ("Preparing for online mode...");
+
+ shell->priv->preparing_for_line_change =
+ e_activity_new (_("Preparing to go online..."));
+
+ g_object_add_toggle_ref (
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ (GToggleNotify) shell_ready_for_online, shell);
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ &shell->priv->preparing_for_line_change);
+
+ g_signal_emit (
+ shell, signals[PREPARE_FOR_ONLINE], 0,
+ shell->priv->preparing_for_line_change);
+
+ g_object_unref (shell->priv->preparing_for_line_change);
}
/* Helper for shell_query_module() */
@@ -535,8 +583,8 @@ shell_class_init (EShellClass *class)
* the #EShellModule should reference the @activity until
* preparations are complete, and then unreference the @activity.
* This will delay Evolution from actually going to offline mode
- * until the all modules have unreferenced @activity.
- */
+ * until all modules have unreferenced @activity.
+ **/
signals[PREPARE_FOR_OFFLINE] = g_signal_new (
"prepare-for-offline",
G_OBJECT_CLASS_TYPE (object_class),
@@ -547,6 +595,31 @@ shell_class_init (EShellClass *class)
E_TYPE_ACTIVITY);
/**
+ * EShell:prepare-for-online
+ * @shell: the #EShell which emitted the signal
+ * @activity: the #EActivity for offline preparations
+ *
+ * Emitted when the user elects to work online. An #EShellModule
+ * should listen for this signal and make preparations for working
+ * in online mode.
+ *
+ * If preparations for working online cannot immediately be
+ * completed (such as when re-connecting to a remote server), the
+ * #EShellModule should reference the @activity until preparations
+ * are complete, and then unreference the @activity. This will
+ * delay Evolution from actually going to online mode until all
+ * modules have unreferenced @activity.
+ **/
+ signals[PREPARE_FOR_ONLINE] = g_signal_new (
+ "prepare-for-online",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_ACTIVITY);
+
+ /**
* EShell:send-receive
* @shell: the #EShell which emitted the signal
* @parent: a parent #GtkWindow
@@ -957,7 +1030,7 @@ e_shell_get_online_mode (EShell *shell)
* @shell: an #EShell
* @online_mode: whether to put Evolution in online mode
*
- * Puts Evolution in online or offline mode.
+ * Asynchronously places Evolution in online or offline mode.
**/
void
e_shell_set_online_mode (EShell *shell,
@@ -968,20 +1041,10 @@ e_shell_set_online_mode (EShell *shell,
if (online_mode == shell->priv->online_mode)
return;
- if (!online_mode && e_shell_get_network_available (shell))
+ if (online_mode)
+ shell_prepare_for_online (shell);
+ else
shell_prepare_for_offline (shell);
- else {
- EActivity *activity;
-
- shell->priv->online_mode = online_mode;
- g_object_notify (G_OBJECT (shell), "online-mode");
-
- /* If we're being forced offline and we've already started
- * preparing for offline mode, cancel the preparations. */
- activity = shell->priv->preparing_for_offline;
- if (!online_mode && activity != NULL)
- e_activity_cancel (activity);
- }
}
GtkWidget *