ContextStoreService realizes ISystemService instead of IService 34/136334/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 29 Jun 2017 06:51:22 +0000 (15:51 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 29 Jun 2017 06:51:22 +0000 (15:51 +0900)
Change-Id: Ie77ef642fa6ee3403e286c32c71d09f70241fda1
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/private/ContextStoreService.h
src/server-dummy/ContextStoreService.cpp
src/server/ContextStore.cpp
src/server/ContextStoreService.cpp
src/server/MethodCallHandler.cpp
src/server/MethodCallHandler.h

index e5619c9..33bbcc8 100644 (file)
@@ -19,7 +19,7 @@
 
 /* This header SHOULD NOT be included by other headers in this directory. */
 
-#include <IService.h>
+#include <ISystemService.h>
 #include <IServiceRunner.h>
 #include <IClient.h>
 #include <IMethodCallHandler.h>
@@ -28,28 +28,24 @@ namespace ctx {
 
        class StoreManager;
 
-       class EXPORT_API ContextStoreService : public IService {
+       class EXPORT_API ContextStoreService : public ISystemService {
        public:
                ContextStoreService();
                ~ContextStoreService();
 
+               // Inherited from IService
                void setServiceRunner(IServiceRunner* runner);
-
-               bool isUserService();
-
                const char* getServiceName();
                const char* getMethodSpecs();
+               IMethodCallHandler* createMethodCallHandler(IClient* client);
 
+               // Inherited from ISystemService
                bool prepare();
                void cleanup();
+               void onUserActivated(uid_t uid);
+               void onUserDeactivated(uid_t uid);
 
-               void onUserActivated();
-               void onUserDeactivated();
-
-               IMethodCallHandler* createMethodCallHandler(IClient* client);
-
-               GMainContext* getMainContext();
-
+               // Own members
                StoreManager* getStoreManager();
 
        private:
index 469fdc4..9e7b503 100644 (file)
@@ -35,17 +35,17 @@ void ContextStoreService::setServiceRunner(IServiceRunner* runner)
 {
 }
 
-bool ContextStoreService::isUserService()
+const char* ContextStoreService::getServiceName()
 {
-       return false;
+       return NULL;
 }
 
-const char* ContextStoreService::getServiceName()
+const char* ContextStoreService::getMethodSpecs()
 {
        return NULL;
 }
 
-const char* ContextStoreService::getMethodSpecs()
+IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
 {
        return NULL;
 }
@@ -59,17 +59,12 @@ void ContextStoreService::cleanup()
 {
 }
 
-void ContextStoreService::onUserActivated()
-{
-}
-
-void ContextStoreService::onUserDeactivated()
+void ContextStoreService::onUserActivated(uid_t uid)
 {
 }
 
-IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
+void ContextStoreService::onUserDeactivated(uid_t uid)
 {
-       return NULL;
 }
 
 StoreManager* ContextStoreService::getStoreManager()
index 04da0cd..5f5c05b 100644 (file)
@@ -30,11 +30,8 @@ static Store* __getStore(ContextStoreService* hostService, const std::string& ur
 
        if (isSystem)
                return manager.getSystemStore(uri);
-       else if (util::getActiveUid() != ROOT_UID)
+       else
                return manager.getUserStore(uri);
-
-       _W("No active user");
-       return NULL;
 }
 
 ContextStoreService* ContextStore::__hostService = NULL;
index 092a0a6..ccdcea1 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <ServerUtil.h>
 #include <ContextStoreTypesPrivate.h>
 #include <ContextStore.h>
 #include <ContextStoreService.h>
@@ -41,11 +40,6 @@ void ContextStoreService::setServiceRunner(IServiceRunner* runner)
        __serviceRunner = runner;
 }
 
-bool ContextStoreService::isUserService()
-{
-       return false;
-}
-
 const char* ContextStoreService::getServiceName()
 {
        return CTX_CONTEXT_STORE;
@@ -56,6 +50,11 @@ const char* ContextStoreService::getMethodSpecs()
        return CTX_CONTEXT_STORE_SPEC;
 }
 
+IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
+{
+       return new MethodCallHandler(client);
+}
+
 bool ContextStoreService::prepare()
 {
        if (!DatabaseManager::openSystem())
@@ -75,32 +74,23 @@ void ContextStoreService::cleanup()
        DatabaseManager::closeSystem();
 }
 
-void ContextStoreService::onUserActivated()
+void ContextStoreService::onUserActivated(uid_t uid)
 {
-       if (!DatabaseManager::openUser(util::getActiveUid()))
+       // TODO: Need to support a normal user and a container user simultaneously.
+       if (!DatabaseManager::openUser(uid))
                return;
 
        UserSchemaLoader schemaLoader;
        schemaLoader.load();
 }
 
-void ContextStoreService::onUserDeactivated()
+void ContextStoreService::onUserDeactivated(uid_t uid)
 {
        DatabaseManager::closeUser();
        if (__storeManager)
                __storeManager->flushUserCache();
 }
 
-IMethodCallHandler* ContextStoreService::createMethodCallHandler(IClient* client)
-{
-       return new MethodCallHandler(client);
-}
-
-GMainContext* ContextStoreService::getMainContext()
-{
-       return __serviceRunner->getMainContext();
-}
-
 StoreManager* ContextStoreService::getStoreManager()
 {
        if (__storeManager)
index a16ddbd..fd8c992 100644 (file)
@@ -36,7 +36,6 @@ MethodCallHandler::~MethodCallHandler()
 void MethodCallHandler::onMethodCalled(IMethodCall* methodCall)
 {
        try {
-               __verifyUid(methodCall->getUid());
                std::string uri = __getStoreUri(methodCall->getParam());
                Store* store = __getStore(uri);
 
@@ -61,14 +60,6 @@ void MethodCallHandler::onDisconnected()
 {
 }
 
-void MethodCallHandler::__verifyUid(uid_t uid)
-{
-       if (!util::isSystemUid(uid) && uid != util::getActiveUid()) {
-               _E("Invalid Uid: %u != %u (ActiveUser)", uid, util::getActiveUid());
-               throw static_cast<int>(E_ACCESS);
-       }
-}
-
 std::string MethodCallHandler::__getStoreUri(GVariant* param)
 {
        const char* uri = NULL;
index ee11ad3..f7ade24 100644 (file)
@@ -35,7 +35,6 @@ namespace ctx {
                void onDisconnected();
 
        private:
-               void __verifyUid(uid_t uid);
                std::string __getStoreUri(GVariant* param);
                StoreManager& __getStoreManager();
                Store* __getStore(const std::string& uri);