PROJECT(context-service)
INCLUDE(GNUInstallDirs)
-SET(target "contextd")
-
-SET(DEPS "libsystemd-login glib-2.0 gio-2.0 dlog capi-base-common alarm-service")
-SET(DEPS "${DEPS} context-common-server")
-SET(DEPS "${DEPS} context-app-history-server")
-SET(DEPS "${DEPS} context-sensor-recorder-server")
-SET(DEPS "${DEPS} context-store-server")
-SET(DEPS "${DEPS} context-job-scheduler-server")
-
-SET(INCDIR "${CMAKE_INSTALL_INCLUDEDIR}/context-service")
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_INSTALL_PREFIX}/${INCDIR}/private
-)
-
-FILE(GLOB_RECURSE SRCS src/*.cpp)
-MESSAGE("Sources: ${SRCS}")
-
ADD_DEFINITIONS(-O2 -Wall -fPIC -fPIE -fdata-sections -ffunction-sections -fvisibility=hidden)
-ADD_DEFINITIONS(-DLOG_TAG="CONTEXT")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -pie -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section")
-INCLUDE(FindPkgConfig)
-pkg_check_modules(DEPS_PKG REQUIRED ${DEPS})
-
-FOREACH(flag ${DEPS_PKG_CFLAGS})
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
-ENDFOREACH(flag)
-
-ADD_EXECUTABLE(${target} ${SRCS})
-TARGET_LINK_LIBRARIES(${target} ${DEPS_PKG_LDFLAGS})
-
-INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR})
+ADD_SUBDIRECTORY(src/server)
+ADD_SUBDIRECTORY(src/agent)
Group: Service/Context
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-Source1: context-service.service
+Source1: contextd.service
Source2: org.tizen.context.conf
+Source3: contextd-agent.service
+Source4: org.tizen.contextagent.conf
+Source5: org.tizen.contextagent.service
BuildRequires: cmake
BuildRequires: pkgconfig(libsystemd-login)
%description
This is a systemd service that contains all features provided by the Tizen Contextual Service Framework.
+
+%package -n context-agent
+Summary: User-level agent service of the Tizen Contextual Service Framework
+
+%description -n context-agent
+This is a systemd service that runs in the user session to assist the main service daemon of the Contextual Service Framework.
+
+
%prep
%setup -q
mkdir -p %{buildroot}%{_unitdir}/default.target.wants
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}
-ln -s ../context-service.service %{buildroot}%{_unitdir}/default.target.wants/context-service.service
+ln -s ../contextd.service %{buildroot}%{_unitdir}/default.target.wants/contextd.service
mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dbus-1/system.d/
+mkdir -p %{buildroot}%{_unitdir_user}
+install -m 0644 %{SOURCE3} %{buildroot}%{_unitdir_user}
+
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/session.d
+install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/dbus-1/session.d/
+
+mkdir -p %{buildroot}/usr/share/dbus-1/services
+install -m 0644 %{SOURCE5} %{buildroot}/usr/share/dbus-1/services/
+
%files
%manifest packaging/%{name}.manifest
%config %{_sysconfdir}/dbus-1/system.d/*
-%{_bindir}/*
-%{_unitdir}/context-service.service
-%{_unitdir}/*/context-service.service
+%{_bindir}/contextd
+%{_unitdir}/contextd.service
+%{_unitdir}/*/contextd.service
+%license LICENSE
+
+%files -n context-agent
+%manifest packaging/%{name}.manifest
+%config %{_sysconfdir}/dbus-1/session.d/*
+%{_bindir}/contextd-agent
+%{_unitdir_user}/contextd-agent.service
+/usr/share/dbus-1/services/*
%license LICENSE
--- /dev/null
+[Unit]
+Description=Contextual Service Framework User-Level Agent Daemon
+
+[Service]
+Type=dbus
+BusName=org.tizen.contextagent
+ExecStart=/usr/bin/contextd-agent
+Restart=on-failure
+RestartSec=1
[Unit]
-Description=Contextual Service Framework Daemon
+Description=Contextual Service Framework Server Daemon
[Service]
User=service_fw
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy smack="System">
+ <deny own="org.tizen.contextagent"/>
+ <allow send_destination="org.tizen.contextagent"/>
+ </policy>
+ <policy smack="User">
+ <allow own="org.tizen.contextagent"/>
+ <allow send_destination="org.tizen.contextagent"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="org.tizen.contextagent"/>
+ </policy>
+</busconfig>
--- /dev/null
+[Unit]
+Description=Contextual Service Framework User-Level Agent D-Bus
+
+[D-BUS Service]
+Name=org.tizen.contextagent
+Exec=/bin/false
+SystemdService=contextd-agent.service
--- /dev/null
+/*
+ * Copyright (c) 2017 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 <cstdlib>
+
+int main(int argc, char* argv[])
+{
+ return EXIT_SUCCESS;
+}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(target "contextd-agent")
+
+SET(DEPS glib-2.0 gio-2.0 dlog capi-base-common)
+
+FILE(GLOB_RECURSE SRCS *.cpp)
+MESSAGE("Sources: ${SRCS}")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(DEPS_AGENT_PKG REQUIRED ${DEPS})
+
+FOREACH(flag ${DEPS_AGENT_PKG_CFLAGS})
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_EXECUTABLE(${target} ${SRCS})
+SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-AGENT\"")
+TARGET_LINK_LIBRARIES(${target} ${DEPS_AGENT_PKG_LDFLAGS})
+
+INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR})
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(target "contextd")
+
+SET(DEPS libsystemd-login glib-2.0 gio-2.0 dlog capi-base-common alarm-service)
+SET(DEPS ${DEPS} context-common-server)
+SET(DEPS ${DEPS} context-app-history-server)
+SET(DEPS ${DEPS} context-sensor-recorder-server)
+SET(DEPS ${DEPS} context-store-server)
+SET(DEPS ${DEPS} context-job-scheduler-server)
+
+SET(INCDIR "${CMAKE_INSTALL_INCLUDEDIR}/context-service")
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_INSTALL_PREFIX}/${INCDIR}/private
+)
+
+FILE(GLOB_RECURSE SRCS *.cpp)
+MESSAGE("Sources: ${SRCS}")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(DEPS_SERVER_PKG REQUIRED ${DEPS})
+
+FOREACH(flag ${DEPS_SERVER_PKG_CFLAGS})
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_EXECUTABLE(${target} ${SRCS})
+SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT\"")
+TARGET_LINK_LIBRARIES(${target} ${DEPS_SERVER_PKG_LDFLAGS})
+
+INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR})