2007-06-26 Murray Cumming <murrayc@murrayc.com>
+ * 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 <murrayc@murrayc.com>
+
* 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
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)
{
* @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)
#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);
-
-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);
#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
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.
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);
$(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 \
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)
+++ /dev/null
-#include <libmodest-dbus-client/libmodest-dbus-client.h>
-#include <stdio.h>
-
-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;
-}