Fix collation error 81/223381/1 accepted/tizen/unified/20200130.214657 submit/tizen/20200130.003651
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 29 Jan 2020 07:11:19 +0000 (16:11 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 29 Jan 2020 07:11:19 +0000 (16:11 +0900)
Cannot find symbol in linked library.
So, use icu API directly instead dlcall.

Change-Id: I3248794bec7cfd07097c40325e344842b9e9d3a2
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
lib/media-util-db.c

index b7025ae..59f1307 100755 (executable)
 
 #define BATCH_START "BEGIN"
 #define BATCH_END "COMMIT"
-#define PATH_PLUGIN_LIBICU                             PATH_LIBDIR"/libicui18n.so"
-
-static UCollator *(*icu_ucol_open)(const char *, UErrorCode *);
-static void (*icu_ucol_close)(UCollator *);
-static void (*icu_ucol_setStrength)(UCollator *, UCollationStrength);
-static UCollationResult (*icu_ucol_strcollIter)(const UCollator *, UCharIterator *, UCharIterator *, UErrorCode *);
-static void (*icu_uiter_setUTF8)(UCharIterator *, const char *, int32_t);
-static void (*icu_uloc_setDefault)(const char* localeID, UErrorCode* status);
-static const char* (*icu_uloc_getDefault)(void);
-
-static void *funcHandle = NULL;
 
 static int __media_db_request_recovery(uid_t uid);
 
@@ -68,13 +57,10 @@ static int __media_db_collate_icu_8(void *ucol, int str1_len, const void *str1,
        UCharIterator uiter1, uiter2;
        UErrorCode error = U_ZERO_ERROR;
 
-       icu_ucol_strcollIter = dlsym(funcHandle, "ucol_strcollIter");
-       icu_uiter_setUTF8 = dlsym(funcHandle, "uiter_setUTF8");
+       uiter_setUTF8(&uiter1, (const char *) str1, str1_len);
+       uiter_setUTF8(&uiter2, (const char *) str2, str2_len);
 
-       icu_uiter_setUTF8(&uiter1, (const char *) str1, str1_len);
-       icu_uiter_setUTF8(&uiter2, (const char *) str2, str2_len);
-
-       UCollationResult result = icu_ucol_strcollIter((UCollator *) ucol, &uiter1, &uiter2, &error);
+       UCollationResult result = ucol_strcollIter((UCollator *) ucol, &uiter1, &uiter2, &error);
        if (U_FAILURE(error)) {
                MSAPI_DBG_ERR("ucol_strcollIter error: %d", error);
                return -1;
@@ -97,61 +83,43 @@ static void __media_db_collation_cb(void* pArg, sqlite3* handle, int charset, co
        }
 
        if (charset == SQLITE_UTF8 && !sqlite3_stricmp(name, "localized")) {
-               funcHandle = dlopen(PATH_PLUGIN_LIBICU, RTLD_LAZY);
-               if (funcHandle == NULL) {
-                       MSAPI_DBG_ERR("dlopen failed");
-                       return;
-               }
-
-               icu_ucol_open = dlsym(funcHandle, "ucol_open");
-               icu_ucol_close = dlsym(funcHandle, "ucol_close");
-               icu_ucol_setStrength = dlsym(funcHandle, "ucol_setStrength");
-               icu_uloc_setDefault = dlsym(funcHandle, "uloc_setDefault");
-               icu_uloc_getDefault = dlsym(funcHandle, "uloc_getDefault");
-
                lang = vconf_get_str(VCONFKEY_LANGSET);
                /* get current locale */
                if (lang) {
-                       icu_uloc_setDefault(lang, &status);
+                       uloc_setDefault(lang, &status);
                        MS_SAFE_FREE(lang);
                } else {
                        MSAPI_DBG_ERR("Fail to get current language vconf");
-                       dlclose(funcHandle);
                        return;
                }
-               locale = icu_uloc_getDefault();
+               locale = uloc_getDefault();
                if (locale == NULL) {
                        MSAPI_DBG_ERR("Fail to get current locale");
-                       dlclose(funcHandle);
                        return;
                }
                MSAPI_DBG_INFO("locale : %s", locale);
 
-               ucol = icu_ucol_open(locale, &status);
+               ucol = ucol_open(locale, &status);
                if (status == U_USING_DEFAULT_WARNING) {
                        MSAPI_DBG("ucol_open success with default collate option");
                } else if (U_FAILURE(status)) {
                        MSAPI_DBG_ERR("ucol_open fail : %d", status);
-                       dlclose(funcHandle);
                        return;
                }
 
-               icu_ucol_setStrength(ucol, UCOL_SECONDARY); /* NOTICE : MCD sets UCOL_PRIMARY */
+               ucol_setStrength(ucol, UCOL_SECONDARY); /* NOTICE : MCD sets UCOL_PRIMARY */
                if (U_FAILURE(status)) {
                        MSAPI_DBG_ERR("ucol_setStrength fail : %d", status);
-                       dlclose(funcHandle);
                        return;
                }
 
-               ret = sqlite3_create_collation_v2(handle, name, SQLITE_UTF8, ucol, __media_db_collate_icu_8, (void *)icu_ucol_close);
+               ret = sqlite3_create_collation_v2(handle, name, SQLITE_UTF8, ucol, __media_db_collate_icu_8, (void *)ucol_close);
                if (ret != SQLITE_OK) {
                        MSAPI_DBG_ERR("sqlite3_create_collation_v2 fail : %d", ret);
-                       icu_ucol_close(ucol);
+                       ucol_close(ucol);
                } else {
                        MSAPI_DBG("sqlite3_create_collation_v2 success");
                }
-
-               dlclose(funcHandle);
        } else {
                MSAPI_DBG_ERR("No matching collator for %s", name);
        }