Remove hard coded path and deprecated internal APIs 67/60767/1
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 2 Mar 2016 06:20:29 +0000 (15:20 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Wed, 2 Mar 2016 06:22:33 +0000 (15:22 +0900)
- notification_setting_db_set
- notification_setting_db_get
- notification_setting_property_set
- notification_setting_property_get

Change-Id: I1d03dd54dfab4e33f60c311e1485071ef7d79e47
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/notification_setting.c
test-app/CMakeLists.txt
test-app/main.c

index fcb07eb7027d7fb41a9592425e7d22ce3ff75e9f..a2d6fd10d92374f951e32b9c7c3e072692cdbdfd 100755 (executable)
@@ -774,310 +774,3 @@ return_close_db:
        return err;
 }
 
-/* OLD IMPLEMENTATION ----------------------------*/
-#define NOTIFICATION_SETTING_DB "notification_setting"
-#define NOTIFICATION_SETTING_DB_PATH "/opt/usr/dbspace/.notification_parser.db"
-
-struct _notification_setting_h {
-       char *appid;
-       char *notification;
-       char *sounds;
-       char *contents;
-       char *badge;
-       char *pkgid;
-};
-
-struct prop_table {
-       const char *property;
-       const char *column;
-       const char *default_value;
-};
-
-static struct prop_table g_prop_table[] = {
-       {
-               .property = "OPT_NOTIFICATION",
-               .column = "notification",
-               .default_value = "ON",
-       },
-       {
-               .property = "OPT_SOUNDS",
-               .column = "sounds",
-               .default_value = "ON",
-       },
-       {
-               .property = "OPT_CONTENTS",
-               .column = "contents",
-               .default_value = "ON",
-       },
-       {
-               .property = "OPT_BADGE",
-               .column = "badge",
-               .default_value = "ON",
-       },
-       {
-               .property = NULL,
-               .column = NULL,
-               .default_value = NULL,
-       }
-};
-
-static const char *_get_prop_column(const char *property)
-{
-       int i;
-
-       for (i = 0; g_prop_table[i].property; i++) {
-               if (strcmp(g_prop_table[i].property, property))
-                       continue;
-
-               return g_prop_table[i].column;
-       }
-
-       return NULL;
-}
-
-#ifdef TBD
-static const char *_get_prop_default_value(const char *property)
-{
-       int i;
-
-       for (i = 0; g_prop_table[i].property; i++) {
-               if (strcmp(g_prop_table[i].property, property))
-                       continue;
-
-               return g_prop_table[i].default_value;
-       }
-
-       return NULL;
-}
-#endif
-
-static int _is_record_exist(const char *pkgname, sqlite3 *db)
-{
-       sqlite3_stmt *stmt = NULL;
-       int count = 0;
-       int result = NOTIFICATION_ERROR_NONE;
-       char *sqlbuf = NULL;
-       int sqlret;
-
-       if (!pkgname)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!db)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       sqlbuf = sqlite3_mprintf("SELECT count(*) FROM %s WHERE " \
-                       "appid = %Q",
-                       NOTIFICATION_SETTING_DB, pkgname);
-
-       if (!sqlbuf) {
-               NOTIFICATION_ERR("fail to alloc sql query");
-               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-       }
-
-       sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
-       if (sqlret != SQLITE_OK) {
-               NOTIFICATION_ERR("DB err [%s]", sqlite3_errmsg(db));
-               NOTIFICATION_ERR("query[%s]", sqlbuf);
-               result = NOTIFICATION_ERROR_FROM_DB;
-               goto free_and_return;
-       }
-
-       sqlret = sqlite3_step(stmt);
-       if (sqlret == SQLITE_ROW)
-               count = sqlite3_column_int(stmt, 0);
-       else
-               count = 0;
-
-       if (count > 0)
-               result = NOTIFICATION_ERROR_ALREADY_EXIST_ID;
-       else
-               result = NOTIFICATION_ERROR_NOT_EXIST_ID;
-
-free_and_return:
-       if (sqlbuf)
-               sqlite3_free(sqlbuf);
-
-       if (stmt)
-               sqlite3_finalize(stmt);
-
-       return result;
-}
-
-EXPORT_API int notification_setting_db_set(const char *pkgname, const char *property, const char *value)
-{
-       int ret = NOTIFICATION_ERROR_NONE;
-       int result = NOTIFICATION_ERROR_NONE;
-       sqlite3 *db = NULL;
-       char *sqlbuf = NULL;
-       int sqlret;
-       const char *column = NULL;
-
-       if (!pkgname || strlen(pkgname) == 0)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!property || strlen(property) == 0)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!value || strlen(value) == 0)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       column = _get_prop_column(property);
-       if (!column)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       sqlret = db_util_open(NOTIFICATION_SETTING_DB_PATH, &db, 0);
-       if (sqlret != SQLITE_OK || !db) {
-               NOTIFICATION_ERR("fail to db_util_open - [%d]", sqlret);
-               return NOTIFICATION_ERROR_FROM_DB;
-       }
-
-       ret = _is_record_exist(pkgname, db);
-       if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
-               result = ret;
-               goto return_close_db;
-       }
-
-       sqlbuf = sqlite3_mprintf("UPDATE %s SET %s = %Q " \
-                       "WHERE appid = %Q",
-                       NOTIFICATION_SETTING_DB, column, value, pkgname);
-       if (!sqlbuf) {
-               NOTIFICATION_ERR("fail to alloc query");
-               result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               goto return_close_db;
-       }
-
-       result = notification_db_exec(db, sqlbuf, NULL);
-
-return_close_db:
-       if (sqlbuf)
-               sqlite3_free(sqlbuf);
-
-       sqlret = db_util_close(db);
-       if (sqlret != SQLITE_OK)
-               NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
-
-       return result;
-}
-
-EXPORT_API int notification_setting_db_get(const char *pkgname, const char *property, char **value)
-{
-       int ret = NOTIFICATION_ERROR_NONE;
-       int result = NOTIFICATION_ERROR_NONE;
-       sqlite3 *db = NULL;
-       char *sqlbuf = NULL;
-       sqlite3_stmt *stmt = NULL;
-       int sqlret;
-       const char *column = NULL;
-
-       if (!pkgname || strlen(pkgname) == 0)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!property || strlen(property) == 0)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!value)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       column = _get_prop_column(property);
-       if (!column)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       sqlret = db_util_open(NOTIFICATION_SETTING_DB_PATH, &db, 0);
-       if (sqlret != SQLITE_OK || !db) {
-               NOTIFICATION_ERR("fail to db_util_open - [%d]", sqlret);
-               return NOTIFICATION_ERROR_FROM_DB;
-       }
-
-       ret = _is_record_exist(pkgname, db);
-       if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
-               result = ret;
-               goto return_close_db;
-       }
-
-       sqlbuf = sqlite3_mprintf("SELECT %s FROM %s " \
-                       "WHERE appid = %Q",
-                       column, NOTIFICATION_SETTING_DB, pkgname);
-       if (!sqlbuf) {
-               NOTIFICATION_ERR("fail to alloc query");
-               result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               goto return_close_db;
-       }
-
-       sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
-       if (sqlret != SQLITE_OK) {
-               NOTIFICATION_ERR("fail to prepare %s - [%s]",
-                               sqlbuf, sqlite3_errmsg(db));
-               result = NOTIFICATION_ERROR_FROM_DB;
-               goto return_close_db;
-       }
-
-       sqlret = sqlite3_step(stmt);
-       if (sqlret == SQLITE_ROW) {
-               int get_bytes = sqlite3_column_bytes(stmt, 0);
-               char *get_data = (char *)calloc(get_bytes + 1, sizeof(char));
-               if (get_data != NULL) {
-                       memcpy(get_data, sqlite3_column_text(stmt, 0),
-                                       get_bytes * sizeof(char));
-                       get_data[get_bytes] = '\0';
-                       *value = get_data;
-               } else {
-                       NOTIFICATION_ERR("fail to alloc query");
-                       result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
-                       goto return_close_db;
-               }
-       }
-
-return_close_db:
-       if (sqlbuf)
-               sqlite3_free(sqlbuf);
-
-       if (stmt)
-               sqlite3_finalize(stmt);
-
-       sqlret = db_util_close(db);
-       if (sqlret != SQLITE_OK)
-               NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
-
-       return result;
-}
-
-EXPORT_API int notification_setting_property_set(const char *pkgname, const char *property, const char *value)
-{
-       int ret = 0;
-
-       if (!pkgname)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!property)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!value)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       ret = notification_ipc_noti_setting_property_set(pkgname, property, value);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return ret;
-
-       return NOTIFICATION_ERROR_NONE;
-}
-
-EXPORT_API int notification_setting_property_get(const char *pkgname, const char *property, char **value)
-{
-       int ret = 0;
-
-       if (!pkgname)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!property)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       if (!value)
-               return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
-       ret = notification_ipc_noti_setting_property_get(pkgname, property, value);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return ret;
-
-       return NOTIFICATION_ERROR_NONE;
-}
-
index efa40eb053a9bdf7c67a40a0b5a03e7c2e155f08..aa9ab6ca170f9a48d49bee707b843bedb65bcf94 100644 (file)
@@ -28,7 +28,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(test_app_pkgs REQUIRED glib-2.0 gthread-2.0 vconf appsvc capi-appfw-application)
+pkg_check_modules(test_app_pkgs REQUIRED glib-2.0 gthread-2.0 vconf appsvc capi-appfw-application libtzplatform-config)
 
 FOREACH(flag ${test_app_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index e775f6a6633c1646847513969cad9ae6bfd40ca8..79a0a47b9df2ecd38c3527bd83712d34948dc24d 100755 (executable)
 #include <notification_setting_internal.h>
 #include <notification_list.h>
 #include <notification_text_domain.h>
+#include <tzplatform_config.h>
+
+#define PATH_FMT_RO_APP_ROOT tzplatform_getenv(TZ_SYS_RO_APP)
+#define TIZEN_PATH_MAX 1024
 
 /*-----------------------------------------------------------------------------------------*/
 /* types */
@@ -267,6 +271,7 @@ static int testapp_test_post_notification_on_indicator()
 {
        notification_h noti_handle = NULL;
        int noti_err = NOTIFICATION_ERROR_NONE;
+       char image_path[TIZEN_PATH_MAX] = {0, };
 
        noti_handle = notification_create(NOTIFICATION_TYPE_ONGOING);
 
@@ -275,7 +280,8 @@ static int testapp_test_post_notification_on_indicator()
                goto FINISH_OFF;
        }
 
-       noti_err  = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, "/usr/apps/org.tizen.indicator/res/icons/Shealth/B03_shealth.png");
+       snprintf(image_path, TIZEN_PATH_MAX, "%s/org.tizen.indicator/res/icons/Shealth/B03_shealth.png", PATH_FMT_RO_APP_ROOT);
+       noti_err  = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, image_path);
        /*
        noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
        noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "This is very loooooooooooooooooooooooooooooooooooooooooong message", NOTIFICATION_VARIABLE_TYPE_NONE);