Add device cap Api and move ecore main loop 89/10289/1
authorHyunwoo Kim <hwlove.kim@samsung.com>
Thu, 26 Sep 2013 09:05:35 +0000 (18:05 +0900)
committerHyunwoo Kim <hwlove.kim@samsung.com>
Thu, 26 Sep 2013 09:06:09 +0000 (18:06 +0900)
Change-Id: I36f83408ff41e2d40a5e04c3a23c401fa96dcff0
Signed-off-by: Hyunwoo Kim <hwlove.kim@samsung.com>
ace/dao/AceDAO.cpp
ace/include/ace-dao-rw/AceDAO.h
ace_install/include/ace_api_install.h
ace_install/src/ace_api_install.cpp
etc/wrt_security_create_clean_db.sh
packaging/wrt-security.changes
packaging/wrt-security.spec
src/daemon/security_daemon.cpp
src/main.cpp

index 4d4ce06..45d86a0 100644 (file)
@@ -369,6 +369,19 @@ void AceDAO::setRequestedDevCaps(
     }
 }
 
+void AceDAO::removeRequestedDevCaps(
+    WidgetHandle widgetHandle)
+{
+    Try {
+        ACE_DB_DELETE(del, AceRequestedDevCaps,
+                      &AceDaoUtilities::m_databaseInterface);
+        del->Where(Equals<AceRequestedDevCaps::app_id>(widgetHandle));
+        del->Execute();
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(Exception::DatabaseError, "Failed in removeRequestedDevCaps");
+    }
+}
+
 void AceDAO::setAcceptedFeature(
     WidgetHandle widgetHandle,
     const FeatureNameVector &vector)
index 5a01cfe..ffd3bb0 100644 (file)
@@ -101,6 +101,9 @@ class AceDAO : public AceDAOReadOnly
         WidgetHandle widgetHandle,
         const RequestedDevCapsMap &permissions);
 
+    static void removeRequestedDevCaps(
+        WidgetHandle widgetHandle);
+
     static void setAcceptedFeature(
         WidgetHandle widgetHandle,
         const FeatureNameVector &vector);
index 598b96d..734861c 100644 (file)
@@ -91,6 +91,8 @@ ace_return_t ace_get_requested_dev_caps(ace_widget_handle_t handle,
 ace_return_t ace_set_requested_dev_caps(ace_widget_handle_t handle,
                                         const ace_requested_dev_cap_list_t* caps);
 
+ace_return_t ace_rem_requested_dev_caps(ace_widget_handle_t handle);
+
 // ---------------- Accepted Api featuresk API for installer ----------------
 
 
index eca3305..bda65d9 100644 (file)
@@ -166,6 +166,16 @@ ace_return_t ace_set_requested_dev_caps(
     }
     return ACE_OK;
 }
