Merge "Remove com-core dependency" into tizen submit/tizen/20160315.050359 submit/tizen_common/20160316.154911
authorjusung son <jusung07.son@samsung.com>
Tue, 15 Mar 2016 04:24:03 +0000 (21:24 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 15 Mar 2016 04:24:03 +0000 (21:24 -0700)
src/notification_ipc.c
src/notification_setting.c
test-app/CMakeLists.txt
test-app/main.c

index d04d647..eef8bf6 100755 (executable)
@@ -579,11 +579,14 @@ static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd)
        g_object_unref(msg);
 
        if (!*reply) {
+               ret = NOTIFICATION_ERROR_SERVICE_NOT_READY;
                if (err != NULL) {
                        NOTIFICATION_ERR("No reply. cmd = %s,  error = %s", cmd, err->message);
+                       if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+                               ret = NOTIFICATION_ERROR_PERMISSION_DENIED;
                        g_error_free(err);
                }
-               return NOTIFICATION_ERROR_SERVICE_NOT_READY;
+               return ret;
        }
 
        if (g_dbus_message_to_gerror(*reply, &err)) {
@@ -991,6 +994,7 @@ int notification_ipc_request_load_noti_grouping_list(notification_type_e type, i
        GVariant *iter_body;
        GVariantIter *iter;
        notification_h noti;
+       GVariant *noti_body;
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
@@ -1007,7 +1011,8 @@ int notification_ipc_request_load_noti_grouping_list(notification_type_e type, i
 
                while (g_variant_iter_loop(iter, "(v)", &iter_body)) {
                        noti = notification_create(NOTIFICATION_TYPE_NOTI);
-                       notification_ipc_make_noti_from_gvariant(noti, iter_body);
+                       g_variant_get(iter_body, "(v)", &noti_body);
+                       notification_ipc_make_noti_from_gvariant(noti, noti_body);
                        _print_noti(noti);
                        *list = notification_list_append(*list, noti);
                }
@@ -1034,6 +1039,7 @@ int notification_ipc_request_load_noti_detail_list(const char *pkgname,
        GVariant *iter_body;
        GVariantIter *iter;
        notification_h noti;
+       GVariant *noti_body;
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
@@ -1050,7 +1056,8 @@ int notification_ipc_request_load_noti_detail_list(const char *pkgname,
 
                while (g_variant_iter_loop(iter, "(v)", &iter_body)) {
                        noti = notification_create(NOTIFICATION_TYPE_NOTI);
-                       notification_ipc_make_noti_from_gvariant(noti, iter_body);
+                       g_variant_get(iter_body, "(v)", &noti_body);
+                       notification_ipc_make_noti_from_gvariant(noti, noti_body);
                        _print_noti(noti);
                        *list = notification_list_append(*list, noti);
                }
index fcb07eb..a2d6fd1 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 efa40eb..aa9ab6c 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 e775f6a..79a0a47 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);