From 9370ef584b364e702445220330867f28181b480b Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 15 May 2007 14:28:00 +0000 Subject: [PATCH] 2007-05-15 Murray Cumming * src/maemo/modest-maemo-global-settings-dialog.c: (current_connection): Prevent a crash in scratchbox when ny_maemo_conic_device_get_current_iap_id() returns NULL. * src/maemo/modest-platform.c: (on_modest_conf_update_interval_changed), (modest_platform_init): Get the update interval from gconf and reset it when the gconf key changes. pmo-trunk-r1876 --- ChangeLog2 | 9 +++++++ src/dbus_api/modest-dbus-callbacks.c | 2 +- src/maemo/modest-maemo-global-settings-dialog.c | 29 ++++++++++++----------- src/maemo/modest-platform.c | 27 ++++++++++++++++----- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index f6b93dd..4a0dd05 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,14 @@ 2007-05-15 Murray Cumming + * src/maemo/modest-maemo-global-settings-dialog.c: + (current_connection): Prevent a crash in scratchbox when + ny_maemo_conic_device_get_current_iap_id() returns NULL. + * src/maemo/modest-platform.c: + (on_modest_conf_update_interval_changed), (modest_platform_init): + Get the update interval from gconf and reset it when the gconf key changes. + +2007-05-15 Murray Cumming + * src/modest-protocol-info.c: * src/modest-protocol-info.h: Adde enum-specific get functions, instead of using a ModestProtocolType enum parameter. diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 35940a0..aa3d541 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -474,7 +474,7 @@ on_idle_send_receive(gpointer user_data) win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()); /* Send & receive all if "Update automatically" is set */ - /* TODO: check the auto-update parametter in the configuration */ + /* TODO: check the auto-update parameter in the configuration */ modest_ui_actions_do_send_receive_all (win); return FALSE; /* Do not call this callback again. */ diff --git a/src/maemo/modest-maemo-global-settings-dialog.c b/src/maemo/modest-maemo-global-settings-dialog.c index 1d3d6c5..e262409 100644 --- a/src/maemo/modest-maemo-global-settings-dialog.c +++ b/src/maemo/modest-maemo-global-settings-dialog.c @@ -375,25 +375,26 @@ current_connection (void) { TnyAccountStore *account_store; TnyDevice *device; - gboolean retval; - const gchar *bearer_type, *iap_id; - ConIcIap *iap; + gboolean retval = FALSE; account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()); device = tny_account_store_get_device (account_store); /* Get iap id */ - iap_id = tny_maemo_conic_device_get_current_iap_id (TNY_MAEMO_CONIC_DEVICE (device)); - iap = tny_maemo_conic_device_get_iap (TNY_MAEMO_CONIC_DEVICE (device), iap_id); - bearer_type = con_ic_iap_get_bearer_type (iap); - - if (!strcmp (bearer_type, CON_IC_BEARER_WLAN_INFRA) || - !strcmp (bearer_type, CON_IC_BEARER_WLAN_ADHOC)) - retval = MODEST_CONNECTED_VIA_WLAN; - else - retval = MODEST_CONNECTED_VIA_ANY; - - g_object_unref (iap); + const gchar *iap_id = tny_maemo_conic_device_get_current_iap_id (TNY_MAEMO_CONIC_DEVICE (device)); + if (iap_id) { + ConIcIap *iap = tny_maemo_conic_device_get_iap ( + TNY_MAEMO_CONIC_DEVICE (device), iap_id); + const gchar *bearer_type = con_ic_iap_get_bearer_type (iap); + + if (!strcmp (bearer_type, CON_IC_BEARER_WLAN_INFRA) || + !strcmp (bearer_type, CON_IC_BEARER_WLAN_ADHOC)) + retval = MODEST_CONNECTED_VIA_WLAN; + else + retval = MODEST_CONNECTED_VIA_ANY; + + g_object_unref (iap); + } g_object_unref (device); return retval; diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index c1f43f1..0eed3e9 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -50,6 +50,15 @@ static osso_context_t *osso_context = NULL; +static void +on_modest_conf_update_interval_changed (ModestConf* self, const gchar *key, + ModestConfEvent event, gpointer user_data) +{ + const guint update_interval_minutes = + modest_conf_get_int (self, MODEST_CONF_UPDATE_INTERVAL, NULL); + modest_platform_set_update_interval (update_interval_minutes); +} + gboolean modest_platform_init (void) { @@ -95,12 +104,18 @@ modest_platform_init (void) g_warning ("osso_application_set_autosave_cb() failed."); } - - /* TODO: Get the actual update interval from gconf, - * when that preferences dialog has been implemented. - * And make sure that this is called again whenever that is changed. */ - const guint update_interval_minutes = 15; - modest_platform_set_update_interval (update_interval_minutes); + + /* Make sure that the update interval is changed whenever its gconf key + * is changed: */ + ModestConf *conf = modest_runtime_get_conf (); + g_signal_connect (G_OBJECT(conf), + "key_changed", + G_CALLBACK (on_modest_conf_update_interval_changed), + NULL); + + /* Get the initial update interval from gconf: */ + on_modest_conf_update_interval_changed(conf, NULL, + MODEST_CONF_EVENT_KEY_CHANGED, NULL); return TRUE; } -- 1.7.9.5