+ace_return_t ace_rem_requested_dev_caps(
+        ace_widget_handle_t handle)
+{
+    Try {
+        AceDB::AceDAO::removeRequestedDevCaps(handle);
+    } Catch(AceDB::AceDAOReadOnly::Exception::DatabaseError) {
+        return ACE_INTERNAL_ERROR;
+    }
+    return ACE_OK;
+}
 
 ace_return_t ace_set_accepted_feature(
         ace_widget_handle_t handle,
index c70c6e7..08d7a3f 100644 (file)
@@ -26,5 +26,11 @@ do
     chown 0:6026 /opt/dbspace/.$name.db-journal
     chmod 660 /opt/dbspace/.$name.db
     chmod 660 /opt/dbspace/.$name.db-journal
+    if [ -f /usr/lib/rpm-plugins/msm.so ]
+    then
+        chsmack -a "wrt-security-daemon::db" /opt/dbspace/.$name.db
+        chsmack -a "wrt-security-daemon::db" /opt/dbspace/.$name.db-journal
+    fi
 done
 
+
index 701df6d..5900738 100644 (file)
@@ -1,3 +1,8 @@
+* Thu Sep 12 2013 Hyunwoo Kim <hwlove.kim@samsung.com>
+- Use GDbus instead of dbus-glib
+- Start ecore main loop in main()
+- Add API for removing requested device capabilities of widget
+
 * Tue Sep 10 2013 Rusty Lynch <rusty.lynch@intel.com>
 * submit/tizen/20130909.074700@0773e77
 - Reset manifest to default floor domain
index 17b9c4f..ff36036 100644 (file)
@@ -1,7 +1,7 @@
 #sbs-git:slp/pkgs/s/security-server security-server 0.0.37
 Name:       wrt-security
 Summary:    Wrt security daemon
-Version:    0.0.66
+Version:    0.0.67
 Release:    0
 Group:      Security/Access Control
 License:    Apache-2.0
@@ -78,7 +78,7 @@ ln -sf /usr/lib/systemd/system/wrt-security-daemon.socket  %{buildroot}%{_libdir
 rm -rf %{buildroot}
 
 %post
-if [ -z ${2} ]; then
+if [ ! -e "/opt/dbspace/.ace.db" ]; then
     echo "This is new install of wrt-security"
     echo "Calling /usr/bin/wrt_security_create_clean_db.sh"
     /usr/bin/wrt_security_create_clean_db.sh
index 7f93e4f..44153cd 100644 (file)
@@ -35,16 +35,6 @@ IMPLEMENT_SINGLETON(SecurityDaemon::SecurityDaemon)
 
 namespace SecurityDaemon {
 
-//This is declared not in SecurityDaemon class, so no Ecore.h is needed there.
-static Ecore_Event_Handler *g_exitHandler;
-static Eina_Bool exitHandler(void */*data*/, int /*type*/, void */*event*/)
-{
-    auto& daemon = SecurityDaemonSingleton::Instance();
-    daemon.terminate(0);
-
-    return ECORE_CALLBACK_CANCEL;
-}
-
 SecurityDaemon::SecurityDaemon() :
     m_initialized(false),
     m_terminating(false),
@@ -58,10 +48,6 @@ void SecurityDaemon::initialize(int& /*argc*/, char** /*argv*/)
     LogDebug("Initializing");
     Assert(!m_initialized && "Already Initialized");
 
-    g_exitHandler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
-                                            &exitHandler,
-                                            NULL);
-
     DatabaseService::initialize();
     FOREACH (service, m_servicesList) {
         (*service)->initialize();
@@ -77,7 +63,7 @@ int SecurityDaemon::execute()
     FOREACH (service, m_servicesList) {
         (*service)->start();
     }
-    ecore_main_loop_begin();
+
     return m_returnValue;
 }
 
@@ -87,16 +73,12 @@ void SecurityDaemon::terminate(int returnValue)
     Assert(!m_terminating && "Already terminating");
     LogDebug("Terminating");
 
-    ecore_event_handler_del(g_exitHandler);
-
     m_returnValue = returnValue;
     m_terminating = true;
 
     FOREACH (service, m_servicesList) {
         (*service)->stop();
     }
-
-    ecore_main_loop_quit();
 }
 
 void SecurityDaemon::shutdown()
index a0f7bc9..dcab031 100644 (file)
 #include "privacy_manager_daemon.h"
 
 #include <pthread.h>
+#include <glib.h>
+#include <Ecore.h>
 
 static const std::string DAEMON_INSTANCE_UUID =
     "5ebf3f24-dad6-4a27-88b4-df7970efe7a9";
 
-int main(int argc, char* argv[])
+static Ecore_Event_Handler *g_exitHandler;
+static Eina_Bool exitHandler(void */*data*/, int /*type*/, void */*event*/)
 {
-    DPL::SingleInstance instance;
-    int retVal;
-    Try {
-               if (!instance.TryLock(DAEMON_INSTANCE_UUID)) {
-                       LogError("Security Daemon is already running");
-                       return -1;
-               }
+    privacy_manager_daemon_stop();
+    privacy_manager_daemon_shutdown();
 
-               auto& daemon = SecurityDaemonSingleton::Instance();
-        
-        privacy_manager_daemon_initialize();
+    auto& daemon = SecurityDaemonSingleton::Instance();
+    daemon.shutdown();                   
 
-        privacy_manager_daemon_start();
+    ecore_event_handler_del(g_exitHandler);
 
-               daemon.initialize(argc, argv);
+    ecore_main_loop_quit();
 
-               // Notification to systemd
-               sd_notify(0, "READY=1");
+    return ECORE_CALLBACK_CANCEL;
+}      
 
-               //Run daemon
-               retVal = daemon.execute();
+static Eina_Bool startHandler(void */*data*/)
+{
+    int retVal;
+       auto& daemon = SecurityDaemonSingleton::Instance();
+       
+       privacy_manager_daemon_initialize();
 
-        privacy_manager_daemon_stop();
-        privacy_manager_daemon_shutdown();
+       privacy_manager_daemon_start();
+       
+       int argc = 0;
+       char* argv = NULL;
 
-               daemon.shutdown();
-    
-        instance.Release();
+       daemon.initialize(argc, &argv);
+    retVal = daemon.execute();
+    if (retVal != 0)
+    {
+        LogError("Failed to execute daemon.");
+        ecore_main_loop_quit();
+        
+        return ECORE_CALLBACK_CANCEL;
+    }
+
+       // Notification to systemd
+       sd_notify(0, "READY=1");
+
+    return ECORE_CALLBACK_CANCEL;
+}
+
+int main(int argc, char* argv[])
+{
+       DPL::SingleInstance instance;
+       
+       Try {
+               if (!instance.TryLock(DAEMON_INSTANCE_UUID)) {
+                       LogError("Security Daemon is already running");
+                       return -1;
+               }
     } Catch (DPL::SingleInstance::Exception::LockError) {
         LogError("Failed to lock/unlock Security Daemon instance.");
-        return retVal;
+        return -1;
     }
-
-    return retVal;
+       
+    if (!ecore_init())
+    {
+        LogError("Ecore cannot be initialized");
+        return -1;
+    }
+       
+    ecore_timer_add(0.1, &startHandler, NULL);
+    g_exitHandler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, &exitHandler, NULL);
+    ecore_main_loop_begin();
+    ecore_shutdown();
+    
+    instance.Release();
+    
+    return 0;
 }