From: Sungbok Park Date: Thu, 8 Nov 2012 20:39:43 +0000 (+0900) Subject: merge viewer codes X-Git-Tag: 2.1b_release~3^2~99 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4668a29c538d0d89200f2aace90923f97539e13;p=apps%2Fhome%2Femail.git merge viewer codes --- diff --git a/common/include/email-common-types.h b/common/include/email-common-types.h index aaa6632..b2f6a3f 100755 --- a/common/include/email-common-types.h +++ b/common/include/email-common-types.h @@ -84,8 +84,6 @@ #define EMAIL_BUNDLE_VAL_END_KEY "END_KEY_EVENT" #define EMAIL_BUNDLE_VAL_NEXT_MSG "NEXT_MSG" #define EMAIL_BUNDLE_VAL_PREV_MSG "PREV_MSG" -#define EMAIL_BUNDLE_VAL_UNREAD "UNREAD" -#define EMAIL_BUNDLE_VAL_READ "READ" #define EMAIL_BUNDLE_VAL_VIEW_SETTING_MAIN "main-view" #define EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP "first-setup" diff --git a/common/src/email-engine.c b/common/src/email-engine.c index 9177496..cabd555 100755 --- a/common/src/email-engine.c +++ b/common/src/email-engine.c @@ -366,7 +366,7 @@ void email_engine_stop_working(gint account_id, int handle) debug_log(""); RETURN_IF_FAIL(account_id > ACCOUNT_MIN); - RETURN_IF_FAIL(handle > 0); + RETURN_IF_FAIL(handle != 0); int err = 0; diff --git a/common/src/email-utils.c b/common/src/email-utils.c index 40f6d19..a130cd9 100755 --- a/common/src/email-utils.c +++ b/common/src/email-utils.c @@ -733,20 +733,20 @@ int email_attachments_save_file(const gchar *path, gchar *newpath, gboolean(*cop debug_log(""); RETURN_VAL_IF_FAIL(STR_VALID(path), EMAIL_EXT_SAVE_ERR_UNKNOWN); - gchar new_path[MAX_DEFAULT_DIR_PATH] = { 0, }; - gchar tmp_path[MAX_DEFAULT_DIR_PATH] = { 0, }; - gchar new_filename[MAX_DEFAULT_DIR_PATH] = { 0, }; - gchar prefix[MAX_DEFAULT_DIR_PATH] = { 0, }; + gchar new_path[MAX_PATH_LEN] = { 0, }; + gchar tmp_path[MAX_PATH_LEN] = { 0, }; + gchar new_filename[MAX_PATH_LEN] = { 0, }; + gchar prefix[MAX_PATH_LEN] = { 0, }; gboolean saved = FALSE; gint err = 0; - gint max_length = MAX_DEFAULT_DIR_PATH; + gint max_length = MAX_PATH_LEN; snprintf(prefix, sizeof(prefix), "%s", DIR_DEFAULT_MEDIA_PHONE"/Downloads"); debug_log("prefix:%s", prefix); - memset(new_path, 0, sizeof(MAX_DEFAULT_DIR_PATH)); - memset(tmp_path, 0, sizeof(MAX_DEFAULT_DIR_PATH)); + memset(new_path, 0, sizeof(MAX_PATH_LEN)); + memset(tmp_path, 0, sizeof(MAX_PATH_LEN)); if (STR_LEN(tmp_path) == 0) { g_sprintf(tmp_path, "%s", path); @@ -816,7 +816,7 @@ int email_attachments_save_file(const gchar *path, gchar *newpath, gboolean(*cop err = EMAIL_EXT_SAVE_ERR_UNKNOWN; } - snprintf(newpath, MAX_STR_LEN, "%s", new_path); + snprintf(newpath, MAX_PATH_LEN, "%s", new_path); return err; } diff --git a/main/email.c b/main/email.c index 1312444..4eac120 100755 --- a/main/email.c +++ b/main/email.c @@ -276,7 +276,7 @@ static int _email_main_rotation_cb(app_device_orientation_e m, void *data) if (ad == NULL || ad->win_main == NULL) { return -1; } - debug_log("%d", m); + debug_log("app_device_orientation: %d", m); switch (m) { case APP_DEVICE_ORIENTATION_0: diff --git a/main/org.tizen.email.xml b/main/org.tizen.email.xml index cee3f7a..b622349 100755 --- a/main/org.tizen.email.xml +++ b/main/org.tizen.email.xml @@ -1,4 +1,5 @@ - + + Minsoo Kim Email Application diff --git a/packaging/org.tizen.email.spec b/packaging/org.tizen.email.spec index 6443635..f885f16 100755 --- a/packaging/org.tizen.email.spec +++ b/packaging/org.tizen.email.spec @@ -32,11 +32,12 @@ BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(contacts-service) BuildRequires: pkgconfig(ethumb) BuildRequires: pkgconfig(libmedia-utils) -BuildRequires: pkgconfig(calendar) +BuildRequires: pkgconfig(calendar-service2) BuildRequires: pkgconfig(drm-client) BuildRequires: pkgconfig(status) BuildRequires: pkgconfig(capi-media-metadata-extractor) BuildRequires: pkgconfig(capi-media-image-util) +BuildRequires: pkgconfig(libexif) BuildRequires: pkgconfig(libxml-2.0) diff --git a/viewer/CMakeLists.txt b/viewer/CMakeLists.txt index 175f92b..5de6a6e 100755 --- a/viewer/CMakeLists.txt +++ b/viewer/CMakeLists.txt @@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs-viewer REQUIRED appcore-efl ui-gadget-1 x11 elementary ecore glib-2.0 gobject-2.0 status capi-media-metadata-extractor capi-media-image-util - email-service edbus capi-appfw-application vconf ewebkit2 contacts-service sysman bundle dlog efreet-mime libmedia-utils calendar ethumb) + email-service edbus capi-appfw-application vconf ewebkit2 contacts-service sysman bundle dlog efreet-mime libmedia-utils calendar-service2 ethumb) FOREACH(flag ${pkgs-viewer_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -45,7 +45,6 @@ ADD_DEFINITIONS("-DDEBUG") ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") ADD_DEFINITIONS("-DDATAFS=\"$ENV{DATAFS}\"") ADD_DEFINITIONS("-D_POPUP_WITH_LIST") -ADD_DEFINITIONS("-D_NEW_CT_SVC_API") ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} email-common ${CMAKE_LDFLAGS} ${pkgs-viewer_LDFLAGS}) diff --git a/viewer/include/email-viewer.h b/viewer/include/email-viewer.h index df89f4d..df70863 100755 --- a/viewer/include/email-viewer.h +++ b/viewer/include/email-viewer.h @@ -47,7 +47,6 @@ #define VIEWER_PACKAGE "email-viewer" #define EV_THEME_PATH EDJDIR"/email-viewer-theme.edj" -#define PATH_VTCALL "/usr/bin/vtmain" #define _EDJ(o) elm_layout_edje_get(o) @@ -67,9 +66,9 @@ #define CONTACT_PHONE_CONTACT 0 #define CONTACTUI_REQ_CONTACT_DETAIL_INFO_VIEW 43 -#define EMAIL_VIEW_MAX_TO_COUNT 50 -#define EMAIL_VIEW_MAX_CC_COUNT 50 -#define EMAIL_VIEW_MAX_BCC_COUNT 50 +#define EMAIL_VIEW_MAX_TO_COUNT 500 +#define EMAIL_VIEW_MAX_CC_COUNT 500 +#define EMAIL_VIEW_MAX_BCC_COUNT 500 #define ICON_REPLY IMGDIR"/M02_controlbar_icon_reply.png" #define ICON_REPLY_ALL IMGDIR"/M02_controlbar_icon_reply.png" @@ -132,12 +131,7 @@ struct list_data { typedef struct _EMAIL_CONTACT_LIST_INFO_S { int index; -#ifndef _NEW_CT_SVC_API - char *first_name; - char *last_name; -#else char *display; -#endif char *email_address; char display_name[40]; } EMAIL_CONTACT_LIST_INFO_S; diff --git a/viewer/src/email-viewer-logic.c b/viewer/src/email-viewer-logic.c index 383510c..84eee84 100755 --- a/viewer/src/email-viewer-logic.c +++ b/viewer/src/email-viewer-logic.c @@ -152,6 +152,18 @@ static void _set_status(EmailViewerProp *prop, email_mail_data_t *mail_info) return; } +#if 0 + if (mail_info->flags_answered_field) { + prop->status |= EMAIL_STATUS_REPLY; + debug_log("status - set reply"); + } + + if (mail_info->flags_forwarded_field) { + prop->status |= EMAIL_STATUS_FORWARD; + debug_log("status - set forward"); + } +#endif + prop->status2 = mail_info->save_status; debug_log("status2 (%d)", prop->status2); } diff --git a/viewer/src/email-viewer-webview.c b/viewer/src/email-viewer-webview.c index 64735d9..a87a3e8 100755 --- a/viewer/src/email-viewer-webview.c +++ b/viewer/src/email-viewer-webview.c @@ -96,7 +96,7 @@ void viewer_set_webview_content(EmailViewerUGD *ug_data, int reload) return; } - char tmp_file_path[MAX_STR_LEN] = { 0, }; + char tmp_file_path[MAX_PATH_LEN] = { 0, }; char *tmp_file_name = NULL; /* set content */ @@ -106,9 +106,6 @@ void viewer_set_webview_content(EmailViewerUGD *ug_data, int reload) return; } - snprintf(tmp_file_path, sizeof(tmp_file_path), "file://%s", wvd->uri); - debug_log("file://%s", wvd->uri); - /* Fix for issue - Sometimes html content of previous mail is shown * Set the default html page if file size is 0 */ struct stat statbuf = { 0 }; @@ -121,6 +118,9 @@ void viewer_set_webview_content(EmailViewerUGD *ug_data, int reload) return; } } + + snprintf(tmp_file_path, sizeof(tmp_file_path), "file://%s", wvd->uri); + debug_log("file://%s", wvd->uri); } else if (wvd->body_type == BODY_TYPE_TEXT) { /* generate temporary html file for viewing */ tmp_file_name = viewer_set_html_content_file(wvd); diff --git a/viewer/src/email-viewer.c b/viewer/src/email-viewer.c index bf24015..2efb70d 100755 --- a/viewer/src/email-viewer.c +++ b/viewer/src/email-viewer.c @@ -19,11 +19,11 @@ #endif /* Header Include */ -#include -#include -#include #include #include +#include +#include +#include #include "email-viewer.h" #include "email-viewer-webview.h" @@ -122,6 +122,7 @@ static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_i static void _ctxpopup_cutlink_update_contact_cb(void *data, Evas_Object *obj, void *event_info); static void _ctxpopup_select_contact_mode_email_cb(void *data, Evas_Object *obj, void *event_info); static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *event_info); +static void _popup_waiting_response_cb(void *data, Evas_Object *obj, void *event_info); static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info); static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info); static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info); @@ -306,7 +307,8 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void * debug_log("mail_data is NULL"); } - ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name); + if (mail_data->server_mailbox_name) + ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name); ug_data->mailbox_type = mail_data->mailbox_type; debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name); debug_log("mailbox_name:%s", ug_data->mailbox_name); @@ -529,15 +531,16 @@ static void on_destroy(ui_gadget_h ug, service_h data, void *pd) ug_data->property = NULL; } - email_engine_finalize(); + ug_data->base = NULL; _dbus_receiver_remove(NULL); - int ret = e_dbus_shutdown(); debug_log("ret: %d", ret); - debug_log("~"); - ug_data->base = NULL; + email_engine_finalize(); + + + debug_log("~"); } static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv) @@ -613,7 +616,8 @@ static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv debug_log("mail_data is NULL"); } - ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name); + if (mail_data->server_mailbox_name) + ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name); ug_data->mailbox_type = mail_data->mailbox_type; debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name); debug_log("mailbox_name:%s", ug_data->mailbox_name); @@ -928,7 +932,7 @@ static void result_cb(ui_gadget_h ug, service_h result, void *priv) debug_log("service_get_extra_data: %d", ret); debug_log("return of bundle_get_val for save all(%s)", cmd); if (cmd) { - debug_log("save all from composer(%s)", cmd); + debug_log("save all from composer(%s), real_att_len(%d), att_len(%d)", cmd, prop->real_att_len, prop->att_len); if (prop->real_att_len == 1) { private->b_all_att_save = TRUE; @@ -1142,7 +1146,6 @@ static void _create_view(EmailViewerUGD *ug_data) elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE); if (ug_data->b_btn) { - debug_log("hiding back button"); evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb); @@ -1167,7 +1170,6 @@ static void _reset_view(EmailViewerUGD *ug_data) elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE); if (ug_data->b_btn) { - debug_log("hiding back button"); evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb); @@ -1288,6 +1290,8 @@ static void _reset_view(EmailViewerUGD *ug_data) if (!ug_data->to_list && !ug_data->cc_list && !ug_data->bcc_list) { edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm"); + } else { + edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, ug_data->ly_subject); } if (prop->has_attachment) @@ -1415,6 +1419,7 @@ void _hide_view(EmailViewerUGD *ug_data) } edje_object_signal_emit(_EDJ(ug_data->ly_subject), "elm,state,contracted", "elm"); + edje_object_signal_callback_del(_EDJ(ug_data->ly_subject), "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb); evas_object_hide(ug_data->noc_bx); evas_object_hide(ug_data->dn_btn); @@ -2558,9 +2563,12 @@ static void _create_more_ctxpopup(EmailViewerUGD *ug_data) email_free_rule(&rule_list, count); } - Evas_Coord x, y; + Evas_Coord x, y, w, h; evas_pointer_canvas_xy_get(ug_data->evas, &x, &y); - evas_object_move(ug_data->con_popup, x, y - 20); +// evas_object_move(ug_data->con_popup, x, y - 20); + evas_object_geometry_get(ug_data->ctr_bar, &x, &y, &w, &h); + debug_log("x:%d, y:%d, w:%d, h:%d, mx:%d", x, y, w, h, ((w - x) * 6) / 7); + evas_object_move(ug_data->con_popup, ((w - x) * 6) / 7 , y); evas_object_show(ug_data->con_popup); } @@ -3157,9 +3165,9 @@ static void _body_down_cb(void *data, Evas_Object *obj, void *event_info) int body_download_status = ug_data->property->body_download; if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE - debug_log("need body download"); + debug_log("only header downloaded -> need body download"); } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED - debug_log("already downloaded, create body directly"); + debug_log("already downloaded fully, create body directly"); /* set property */ if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) { @@ -3214,7 +3222,7 @@ static void _body_down_cb(void *data, Evas_Object *obj, void *event_info) return; } else if (body_download_status == 2) { //EMAILL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED - debug_log("need full body download"); + debug_log("body downloaded partially -> need full body download"); } ret = email_engine_body_download(priv->account_id, priv->mail_id, &handle); @@ -3309,25 +3317,6 @@ static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const cha elm_icon_resizable_set(favorite_icon, 1, 1); elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon); evas_object_show(favorite_icon); - - /* send unread request to mailbox. */ - int ret; - service_h service = NULL; - - ret = service_create(&service); - debug_log("service_create: %d", ret); - if (!service) { - debug_log("service create failed"); - return; - } - - ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_READ); - debug_log("service_add_extra_data: %d", ret); - - ug_send_message(_g_mailbox_ug, service); - - ret = service_destroy(service); - debug_log("service_destroy: %d", ret); } static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) @@ -3557,25 +3546,6 @@ static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info) char str[128] = { 0, }; snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_UNREAD")); _show_select_info(ug_data, str); - - /* send unread request to mailbox. */ - int ret; - service_h service = NULL; - - ret = service_create(&service); - debug_log("service_create: %d", ret); - if (!service) { - debug_log("service create failed"); - return; - } - - ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_UNREAD); - debug_log("service_add_extra_data: %d", ret); - - ug_send_message(_g_mailbox_ug, service); - - ret = service_destroy(service); - debug_log("service_destroy: %d", ret); } } @@ -3609,44 +3579,22 @@ static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info) char str[128] = { 0, }; snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_READ")); _show_select_info(ug_data, str); - - /* send unread request to mailbox. */ - int ret; - service_h service = NULL; - - ret = service_create(&service); - debug_log("service_create: %d", ret); - if (!service) { - debug_log("service create failed"); - return; - } - - ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_READ); - debug_log("service_add_extra_data: %d", ret); - - ug_send_message(_g_mailbox_ug, service); - - ret = service_destroy(service); - debug_log("service_destroy: %d", ret); } } static void _create_waiting_popup(EmailViewerUGD *ug_data, const char *title_text, const char *style) { debug_enter(); - Evas_Object *popup; - Evas_Object *progress; - if (title_text == NULL) { debug_log("popup text is null"); return; } - popup = elm_popup_add(ug_data->win_main); + Evas_Object *popup = elm_popup_add(ug_data->win_main); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_part_text_set(popup, "title,text", title_text); - progress = elm_progressbar_add(popup); + Evas_Object *progress = elm_progressbar_add(popup); elm_object_style_set(progress, style); elm_progressbar_pulse_set(progress, EINA_TRUE); elm_progressbar_pulse(progress, EINA_TRUE); @@ -3654,6 +3602,12 @@ static void _create_waiting_popup(EmailViewerUGD *ug_data, const char *title_tex elm_object_content_set(popup, progress); + Evas_Object *btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL")); + elm_object_part_content_set(popup, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", _popup_waiting_response_cb, ug_data); + ug_data->timeout_popup = popup; evas_object_show(popup); @@ -3674,6 +3628,10 @@ static void _save_email_cb(void *data, Evas_Object *obj, void *event_info) ug_data->con_popup = NULL; } + if (ug_data->timeout_popup) { + evas_object_del(ug_data->timeout_popup); + ug_data->timeout_popup = NULL; + } _create_waiting_popup(ug_data, dgettext("sys_string", "IDS_COM_POP_SAVING_ING"), "pending_list"); //"list_process" if (ug_data->waiting_timer) { @@ -3707,7 +3665,7 @@ static Eina_Bool _save_email_prog_cb(void *data) debug_log("email_get_attachment_data_list - err (%d)", err); char file_name[MAX_PATH_LEN] = { 0, }; - snprintf(file_name, sizeof(file_name), "%s_%d_%d.%s", DIR_DEFAULT_MEDIA_PHONE"/Downloads/Others/email", ug_data->account_id, ug_data->mail_id, "eml"); + snprintf(file_name, sizeof(file_name), "%s_%d_%d.%s", DIR_DEFAULT_MEDIA_PHONE"/Downloads/email", ug_data->account_id, ug_data->mail_id, "eml"); char *output_file_path = g_strdup(file_name); debug_log("output_file_path(%s)", file_name, output_file_path); @@ -4085,6 +4043,27 @@ static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *even email_free_rule(&rule, 1); } +static void _popup_waiting_response_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + if (!_g_ug_data) { + debug_log("_g_ug_data is NULL"); + return; + } + + if (!data) { + debug_log("data is NULL"); + return; + } + + EmailViewerUGD *ug_data = (EmailViewerUGD *)data; + + if (ug_data->timeout_popup) { + evas_object_del(ug_data->timeout_popup); + ug_data->timeout_popup = NULL; + } +} + static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); @@ -4778,7 +4757,7 @@ static void _save_attachment(EmailViewerUGD *ug_data, int index) debug_log(""); EmailViewerPrivate *priv = ug_data->email_data; EmailViewerProp *prop = ug_data->property; - char newpath[MAX_STR_LEN] = { 0, }; + char newpath[MAX_PATH_LEN] = { 0, }; RETURN_IF_FAIL(prop->attachments != NULL); EmailAttachmentType *info = g_list_nth_data(prop->attachments, index); @@ -4844,7 +4823,7 @@ static void _show_attachment(EmailViewerUGD *ug_data, int index) EmailViewerPrivate *priv = ug_data->email_data; EmailViewerProp *prop = ug_data->property; EmailAttachmentType *info = g_list_nth_data(prop->attachments, index); - char newpath[MAX_STR_LEN] = { 0, }; + char newpath[MAX_PATH_LEN] = { 0, }; if (info == NULL) { debug_log("EmailAttachmentType *info is NULL"); @@ -4889,17 +4868,55 @@ static void _show_attachment(EmailViewerUGD *ug_data, int index) debug_log("status_message_post failed: %d", ret); if (g_str_has_suffix(info->path, ".vcs")) { - int nResult = -1; - int calendar_id = 1; - calendar_svc_connect(); - nResult = calendar_svc_calendar_import(newpath, calendar_id); - - debug_log("check return value of calendar_svc_util_register_vcs_file for %s - %d", newpath, nResult); - if (nResult != CAL_SUCCESS) { - debug_log("Failed to import path(%s) to id(%d)", newpath, calendar_id); + calendar_connect(); + + FILE * fp = NULL; + fp = fopen(newpath, "r"); + if (!fp) { + debug_error("fopen(%s) is failed.", newpath); + calendar_disconnect(); + return; + } + + struct stat st; + if (stat(newpath, &st) == -1) { + debug_error("file(%s), stat Error(%d): %s", newpath, errno, strerror(errno)); + fclose(fp); + calendar_disconnect(); + return; + } + + int size = st.st_size; + char *raw_data = calloc(size + 1, sizeof(char)); + if (!raw_data) { + debug_error("calloc is failed."); + fclose(fp); + calendar_disconnect(); + return; + } + + size_t n = 0; + if ((n = fread(raw_data, 1, size, fp)) != size) { + debug_error("error in fread"); + g_free(raw_data); + fclose(fp); + calendar_disconnect(); return; } - calendar_svc_close(); + + fclose(fp); + + calendar_list_h list = NULL; + + ret = calendar_vcalendar_parse_to_calendar(raw_data, &list); + + if( list && ret == CALENDAR_ERROR_NONE) { + calendar_db_insert_records(list, NULL, NULL); + debug_log("vcalendar is registered to calendar"); + } + + g_free(raw_data); + calendar_disconnect(); } else media_file_register(newpath); } else if (res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST && !ug_data->display_download_result) { @@ -5424,15 +5441,8 @@ static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item) debug_log(""); if (contacts_list_item) { -#ifndef _NEW_CT_SVC_API - g_free(contacts_list_item->first_name); - contacts_list_item->first_name = NULL; - g_free(contacts_list_item->last_name); - contacts_list_item->last_name = NULL; -#else g_free(contacts_list_item->display); contacts_list_item->display = NULL; -#endif g_free(contacts_list_item->email_address); contacts_list_item->email_address = NULL; g_free(contacts_list_item); @@ -5472,39 +5482,10 @@ static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *searc int index = contacts_svc_value_get_int(row_info, CTS_LIST_EMAIL_CONTACT_ID_INT); contacts_list_item->index = index; -#ifndef _NEW_CT_SVC_API - contacts_list_item->first_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_FIRST_STR)); - contacts_list_item->last_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_LAST_STR)); -#else contacts_list_item->display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR)); -#endif contacts_list_item->email_address = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_ADDR_STR)); -#ifndef _NEW_CT_SVC_API - char *first = contacts_list_item->first_name; - char *last = contacts_list_item->last_name; - char *display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR)); - - if (!display) { - if (first != NULL && last != NULL) { - if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) { - display = g_strconcat(first, " ", last, NULL); - } else { - display = g_strconcat(last, " ", first, NULL); - } - } else if (first != NULL || last != NULL) { - display = (first != NULL) ? g_strdup(first) : g_strdup(last); - } else { - display = g_strdup(" "); - } - } - - snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", display); - g_free(display); -#else snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", contacts_list_item->display); -#endif - } contacts_svc_value_free(row_info);