Switch to user-session daemon 80/46180/2
authorMu-Woong <muwoong.lee@samsung.com>
Mon, 17 Aug 2015 13:13:59 +0000 (22:13 +0900)
committerMu-Woong <muwoong.lee@samsung.com>
Mon, 17 Aug 2015 13:15:45 +0000 (22:15 +0900)
Change-Id: Iccc348aa4384817cbf76304587e9b7446c54ddb3
Signed-off-by: Mu-Woong <muwoong.lee@samsung.com>
CMakeLists.txt
data/template-json-to-sql.sh [deleted file]
data/trigger-template.json [deleted file]
packaging/context-service.service
packaging/context-service.spec
packaging/org.tizen.context.conf
src/db_mgr_impl.cpp
src/dbus_server_impl.cpp

index 6028a35916dad39aa3f39325474fcac2d77ab337..65c48c7935bafd051754c084ff8fd3983d601802 100644 (file)
@@ -11,6 +11,7 @@ MESSAGE("Sources: ${SRCS}")
 
 # Dependencies
 SET(DEPS
+       libtzplatform-config
        vconf
        libxml-2.0
        sqlite3
diff --git a/data/template-json-to-sql.sh b/data/template-json-to-sql.sh
deleted file mode 100644 (file)
index c5dba2c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-function print_sql {
-       echo "UPDATE context_trigger_template SET j_template='{$2 }' WHERE name='$1';"
-       echo "INSERT OR IGNORE INTO context_trigger_template (name, j_template) VALUES ('$1', '{$2 }');"
-}
-
-echo "CREATE TABLE IF NOT EXISTS context_trigger_template ("
-echo " name TEXT DEFAULT '' NOT NULL PRIMARY KEY,"
-echo " j_template TEXT DEFAULT '' NOT NULL);"
-
-template_json_file="$1"
-
-while read -r line
-do
-       keyword=`echo $line | awk '{print $1}' | tr -cd '[:alpha:]'`
-
-       if [[ $keyword = "name" ]]; then
-
-               if [ -n "$template" ]; then
-                       print_sql "$name" "$template"
-                       template=""
-               fi
-
-               name=`echo $line | tr -d '":,' | awk '{print $2}'`
-       fi
-
-       if [[ $keyword = "name" ]] || [[ $keyword = "attributes" ]] || [[ $keyword = "option" ]]; then
-               template="$template $line"
-       fi
-
-done < "$template_json_file"
-
-print_sql "$name" "$template"
diff --git a/data/trigger-template.json b/data/trigger-template.json
deleted file mode 100644 (file)
index e515ecb..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-{
-       "templates": [
-               {
-                       "name": "time/alarm",
-                       "attributes": ["TimeOfDay", "DayOfWeek"]
-               },
-               {
-                       "name": "time/now",
-                       "attributes": ["TimeOfDay", "DayOfWeek", "DayOfMonth"]
-               },
-               {
-                       "name": "system/battery",
-                       "attributes": ["Level", "IsCharging"]
-               },
-               {
-                       "name": "system/charger",
-                       "attributes": ["IsConnected"]
-               },
-               {
-                       "name": "system/gps",
-                       "attributes": ["State"]
-               },
-               {
-                       "name": "system/headphone",
-                       "attributes": ["IsConnected", "Type"]
-               },
-               {
-                       "name": "system/psmode",
-                       "attributes": ["IsEnabled"]
-               },
-               {
-                       "name": "system/usb",
-                       "attributes": ["IsConnected"]
-               },
-               {
-                       "name": "system/wifi",
-                       "attributes": ["State", "BSSID"]
-               },
-               {
-                       "name": "social/call",
-                       "attributes": ["Medium", "State", "Address"]
-               },
-               {
-                       "name": "social/email",
-                       "attributes": ["Event"]
-               },
-               {
-                       "name": "social/message",
-                       "attributes": ["Event", "Type", "Address"]
-               },
-               {
-                       "name": "activity/stationary",
-                       "attributes": ["Event", "Accuracy"]
-               },
-               {
-                       "name": "activity/walking",
-                       "attributes": ["Event", "Accuracy"]
-               },
-               {
-                       "name": "activity/running",
-                       "attributes": ["Event", "Accuracy"]
-               },
-               {
-                       "name": "activity/in_vehicle",
-                       "attributes": ["Event", "Accuracy"]
-               },
-               {
-                       "name": "place/geofence",
-                       "attributes": ["Event"],
-                       "option": ["PlaceId"]
-               },
-               {
-                       "name": "stats/app/frequency",
-                       "attributes": ["Rank", "TotalCount"],
-                       "option": ["AppId", "TimeOfDay", "DayOfWeek"]
-               },
-               {
-                       "name": "stats/contact/frequency",
-                       "attributes": ["Rank", "TotalCount"],
-                       "option": ["Address", "TimeOfDay", "DayOfWeek"]
-               },
-               {
-                       "name": "stats/music/frequency",
-                       "attributes": ["TotalCount"],
-                       "option": ["TimeOfDay", "DayOfWeek"]
-               },
-               {
-                       "name": "stats/video/frequency",
-                       "attributes": ["TotalCount"],
-                       "option": ["TimeOfDay", "DayOfWeek"]
-               }
-       ]
-}
index 5b5a8455baf11ef666ee6f01c0e0508cd3eefa29..ba392a55eb37e0e87f03b528716c2d7ab3a64ba0 100644 (file)
@@ -3,12 +3,10 @@ Description=Contextual Service Framework Daemon
 
 [Service]
 Type=dbus
-User=system
-Group=system
 BusName=org.tizen.context
 ExecStart=/usr/bin/contextd
 Restart=always
 RestartSec=1
 
 [Install]
-WantedBy=graphical.target
+WantedBy=default.target
index 9d4bcb8b7da2ff6fc28b4a7d782d538c92abcaf0..12721c3e6efe4c5c79b258ebf03c65c9168a4fa4 100644 (file)
@@ -13,6 +13,7 @@ Source2:      org.tizen.context.conf
 
 BuildRequires: cmake
 BuildRequires: sed
+BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(sqlite3)
@@ -39,7 +40,6 @@ BuildRequires: pkgconfig(place-context-provider)
 Requires(preun): /usr/bin/systemctl
 Requires(post): sys-assert
 Requires(post): /usr/bin/systemctl
-Requires(post): /usr/bin/sqlite3
 Requires(postun): /usr/bin/systemctl
 
 %description
@@ -72,48 +72,38 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p %{buildroot}%{_unitdir}
+mkdir -p %{buildroot}%{_unitdir_user}
 mkdir -p %{buildroot}%{_datadir}/license
 mkdir -p %{buildroot}%{_datadir}/packages
-mkdir -p %{buildroot}/opt/dbspace
 mkdir -p %{buildroot}/opt/data/context-service
-sqlite3 %{buildroot}/opt/dbspace/.context-service.db "PRAGMA journal_mode = PERSIST;"
-sqlite3 %{buildroot}/opt/dbspace/.context-service.db "CREATE TABLE VERSION (VERSION TEXT);"
-sqlite3 %{buildroot}/opt/dbspace/.context-service.db "INSERT INTO VERSION VALUES ('%{version}');"
-install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}
+install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir_user}
 cp LICENSE %{buildroot}%{_datadir}/license/%{name}
 #sed -i "s/^\tversion=\".*\"/\tversion=\"%{version}\"/g" packaging/context-service.xml
 #cp packaging/context-service.xml %{buildroot}%{_datadir}/packages/
