calendar: Remove ICU dependency ICU module will load from efl-modules. 44/120344/3
authorWoochan Lee <wc0917.lee@samsung.com>
Wed, 22 Mar 2017 10:12:55 +0000 (19:12 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 24 Mar 2017 10:37:56 +0000 (03:37 -0700)
Change-Id: I0c93c2828b88dba26effb46487f73e0149fcef60

configure.ac
packaging/elementary.spec
src/lib/elm_calendar.c
src/lib/elm_widget_calendar.h

index b44e61c13a0db9204f912578f1d819013d2c07bd..1f87e57ff64289798d6c5f3cc7bca31dc0d34463 100644 (file)
@@ -211,11 +211,6 @@ case "$host_os" in
    mingw*)
       requirement_elm_pc="evil >= efl_version"
       ;;
-#TIZEN_ONLY(20160425): Mobile Ux needs icu.
-   *)
-      requirement_elm_pc="icu-i18n >= 4.8"
-      ;;
-#
 esac
 
 requirement_elm_pc_only="\
index c66fe24a444df40efc23e3bd0c8cd5dc93fed914..7958d68e953f5f5cd386ccc7380cc40b6516f2a9 100644 (file)
@@ -51,10 +51,6 @@ BuildRequires:  eolian-devel
 BuildRequires:  python-devel
 BuildRequires:  pkgconfig(ttrace)
 
-#TINEN ONLY(20160425) : Support Mobile target language.
-BuildRequires:  pkgconfig(icu-i18n)
-#
-
 Recommends:     %{name}-locale = %{version}
 
 Provides:       %{name}-profile_common = %{version}-%{release}
index 994d58316998c4e7129bf186085ca230b64d6c11..96a5fb5da3d584ac91f9caeb71094a3d80cc277d 100644 (file)
@@ -8,12 +8,6 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 #include "elm_widget_calendar.h"
-//TIZEN_ONLY(20160425): Using icu lib to support languages which not support
-//                      in strftime().
-#include <unicode/udat.h>
-#include <unicode/ustring.h>
-#include <unicode/udatpg.h>
-//
 
 #define MY_CLASS ELM_CALENDAR_CLASS
 
@@ -36,6 +30,11 @@ static const char MONTH_ACCESS_PART[] = "month_text.access";
 static const char SIG_ATSPI_SCREEN_READER_CHANGED[] = "atspi,screen,reader,changed";
 //
 
+//TIZEN_ONLY(20170322): Using icu lib to support languages which not support
+//                      in strftime().
+static Calendar_Mod_Api *cal_mod = NULL;
+//
+
 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {SIG_CHANGED, ""},
    {SIG_DISPLAY_CHANGED, ""},
@@ -95,133 +94,36 @@ _button_widget_year_dec_start(void *data,
                               Evas_Object *obj EINA_UNUSED,
                               void *event_info EINA_UNUSED);
 
-//TIZEN_ONLY(20160425): Using icu lib to support languages which not support
+//TIZEN_ONLY(20170322): Using icu lib to support languages which not support
 //                      in strftime().
-static char *
-_current_region_date_string_get(const char *format, struct tm *tm)
+static Calendar_Mod_Api *
+_cal_mod_init()
 {
-#ifndef HAVE_ELEMENTARY_WIN32
-#ifndef HAVE_ELEMENTARY_COCOA
-#ifdef ENABLE_NLS
-   char *p, *locale;
-   char buf[128] = {0, };
-   UDateFormat *dt_formatter = NULL;
-   UErrorCode status = U_ZERO_ERROR;
-   UChar pattern[128] = {0, };
-   UChar str[128] = {0, };
-   UChar weekday[128] = {0, };
-   UChar ufield[128] = {0, };
-   UChar custom_skeleton[128] = {0, };
-   UDate date;
-   UDateTimePatternGenerator *pattern_generator;
-   UCalendar *calendar = NULL;
-   char *skeleton = "MMMM y";
-   int32_t pos = 0;
-
-   //Current locale get form evn.
-   locale = getenv("LC_TIME");
-   if (!locale)
-     {
-        locale = setlocale(LC_TIME, NULL);
-        if (!locale) return NULL;
-     }
-
-   //Separate up with useless string in locale.
-   p = strstr(locale, ".UTF-8");
-   if (p) *p = 0;
-
-   //Get the pattern from format or get a best pattern to use icu.
-   if (!strcmp(format, "%a"))
-     u_uastrcpy(pattern, "EE");
-   else
-   {
-      pattern_generator = udatpg_open(locale, &status);
-
-      u_uastrcpy(custom_skeleton, skeleton);
-      int32_t best_pattern_capacity = (int32_t)(sizeof(pattern) /
-                                      sizeof((pattern)[0]));
-
-      udatpg_getBestPattern(pattern_generator, custom_skeleton,
-                            u_strlen(custom_skeleton), pattern,
-                            best_pattern_capacity, &status);
-   }
-
-   //Open a new UDateFormat for formatting and parsing date.
-   dt_formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale,
-                            NULL, -1, pattern, -1, &status);
-   if (!dt_formatter)
-     return NULL;
-
-   if (!strcmp(format, "%a"))
-     {
-        udat_getSymbols(dt_formatter, UDAT_SHORT_WEEKDAYS, (tm->tm_mday - 3),
-                        weekday, sizeof(weekday), &status);
-        u_austrcpy(buf, weekday);
-        udat_close(dt_formatter);
-
-        return strdup(buf);
-     }
-   else
-     {
-        if (pattern[0] == 'M')
-          {
-             snprintf(buf, sizeof(buf), "%d %d", tm->tm_mon + 1, tm->tm_year + 1900);
-             u_uastrcpy(ufield, buf);
-          }
-        else
-          {
-             snprintf(buf, sizeof(buf), "%d %d", tm->tm_year + 1900, tm->tm_mon + 1);
-             u_uastrcpy(ufield, buf);
-          }
-     }
+   Elm_Module *mod = NULL;
 
