+++ /dev/null
-# 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})
+++ /dev/null
-#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"
-#define HIDE_TIME 3.0
-
-SET_TAG(SERVICE_NAME)
-
-struct _priv {
- Evas_Object *win;
- Evas_Object *popup;
-
- time_t last_time;
-};
-
-static void _hide(void *data, Evas_Object *obj, void *event_info)
-{
- evas_object_hide(data);
-}
-
-void _show_notification(struct _priv *priv, notification_h noti)
-{
- char *title = NULL;
- char *content = NULL;
-
- notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &title);
- notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
-
- elm_object_text_set(priv->popup, content);
- elm_object_part_text_set(priv->popup, "title,text", title);
- evas_object_show(priv->popup);
- evas_object_show(priv->win);
-}
-
-void _notification_changed_cb(void *data, notification_type_e notif_type)
-{
- struct _priv *priv;
- time_t latest_time;
- notification_h noti = NULL;
- notification_list_h noti_list = NULL;
-
- if (notif_type != NOTIFICATION_TYPE_NOTI)
- return;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
- priv = data;
-
- notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list);
- if (noti_list) {
- noti = notification_list_get_data(noti_list);
- if (noti) {
- notification_get_insert_time(noti, &latest_time);
-
- if (latest_time > priv->last_time) {
- _show_notification(priv, noti);
- priv->last_time = latest_time;
- }
- }
- }
-
- notification_free_list(noti_list);
-}
-
-time_t _get_last_time(void)
-{
- time_t last_time = 0;
- notification_h noti = NULL;
- notification_list_h noti_list = NULL;
-
- notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list);
- if (noti_list) {
- noti = notification_list_get_data(noti_list);
- if (noti)
- notification_get_insert_time(noti, &last_time);
- }
-
- notification_free_list(noti_list);
-
- return last_time;
-}
-
-int _create_popup(struct _priv *priv)
-{
- Evas_Object *btn;
-
- priv->win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
- if (!priv->win) {
- _ERR("elm_win_add failed");
- return -1;
- }
- elm_win_autodel_set(priv->win, EINA_TRUE);
- elm_win_alpha_set(priv->win, EINA_TRUE);
-
- priv->popup = elm_popup_add(priv->win);
- if (!priv->popup) {
- evas_object_del(priv->win);
- _ERR("elm_win_add failed");
- return -1;
- }
- elm_popup_orient_set(priv->popup, ELM_POPUP_ORIENT_BOTTOM_LEFT);
-
- btn = elm_button_add(priv->popup);
- elm_object_text_set(btn, "OK");
- elm_object_part_content_set(priv->popup, "button1", btn);
- evas_object_smart_callback_add(btn, "clicked", _hide, priv->win);
-
- return 0;
-}
-
-void _destroy_popup(struct _priv *priv)
-{
- evas_object_del(priv->popup);
- evas_object_del(priv->win);
-}
-
-int main(int argc, char **argv)
-{
- struct _priv *priv;
- notification_error_e error_n;
-
- elm_init(0, NULL);
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return 0;
- }
-
- if (_create_popup(priv) < 0) {
- _ERR("failed to create popup");
- free(priv);
- return 0;
- }
-
- priv->last_time = _get_last_time();
-
- error_n = NOTIFICATION_ERROR_SERVICE_NOT_READY;
- while (error_n != NOTIFICATION_ERROR_NONE) {
- error_n = notification_resister_changed_cb(
- _notification_changed_cb, priv);
- _DBG("Could not register with notifications server");
- sleep(5);
- }
-
- elm_run();
-
- _destroy_popup(priv);
- free(priv);
-
- elm_shutdown();
-
- return 0;
-}
%define _resdir %{_pkgdir}/res
%define _datadir %{_pkgdir}/data
%define _edjedir %{_resdir}/edje
-%define _servicedir %{_prefix}/bin
%define _manifestdir %{_datarootdir}/packages
%description
-DBINDIR=%{_bindir} \
-DEDJEDIR=%{_edjedir} \
-DMANIFESTDIR=%{_manifestdir} \
- -DSERVICEDIR=%{_servicedir} \
-DVERSION=%{version}
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
-install -m 0644 daemon/notification-display.path %{buildroot}/%{_unitdir_user}/notification-display.path
-ln -sf ../notification-display.path %{buildroot}/%{_unitdir_user}/default.target.wants/notification-display.path
%clean
rm -rf %{buildroot}
%defattr(-,root,root,-)
%{_bindir}/*
%{_resdir}/*
-%{_servicedir}/*
%{_datadir}
%{_manifestdir}/%{name}.xml
-%{_unitdir_user}/default.target.wants/notification-display.path
-%{_unitdir_user}/notification-display.service
-%{_unitdir_user}/notification-display.path