diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-10-22 04:21:19 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-23 02:21:22 +0800 |
commit | c881b5bc5e61d04b18d4ab46ad70533e7340d15b (patch) | |
tree | e70a3ed0d2f93dacfe20d856de4d29578beb2e50 /mail/importers | |
parent | f0714755e2fa8b06425907c2cf189abd3a1b7119 (diff) | |
download | gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.gz gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.zst gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.zip |
Simplify EActivity.
With unintrusive error dialogs gone, we can cut some unnecessary bits
out of EActivity.
I'm also adding a new enum property called "state", which is one of:
E_ACTIVITY_RUNNING
E_ACTIVITY_WAITING
E_ACTIVITY_CANCELLED
E_ACTIVITY_COMPLETED
The state of an activity must be explicitly changed. In particular,
when the user cancels an activity the state should be set only after
confirming the operation has been cancelled and not when cancellation
is requested (e.g. after receiving a G_IO_ERROR_CANCELLED, not when
the GCancellable emits "cancelled"). EActivityBar and EActivityProxy
widgets have been updated to make this distinction clearer in the UI.
E_ACTIVITY_WAITING will be used when activities have to be queued and
dispatched in sequence, which I haven't written yet.
Diffstat (limited to 'mail/importers')
-rw-r--r-- | mail/importers/elm-importer.c | 4 | ||||
-rw-r--r-- | mail/importers/mail-importer.c | 22 | ||||
-rw-r--r-- | mail/importers/pine-importer.c | 4 |
3 files changed, 19 insertions, 11 deletions
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 18548fc21b..292d7c3ffe 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -184,7 +184,9 @@ static MailImporterSpecial elm_special_folders[] = { }; static void -elm_import_exec (struct _elm_import_msg *m) +elm_import_exec (struct _elm_import_msg *m, + GCancellable *cancellable, + GError **error) { EShell *shell; EShellBackend *shell_backend; diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index b4fb3c0431..7eaed4759e 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -107,7 +107,9 @@ decode_mozilla_status (const gchar *tmp) } static void -import_mbox_exec (struct _import_mbox_msg *m) +import_mbox_exec (struct _import_mbox_msg *m, + GCancellable *cancellable, + GError **error) { CamelFolder *folder; CamelMimeParser *mp = NULL; @@ -125,7 +127,7 @@ import_mbox_exec (struct _import_mbox_msg *m) else folder = e_mail_session_uri_to_folder_sync ( m->session, m->uri, CAMEL_STORE_FOLDER_CREATE, - m->base.cancellable, &m->base.error); + cancellable, error); if (folder == NULL) return; @@ -144,7 +146,7 @@ import_mbox_exec (struct _import_mbox_msg *m) } camel_operation_push_message ( - m->base.cancellable, _("Importing '%s'"), + cancellable, _("Importing '%s'"), camel_folder_get_full_name (folder)); camel_folder_freeze (folder); while (camel_mime_parser_step (mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) { @@ -155,7 +157,7 @@ import_mbox_exec (struct _import_mbox_msg *m) if (st.st_size > 0) pc = (gint)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size)); - camel_operation_progress (m->base.cancellable, pc); + camel_operation_progress (cancellable, pc); msg = camel_mime_message_new (); if (!camel_mime_part_construct_from_parser_sync ( @@ -180,11 +182,11 @@ import_mbox_exec (struct _import_mbox_msg *m) camel_message_info_set_flags (info, flags, ~0); camel_folder_append_message_sync ( folder, msg, info, NULL, - m->base.cancellable, &m->base.error); + cancellable, error); camel_message_info_free (info); g_object_unref (msg); - if (m->base.error != NULL) + if (error != NULL) break; camel_mime_parser_step (mp, NULL, NULL); @@ -192,7 +194,7 @@ import_mbox_exec (struct _import_mbox_msg *m) /* FIXME Not passing a GCancellable or GError here. */ camel_folder_synchronize_sync (folder, FALSE, NULL, NULL); camel_folder_thaw (folder); - camel_operation_pop_message (m->base.cancellable); + camel_operation_pop_message (cancellable); /* TODO: these api's are a bit weird, registering the old is the same as deregistering */ fail2: g_object_unref (mp); @@ -267,9 +269,11 @@ mail_importer_import_mbox_sync (EMailSession *session, m->path = g_strdup (path); m->uri = g_strdup (folderuri); if (cancellable) - m->cancellable = g_object_ref (cancellable); + e_activity_set_cancellable (m->base.activity, cancellable); + + cancellable = e_activity_get_cancellable (m->base.activity); - import_mbox_exec (m); + import_mbox_exec (m, cancellable, &m->base.error); import_mbox_done (m); mail_msg_unref (m); } diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index 26a37b853e..e7ace0b1b5 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -230,7 +230,9 @@ static MailImporterSpecial pine_special_folders[] = { }; static void -pine_import_exec (struct _pine_import_msg *m) +pine_import_exec (struct _pine_import_msg *m, + GCancellable *cancellable, + GError **error) { EShell *shell; EShellBackend *shell_backend; |