-   //Open a UCalendar.
-   //A UCalendar may be used to convert a millisecond value to a year, month, and day.
-   calendar = ucal_open(NULL, -1, locale, UCAL_GREGORIAN, &status);
-   if (!calendar)
-     {
-        udat_close(dt_formatter);
-        return NULL;
-     }
-   ucal_clear(calendar);
+   if (!(mod = _elm_module_find_as("calendar/api"))) return NULL;
 
-   //Parse a string into an date/time using a UDateFormat.
-   udat_parseCalendar(dt_formatter, calendar, ufield, (sizeof(ufield) / sizeof(UChar)), &pos, &status);
-   date = ucal_getMillis(calendar, &status);
-   ucal_close(calendar);
+   mod->api = malloc(sizeof(Calendar_Mod_Api));
+   if (!mod->api) return NULL;
 
-   udat_format(dt_formatter, date, str, sizeof(str), NULL, &status);
-   u_austrcpy(buf, str);
-   udat_close(dt_formatter);
+   ((Calendar_Mod_Api *)(mod->api))->string_get =
+     _elm_module_symbol_get(mod, "string_get");
 
-   return strdup(buf);
-#else
-   return NULL;
-#endif
-#else
-   return NULL;
-#endif
-#else
-   return NULL;
-#endif
+   return mod->api;
 }
-//
 
-/* This two functions should be moved in Eina for next release. */
 static Eina_Tmpstr *
-//TIZEN_ONLY(20160425): Using icu lib to support languages which not support
-//                      in strftime().
 _eina_tmpstr_strftime(const char *format, struct tm *tm)
-//_eina_tmpstr_strftime(const char *format, const struct tm *tm)
-//
 {
    const size_t flen = strlen(format);
    size_t buflen = 16; // An arbitrary starting size
    char *buf = NULL;
 
-   //TIZEN_ONLY(20160425): Using icu lib to support languages which not support
-   //                      in strftime().
-   buf = _current_region_date_string_get(format, tm);
+#ifndef HAVE_ELEMENTARY_WIN32
+#ifndef HAVE_ELEMENTARY_COCOA
+#ifdef ENABLE_NLS
+   if (cal_mod && cal_mod->string_get)
+     buf = cal_mod->string_get(format, tm);
 
    if (buf)
      {
@@ -234,7 +136,9 @@ _eina_tmpstr_strftime(const char *format, struct tm *tm)
         free(buf);
         return r;
      }
-   //
+#endif
+#endif
+#endif
 
    do {
       char *tmp;
@@ -271,6 +175,7 @@ _eina_tmpstr_steal(Eina_Tmpstr *s)
    eina_tmpstr_del(s);
    return r;
 }
+//
 
 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
 //TIZEN_ONLY(20161123): Support Focused UI.
@@ -2047,6 +1952,11 @@ _elm_calendar_evas_object_smart_add(Eo *obj, Elm_Calendar_Data *priv)
       (wd->resize_obj, "load", "*",
        _style_changed, obj);
 
+   //TIZEN_ONLY(20170322): Using icu lib to support languages which not support
+   //                      in strftime().
+   if (!cal_mod) cal_mod = _cal_mod_init();
+   //
+
    for (i = 0; i < ELM_DAY_LAST; i++)
      {
         struct tm *info;
index 45a3d1e14e66daf06278fa36e6e4fd5c55448429..e49561b310a3bdb3633f32b4a02b8143afcc6eaa 100644 (file)
  */
 typedef struct _Elm_Calendar_Data Elm_Calendar_Data;
 
+//TIZEN_ONLY(20170322): Using icu lib to support languages which not support
+//                      in strftime().
+typedef struct _Calendar_Mod_Api  Calendar_Mod_Api;
+//
+
 typedef enum _Day_Color // EINA_DEPRECATED
 {
    DAY_WEEKDAY = 0,
@@ -67,6 +72,14 @@ struct _Elm_Calendar_Data
    Eina_Bool                year_repeated : 1;
 };
 
+//TIZEN_ONLY(20170322): Using icu lib to support languages which not support
+//                      in strftime().
+struct _Calendar_Mod_Api
+{
+   char                    *(*string_get)(const char *format, struct tm *tm);
+};
+//
+
 struct _Elm_Calendar_Mark
 {
    Evas_Object                  *obj;