* configure.ac: Depend on libalarm for Maemo.
* src/dbus_api/modest-dbus-api.h:
* src/dbus_api/modest-dbus-callbacks.c: (on_idle_send_receive),
(on_send_receive), (modest_dbus_req_handler):
Handle a SEND_RECEIVE D-Bus method.
* libmodest-dbus-client/libmodest-dbus-client.c:
(libmodest_dbus_client_send_and_receive):
* libmodest-dbus-client/libmodest-dbus-client.h:
Add C convenience functions for calling the new D-Bus method.
* src/modest-platform.h:
* src/gnome/modest-platform.c:
* src/maemo/modest-platform.c:
Added modest_platform_set_update_interval(), which uses the
alarmd API on Maemo.
(modest_platform_init),
Call modest_platform_set_update_interval(), using a hard-coded
interval for now (until the global settings dialog is implemented),
though I am not sure that this makes sense yet.
pmo-trunk-r1742
+2007-05-03 Murray Cumming <murrayc@murrayc.com>
+
+ * configure.ac: Depend on libalarm for Maemo.
+
+ * src/dbus_api/modest-dbus-api.h:
+ * src/dbus_api/modest-dbus-callbacks.c: (on_idle_send_receive),
+ (on_send_receive), (modest_dbus_req_handler):
+ Handle a SEND_RECEIVE D-Bus method.
+
+ * libmodest-dbus-client/libmodest-dbus-client.c:
+ (libmodest_dbus_client_send_and_receive):
+ * libmodest-dbus-client/libmodest-dbus-client.h:
+ Add C convenience functions for calling the new D-Bus method.
+
+ * src/modest-platform.h:
+ * src/gnome/modest-platform.c:
+ * src/maemo/modest-platform.c:
+ Added modest_platform_set_update_interval(), which uses the
+ alarmd API on Maemo.
+ (modest_platform_init),
+ Call modest_platform_set_update_interval(), using a hard-coded
+ interval for now (until the global settings dialog is implemented),
+ though I am not sure that this makes sense yet.
+
2007-05-02 Murray Cumming <murrayc@murrayc.com>
* src/dbus_api/modest-dbus-callbacks.c:
PKG_CHECK_MODULES(HILDON, hildon-1 >= 0.9.9, hildon1=yes, hildon1=no)
if test "$hildon1" == "yes"; then # the 'new' hildon
- PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-1 libosso libhildonmime osso-addressbook-1.0 wpeditor libossohelp libebook-1.2)
+ PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-1 libosso libhildonmime osso-addressbook-1.0 wpeditor libossohelp libebook-1.2 libalarm)
else # the old hildon
- PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-libs >= 0.12.0 libosso libossomime libossohelp osso-addressbook-1.0 wpeditor libebook-1.2)
+ PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-libs >= 0.12.0 libosso libossomime libossohelp osso-addressbook-1.0 wpeditor libebook-1.2 libalarm)
AC_DEFINE_UNQUOTED(MODEST_HILDON_VERSION_0, 1, ["The Hildon version we support."])
fi
return TRUE;
}
+gboolean
+libmodest_dbus_client_send_and_receive (osso_context_t *osso_context)
+{
+ osso_rpc_t retval;
+ const osso_return_t ret = osso_rpc_run_with_defaults(osso_context,
+ MODEST_DBUS_NAME,
+ MODEST_DBUS_METHOD_SEND_RECEIVE, &retval,
+ DBUS_TYPE_INVALID);
+
+ if (ret != OSSO_OK) {
+ printf("debug: osso_rpc_run() failed.\n");
+ return FALSE;
+ } else {
+ printf("debug: osso_rpc_run() succeeded.\n");
+ }
+
+ osso_rpc_free_val(&retval);
+
+ return TRUE;
+}
+
#include <stdio.h>
gboolean
-libmodest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to, const gchar *cc,
- const gchar *bcc, const gchar* subject, const gchar* body, GSList *attachments);
+libmodest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to,
+ const gchar *cc, const gchar *bcc, const gchar* subject, const gchar* body,
+ GSList *attachments);
gboolean
-libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto_uri);
+libmodest_dbus_client_mail_to (osso_context_t *osso_context,
+ const gchar *mailto_uri);
gboolean
-libmodest_dbus_client_open_message (osso_context_t *osso_context, const gchar *mail_uri);
+libmodest_dbus_client_open_message (osso_context_t *osso_context,
+ const gchar *mail_uri);
+
+gboolean
+libmodest_dbus_client_send_and_receive (osso_context_t *osso_context);
#endif /* __LIBMODEST_DBUS_CLIENT_H__ */
MODEST_DEBUS_OPEN_MESSAGE_ARGS_COUNT
};
+#define MODEST_DBUS_METHOD_SEND_RECEIVE "SendReceive"
+
#endif /* __MODEST_DBUS_API__ */
#include "modest-account-mgr.h"
#include "modest-account-mgr-helpers.h"
#include "modest-tny-account.h"
+#include "modest-ui-actions.h"
#include "widgets/modest-msg-edit-window.h"
#include "modest-tny-msg.h"
#include <libgnomevfs/gnome-vfs-utils.h>
* because that would be asynchronous. */
return OSSO_OK;
}
+
+static gboolean
+on_idle_send_receive(gpointer user_data)
+{
+ ModestWindow* main_window = modest_window_mgr_get_main_window(
+ modest_runtime_get_window_mgr ());
+ do_send_receive(main_window);
+
+ return FALSE; /* Do not call this callback again. */
+}
+
+static gint on_send_receive(GArray * arguments, gpointer data, osso_rpc_t * retval)
+{
+ /* Use g_idle to context-switch into the application's thread: */
+
+ /* This method has no arguments. */
+
+ /* printf(" debug: to=%s\n", idle_data->to); */
+ g_idle_add(on_idle_send_receive, NULL);
+
+ /* Note that we cannot report failures during send/receive,
+ * because that would be asynchronous. */
+ return OSSO_OK;
+}
/* Callback for normal D-BUS messages */
gint modest_dbus_req_handler(const gchar * interface, const gchar * method,
return on_mail_to (arguments, data, retval);
} else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_OPEN_MESSAGE) == 0) {
return on_open_message (arguments, data, retval);
+ } else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_SEND_RECEIVE) == 0) {
+ return on_send_receive (arguments, data, retval);
}
else
return OSSO_ERROR;
return TRUE;
}
+gboolean modest_platform_set_update_interval (guint minutes)
+{
+ /* TODO. */
+}
+
#include <dbus_api/modest-dbus-callbacks.h>
#include <libosso.h>
+#include <alarmd/alarm_event.h> /* For alarm_event_add(), etc. */
#include <tny-maemo-conic-device.h>
#include <tny-folder.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkmain.h>
#include <string.h>
+static cookie_t alarm_cookie = 0;
+
gboolean
modest_platform_init (void)
{
return OSSO_ERROR;
}
- /* Register hardware event dbus callback: */
- osso_hw_set_event_cb(osso_context, NULL, modest_osso_cb_hw_state_handler, NULL);
-
/* Add handler for Exit D-BUS messages.
* Not used because osso_application_set_exit_cb() is deprecated and obsolete:
result = osso_application_set_exit_cb(osso_context,
}
*/
+ /* Register hardware event dbus callback: */
+ osso_hw_set_event_cb(osso_context, NULL, modest_osso_cb_hw_state_handler, NULL);
+
+ /* 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);
+
return TRUE;
}
/* Free */
gtk_widget_destroy (GTK_WIDGET (dialog));
}
+
+
+gboolean modest_platform_set_update_interval (guint minutes)
+{
+ /* Delete any existing alarm,
+ * because we will replace it: */
+ if (alarm_cookie) {
+ /* TODO: What does the alarm_event_del() return value mean? */
+ alarm_event_del(alarm_cookie);
+ alarm_cookie = 0;
+ }
+
+ /* 0 means no updates: */
+ if (minutes == 0)
+ return TRUE;
+
+
+ /* Register alarm: */
+
+ /* Get current time: */
+ time_t time_now;
+ time (&time_now);
+ struct tm *st_time = localtime (&time_now);
+
+ /* Add minutes to tm_min field: */
+ st_time->tm_min += minutes;
+
+ /* Set the time in alarm_event_t structure: */
+ alarm_event_t event;
+ memset (&event, 0, sizeof (alarm_event_t));
+ event.alarm_time = mktime (st_time);
+
+ /* Specify what should happen when the alarm happens:
+ * It should call this D-Bus method: */
+
+ /* Note: I am surpised that alarmd can't just use the modest.service file
+ * for this. murrayc. */
+ event.dbus_path = g_strdup(PREFIX "/bin/modest");
+
+ event.dbus_interface = g_strdup (MODEST_DBUS_IFACE);
+ event.dbus_service = g_strdup (MODEST_DBUS_SERVICE);
+ event.dbus_name = g_strdup (MODEST_DBUS_METHOD_SEND_RECEIVE);
+
+ alarm_cookie = alarm_event_add (&event);
+
+ if (!alarm_cookie) {
+ /* Error */
+ printf ("Error setting alarm event. Error code: '%d'\n", alarmd_get_error ());
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/*
* modest_platform_connect_and_wait:
* @parent_window: the parent #GtkWindow for any interactive or progress feedback UI.
- * @return value: Whether a connection was make.
+ * @return value: Whether a connection was made.
*
* Attempts to make a connection, possibly showing interactive UI to achieve this.
* This will return TRUE immediately if a connection is already open.
*/
gboolean modest_platform_connect_and_wait (GtkWindow *parent_window);
+/**
+ * modest_platform_set_update_interval:
+ * @minutes: The number of minutes between updates, or 0 for no updates.
+ *
+ * Set the number of minutes between automatic updates of email accounts.
+ * The platform will cause the send/receive action to happen repeatedly.
+ **/
+gboolean modest_platform_set_update_interval (guint minutes);
+
G_END_DECLS
#endif /* __MODEST_PLATFORM_UTILS_H__ */