diff options
Diffstat (limited to 'lib/details/ct-detail-view.c')
-rwxr-xr-x | lib/details/ct-detail-view.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/lib/details/ct-detail-view.c b/lib/details/ct-detail-view.c index 1827914..683f86e 100755 --- a/lib/details/ct-detail-view.c +++ b/lib/details/ct-detail-view.c @@ -29,7 +29,6 @@ #include <vconf.h> #include <vconf-keys.h> #include <unicode/udatpg.h> -#include <unicode/udat.h> #include <unicode/ucal.h> #include <unicode/ustring.h> #include "contacts.h" @@ -120,55 +119,27 @@ static char *detail_gl_address_label_get(void *data, Evas_Object *obj, const cha return NULL; } -static char* detail_get_datetime_str(int year, int mon, int day) +static char* detail_get_datetime_str(UDateFormat* formatter, int year, int mon, int day) { - char *locale; - char *ret_str; + time_t timer; + struct tm stime; + char *ret_str = NULL; char formatted_str[CT_TEXT_SHORT_LEN]; - int32_t pattern_capacity; int32_t formattedCapacity; - UCalendar *cal; - UChar *tzId; - UChar pattern[CT_TEXT_SHORT_LEN]; UChar formatted[CT_TEXT_SHORT_LEN]; - UChar customSkeleton[CT_TEXT_SHORT_LEN]; - UDate date; - UDateFormat *formatter = NULL; - UDateTimePatternGenerator generator; UErrorCode status = U_ZERO_ERROR; - u_uastrncpy(customSkeleton, UDAT_YEAR_MONTH_DAY, strlen(UDAT_YEAR_MONTH_DAY)); - - locale = vconf_get_str(VCONFKEY_REGIONFORMAT); - c_retvm_if(NULL == locale, NULL, "vconf_get_str() return NULL"); - - generator = udatpg_open(locale, &status); - c_retvm_if(U_FAILURE(status), NULL, "udatpg_open() Failed()"); + memset(&stime, 0, sizeof(struct tm)); + stime.tm_year = year-1900; + stime.tm_mon = mon-1; + stime.tm_mday = day; + timer=mktime(&stime); - pattern_capacity = (int32_t) (sizeof(pattern) / sizeof((pattern)[0])); - udatpg_getBestPattern(generator, customSkeleton, 6, pattern, pattern_capacity, &status); - c_retvm_if(U_FAILURE(status), NULL, "udatpg_getBestPattern() Failed()"); - - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, NULL, -1, pattern, -1, &status); - c_retvm_if(U_FAILURE(status), NULL, "udat_open() Failed()"); - - formattedCapacity = (int32_t) (sizeof(formatted) / sizeof((formatted)[0])); - - tzId = (UChar*)malloc(sizeof(UChar) * (strlen("PST")+1) ); - c_retvm_if(NULL == tzId, NULL, "malloc() return NULL"); - u_uastrcpy(tzId, "PST"); - cal = ucal_open(tzId, u_strlen(tzId), NULL, UCAL_TRADITIONAL, &status); - free(tzId); - - ucal_setDate(cal, year, mon, day, &status); - c_retvm_if(U_FAILURE(status), NULL, "ucal_setDate() Failed()"); - date = ucal_getMillis(cal, &status); - - udat_format(formatter, date, formatted, formattedCapacity, NULL, &status); + formattedCapacity = (int32_t)(sizeof(formatted)/sizeof((formatted)[0])); + udat_format(formatter, (UDate)timer*1000, formatted, formattedCapacity, NULL, &status); c_retvm_if(U_FAILURE(status), NULL, "udat_format() Failed()"); u_austrcpy(formatted_str, formatted); - udat_close(formatter); ret_str = g_strdup(formatted_str); return ret_str; @@ -179,6 +150,7 @@ static char* detail_gl_title_big_text_label_get(void *data, Evas_Object *obj, co int type; const char *ret_str; CTSvalue *value = data; + ct_detail_data *cdetail_d = evas_object_data_get(obj, "cdetail_d"); c_retvm_if(NULL == value, NULL, "parameter(CTSvalue) is NULL"); @@ -199,7 +171,7 @@ static char* detail_gl_title_big_text_label_get(void *data, Evas_Object *obj, co year = date/10000; c_retvm_if(mon < 1 || 12 < mon || day < 1 || 31 < day, NULL, "Invalid date(mon=%d,day=%d)",mon,day); - return detail_get_datetime_str(year, mon - 1, day - 1); + return detail_get_datetime_str(cdetail_d->formatter, year, mon, day); case CTS_VALUE_MESSENGER: ret_str = contacts_svc_value_get_str(value, CTS_MESSENGER_VAL_IM_ID_STR); @@ -361,7 +333,6 @@ static void detail_number_cb(CTSvalue *value, ct_detail_data *cdetail_d) detail_voice_call_cb, num); item = elm_ctxpopup_item_append(cdetail_d->popup, S_(CT_SYS_BODY_MESSAGE), NULL, detail_msg_ug_cb, num); - elm_object_item_disabled_set(item, EINA_TRUE); evas_object_move(cdetail_d->popup, cdetail_d->touch_x, cdetail_d->touch_y); evas_object_show(cdetail_d->popup); @@ -589,9 +560,6 @@ static Evas_Object *detail_gl_number_util_icon_get(void *data, Evas_Object *obj, btn = ctui_create_btn(obj, label); c_retvm_if(NULL == btn, NULL, "ctui_create_btn() return NULL"); - if (0 == strcmp(part, "elm.icon.2")) - elm_object_disabled_set(btn, EINA_TRUE); - evas_object_data_set(btn, "cdetail_d", cdetail_d); evas_object_smart_callback_add(btn, "clicked", clicked_fn, number); @@ -744,6 +712,10 @@ static void detail_view_delete_cb(void *data, Evas *e, Evas_Object *obj, evas_object_data_del(cdetail_d->navi, "cdetail_d"); + if (cdetail_d->formatter) + udat_close(cdetail_d->formatter); + cdetail_d->formatter = NULL; + if (cdetail_d->has_input) cdetail_d->has_detail = false; else @@ -935,6 +907,33 @@ API Evas_Object* ctui_detail_genlist_update(ct_detail_data *cdetail_d) return genlist; } +static UDateFormat* detail_init_time_formatter() +{ + const char *locale; + int32_t pattern_capacity; + UChar pattern[CT_TEXT_SHORT_LEN]; + UChar customSkeleton[CT_TEXT_SHORT_LEN]; + UDateFormat *formatter = NULL; + UDateTimePatternGenerator generator; + UErrorCode status = U_ZERO_ERROR; + + u_uastrncpy(customSkeleton, UDAT_YEAR_MONTH_DAY, strlen(UDAT_YEAR_MONTH_DAY)); + + locale = uloc_getDefault(); + c_retvm_if(NULL == locale, NULL, "uloc_getDefault() return NULL"); + + generator = udatpg_open(locale, &status); + c_retvm_if(U_FAILURE(status), NULL, "udatpg_open() Failed()"); + + pattern_capacity = (int32_t) (sizeof(pattern) / sizeof((pattern)[0])); + udatpg_getBestPattern(generator, customSkeleton, 6, pattern, pattern_capacity, &status); + + if (!U_FAILURE(status)) + formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, NULL, -1, pattern, -1, &status); + + udatpg_close(generator); + return formatter; +} Evas_Object* ct_detail_create_content(ct_detail_data *cdetail_d) { @@ -992,6 +991,7 @@ Evas_Object* ct_detail_create_content(ct_detail_data *cdetail_d) } detail_create_itcs(); + cdetail_d->formatter = detail_init_time_formatter(); genlist = ctui_detail_genlist_update(cdetail_d); evas_object_data_set(cdetail_d->navi, "cdetail_d", cdetail_d); |