From 99b831c709432c1dbf5331b9ab18690426244bb8 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 27 Apr 2007 11:35:53 +0000 Subject: [PATCH] 2007-04-27 Murray Cumming * src/modest-platform.h: * src/gnome/modest-platform.c: (modest_platform_connect_and_wait): * src/maemo/modest-platform.c: (modest_platform_connect_and_wait): * src/modest-main.c: Implement this function so we can avoid using maemo-specific API from cross-platform code. (main): * src/modest-tny-account-store.c: (get_smtp_specific_transport_account_for_open_connection): * src/modest-ui-actions.c: (check_for_connection), (modest_ui_actions_on_item_not_found): Use modest_platform_connect_and_wait() and put #idefs around other maemo-specific code, because only maemo currently has a way to identify connection names. pmo-trunk-r1692 --- ChangeLog2 | 18 +++++++++++++++++- src/gnome/modest-platform.c | 8 ++++++++ src/maemo/modest-platform.c | 17 +++++++++++++++++ src/modest-main.c | 4 ++-- src/modest-platform.h | 11 +++++++++++ src/modest-tny-account-store.c | 10 +++++++++- src/modest-ui-actions.c | 5 ++--- 7 files changed, 66 insertions(+), 7 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index 11c02a0..080b38d 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,21 @@ 2007-04-27 Murray Cumming + * src/modest-platform.h: + * src/gnome/modest-platform.c: (modest_platform_connect_and_wait): + * src/maemo/modest-platform.c: (modest_platform_connect_and_wait): + * src/modest-main.c: Implement this function so we can avoid using + maemo-specific API from cross-platform code. + (main): + * src/modest-tny-account-store.c: + (get_smtp_specific_transport_account_for_open_connection): + * src/modest-ui-actions.c: (check_for_connection), + (modest_ui_actions_on_item_not_found): + Use modest_platform_connect_and_wait() and put #idefs around other + maemo-specific code, because only maemo currently has a way to + identify connection names. + +2007-04-27 Murray Cumming + * src/modest-tny-account-store.h: * src/modest-tny-account-store.c: Added modest_tny_account_store_get_transport_account_for_open_connection(), which respects @@ -21,7 +37,7 @@ (modest_ui_actions_on_send_receive): Check that a connection is open before proceeding. - Receive and then send, instead of vice-versa, as per the specification + Receive and then send, instead of vice-versa, as per the specification. 2007-04-26 Murray Cumming diff --git a/src/gnome/modest-platform.c b/src/gnome/modest-platform.c index 999e462..3fc46b4 100644 --- a/src/gnome/modest-platform.c +++ b/src/gnome/modest-platform.c @@ -189,3 +189,11 @@ modest_platform_run_information_dialog (GtkWindow *parent_window, /* TODO: implement a information dialog */ } + +gboolean modest_platform_connect_and_wait (GtkWindow *parent_window) +{ + /* TODO: Do something with network-manager? + Otherwise, maybe it is safe to assume that we would already be online if we could be. */ + return TRUE; +} + diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index 2659506..46505dd 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -507,3 +508,19 @@ modest_platform_run_information_dialog (GtkWindow *parent_window, gtk_widget_destroy (GTK_WIDGET (dialog)); } + +gboolean modest_platform_connect_and_wait (GtkWindow *parent_window) +{ + TnyDevice *device = modest_runtime_get_device(); + + if (tny_device_is_online (device)) + return TRUE; + + /* TODO: Block on the result: */ + gboolean request_sent = tny_maemo_conic_device_connect (TNY_MAEMO_CONIC_DEVICE (device), NULL); + if (!request_sent) + return FALSE; + + return TRUE; +} + diff --git a/src/modest-main.c b/src/modest-main.c index 9dcc063..324465c 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -38,9 +38,9 @@ #include #include #include -#include /* For tny_maemo_conic_device_connect() */ #include +#include #include #include @@ -136,7 +136,7 @@ main (int argc, char *argv[]) } else { if (modest_conf_get_bool (modest_runtime_get_conf(), MODEST_CONF_CONNECT_AT_STARTUP, NULL)) - tny_maemo_conic_device_connect (TNY_MAEMO_CONIC_DEVICE (modest_runtime_get_device()), NULL); + modest_platform_connect_and_wait(NULL); retval = start_ui (account_or_default, mailto, cc, bcc, subject, body); diff --git a/src/modest-platform.h b/src/modest-platform.h index 492bfa3..84aa8cd 100644 --- a/src/modest-platform.h +++ b/src/modest-platform.h @@ -163,6 +163,17 @@ gint modest_platform_run_confirmation_dialog (GtkWindow *parent_window **/ void modest_platform_run_information_dialog (GtkWindow *parent_window, ModestInformationDialogType type); + +/* + * modest_platform_connect_and_wait: + * @parent_window: the parent #GtkWindow for any interactive or progress feedback UI. + * @return value: Whether a connection was make. + * + * Attempts to make a connection, possibly showing interactive UI to achieve this. + * This will return TRUE immediately if a connection is already open. + * Otherwise, this function blocks until the connection attempt has either succeded or failed. + */ +gboolean modest_platform_connect_and_wait (GtkWindow *parent_window); G_END_DECLS diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 39f6b78..8eac8c8 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -36,10 +36,10 @@ #include #include #include -#include /* For ConIcIap */ #include #include #include + #include #include #include @@ -53,6 +53,10 @@ #include #include +#ifdef MODEST_PLATFORM_MAEMO +#include +#endif + /* 'private'/'protected' functions */ static void modest_tny_account_store_class_init (ModestTnyAccountStoreClass *klass); //static void modest_tny_account_store_init (ModestTnyAccountStore *obj); @@ -780,6 +784,7 @@ static TnyAccount* get_smtp_specific_transport_account_for_open_connection (Mode if (!tny_device_is_online (device)) return NULL; +#ifdef MODEST_PLATFORM_MAEMO g_assert (TNY_IS_MAEMO_CONIC_DEVICE (device)); TnyMaemoConicDevice *maemo_device = TNY_MAEMO_CONIC_DEVICE (device); const gchar* iap_id = tny_maemo_conic_device_get_current_iap_id (maemo_device); @@ -809,6 +814,9 @@ static TnyAccount* get_smtp_specific_transport_account_for_open_connection (Mode g_object_unref (connection); return account; +#else + return NULL; /* TODO: Implement this for GNOME, instead of just Maemo? */ +#endif /* MODEST_PLATFORM_MAEMO */ } diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index b7d12f9..f286737 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -52,7 +52,6 @@ #include "modest-account-mgr-helpers.h" #include "modest-mail-operation.h" #include "modest-text-utils.h" -#include /* For ConIcIap */ #ifdef MODEST_HAVE_EASYSETUP #include "easysetup/modest-easysetup-wizard.h" @@ -677,7 +676,7 @@ gboolean check_for_connection (const gchar *account_name) if (tny_device_is_online (device)) return TRUE; else { - tny_maemo_conic_device_connect (TNY_MAEMO_CONIC_DEVICE (device), NULL); + modest_platform_connect_and_wait (NULL); /* TODO: Wait until a result. */ return TRUE; @@ -1017,7 +1016,7 @@ modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,ModestItemTyp gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300); if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { -// tny_maemo_conic_device_connect (TNY_MAEMO_CONIC_DEVICE (modest_runtime_get_device()); +// modest_platform_connect_and_wait ();; } } gtk_widget_destroy (dialog); -- 1.7.9.5