Add notification display daemon 46/42046/7
authorjinwoo.shin <jw0227.shin@samsung.com>
Mon, 22 Jun 2015 11:46:39 +0000 (20:46 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Tue, 23 Jun 2015 07:31:32 +0000 (16:31 +0900)
Change-Id: If3ea6f75a691660036d85121814bfefb7b3fcebc
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
CMakeLists.txt
daemon/CMakeLists.txt [new file with mode: 0644]
daemon/notification-display.service [new file with mode: 0644]
daemon/notification_display_service.c [new file with mode: 0644]
packaging/org.tizen.infosquare.spec

index 280822a..eb89b99 100644 (file)
@@ -76,3 +76,4 @@ INSTALL(FILES ${PACKAGE_NAME}.xml DESTINATION ${MANIFESTDIR})
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/images DESTINATION ${RESDIR})
 
 ADD_SUBDIRECTORY(data)
+ADD_SUBDIRECTORY(daemon)
diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7d8c765
--- /dev/null
@@ -0,0 +1,41 @@
+# Copyright (c) 2014 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.
+#
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT("notification-display" C)
+
+MESSAGE(STATUS "PREFIX: " ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(SERVICE_PKGS REQUIRED
+               glib-2.0
+               notification
+               app-utils)
+
+SET(SERVICE_SRCS
+               notification_display_service.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
+
+FOREACH(flag ${SERVICE_PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SERVICE_SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SERVICE_PKGS_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${SERVICEDIR})
diff --git a/daemon/notification-display.service b/daemon/notification-display.service
new file mode 100644 (file)
index 0000000..8dccc65
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Notifications Display daemon
+Requires=notifications.service display-manager-run.service
+After=notifications.service display-manager-run.service
+
+[Service]
+Type=simple
+EnvironmentFile=/run/tizen-system-env
+ExecStart=/usr/bin/notification-display
+Restart=always
+
+[Install]
+WantedBy=default.target
+
diff --git a/daemon/notification_display_service.c b/daemon/notification_display_service.c
new file mode 100644 (file)
index 0000000..f6f4b85
--- /dev/null
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <glib.h>
+#include <Elementary.h>
+#include <app_debug.h>
+#include <notification.h>
+#include <notification_internal.h>
+
+#define SERVICE_NAME "notification-display"
+
+SET_TAG(SERVICE_NAME)
+
+void _dbg_notification(notification_h noti)
+{
+       char *pkgname = NULL;
+       char *title = NULL;
+       char *content = NULL;
+       char *image_path = NULL;
+
+       notification_get_pkgname(noti, &pkgname);
+       notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &title);
+       notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
+       notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path);
+
+       _DBG("\nNew Notification : %s", title);
+       _DBG("Icon : %s", image_path);
+       _DBG("Message : %s", content);
+}
+
+void _notification_changed_cb(void *data, notification_type_e notif_type)
+{
+       notification_h noti = NULL;
+       notification_list_h noti_list = NULL, get_list;
+
+       notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
+       get_list = notification_list_get_tail(noti_list);
+       if (get_list) {
+               noti = notification_list_get_data(get_list);
+               _dbg_notification(noti);
+       }
+
+       notification_free_list(noti_list);
+}
+
+int main(int argc, char **argv)
+{
+       notification_error_e error_n;
+       Evas_Object *win;
+
+       elm_init(0, NULL);
+
+       win = elm_win_add(NULL, SERVICE_NAME, ELM_WIN_NOTIFICATION);
+       elm_win_alpha_set(win, EINA_TRUE);
+       evas_object_show(win);
+
+       error_n = NOTIFICATION_ERROR_SERVICE_NOT_READY;
+       while (error_n != NOTIFICATION_ERROR_NONE) {
+               error_n = notification_resister_changed_cb(
+                               _notification_changed_cb, NULL);
+               _DBG("Could not register with notifications server");
+               sleep(5);
+       }
+
+       elm_run();
+
+       elm_shutdown();
+
+       return 0;
+}
index b7592a2..bc897e2 100644 (file)
@@ -22,6 +22,7 @@ BuildRequires: edje-bin
 %define _resdir %{_pkgdir}/res
 %define _datadir %{_pkgdir}/data
 %define _edjedir %{_resdir}/edje
+%define _servicedir %{_prefix}/bin
 %define _manifestdir %{_datarootdir}/packages
 
 %description
@@ -37,6 +38,7 @@ cmake \
        -DBINDIR=%{_bindir} \
        -DEDJEDIR=%{_edjedir} \
        -DMANIFESTDIR=%{_manifestdir} \
+       -DSERVICEDIR=%{_servicedir} \
        -DVERSION=%{version}
 
 make %{?jobs:-j%jobs}
@@ -44,6 +46,9 @@ make %{?jobs:-j%jobs}
 %install
 %make_install
 install --directory %{buildroot}/%{_datadir}
+mkdir -p %{buildroot}/%{_unitdir_user}/default.target.wants
+install -m 0644 daemon/notification-display.service %{buildroot}/%{_unitdir_user}/notification-display.service
+ln -sf ../notification-display.service %{buildroot}/%{_unitdir_user}/default.target.wants/notification-display.service
 
 %clean
 rm -rf %{buildroot}
@@ -52,5 +57,8 @@ rm -rf %{buildroot}
 %defattr(-,root,root,-)
 %{_bindir}/*
 %{_resdir}/*
+%{_servicedir}/*
 %{_datadir}
 %{_manifestdir}/%{name}.xml
+%{_unitdir_user}/default.target.wants/notification-display.service
+%{_unitdir_user}/notification-display.service