--- /dev/null
+notification_init --uid $2
\ No newline at end of file
ADD_SUBDIRECTORY(test-app)
+SET(INIT-SRCS
+ ./src/notification_init.c
+)
+
SET(SRCS
./src/notification.c
./src/notification_noti.c
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+ADD_EXECUTABLE(notification_init ${INIT-SRCS})
+TARGET_LINK_LIBRARIES(notification_init ${pkgs_LDFLAGS} notification)
+
MESSAGE(STATUS "LIB_INSTALL_DIR: " ${LIB_INSTALL_DIR})
CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
FOREACH(hfile ${HEADERS-DEVEL})
INSTALL(FILES ${CMAKE_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
ENDFOREACH(hfile)
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/11_notification-add.post DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/useradd.d/)
+INSTALL(TARGETS notification_init DESTINATION bin)
\ No newline at end of file
* @addtogroup NOTIFICATION_INTERNAL
* @{
*/
-
+#define NOTIFICATION_GLOBAL_UID -1
#define NOTIFICATION_DISPLAY_APP_HEADS_UP NOTIFICATION_DISPLAY_APP_ACTIVE /* To avoid build error */
#define NOTIFICATION_ERROR (notification_error_quark())
GQuark notification_error_quark(void);
int notification_del_deferred_task(
void (*deferred_task_cb)(void *data));
+
+int
+notification_resister_changed_cb_for_uid(
+ void (*changed_cb)(void *data, notification_type_e type),
+ void *user_data, uid_t uid);
+
/**
* @brief This function will be removed.
* @see notification_unresister_changed_cb()
* @endcode
*/
int notification_insert(notification_h noti,
- int *priv_id);
+ int *priv_id);
+
+int notification_insert_for_uid(notification_h noti,
+ int *priv_id, uid_t uid);
/**
* @internal
*/
int notification_update_async(notification_h noti,
void (*result_cb)(int priv_id, int result, void *data), void *user_data);
+int notification_update_async_for_uid(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data, uid_t uid);
/**
* @internal
int notification_register_detailed_changed_cb(
void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
void *user_data);
+int notification_register_detailed_changed_cb_for_uid(
+ void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+ void *user_data, uid_t uid);
/**
* @internal
* @see notification_create()
*/
int notification_translate_localized_text(notification_h noti);
+int notification_set_uid(notification_h noti, uid_t uid);
+int notification_get_uid(notification_h noti, uid_t *uid);
+int notification_post_for_uid(notification_h noti, uid_t uid);
+int notification_update_for_uid(notification_h noti, uid_t uid);
+int notification_delete_for_uid(notification_h noti, uid_t uid);
+int notification_delete_all_for_uid(notification_type_e type, uid_t uid);
+notification_h notification_load_by_tag_for_uid(const char *tag, uid_t uid);
/**
* @}
GVariant *variant);
int notification_dbus_init();
-int notification_ipc_monitor_init(void);
+int notification_ipc_monitor_init(uid_t uid);
int notification_ipc_monitor_fini(void);
int notification_ipc_is_master_ready(void);
int notification_ipc_request_update_async(notification_h noti,
void (*result_cb)(int priv_id, int result, void *data),
void *user_data);
-int notification_ipc_request_refresh(void);
+int notification_ipc_request_refresh(uid_t uid);
int notification_ipc_request_delete_multiple(notification_type_e type,
- char *pkgname);
+ char *pkgname, uid_t uid);
int notification_ipc_request_delete_single(notification_type_e type,
- char *pkgname, int priv_id);
-int notification_ipc_update_setting(notification_setting_h setting);
+ char *pkgname, int priv_id, uid_t uid);
+int notification_ipc_update_setting(notification_setting_h setting, uid_t uid);
int notification_ipc_update_system_setting(
- notification_system_setting_h system_setting);
+ notification_system_setting_h system_setting, uid_t uid);
int notification_ipc_request_load_noti_by_tag(notification_h noti,
- const char *pkgname, const char *tag);
+ const char *pkgname, const char *tag, uid_t uid);
int notification_ipc_request_load_noti_grouping_list(notification_type_e type,
int count,
- notification_list_h *list);
+ notification_list_h *list, uid_t uid);
int notification_ipc_request_get_setting_array(
- notification_setting_h *setting_array, int *count);
+ notification_setting_h *setting_array, int *count, uid_t uid);
int notification_ipc_request_get_setting_by_package_name(
- const char *package_name, notification_setting_h *setting);
+ const char *package_name, notification_setting_h *setting, uid_t uid);
int notification_ipc_request_load_system_setting(
- notification_system_setting_h *setting);
+ notification_system_setting_h *setting, uid_t uid);
int notification_ipc_request_get_count(notification_type_e type,
- const char *pkgname, int group_id, int priv_id, int *count);
+ const char *pkgname, int group_id, int priv_id, int *count, uid_t uid);
int notification_ipc_request_load_noti_by_priv_id(notification_h noti,
- const char *pkgname, int priv_id);
+ const char *pkgname, int priv_id, uid_t uid);
int notification_ipc_request_load_noti_detail_list(const char *pkgname,
int group_id, int priv_id, int count,
- notification_list_h *list);
+ notification_list_h *list, uid_t uid);
#ifdef __cplusplus
}
* @endcode
*/
int notification_get_list(notification_type_e type,
- int count,
- notification_list_h *list);
+ int count,
+ notification_list_h *list);
+
+int notification_get_list_for_uid(notification_type_e type,
+ int count,
+ notification_list_h *list, uid_t uid);
/**
* @brief Returns the notification detail list handle of grouping data.
* @endcode
*/
int notification_get_detail_list(const char *pkgname,
- int group_id,
- int priv_id,
- int count,
- notification_list_h *list);
+ int group_id,
+ int priv_id,
+ int count,
+ notification_list_h *list);
+
+int notification_get_detail_list_for_uid(const char *pkgname,
+ int group_id,
+ int priv_id,
+ int count,
+ notification_list_h *list,
+ uid_t uid);
/**
* @brief Frees a notification list.
int notification_noti_update(notification_h noti);
-int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid);
+int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid, uid_t uid);
-int notification_noti_delete_group_by_group_id(const char *pkgname,
- int group_id, int *num_deleted, int **list_deleted_rowid);
-
-int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id);
-
-int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id);
-int notification_noti_get_by_tag(notification_h noti, char *pkgname, char* tag);
+int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id, uid_t uid);
+int notification_noti_get_by_tag(notification_h noti, char *pkgname, char* tag, uid_t uid);
int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id);
-int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes);
+int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes, uid_t uid);
int notification_noti_get_count(notification_type_e type,
- const char *pkgname,
- int group_id, int priv_id,
- int *count);
+ const char *pkgname,
+ int group_id, int priv_id,
+ int *count, uid_t uid);
int notification_noti_get_grouping_list(notification_type_e type,
- int count,
- notification_list_h *list);
+ int count,
+ notification_list_h *list,
+ uid_t uid);
int notification_noti_get_detail_list(const char *pkgname,
- int group_id,
- int priv_id, int count,
- notification_list_h *list);
+ int group_id,
+ int priv_id, int count,
+ notification_list_h *list,
+ uid_t uid);
int notification_noti_check_tag(notification_h noti);
char *tag;
bool ongoing_flag;
bool auto_remove;
+ uid_t uid;
};
struct notification_system_setting {
NOTIFICATION_DATA_TYPE_TAG,
NOTIFICATION_DATA_TYPE_ONGOING_FLAG,
NOTIFICATION_DATA_TYPE_AUTO_REMOVE,
+ NOTIFICATION_DATA_TYPE_UID,
} notification_data_type_e;
void notification_call_changed_cb(notification_op *op_list, int op_num);
int notification_setting_free_notification(notification_setting_h setting);
-int notification_setting_refresh_setting_table();
+int notification_setting_refresh_setting_table(uid_t uid);
#ifdef __cplusplus
}
int notification_setting_get_do_not_disturb_except(notification_setting_h setting, bool *value);
int notification_setting_set_do_not_disturb_except(notification_setting_h setting, bool value);
-int notification_setting_insert_package(const char *package_id);
-int notification_setting_delete_package(const char *package_id);
+int notification_setting_insert_package_for_uid(const char *package_id, uid_t uid);
+int notification_setting_delete_package_for_uid(const char *package_id, uid_t uid);
/* System setting */
typedef struct notification_system_setting *notification_system_setting_h;
int notification_setting_db_set(const char *pkgname, const char *property, const char *value);
int notification_setting_db_get(const char *pkgname, const char *property, char **value);
-int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class);
-int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class);
+int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class, uid_t uid);
+int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class, uid_t uid);
-int noti_setting_service_get_setting_by_package_name(const char *package_name, notification_setting_h *setting);
-int noti_setting_get_setting_array(notification_setting_h *setting_array, int *count);
-int noti_system_setting_load_system_setting(notification_system_setting_h *system_setting);
+int noti_setting_service_get_setting_by_package_name(const char *package_name, notification_setting_h *setting, uid_t uid);
+int noti_setting_get_setting_array(notification_setting_h *setting_array, int *count, uid_t uid);
+int noti_system_setting_load_system_setting(notification_system_setting_h *system_setting, uid_t uid);
#ifdef __cplusplus
}
%defattr(-,root,root,-)
%{_libdir}/libnotification.so*
%{TZ_SYS_SHARE}/license/%{name}
+%attr(755,root,root) %{_sysconfdir}/gumd/useradd.d/11_notification-add.post
+%{_bindir}/notification_init
+#%{_bindir}/notification-test-app
%files devel
%defattr(-,root,root,-)
EXPORT_API int notification_post(notification_h noti)
{
- int ret = 0;
- int id = 0;
-
- /* Check noti is vaild data */
- if (noti == NULL)
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
- /* Check noti type is valid type */
- if (noti->type <= NOTIFICATION_TYPE_NONE
- || noti->type >= NOTIFICATION_TYPE_MAX)
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
- /* Save insert time */
- noti->insert_time = time(NULL);
-
- ret = notification_ipc_request_insert(noti, &id);
- if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
-
- noti->priv_id = id;
- NOTIFICATION_DBG("from master:%d", id);
-
- return NOTIFICATION_ERROR_NONE;
+ return notification_post_for_uid(noti, getuid());
}
-
-
EXPORT_API int notification_update(notification_h noti)
{
- int ret = 0;
-
- /* Check noti is valid data */
- if (noti != NULL) {
- /* Update insert time ? */
- noti->insert_time = time(NULL);
- ret = notification_ipc_request_update(noti);
- } else {
- notification_ipc_request_refresh();
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
- return ret;
+ return notification_update_for_uid(noti, getuid());
}
EXPORT_API int notification_delete_all(notification_type_e type)
{
- int ret = 0;
- char *caller_pkgname = NULL;
-
- if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
- caller_pkgname = notification_get_pkgname_by_pid();
-
- ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
-
- if (caller_pkgname)
- free(caller_pkgname);
-
- return ret;
+ return notification_delete_all_for_uid(type, getuid());
}
EXPORT_API int notification_delete(notification_h noti)
{
- int ret = 0;
-
- if (noti == NULL)
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
- ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
-
- return ret;
+ return notification_delete_for_uid(noti, getuid());
}
static notification_h _notification_create(notification_type_e type)
noti->caller_pkgname = notification_get_pkgname_by_pid();
noti->group_id = NOTIFICATION_GROUP_ID_NONE;
- noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
noti->led_operation = NOTIFICATION_LED_OP_OFF;
EXPORT_API notification_h notification_load_by_tag(const char *tag)
{
- int ret = 0;
- notification_h noti = NULL;
- char *caller_pkgname = NULL;
-
- if (tag == NULL) {
- NOTIFICATION_ERR("Invalid parameter");
- set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- caller_pkgname = notification_get_pkgname_by_pid();
- if (!caller_pkgname) {
- NOTIFICATION_ERR("Failed to get a package name");
- set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- noti = (notification_h)calloc(1, sizeof(struct _notification));
- if (noti == NULL) {
- NOTIFICATION_ERR("Failed to alloc a new notification");
- set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
- free(caller_pkgname);
-
- return NULL;
- }
-
- ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, (char *)tag);
- free(caller_pkgname);
-
- set_last_result(ret);
- if (ret != NOTIFICATION_ERROR_NONE) {
- notification_free(noti);
- return NULL;
- }
-
- return noti;
+ return notification_load_by_tag_for_uid(tag, getuid());
}
EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
image_path TEXT, \
group_id INTEGER default 0, \
internal_group_id INTEGER default 0, \
- priv_id INTERGER NOT NULL, \
+ priv_id INTEGER PRIMARY KEY AUTOINCREMENT, \
title_key TEXT, \
b_text TEXT, \
b_key TEXT, \
display_applist INTEGER, \
progress_size DOUBLE default 0, \
progress_percentage DOUBLE default 0, \
- rowid INTEGER PRIMARY KEY AUTOINCREMENT, \
ongoing_flag INTEGER default 0, \
auto_remove INTEGER default 1, \
- UNIQUE (caller_pkgname, priv_id) \
+ uid INTEGER \
); \
create table if not exists noti_group_data ( \
caller_pkgname TEXT NOT NULL, \
UNIQUE (caller_pkgname, priv_id) \
); \
CREATE TABLE IF NOT EXISTS notification_setting ( \
- priv_id INTEGER PRIMARY KEY AUTOINCREMENT, \
+ uid INTEGER, \
package_name TEXT NOT NULL, \
allow_to_notify INTEGER DEFAULT 1, \
do_not_disturb_except INTEGER DEFAULT 0, \
visibility_class INTEGER DEFAULT 0, \
- UNIQUE (priv_id, package_name) \
+ UNIQUE (uid, package_name) \
); \
CREATE TABLE IF NOT EXISTS notification_system_setting ( \
- priv_id INTERGER PRIMARY KEY, \
+ uid INTEGER, \
do_not_disturb INTEGER DEFAULT 0, \
- visibility_class INTEGER DEFAULT 0 \
- ); \
- INSERT OR IGNORE INTO notification_system_setting (priv_id, do_not_disturb, visibility_class) VALUES (0, 0, 0); \
- CREATE UNIQUE INDEX IF NOT EXISTS package_name_idx1 ON notification_setting (package_name);"
+ visibility_class INTEGER DEFAULT 0, \
+ UNIQUE (uid) \
+ );"
EXPORT_API int notification_db_init()
{
sqlite3 *db = NULL;
char *errmsg = NULL;
char defname[FILENAME_MAX];
+ char *query = NULL;
const char *db_path = tzplatform_getenv(TZ_SYS_DB);
if (db_path == NULL) {
NOTIFICATION_ERR("fail to get db_path");
NOTIFICATION_ERR("fail to open notification db %d", r);
return NOTIFICATION_ERROR_IO_ERROR;
}
+ query = sqlite3_mprintf(CREATE_NOTIFICATION_TABLE, tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+ NOTIFICATION_DBG("@@@ query : %s", query);
r = sqlite3_exec(db, CREATE_NOTIFICATION_TABLE, NULL, NULL, &errmsg);
+ if (query)
+ sqlite3_free(query);
if (r != SQLITE_OK) {
NOTIFICATION_ERR("query error(%d)(%s)", r, errmsg);
sqlite3_free(errmsg);
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+#include <notification_setting.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
+#define OWNER_ROOT 0
+
+#ifdef _E
+#undef _E
+#endif
+#define _E(fmt, arg...) fprintf(stderr, "[NOTIFICATION_INIT][E][%s,%d] "fmt"\n", \
+ __FUNCTION__, __LINE__, ##arg);
+
+static int _is_authorized()
+{
+ /* pkg_init db should be called by as root privilege. */
+ uid_t uid = getuid();
+
+ if ((uid_t) OWNER_ROOT == uid)
+ return 1;
+ else
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ uid_t uid = 0;
+
+ if (!_is_authorized()) {
+ _E("You are not an authorized user!");
+ return -1;
+ }
+
+ if (argc > 2)
+ uid = (uid_t)atoi(argv[2]);
+ ret = notification_setting_refresh_setting_table(uid);
+ return ret;
+}
while (noti_cb_list != NULL) {
if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
noti_cb_list->changed_cb(noti_cb_list->data,
- type);
+ type);
}
if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
noti_cb_list->detailed_changed_cb(noti_cb_list->data,
- type, op_list, op_num);
+ type, op_list, op_num);
}
noti_cb_list = noti_cb_list->next;
return notification_ipc_del_deffered_task(deferred_task_cb);
}
-EXPORT_API int notification_resister_changed_cb(void (*changed_cb)
- (void *data, notification_type_e type),
- void *user_data)
+
+EXPORT_API int notification_resister_changed_cb_for_uid(
+ void (*changed_cb)(void *data, notification_type_e type),
+ void *user_data, uid_t uid)
{
notification_cb_list_s *noti_cb_list_new = NULL;
notification_cb_list_s *noti_cb_list = NULL;
return NOTIFICATION_ERROR_INVALID_PARAMETER;
noti_cb_list_new =
- (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
+ (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
if (noti_cb_list_new == NULL) {
NOTIFICATION_ERR("malloc failed");
noti_cb_list_new->prev = noti_cb_list;
}
- if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
+ if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE) {
notification_unresister_changed_cb(changed_cb);
return NOTIFICATION_ERROR_IO_ERROR;
}
return NOTIFICATION_ERROR_NONE;
}
-EXPORT_API int notification_unresister_changed_cb(void (*changed_cb)
- (void *data, notification_type_e type))
+EXPORT_API int notification_resister_changed_cb(
+ void (*changed_cb)(void *data, notification_type_e type),
+ void *user_data)
+{
+ return notification_resister_changed_cb_for_uid(
+ changed_cb, user_data, getuid());
+}
+
+EXPORT_API int notification_unresister_changed_cb(
+ void (*changed_cb)(void *data, notification_type_e type))
{
notification_cb_list_s *noti_cb_list = NULL;
notification_cb_list_s *noti_cb_list_prev = NULL;
}
EXPORT_API int notification_update_progress(notification_h noti,
- int priv_id,
- double progress)
+ int priv_id,
+ double progress)
{
char *caller_pkgname = NULL;
int input_priv_id = 0;
input_progress = progress;
ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
- input_progress);
+ input_progress);
if (caller_pkgname)
free(caller_pkgname);
}
EXPORT_API int notification_update_size(notification_h noti,
- int priv_id,
- double size)
+ int priv_id,
+ double size)
{
char *caller_pkgname = NULL;
int input_priv_id = 0;
input_size = size;
ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
- input_size);
+ input_size);
if (caller_pkgname)
free(caller_pkgname);
}
EXPORT_API int notification_update_content(notification_h noti,
- int priv_id,
- const char *content)
+ int priv_id,
+ const char *content)
{
char *caller_pkgname = NULL;
int input_priv_id = 0;
caller_pkgname = strdup(noti->caller_pkgname);
ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
- content);
+ content);
if (caller_pkgname)
free(caller_pkgname);
/* notification_set_icon will be removed */
/* LCOV_EXCL_START */
EXPORT_API int notification_set_icon(notification_h noti,
- const char *icon_path)
+ const char *icon_path)
{
int ret_err = NOTIFICATION_ERROR_NONE;
ret_err =
- notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
- icon_path);
+ notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
+ icon_path);
return ret_err;
}
/* notification_get_icon will be removed */
/* LCOV_EXCL_START */
EXPORT_API int notification_get_icon(notification_h noti,
- char **icon_path)
+ char **icon_path)
{
int ret_err = NOTIFICATION_ERROR_NONE;
char *ret_image_path = NULL;
ret_err =
- notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
- &ret_image_path);
+ notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
+ &ret_image_path);
if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL)
*icon_path = ret_image_path;
/* LCOV_EXCL_START */
EXPORT_API int notification_set_title(notification_h noti,
- const char *title,
- const char *loc_title)
+ const char *title,
+ const char *loc_title)
{
int noti_err = NOTIFICATION_ERROR_NONE;
noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
- title, loc_title,
- NOTIFICATION_VARIABLE_TYPE_NONE);
+ title, loc_title,
+ NOTIFICATION_VARIABLE_TYPE_NONE);
return noti_err;
}
/* LCOV_EXCL_START */
EXPORT_API int notification_get_title(notification_h noti,
- char **title,
- char **loc_title)
+ char **title,
+ char **loc_title)
{
int noti_err = NOTIFICATION_ERROR_NONE;
char *ret_text = NULL;
noti_err =
- notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
- &ret_text);
+ notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+ &ret_text);
if (title != NULL)
*title = ret_text;
/* LCOV_EXCL_START */
EXPORT_API int notification_set_content(notification_h noti,
- const char *content,
- const char *loc_content)
+ const char *content,
+ const char *loc_content)
{
int noti_err = NOTIFICATION_ERROR_NONE;
noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
- content, loc_content,
- NOTIFICATION_VARIABLE_TYPE_NONE);
+ content, loc_content,
+ NOTIFICATION_VARIABLE_TYPE_NONE);
return noti_err;
}
/* LCOV_EXCL_START */
EXPORT_API int notification_get_content(notification_h noti,
- char **content,
- char **loc_content)
+ char **content,
+ char **loc_content)
{
int noti_err = NOTIFICATION_ERROR_NONE;
char *ret_text = NULL;
noti_err =
- notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
- &ret_text);
+ notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+ &ret_text);
if (content != NULL)
*content = ret_text;
#if 0
ret =
- vconf_get_bool
- (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
+ vconf_get_bool
+ (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
if (ret == -1 || boolval == 0) {
if (content != NULL && noti->default_content != NULL)
/* LCOV_EXCL_START */
EXPORT_API int notification_set_application(notification_h noti,
- const char *pkgname)
+ const char *pkgname)
{
if (noti == NULL || pkgname == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_START */
EXPORT_API int notification_get_application(notification_h noti,
- char **pkgname)
+ char **pkgname)
{
if (noti == NULL || pkgname == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_START */
EXPORT_API int notification_get_args(notification_h noti,
- bundle **args,
- bundle **group_args)
+ bundle **args,
+ bundle **group_args)
{
if (noti == NULL || args == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
- notification_list_h *list)
+int notification_get_grouping_list_for_uid(notification_type_e type, int count,
+ notification_list_h *list, uid_t uid)
{
notification_list_h get_list = NULL;
int ret = 0;
if (list == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- ret = notification_noti_get_grouping_list(type, count, &get_list);
+ ret = notification_noti_get_grouping_list(type, count, &get_list, uid);
if (ret != NOTIFICATION_ERROR_NONE)
return ret;
return NOTIFICATION_ERROR_NONE;
}
+
+EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
+ notification_list_h *list)
+{
+ return notification_get_grouping_list_for_uid(type, count, list, getuid());
+}
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
- notification_type_e type,
- int group_id)
+ notification_type_e type,
+ int group_id)
{
int ret = 0;
char *caller_pkgname = NULL;
else
caller_pkgname = strdup(pkgname);
- ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
+ ret = notification_ipc_request_delete_multiple(type, caller_pkgname, getuid());
if (caller_pkgname)
free(caller_pkgname);
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
- notification_type_e type,
- int priv_id)
+int notification_delete_group_by_priv_id_for_uid(const char *pkgname,
+ notification_type_e type,
+ int priv_id, uid_t uid)
{
int ret = 0;
char *caller_pkgname = NULL;
else
caller_pkgname = strdup(pkgname);
- ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
+ ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id, uid);
if (caller_pkgname)
free(caller_pkgname);
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API int notification_get_count(notification_type_e type,
- const char *pkgname,
- int group_id,
- int priv_id, int *count)
+EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
+ notification_type_e type,
+ int priv_id)
+{
+ return notification_delete_group_by_priv_id_for_uid(pkgname, type, priv_id, getuid());
+}
+
+int notification_get_count_for_uid(notification_type_e type,
+ const char *pkgname,
+ int group_id,
+ int priv_id, int *count,
+ uid_t uid)
{
int ret = 0;
char *caller_pkgname = NULL;
caller_pkgname,
group_id,
priv_id,
- count);
+ count,
+ uid);
if (caller_pkgname)
free(caller_pkgname);
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API int notification_clear(notification_type_e type)
+EXPORT_API int notification_get_count(notification_type_e type,
+ const char *pkgname,
+ int group_id,
+ int priv_id, int *count)
+{
+ return notification_get_count_for_uid(type, pkgname, group_id, priv_id, count, getuid());
+}
+
+int notification_clear_for_uid(notification_type_e type, uid_t uid)
{
int ret = 0;
if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- ret = notification_ipc_request_delete_multiple(type, NULL);
+ ret = notification_ipc_request_delete_multiple(type, NULL, uid);
return ret;
}
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
+EXPORT_API int notification_clear(notification_type_e type)
+{
+ return notification_clear_for_uid(type, getuid());
+}
+
EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
- void *data)
+ void *data)
{
if (noti_op == NULL || data == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_START */
EXPORT_API int notification_set_pkgname(notification_h noti,
- const char *pkgname)
+ const char *pkgname)
{
/* check noti and pkgname are valid data */
if (noti == NULL || pkgname == NULL)
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API int notification_delete_all_by_type(const char *pkgname,
- notification_type_e type)
+int notification_delete_all_by_type_for_uid(const char *pkgname,
+ notification_type_e type, uid_t uid)
{
int ret = 0;
char *caller_pkgname = NULL;
else
caller_pkgname = strdup(pkgname);
- ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
+ ret = notification_ipc_request_delete_multiple(type, caller_pkgname, uid);
if (caller_pkgname)
free(caller_pkgname);
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
- notification_type_e type,
- int priv_id)
+EXPORT_API int notification_delete_all_by_type(const char *pkgname,
+ notification_type_e type)
+{
+ return notification_delete_all_by_type_for_uid(pkgname, type, getuid());
+}
+
+int notification_delete_by_priv_id_for_uid(const char *pkgname,
+ notification_type_e type,
+ int priv_id,
+ uid_t uid)
{
int ret = 0;
char *caller_pkgname = NULL;
else
caller_pkgname = strdup(pkgname);
- ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
+ ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id, uid);
if (caller_pkgname)
free(caller_pkgname);
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
+EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
+ notification_type_e type,
+ int priv_id)
+{
+ return notification_delete_by_priv_id_for_uid(pkgname, type, priv_id, getuid());
+}
+
EXPORT_API int notification_set_execute_option(notification_h noti,
- notification_execute_type_e type,
- const char *text,
- const char *key,
- bundle *service_handle)
+ notification_execute_type_e type,
+ const char *text,
+ const char *key,
+ bundle *service_handle)
{
char buf_key[32] = { 0, };
char *ret_val = NULL;
return NOTIFICATION_ERROR_INVALID_PARAMETER;
if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
- || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
+ || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
/* Create execute option bundle if does not exist */
/* LCOV_EXCL_START */
EXPORT_API int notification_get_id(notification_h noti,
- int *group_id, int *priv_id)
+ int *group_id, int *priv_id)
{
/* check noti is valid data */
if (noti == NULL)
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-EXPORT_API notification_h notification_load(char *pkgname,
- int priv_id)
+notification_h notification_load_for_uid(char *pkgname,
+ int priv_id, uid_t uid)
{
int ret = 0;
notification_h noti = NULL;
return NULL;
}
- ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id);
+ ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id, uid);
if (ret != NOTIFICATION_ERROR_NONE) {
notification_free(noti);
return NULL;
}
/* LCOV_EXCL_STOP */
+EXPORT_API notification_h notification_load(char *pkgname,
+ int priv_id)
+{
+ return notification_load_for_uid(pkgname, priv_id, getuid());
+}
+
+/* LCOV_EXCL_START */
EXPORT_API notification_h notification_new(notification_type_e type,
- int group_id, int priv_id)
+ int group_id, int priv_id)
{
- return notification_create(type); //LCOV_EXCL_LINE
+ return notification_create(type);
}
static void _notification_get_text_domain(notification_h noti)
{
-/*
- if (noti->domain != NULL) {
-
- }
-
- if (noti->dir != NULL) {
-
- }
-*/
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API int notification_get_execute_option(notification_h noti,
- notification_execute_type_e type,
- const char **text,
- bundle **service_handle)
+ notification_execute_type_e type,
+ const char **text,
+ bundle **service_handle)
{
char buf_key[32] = { 0, };
char *ret_val = NULL;
return NOTIFICATION_ERROR_INVALID_PARAMETER;
if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
- || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
+ || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
if (b != NULL) {
- /* Return text */
+ /* Return text */
if (text != NULL) {
/* Get text domain and dir */
if (noti->domain == NULL || noti->dir == NULL)
/* Check key key exist */
bundle_get_str(b, buf_key, &ret_val);
if (ret_val != NULL && noti->domain != NULL
- && noti->dir != NULL) {
+ && noti->dir != NULL) {
/* Get application string */
bindtextdomain(noti->domain, noti->dir);
} else {
/* Get basic text */
snprintf(buf_key, sizeof(buf_key), "text%d",
- type);
+ type);
bundle_get_str(b, buf_key, &ret_val);
}
/* LCOV_EXCL_STOP */
-EXPORT_API int notification_insert(notification_h noti,
- int *priv_id)
+EXPORT_API int notification_insert_for_uid(notification_h noti,
+ int *priv_id, uid_t uid)
{
int ret = 0;
int id = 0;
/* Check noti type is valid type */
if (noti->type <= NOTIFICATION_TYPE_NONE
- || noti->type >= NOTIFICATION_TYPE_MAX)
+ || noti->type >= NOTIFICATION_TYPE_MAX)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ noti->uid = uid;
/* Save insert time */
noti->insert_time = time(NULL);
ret = notification_ipc_request_insert(noti, &id);
return NOTIFICATION_ERROR_NONE;
}
-EXPORT_API int notification_update_async(notification_h noti,
- void (*result_cb)(int priv_id, int result, void *data), void *user_data)
+EXPORT_API int notification_insert(notification_h noti,
+ int *priv_id)
{
- int ret = 0;
+ return notification_insert_for_uid(noti, priv_id, getuid());
+}
+EXPORT_API int notification_update_async_for_uid(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data, uid_t uid)
+{
+ int ret = 0;
if (noti == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ noti->uid = uid;
/* Update insert time ? */
noti->insert_time = time(NULL);
ret = notification_ipc_request_update_async(noti, result_cb, user_data);
return ret;
}
-EXPORT_API int notification_register_detailed_changed_cb(
+EXPORT_API int notification_update_async(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data)
+{
+ return notification_update_async_for_uid(noti, result_cb, user_data, getuid());
+}
+
+EXPORT_API int notification_register_detailed_changed_cb_for_uid(
void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
- void *user_data)
+ void *user_data, uid_t uid)
{
notification_cb_list_s *noti_cb_list_new = NULL;
notification_cb_list_s *noti_cb_list = NULL;
if (detailed_changed_cb == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
+ if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE)
return NOTIFICATION_ERROR_IO_ERROR;
noti_cb_list_new =
- (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
+ (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
if (noti_cb_list_new == NULL) {
NOTIFICATION_ERR("malloc failed");
return NOTIFICATION_ERROR_NONE;
}
+EXPORT_API int notification_register_detailed_changed_cb(
+ void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+ void *user_data)
+{
+ return notification_register_detailed_changed_cb_for_uid(detailed_changed_cb, user_data, getuid());
+}
+
EXPORT_API int notification_unregister_detailed_changed_cb(
void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
void *user_data)
return notification_ipc_is_master_ready();
}
+EXPORT_API int notification_set_uid(notification_h noti,
+ uid_t uid)
+{
+ if (noti == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ noti->uid = uid;
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_uid(notification_h noti,
+ uid_t *uid)
+{
+ if (noti == NULL || uid == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ *uid = noti->uid;
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_post_for_uid(notification_h noti, uid_t uid)
+{
+ int ret = 0;
+ int id = 0;
+
+ /* Check noti is vaild data */
+ if (noti == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ /* Check noti type is valid type */
+ if (noti->type <= NOTIFICATION_TYPE_NONE
+ || noti->type >= NOTIFICATION_TYPE_MAX)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ /* Save insert time */
+ noti->insert_time = time(NULL);
+ noti->uid = uid;
+
+ ret = notification_ipc_request_insert(noti, &id);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ return ret;
+
+ noti->priv_id = id;
+ NOTIFICATION_DBG("from master:%d", id);
+
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_update_for_uid(notification_h noti, uid_t uid)
+{
+ int ret;
+
+ /* Check noti is valid data */
+ if (noti != NULL) {
+ noti->uid = uid;
+ /* Update insert time ? */
+ noti->insert_time = time(NULL);
+ ret = notification_ipc_request_update(noti);
+ } else {
+ notification_ipc_request_refresh(uid);
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+EXPORT_API int notification_delete_for_uid(notification_h noti, uid_t uid)
+{
+ int ret = 0;
+
+ if (noti == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id, uid);
+
+ return ret;
+}
+
+EXPORT_API int notification_delete_all_for_uid(notification_type_e type, uid_t uid)
+{
+ int ret = 0;
+ char *caller_pkgname = NULL;
+
+ if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ caller_pkgname = notification_get_pkgname_by_pid();
+
+ ret = notification_ipc_request_delete_multiple(type, caller_pkgname, uid);
+
+ if (caller_pkgname)
+ free(caller_pkgname);
+
+ return ret;
+}
+
+EXPORT_API notification_h notification_load_by_tag_for_uid(const char *tag, uid_t uid)
+{
+ int ret = 0;
+ notification_h noti = NULL;
+ char *caller_pkgname = NULL;
+
+ if (tag == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ caller_pkgname = notification_get_pkgname_by_pid();
+ if (!caller_pkgname) {
+ NOTIFICATION_ERR("Failed to get a package name");
+ set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ noti = (notification_h)calloc(1, sizeof(struct _notification));
+ if (noti == NULL) {
+ NOTIFICATION_ERR("Failed to alloc a new notification");
+ set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ free(caller_pkgname);
+
+ return NULL;
+ }
+
+ ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, (char *)tag, uid);
+ free(caller_pkgname);
+
+ set_last_result(ret);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ notification_free(noti);
+ return NULL;
+ }
+
+ return noti;
+}
static task_list *g_task_list;
-static int _ipc_monitor_register(void);
+static int _ipc_monitor_register(uid_t uid);
static int _ipc_monitor_deregister(void);
static void _do_deffered_task(void);
}
/* Initialize private ID */
- noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
noti->group_id = NOTIFICATION_GROUP_ID_NONE;
noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
return result;
}
-int notification_ipc_request_refresh(void)
+int notification_ipc_request_refresh(uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- body = g_variant_new("(i)", NOTIFICATION_OP_REFRESH);
+ body = g_variant_new("(i)", uid);
result = _send_sync_noti(body, &reply, "refresh_noti");
if (reply)
return result;
}
-int notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id)
+int notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id, uid_t uid)
{
int result;
int id;
return result;
}
- body = g_variant_new("(si)", pkgname, priv_id);
+ body = g_variant_new("(sii)", pkgname, priv_id, uid);
result = _send_sync_noti(body, &reply, "del_noti_single");
if (result == NOTIFICATION_ERROR_NONE) {
return result;
}
-int notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname)
+int notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname, uid_t uid)
{
int result;
int num_deleted;
if (!pkgname)
pkgname = "";
- body = g_variant_new("(si)", pkgname, type);
+ body = g_variant_new("(sii)", pkgname, type, uid);
result = _send_sync_noti(body, &reply, "del_noti_multiple");
if (result == NOTIFICATION_ERROR_NONE) {
return result;
}
-int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *pkgname, const char *tag)
+int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *pkgname, const char *tag, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
if (!pkgname)
pkgname = "";
- body = g_variant_new("(ss)", pkgname, tag);
+ body = g_variant_new("(ssi)", pkgname, tag, uid);
result = _send_sync_noti(body, &reply, "load_noti_by_tag");
if (result == NOTIFICATION_ERROR_NONE) {
return result;
}
-int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const char *pkgname, int priv_id)
+int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const char *pkgname, int priv_id, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
if (!pkgname)
pkgname = "";
- body = g_variant_new("(si)", pkgname, priv_id);
+ body = g_variant_new("(sii)", pkgname, priv_id, uid);
result = _send_sync_noti(body, &reply, "load_noti_by_priv_id");
if (result == NOTIFICATION_ERROR_NONE) {
}
int notification_ipc_request_get_count(notification_type_e type,
- const char *pkgname, int group_id, int priv_id, int *count)
+ const char *pkgname, int group_id, int priv_id, int *count, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
if (!pkgname)
pkgname = "";
- body = g_variant_new("(isii)", type, pkgname, group_id, priv_id);
+ body = g_variant_new("(isiii)", type, pkgname, group_id, priv_id, uid);
result = _send_sync_noti(body, &reply, "get_noti_count");
if (result == NOTIFICATION_ERROR_NONE) {
}
int notification_ipc_request_load_noti_grouping_list(notification_type_e type, int count,
- notification_list_h *list)
+ notification_list_h *list, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- body = g_variant_new("(ii)", type, count);
+ body = g_variant_new("(iii)", type, count, uid);
result = _send_sync_noti(body, &reply, "load_noti_grouping_list");
if (result == NOTIFICATION_ERROR_NONE) {
noti = notification_create(NOTIFICATION_TYPE_NOTI);
g_variant_get(iter_body, "(v)", ¬i_body);
notification_ipc_make_noti_from_gvariant(noti, noti_body);
- _print_noti(noti);
*list = notification_list_append(*list, noti);
}
g_variant_iter_free(iter);
int group_id,
int priv_id,
int count,
- notification_list_h *list)
+ notification_list_h *list,
+ uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- body = g_variant_new("(siii)", pkgname, group_id, priv_id, count);
+ body = g_variant_new("(siiii)", pkgname, group_id, priv_id, count, uid);
result = _send_sync_noti(body, &reply, "load_noti_detail_list");
if (result == NOTIFICATION_ERROR_NONE) {
noti = notification_create(NOTIFICATION_TYPE_NOTI);
g_variant_get(iter_body, "(v)", ¬i_body);
notification_ipc_make_noti_from_gvariant(noti, noti_body);
- _print_noti(noti);
*list = notification_list_append(*list, noti);
}
g_variant_iter_free(iter);
int notification_ipc_request_get_setting_array(
notification_setting_h *setting_array,
- int *count)
+ int *count,
+ uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- result = _send_sync_noti(NULL, &reply, "get_setting_array");
+ result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "get_setting_array");
if (result == NOTIFICATION_ERROR_NONE) {
reply_body = g_dbus_message_get_body(reply);
}
int notification_ipc_request_get_setting_by_package_name(
- const char *package_name, notification_setting_h *setting)
+ const char *package_name, notification_setting_h *setting, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- body = g_variant_new("(s)", package_name);
+ body = g_variant_new("(si)", package_name, uid);
result = _send_sync_noti(body, &reply, "get_setting_by_package_name");
if (result == NOTIFICATION_ERROR_NONE) {
return result;
}
-int notification_ipc_request_load_system_setting(notification_system_setting_h *setting)
+int notification_ipc_request_load_system_setting(notification_system_setting_h *setting, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- result = _send_sync_noti(NULL, &reply, "load_system_setting");
+ result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "load_system_setting");
if (result == NOTIFICATION_ERROR_NONE) {
reply_body = g_dbus_message_get_body(reply);
return result;
}
-int notification_ipc_update_setting(notification_setting_h setting)
+int notification_ipc_update_setting(notification_setting_h setting, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- body = g_variant_new("(siii)",
+ body = g_variant_new("(siiii)",
setting->package_name,
(int)(setting->allow_to_notify),
(int)(setting->do_not_disturb_except),
- (int)(setting->visibility_class));
+ (int)(setting->visibility_class),
+ uid);
result = _send_sync_noti(body, &reply, "update_noti_setting");
return result;
}
-int notification_ipc_update_system_setting(notification_system_setting_h system_setting)
+int notification_ipc_update_system_setting(notification_system_setting_h system_setting, uid_t uid)
{
int result;
GDBusMessage *reply = NULL;
return result;
}
- body = g_variant_new("(ii)",
+ body = g_variant_new("(iii)",
(int)(system_setting->do_not_disturb),
- (int)(system_setting->visibility_class));
+ (int)(system_setting->visibility_class),
+ uid);
result = _send_sync_noti(body, &reply, "update_noti_sys_setting");
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_FLAG, g_variant_new_int32(noti->ongoing_flag));
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_AUTO_REMOVE, g_variant_new_int32(noti->auto_remove));
+ g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_UID, g_variant_new_int32(noti->uid));
result_body = g_variant_builder_end(&builder);
body = g_variant_new("(v)", result_body);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TAG, "&s", &tag);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_FLAG, "i", ¬i->ongoing_flag);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_AUTO_REMOVE, "i", ¬i->auto_remove);
+ _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", ¬i->uid);
noti->caller_pkgname = _dup_string(caller_pkgname);
noti->launch_pkgname = _dup_string(launch_pkgname);
return NOTIFICATION_ERROR_NONE;
}
-static int _send_service_register()
+static int _send_service_register(uid_t uid)
{
NOTIFICATION_DBG("service register");
GDBusMessage *reply = NULL;
int result;
notification_op *noti_op = NULL;
- result = _send_sync_noti(NULL, &reply, "noti_service_register");
+ result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "noti_service_register");
if (reply)
g_object_unref(reply);
return result;
}
-static int _ipc_monitor_register(void)
+static int _ipc_monitor_register(uid_t uid)
{
NOTIFICATION_ERR("register a service\n");
- return _send_service_register();
+ return _send_service_register(uid);
}
static void _on_name_appeared(GDBusConnection *connection,
const gchar *name_owner,
gpointer user_data)
{
- NOTIFICATION_DBG("name appeared : %s", name);
+ int uid = GPOINTER_TO_INT(user_data);
+ NOTIFICATION_DBG("name appeared [%d] : %s", uid, name);
is_master_started = 1;
- _ipc_monitor_register();
+ _ipc_monitor_register(uid);
/* TODO: dbus activation isn't enough ? */
_do_deffered_task();
const gchar *name,
gpointer user_data)
{
- NOTIFICATION_DBG("name vanished : %s", name);
+ int uid = GPOINTER_TO_INT(user_data);
+ NOTIFICATION_DBG("name vanished [%d] : %s", uid, name);
is_master_started = 0;
}
-int notification_ipc_monitor_init(void)
+int notification_ipc_monitor_init(uid_t uid)
{
int ret;
return ret;
}
- ret = _ipc_monitor_register();
+ ret = _ipc_monitor_register(uid);
if (ret != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("Can't init ipc_monitor_register %d", ret);
return ret;
}
if (provider_monitor_id == 0) {
+
provider_monitor_id = g_bus_watch_name_on_connection(
_gdbus_conn,
PROVIDER_BUS_NAME,
G_BUS_NAME_WATCHER_FLAGS_NONE,
_on_name_appeared,
_on_name_vanished,
- NULL,
+ GINT_TO_POINTER((int)uid),
NULL);
if (provider_monitor_id == 0) {
}
EXPORT_API notification_list_h notification_list_append(notification_list_h list,
- notification_h noti)
+ notification_h noti)
{
notification_list_h new_list = NULL;
notification_list_h cur_list = NULL;
}
EXPORT_API notification_list_h notification_list_remove(notification_list_h list,
- notification_h noti)
+ notification_h noti)
{
notification_list_h cur_list = NULL;
notification_list_h prev_list = NULL;
return NULL;
}
-EXPORT_API int notification_get_list(notification_type_e type,
- int count,
- notification_list_h *list)
+EXPORT_API int notification_get_list_for_uid(notification_type_e type,
+ int count,
+ notification_list_h *list, uid_t uid)
{
notification_list_h get_list = NULL;
int ret = 0;
if (list == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- ret = notification_ipc_request_load_noti_grouping_list(type, count, &get_list);
+ ret = notification_ipc_request_load_noti_grouping_list(type, count, &get_list, uid);
if (ret != NOTIFICATION_ERROR_NONE)
return ret;
return NOTIFICATION_ERROR_NONE;
}
-EXPORT_API int notification_get_detail_list(const char *pkgname,
- int group_id,
- int priv_id,
- int count,
- notification_list_h *list)
+EXPORT_API int notification_get_list(notification_type_e type,
+ int count,
+ notification_list_h *list)
+{
+ return notification_get_list_for_uid(type, count, list, getuid());
+}
+
+EXPORT_API int notification_get_detail_list_for_uid(const char *pkgname,
+ int group_id,
+ int priv_id,
+ int count,
+ notification_list_h *list,
+ uid_t uid)
{
notification_list_h get_list = NULL;
int ret = 0;
if (list == NULL || pkgname == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- ret =
- notification_ipc_request_load_noti_detail_list(pkgname, group_id, priv_id, count,
- &get_list);
+ ret = notification_ipc_request_load_noti_detail_list(pkgname, group_id, priv_id, count,
+ &get_list, uid);
if (ret != NOTIFICATION_ERROR_NONE)
return ret;
return NOTIFICATION_ERROR_NONE;
}
+EXPORT_API int notification_get_detail_list(const char *pkgname,
+ int group_id,
+ int priv_id,
+ int count,
+ notification_list_h *list)
+{
+ return notification_get_detail_list_for_uid(pkgname, group_id,
+ priv_id, count, list, getuid());
+}
+
EXPORT_API int notification_free_list(notification_list_h list)
{
notification_list_h cur_list = NULL;
#include <package_manager.h>
#include <notification.h>
+#include <notification_internal.h>
#include <notification_db.h>
#include <notification_list.h>
#include <notification_noti.h>
"layout, "
"caller_pkgname, launch_pkgname, "
"image_path, "
- "group_id, internal_group_id, priv_id, "
+ "group_id, internal_group_id,"
"title_key, "
"b_text, b_key, tag, b_format_args, num_format_args, "
"text_domain, text_dir, "
"b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, flag_simmode, display_applist, "
- "progress_size, progress_percentage, ongoing_flag, auto_remove) values ("
+ "progress_size, progress_percentage, ongoing_flag, auto_remove, uid) values ("
"%d, "
"%d, "
"'%s', '%s', "
"'%s', "
- "%d, %d, %d, "
+ "%d, %d,"
"$title_key, "
"'%s', '%s', $tag, '%s', %d, "
"'%s', '%s', "
"'%s', '%s', "
"%d, '%s', %d, '%s', %d, %d, %d, %d,"
"%d, %d, %d, "
- "$progress_size, $progress_percentage, %d, %d)",
+ "$progress_size, $progress_percentage, %d, %d, %d)",
noti->type,
noti->layout,
NOTIFICATION_CHECK_STR(noti->caller_pkgname),
NOTIFICATION_CHECK_STR(noti->launch_pkgname),
NOTIFICATION_CHECK_STR(b_image_path), noti->group_id,
- noti->internal_group_id, noti->priv_id,
+ noti->internal_group_id,
NOTIFICATION_CHECK_STR(b_text), NOTIFICATION_CHECK_STR(b_key),
NOTIFICATION_CHECK_STR(b_format_args), noti->num_format_args,
NOTIFICATION_CHECK_STR(noti->domain),
noti->led_off_ms,
noti->flags_for_property, flag_simmode, noti->display_applist,
noti->ongoing_flag,
- noti->auto_remove);
+ noti->auto_remove,
+ noti->uid);
/* Free decoded data */
if (args)
return err;
}
-static bool _is_allowed_to_notify(const char *caller_package_name)
+static bool _is_allowed_to_notify(const char *caller_package_name, uid_t uid)
{
notification_setting_h setting = NULL;
int err;
char *package_id = NULL;
bool ret = true;
- err = noti_setting_service_get_setting_by_package_name(caller_package_name, &setting);
+ err = noti_setting_service_get_setting_by_package_name(caller_package_name, &setting, uid);
if (err != NOTIFICATION_ERROR_NONE) {
/* Retry with package id */
err = _get_package_id_by_app_id(caller_package_name, &package_id);
NOTIFICATION_ERR("_get_package_id_by_app_id failed [%d]", err);
goto out;
} else {
- err = noti_setting_service_get_setting_by_package_name(package_id, &setting);
+ err = noti_setting_service_get_setting_by_package_name(package_id, &setting, uid);
if (err != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("noti_setting_service_get_setting_by_package_name failed [%d]", err);
goto out;
}
/* Get system setting */
- if ((err = noti_system_setting_load_system_setting(&system_setting)) != NOTIFICATION_ERROR_NONE) {
+ if ((err = noti_system_setting_load_system_setting(&system_setting, noti->uid)) != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("noti_system_setting_load_system_setting failed [%d]", err);
goto out;
}
if (do_not_disturb) {
/* Check exception option of the caller package */
- err = noti_setting_service_get_setting_by_package_name(noti->caller_pkgname, &setting);
+ err = noti_setting_service_get_setting_by_package_name(noti->caller_pkgname, &setting, noti->uid);
if (err != NOTIFICATION_ERROR_NONE) {
/* Retry with package id */
NOTIFICATION_ERR("_get_package_id_by_app_id failed [%d]", err);
goto out;
} else {
- err = noti_setting_service_get_setting_by_package_name(package_id, &setting);
+ err = noti_setting_service_get_setting_by_package_name(package_id, &setting, noti->uid);
if (err != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("noti_setting_service_get_setting_by_package_name failed [%d]", err);
goto out;
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (_is_allowed_to_notify((const char *)noti->caller_pkgname) == false) {
+ if (_is_allowed_to_notify((const char *)noti->caller_pkgname, noti->uid) == false) {
NOTIFICATION_DBG("[%s] is not allowed to notify", noti->caller_pkgname);
return NOTIFICATION_ERROR_PERMISSION_DENIED;
}
return get_last_result();
/* Initialize private ID */
- noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
noti->group_id = NOTIFICATION_GROUP_ID_NONE;
noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
return ret;
}
-EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id)
+EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id, uid_t uid)
{
int ret = 0;
char *query = NULL;
"from noti_list ";
if (pkgname != NULL && strlen(pkgname) != 0)
- query = sqlite3_mprintf("%s where caller_pkgname = '%s' and priv_id = %d",
- base_query, pkgname, priv_id);
+ query = sqlite3_mprintf("%s where caller_pkgname = '%s' and priv_id = %d and uid = %d",
+ base_query, pkgname, priv_id, uid);
else
- query = sqlite3_mprintf("%s where priv_id = %d", base_query, priv_id);
+ query = sqlite3_mprintf("%s where priv_id = %d and uid = %d", base_query, priv_id, uid);
if (query == NULL) {
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
return ret;
}
-EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, char* tag)
+EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, char* tag, uid_t uid)
{
int ret = 0;
sqlite3 *db = NULL;
"b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage, ongoing_flag, auto_remove "
- "from noti_list where caller_pkgname = ? and tag = ?", -1, &stmt, NULL);
+ "from noti_list where caller_pkgname = ? and tag = ? and uid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
goto err;
}
+
+ ret = sqlite3_bind_int(stmt, 3, uid);
+ if (ret != SQLITE_OK) {
+ NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
+ goto err;
+ }
+
} else {
ret = sqlite3_prepare_v2(db, "select "
"type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
"b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage, ongoing_flag, auto_remove "
- "from noti_list where tag = ?", -1, &stmt, NULL);
+ "from noti_list where tag = ? and uid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
goto err;
}
+
+ ret = sqlite3_bind_int(stmt, 2, uid);
+ if (ret != SQLITE_OK) {
+ NOTIFICATION_ERR("Error: %s\n", sqlite3_errmsg(db));
+ goto err;
+ }
}
ret = sqlite3_step(stmt);
if (!db)
return get_last_result();
- if (_is_allowed_to_notify((const char *)noti->caller_pkgname) == false) {
+ if (_is_allowed_to_notify((const char *)noti->caller_pkgname, noti->uid) == false) {
NOTIFICATION_DBG("[%s] is not allowed to notify", noti->caller_pkgname);
return NOTIFICATION_ERROR_PERMISSION_DENIED;
}
return ret;
}
-EXPORT_API int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid)
+EXPORT_API int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid, uid_t uid)
{
int ret = NOTIFICATION_ERROR_NONE;
int ret_tmp = NOTIFICATION_ERROR_NONE;
if (pkgname == NULL || strlen(pkgname) == 0) {
if (type != NOTIFICATION_TYPE_NONE)
snprintf(query_where, sizeof(query_where),
- "where type = %d ", type);
+ "where type = %d and uid = %d", type, uid);
} else {
if (type == NOTIFICATION_TYPE_NONE)
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' ", pkgname);
+ "where caller_pkgname = '%s' and uid = %d", pkgname, uid);
else
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and type = %d ",
- pkgname, type);
+ "where caller_pkgname = '%s' and type = %d and uid = %d",
+ pkgname, type, uid);
}
return ret;
}
-int notification_noti_delete_group_by_group_id(const char *pkgname,
- int group_id, int *num_deleted, int **list_deleted_rowid)
-{
- int ret = NOTIFICATION_ERROR_NONE;
- int ret_tmp = NOTIFICATION_ERROR_NONE;
- sqlite3 *db = NULL;
- int i = 0, data_cnt = 0;
- sqlite3_stmt *stmt = NULL;
- char buf[128] = { 0, };
- char query[NOTIFICATION_QUERY_MAX] = { 0, };
- char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
- char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
-
- /* Check pkgname is valid */
- if (pkgname == NULL)
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
- snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and group_id = %d", pkgname, group_id);
-
- /* Open DB */
- db = notification_db_open(DBPATH);
- if (!db)
- return get_last_result();
-
- if (num_deleted != NULL)
- *num_deleted = 0;
-
- if (list_deleted_rowid != NULL) {
- *list_deleted_rowid = NULL;
- snprintf(query, sizeof(query),
- "select priv_id from noti_list %s ", query_where);
-
- ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
- if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Select Query : %s", query);
- NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
- sqlite3_errmsg(db));
-
- ret = NOTIFICATION_ERROR_FROM_DB;
- goto err;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- if (data_cnt % 8 == 0) {
- int *tmp;
- tmp = (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
- if (tmp) {
- *list_deleted_rowid = tmp;
- } else {
- free(*list_deleted_rowid);
- *list_deleted_rowid = NULL;
- ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
- goto err;
- }
- }
- *((*list_deleted_rowid) + data_cnt) = sqlite3_column_int(stmt, 0);
- data_cnt++;
- }
-
- if (stmt) {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- if (data_cnt > 0) {
- query_where[0] = '\0';
- snprintf(query_base, sizeof(query_base) - 1, "delete from noti_list");
- for (i = 0; i < data_cnt ; i++) {
- if (i % NOTI_BURST_DELETE_UNIT == 0 && i != 0) {
- snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where);
- ret_tmp = notification_db_exec(db, query, NULL);
- query_where[0] = '\0';
- if (ret == NOTIFICATION_ERROR_NONE)
- ret = ret_tmp;
- }
- snprintf(buf, sizeof(buf) - 1, "%s%d", (i % NOTI_BURST_DELETE_UNIT == 0) ? "" : ",", *((*list_deleted_rowid) + i));
- strncat(query_where, buf, sizeof(query_where) - strlen(query_where) - 1);
- }
- if ((i <= NOTI_BURST_DELETE_UNIT) || ((i % NOTI_BURST_DELETE_UNIT) > 0)) {
- snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where);
- ret_tmp = notification_db_exec(db, query, NULL);
- if (ret == NOTIFICATION_ERROR_NONE)
- ret = ret_tmp;
- }
- } else {
- free(*list_deleted_rowid);
- *list_deleted_rowid = NULL;
- }
-
- if (num_deleted != NULL)
- *num_deleted = data_cnt;
-
- } else {
- /* Make query */
- snprintf(query, sizeof(query), "delete from noti_list %s", query_where);
-
- /* execute DB */
- ret = notification_db_exec(db, query, NULL);
- }
-
-err:
- if (stmt)
- sqlite3_finalize(stmt);
-
- /* Close DB */
- if (db)
- notification_db_close(&db);
-
- return ret;
-}
-
-int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id)
-{
- sqlite3 *db = NULL;
- char query[NOTIFICATION_QUERY_MAX] = { 0, };
- int internal_group_id = 0;
- int ret;
-
- /* Check pkgname is valid */
- if (pkgname == NULL)
- return NOTIFICATION_ERROR_INVALID_PARAMETER;
-
- /* Open DB */
- db = notification_db_open(DBPATH);
- if (!db)
- return get_last_result();
-
- /* Get internal group id using priv id */
- internal_group_id =
- _notification_noti_get_internal_group_id_by_priv_id(pkgname,
- priv_id, db);
-
- /* Make query */
- snprintf(query, sizeof(query), "delete from noti_list "
- "where caller_pkgname = '%s' and internal_group_id = %d",
- pkgname, internal_group_id);
-
- /* execute DB */
- ret = notification_db_exec(db, query, NULL);
-
- /* Close DB */
- notification_db_close(&db);
-
- return ret;
-}
-
EXPORT_API int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id)
{
sqlite3 *db = NULL;
return ret;
}
-EXPORT_API int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes)
+EXPORT_API int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes, uid_t uid)
{
sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = {0, };
/* Make query */
snprintf(query, sizeof(query), "delete from noti_list "
- "where caller_pkgname = '%s' and priv_id = %d", pkgname,
- priv_id);
+ "where caller_pkgname = '%s' and priv_id = %d and uid = %d", pkgname,
+ priv_id, uid);
NOTIFICATION_DBG("%s", query);
/* execute DB */
return ret;
}
+/* todo refactoring */
EXPORT_API int notification_noti_get_count(notification_type_e type,
const char *pkgname,
int group_id, int priv_id,
- int *count)
+ int *count, uid_t uid)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
int ret = 0, get_count = 0, internal_group_id = 0;
int status = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
- int flag_where = 0;
int flag_where_more = 0;
int ret_vconf = 0;
if (group_id == NOTIFICATION_GROUP_ID_NONE) {
if (priv_id == NOTIFICATION_PRIV_ID_NONE) {
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' ",
- pkgname);
- flag_where = 1;
+ "where caller_pkgname = '%s' and uid = %d ",
+ pkgname, uid);
} else {
internal_group_id =
_notification_noti_get_internal_group_id_by_priv_id
(pkgname, priv_id, db);
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and internal_group_id = %d ",
- pkgname, internal_group_id);
- flag_where = 1;
+ "where caller_pkgname = '%s' and internal_group_id = %d and uid = %d ",
+ pkgname, internal_group_id, uid);
}
} else {
if (priv_id == NOTIFICATION_PRIV_ID_NONE) {
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and group_id = %d ",
- pkgname, group_id);
- flag_where = 1;
+ "where caller_pkgname = '%s' and group_id = %d and uid = %d ",
+ pkgname, group_id, uid);
} else {
internal_group_id =
_notification_noti_get_internal_group_id_by_priv_id
(pkgname, priv_id, db);
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and internal_group_id = %d ",
- pkgname, internal_group_id);
- flag_where = 1;
+ "where caller_pkgname = '%s' and internal_group_id = %d and uid = %d ",
+ pkgname, internal_group_id, uid);
}
}
-
+ } else {
+ snprintf(query_where, sizeof(query_where), "where uid = %d", uid);
}
if (ret_vconf == 0 && status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
}
}
- if (flag_where == 1) {
- if (flag_where_more == 1) {
- snprintf(query, sizeof(query), "%s %s and %s",
- query_base, query_where, query_where_more);
- } else {
- snprintf(query, sizeof(query), "%s %s", query_base,
- query_where);
- }
-
+ if (flag_where_more == 1) {
+ snprintf(query, sizeof(query), "%s %s and %s",
+ query_base, query_where, query_where_more);
} else {
- if (flag_where_more == 1) {
- snprintf(query, sizeof(query), "%s where %s",
- query_base, query_where_more);
- } else {
- snprintf(query, sizeof(query), "%s", query_base);
- }
+ snprintf(query, sizeof(query), "%s %s", query_base,
+ query_where);
}
ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
EXPORT_API int notification_noti_get_grouping_list(notification_type_e type,
int count,
- notification_list_h *
- list)
+ notification_list_h *list,
+ uid_t uid)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
+ char query_uid[NOTIFICATION_QUERY_MAX] = { 0, };
char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
int ret = 0;
"b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage, ongoing_flag, auto_remove "
- "from noti_list ");
+ "from noti_list where 1 > 0 ");
if (status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
if (type != NOTIFICATION_TYPE_NONE)
snprintf(query_where, sizeof(query_where),
- "where type = %d ", type);
+ " and type = %d ", type);
} else {
if (type != NOTIFICATION_TYPE_NONE)
snprintf(query_where, sizeof(query_where),
- "where type = %d and flag_simmode = 0 ", type);
+ " and type = %d and flag_simmode = 0 ", type);
else
snprintf(query_where, sizeof(query_where),
- "where flag_simmode = 0 ");
+ " and flag_simmode = 0 ");
}
+ if (uid != NOTIFICATION_GLOBAL_UID)
+ snprintf(query_uid, sizeof(query_uid), " and uid = %d ", uid);
+
snprintf(query, sizeof(query),
- "%s %s "
+ "%s %s %s "
"group by internal_group_id "
- "order by rowid desc, time desc", query_base, query_where);
+ "order by rowid desc, time desc", query_base, query_where, query_uid);
ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
if (ret != SQLITE_OK) {
if (get_list != NULL)
*list = notification_list_get_head(get_list);
-
return ret;
}
EXPORT_API int notification_noti_get_detail_list(const char *pkgname,
int group_id,
int priv_id, int count,
- notification_list_h *list)
+ notification_list_h *list,
+ uid_t uid)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
if (priv_id == NOTIFICATION_PRIV_ID_NONE && group_id == NOTIFICATION_GROUP_ID_NONE) {
if (status == VCONFKEY_TELEPHONY_SIM_INSERTED)
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' ", pkgname);
+ "where caller_pkgname = '%s' and uid = %d ", pkgname, uid);
else
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and flag_simmode = 0 ", pkgname);
+ "where caller_pkgname = '%s' and flag_simmode = 0 and uid = %d ", pkgname, uid);
} else {
internal_group_id =
if (status == VCONFKEY_TELEPHONY_SIM_INSERTED)
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and internal_group_id = %d ",
- pkgname, internal_group_id);
+ "where caller_pkgname = '%s' and internal_group_id = %d and uid = %d ",
+ pkgname, internal_group_id, uid);
else
snprintf(query_where, sizeof(query_where),
- "where caller_pkgname = '%s' and internal_group_id = %d and flag_simmode = 0 ",
- pkgname, internal_group_id);
+ "where caller_pkgname = '%s' and internal_group_id = %d and flag_simmode = 0 and uid = %d ",
+ pkgname, internal_group_id, uid);
}
snprintf(query, sizeof(query),
#define NOTIFICATION_PRIVILEGE "http://tizen.org/privilege/notification"
-EXPORT_API int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count)
+typedef struct {
+ uid_t uid;
+ sqlite3 *db;
+} setting_local_info;
+
+EXPORT_API int notification_setting_get_setting_array_for_uid(notification_setting_h *setting_array, int *count, uid_t uid)
{
int ret = NOTIFICATION_ERROR_NONE;
if (setting_array == NULL || count == NULL) {
NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- ret = notification_ipc_request_get_setting_array(setting_array, count);
+ ret = notification_ipc_request_get_setting_array(setting_array, count, uid);
return ret;
}
-EXPORT_API int notification_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *setting)
+EXPORT_API int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count)
+{
+ return notification_setting_get_setting_array_for_uid(setting_array, count, getuid());
+}
+
+EXPORT_API int notification_setting_get_setting_by_package_name_for_uid(const char *package_name, notification_setting_h *setting, uid_t uid)
{
int ret = NOTIFICATION_ERROR_NONE;
if (package_name == NULL || setting == NULL) {
NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- ret = notification_ipc_request_get_setting_by_package_name(package_name, setting);
+ ret = notification_ipc_request_get_setting_by_package_name(package_name, setting, uid);
return ret;
}
+EXPORT_API int notification_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *setting)
+{
+ return notification_setting_get_setting_by_package_name_for_uid(package_name, setting, getuid());
+}
+
EXPORT_API int notification_setting_get_setting(notification_setting_h *setting)
{
int ret;
return err;
}
-EXPORT_API int notification_setting_update_setting(notification_setting_h setting)
+EXPORT_API int notification_setting_update_setting_for_uid(notification_setting_h setting, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
goto out;
}
- err = notification_ipc_update_setting(setting);
+ err = notification_ipc_update_setting(setting, uid);
if (err != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("notification_setting_update_setting returns[%d]\n", err);
goto out;
return err;
}
+EXPORT_API int notification_setting_update_setting(notification_setting_h setting)
+{
+ return notification_setting_update_setting_for_uid(setting, getuid());
+}
+
EXPORT_API int notification_setting_free_notification(notification_setting_h setting)
{
int err = NOTIFICATION_ERROR_NONE;
return err;
}
-EXPORT_API int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class)
+EXPORT_API int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
sqlite3 *db = NULL;
}
sqlbuf = sqlite3_mprintf("UPDATE %s SET allow_to_notify = %d, do_not_disturb_except = %d, visibility_class = %d " \
- "WHERE package_name = %Q",
- NOTIFICATION_SETTING_DB_TABLE, allow_to_notify, do_not_disturb_except, visibility_class, package_name);
+ "WHERE package_name = %Q AND uid = %d",
+ NOTIFICATION_SETTING_DB_TABLE, allow_to_notify, do_not_disturb_except, visibility_class, package_name, uid);
if (!sqlbuf) {
NOTIFICATION_ERR("fail to alloc query");
err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
return err;
}
-static bool _is_package_in_setting_table(sqlite3 *db, const char *package_name)
+static bool _is_package_in_setting_table(sqlite3 *db, const char *package_name, uid_t uid)
{
sqlite3_stmt *db_statement = NULL;
int sqlite3_ret = SQLITE_OK;
bool err = true;
int field_index = 1;
- sqlite3_ret = sqlite3_prepare_v2(db, "SELECT package_name FROM notification_setting WHERE package_name = ?", -1, &db_statement, NULL);
+ sqlite3_ret = sqlite3_prepare_v2(db, "SELECT package_name FROM notification_setting WHERE uid = ? AND package_name = ?", -1, &db_statement, NULL);
if (sqlite3_ret != SQLITE_OK) {
NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
goto out;
}
+ sqlite3_bind_int(db_statement, field_index++, uid);
sqlite3_bind_text(db_statement, field_index++, package_name, -1, SQLITE_TRANSIENT);
sqlite3_ret = sqlite3_step(db_statement);
static int foreach_package_info_callback(const pkgmgrinfo_pkginfo_h package_info, void *user_data)
{
- sqlite3 *db = user_data;
+ setting_local_info *info = (setting_local_info *)user_data;
+ sqlite3 *db = info->db;
sqlite3_stmt *db_statement = NULL;
char *package_name = NULL;
int pkgmgr_ret = PACKAGE_MANAGER_ERROR_NONE;
goto out;
}
- if (_is_package_in_setting_table(db, package_name) == true) {
- NOTIFICATION_INFO("[%s] is exist", package_name);
+ if (_is_package_in_setting_table(db, package_name, info->uid) == true) {
+ NOTIFICATION_INFO("uid %d [%s] is exist", info->uid, package_name);
goto out;
}
- NOTIFICATION_INFO("[%s] will be inserted", package_name);
-
- sqlite3_ret = sqlite3_prepare_v2(db, "INSERT INTO notification_setting (package_name) VALUES (?) ", -1, &db_statement, NULL);
+ NOTIFICATION_INFO("uid %d [%s] will be inserted", info->uid, package_name);
+ sqlite3_ret = sqlite3_prepare_v2(db, "INSERT INTO notification_setting (uid, package_name) VALUES (?, ?) ", -1, &db_statement, NULL);
if (sqlite3_ret != SQLITE_OK) {
NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
goto out;
}
+ sqlite3_bind_int(db_statement, field_index++, info->uid);
sqlite3_bind_text(db_statement, field_index++, package_name, -1, SQLITE_TRANSIENT);
sqlite3_ret = sqlite3_step(db_statement);
return err;
}
-EXPORT_API int notification_setting_refresh_setting_table()
+EXPORT_API int notification_setting_refresh_setting_table(uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
sqlite3 *db = NULL;
int sqlite3_ret = SQLITE_OK;
int pkgmgr_ret = PACKAGE_MANAGER_ERROR_NONE;
pkgmgrinfo_pkginfo_filter_h filter;
+ setting_local_info info;
+ NOTIFICATION_ERR("refresh seeting table [%d]", uid);
sqlite3_ret = db_util_open(DBPATH, &db, 0);
if (sqlite3_ret != SQLITE_OK || db == NULL) {
goto out;
}
- /*
- * DEFAULT_UID is owner's uid(5001)
- * currently this api do not support multi-user.
- */
- pkgmgr_ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(filter, foreach_package_info_callback, db, tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+ info.db = db;
+ info.uid = uid;
+ pkgmgr_ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(filter, foreach_package_info_callback, &info, uid);
if (pkgmgr_ret != PMINFO_R_OK) {
NOTIFICATION_ERR("pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo failed [%d]", pkgmgr_ret);
err = NOTIFICATION_ERROR_FROM_DB;
OPERATION_TYPE_DELETE_RECORD = 1,
} notification_setting_operation_type;
-static int _notification_setting_alter_package_list(notification_setting_operation_type operation_type, const char *package_name)
+static int _notification_setting_alter_package_list(notification_setting_operation_type operation_type, const char *package_name, uid_t uid)
{
sqlite3 *db = NULL;
sqlite3_stmt *db_statement = NULL;
sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
- is_package_in_setting_table = _is_package_in_setting_table(db, package_name);
+ is_package_in_setting_table = _is_package_in_setting_table(db, package_name, uid);
switch (operation_type) {
case OPERATION_TYPE_INSERT_RECORD:
goto out;
}
NOTIFICATION_INFO("[%s] will be inserted", package_name);
- sqlite3_ret = sqlite3_prepare_v2(db, "INSERT INTO notification_setting (package_name) VALUES (?) ", -1, &db_statement, NULL);
+ sqlite3_ret = sqlite3_prepare_v2(db, "INSERT INTO notification_setting (uid, package_name) VALUES (?, ?) ", -1, &db_statement, NULL);
break;
case OPERATION_TYPE_DELETE_RECORD:
goto out;
}
NOTIFICATION_INFO("[%s] will be removed", package_name);
- sqlite3_ret = sqlite3_prepare_v2(db, "DELETE FROM notification_setting WHERE package_name = ? ", -1, &db_statement, NULL);
+ sqlite3_ret = sqlite3_prepare_v2(db, "DELETE FROM notification_setting WHERE uid = ? AND package_name = ? ", -1, &db_statement, NULL);
break;
default:
break;
goto out;
}
+ sqlite3_bind_int(db_statement, field_index++, uid);
sqlite3_bind_text(db_statement, field_index++, package_name, -1, SQLITE_TRANSIENT);
sqlite3_ret = sqlite3_step(db_statement);
return true;
}
-static bool _has_privilege(const char *package_id)
-{
- bool found = false;
- int error_from_package_info = PACKAGE_MANAGER_ERROR_NONE;
- package_info_h package_info = NULL;
-
- error_from_package_info = package_info_create(package_id, &package_info);
- if (error_from_package_info != PACKAGE_MANAGER_ERROR_NONE) {
- NOTIFICATION_ERR("package_info_create failed [%d]", error_from_package_info);
- goto out;
- }
-
- error_from_package_info = package_info_foreach_privilege_info(package_info, privilege_info_cb, &found);
-
- if (error_from_package_info != PACKAGE_MANAGER_ERROR_NONE) {
- NOTIFICATION_ERR("package_info_foreach_privilege_info failed [%d]", error_from_package_info);
- goto out;
- }
-
-out:
-
- if (package_info)
- package_info_destroy(package_info);
-
- return found;
-}
-
-EXPORT_API int notification_setting_insert_package(const char *package_id)
+EXPORT_API int notification_setting_insert_package_for_uid(const char *package_id, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
-
- if (_has_privilege(package_id) == true)
- err = _notification_setting_alter_package_list(OPERATION_TYPE_INSERT_RECORD, package_id);
+ err = _notification_setting_alter_package_list(OPERATION_TYPE_INSERT_RECORD, package_id, uid);
return err;
}
-EXPORT_API int notification_setting_delete_package(const char *package_id)
+EXPORT_API int notification_setting_delete_package_for_uid(const char *package_id, uid_t uid)
{
- return _notification_setting_alter_package_list(OPERATION_TYPE_DELETE_RECORD, package_id);
+ return _notification_setting_alter_package_list(OPERATION_TYPE_DELETE_RECORD, package_id, uid);
}
/* system setting --------------------------------*/
-EXPORT_API int notification_system_setting_load_system_setting(notification_system_setting_h *system_setting)
+EXPORT_API int notification_system_setting_load_system_setting_for_uid(notification_system_setting_h *system_setting, uid_t uid)
{
int ret = NOTIFICATION_ERROR_NONE;
if (system_setting == NULL) {
NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- ret = notification_ipc_request_load_system_setting(system_setting);
+ ret = notification_ipc_request_load_system_setting(system_setting, uid);
return ret;
}
-EXPORT_API int notification_system_setting_update_system_setting(notification_system_setting_h system_setting)
+EXPORT_API int notification_system_setting_load_system_setting(notification_system_setting_h *system_setting)
+{
+ return notification_system_setting_load_system_setting_for_uid(system_setting, getuid());
+}
+
+EXPORT_API int notification_system_setting_update_system_setting_for_uid(notification_system_setting_h system_setting, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
goto out;
}
- err = notification_ipc_update_system_setting(system_setting);
+ err = notification_ipc_update_system_setting(system_setting, uid);
if (err != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("notification_ipc_update_system_setting returns[%d]\n", err);
goto out;
return err;
}
+EXPORT_API int notification_system_setting_update_system_setting(notification_system_setting_h system_setting)
+{
+ return notification_system_setting_update_system_setting_for_uid(system_setting, getuid());
+}
+
EXPORT_API int notification_system_setting_free_system_setting(notification_system_setting_h system_setting)
{
int err = NOTIFICATION_ERROR_NONE;
}
-EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class)
+EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
int sqlret;
sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
- sqlret = sqlite3_prepare_v2(db, "UPDATE notification_system_setting SET do_not_disturb = ?, visibility_class = ?;", -1, &db_statement, NULL);
+ sqlret = sqlite3_prepare_v2(db, "INSERT OR REPLACE notification_system_setting SET do_not_disturb = ?, visibility_class = ? WHERE uid = ?;", -1, &db_statement, NULL);
if (sqlret != SQLITE_OK) {
NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlret, sqlite3_errmsg(db));
sqlite3_bind_int(db_statement, field_index++, do_not_disturb);
sqlite3_bind_int(db_statement, field_index++, visibility_class);
+ sqlite3_bind_int(db_statement, field_index++, uid);
sqlret = sqlite3_step(db_statement);
return ret;
}
-EXPORT_API int noti_setting_service_get_setting_by_package_name(const char *package_name, notification_setting_h *setting)
+EXPORT_API int noti_setting_service_get_setting_by_package_name(const char *package_name, notification_setting_h *setting, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
sqlite3 *local_db_handle = NULL;
sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class "
"FROM %s "
- "WHERE package_name = %Q ", NOTIFICATION_SETTING_DB_TABLE, package_name);
+ "WHERE package_name = %Q AND uid = %d", NOTIFICATION_SETTING_DB_TABLE, package_name, uid);
if (!sql_query) {
NOTIFICATION_ERR("fail to alloc query");
-EXPORT_API int noti_setting_get_setting_array(notification_setting_h *setting_array, int *count)
+EXPORT_API int noti_setting_get_setting_array(notification_setting_h *setting_array, int *count, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
sqlite3 *local_db_handle = NULL;
}
sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class "
- "FROM %s "
- "ORDER BY package_name", NOTIFICATION_SETTING_DB_TABLE);
+ "FROM %s WHERE uid = %d "
+ "ORDER BY package_name", NOTIFICATION_SETTING_DB_TABLE, uid);
if (!sql_query) {
NOTIFICATION_ERR("fail to alloc query");
}
-EXPORT_API int noti_system_setting_load_system_setting(notification_system_setting_h *system_setting)
+EXPORT_API int noti_system_setting_load_system_setting(notification_system_setting_h *system_setting, uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
sqlite3 *local_db_handle = NULL;
}
sql_query = sqlite3_mprintf("SELECT do_not_disturb, visibility_class "
- "FROM %s ", NOTIFICATION_SYSTEM_SETTING_DB_TABLE);
+ "FROM %s WHERE uid = %d", NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
if (!sql_query) {
NOTIFICATION_ERR("fail to alloc query");
goto out;
}
- if (!row_count) {
- NOTIFICATION_DBG("No setting found...");
- err = NOTIFICATION_ERROR_NOT_EXIST_ID;
- goto out;
- }
-
NOTIFICATION_DBG("row_count [%d] column_count [%d]", row_count, column_count);
-
- row_count = 1;
-
if (!(result_system_setting = (struct notification_system_setting *)malloc(sizeof(struct notification_system_setting)))) {
NOTIFICATION_ERR("malloc failed...");
err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
}
- col_index = column_count;
-
- _get_table_field_data_int(query_result, (int *)&(result_system_setting->do_not_disturb), col_index++);
- _get_table_field_data_int(query_result, &(result_system_setting->visibility_class), col_index++);
+ /* no system setting record. allow everyting */
+ if (!row_count) {
+ NOTIFICATION_DBG("No setting found...");
+ result_system_setting->do_not_disturb = 0;
+ result_system_setting->visibility_class = 0;
+ } else {
+ col_index = column_count;
+ _get_table_field_data_int(query_result, (int *)&(result_system_setting->do_not_disturb), col_index++);
+ _get_table_field_data_int(query_result, &(result_system_setting->visibility_class), col_index++);
+ }
*system_setting = result_system_setting;
-
out:
if (query_result)
sqlite3_free_table(query_result);
ADD_EXECUTABLE(notification-test-app ${TEST-APP-SRCS})
TARGET_LINK_LIBRARIES(notification-test-app ${test_app_pkgs_LDFLAGS} notification)
-# INSTALL(TARGETS notification-test-app DESTINATION bin)
+#INSTALL(TARGETS notification-test-app DESTINATION bin)
testapp_print(" 7. Post a notification with domain text\n");
testapp_print(" 8. Load by tag\n");
testapp_print(" 9. Get list\n");
+ testapp_print(" 10. Post noti to 5002 \n");
testapp_print("------------------------------------------\n");
break;
case TESTAPP_MENU_TYPE_SETTING_TEST_MENU:
}
/* Common { ------------------------------------------------------------------*/
+
+static int testapp_add_a_notification_to_bob()
+{
+ notification_h noti_handle = NULL;
+ int noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
+
+ if (noti_handle == NULL) {
+ testapp_print("notification_create failed");
+ goto FINISH_OFF;
+ }
+
+ 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", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "3", "3", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_1, "I'm Info 1", "INFO_1", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, "I'm Info Sub 1", "INFO_SUB_1", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_2, "I'm Info 2", "INFO_2", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, "I'm Info Sub 2", "INFO_SUB_2", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_3, "I'm Info 3", "INFO_3", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, "I'm Info Sub 3", "INFO_SUB_3", NOTIFICATION_VARIABLE_TYPE_NONE);
+
+ noti_err = notification_set_ongoing_flag(noti_handle, true);
+ noti_err = notification_set_auto_remove(noti_handle, false);
+
+ noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER);
+
+ noti_err = notification_post_for_uid(noti_handle, 5002);
+
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ testapp_print("notification_post failed[%d]", noti_err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ if (noti_handle)
+ notification_free(noti_handle);
+
+ return noti_err;
+}
+
+
static int testapp_add_a_notification()
{
notification_h noti_handle = NULL;
case 9:
testapp_test_get_list();
break;
+ case 10:
+ testapp_add_a_notification_to_bob();
+ break;
case 0:
go_to_loop = FALSE;
static int testapp_test_refresh_setting_table()
{
int err = NOTIFICATION_ERROR_NONE;
- err = notification_setting_refresh_setting_table();
+ err = notification_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
if (err != NOTIFICATION_ERROR_NONE) {
testapp_print("notification_setting_refresh_setting_table failed [%d]\n", err);