summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2016-03-02 15:20:29 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2016-03-02 15:22:33 +0900
commit3b9e481b6fdc211e8e1ab2a3bc6a4c8be4b4b799 (patch)
tree6d2c269699cbdd563c5f1791a1e586318bfdcdc6
parent76cb826409d479bd27efc65c6952a1be91429ce6 (diff)
downloadnotification-3b9e481b6fdc211e8e1ab2a3bc6a4c8be4b4b799.tar.gz
notification-3b9e481b6fdc211e8e1ab2a3bc6a4c8be4b4b799.tar.bz2
notification-3b9e481b6fdc211e8e1ab2a3bc6a4c8be4b4b799.zip
Remove hard coded path and deprecated internal APIs
- 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>
-rwxr-xr-xsrc/notification_setting.c307
-rw-r--r--test-app/CMakeLists.txt2
-rwxr-xr-xtest-app/main.c8
3 files changed, 8 insertions, 309 deletions
diff --git a/src/notification_setting.c b/src/notification_setting.c
index fcb07eb..a2d6fd1 100755
--- a/src/notification_setting.c
+++ b/src/notification_setting.c
@@ -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;
-}
-
diff --git a/test-app/CMakeLists.txt b/test-app/CMakeLists.txt
index efa40eb..aa9ab6c 100644
--- a/test-app/CMakeLists.txt
+++ b/test-app/CMakeLists.txt
@@ -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}")
diff --git a/test-app/main.c b/test-app/main.c
index e775f6a..79a0a47 100755
--- a/test-app/main.c
+++ b/test-app/main.c
@@ -40,6 +40,10 @@
#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);