CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(${NAME} C)
+PROJECT(data-provider-master C CXX)
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
SET(LIBDIR ${LIB_INSTALL_DIR})
-SET(INCLUDEDIR "\${prefix}/include")
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.0.0")
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkg REQUIRED
+pkg_check_modules(pkgs REQUIRED
dlog
aul
vconf
sqlite3
- db-util
glib-2.0
gio-2.0
gio-unix-2.0
bundle
pkgmgr
notification
+ notification-ex
badge
libsmack
shortcut
libtzplatform-config
)
-SET(PACKAGE "${PROJECT_NAME}")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Werror -fno-builtin-malloc -fno-omit-frame-pointer -g -fPIE -Wl,-z,relro")
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror -Winline")
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-#ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DPATH_MAX=256")
-ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
-ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
-
-ADD_DEFINITIONS("-D_GNU_SOURCE")
-ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
-
-ADD_DEFINITIONS("-DSHORTCUT_SMACK_LABEL=NULL")
-ADD_DEFINITIONS("-DNOTIFICATION_SMACK_LABEL=NULL")
-ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=NULL")
-ADD_DEFINITIONS("-DDATA_SHARE_LABEL=NULL")
-ADD_DEFINITIONS("-DDEFAULT_SMACK_LABEL=NULL")
-
-ADD_DEFINITIONS("-DNDEBUG")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
-
-SET(BUILD_SOURCE
- src/main.c
- src/pkgmgr.c
- src/shortcut_service.c
- src/badge_service.c
- src/notification_service.c
- src/service_common.c
-)
-
-STRING(REPLACE "-L-l" "-l" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
-STRING(REPLACE "-l" " -l" pkg_LDFLAGS ${pkg_fixed_LDFLAGS})
-STRING(REPLACE "-L" " -L" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
-STRING(REGEX REPLACE "^ " "" pkg_LDFLAGS ${pkg_fixed_LDFLAGS})
-
-ADD_DEFINITIONS(${pkg_CFLAGS})
-ADD_DEFINITIONS(${pkg_LDFLAGS})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-ADD_EXECUTABLE(${PROJECT_NAME} ${BUILD_SOURCE})
+AUX_SOURCE_DIRECTORY(src SOURCES)
+ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl -lrt -pie")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-pie")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.data-provider-master.service DESTINATION ${SHARE_INSTALL_PREFIX}/dbus-1/system-services/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.conf DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
-# End of a file
<busconfig>
<policy user="app_fw">
<allow own="org.tizen.data_provider_service"/>
+ <allow own="org.tizen.notification_ex._data-provider-master"/>
+ <allow send_type="signal" send_interface="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"/>
<deny send_type="signal" send_interface="org.tizen.data_provider_badge_service"/>
<deny send_type="signal" send_interface="org.tizen.data_provider_shortcut_service"/>
<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"/>
</policy>
#include <gio/gio.h>
#include <sys/types.h>
-extern int badge_service_init(void);
-extern int badge_service_fini(void);
+#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_init_display(GVariant *parameters, GVariant **reply_body, uid_t uid);
int badge_register_dbus_interface();
-/* End of a file */
+#ifdef __cplusplus
+}
+#endif
+
+#endif // BADGE_SERVICE_H_
* limitations under the License.
*/
+#ifndef CONF_H_
+#define CONF_H_
+
#define DELAY_TIME 0.0000001f
#define HAPI __attribute__((visibility("hidden")))
#define CR 13
#define LF 10
-/* End of a file */
+#endif // CONF_H_
\ No newline at end of file
* limitations under the License.
*/
+#ifndef DEBUG_H_
+#define DEBUG_H_
+
#define DBG(format, arg...) SECURE_LOGD(format, ##arg)
#define ERR(format, arg...) SECURE_LOGE(format, ##arg)
#define WARN(format, arg...) SECURE_LOGW(format, ##arg)
#define HAPI __attribute__((visibility("hidden")))
-/* End of a file */
+#endif //DEBUG_H_
\ No newline at end of file
--- /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 NOTIFICATION_EX_SERVICE_H_
+#define NOTIFICATION_EX_SERVICE_H_
+
+extern int notification_ex_service_init(void);
+extern int notification_ex_service_fini(void);
+extern GDBusConnection* notification_ex_service_get_gdbus_connection(void);
+
+#endif //NOTIFICATION_EX_SERVICE_H_
\ No newline at end of file
#include <gio/gio.h>
-extern int notification_service_init(void);
-extern int notification_service_fini(void);
+#ifndef NOTIFICATION_SERVICE_H_
+#define NOTIFICATION_SERVICE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int notification_service_init(void);
+int notification_service_fini(void);
int notification_add_noti(GVariant *parameters, GVariant **reply_body,
const char *sender, pid_t pid, uid_t uid);
int notification_register_dbus_interface();
int notification_delete_noti_by_app_id(const char *app_id, uid_t uid);
-/* End of a file */
+#ifdef __cplusplus
+}
+#endif
+
+#endif //NOTIFICATION_SERVICE_H_
\ No newline at end of file
* limitations under the License.
*/
+#ifndef PKGMGR_H_
+#define PKGMGR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
enum pkgmgr_event_type {
PKGMGR_EVENT_DOWNLOAD,
PKGMGR_EVENT_INSTALL,
extern int pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data);
extern void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data);
+#ifdef __cplusplus
+}
+#endif
-/* End of a file */
+#endif //PKGMGR_H_
\ No newline at end of file
#include <shortcut.h>
#include <stdlib.h>
+#ifndef SERVICE_COMMON_H_
+#define SERVICE_COMMON_H_
+
#define NORMAL_UID_BASE 5000
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum {
NOTIFICATION_SERVICE = 0,
SHORTCUT_SERVICE,
pid_t get_sender_pid(const char *sender_name);
void free_monitoring_list(gpointer data);
void service_common_init(void);
+void service_common_set_connection(GDBusConnection *conn);
+
+#ifdef __cplusplus
+}
+#endif
-/* End of a file */
+#endif //SERVICE_COMMON_H_
#include <gio/gio.h>
-extern int shortcut_service_init(void);
-extern int shortcut_service_fini(void);
+#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);
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);
-/* End of a file */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //SHORTCUT_SERVICE_H_
\ No newline at end of file
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(notification)
+BuildRequires: pkgconfig(notification-ex)
BuildRequires: pkgconfig(badge)
BuildRequires: pkgconfig(shortcut)
BuildRequires: pkgconfig(libsystemd-daemon)
#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;
lang_key_changed_cb(NULL, NULL);
+ ret = notification_ex_service_init();
+ if (ret < 0)
+ WARN("notification_ex [%d]", ret);
+
+ service_common_set_connection(
+ notification_ex_service_get_gdbus_connection());
+
ret = shortcut_service_init();
if (ret < 0)
WARN("shortcut [%d]", ret);
--- /dev/null
+/*
+ * Copyright (c) 2019 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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+#include <math.h>
+#include <gio/gio.h>
+
+#include <aul.h>
+#include <dlog.h>
+
+#include <notification-ex/manager.h>
+#include <notification-ex/reporter.h>
+#include <notification-ex/dbus_sender.h>
+#include <notification-ex/dbus_event_listener.h>
+#include <notification-ex/dbus_connection_manager.h>
+#include <notification-ex/button_item.h>
+#include <notification-ex/ex_util.h>
+
+#include "debug.h"
+#include "notification_ex_service.h"
+
+using namespace notification;
+using namespace std;
+
+class DPMFacade {
+ public:
+ DPMFacade(unique_ptr<Reporter> reporter, unique_ptr<Manager> manager)
+ : reporter_(move(reporter)), manager_(move(manager)) {
+ }
+
+ void DelegateReporterEvent(const EventInfo& info, shared_ptr<item::AbstractItem> item) {
+ reporter_->SendEvent(info, item);
+ }
+
+ void DelegateManagerEvent(const EventInfo& info, shared_ptr<item::AbstractItem> noti) {
+ manager_->SendEvent(info, noti);
+ }
+
+ unique_ptr<Reporter> reporter_;
+ unique_ptr<Manager> manager_;
+};
+
+static DPMFacade* facade_;
+
+class DPMReporter : public Reporter {
+ protected:
+ void OnEvent(const EventInfo& info,
+ list<shared_ptr<item::AbstractItem>> noti_list) override {
+ LOGI("Event received (%d) !!", (int)info.GetEventType());
+ for (auto& i : noti_list) {
+ facade_->DelegateManagerEvent(info, i);
+
+ /* noti to viewers */
+ facade_->DelegateReporterEvent(info, i);
+ }
+ }
+
+ list<shared_ptr<item::AbstractItem>> OnRequestEvent(const EventInfo& info) override {
+ DBG("Get report !!! %s", info.GetItemId().c_str());
+ list<shared_ptr<item::AbstractItem>> ret {
+ make_shared<item::ButtonItem>(info.GetItemId().c_str(), "title")
+ };
+ return ret;
+ }
+
+ public:
+ DPMReporter(std::unique_ptr<IEventSender> sender,
+ std::unique_ptr<IEventListener> listener)
+ : Reporter(move(sender), move(listener)) {
+ }
+};
+
+class DPMManager : public Manager {
+ protected:
+ void OnAdd(const EventInfo& info,
+ list<shared_ptr<item::AbstractItem>> addedItem) override {
+ DBG("Add !!!");
+ //TODO: store it to DB
+ for (auto& i : addedItem)
+ facade_->DelegateReporterEvent(info, i);
+ }
+
+ void OnUpdate(const EventInfo& info,
+ shared_ptr<item::AbstractItem> updatedItem) override {
+ DBG("Update !!!");
+ facade_->DelegateReporterEvent(info, updatedItem);
+ }
+
+ void OnDelete(const EventInfo& info,
+ shared_ptr<item::AbstractItem> deletedItem) override {
+ DBG("Delete !!!");
+ facade_->DelegateReporterEvent(info, deletedItem);
+ }
+
+ list<shared_ptr<item::AbstractItem>> OnRequestEvent(const EventInfo& info) override {
+ DBG("Get !!! %s", info.GetItemId().c_str());
+ //TODO: Get it from DB
+ list<shared_ptr<item::AbstractItem>> ret {
+ make_shared<item::ButtonItem>(info.GetItemId().c_str(), "title")
+ };
+ return ret;
+ }
+
+ public:
+ DPMManager(std::unique_ptr<IEventSender> sender,
+ std::unique_ptr<IEventListener> listener)
+ : Manager(move(sender), move(listener)) {
+ }
+};
+
+HAPI int notification_ex_service_init() {
+ facade_ = new DPMFacade(
+ unique_ptr<Reporter>(
+ new DPMReporter(
+ unique_ptr<DBusSender>(new DBusSender(Manager::GetPath())),
+ unique_ptr<DBusEventListener>(new DBusEventListener(Reporter::GetPath()))
+ )
+ ),
+ unique_ptr<Manager>(
+ new DPMManager(
+ unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
+ unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath()))
+ )
+ )
+ );
+
+ return 0;
+}
+
+HAPI int notification_ex_service_fini() {
+ delete facade_;
+ return 0;
+}
+
+HAPI GDBusConnection* notification_ex_service_get_gdbus_connection() {
+ return DBusConnectionManager::GetInst().GetConnection();
+}
\ No newline at end of file
pkgmgr_add_event_callback(PKGMGR_EVENT_APP_ENABLE, _app_enabled_cb, NULL);
pkgmgr_add_event_callback(PKGMGR_EVENT_APP_DISABLE, _app_disabled_cb, NULL);
}
+
+void service_common_set_connection(GDBusConnection *conn)
+{
+ _gdbus_conn = conn;
+}
\ No newline at end of file