-cp data/trigger-template.json %{buildroot}/opt/data/context-service/
-sh data/template-json-to-sql.sh data/trigger-template.json > %{buildroot}/opt/data/context-service/trigger-template.sql
 
-mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
-install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dbus-1/system.d/
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/session.d
+install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dbus-1/session.d/
 
 %post
-sqlite3 -echo /opt/dbspace/.context-service.db < /opt/data/context-service/trigger-template.sql
-mkdir -p %{_unitdir}/graphical.target.wants
-ln -s ../context-service.service %{_unitdir}/graphical.target.wants/
+mkdir -p %{_unitdir_user}/default.target.wants
+ln -s ../context-service.service %{_unitdir_user}/default.target.wants/
 /sbin/ldconfig
-systemctl daemon-reload
+#systemctl daemon-reload
 
 %preun
-if [ $1 == 0 ]; then
-    systemctl stop context-service
-fi
+#if [ $1 == 0 ]; then
+#    systemctl stop context-service
+#fi
 
 %postun
-rm -f %{_unitdir}/graphical.target.wants/context-service.service
-systemctl daemon-reload
+rm -f %{_unitdir_user}/default.target.wants/context-service.service
+#systemctl daemon-reload
 /sbin/ldconfig
 
 %files
 %manifest packaging/%{name}.manifest
-%config %{_sysconfdir}/dbus-1/system.d/*
+%config %{_sysconfdir}/dbus-1/session.d/*
 %{_bindir}/*
-%{_unitdir}/context-service.service
+%{_unitdir_user}/context-service.service
 %{_datadir}/license/%{name}
 #%{_datadir}/packages/*.xml
-%defattr(0600,system,system,-)
-/opt/data/context-service/*
-%config(noreplace) /opt/dbspace/.context-service.db*
index be59b20b1e8e115c19053195a1cfd1e119f5c5eb..2455458f58b7380d274f420ec8db29da2948862b 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 <busconfig>
-       <policy user="system">
+       <policy smack="System">
                <allow own="org.tizen.context"/>
                <allow send_destination="org.tizen.context"/>
                <allow send_interface="org.tizen.context"/>
index a75f292a9ab608ebdbc0db6092bc629f9de9773a..a2710496d818ddc1d261095f00de59ec26962dc9 100644 (file)
 #include <string>
 #include <sstream>
 #include <list>
+#include <tzplatform_config.h>
 #include <scope_mutex.h>
 #include "server.h"
 #include "db_mgr_impl.h"
 
-//TODO: conf file for this kind of env. params.
-#define CONTEXT_DB_PATH "/opt/dbspace/.context-service.db"
+#define CONTEXT_DB_PATH tzplatform_mkpath(TZ_USER_DB, ".context-service.db")
 
 static bool initialized = false;
 static GThread *mainthread = NULL;
@@ -71,7 +71,7 @@ bool ctx::db_manager_impl::open()
        sqlite3 *db = NULL;
        int r = sqlite3_open(CONTEXT_DB_PATH, &db);
 
-       IF_FAIL_RETURN_TAG(r == SQLITE_OK, false, _E, "DB Error: %s", sqlite3_errmsg(db));
+       IF_FAIL_RETURN_TAG(r == SQLITE_OK, false, _E, "Path: %s / Error: %s", CONTEXT_DB_PATH, sqlite3_errmsg(db));
 
        db_handle = db;
        return true;
index aeee10315f9e7608f93c4de43f1edeb050ef9bfc..dec533531bc61f880e90d4e1f5fd7eebe47246e4 100644 (file)
@@ -173,7 +173,7 @@ bool ctx::dbus_server_impl::init()
        dbus_node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
        IF_FAIL_RETURN_TAG(dbus_node_info != NULL, false, _E, "Initialization failed");
 
-       dbus_owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, DBUS_DEST, G_BUS_NAME_OWNER_FLAGS_NONE,
+       dbus_owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_DEST, G_BUS_NAME_OWNER_FLAGS_NONE,
                        on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
 
        _instance = this;