capi-system-info
capi-appfw-app-manager
appsvc
- capi-security-privilege-manager
alarm-service
notification
cynara-creds-gdbus
ADD_DEFINITIONS("-D_EMULATOR")
ENDIF("${ARCH}" STREQUAL "arm")
+IF("${MAINLOOP}" STREQUAL "ecore")
+ ADD_DEFINITIONS("-D_USE_ECORE_MAIN_LOOP_")
+ SET(DEPS
+ ${DEPS}
+ ecore
+ )
+ENDIF("${MAINLOOP}" STREQUAL "ecore")
+
# Common Options
INCLUDE(FindPkgConfig)
INCLUDE_DIRECTORIES(
<Allow subject="video/history/play_freq"/>\r
</Privilege>\r
\r
- <Privilege name="mediahistory.admin">\r
- <Allow subject="music/event/start"/>\r
- <Allow subject="music/event/stop"/>\r
- <Allow subject="video/event/start"/>\r
- <Allow subject="video/event/stop"/>\r
- </Privilege>\r
-\r
<Privilege name="callhistory.read">\r
<Allow subject="contact/history/comm_freq"/>\r
</Privilege>\r
<request>
<smack request="xorg" type="rw"/>
<smack request="security-server::api-cookie-check" type="w"/>
- <smack request="security-server::api-privilege-by-pid" type="w"/>
+ <smack request="security-server::api-app-privilege-by-name" type="rlw"/>
+ <smack request="security-server::api-permissions" type="rlw"/>
<smack request="vasum::manage" type="rw"/>
<smack request="sys-assert::core" type="rwxat"/>
<smack request="device::app_logging" type="rw"/>
<smack request="device::sys_logging" type="rw"/>
<smack request="deviced::display" type="rw"/>
- <smack request="ail::db" type="rlx"/>
- <smack request="pkgmgr" type="r"/>
- <smack request="pkgmgr::db" type="rwx"/>
- <smack request="pkgmgr::info" type="r"/>
<smack request="alarm-server::alarm" type="rw"/>
<smack request="libaccounts-svc" type="r"/>
<smack request="libaccounts-svc::db" type="rl"/>
<smack request="tizen::vconf::message" type="r"/>
<smack request="tizen::vconf::setting::admin" type="rl"/>
<smack request="tizen::vconf::volume::set" type="rl"/>
+ <smack request="sound_server" type="rlwx"/>
+ <smack request="media-data::db" type="rlw"/>
</request>
</define>
<request>
Source1: context-service.service
Source2: org.tizen.context.service
+# For active window hooking, we need to use 'ecore' mainloop instead of the 'glib' mainloop.
+%define MAINLOOP ecore
+
BuildRequires: cmake
BuildRequires: sed
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(appsvc)
-BuildRequires: pkgconfig(capi-security-privilege-manager)
BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(notification)
+%if "%{MAINLOOP}" == "ecore"
+BuildRequires: pkgconfig(ecore)
+%endif
+
BuildRequires: pkgconfig(cynara-creds-gdbus)
BuildRequires: pkgconfig(clips)
BuildRequires: pkgconfig(context-common)
BuildRequires: pkgconfig(context)
-BuildRequires: context-internal
BuildRequires: pkgconfig(device-context-provider)
BuildRequires: pkgconfig(statistics-context-provider)
export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE"
export FFLAGS+=" -DTIZEN_ENGINEER_MODE"
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCH=%{ARCH} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?tizen_profile_name}
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCH=%{ARCH} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?tizen_profile_name} -DMAINLOOP=%{MAINLOOP}
make %{?jobs:-j%jobs}
%install
</service-application>
<privileges>
<privilege>http://tizen.org/privilege/location</privilege>
+ <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
</privileges>
</manifest>
#include <string>
#include <map>
-#include <privilege_checker.h>
+#include <security-server.h>
#include <types_internal.h>
#include "config_loader.h"
#include "privilege.h"
return true;
}
- _D("PkgId: %s, Priv: %s", pkg_id, (it->second).c_str());
- std::string priv = "http://tizen.org/privilege/";
+ std::string priv = "org.tizen.privilege.";
priv += (it->second).c_str();
- int ret = privilege_checker_check_package_privilege(pkg_id, priv.c_str());
- _D("Privilege Check Result: %#x", ret);
- return (ret == PRIV_CHECKER_ERR_NONE);
+ int result = 0;
+ int err = security_server_app_has_privilege(pkg_id, PERM_APP_TYPE_EFL, priv.c_str(), &result);
+
+ _D("PkgId: %s, PrivName: %s, Enabled: %d", pkg_id, (it->second).c_str(), result);
+ IF_FAIL_RETURN_TAG(err == SECURITY_SERVER_API_SUCCESS, false, _E, "Privilege checking failed");
+
+ return (result == 1);
}
#include "zone_util_impl.h"
#include "dbus_server_impl.h"
+static bool conn_acquired = false;
+static bool name_acquired = false;
static ctx::dbus_server_impl *_instance = NULL;
static GDBusConnection *dbus_connection = NULL;
static guint dbus_owner_id = 0;
return;
}
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", ERR_OPERATION_FAILED, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
+ delete request;
}
static void handle_method_call(GDBusConnection *conn, const gchar *sender,
raise(SIGTERM);
}
+ conn_acquired = true;
dbus_connection = conn;
+
+ _I("Dbus connection acquired");
+
+ if (name_acquired)
+ ctx::server::activate();
}
static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
{
+ name_acquired = true;
_SI("Dbus name acquired: %s", name);
+
+ if (conn_acquired)
+ ctx::server::activate();
}
static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data)
* limitations under the License.
*/
-//#define _USE_ECORE_MAIN_LOOP_
-
#include <stdlib.h>
#include <new>
#include <glib.h>
static ctx::dbus_server_impl *dbus_handle = NULL;
static ctx::context_trigger *trigger = NULL;
-void ctx::server::run()
+void ctx::server::initialize()
{
- if (started) {
- _W("Started already");
- return;
- }
-
_I("Init MainLoop");
#ifdef _USE_ECORE_MAIN_LOOP_
ecore_init();
mainloop = g_main_loop_new(NULL, FALSE);
#endif
+ _I("Init Dbus Connection");
+ dbus_handle = new(std::nothrow) ctx::dbus_server_impl();
+ IF_FAIL_VOID_TAG(dbus_handle, _E, "Memory allocation failed");
+
+ dbus_server::set_instance(dbus_handle);
+ IF_FAIL_VOID_TAG(dbus_handle->init(), _E, "Initialization Failed");
+
+ // Start the main loop
+ _I(CYAN("Launching Context-Service"));
+#ifdef _USE_ECORE_MAIN_LOOP_
+ ecore_main_loop_begin();
+#else
+ g_main_loop_run(mainloop);
+#endif
+}
+
+void ctx::server::activate()
+{
+ IF_FAIL_VOID(!started);
+
bool result = false;
_I("Init vasum context");
result = trigger->init(context_mgr);
IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
- _I("Init Dbus Connection");
- dbus_handle = new(std::nothrow) ctx::dbus_server_impl();
- IF_FAIL_CATCH_TAG(dbus_handle, _E, "Memory allocation failed");
- dbus_server::set_instance(dbus_handle);
- result = dbus_handle->init();
- IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
-
- // Start the main loop
started = true;
_I(CYAN("Context-Service Launched"));
+ return;
+
+CATCH:
+ _E(RED("Launching Failed"));
+
+ // Stop the main loop
#ifdef _USE_ECORE_MAIN_LOOP_
- ecore_main_loop_begin();
+ ecore_main_loop_quit();
#else
- g_main_loop_run(mainloop);
+ g_main_loop_quit(mainloop);
#endif
+}
+void ctx::server::release()
+{
_I(CYAN("Terminating Context-Service"));
-
_I("Release Context Trigger");
- trigger->release();
+ if (trigger)
+ trigger->release();
_I("Release Analyzer Manager");
- context_mgr->release();
+ if (context_mgr)
+ context_mgr->release();
_I("Release Dbus Connection");
- dbus_handle->release();
+ if (dbus_handle)
+ dbus_handle->release();
_I("Close the Database");
- database_mgr->release();
+ if (database_mgr)
+ database_mgr->release();
_I("Release Timer Manager");
- timer_mgr->release();
+ if (timer_mgr)
+ timer_mgr->release();
_I("Release Access control configuration");
ctx::privilege_manager::release();
delete dbus_handle;
delete database_mgr;
delete timer_mgr;
- return;
-
-CATCH:
- _E(RED("Launching Failed"));
- delete trigger;
- delete context_mgr;
- delete dbus_handle;
- delete database_mgr;
- delete timer_mgr;
}
void ctx::server::send_request(ctx::request_info* request)
g_type_init();
#endif
- ctx::server::run();
+ ctx::server::initialize();
+ ctx::server::release();
return EXIT_SUCCESS;
}
namespace server {
- void run();
+ void initialize();
+ void activate();
+ void release();
void send_request(request_info* request);
}; /* namespace ctx::server */