Implement isIdle() function of agent plugins 74/141774/2
authorMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 1 Aug 2017 10:33:08 +0000 (19:33 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 1 Aug 2017 10:33:53 +0000 (10:33 +0000)
Change-Id: I34634c5c5f03f60d05b0ef3e19401088291ef96c
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/agent/ContactsDbAgent.cpp
src/agent/ContactsDbAgent.h
src/agent/GeofenceAgent.cpp
src/agent/GeofenceAgent.h

index 2cd247c9d46049ffbdb3a1a625f8f0034dfd4a00..db8b4c3bd446f497e6d33d0553648b1bb02b7669 100644 (file)
@@ -21,6 +21,7 @@
 using namespace ctx;
 
 ContactsDbAgent::ContactsDbAgent(IAgentUtil* agentUtil) :
+       __idle(true),
        __agentUtil(agentUtil)
 {
        _D("Created");
@@ -38,10 +39,19 @@ uint16_t ContactsDbAgent::getId()
 
 bool ContactsDbAgent::doAction(uint8_t length, const void* command)
 {
-       _D("Command: %d", reinterpret_cast<const char*>(command)[0]);
+       char cmd = reinterpret_cast<const char*>(command)[0];
+       _D("Command: %d", cmd);
+
+       __idle = (cmd == GEOFENCE_CMD_STOP);
 
        //TODO
        // Regarding the given command, start or stop monitoring the DB changes.
        // If a change is detected, send a signal to the ContactsDbChanges publisher.
+
        return true;
 }
+
+bool ContactsDbAgent::isIdle()
+{
+       return __idle;
+}
index e3529d37f7791cdce3f23a2e5b4e6351c6e7deb6..e44d4de7516b9957f8caa503b0a209c0b293d224 100644 (file)
@@ -27,10 +27,11 @@ namespace ctx {
                ~ContactsDbAgent();
 
                uint16_t getId();
-
                bool doAction(uint8_t length, const void* command);
+               bool isIdle();
 
        private:
+               bool __idle;
                IAgentUtil* __agentUtil;
        };
 }
index 8e9c874276828193ca966f15c8eb3253bbb913d7..603ebe10c6df1b93c3ef7721adbce59cdb80f82f 100644 (file)
@@ -21,6 +21,7 @@
 using namespace ctx;
 
 GeofenceAgent::GeofenceAgent(IAgentUtil* agentUtil) :
+       __idle(true),
        __agentUtil(agentUtil)
 {
        _D("Created");
@@ -38,12 +39,21 @@ uint16_t GeofenceAgent::getId()
 
 bool GeofenceAgent::doAction(uint8_t length, const void* command)
 {
-       _D("Command: %d", reinterpret_cast<const char*>(command)[0]);
+       char cmd = reinterpret_cast<const char*>(command)[0];
+       _D("Command: %d", cmd);
+
+       __idle = (cmd == GEOFENCE_CMD_STOP);
 
        //TODO
        // Regarding the given command, start or stop monitoring Home/Work geofencing events.
        // If an event is detected, send a signal to the GeofenceEvent publisher.
        // This may require to assign an app id to this user session daemon,
        // as the Geofence API requires the package id to distinguish a client.
+
        return true;
 }
+
+bool GeofenceAgent::isIdle()
+{
+       return __idle;
+}
index c11c92193269afb25c7f874e998a4009692d4b4d..1d2dbcddcd5706f96baefb441159d3dba78ef8e4 100644 (file)
@@ -27,10 +27,11 @@ namespace ctx {
                ~GeofenceAgent();
 
                uint16_t getId();
-
                bool doAction(uint8_t length, const void* command);
+               bool isIdle();
 
        private:
+               bool __idle;
                IAgentUtil* __agentUtil;
        };
 }