Code cleanup: merge geofence-related macros into ProviderTypes.h 02/66902/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 22 Apr 2016 02:31:32 +0000 (11:31 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 22 Apr 2016 02:31:32 +0000 (11:31 +0900)
Change-Id: Ibb731bfdc6c34c6ba999c0798bda9c48142afc7c
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/geofence/GeofenceMonitorHandle.cpp
src/geofence/PlaceGeofenceProvider.cpp
src/geofence/PlaceGeofenceProvider.h
src/geofence/PlaceGeofenceTypes.h [deleted file]
src/shared/PlaceContextProvider.cpp
src/shared/ProviderTypes.h

index 868966a..cf896b2 100644 (file)
@@ -169,11 +169,11 @@ void GeofenceMonitorHandle::__emitStateChange()
        __prevState = currentState;
 
        Json option;
-       option.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId);
+       option.set(NULL, KEY_PLACE_ID, __placeId);
 
        Json data;
-       data.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId);
-       data.set(NULL, PLACE_GEOFENCE_EVENT, __getStateString(currentState));
+       data.set(NULL, KEY_PLACE_ID, __placeId);
+       data.set(NULL, KEY_EVENT, __getStateString(currentState));
 
        __provider->publish(option, ERR_NONE, data);
 }
@@ -182,13 +182,11 @@ const char* GeofenceMonitorHandle::__getStateString(geofence_state_e state)
 {
        switch (state) {
        case GEOFENCE_STATE_IN:
-               return PLACE_GEOFENCE_IN;
+               return VAL_IN;
        case GEOFENCE_STATE_OUT:
-               return PLACE_GEOFENCE_OUT;
-       case GEOFENCE_STATE_UNCERTAIN:
-               return PLACE_GEOFENCE_UNCERTAIN;
+               return VAL_OUT;
        default:
-               return PLACE_GEOFENCE_UNCERTAIN;
+               return VAL_UNCERTAIN;
        }
 }
 
index e7aff50..718271b 100644 (file)
@@ -21,7 +21,7 @@
 using namespace ctx;
 
 PlaceGeofenceProvider::PlaceGeofenceProvider() :
-       ContextProvider(PLACE_SUBJ_GEOFENCE)
+       ContextProvider(SUBJ_PLACE_GEOFENCE)
 {
 }
 
@@ -56,7 +56,7 @@ void PlaceGeofenceProvider::submitTriggerItem()
 int PlaceGeofenceProvider::subscribe(Json option, Json *requestResult)
 {
        int placeId = -1;
-       option.get(NULL, PLACE_GEOFENCE_PLACE_ID, &placeId);
+       option.get(NULL, KEY_PLACE_ID, &placeId);
        IF_FAIL_RETURN_TAG(placeId != -1, ERR_INVALID_PARAMETER, _E, "Getting PlaceID failed");
 
        auto it = __handleMap.find(placeId);
@@ -83,7 +83,7 @@ int PlaceGeofenceProvider::subscribe(Json option, Json *requestResult)
 int PlaceGeofenceProvider::unsubscribe(Json option)
 {
        int placeId = -1;
-       option.get(NULL, PLACE_GEOFENCE_PLACE_ID, &placeId);
+       option.get(NULL, KEY_PLACE_ID, &placeId);
        IF_FAIL_RETURN_TAG(placeId != -1, ERR_INVALID_PARAMETER, _E, "Getting PlaceID failed");
 
        auto it = __handleMap.find(placeId);
index e6ebf2f..286b239 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <map>
 #include <ContextProvider.h>
-#include "PlaceGeofenceTypes.h"
+#include <ProviderTypes.h>
 
 namespace ctx {
 
diff --git a/src/geofence/PlaceGeofenceTypes.h b/src/geofence/PlaceGeofenceTypes.h
deleted file mode 100644 (file)
index fa66a41..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _CONTEXT_PLACE_GEOFENCE_TYPES_H_
-#define _CONTEXT_PLACE_GEOFENCE_TYPES_H_
-
-// Subject
-#define PLACE_SUBJ_GEOFENCE            "place/geofence"
-
-// Privilege
-#define PLACE_PRIV_GEOFENCE            "location"
-
-// Option & Data Key
-#define PLACE_GEOFENCE_PLACE_ID        "PlaceId"
-#define PLACE_GEOFENCE_EVENT   "Event"
-
-// Data Value
-#define        PLACE_GEOFENCE_UNCERTAIN        "Uncertain"
-#define        PLACE_GEOFENCE_IN               "In"
-#define        PLACE_GEOFENCE_OUT              "Out"
-
-#endif /* End of _CONTEXT_PLACE_GEOFENCE_TYPES_H_ */
index eba5ff0..ec00515 100644 (file)
@@ -23,6 +23,8 @@
 #include "../my-place/place_recognition.h"
 #endif /* _MOBILE_ */
 
+#define PRIV_LOCATION  "location"
+
 template<typename Provider>
 void registerProvider(const char *subject, const char *privilege)
 {
@@ -41,7 +43,7 @@ void registerProvider(const char *subject, const char *privilege)
 SO_EXPORT bool ctx::initPlaceContextProvider()
 {
 #ifdef _MOBILE_
-       registerProvider<PlaceGeofenceProvider>(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE);
+       registerProvider<PlaceGeofenceProvider>(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION);
 
        /*
        registerProvider<PlaceRecognitionProvider>(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION);
index 667da28..03ddd38 100644 (file)
@@ -48,6 +48,7 @@
 #define SUBJ_ACTIVITY_STATIONARY       "activity/stationary"
 #define SUBJ_ACTIVITY_WALKING          "activity/walking"
 
+#define SUBJ_PLACE_GEOFENCE            "place/geofence"
 
 /* Data & Option Keys */
 #define KEY_QUERY_RESULT       "QueryResult"
@@ -90,6 +91,7 @@
 #define KEY_TIME_OF_DAY                "TimeOfDay"
 #define KEY_DAY_OF_WEEK                "DayOfWeek"
 #define KEY_DAY_OF_MONTH       "DayOfMonth"
+#define KEY_PLACE_ID           "PlaceId"
 
 
 /* Data & Option Values */
 #define VAL_PERSON                     "Person"
 #define VAL_CHANGED                    "Changed"
 #define VAL_DETECTED           "Detected"
+#define        VAL_UNCERTAIN           "Uncertain"
+#define        VAL_IN                          "In"
+#define        VAL_OUT                         "Out"
 
 #define VAL_ACTIVE             VAL_CONNECTED
 #define VAL_ALERTING   VAL_CONNECTING