SensorRecorderService realizes IUserService instead of IService 30/136330/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 29 Jun 2017 06:27:56 +0000 (15:27 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 29 Jun 2017 06:27:56 +0000 (15:27 +0900)
Change-Id: I5a6ce9b3a7b99dd80cba722d2258ad8cea6735b3
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/private/SensorRecorderService.h
src/server-dummy/SensorRecorderService.cpp
src/server/MethodCallHandler.cpp
src/server/MethodCallHandler.h
src/server/SensorRecorderService.cpp

index 0235691..aff866f 100644 (file)
 
 /* This header SHOULD NOT be included by other headers in this directory. */
 
-#include <IService.h>
+#include <IUserService.h>
 #include <IServiceRunner.h>
 #include <IClient.h>
 #include <IMethodCallHandler.h>
 
 namespace ctx {
 
-       class EXPORT_API SensorRecorderService : public IService {
+       class EXPORT_API SensorRecorderService : public IUserService {
        public:
                SensorRecorderService();
                ~SensorRecorderService();
 
+               // Inherited from IService
                void setServiceRunner(IServiceRunner* runner);
-
-               bool isUserService();
-
                const char* getServiceName();
                const char* getMethodSpecs();
-
-               bool prepare();
-               void cleanup();
-
-               void onUserActivated();
-               void onUserDeactivated();
-
                IMethodCallHandler* createMethodCallHandler(IClient* client);
 
+               // Inherited from IUserService
+               bool prepare(uid_t uid);
+               void cleanup(uid_t uid);
+
+               // Own members
                GDBusConnection* getConnection();
 
        private:
index 5ef92f8..b5052a4 100644 (file)
@@ -34,11 +34,6 @@ void SensorRecorderService::setServiceRunner(IServiceRunner* runner)
 {
 }
 
-bool SensorRecorderService::isUserService()
-{
-       return true;
-}
-
 const char* SensorRecorderService::getServiceName()
 {
        return NULL;
@@ -49,24 +44,21 @@ const char* SensorRecorderService::getMethodSpecs()
        return NULL;
 }
 
-bool SensorRecorderService::prepare()
-{
-       return false;
-}
-
-void SensorRecorderService::cleanup()
+IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
 {
+       return NULL;
 }
 
-void SensorRecorderService::onUserActivated()
+bool SensorRecorderService::prepare(uid_t uid)
 {
+       return false;
 }
 
-void SensorRecorderService::onUserDeactivated()
+void SensorRecorderService::cleanup(uid_t uid)
 {
 }
 
-IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
+GDBusConnection* SensorRecorderService::getConnection()
 {
        return NULL;
 }
index 6acc120..c821a24 100644 (file)
@@ -36,7 +36,6 @@ MethodCallHandler::~MethodCallHandler()
 void MethodCallHandler::onMethodCalled(IMethodCall* methodCall)
 {
        try {
-               __verifyUid(methodCall->getUid());
                std::string subject = __extractParameter(methodCall->getParam(), IDX_SUBJECT);
                _D("%s(%s)", methodCall->getMethodName().c_str(), subject.c_str());
 
@@ -67,14 +66,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::__extractParameter(GVariant* param, unsigned int idx)
 {
        const char* val = NULL;
index 83ff751..817d4bb 100644 (file)
@@ -34,7 +34,6 @@ namespace ctx {
                void onDisconnected();
 
        private:
-               void __verifyUid(uid_t uid);
                std::string __extractParameter(GVariant* param, unsigned int idx);
                void __startRecording(SensorProvider& provider, IMethodCall& methodCall);
                void __stopRecording(SensorProvider& provider, IMethodCall& methodCall);
index 8fba83b..0b62991 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <ServerUtil.h>
 #include <SensorRecorderTypesPrivate.h>
 #include <SensorRecorderService.h>
 #include "MethodCallHandler.h"
@@ -39,11 +38,6 @@ void SensorRecorderService::setServiceRunner(IServiceRunner* runner)
        __serviceRunner = runner;
 }
 
-bool SensorRecorderService::isUserService()
-{
-       return true;
-}
-
 const char* SensorRecorderService::getServiceName()
 {
        return CTX_SENSOR_RECORDER;
@@ -54,11 +48,16 @@ const char* SensorRecorderService::getMethodSpecs()
        return CTX_SENSOR_RECORDER_SPEC;
 }
 
-bool SensorRecorderService::prepare()
+IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
+{
+       return new MethodCallHandler(client);
+}
+
+bool SensorRecorderService::prepare(uid_t uid)
 {
        RecorderClientInfo::setHostService(this);
 
-       if (!SensorDatabase::open(util::getActiveUid()))
+       if (!SensorDatabase::open(uid))
                return false;
 
        SensorTimer::init();
@@ -67,26 +66,13 @@ bool SensorRecorderService::prepare()
        return true;
 }
 
-void SensorRecorderService::cleanup()
+void SensorRecorderService::cleanup(uid_t uid)
 {
        SensorProvider::release();
        SensorTimer::release();
        SensorDatabase::close();
 }
 
-void SensorRecorderService::onUserActivated()
-{
-}
-
-void SensorRecorderService::onUserDeactivated()
-{
-}
-
-IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
-{
-       return new MethodCallHandler(client);
-}
-
 GDBusConnection* SensorRecorderService::getConnection()
 {
        return __serviceRunner->getConnection();