}
void
+modest_mail_operation_send_mail (ModestMailOperation *self,
+ TnyTransportAccount *transport_account,
+ TnyMsg *msg)
+{
+ TnySendQueue *send_queue = NULL;
+ ModestMailOperationPrivate *priv = NULL;
+
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+
+ if (!msg) {
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ modest_mail_operation_notify_end (self);
+ return;
+ }
+
+ if (priv->error && priv->error->code != MODEST_MAIL_OPERATION_ERROR_FILE_IO) {
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ modest_mail_operation_notify_end (self);
+ return;
+ }
+
+ /* Add message to send queue */
+ send_queue = TNY_SEND_QUEUE (modest_runtime_get_send_queue (transport_account, TRUE));
+ if (!TNY_IS_SEND_QUEUE(send_queue)) {
+ if (priv->error) {
+ g_error_free (priv->error);
+ priv->error = NULL;
+ }
+ g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
+ MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
+ "modest: could not find send queue for account\n");
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ modest_mail_operation_notify_end (self);
+ return;
+ } else {
+ SendNewMailHelper *helper = g_slice_new (SendNewMailHelper);
+ helper->mail_op = g_object_ref (self);
+ helper->notify = TRUE;
+
+ /* Add the msg to the queue. The callback will free
+ the helper */
+ modest_tny_send_queue_set_requested_send_receive (MODEST_TNY_SEND_QUEUE (send_queue),
+ FALSE);
+ tny_send_queue_add_async (send_queue, msg, send_mail_on_added_to_outbox,
+ NULL, helper);
+ }
+
+}
+
+void
modest_mail_operation_send_new_mail (ModestMailOperation *self,
TnyTransportAccount *transport_account,
TnyMsg *draft_msg,
TnyHeaderFlags priority_flags,
TnyList *header_pairs);
+void modest_mail_operation_send_mail (ModestMailOperation *mail_operation,
+ TnyTransportAccount *transport_account,
+ TnyMsg *msg);
/**
* modest_mail_operation_save_to_drafts:
return !had_error;
}
+gboolean
+modest_ui_actions_on_send_msg (ModestWindow *window,
+ TnyMsg *msg)
+{
+ TnyTransportAccount *transport_account = NULL;
+ gboolean had_error = FALSE;
+ ModestAccountMgr *account_mgr;
+ gchar *account_name;
+ ModestMailOperation *mail_operation;
+
+ account_mgr = modest_runtime_get_account_mgr();
+ account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(window)));
+
+ if (!account_name)
+ account_name = modest_account_mgr_get_default_account (account_mgr);
+
+ /* Get the currently-active transport account for this modest account: */
+ if (account_name && strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) {
+ transport_account =
+ TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account
+ (modest_runtime_get_account_store (),
+ account_name, TNY_ACCOUNT_TYPE_TRANSPORT));
+ }
+
+ /* Create the mail operation */
+ mail_operation = modest_mail_operation_new_with_error_handling (NULL, modest_ui_actions_disk_operations_error_handler, NULL, NULL);
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
+
+ modest_mail_operation_send_mail (mail_operation,
+ transport_account,
+ msg);
+
+ if (modest_mail_operation_get_status (mail_operation) == MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
+ modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent"));
+
+ if (modest_mail_operation_get_error (mail_operation) != NULL) {
+ const GError *error = modest_mail_operation_get_error (mail_operation);
+ if (error->domain == MODEST_MAIL_OPERATION_ERROR &&
+ error->code == MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED) {
+ g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_operation))->message);
+ modest_platform_information_banner (NULL, NULL, _CS("sfil_ni_not_enough_memory"));
+ had_error = TRUE;
+ }
+ }
+
+ /* Free data: */
+ g_free (account_name);
+ g_object_unref (G_OBJECT (transport_account));
+ g_object_unref (G_OBJECT (mail_operation));
+
+ return !had_error;
+}
+
void
modest_ui_actions_on_toggle_bold (GtkToggleAction *action,
ModestMsgEditWindow *window)
void modest_ui_actions_on_msg_recpt_activated (ModestMsgView *msgview, const gchar *address,
ModestWindow *win);
+gboolean modest_ui_actions_on_send_msg (ModestWindow *window,
+ TnyMsg *msg);
+
gboolean modest_ui_actions_on_send (GtkWidget *widget,
ModestMsgEditWindow *edit_window);
gboolean modest_ui_actions_on_save_to_drafts (GtkWidget *widget,