From: Mu-Woong Lee Date: Fri, 22 Apr 2016 02:31:32 +0000 (+0900) Subject: Code cleanup: merge geofence-related macros into ProviderTypes.h X-Git-Tag: submit/tizen/20160503.015801^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F66902%2F1;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git Code cleanup: merge geofence-related macros into ProviderTypes.h Change-Id: Ibb731bfdc6c34c6ba999c0798bda9c48142afc7c Signed-off-by: Mu-Woong Lee --- diff --git a/src/geofence/GeofenceMonitorHandle.cpp b/src/geofence/GeofenceMonitorHandle.cpp index 868966a..cf896b2 100644 --- a/src/geofence/GeofenceMonitorHandle.cpp +++ b/src/geofence/GeofenceMonitorHandle.cpp @@ -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; } } diff --git a/src/geofence/PlaceGeofenceProvider.cpp b/src/geofence/PlaceGeofenceProvider.cpp index e7aff50..718271b 100644 --- a/src/geofence/PlaceGeofenceProvider.cpp +++ b/src/geofence/PlaceGeofenceProvider.cpp @@ -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); diff --git a/src/geofence/PlaceGeofenceProvider.h b/src/geofence/PlaceGeofenceProvider.h index e6ebf2f..286b239 100644 --- a/src/geofence/PlaceGeofenceProvider.h +++ b/src/geofence/PlaceGeofenceProvider.h @@ -19,7 +19,7 @@ #include #include -#include "PlaceGeofenceTypes.h" +#include namespace ctx { diff --git a/src/geofence/PlaceGeofenceTypes.h b/src/geofence/PlaceGeofenceTypes.h deleted file mode 100644 index fa66a41..0000000 --- a/src/geofence/PlaceGeofenceTypes.h +++ /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_ */ diff --git a/src/shared/PlaceContextProvider.cpp b/src/shared/PlaceContextProvider.cpp index eba5ff0..ec00515 100644 --- a/src/shared/PlaceContextProvider.cpp +++ b/src/shared/PlaceContextProvider.cpp @@ -23,6 +23,8 @@ #include "../my-place/place_recognition.h" #endif /* _MOBILE_ */ +#define PRIV_LOCATION "location" + template 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(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); + registerProvider(SUBJ_PLACE_GEOFENCE, PRIV_LOCATION); /* registerProvider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); diff --git a/src/shared/ProviderTypes.h b/src/shared/ProviderTypes.h index 667da28..03ddd38 100644 --- a/src/shared/ProviderTypes.h +++ b/src/shared/ProviderTypes.h @@ -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 */ @@ -124,6 +126,9 @@ #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