merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:14:51 +0000 (01:14 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:14:51 +0000 (01:14 +0900)
email-core/email-core-mail.c
email-core/email-core-mailbox-sync.c
email-core/email-core-smtp.c
email-ipc/email-activation/email-dbus-activation.c
email-ipc/email-activation/email-service.service
email-ipc/email-activation/email-service.xml
email-ipc/email-activation/include/email-dbus-activation.h
packaging/email-service.spec

index 7106687..d755813 100755 (executable)
@@ -4769,8 +4769,15 @@ INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_m
        ret = true;
 
 FINISH_OFF:
+       if (ret == false) {
+               if (!emcore_notify_storage_event(NOTI_MAIL_MOVE_FAIL, account_id, noti_param_1, parameter_string, noti_param_2))
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_MAIL_MOVE_FAIL ] >>>> ");
+       }
+
        emstorage_free_mail(&mail_list, mail_ids_count, NULL);
+
        EM_SAFE_FREE(parameter_string);
+
        if (err_code != NULL)
                *err_code = err;
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -4865,8 +4872,11 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id,
                                        EM_DEBUG_LOG("Mail MOVE SUCCESS ");
                                }
                        }
-                       else
+                       else {
                                EM_DEBUG_EXCEPTION(">>>> Server MAIL ID IS NULL >>>> ");
+                               ret = 0;
+                               goto FINISH_OFF;
+                       }
                }
                else {
                        EM_DEBUG_EXCEPTION(">>>> STREAM DATA IS NULL >>> ");
index 57f7642..12f362c 100755 (executable)
@@ -2463,7 +2463,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
                goto FINISH_OFF;
        }
 
-       if (mailbox_tbl->local_yn == 0) {
+       if (mailbox_tbl->local_yn) {
                EM_DEBUG_EXCEPTION("The mailbox [%s] is not on server.", mail_table_data->mailbox_name);
                err = EMAIL_ERROR_INVALID_MAILBOX;
                goto FINISH_OFF;
@@ -3699,8 +3699,10 @@ static int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *stream, i
                attachment_num = 0;
                uidno = 0;
 
-               if ((err = emcore_parse_bodystructure(stream, reply_from_server, imap_response[i].header, &body, &cnt_info, &total_mail_size, &uidno)) != EMAIL_ERROR_NONE) {
+               err = emcore_parse_bodystructure(stream, reply_from_server, imap_response[i].header, &body, &cnt_info, &total_mail_size, &uidno);
+               if (err != EMAIL_ERROR_NONE || !body) {
                        EM_DEBUG_EXCEPTION("emcore_parse_bodystructure failed : [%d]", err);
+                       err = EMAIL_ERROR_ON_PARSING;
                        goto FINISH_OFF;
                }
 
index 96467e8..e8bca48 100755 (executable)
@@ -1279,9 +1279,7 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mai
                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))  {
@@ -1328,9 +1326,7 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mai
                        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))
@@ -1395,6 +1391,24 @@ INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mai
 #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;
 
index 1f3d6ca..b85a4db 100755 (executable)
 #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
@@ -79,87 +51,96 @@ EXPORT_API int emipc_launch_email_service()
        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
@@ -167,11 +148,11 @@ EXPORT_API int emipc_init_dbus_connection()
 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
index aac4dcb..de17fe1 100755 (executable)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.email_service
 Exec=/usr/bin/email-service
+User=root
\ No newline at end of file
index 0783757..013c463 100755 (executable)
@@ -3,7 +3,7 @@
        <interface name="org.tizen.email_service">
                <method name="Launch">
                        <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="email_service_launch"/>
-                       <arg type="u" name="result_val" direction="out"/>
+                       <arg type="u" name="result_val" direction="out" />
                </method>
        </interface>
 </node>
index 1341694..7592427 100755 (executable)
@@ -19,7 +19,6 @@
 *\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
@@ -53,19 +49,15 @@ struct _email_service_class_t
 #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
index 292bdd6..3585fc6 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       email-service
 Summary:    E-mail Framework Middleware package
-Version:    0.10.85
+Version:    0.10.89
 Release:    1
 Group:      System/Libraries
 License:    TBD