goto FINISH_OFF;
}
dst_mailbox_id = local_mailbox->mailbox_id;
-
- if(local_mailbox)
- emstorage_free_mailbox(&local_mailbox, 1, NULL);
+ emstorage_free_mailbox(&local_mailbox, 1, NULL);
if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, (void **)&tmp_stream, &err)) {
goto FINISH_OFF;
}
dst_mailbox_id = local_mailbox->mailbox_id;
-
- if(local_mailbox)
- emstorage_free_mailbox(&local_mailbox, 1, NULL);
+ emstorage_free_mailbox(&local_mailbox, 1, NULL);
/* unsent mail is moved to 'OUTBOX'. */
if (!emcore_move_mail(&mail_id, 1, dst_mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, NULL))
#endif
#endif
+ if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ emstorage_mailbox_tbl_t* src_mailbox = NULL;
+ if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &src_mailbox, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (src_mailbox->local_yn)
+ emcore_sync_mail_from_client_to_server(mail_id);
+ else {
+ if (!emcore_move_mail_on_server(account_id, src_mailbox->mailbox_id, &mail_id, 1, local_mailbox->mailbox_name, &err)) {
+ EM_DEBUG_EXCEPTION(" emcore_move_mail_on_server falied [%d]", err);
+ }
+ }
+
+ emstorage_free_mailbox(&src_mailbox, 1, NULL);
+ }
+
/* On Successful Mail sent remove the Draft flag */
mail_tbl_data->flags_draft_field = 0;
#include "email-service-glue.h"\r
#include <unistd.h>\r
\r
-GMainLoop *loop = NULL;\r
-GObject *object = NULL;\r
-DBusGConnection *connection = NULL;\r
-\r
-static pid_t launch_by_client = 0;\r
-\r
-void __net_nfc_discovery_polling_cb(int signo);\r
-bool Check_Redwood();\r
\r
G_DEFINE_TYPE(EmailService, email_service, G_TYPE_OBJECT)\r
\r
-#define __G_ASSERT(test, return_val, error, domain, error_code)\\r
-G_STMT_START\\r
-{\\r
- if G_LIKELY (!(test)) { \\r
- g_set_error (error, domain, error_code, #test); \\r
- return (return_val); \\r
- }\\r
-}\\r
-G_STMT_END\r
-\r
-\r
static void email_service_init(EmailService *email_service)\r
{\r
EM_DEBUG_LOG("email_service_init entered");\r
}\r
\r
-GQuark email_service_error_quark(void)\r
-{\r
- EM_DEBUG_LOG("email_service_error_quark entered");\r
- return g_quark_from_static_string("email_service_error");\r
-}\r
-\r
-\r
static void email_service_class_init(EmailServiceClass *email_service_class)\r
{\r
EM_DEBUG_LOG("email_service_class_init entered");\r
\r
- /*\r
- dbus_g_object_type_install_info(EMAIL_SERVICE_TYPE, &dbus_glib_nfc_service_object_info);\r
- */\r
+ dbus_g_object_type_install_info(EMAIL_SERVICE_TYPE, &dbus_glib_email_service_object_info);\r
}\r
\r
EXPORT_API int emipc_launch_email_service()\r
EM_DEBUG_FUNC_BEGIN();\r
int err = EMAIL_ERROR_NONE;\r
\r
- /*DBUS*/\r
DBusGConnection *connection = NULL;\r
DBusGProxy *proxy = NULL;\r
GError *error = NULL;\r
guint dbus_result = 0;\r
\r
- //if(!g_thread_supported()) {\r
- // g_thread_init(NULL);\r
- //}\r
-\r
- //dbus_g_thread_init();\r
-\r
g_type_init();\r
\r
- //pthread_mutex_lock(&g_client_context.g_client_lock);\r
-\r
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);\r
- if (error == NULL) {\r
- proxy = dbus_g_proxy_new_for_name(connection, EMAIL_SERVICE_NAME, EMAIL_SERVICE_PATH, EMAIL_SERVICE_NAME);\r
-\r
- if (proxy != NULL) {\r
- if (org_tizen_email_service_launch(proxy, &dbus_result, &error) == false) {\r
- EM_DEBUG_EXCEPTION("email_service_launch failed");\r
- if (error != NULL) {\r
- EM_DEBUG_EXCEPTION("message : [%s]", error->message);\r
- g_error_free(error);\r
- return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
- }\r
- }\r
- EM_DEBUG_LOG("org_tizen_email_service_launch");\r
-\r
- g_object_unref (proxy);\r
- }\r
- else {\r
- EM_DEBUG_EXCEPTION("dbus_g_proxy_new_for_name failed");\r
+ if (!connection) {\r
+ if (error) {\r
+ EM_DEBUG_EXCEPTION("Unable to connect to dbus: %s", error->message);\r
+ g_error_free(error);\r
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
+ return err;\r
}\r
}\r
- else {\r
- EM_DEBUG_EXCEPTION("ERROR: Can't get on system bus [%s]", error->message);\r
- g_error_free(error);\r
+\r
+ proxy = dbus_g_proxy_new_for_name(connection, EMAIL_SERVICE_NAME, EMAIL_SERVICE_PATH, EMAIL_SERVICE_NAME);\r
+ if (!proxy) {\r
+ EM_DEBUG_EXCEPTION("dbus_g_proxy_new_for_name failed");\r
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
+ return err;\r
+ }\r
+\r
+ //will trigger activation if the service does not exist\r
+ if (org_tizen_email_service_launch(proxy, &dbus_result, &error) == false) {\r
+ if (error) {\r
+ EM_DEBUG_EXCEPTION("email_service_launch failed : [%s]", error->message);\r
+ g_error_free(error);\r
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
+ return err;\r
+ }\r
}\r
\r
+ EM_DEBUG_LOG("org_tizen_email_service_launch : [%d]", dbus_result);\r
+\r
+ g_object_unref(proxy);\r
EM_DEBUG_FUNC_END("ret [%d]", err);\r
return err;\r
}\r
\r
-\r
EXPORT_API int emipc_init_dbus_connection()\r
{\r
EM_DEBUG_FUNC_BEGIN();\r
- int err = EMAIL_ERROR_NONE;\r
\r
- GError *error = NULL;\r
+ EmailService *object;\r
DBusGProxy *proxy = NULL;\r
- guint ret = 0;\r
+ DBusGConnection *connection = NULL;\r
+ GError *error = NULL;\r
+\r
+ guint request_ret = 0;\r
+ int err = EMAIL_ERROR_NONE;\r
\r
g_type_init();\r
\r
+ //init dbus connection\r
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);\r
- if (error == NULL) {\r
- object = (GObject *)g_object_new(EMAIL_SERVICE_TYPE, NULL);\r
- dbus_g_connection_register_g_object(connection, EMAIL_SERVICE_PATH, object);\r
-\r
- // register service\r
- proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);\r
- if (proxy != NULL) {\r
- if (!org_freedesktop_DBus_request_name(proxy, EMAIL_SERVICE_NAME, 0, &ret, &error)) {\r
- EM_DEBUG_EXCEPTION("Unable to register service: %s", error->message);\r
- g_error_free(error);\r
- }\r
-\r
- g_object_unref (proxy);\r
- }\r
- else {\r
- EM_DEBUG_EXCEPTION("dbus_g_proxy_new_for_name failed");\r
+ if (!connection) {\r
+ if (error) {\r
+ EM_DEBUG_EXCEPTION("Unable to connect to dbus: %s", error->message);\r
+ g_error_free(error);\r
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
+ return err;\r
}\r
}\r
- else {\r
- EM_DEBUG_EXCEPTION("ERROR: Can't get on system bus [%s]", error->message);\r
- g_error_free(error);\r
+\r
+ //create email_service object\r
+ object = g_object_new(EMAIL_SERVICE_TYPE, NULL);\r
+\r
+ //register dbus path\r
+ dbus_g_connection_register_g_object(connection, EMAIL_SERVICE_PATH, G_OBJECT(object));\r
+\r
+ //register the service name\r
+ proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);\r
+ if (!proxy) {\r
+ EM_DEBUG_EXCEPTION("dbus_g_proxy_new_for_name failed");\r
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
+ return err;\r
+ }\r
+\r
+ if (!org_freedesktop_DBus_request_name(proxy, EMAIL_SERVICE_NAME, 0, &request_ret, &error)) {\r
+ if (error) {\r
+ EM_DEBUG_EXCEPTION("Unable to register service: %s", error->message);\r
+ g_error_free(error);\r
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;\r
+ }\r
}\r
+\r
+ g_object_unref(proxy);\r
+\r
EM_DEBUG_FUNC_END("err [%d]", err);\r
return err;\r
}\r
gboolean email_service_launch(EmailService *email_service, guint *result_val, GError **error)\r
{\r
EM_DEBUG_LOG("email_service_launch entered");\r
-\r
- EM_DEBUG_LOG("email_service_launch PID=[%ld]\n" , getpid());\r
+ EM_DEBUG_LOG("email_service_launch PID=[%ld]" , getpid());\r
EM_DEBUG_LOG("email_service_launch TID=[%ld]" , pthread_self());\r
\r
- launch_by_client = getpid();\r
+ if (result_val)\r
+ *result_val = TRUE;\r
\r
return TRUE;\r
}\r
*\r
*/\r
\r
-\r
#ifndef __EMAIL_DBUS_ACTIVATION_H__\r
#define __EMAIL_DBUS_ACTIVATION_H__\r
\r
typedef struct _email_service_t EmailService;\r
typedef struct _email_service_class_t EmailServiceClass;\r
\r
-\r
#define EMAIL_SERVICE_NAME "org.tizen.email_service"\r
#define EMAIL_SERVICE_PATH "/org/tizen/email_service"\r
\r
GType email_service_get_type(void);\r
\r
-struct _email_service_t\r
-{\r
+struct _email_service_t {\r
GObject parent;\r
int status;\r
};\r
\r
-struct _email_service_class_t\r
-{\r
+struct _email_service_class_t {\r
GObjectClass parent;\r
};\r
\r
#define IS_EMAIL_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMAIL_SERVICE_TYPE))\r
#define EMAIL_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMAIL_SERVICE_TYPE, EmailServiceClass))\r
\r
-typedef enum\r
-{\r
+typedef enum {\r
NFC_SERVICE_ERROR_INVALID_PRAM\r
} email_servcie_error;\r
\r
-GQuark email_service_error_quark(void);\r
-#define EMAIL_SERVICE_ERROR email_service_error_quark()\r
-\r
/**\r
* launch the email-service\r
*/\r
-gboolean email_service_launch(EmailService *email_service, guint *result_val, GError **error);\r
\r
+gboolean email_service_launch(EmailService *email_service, guint *result_val, GError **error);\r
EXPORT_API int emipc_init_dbus_connection();\r
EXPORT_API int emipc_launch_email_service();\r
\r