<allow own_prefix="org.tizen.notification_ex"/>
<allow send_type="signal" send_interface="org.tizen.data_provider_noti_service"/>
<allow send_type="signal" send_interface="org.tizen.data_provider_noti_event_service"/>
- <allow send_type="signal" send_interface="org.tizen.data_provider_badge_service"/>
- <allow send_type="signal" send_interface="org.tizen.data_provider_shortcut_service"/>
</policy>
<policy user="root">
<allow send_type="signal" send_interface="org.tizen.notification_ex"/>
<check send_type="method_call" send_destination="org.tizen.data_provider_service" send_interface="org.tizen.data_provider_noti_service" privilege="http://tizen.org/privilege/notification"/>
<check send_type="method_call" send_destination="org.tizen.notification_ex._data-provider-master" send_interface="org.tizen.notification_ex" privilege="http://tizen.org/privilege/notification"/>
- <check send_destination="org.tizen.data_provider_service" send_interface="org.tizen.data_provider_badge_service" privilege="http://tizen.org/privilege/notification"/>
- <check send_destination="org.tizen.data_provider_service" send_interface="org.tizen.data_provider_shortcut_service" privilege="http://tizen.org/privilege/shortcut"/>
<deny send_type="method_call" send_destination="org.tizen.data_provider_service" send_path="/org/tizen/notification_ex_reporter" send_interface="org.tizen.notification_ex"/>
</policy>
</busconfig>
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <gio/gio.h>
-#include <sys/types.h>
-
-#ifndef BADGE_SERVICE_H_
-#define BADGE_SERVICE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int badge_service_init(void);
-int badge_service_fini(void);
-
-int badge_get_badge_existing(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_get_badge_list(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_insert(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_delete(GVariant *parameters, GVariant **reply_body, uid_t uid, pid_t pid);
-int badge_set_badge_count(GVariant *parameters, GVariant **reply_body, uid_t uid, pid_t pid);
-int badge_get_badge_count(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_set_display_option(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_get_display_option(GVariant *parameters, GVariant **reply_body, const gchar *sender, uid_t uid);
-int badge_update_badge_setting(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_get_setting_by_appid(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_init_display(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int badge_register_dbus_interface();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // BADGE_SERVICE_H_
#include <gio/gio.h>
#include <notification.h>
-#include <badge.h>
-#include <shortcut.h>
#include <stdlib.h>
#ifndef SERVICE_COMMON_H_
typedef enum {
NOTIFICATION_SERVICE = 0,
- SHORTCUT_SERVICE,
- BADGE_SERVICE,
} service_type;
enum service_common_error {
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <gio/gio.h>
-
-#ifndef SHORTCUT_SERVICE_H_
-#define SHORTCUT_SERVICE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int shortcut_service_init(void);
-int shortcut_service_fini(void);
-
-void shortcut_add(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid);
-void shortcut_add_widget(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid);
-void shortcut_remove(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid);
-int shortcut_register_dbus_interface();
-int shortcut_get_shortcut_service_list(GVariant *parameters, GVariant **reply_body, uid_t uid);
-int shortcut_check_privilege(void);
-int shortcut_send_return_value(GVariant *parameters, GVariant **reply_body);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //SHORTCUT_SERVICE_H_
\ No newline at end of file
%bcond_with wayland
Name: data-provider-master
-Summary: Master service provider for badge, shortcut, notification
+Summary: Master service provider for notification
Version: 1.6.34
Release: 1
Group: Applications/Core Applications
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(notification-ex)
-BuildRequires: pkgconfig(badge)
-BuildRequires: pkgconfig(shortcut)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(libtzplatform-config)
pkgmgr
notification
notification-ex
- badge
libsmack
- shortcut
pkgmgr-info
libsystemd
capi-appfw-app-manager
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <dlog.h>
-#include <gio/gio.h>
-#include <sys/smack.h>
-#include <badge.h>
-#include <badge_db.h>
-#include <badge_internal.h>
-#include <badge_setting.h>
-#include <badge_setting_service.h>
-#include <badge_ipc.h>
-#include <tzplatform_config.h>
-
-#include "service_common.h"
-#include "badge_service.h"
-#include "debug.h"
-
-#define PROVIDER_BADGE_INTERFACE_NAME "org.tizen.data_provider_badge_service"
-static GHashTable *_monitoring_hash;
-
-static void _on_name_appeared(GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
- gpointer user_data)
-{
- DBG("name [%s]", name);
-}
-
-static void _on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- DBG("name [%s]", name);
- monitoring_info_s *info = (monitoring_info_s *)user_data;
-
- if (info) {
- DBG("vanished uid [%d]", info->uid);
- g_bus_unwatch_name(info->watcher_id);
- delete_monitoring_list(&_monitoring_hash, name, info->uid);
-
- if (info->bus_name)
- free(info->bus_name);
- free(info);
- }
-}
-
-static void _badge_dbus_method_call_handler(GDBusConnection *conn,
- const gchar *sender, const gchar *object_path,
- const gchar *iface_name, const gchar *method_name,
- GVariant *parameters, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- DBG("badge method_name [%s]", method_name);
-
- GVariant *reply_body = NULL;
- int ret = BADGE_ERROR_INVALID_PARAMETER;
- uid_t uid = get_sender_uid(sender);
- pid_t pid = get_sender_pid(sender);
-
- if (g_strcmp0(method_name, "badge_service_register") == 0)
- ret = service_register(parameters, &reply_body, sender,
- _on_name_appeared, _on_name_vanished, &_monitoring_hash, uid);
- else if (g_strcmp0(method_name, "get_badge_existing") == 0)
- ret = badge_get_badge_existing(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "get_list") == 0)
- ret = badge_get_badge_list(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "insert_badge") == 0)
- ret = badge_insert(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "delete_badge") == 0)
- ret = badge_delete(parameters, &reply_body, uid, pid);
- else if (g_strcmp0(method_name, "set_badge_count") == 0)
- ret = badge_set_badge_count(parameters, &reply_body, uid, pid);
- else if (g_strcmp0(method_name, "get_badge_count") == 0)
- ret = badge_get_badge_count(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "set_disp_option") == 0)
- ret = badge_set_display_option(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "get_disp_option") == 0)
- ret = badge_get_display_option(parameters, &reply_body, sender, uid);
- else if (g_strcmp0(method_name, "update_badge_setting") == 0)
- ret = badge_update_badge_setting(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "get_setting_by_appid") == 0)
- ret = badge_get_setting_by_appid(parameters, &reply_body, uid);
- else if (g_strcmp0(method_name, "init_badge") == 0)
- ret = badge_init_display(parameters, &reply_body, uid);
-
- if (ret == BADGE_ERROR_NONE) {
- DBG("Badge service success, method [%s]", method_name);
- g_dbus_method_invocation_return_value(
- invocation, reply_body);
- } else {
- ERR("Badge service fail, method_name[%s] err[%d]",
- method_name, ret);
- g_dbus_method_invocation_return_error(
- invocation,
- BADGE_ERROR,
- ret,
- "badge service error");
- }
-}
-
-static const GDBusInterfaceVTable _badge_interface_vtable = {
- _badge_dbus_method_call_handler,
- NULL,
- NULL
-};
-
-int badge_register_dbus_interface(void)
-{
- static gchar introspection_xml[] =
- " <node>"
- " <interface name='org.tizen.data_provider_badge_service'>"
- " <method name='badge_service_register'>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='get_badge_existing'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='i' name='exist' direction='out'/>"
- " </method>"
-
- " <method name='get_list'>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='a(v)' name='badge_list' direction='out'/>"
- " </method>"
-
- " <method name='insert_badge'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='s' name='writable_pkg' direction='in'/>"
- " <arg type='s' name='caller' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='delete_badge'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='s' name='caller' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='set_badge_count'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='s' name='caller' direction='in'/>"
- " <arg type='i' name='count' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='get_badge_count'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='i' name='count' direction='out'/>"
- " </method>"
-
- " <method name='set_disp_option'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='s' name='caller' direction='in'/>"
- " <arg type='i' name='is_display' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='get_disp_option'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='i' name='is_display' direction='out'/>"
- " </method>"
-
- " <method name='update_badge_setting'>"
- " <arg type='s' name='pkgname' direction='in'/>"
- " <arg type='s' name='appid' direction='in'/>"
- " <arg type='i' name='allow_to_display' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='get_setting_by_appid'>"
- " <arg type='s' name='appid' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='v' name='setting' direction='out'/>"
- " </method>"
-
- " <method name='init_badge'>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " </interface>"
- " </node>";
-
- return service_common_register_dbus_interface(introspection_xml, _badge_interface_vtable);
-}
-
-static int _validate_and_set_param_uid_with_uid(uid_t uid, uid_t *param_uid)
-{
- if (uid > NORMAL_UID_BASE && uid != *param_uid) {
- ERR("Invalid sender uid[%d] param_uid[%d]", uid, *param_uid);
- return BADGE_ERROR_INVALID_PARAMETER;
- } else if (uid <= NORMAL_UID_BASE) {
- if (*param_uid <= NORMAL_UID_BASE) {
- if (*param_uid != uid)
- return BADGE_ERROR_INVALID_PARAMETER;
- *param_uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
- }
- }
- return BADGE_ERROR_NONE;
-}
-
-static void _release_badge_info(gpointer data)
-{
- badge_info_s *badge;
-
- badge = (badge_info_s *)data;
- if (badge == NULL)
- return;
- if (badge->pkg)
- free(badge->pkg);
- free(badge);
-}
-
-/* get_badge_existing */
-int badge_get_badge_existing(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- bool existing = 0;
- uid_t param_uid;
-
- g_variant_get(parameters, "(&si)", &pkgname, ¶m_uid);
-
- if (pkgname == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_is_existing(pkgname, &existing, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get badge existing :%d", ret);
- return ret;
- }
- INFO("The badge of [%s] exists", pkgname);
-
- *reply_body = g_variant_new("(i)", existing);
- if (*reply_body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- DBG("result [%d]", ret);
- return ret;
-}
-
-/* get_list */
-int badge_get_badge_list(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- GList *badge_list = NULL;
- GList *iter_list = NULL;
- GVariant *body = NULL;
- badge_info_s *badge;
- GVariantBuilder *builder;
- int ret;
- uid_t param_uid;
-
- g_variant_get(parameters, "(i)", ¶m_uid);
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_get_list(&badge_list, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get list [%d]", ret);
- return ret;
- }
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
- iter_list = g_list_first(badge_list);
- for (; iter_list != NULL; iter_list = iter_list->next) {
- badge = iter_list->data;
- body = g_variant_new("(si)", badge->pkg, badge->badge_count);
- g_variant_builder_add(builder, "(v)", body);
- }
- g_list_free_full(badge_list, (GDestroyNotify)_release_badge_info);
-
- *reply_body = g_variant_new("(a(v))", builder);
- g_variant_builder_unref(builder);
-
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- DBG("Success to get badge list");
- return BADGE_ERROR_NONE;
-}
-
-/* insert_badge */
-int badge_insert(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- char *writable_pkg = NULL;
- char *caller = NULL;
- GVariant *body = NULL;
- uid_t param_uid;
- int allow_to_display = 0;
-
- g_variant_get(parameters, "(&s&s&si)", &pkgname, &writable_pkg, &caller, ¶m_uid);
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- if (pkgname != NULL && writable_pkg != NULL && caller != NULL)
- ret = badge_db_insert(pkgname, writable_pkg, caller, param_uid);
- else
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to insert badge [%d]", ret);
- return ret;
- }
-
- ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get allow_to_display by appid [%d]", ret);
- return ret;
- }
-
- if (allow_to_display) {
- body = g_variant_new("(si)", pkgname, param_uid);
- if (body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- ret = send_notify(body, "insert_badge_notify", &_monitoring_hash, PROVIDER_BADGE_INTERFACE_NAME, param_uid);
- g_variant_unref(body);
-
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to send notify [%d]", ret);
- return ret;
- }
- }
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, pkgname[%s] writable_pkg[%s] caller[%s]", pkgname, writable_pkg, caller);
-
- return ret;
-}
-
-/* delete_badge */
-int badge_delete(GVariant *parameters, GVariant **reply_body, uid_t uid, pid_t pid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- char *caller = NULL;
- GVariant *body = NULL;
- uid_t param_uid;
-
- g_variant_get(parameters, "(&s&si)", &pkgname, &caller, ¶m_uid);
-
- if (pkgname == NULL || caller == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_delete(pkgname, caller, param_uid, pid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to delete badge [%d]", ret);
- return ret;
- }
-
- body = g_variant_new("(si)", pkgname, param_uid);
- if (body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- ret = send_notify(body, "delete_badge_notify", &_monitoring_hash, PROVIDER_BADGE_INTERFACE_NAME, param_uid);
- g_variant_unref(body);
-
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to send notify:%d", ret);
- return ret;
- }
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("success, pkgname[%s] caller[%s]", pkgname, caller);
-
- return ret;
-}
-
-/* set_badge_count */
-int badge_set_badge_count(GVariant *parameters, GVariant **reply_body, uid_t uid, pid_t pid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- char *caller = NULL;
- unsigned int count = 0;
- GVariant *body = NULL;
- uid_t param_uid;
- int allow_to_display = 0;
-
- g_variant_get(parameters, "(&s&sii)", &pkgname, &caller, &count, ¶m_uid);
-
- if (pkgname == NULL || caller == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_set_count(pkgname, caller, count, param_uid, pid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to set badge [%d]", ret);
- return ret;
- }
-
- ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get allow_to_display [%d]", ret);
- return ret;
- }
-
- if (allow_to_display) {
- body = g_variant_new("(sii)", pkgname, count, param_uid);
- if (body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- ret = send_notify(body, "set_badge_count_notify", &_monitoring_hash, PROVIDER_BADGE_INTERFACE_NAME, param_uid);
- g_variant_unref(body);
-
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to send notify [%d]", ret);
- return ret;
- }
- }
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, pkgname[%s] caller[%s] count[%d]", pkgname, caller, count);
-
- return ret;
-}
-
-/* get_badge_count */
-int badge_get_badge_count(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- unsigned int count = 0;
- uid_t param_uid;
-
- g_variant_get(parameters, "(&si)", &pkgname, ¶m_uid);
-
- if (pkgname == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_get_count(pkgname, &count, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get badge count [%d]", ret);
- return ret;
- }
-
- *reply_body = g_variant_new("(i)", count);
- if (*reply_body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, count[%d]", count);
- return ret;
-}
-
-/* set_disp_option */
-int badge_set_display_option(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- char *caller = NULL;
- unsigned int is_display = 0;
- GVariant *body = NULL;
- uid_t param_uid;
- int allow_to_display = 0;
-
- g_variant_get(parameters, "(&s&sii)", &pkgname, &caller, &is_display, ¶m_uid);
-
- if (pkgname == NULL || caller == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_set_display_option(pkgname, is_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to set display option [%d]", ret);
- return ret;
- }
-
- ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get allow_to_display [%d]", ret);
- return ret;
- }
-
- if (allow_to_display) {
- body = g_variant_new("(sii)", pkgname, is_display, param_uid);
- if (body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- ret = send_notify(body, "set_disp_option_notify", &_monitoring_hash, PROVIDER_BADGE_INTERFACE_NAME, param_uid);
- g_variant_unref(body);
-
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to send notify [%d]", ret);
- return ret;
- }
- }
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, pkgname[%s] caller[%s] is_dispaly[%d]",
- pkgname, caller, is_display);
-
- return ret;
-}
-
-static gint __compare_sender(gconstpointer a, gconstpointer b)
-{
- if (!a)
- return -1;
-
- return strcmp(a, b);
-}
-
-/* get_disp_option */
-int badge_get_display_option(GVariant *parameters, GVariant **reply_body, const gchar *sender, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- char *pkgname = NULL;
- unsigned int is_display = 0;
- int allow_to_display;
- GList *monitoring_list = NULL;
- GList *find_list = NULL;
- uid_t param_uid;
-
- g_variant_get(parameters, "(&si)", &pkgname, ¶m_uid);
-
- if (pkgname == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_get_display_option(pkgname, &is_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get display option [%d]", ret);
- return ret;
- }
-
- ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get allow_to_display [%d]", ret);
- return ret;
- }
-
- if (!allow_to_display) {
- monitoring_list = (GList *)g_hash_table_lookup(_monitoring_hash, GUINT_TO_POINTER(param_uid));
- monitoring_list = g_list_first(monitoring_list);
- find_list = g_list_find_custom(monitoring_list, (gconstpointer)sender,
- (GCompareFunc)__compare_sender);
- if (find_list != NULL)
- is_display = 0;
- }
-
- *reply_body = g_variant_new("(i)", is_display);
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, display option[%d]", is_display);
- return ret;
-}
-
-static int __badge_emit_fake_signal(char *appid, unsigned int disp_option, uid_t uid)
-{
- int ret;
- GVariant *fake_body = NULL;
-
- fake_body = g_variant_new("(sii)", appid, disp_option, uid);
- if (fake_body == NULL) {
- ERR("Failed to make gvariant");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- ret = send_notify(fake_body, "set_disp_option_notify", &_monitoring_hash, PROVIDER_BADGE_INTERFACE_NAME, uid);
- g_variant_unref(fake_body);
- if (ret != BADGE_ERROR_NONE)
- ERR("Failed to send notify [%d]", ret);
-
- return ret;
-}
-
-/* update_badge_setting */
-int badge_update_badge_setting(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- uid_t param_uid;
- unsigned int allow_to_display;
- unsigned int disp_option = 0;
- char *pkgname = NULL;
- char *appid = NULL;
-
- g_variant_get(parameters, "(&s&sii)", &pkgname, &appid, &allow_to_display, ¶m_uid);
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_update_setting(pkgname, appid, allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to update badge setting [%d]", ret);
- return ret;
- }
-
- if (!allow_to_display) {
- ret = __badge_emit_fake_signal(appid, allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
- } else {
- ret = badge_db_get_display_option(appid, &disp_option, param_uid);
- if (ret != BADGE_ERROR_NONE && ret != BADGE_ERROR_NOT_EXIST) {
- ERR("Failed to get display_option [%d]", ret);
- return ret;
- }
-
- if (disp_option) {
- ret = __badge_emit_fake_signal(appid, disp_option, param_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
- }
- }
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply_body");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, pkgname[%s], appid[%s]", pkgname, appid);
- return ret;
-}
-
-int badge_get_setting_by_appid(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret;
- char *appid = NULL;
- GVariant *body;
- badge_setting_h setting = NULL;
- uid_t param_uid;
-
- g_variant_get(parameters, "(&si)", &appid, ¶m_uid);
-
- if (appid == NULL)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
-
- ret = badge_db_get_setting_by_appid(appid, &setting, param_uid);
- if (ret == BADGE_ERROR_NONE) {
- body = badge_ipc_make_gvariant_from_setting(setting);
- badge_setting_free_setting(setting);
- if (body == NULL) {
- ERR("Failed to make gvariant from setting");
- return NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- } else {
- return ret;
- }
-
- *reply_body = g_variant_new("(v)", body);
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("Success, appid[%s]", appid);
- return ret;
-}
-
-/* init badge */
-int badge_init_display(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- unsigned int disp_option;
- int allow_to_display;
- GList *badge_list = NULL;
- GList *iter_list = NULL;
- GVariant *body = NULL;
- badge_info_s *badge;
- uid_t param_uid;
-
- g_variant_get(parameters, "(i)", ¶m_uid);
-
- ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- ret = badge_db_get_list(&badge_list, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get list [%d]", ret);
- return ret;
- }
-
- iter_list = g_list_first(badge_list);
- while (iter_list) {
- badge = (badge_info_s *)g_list_nth_data(iter_list, 0);
- iter_list = g_list_next(iter_list);
-
- ret = badge_db_get_display_option(badge->pkg, &disp_option, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get display option [%d]", ret);
- continue;
- }
-
- ret = badge_db_get_allow_to_display_by_appid(badge->pkg, &allow_to_display, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to get allow_to_display [%d]", ret);
- continue;
- }
-
- if (disp_option && allow_to_display) {
- body = g_variant_new("(sii)", badge->pkg, disp_option, param_uid);
- ret = send_notify(body, "set_disp_option_notify", &_monitoring_hash, PROVIDER_BADGE_INTERFACE_NAME, param_uid);
- if (ret != BADGE_ERROR_NONE) {
- ERR("Failed to send notify");
- continue;
- }
- g_variant_unref(body);
- }
- }
-
- if (badge_list)
- g_list_free_full(badge_list, (GDestroyNotify)_release_badge_info);
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply_body");
- return NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- DBG("result [%d]", ret);
- return ret;
-}
-
-static gboolean __refresh_setting_table(gpointer data)
-{
- uid_t uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
-
- badge_setting_refresh_setting_table(uid);
- badge_setting_arrange_tables(uid);
-
- return G_SOURCE_REMOVE;
-}
-
-/*!
- * MAIN THREAD
- * Do not try to do anyother operation in these functions
- */
-HAPI int badge_service_init(void)
-{
- int result;
-
- _monitoring_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
- result = badge_db_init();
- if (result != BADGE_ERROR_NONE) {
- ERR("Failed to init DB [%d]", result);
- return result;
- }
-
- result = badge_register_dbus_interface();
- if (result != SERVICE_COMMON_ERROR_NONE) {
- ERR("Failed to register dbus interface [%d]", result);
- return BADGE_ERROR_IO_ERROR;
- }
-
- g_idle_add(__refresh_setting_table, NULL);
- INFO("Successfully initialized");
- return BADGE_ERROR_NONE;
-}
-
-HAPI int badge_service_fini(void)
-{
- return BADGE_ERROR_NONE;
-}
-
-/* End of a file */
#include "debug.h"
#include "service_common.h"
-#include "shortcut_service.h"
#include "notification_service.h"
#include "notification_ex_service.h"
-#include "badge_service.h"
static GMainLoop *main_loop;
static GIOChannel *channel;
service_common_set_connection(
notification_ex_service_get_gdbus_connection());
- ret = shortcut_service_init();
- if (ret < 0)
- WARN("shortcut [%d]", ret);
-
- ret = badge_service_init();
- if (ret < 0)
- WARN("badge [%d]", ret);
-
service_common_init();
INFO("Successfully initialized");
{
int ret;
- ret = badge_service_fini();
- if (ret < 0)
- DBG("badge [%d]", ret);
-
ret = notification_service_fini();
if (ret < 0)
DBG("notification [%d]", ret);
- ret = shortcut_service_fini();
- if (ret < 0)
- DBG("shortcut [%d]", ret);
-
return 0;
}
#include <notification_setting_internal.h>
#include <notification_setting_service.h>
#include <notification_noti.h>
-#include <badge_setting.h>
-#include <badge_setting_service.h>
-#include <badge_db.h>
#include <package-manager.h>
#include <tzplatform_config.h>
#include <pkgmgr-info.h>
#include "pkgmgr_client.hh"
#include "service_common.h"
#include "notification_service.h"
-#include "badge_service.h"
-#include "shortcut_service.h"
#define DBUS_NAME "org.freedesktop.DBus"
#define DBUS_OBJECT_PATH "/org/freedesktop/DBus"
static GDBusConnection *_gdbus_conn;
static GHashTable *_noti_pkg_privilege_info;
-static GHashTable *_badge_pkg_privilege_info;
std::unique_ptr<PkgmgrClient> pkgmgr_client_;
std::list<std::shared_ptr<PkgmgrEventArgs>> pkgmgr_event_list_;
std::list<std::shared_ptr<PkgmgrAppEventArgs>> pkgmgr_app_event_list_;
_noti_pkg_privilege_info =
g_hash_table_new_full(g_str_hash, g_str_equal, free, nullptr);
- _badge_pkg_privilege_info =
- g_hash_table_new_full(g_str_hash, g_str_equal, free, nullptr);
DBG("init pkg privilege info done");
return 0;
}
notification_setting_insert_package_for_uid(pkgname, uid);
}
- if (g_hash_table_contains(_badge_pkg_privilege_info, pkgname)) {
- tmp = g_hash_table_lookup(_badge_pkg_privilege_info, pkgname);
- privilege_info = GPOINTER_TO_UINT(tmp);
- if (privilege_info == 1)
- badge_db_update_pkg_disabled(pkgname, false, uid);
-
- g_hash_table_remove(_badge_pkg_privilege_info, pkgname);
- } else {
- /* In consideration of the reboot status, change the disable information. */
- ret = badge_db_update_pkg_disabled(pkgname, false, uid);
- if (ret != BADGE_ERROR_NONE)
- badge_setting_insert_package_for_uid(pkgname, uid);
- }
-
return 0;
}
g_hash_table_insert(_noti_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(1));
else
g_hash_table_insert(_noti_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(0));
-
- ret = badge_db_update_pkg_disabled(pkgname, true, uid);
- if (ret == BADGE_ERROR_NONE)
- g_hash_table_insert(_badge_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(1));
- else
- g_hash_table_insert(_badge_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(0));
} else {
notification_setting_delete_package_for_uid(pkgname, uid);
- badge_db_delete_by_pkgname(pkgname, uid);
- badge_setting_delete_package_for_uid(pkgname, uid);
notification_noti_delete_template(pkgname);
}
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-#include <dlog.h>
-#include <gio/gio.h>
-#include <shortcut_db.h>
-#include <shortcut.h>
-#include "service_common.h"
-#include "shortcut_service.h"
-#include "debug.h"
-
-#define PROVIDER_SHORTCUT_INTERFACE_NAME "org.tizen.data_provider_shortcut_service"
-#define SHORTCUT_INVOCATION_KEY_POS 0
-
-static GHashTable *_monitoring_hash;
-static GHashTable *_invocation_hash;
-
-static void _on_name_appeared(GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
- gpointer user_data)
-{
- DBG("name [%s]", name);
-}
-
-static void _on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- DBG("name [%s]", name);
- monitoring_info_s *info = (monitoring_info_s *)user_data;
-
- if (info) {
- DBG("vanished uid [%d]", info->uid);
- g_bus_unwatch_name(info->watcher_id);
- delete_monitoring_list(&_monitoring_hash, name, info->uid);
-
- if (info->bus_name)
- free(info->bus_name);
- free(info);
- }
-}
-
-static void _shortcut_dbus_method_call_handler(GDBusConnection *conn,
- const gchar *sender, const gchar *object_path,
- const gchar *iface_name, const gchar *method_name,
- GVariant *parameters, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- /* TODO : sender authority(privilege) check */
- DBG("shortcut method_name [%s]", method_name);
- GVariant *reply_body = NULL;
- int ret = SHORTCUT_ERROR_NOT_SUPPORTED;
- uid_t uid = get_sender_uid(sender);
-
- if (g_strcmp0(method_name, "shortcut_service_register") == 0) {
- ret = service_register(parameters, &reply_body, sender,
- _on_name_appeared, _on_name_vanished, &_monitoring_hash, uid);
- } else if (g_strcmp0(method_name, "add_shortcut") == 0) {
- shortcut_add(parameters, invocation, uid);
- return;
- } else if (g_strcmp0(method_name, "add_shortcut_widget") == 0) {
- shortcut_add_widget(parameters, invocation, uid);
- return;
- } else if (g_strcmp0(method_name, "remove_shortcut") == 0) {
- shortcut_remove(parameters, invocation, uid);
- return;
- } else if (g_strcmp0(method_name, "get_list") == 0) {
- ret = shortcut_get_shortcut_service_list(parameters, &reply_body, uid);
- } else if (g_strcmp0(method_name, "check_privilege") == 0) {
- ret = shortcut_check_privilege();
- } else if (g_strcmp0(method_name, "send_return_value") == 0) {
- ret = shortcut_send_return_value(parameters, &reply_body);
- }
-
- if (ret == SERVICE_COMMON_ERROR_NONE) {
- DBG("shortcut service success, method[%s]", method_name);
- g_dbus_method_invocation_return_value(
- invocation, reply_body);
- } else {
- DBG("shortcut service fail, method_name[%s] err[%d]",
- method_name, ret);
- g_dbus_method_invocation_return_error(
- invocation,
- SHORTCUT_ERROR,
- ret,
- "shortcut service error");
- }
-}
-
-static const GDBusInterfaceVTable _shortcut_interface_vtable = {
- _shortcut_dbus_method_call_handler,
- NULL,
- NULL
-};
-
-int shortcut_register_dbus_interface(void)
-{
- static gchar introspection_xml[] =
- " <node>"
- " <interface name='org.tizen.data_provider_shortcut_service'>"
- " <method name='shortcut_service_register'>"
- " <arg type='i' name='uid' direction='in'/>"
- " </method>"
-
- " <method name='get_list'>"
- " <arg type='v' name='package_name' direction='in'/>"
- " <arg type='i' name='shortcut_cnt' direction='out'/>"
- " <arg type='a(v)' name='shortcut_list' direction='out'/>"
- " </method>"
-
- " <method name='add_shortcut'>"
- " <arg type='s' name='request_id' direction='in'/>"
- " <arg type='i' name='pid' direction='in'/>"
- " <arg type='s' name='appid' direction='in'/>"
- " <arg type='s' name='name' direction='in'/>"
- " <arg type='i' name='type' direction='in'/>"
- " <arg type='s' name='uri' direction='in'/>"
- " <arg type='s' name='icon' direction='in'/>"
- " <arg type='i' name='allow_duplicate' direction='in'/>"
- " <arg type='i' name='return_value' direction='out'/>"
- " </method>"
-
- " <method name='add_shortcut_widget'>"
- " <arg type='s' name='request_id' direction='in'/>"
- " <arg type='i' name='pid' direction='in'/>"
- " <arg type='s' name='widget_id' direction='in'/>"
- " <arg type='s' name='name' direction='in'/>"
- " <arg type='i' name='size' direction='in'/>"
- " <arg type='s' name='uri' direction='in'/>"
- " <arg type='s' name='icon' direction='in'/>"
- " <arg type='d' name='period' direction='in'/>"
- " <arg type='i' name='allow_duplicate' direction='in'/>"
- " <arg type='i' name='return_value' direction='out'/>"
- " </method>"
-
- " <method name='remove_shortcut'>"
- " <arg type='s' name='request_id' direction='in'/>"
- " <arg type='i' name='pid' direction='in'/>"
- " <arg type='s' name='appid' direction='in'/>"
- " <arg type='s' name='name' direction='in'/>"
- " <arg type='i' name='return_value' direction='out'/>"
- " </method>"
-
- " <method name='check_privilege'>"
- " </method>"
-
- " <method name='send_return_value'>"
- " <arg type='i' name='return_value' direction='in'/>"
- " <arg type='s' name='request_id' direction='in'/>"
- " </method>"
- " </interface>"
- " </node>";
-
- return service_common_register_dbus_interface(introspection_xml, _shortcut_interface_vtable);
-}
-
-static void _release_shortcut_info(gpointer data)
-{
- if (data == NULL)
- return;
-
- shortcut_info_s *shortcut = (shortcut_info_s *)data;
-
- if (shortcut->package_name)
- free(shortcut->package_name);
- if (shortcut->icon)
- free(shortcut->icon);
- if (shortcut->name)
- free(shortcut->name);
- if (shortcut->extra_key)
- free(shortcut->extra_key);
- if (shortcut->extra_data)
- free(shortcut->extra_data);
- free(shortcut);
-}
-
-/* get_list */
-int shortcut_get_shortcut_service_list(GVariant *parameters, GVariant **reply_body, uid_t uid)
-{
- int count;
- GList *shortcut_list = NULL;
- GList *iter_list = NULL;
- GVariant *param_body = NULL;
- GVariant *body = NULL;
- shortcut_info_s *shortcut;
- GVariantDict dict;
- char *package_name = NULL;
- GVariantBuilder *builder;
-
- g_variant_get(parameters, "(v)", ¶m_body);
- g_variant_dict_init(&dict, param_body);
- g_variant_dict_lookup(&dict, "package_name", "&s", &package_name);
- g_variant_dict_end(&dict);
-
- count = shortcut_db_get_list(package_name, &shortcut_list);
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
- if (count > 0) {
- iter_list = g_list_first(shortcut_list);
- for (; iter_list != NULL; iter_list = iter_list->next) {
- shortcut = iter_list->data;
- body = g_variant_new("(sssss)",
- shortcut->package_name, shortcut->icon, shortcut->name, shortcut->extra_key, shortcut->extra_data);
- g_variant_builder_add(builder, "(v)", body);
- }
- g_list_free_full(shortcut_list, (GDestroyNotify)_release_shortcut_info);
- }
-
- *reply_body = g_variant_new("(ia(v))", count, builder);
- g_variant_builder_unref(builder);
-
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return SHORTCUT_ERROR_OUT_OF_MEMORY;
- }
-
- INFO("count[%d]", count);
- return SERVICE_COMMON_ERROR_NONE;
-}
-
-static GDBusMethodInvocation *_get_invocation(char *request_id)
-{
- GDBusMethodInvocation *find_invocation;
-
- find_invocation = (GDBusMethodInvocation *)g_hash_table_lookup(_invocation_hash, request_id);
- if (!find_invocation)
- return NULL;
-
- return find_invocation;
-}
-
-static void _add_invocation(GDBusMethodInvocation *invocation, char *request_id)
-{
- GDBusMethodInvocation *find_invocation;
-
- if (request_id == NULL)
- return;
-
- find_invocation = _get_invocation(request_id);
- if (find_invocation)
- return;
-
- g_hash_table_insert(_invocation_hash, strdup(request_id), invocation);
-
- DBG("Invocation key [%s]", request_id);
-}
-
-static void _remove_invocation(char *request_id)
-{
- if (request_id == NULL)
- return;
-
- g_hash_table_remove(_invocation_hash, request_id);
-
- DBG("Invocation key [%s]", request_id);
-}
-
-/* add_shortcut */
-void shortcut_add(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid)
-{
- int ret = SERVICE_COMMON_ERROR_NONE;
- char *request_id = NULL;
-
- g_variant_get_child(parameters, SHORTCUT_INVOCATION_KEY_POS, "&s", &request_id);
-
- _add_invocation(invocation, request_id);
-
- ret = send_notify(parameters, "add_shortcut_notify", &_monitoring_hash, PROVIDER_SHORTCUT_INTERFACE_NAME, uid);
- if (ret != SERVICE_COMMON_ERROR_NONE)
- ERR("Failed to send notify [%d]", ret);
- else
- DBG("Success to send notify");
-
-}
-
-/* add_shortcut_widget */
-void shortcut_add_widget(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid)
-{
- int ret = SERVICE_COMMON_ERROR_NONE;
- char *request_id = NULL;
-
- g_variant_get_child(parameters, SHORTCUT_INVOCATION_KEY_POS, "&s", &request_id);
-
- _add_invocation(invocation, request_id);
-
- ret = send_notify(parameters, "add_shortcut_widget_notify", &_monitoring_hash, PROVIDER_SHORTCUT_INTERFACE_NAME, uid);
- if (ret != SERVICE_COMMON_ERROR_NONE)
- ERR("Failed to send notify [%d]", ret);
- else
- DBG("Success to send notify");
-}
-
-/* remove_shortcut */
-void shortcut_remove(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid)
-{
- int ret = SERVICE_COMMON_ERROR_NONE;
- char *request_id = NULL;
-
- g_variant_get_child(parameters, SHORTCUT_INVOCATION_KEY_POS, "&s", &request_id);
-
- _add_invocation(invocation, request_id);
-
- ret = send_notify(parameters, "remove_shortcut_notify", &_monitoring_hash, PROVIDER_SHORTCUT_INTERFACE_NAME, uid);
- if (ret != SERVICE_COMMON_ERROR_NONE)
- ERR("Failed to send notify [%d]", ret);
- else
- DBG("Success to send notify");
-}
-
-/* check shortcut privilege */
-int shortcut_check_privilege(void)
-{
- return SERVICE_COMMON_ERROR_NONE;
-}
-
-int shortcut_send_return_value(GVariant *parameters, GVariant **reply_body)
-{
- int return_value;
- char *request_id = NULL;
- GDBusMethodInvocation *invocation = NULL;
-
- g_variant_get(parameters, "(i&s)", &return_value, &request_id);
-
- if (request_id == NULL)
- return SHORTCUT_ERROR_INVALID_PARAMETER;
-
- invocation = _get_invocation(request_id);
- if (!invocation)
- return SHORTCUT_ERROR_INVALID_PARAMETER;
-
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", return_value));
- _remove_invocation(request_id);
-
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL) {
- ERR("Failed to make reply");
- return SHORTCUT_ERROR_OUT_OF_MEMORY;
- }
-
- DBG("Success to send return value");
- return SHORTCUT_ERROR_NONE;
-}
-
-/*!
- * MAIN THREAD
- * Do not try to do anyother operation in these functions
- */
-HAPI int shortcut_service_init(void)
-{
- int result;
-
- _monitoring_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
- _invocation_hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
-
- result = shortcut_db_init();
- if (result != SHORTCUT_ERROR_NONE) {
- ERR("Failed to init DB[%d]", result);
- return result;
- }
-
- result = shortcut_register_dbus_interface();
- if (result != SERVICE_COMMON_ERROR_NONE) {
- ERR("Failed to register dbus interface [%d]", result);
- return result;
- }
-
- INFO("Initialization success");
- return result;
-}
-
-HAPI int shortcut_service_fini(void)
-{
- g_hash_table_destroy(_invocation_hash);
-
- DBG("Finalization success");
- return SERVICE_COMMON_ERROR_NONE;
-}
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include "badge_mock.h"
-#include "mock_hook.h"
-#include "test_fixture.h"
-
-extern "C" int badge_db_init(void) {
- return MOCK_HOOK_P0(BadgeMock, badge_db_init);
-}
-
-extern "C" int badge_db_is_existing(const char* arg0, bool* arg1, uid_t arg2) {
- return MOCK_HOOK_P3(BadgeMock, badge_db_is_existing, arg0, arg1, arg2);
-}
-
-extern "C" int badge_db_get_list(GList** arg0, uid_t arg1) {
- return MOCK_HOOK_P2(BadgeMock, badge_db_get_list, arg0, arg1);
-}
-
-extern "C" int badge_db_insert(const char* arg0, const char* arg1,
- const char* arg2, uid_t arg3) {
- return MOCK_HOOK_P4(BadgeMock, badge_db_insert, arg0, arg1, arg2, arg3);
-}
-
-extern "C" int badge_db_delete(const char* arg0, const char* arg1,
- uid_t arg2, pid_t arg3) {
- return MOCK_HOOK_P4(BadgeMock, badge_db_delete, arg0, arg1, arg2, arg3);
-}
-
-extern "C" int badge_db_set_count(const char* arg0, const char* arg1,
- unsigned int arg2, uid_t arg3, pid_t arg4) {
- return MOCK_HOOK_P5(BadgeMock, badge_db_set_count, arg0, arg1, arg2, arg3, arg4);
-}
-
-extern "C" int badge_db_get_count(const char* arg0, unsigned int* arg1,
- uid_t arg2) {
- return MOCK_HOOK_P3(BadgeMock, badge_db_get_count, arg0, arg1, arg2);
-}
-
-extern "C" int badge_db_set_display_option(const char* arg0, unsigned int arg1,
- uid_t arg2) {
- return MOCK_HOOK_P3(BadgeMock, badge_db_set_display_option, arg0, arg1, arg2);
-}
-
-extern "C" int badge_db_get_display_option(const char* arg0, unsigned int* arg1,
- uid_t arg2) {
- return MOCK_HOOK_P3(BadgeMock, badge_db_get_display_option, arg0, arg1, arg2);
-}
-
-extern "C" int badge_db_get_allow_to_display_by_appid(char* arg0, int* arg1,
- uid_t arg2) {
- return MOCK_HOOK_P3(BadgeMock, badge_db_get_allow_to_display_by_appid, arg0,
- arg1, arg2);
-}
-
-extern "C" int badge_db_update_setting(char* arg0, char* arg1, int arg2,
- uid_t arg3) {
- return MOCK_HOOK_P4(BadgeMock, badge_db_update_setting, arg0, arg1, arg2, arg3);
-}
-
-extern "C" int badge_setting_get_appid(badge_setting_h arg0, char** arg1) {
- return MOCK_HOOK_P2(BadgeMock, badge_setting_get_appid, arg0, arg1);
-}
-
-extern "C" int badge_db_get_setting_by_appid(const char* arg0,
- badge_setting_h* arg1, uid_t arg2) {
- return MOCK_HOOK_P3(BadgeMock, badge_db_get_setting_by_appid, arg0, arg1, arg2);
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#ifndef MOCK_BADGE_MOCK_H_
-#define MOCK_BADGE_MOCK_H_
-
-#include <badge.h>
-#include <badge_db.h>
-#include <badge_setting.h>
-#include <badge_setting_service.h>
-#include <gmock/gmock.h>
-
-#include "module_mock.h"
-
-class BadgeMock : public virtual ModuleMock {
- public:
- virtual ~BadgeMock() {}
-
- MOCK_METHOD0(badge_db_init, int (void));
- MOCK_METHOD3(badge_db_is_existing, int (const char*, bool*, uid_t));
- MOCK_METHOD2(badge_db_get_list, int (GList**, uid_t));
- MOCK_METHOD4(badge_db_insert, int (const char*, const char*, const char*,
- uid_t));
- MOCK_METHOD4(badge_db_delete, int (const char*, const char*, uid_t, pid_t));
- MOCK_METHOD5(badge_db_set_count, int (const char*, const char*, unsigned int,
- uid_t, pid_t));
- MOCK_METHOD3(badge_db_get_count, int (const char*, unsigned int*, uid_t));
- MOCK_METHOD3(badge_db_set_display_option, int (const char*, unsigned int,
- uid_t));
- MOCK_METHOD3(badge_db_get_display_option, int (const char*, unsigned int*,
- uid_t));
- MOCK_METHOD3(badge_db_get_allow_to_display_by_appid, int (char*, int*,
- uid_t));
- MOCK_METHOD4(badge_db_update_setting, int (char*, char*, int, uid_t));
- MOCK_METHOD2(badge_setting_get_appid, int (badge_setting_h, char**));
- MOCK_METHOD3(badge_db_get_setting_by_appid, int (const char*,
- badge_setting_h*, uid_t));
-
-};
-
-#endif // MOCK_BADGE_MOCK_H_
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include "shortcut_mock.h"
-#include "mock_hook.h"
-#include "test_fixture.h"
-
-extern "C" int shortcut_db_init(void) {
- return MOCK_HOOK_P0(ShortcutMock, shortcut_db_init);
-}
-
-extern "C" int shortcut_db_get_list(const char* arg0, GList** arg1) {
- return MOCK_HOOK_P2(ShortcutMock, shortcut_db_get_list, arg0, arg1);
-}
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#ifndef MOCK_SHORTCUT_MOCK_H_
-#define MOCK_SHORTCUT_MOCK_H_
-
-#include <shortcut.h>
-#include <shortcut_db.h>
-#include <badge_setting.h>
-#include <badge_setting_service.h>
-#include <gmock/gmock.h>
-
-#include "module_mock.h"
-
-class ShortcutMock : public virtual ModuleMock {
- public:
- virtual ~ShortcutMock() {}
-
- MOCK_METHOD0(shortcut_db_init, int (void));
- MOCK_METHOD2(shortcut_db_get_list, int (const char*, GList**));
-};
-
-#endif // MOCK_SHORTCUT_MOCK_H_
pkgmgr\r
notification\r
notification-ex\r
- badge\r
libsmack\r
- shortcut\r
pkgmgr-info\r
libsystemd\r
capi-appfw-app-manager\r
\r
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src TEST_SOURCES)\r
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)\r
-SET(DPM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../src/badge_service.c\r
- ${CMAKE_CURRENT_SOURCE_DIR}/../../src/notification_ex_service.cc\r
+SET(DPM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../src/notification_ex_service.cc\r
${CMAKE_CURRENT_SOURCE_DIR}/../../src/notification_service.c\r
${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkgmgr_client.cc\r
${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkgmgr_event_args.cc\r
${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkgmgr_app_event_args.cc\r
- ${CMAKE_CURRENT_SOURCE_DIR}/../../src/shortcut_service.c\r
${CMAKE_CURRENT_SOURCE_DIR}/../../src/service_common.cc)\r
\r
ADD_EXECUTABLE(${PROJECT_NAME}\r
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include <gtest/gtest.h>
-
-#include "include/service_common.h"
-#include "include/badge_service.h"
-#include "tests/mock/badge_mock.h"
-#include "tests/mock/gio_mock.h"
-#include "tests/mock/tzplatform_config_mock.h"
-#include "tests/mock/test_fixture.h"
-
-using ::testing::_;
-using ::testing::DoAll;
-using ::testing::Return;
-using ::testing::SetArgPointee;
-
-namespace {
-
-class Mocks : public ::testing::NiceMock<BadgeMock>,
- public ::testing::NiceMock<GioMock>,
- public ::testing::NiceMock<TzplatformConfigMock> {};
-
-} //namespace
-
-class BadgeServiceTest : public TestFixture {
- public:
- BadgeServiceTest() : TestFixture(std::make_unique<Mocks>()) {}
- virtual ~BadgeServiceTest() {}
-
- virtual void SetUp() {
- EXPECT_CALL(GetMock<TzplatformConfigMock>(), tzplatform_getuid(_))
- .WillRepeatedly(Return(6001));
- }
-
- virtual void TearDown() {
- }
-};
-
-TEST_F(BadgeServiceTest, badge_service_init) {
- GDBusNodeInfo* info = reinterpret_cast<GDBusNodeInfo*>(
- malloc(sizeof(GDBusNodeInfo)));
- info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
- malloc(sizeof(GDBusInterfaceInfo*)));
- GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_init())
- .WillOnce(Return(0));
- EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name(_, _, _, _, _, _, _, _))
- .WillOnce(Return(1));
- EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _))
- .WillOnce(Return(conn));
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_new_for_xml(_, _))
- .WillOnce(Return(info));
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_unref(_))
- .WillOnce(Return());
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_connection_register_object(_, _, _, _, _, _, _))
- .WillOnce(Return(1));
-
- int ret = badge_service_init();
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- free(info->interfaces);
- free(info);
- free(conn);
-}
-
-TEST_F(BadgeServiceTest, badge_service_fini) {
- int ret = badge_service_fini();
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-}
-
-TEST_F(BadgeServiceTest, badge_get_badge_existing) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_is_existing(_, _, _))
- .WillOnce(Return(0));
- GVariant* param = g_variant_new("(si)", "pkgname", 5001);
- GVariant* reply;
- int ret = badge_get_badge_existing(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_get_badge_list) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_list(_, _))
- .WillOnce(Return(0));
- GVariant* param = g_variant_new("(i)", 5001);
- GVariant* reply;
- int ret = badge_get_badge_list(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-
-}
-
-TEST_F(BadgeServiceTest, badge_insert) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_insert(_, _, _, _))
- .WillOnce(Return(0));
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
- _)).WillOnce(Return(0));
- GVariant* param = g_variant_new("(sssi)", "pkgname", "writable", "call", 5001);
- GVariant* reply;
- int ret = badge_insert(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_delete) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_delete(_, _, _, _))
- .WillOnce(Return(0));
- GVariant* param = g_variant_new("(ssi)", "pkgname", "caller", 5001);
- GVariant* reply;
- int ret = badge_delete(param, &reply, 5001, 10);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_set_badge_count) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_set_count(_, _, _, _, _))
- .WillOnce(Return(0));
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
- _)).WillOnce(Return(0));
- GVariant* param = g_variant_new("(ssii)", "pkgname", "caller", 10, 5001);
- GVariant* reply;
- int ret = badge_set_badge_count(param, &reply, 5001, 10);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_get_badge_count) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_count(_, _, _))
- .WillOnce(Return(0));
- GVariant* param = g_variant_new("(si)", "pkgname", 5001);
- GVariant* reply;
- int ret = badge_get_badge_count(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_set_display_option) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_set_display_option(_, _, _))
- .WillOnce(Return(0));
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
- _)).WillOnce(Return(0));
- GVariant* param = g_variant_new("(ssii)", "pkgname", "caller", 1, 5001);
- GVariant* reply;
- int ret = badge_set_display_option(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_get_display_option) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_display_option(_, _, _))
- .WillOnce(Return(0));
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
- _)).WillOnce(Return(0));
- GVariant* param = g_variant_new("(si)", "pkgname", 5001);
- GVariant* reply;
- int ret = badge_get_display_option(param, &reply, "sender", 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_update_badge_setting) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_update_setting(_, _, _, _))
- .WillOnce(Return(0));
- GVariant* param = g_variant_new("(ssii)", "pkgname", "caller", 1, 5001);
- GVariant* reply;
- int ret = badge_update_badge_setting(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_get_setting_by_appid) {
- struct badge_setting* setting =
- reinterpret_cast<struct badge_setting*>(malloc(sizeof(struct badge_setting)));
- setting->pkgname = strdup("pkgname");
- setting->appid = strdup("appid");
- setting->allow_to_display = 1;
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_setting_by_appid(_, _, _))
- .WillOnce(DoAll(SetArgPointee<1>(setting), Return(0)));
- GVariant* param = g_variant_new("(si)", "appid", 5001);
- GVariant* reply;
- int ret = badge_get_setting_by_appid(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(BadgeServiceTest, badge_init_display) {
- EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_list(_, _))
- .WillOnce(Return(0));
- GVariant* param = g_variant_new("(i)", 5001);
- GVariant* reply;
- int ret = badge_init_display(param, &reply, 5001);
- EXPECT_EQ(ret, BADGE_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
\ No newline at end of file
};
TEST_F(NotificationServiceTest, notification_service_init) {
+ GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
GDBusNodeInfo* info = reinterpret_cast<GDBusNodeInfo*>(
malloc(sizeof(GDBusNodeInfo)));
info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
EXPECT_CALL(GetMock<NotificationMock>(),
notification_system_setting_get_dnd_schedule_enabled_uid(_, _))
.WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _))
+ .WillOnce(Return(conn));
EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name(_, _, _, _, _, _, _, _))
.WillOnce(Return(1));
EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_new_for_xml(_, _))
free(info->interfaces);
free(info);
+ free(conn);
}
TEST_F(NotificationServiceTest, notification_service_fini) {
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-#include <gtest/gtest.h>
-
-#include "include/service_common.h"
-#include "include/shortcut_service.h"
-#include "tests/mock/shortcut_mock.h"
-#include "tests/mock/gio_mock.h"
-#include "tests/mock/test_fixture.h"
-
-using ::testing::_;
-using ::testing::DoAll;
-using ::testing::Return;
-using ::testing::SetArgPointee;
-
-namespace {
-
-class Mocks : public ::testing::NiceMock<ShortcutMock>,
- public ::testing::NiceMock<GioMock> {};
-
-} //namespace
-
-class ShortcutServiceTest : public TestFixture {
- public:
- ShortcutServiceTest() : TestFixture(std::make_unique<Mocks>()) {}
- virtual ~ShortcutServiceTest() {}
-
- virtual void SetUp() {
- }
-
- virtual void TearDown() {
- }
-};
-
-TEST_F(ShortcutServiceTest, shortcut_service_init) {
- GDBusNodeInfo* info = reinterpret_cast<GDBusNodeInfo*>(
- malloc(sizeof(GDBusNodeInfo)));
- info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
- malloc(sizeof(GDBusInterfaceInfo*)));
- EXPECT_CALL(GetMock<ShortcutMock>(), shortcut_db_init())
- .WillOnce(Return(0));
- EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name(_, _, _, _, _, _, _, _))
- .WillOnce(Return(1));
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_new_for_xml(_, _))
- .WillOnce(Return(info));
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_unref(_))
- .WillOnce(Return());
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_connection_register_object(_, _, _, _, _, _, _))
- .WillOnce(Return(1));
-
- int ret = shortcut_service_init();
- EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
-
- free(info->interfaces);
- free(info);
-}
-
-TEST_F(ShortcutServiceTest, shortcut_get_shortcut_service_list) {
- GVariantBuilder* b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- g_variant_builder_add(b, "{sv}", "package_name", g_variant_new_string("name"));
- GVariant* body = g_variant_builder_end(b);
- GVariant* param = g_variant_new("(v)", body);
-
- GVariant* reply;
- int ret = shortcut_get_shortcut_service_list(param, &reply, 5001);
- EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
-}
-
-TEST_F(ShortcutServiceTest, shortcut_send_return_value) {
- EXPECT_CALL(GetMock<GioMock>(), g_dbus_method_invocation_return_value(_, _))
- .WillOnce(Return());
- GDBusMethodInvocation* invoc = reinterpret_cast<GDBusMethodInvocation*>(
- malloc(sizeof(GDBusMethodInvocation*)));
- GVariant* param = g_variant_new("(sis)", "request_id", 10, "appid");
- GVariant* param2 = g_variant_new("(is)", 1, "request_id");
- GVariant* reply;
-
- shortcut_add(param, invoc, 5001);
- shortcut_add_widget(param, invoc, 5001);
- shortcut_remove(param, invoc, 5001);
-
- int ret = shortcut_send_return_value(param2, &reply);
- EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
-
- g_object_unref(param);
- g_object_unref(reply);
- free(invoc);
-}
-
-TEST_F(ShortcutServiceTest, shortcut_service_fini) {
- int ret = shortcut_service_fini();
- EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
-}