From 045b188038e81aebbc7fc4b899537cd8f61f80c8 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 26 Jun 2007 11:39:46 +0000 Subject: [PATCH] 2007-06-26 Murray Cumming * libmodest-dbus-client/libmodest-dbus-client.c: * libmodest-dbus-client/libmodest-dbus-client.h: Removed libmodest_dbus_client_send_mail() because it is not used by anything. libmodest_dbus_client_compose_mail() is what things actually use. * src/dbus_api/modest-dbus-api.h: * src/dbus_api/modest-dbus-callbacks.c: (modest_dbus_req_handler): * tests/dbus_api/Makefile.am: * tests/dbus_api/test_send_mail.c: Removed the MODEST_DBUS_METHOD_SEND_MAIL D-Bus method. pmo-trunk-r2424 --- ChangeLog2 | 13 +++ libmodest-dbus-client/libmodest-dbus-client.c | 53 ++---------- libmodest-dbus-client/libmodest-dbus-client.h | 5 -- src/dbus_api/modest-dbus-api.h | 11 --- src/dbus_api/modest-dbus-callbacks.c | 107 +------------------------ tests/dbus_api/Makefile.am | 6 +- tests/dbus_api/test_send_mail.c | 34 -------- 7 files changed, 21 insertions(+), 208 deletions(-) delete mode 100644 tests/dbus_api/test_send_mail.c diff --git a/ChangeLog2 b/ChangeLog2 index 4e42389..24378ce 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,18 @@ 2007-06-26 Murray Cumming + * libmodest-dbus-client/libmodest-dbus-client.c: + * libmodest-dbus-client/libmodest-dbus-client.h: + Removed libmodest_dbus_client_send_mail() because it is not used by anything. + libmodest_dbus_client_compose_mail() is what things actually use. + + * src/dbus_api/modest-dbus-api.h: + * src/dbus_api/modest-dbus-callbacks.c: (modest_dbus_req_handler): + * tests/dbus_api/Makefile.am: + * tests/dbus_api/test_send_mail.c: Removed the MODEST_DBUS_METHOD_SEND_MAIL + D-Bus method. + +2007-06-26 Murray Cumming + * src/modest-init.c: (modest_init_local_folders): For memory-card (or other non local-folders) maildir accounts, always create an Archive folder, so that there is somewhere to put diff --git a/libmodest-dbus-client/libmodest-dbus-client.c b/libmodest-dbus-client/libmodest-dbus-client.c index 19210d3..e93deae 100644 --- a/libmodest-dbus-client/libmodest-dbus-client.c +++ b/libmodest-dbus-client/libmodest-dbus-client.c @@ -61,60 +61,19 @@ static gchar* get_attachments_string (GSList *attachments) return attachments_str; } - -/* TODO: Is this actually used by anything? - * I guess that everything uses *_compose_mail() instead. murrayc. - */ - + /** - * libmodest_dbus_client_send_mail: + * libmodest_dbus_client_mail_to: * @osso_context: a valid #osso_context_t object. - * @to: The Recipients (From: line) - * @cc: Recipients for carbon copies - * @bcc: Recipients for blind carbon copies - * @subject: Subject line - * @body: The actual body of the mail to send - * @attachments: Additional list of attachments + * @mailto_uri: A mailto URI. * * This function will try to do a remote procedure call (rpc) - * into modest (or start it if necessary) and send a new - * email with the supplied parameters. + * into modest (or start it if necessary) and open a composer + * window with the supplied parameters prefilled. * * Return value: Whether or not the rpc call to modest * was successfull **/ -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) -{ - gchar *attachments_str = get_attachments_string(attachments); - - osso_rpc_t retval; - const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, - MODEST_DBUS_NAME, - MODEST_DBUS_METHOD_SEND_MAIL, &retval, - DBUS_TYPE_STRING, to, - DBUS_TYPE_STRING, cc, - DBUS_TYPE_STRING, bcc, - DBUS_TYPE_STRING, subject, - DBUS_TYPE_STRING, body, - DBUS_TYPE_STRING, attachments_str, - DBUS_TYPE_INVALID); - - if (ret != OSSO_OK) { - printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__); - return FALSE; - } else { - printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__); - } - - osso_rpc_free_val(&retval); - - g_free (attachments_str); - - return TRUE; -} - gboolean libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto_uri) { @@ -144,7 +103,7 @@ libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto * @cc: Recipients for carbon copies * @bcc: Recipients for blind carbon copies * @subject: Subject line - * @body: The actual body of the mail to send + * @body: The actual body of the mail to compose. * @attachments: Additional list of attachments * * This function will try to do a remote procedure call (rpc) diff --git a/libmodest-dbus-client/libmodest-dbus-client.h b/libmodest-dbus-client/libmodest-dbus-client.h index 7ec38dd..484e700 100644 --- a/libmodest-dbus-client/libmodest-dbus-client.h +++ b/libmodest-dbus-client/libmodest-dbus-client.h @@ -35,11 +35,6 @@ #include 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); - -gboolean libmodest_dbus_client_compose_mail (osso_context_t *osso_context, const gchar *to, const gchar *cc, const gchar *bcc, const gchar* subject, const gchar* body, GSList *attachments); diff --git a/src/dbus_api/modest-dbus-api.h b/src/dbus_api/modest-dbus-api.h index 364de16..278ba39 100644 --- a/src/dbus_api/modest-dbus-api.h +++ b/src/dbus_api/modest-dbus-api.h @@ -40,17 +40,6 @@ #define MODEST_DBUS_OBJECT "/com/nokia/"MODEST_DBUS_NAME #define MODEST_DBUS_IFACE "com.nokia."MODEST_DBUS_NAME -#define MODEST_DBUS_METHOD_SEND_MAIL "SendMail" -enum ModestDbusSendMailArguments -{ - MODEST_DEBUS_SEND_MAIL_ARG_TO, - MODEST_DEBUS_SEND_MAIL_ARG_CC, - MODEST_DEBUS_SEND_MAIL_ARG_BCC, - MODEST_DEBUS_SEND_MAIL_ARG_SUBJECT, - MODEST_DEBUS_SEND_MAIL_ARG_BODY, - MODEST_DEBUS_SEND_MAIL_ARG_ATTACHMENTS, - MODEST_DEBUS_SEND_MAIL_ARGS_COUNT -}; #define MODEST_DBUS_METHOD_MAIL_TO "MailTo" enum ModestDbusMailToArguments diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 3c4f70b..d783567 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -73,109 +73,6 @@ typedef struct gchar *attachments; } ComposeMailIdleData; -static gboolean -on_idle_send_mail(gpointer user_data) -{ - SendMailIdleData *idle_data = (SendMailIdleData*)user_data; - - /* Get the TnyTransportAccount so we can instantiate a mail operation: */ - ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr(); - gchar *account_name = modest_account_mgr_get_default_account (account_mgr); - if (!account_name) { - g_printerr ("modest: no account found\n"); - } - - TnyTransportAccount *transport_account = NULL; - if (account_mgr) { - transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection - (modest_runtime_get_account_store(), - account_name)); - } - - if (!transport_account) { - g_printerr ("modest: no transport account found for '%s'\n", account_name); - } - - /* Create the mail operation: */ - if (transport_account) { - /* Use the mail operation: */ - gchar * from = modest_account_mgr_get_from_string (account_mgr, - account_name); - if (!from) { - g_printerr ("modest: no from address for account '%s'\n", account_name); - } else { - ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, NULL); - modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation); - - modest_mail_operation_send_new_mail (mail_operation, - transport_account, - NULL, - from, /* from */ - idle_data->to, idle_data->cc, idle_data->bcc, idle_data->subject, - idle_data->body, /* plain_body */ - NULL, /* html_body */ - NULL, /* attachments_list, GSList of TnyMimePart. */ - (TnyHeaderFlags)0); - - g_free (from); - g_object_unref (G_OBJECT (mail_operation)); - } - - g_object_unref (G_OBJECT (transport_account)); - } - - g_free (account_name); - - /* Free the idle data: */ - g_free (idle_data->to); - g_free (idle_data->cc); - g_free (idle_data->bcc); - g_free (idle_data->subject); - g_free (idle_data->body); - g_free (idle_data->attachments); - g_free (idle_data); - - return FALSE; /* Do not call this callback again. */ -} - -/* TODO: Is this actually used by anything? - * I guess that everything uses *_compose_mail() instead. murrayc. - */ -static gint on_send_mail(GArray * arguments, gpointer data, osso_rpc_t * retval) -{ - if (arguments->len != MODEST_DEBUS_SEND_MAIL_ARGS_COUNT) - return OSSO_ERROR; - - /* Use g_idle to context-switch into the application's thread: */ - SendMailIdleData *idle_data = g_new0(SendMailIdleData, 1); /* Freed in the idle callback. */ - - /* Get the arguments: */ - osso_rpc_t val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_TO); - idle_data->to = g_strdup (val.value.s); - - val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_CC); - idle_data->cc = g_strdup (val.value.s); - - val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_BCC); - idle_data->bcc = g_strdup (val.value.s); - - val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_SUBJECT); - idle_data->subject = g_strdup (val.value.s); - - val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_BODY); - idle_data->body = g_strdup (val.value.s); - - val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_ATTACHMENTS); - idle_data->attachments = g_strdup (val.value.s); - - /* printf(" debug: to=%s\n", idle_data->to); */ - g_idle_add(on_idle_send_mail, (gpointer)idle_data); - - /* Note that we cannot report failures during sending, - * because that would be asynchronous. */ - return OSSO_OK; -} - /** uri_unescape: * @uri An escaped URI. URIs should always be escaped. * @len The length of the @uri string, or -1 if the string is null terminated. @@ -825,9 +722,7 @@ gint modest_dbus_req_handler(const gchar * interface, const gchar * method, g_debug ("debug: %s\n", __FUNCTION__); g_debug ("debug: %s: method received: %s\n", __FUNCTION__, method); - if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_SEND_MAIL) == 0) { - return on_send_mail (arguments, data, retval); - } else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_MAIL_TO) == 0) { + if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_MAIL_TO) == 0) { 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); diff --git a/tests/dbus_api/Makefile.am b/tests/dbus_api/Makefile.am index 696683b..09bfdb7 100644 --- a/tests/dbus_api/Makefile.am +++ b/tests/dbus_api/Makefile.am @@ -16,8 +16,7 @@ objects=\ $(MODEST_LIBTINYMAIL_MAEMO_LIBS) \ ${top_srcdir}/libmodest-dbus-client/libmodest-dbus-client-1.0.la -noinst_PROGRAMS = test_send_mail \ - test_mail_to \ +noinst_PROGRAMS = test_mail_to \ test_open_message \ test_search \ test_delete_message \ @@ -25,9 +24,6 @@ noinst_PROGRAMS = test_send_mail \ test_open_default_inbox \ test_get_folders -test_send_mail_SOURCES = test_send_mail.c -test_send_mail_LDADD = $(objects) - test_mail_to_SOURCES = test_mail_to.c test_mail_to_LDADD = $(objects) diff --git a/tests/dbus_api/test_send_mail.c b/tests/dbus_api/test_send_mail.c deleted file mode 100644 index 7f05a51..0000000 --- a/tests/dbus_api/test_send_mail.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -int main(int argc, char *argv[]) -{ - /* Initialize maemo application */ - osso_context_t * osso_context = osso_initialize( - "test_hello", "0.0.1", TRUE, NULL); - - /* Check that initialization was ok */ - if (osso_context == NULL) - { - printf("osso_initialize() failed.\n"); - return OSSO_ERROR; - } - - /* Call the function in libmodest-dbus-client: */ - const gboolean ret = libmodest_dbus_client_send_mail (osso_context, - "murrayc@murrayc.com", /* to */ - NULL, /* cc */ - NULL, /* bcc */ - "test subject", /* subject */ - "test body\nline two", /* body */ - NULL); - if (!ret) { - printf("libmodest_dbus_client_call_helloworld() failed.\n"); - return OSSO_ERROR; - } else { - printf("libmodest_dbus_client_call_helloworld() succeeded.\n"); - } - - /* Exit */ - return 0; -} -- 1.7.9.5