From: Mu-Woong Lee Date: Thu, 8 Jun 2017 12:28:32 +0000 (+0900) Subject: Rename the class Json to avoid symbol conflicts with Jsoncpp X-Git-Tag: submit/tizen/20170609.130020^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff453622560bba899b7265cec418e71bc2c77e09;p=platform%2Fcore%2Fcontext%2Fcontext-service.git Rename the class Json to avoid symbol conflicts with Jsoncpp Change-Id: I7826f4420ee0fa4879ce2d9e25d1a61c5279bada Signed-off-by: Mu-Woong Lee --- diff --git a/src/agent/legacy/ClientRequest.cpp b/src/agent/legacy/ClientRequest.cpp index e625bf0..0ae8573 100644 --- a/src/agent/legacy/ClientRequest.cpp +++ b/src/agent/legacy/ClientRequest.cpp @@ -72,7 +72,7 @@ bool ctx::ClientRequest::reply(int error) return true; } -bool ctx::ClientRequest::reply(int error, ctx::Json& requestResult) +bool ctx::ClientRequest::reply(int error, ctx::CtxJson1& requestResult) { IF_FAIL_RETURN(__invocation, true); IF_FAIL_RETURN(error != ERR_NONE || __type != REQ_READ_SYNC, true); @@ -89,7 +89,7 @@ bool ctx::ClientRequest::reply(int error, ctx::Json& requestResult) return true; } -bool ctx::ClientRequest::reply(int error, ctx::Json& requestResult, ctx::Json& dataRead) +bool ctx::ClientRequest::reply(int error, ctx::CtxJson1& requestResult, ctx::CtxJson1& dataRead) { if (__invocation == NULL) { return publish(error, dataRead); @@ -109,7 +109,7 @@ bool ctx::ClientRequest::reply(int error, ctx::Json& requestResult, ctx::Json& d return true; } -bool ctx::ClientRequest::publish(int error, ctx::Json& data) +bool ctx::ClientRequest::publish(int error, ctx::CtxJson1& data) { DBusServer::publish(__dbusSender, __reqId, __subject, error, data.str()); return true; diff --git a/src/agent/legacy/ClientRequest.h b/src/agent/legacy/ClientRequest.h index 69d18e1..e6e653b 100644 --- a/src/agent/legacy/ClientRequest.h +++ b/src/agent/legacy/ClientRequest.h @@ -32,9 +32,9 @@ namespace ctx { const char* getPackageId(); const char* getClient(); bool reply(int error); - bool reply(int error, ctx::Json &requestResult); - bool reply(int error, ctx::Json &requestResult, ctx::Json &dataRead); - bool publish(int error, ctx::Json &data); + bool reply(int error, ctx::CtxJson1 &requestResult); + bool reply(int error, ctx::CtxJson1 &requestResult, ctx::CtxJson1 &dataRead); + bool publish(int error, ctx::CtxJson1 &data); private: Credentials *__credentials; diff --git a/src/agent/legacy/ContextManager.cpp b/src/agent/legacy/ContextManager.cpp index 7d07966..9f52415 100644 --- a/src/agent/legacy/ContextManager.cpp +++ b/src/agent/legacy/ContextManager.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -126,7 +126,7 @@ bool ContextManager::isAllowed(const Credentials *creds, const char *subject) return handle->isAllowed(creds); } -void ContextManager::__publish(const char* subject, Json &option, int error, Json &dataUpdated) +void ContextManager::__publish(const char* subject, CtxJson1 &option, int error, CtxJson1 &dataUpdated) { _I("Publishing '%s'", subject); _J("Option", option); @@ -137,7 +137,7 @@ void ContextManager::__publish(const char* subject, Json &option, int error, Jso handle->publish(option, error, dataUpdated); } -void ContextManager::__replyToRead(const char* subject, Json &option, int error, Json &dataRead) +void ContextManager::__replyToRead(const char* subject, CtxJson1 &option, int error, CtxJson1 &dataRead) { _I("Sending data of '%s'", subject); _J("Option", option); @@ -154,9 +154,9 @@ struct PublishedData { ContextManager *mgr; std::string subject; int error; - Json option; - Json data; - PublishedData(int t, ContextManager *m, const char* s, Json& o, int e, Json& d) + CtxJson1 option; + CtxJson1 data; + PublishedData(int t, ContextManager *m, const char* s, CtxJson1& o, int e, CtxJson1& d) : type(t), mgr(m), subject(s), error(e) { option = o.str(); @@ -183,7 +183,7 @@ gboolean ContextManager::__threadSwitcher(gpointer data) return FALSE; } -bool ContextManager::publish(const char* subject, Json& option, int error, Json& dataUpdated) +bool ContextManager::publish(const char* subject, CtxJson1& option, int error, CtxJson1& dataUpdated) { IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter"); @@ -195,7 +195,7 @@ bool ContextManager::publish(const char* subject, Json& option, int error, Json& return true; } -bool ContextManager::replyToRead(const char* subject, Json& option, int error, Json& dataRead) +bool ContextManager::replyToRead(const char* subject, CtxJson1& option, int error, CtxJson1& dataRead) { IF_FAIL_RETURN_TAG(subject, false, _E, "Invalid parameter"); @@ -207,13 +207,13 @@ bool ContextManager::replyToRead(const char* subject, Json& option, int error, J return true; } -bool ContextManager::popTriggerTemplate(std::string &subject, int &operation, Json &attribute, Json &option) +bool ContextManager::popTriggerTemplate(std::string &subject, int &operation, CtxJson1 &attribute, CtxJson1 &option) { return ProviderLoader::popTriggerTemplate(subject, operation, attribute, option); } /* Only for explicit request of custom provider */ -bool ContextManager::registerCustomProvider(const char* subject, int operation, ctx::Json &attribute, ctx::Json &option, const char* owner) +bool ContextManager::registerCustomProvider(const char* subject, int operation, ctx::CtxJson1 &attribute, ctx::CtxJson1 &option, const char* owner) { IF_FAIL_RETURN_TAG(ProviderHandler::getInstance(subject, true), false, _E, "Register provider failed"); diff --git a/src/agent/legacy/ContextManager.h b/src/agent/legacy/ContextManager.h index 9be24c1..ab98910 100644 --- a/src/agent/legacy/ContextManager.h +++ b/src/agent/legacy/ContextManager.h @@ -39,20 +39,20 @@ namespace ctx { bool isAllowed(const Credentials *creds, const char *subject); /* From the interface class */ - bool publish(const char *subject, ctx::Json &option, int error, ctx::Json &dataUpdated); - bool replyToRead(const char *subject, ctx::Json &option, int error, ctx::Json &dataRead); - bool registerCustomProvider(const char* subject, int operation, ctx::Json &attribute, ctx::Json &option, const char* owner); + bool publish(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataUpdated); + bool replyToRead(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataRead); + bool registerCustomProvider(const char* subject, int operation, ctx::CtxJson1 &attribute, ctx::CtxJson1 &option, const char* owner); bool unregisterCustomProvider(const char* subject); - bool popTriggerTemplate(std::string &subject, int &operation, Json &attribute, Json &option); + bool popTriggerTemplate(std::string &subject, int &operation, CtxJson1 &attribute, CtxJson1 &option); private: ContextManager(); static gboolean __threadSwitcher(gpointer data); - void __publish(const char *subject, ctx::Json &option, int error, ctx::Json &dataUpdated); - void __replyToRead(const char *subject, ctx::Json &option, int error, ctx::Json &dataRead); + void __publish(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataUpdated); + void __replyToRead(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataRead); friend class Server; diff --git a/src/agent/legacy/ProviderHandler.cpp b/src/agent/legacy/ProviderHandler.cpp index 62e1cf1..d4bbc4f 100644 --- a/src/agent/legacy/ProviderHandler.cpp +++ b/src/agent/legacy/ProviderHandler.cpp @@ -127,7 +127,7 @@ void ProviderHandler::subscribe(RequestInfo *request) { _I(CYAN("'%s' subscribes '%s' (RID-%d)"), request->getClient(), __subject.c_str(), request->getId()); - Json requestResult; + CtxJson1 requestResult; int error = __provider->subscribe(request->getDescription().str(), &requestResult); if (!request->reply(error, requestResult) || error != ERR_NONE) { @@ -182,7 +182,7 @@ void ProviderHandler::read(RequestInfo *request) { _I(CYAN("'%s' reads '%s' (RID-%d)"), request->getClient(), __subject.c_str(), request->getId()); - Json requestResult; + CtxJson1 requestResult; int error = __provider->read(request->getDescription().str(), &requestResult); if (!request->reply(error, requestResult) || error != ERR_NONE) { @@ -199,7 +199,7 @@ void ProviderHandler::write(RequestInfo *request) { _I(CYAN("'%s' writes '%s' (RID-%d)"), request->getClient(), __subject.c_str(), request->getId()); - Json requestResult; + CtxJson1 requestResult; request->getDescription().set(NULL, KEY_CLIENT_PKG_ID, request->getPackageId()? request->getPackageId() : "SYSTEM"); int error = __provider->write(request->getDescription(), &requestResult); @@ -210,7 +210,7 @@ void ProviderHandler::write(RequestInfo *request) __scheduleToDelete(); } -bool ProviderHandler::publish(Json &option, int error, Json &dataUpdated) +bool ProviderHandler::publish(CtxJson1 &option, int error, CtxJson1 &dataUpdated) { auto end = __subscribeRequests.end(); auto target = __findRequest(__subscribeRequests.begin(), end, option); @@ -225,13 +225,13 @@ bool ProviderHandler::publish(Json &option, int error, Json &dataUpdated) return true; } -bool ProviderHandler::replyToRead(Json &option, int error, Json &dataRead) +bool ProviderHandler::replyToRead(CtxJson1 &option, int error, CtxJson1 &dataRead) { auto end = __readRequests.end(); auto target = __findRequest(__readRequests.begin(), end, option); auto prev = target; - Json dummy; + CtxJson1 dummy; while (target != end) { (*target)->reply(error, dummy, dataRead); @@ -283,7 +283,7 @@ gboolean ProviderHandler::__deletor(gpointer data) } ProviderHandler::RequestList::iterator -ProviderHandler::__findRequest(RequestList &reqList, Json &option) +ProviderHandler::__findRequest(RequestList &reqList, CtxJson1 &option) { return __findRequest(reqList.begin(), reqList.end(), option); } @@ -300,7 +300,7 @@ ProviderHandler::__findRequest(RequestList &reqList, std::string client, int req } ProviderHandler::RequestList::iterator -ProviderHandler::__findRequest(RequestList::iterator begin, RequestList::iterator end, Json &option) +ProviderHandler::__findRequest(RequestList::iterator begin, RequestList::iterator end, CtxJson1 &option) { for (auto it = begin; it != end; ++it) { if (option == (*it)->getDescription()) { diff --git a/src/agent/legacy/ProviderHandler.h b/src/agent/legacy/ProviderHandler.h index 58225f7..ae2228e 100644 --- a/src/agent/legacy/ProviderHandler.h +++ b/src/agent/legacy/ProviderHandler.h @@ -41,8 +41,8 @@ namespace ctx { void read(RequestInfo *request); void write(RequestInfo *request); - bool publish(ctx::Json &option, int error, ctx::Json &dataUpdated); - bool replyToRead(ctx::Json &option, int error, ctx::Json &dataRead); + bool publish(ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataUpdated); + bool replyToRead(ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataRead); static ProviderHandler* getInstance(std::string subject, bool force); static void purge(); @@ -65,9 +65,9 @@ namespace ctx { bool __idle(); void __scheduleToDelete(); - RequestList::iterator __findRequest(RequestList &reqList, Json &option); + RequestList::iterator __findRequest(RequestList &reqList, CtxJson1 &option); RequestList::iterator __findRequest(RequestList &reqList, std::string client, int reqId); - RequestList::iterator __findRequest(RequestList::iterator begin, RequestList::iterator end, Json &option); + RequestList::iterator __findRequest(RequestList::iterator begin, RequestList::iterator end, CtxJson1 &option); static gboolean __deletor(gpointer data); diff --git a/src/agent/legacy/ProviderLoader.cpp b/src/agent/legacy/ProviderLoader.cpp index 8a7d6a6..7ef4627 100644 --- a/src/agent/legacy/ProviderLoader.cpp +++ b/src/agent/legacy/ProviderLoader.cpp @@ -102,7 +102,7 @@ bool ProviderLoader::init() return true; } -bool ProviderLoader::popTriggerTemplate(std::string &subject, int &operation, Json &attribute, Json &option) +bool ProviderLoader::popTriggerTemplate(std::string &subject, int &operation, CtxJson1 &attribute, CtxJson1 &option) { static int i = 0; static int size = ARRAY_SIZE(triggerTemplateList); diff --git a/src/agent/legacy/ProviderLoader.h b/src/agent/legacy/ProviderLoader.h index ab5a427..aae6c5d 100644 --- a/src/agent/legacy/ProviderLoader.h +++ b/src/agent/legacy/ProviderLoader.h @@ -48,7 +48,7 @@ namespace ctx { ContextProvider* load(const char *subject); static bool init(); - static bool popTriggerTemplate(std::string &subject, int &operation, Json &attribute, Json &option); + static bool popTriggerTemplate(std::string &subject, int &operation, CtxJson1 &attribute, CtxJson1 &option); private: ContextProvider* __load(const char *soPath, const char *subject); diff --git a/src/agent/legacy/Request.cpp b/src/agent/legacy/Request.cpp index d900fcc..efaa13f 100644 --- a/src/agent/legacy/Request.cpp +++ b/src/agent/legacy/Request.cpp @@ -60,7 +60,7 @@ const char* ctx::RequestInfo::getSubject() return __subject.c_str(); } -ctx::Json& ctx::RequestInfo::getDescription() +ctx::CtxJson1& ctx::RequestInfo::getDescription() { return __description; } diff --git a/src/agent/legacy/Request.h b/src/agent/legacy/Request.h index 9750b2f..b3425a1 100644 --- a/src/agent/legacy/Request.h +++ b/src/agent/legacy/Request.h @@ -18,7 +18,7 @@ #define _CONTEXT_REQUEST_INFO_H_ #include -#include +#include namespace ctx { @@ -33,22 +33,22 @@ namespace ctx { int getType(); int getId(); const char* getSubject(); - ctx::Json& getDescription(); + ctx::CtxJson1& getDescription(); virtual const Credentials* getCredentials(); virtual const char* getPackageId(); /* TODO: remove this getClient() */ virtual const char* getClient(); virtual bool reply(int error) = 0; - virtual bool reply(int error, ctx::Json &requestResult) = 0; - virtual bool reply(int error, ctx::Json &requestResult, ctx::Json &dataRead) = 0; - virtual bool publish(int error, ctx::Json &data) = 0; + virtual bool reply(int error, ctx::CtxJson1 &requestResult) = 0; + virtual bool reply(int error, ctx::CtxJson1 &requestResult, ctx::CtxJson1 &dataRead) = 0; + virtual bool publish(int error, ctx::CtxJson1 &data) = 0; protected: int __type; int __reqId; std::string __subject; - ctx::Json __description; + ctx::CtxJson1 __description; }; } /* namespace ctx */ diff --git a/src/agent/legacy/policy/PolicyRequest.cpp b/src/agent/legacy/policy/PolicyRequest.cpp index 63cf8ae..cd69534 100644 --- a/src/agent/legacy/policy/PolicyRequest.cpp +++ b/src/agent/legacy/policy/PolicyRequest.cpp @@ -37,17 +37,17 @@ bool PolicyRequest::reply(int error) return true; } -bool PolicyRequest::reply(int error, ctx::Json &requestResult) +bool PolicyRequest::reply(int error, ctx::CtxJson1 &requestResult) { return true; } -bool PolicyRequest::reply(int error, ctx::Json &requestResult, ctx::Json &dataRead) +bool PolicyRequest::reply(int error, ctx::CtxJson1 &requestResult, ctx::CtxJson1 &dataRead) { return true; } -bool PolicyRequest::publish(int error, ctx::Json &data) +bool PolicyRequest::publish(int error, ctx::CtxJson1 &data) { return true; } diff --git a/src/agent/legacy/policy/PolicyRequest.h b/src/agent/legacy/policy/PolicyRequest.h index 2ed28c7..ce68fb8 100644 --- a/src/agent/legacy/policy/PolicyRequest.h +++ b/src/agent/legacy/policy/PolicyRequest.h @@ -29,9 +29,9 @@ namespace ctx { const char* getClient(); bool reply(int error); - bool reply(int error, ctx::Json &requestResult); - bool reply(int error, ctx::Json &requestResult, ctx::Json &dataRead); - bool publish(int error, ctx::Json &data); + bool reply(int error, ctx::CtxJson1 &requestResult); + bool reply(int error, ctx::CtxJson1 &requestResult, ctx::CtxJson1 &dataRead); + bool publish(int error, ctx::CtxJson1 &data); }; } /* namespace ctx */ diff --git a/src/agent/legacy/trigger/ActionManager.cpp b/src/agent/legacy/trigger/ActionManager.cpp index b45671f..332c87e 100644 --- a/src/agent/legacy/trigger/ActionManager.cpp +++ b/src/agent/legacy/trigger/ActionManager.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include @@ -29,11 +29,11 @@ using namespace ctx; -static void __triggerActionAppControl(Json& action); -static void __triggerActionNotification(Json& action, std::string pkgId); -static void __triggerActionDbusCall(Json& action); +static void __triggerActionAppControl(CtxJson1& action); +static void __triggerActionNotification(CtxJson1& action, std::string pkgId); +static void __triggerActionDbusCall(CtxJson1& action); -void trigger::action_manager::triggerAction(Json& action, std::string pkgId) +void trigger::action_manager::triggerAction(CtxJson1& action, std::string pkgId) { std::list types; action.getKeys(&types); @@ -50,7 +50,7 @@ void trigger::action_manager::triggerAction(Json& action, std::string pkgId) } } -void __triggerActionAppControl(Json& action) +void __triggerActionAppControl(CtxJson1& action) { int error; std::string appctlStr; @@ -85,7 +85,7 @@ void __triggerActionAppControl(Json& action) } } -void __triggerActionNotification(Json& action, std::string pkgId) +void __triggerActionNotification(CtxJson1& action, std::string pkgId) { int error; notification_h notification = notification_create(NOTIFICATION_TYPE_NOTI); @@ -187,7 +187,7 @@ void __triggerActionNotification(Json& action, std::string pkgId) } } -void __triggerActionDbusCall(Json& action) +void __triggerActionDbusCall(CtxJson1& action) { std::string busName, object, iface, method; GVariant *param = NULL; diff --git a/src/agent/legacy/trigger/ActionManager.h b/src/agent/legacy/trigger/ActionManager.h index 273f450..5d8c026 100644 --- a/src/agent/legacy/trigger/ActionManager.h +++ b/src/agent/legacy/trigger/ActionManager.h @@ -19,13 +19,13 @@ namespace ctx { /* Forward Declaration */ - class Json; + class CtxJson1; namespace trigger { namespace action_manager { - void triggerAction(Json& action, std::string pkgId); + void triggerAction(CtxJson1& action, std::string pkgId); } /* namespace action_manager */ diff --git a/src/agent/legacy/trigger/ContextMonitor.cpp b/src/agent/legacy/trigger/ContextMonitor.cpp index 5dab7f5..86d8c99 100644 --- a/src/agent/legacy/trigger/ContextMonitor.cpp +++ b/src/agent/legacy/trigger/ContextMonitor.cpp @@ -75,7 +75,7 @@ void ContextMonitor::destroy() } } -int ContextMonitor::subscribe(int ruleId, std::string subject, Json option, IContextListener* listener) +int ContextMonitor::subscribe(int ruleId, std::string subject, CtxJson1 option, IContextListener* listener) { int reqId = __subscribe(subject.c_str(), &option, listener); IF_FAIL_RETURN_TAG(reqId > 0, reqId, _E, "Subscribe event failed"); @@ -84,7 +84,7 @@ int ContextMonitor::subscribe(int ruleId, std::string subject, Json option, ICon return ERR_NONE; } -int ContextMonitor::__subscribe(const char* subject, Json* option, IContextListener* listener) +int ContextMonitor::__subscribe(const char* subject, CtxJson1* option, IContextListener* listener) { IF_FAIL_RETURN(subject, ERR_INVALID_PARAMETER); @@ -113,7 +113,7 @@ int ContextMonitor::__subscribe(const char* subject, Json* option, IContextListe return rid; } -int ContextMonitor::unsubscribe(int ruleId, std::string subject, Json option, IContextListener* listener) +int ContextMonitor::unsubscribe(int ruleId, std::string subject, CtxJson1 option, IContextListener* listener) { int rid = __findSub(REQ_SUBSCRIBE, subject.c_str(), &option); if (rid < 0) { @@ -138,7 +138,7 @@ void ContextMonitor::__unsubscribe(const char *subject, int subscriptionId) __removeSub(REQ_SUBSCRIBE, subscriptionId); } -int ContextMonitor::read(std::string subject, Json option, IContextListener* listener) +int ContextMonitor::read(std::string subject, CtxJson1 option, IContextListener* listener) { int reqId = __read(subject.c_str(), &option, listener); IF_FAIL_RETURN_TAG(reqId > 0, ERR_OPERATION_FAILED, _E, "Read condition failed"); @@ -147,7 +147,7 @@ int ContextMonitor::read(std::string subject, Json option, IContextListener* lis return ERR_NONE; } -int ContextMonitor::__read(const char* subject, Json* option, IContextListener* listener) +int ContextMonitor::__read(const char* subject, CtxJson1* option, IContextListener* listener) { IF_FAIL_RETURN(subject, ERR_INVALID_PARAMETER); @@ -187,12 +187,12 @@ bool ContextMonitor::isAllowed(const char *client, const char *subject) return true; } -int ContextMonitor::__findSub(RequestType type, const char* subject, Json* option) +int ContextMonitor::__findSub(RequestType type, const char* subject, CtxJson1* option) { // @return request id std::map* map = (type == REQ_SUBSCRIBE)? &__subscrMap : &__readMap; - Json jOpt; + CtxJson1 jOpt; if (option) { jOpt = *option; } @@ -206,7 +206,7 @@ int ContextMonitor::__findSub(RequestType type, const char* subject, Json* optio return -1; } -bool ContextMonitor::__addSub(RequestType type, int sid, const char* subject, Json* option, IContextListener* listener) +bool ContextMonitor::__addSub(RequestType type, int sid, const char* subject, CtxJson1* option, IContextListener* listener) { std::map* map = (type == REQ_SUBSCRIBE)? &__subscrMap : &__readMap; @@ -218,11 +218,11 @@ bool ContextMonitor::__addSub(RequestType type, int sid, const char* subject, Js return true; } -void ContextMonitor::__removeSub(RequestType type, const char* subject, Json* option) +void ContextMonitor::__removeSub(RequestType type, const char* subject, CtxJson1* option) { std::map* map = (type == REQ_SUBSCRIBE)? &__subscrMap : &__readMap; - Json jOpt; + CtxJson1 jOpt; if (option) { jOpt = *option; } @@ -281,7 +281,7 @@ int ContextMonitor::__removeListener(RequestType type, int sid, IContextListener return info->listenerList.size(); } -void ContextMonitor::replyResult(int reqId, int error, Json* requestResult) +void ContextMonitor::replyResult(int reqId, int error, CtxJson1* requestResult) { _D("Request result received: %d", reqId); @@ -289,7 +289,7 @@ void ContextMonitor::replyResult(int reqId, int error, Json* requestResult) __lastErr = error; } -void ContextMonitor::replyResult(int reqId, int error, const char* subject, Json* option, Json* fact) +void ContextMonitor::replyResult(int reqId, int error, const char* subject, CtxJson1* option, CtxJson1* fact) { _D(YELLOW("Condition received: subject(%s), option(%s), fact(%s)"), subject, option->str().c_str(), fact->str().c_str()); @@ -304,7 +304,7 @@ void ContextMonitor::replyResult(int reqId, int error, const char* subject, Json __removeSub(REQ_READ, reqId); } -void ContextMonitor::publishFact(int reqId, int error, const char* subject, Json* option, Json* fact) +void ContextMonitor::publishFact(int reqId, int error, const char* subject, CtxJson1* option, CtxJson1* fact) { _D(YELLOW("Event received: subject(%s), option(%s), fact(%s)"), subject, option->str().c_str(), fact->str().c_str()); diff --git a/src/agent/legacy/trigger/ContextMonitor.h b/src/agent/legacy/trigger/ContextMonitor.h index 473cac2..6f65cdf 100644 --- a/src/agent/legacy/trigger/ContextMonitor.h +++ b/src/agent/legacy/trigger/ContextMonitor.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ctx { @@ -37,15 +37,15 @@ namespace trigger { static void setContextManager(ContextManager* ctxMgr); static void destroy(); - int subscribe(int ruleId, std::string subject, Json option, IContextListener* listener); - int unsubscribe(int ruleId, std::string subject, Json option, IContextListener* listener); - int read(std::string subject, Json option, IContextListener* listener); + int subscribe(int ruleId, std::string subject, CtxJson1 option, IContextListener* listener); + int unsubscribe(int ruleId, std::string subject, CtxJson1 option, IContextListener* listener); + int read(std::string subject, CtxJson1 option, IContextListener* listener); bool isSupported(std::string subject); bool isAllowed(const char *client, const char *subject); - void replyResult(int reqId, int error, Json *requestResult = NULL); - void replyResult(int reqId, int error, const char *subject, Json *option, Json *fact); - void publishFact(int reqId, int error, const char *subject, Json *option, Json *fact); + void replyResult(int reqId, int error, CtxJson1 *requestResult = NULL); + void replyResult(int reqId, int error, const char *subject, CtxJson1 *option, CtxJson1 *fact); + void publishFact(int reqId, int error, const char *subject, CtxJson1 *option, CtxJson1 *fact); private: ContextMonitor(); @@ -55,17 +55,17 @@ namespace trigger { static ContextMonitor *__instance; static ContextManager *__contextMgr; - int __subscribe(const char* subject, Json* option, IContextListener* listener); + int __subscribe(const char* subject, CtxJson1* option, IContextListener* listener); void __unsubscribe(const char *subject, int subscriptionId); - int __read(const char *subject, Json *option, IContextListener* listener); + int __read(const char *subject, CtxJson1 *option, IContextListener* listener); struct SubscrInfo { int sid; std::string subject; - Json option; + CtxJson1 option; std::list listenerList; - SubscrInfo(int id, const char *subj, Json *opt) : + SubscrInfo(int id, const char *subj, CtxJson1 *opt) : sid(id), subject(subj) { @@ -77,9 +77,9 @@ namespace trigger { std::map __subscrMap; std::map __readMap; - int __findSub(RequestType type, const char *subject, Json *option); - bool __addSub(RequestType type, int sid, const char *subject, Json *option, IContextListener* listener); - void __removeSub(RequestType type, const char *subject, Json *option); + int __findSub(RequestType type, const char *subject, CtxJson1 *option); + bool __addSub(RequestType type, int sid, const char *subject, CtxJson1 *option, IContextListener* listener); + void __removeSub(RequestType type, const char *subject, CtxJson1 *option); void __removeSub(RequestType type, int sid); int __addListener(RequestType type, int sid, IContextListener* listener); int __removeListener(RequestType type, int sid, IContextListener* listener); diff --git a/src/agent/legacy/trigger/FactRequest.cpp b/src/agent/legacy/trigger/FactRequest.cpp index fc09d9d..da9212c 100644 --- a/src/agent/legacy/trigger/FactRequest.cpp +++ b/src/agent/legacy/trigger/FactRequest.cpp @@ -45,7 +45,7 @@ bool FactRequest::reply(int error) return true; } -bool FactRequest::reply(int error, Json& requestResult) +bool FactRequest::reply(int error, CtxJson1& requestResult) { IF_FAIL_RETURN(!__replied && __ctxMonitor, true); __ctxMonitor->replyResult(__reqId, error, &requestResult); @@ -53,14 +53,14 @@ bool FactRequest::reply(int error, Json& requestResult) return true; } -bool FactRequest::reply(int error, Json& requestResult, Json& dataRead) +bool FactRequest::reply(int error, CtxJson1& requestResult, CtxJson1& dataRead) { IF_FAIL_RETURN(!__replied && __ctxMonitor, true); __ctxMonitor->replyResult(__reqId, error, __subject.c_str(), &getDescription(), &dataRead); return (__replied = true); } -bool FactRequest::publish(int error, Json& data) +bool FactRequest::publish(int error, CtxJson1& data) { IF_FAIL_RETURN(__ctxMonitor, true); __ctxMonitor->publishFact(__reqId, error, __subject.c_str(), &getDescription(), &data); diff --git a/src/agent/legacy/trigger/FactRequest.h b/src/agent/legacy/trigger/FactRequest.h index 8c54fe8..2c18b4a 100644 --- a/src/agent/legacy/trigger/FactRequest.h +++ b/src/agent/legacy/trigger/FactRequest.h @@ -31,9 +31,9 @@ namespace trigger { const char* getClient(); bool reply(int error); - bool reply(int error, ctx::Json& requestResult); - bool reply(int error, ctx::Json& requestResult, ctx::Json& dataRead); - bool publish(int error, ctx::Json& data); + bool reply(int error, ctx::CtxJson1& requestResult); + bool reply(int error, ctx::CtxJson1& requestResult, ctx::CtxJson1& dataRead); + bool publish(int error, ctx::CtxJson1& data); private: ContextMonitor *__ctxMonitor; diff --git a/src/agent/legacy/trigger/IContextListener.h b/src/agent/legacy/trigger/IContextListener.h index 826ab41..1311254 100644 --- a/src/agent/legacy/trigger/IContextListener.h +++ b/src/agent/legacy/trigger/IContextListener.h @@ -19,7 +19,7 @@ namespace ctx { /* Forward Declaration */ - class Json; + class CtxJson1; namespace trigger { @@ -27,9 +27,9 @@ namespace trigger { public: virtual ~IContextListener() {} - virtual void onEventReceived(std::string name, Json option, Json data) = 0; + virtual void onEventReceived(std::string name, CtxJson1 option, CtxJson1 data) = 0; - virtual void onConditionReceived(std::string name, Json option, Json data) = 0; + virtual void onConditionReceived(std::string name, CtxJson1 option, CtxJson1 data) = 0; }; } /* namespace trigger */ diff --git a/src/agent/legacy/trigger/Rule.cpp b/src/agent/legacy/trigger/Rule.cpp index 33b2ef8..d6bff32 100644 --- a/src/agent/legacy/trigger/Rule.cpp +++ b/src/agent/legacy/trigger/Rule.cpp @@ -27,7 +27,7 @@ using namespace ctx::trigger; RuleManager *Rule::__ruleMgr = NULL; -Rule::Rule(int i, Json& d, const char* p, RuleManager* rm) : +Rule::Rule(int i, CtxJson1& d, const char* p, RuleManager* rm) : __result(EMPTY_JSON_OBJECT), id(i), pkgId(p) @@ -41,25 +41,25 @@ Rule::Rule(int i, Json& d, const char* p, RuleManager* rm) : __statement = d.str(); // Event - Json e; + CtxJson1 e; d.get(NULL, TRIG_RULE_KEY_EVENT, &e); __event = new(std::nothrow) ContextItem(e); // Condition int condNum = d.getSize(NULL, TRIG_RULE_KEY_CONDITION); for (int j = 0; j < condNum; j++) { - Json c; + CtxJson1 c; d.getAt(NULL, TRIG_RULE_KEY_CONDITION, j, &c); __condition.push_back(new(std::nothrow) ContextItem(c)); } // Extra - Json extra; + CtxJson1 extra; d.get(NULL, _TRIG_RULE_KEY_EXTRA, &extra); __extra = extra.str(); // Action - Json a; + CtxJson1 a; d.get(NULL, TRIG_RULE_KEY_ACTION, &a); __action = a.str(); } @@ -95,7 +95,7 @@ int Rule::stop(void) return error; } -bool Rule::__setConditionOptionBasedOnEvent(Json& option) +bool Rule::__setConditionOptionBasedOnEvent(CtxJson1& option) { // Set condition option if it references event data std::list optionKeys; @@ -128,7 +128,7 @@ bool Rule::__setConditionOptionBasedOnEvent(Json& option) return true; } -void Rule::onEventReceived(std::string name, Json option, Json data) +void Rule::onEventReceived(std::string name, CtxJson1 option, CtxJson1 data) { if (__result != EMPTY_JSON_OBJECT) { __clearResult(); @@ -157,7 +157,7 @@ void Rule::onEventReceived(std::string name, Json option, Json data) // Request read conditions for (auto it = __condition.begin(); it != __condition.end(); ++it) { - Json condOption = (*it)->option.str(); + CtxJson1 condOption = (*it)->option.str(); if (!__setConditionOptionBasedOnEvent(condOption)) { // condOption should be copy of original option. __clearResult(); return; @@ -170,12 +170,12 @@ void Rule::onEventReceived(std::string name, Json option, Json data) // TODO timer set } -void Rule::onConditionReceived(std::string name, Json option, Json data) +void Rule::onConditionReceived(std::string name, CtxJson1 option, CtxJson1 data) { _D("Rule%d received condition data", id); // Set condition data - Json item; + CtxJson1 item; item.set(NULL, FACT_KEY_NAME, name); item.set(NULL, FACT_KEY_OPTION, option); item.set(NULL, FACT_KEY_DATA, data); diff --git a/src/agent/legacy/trigger/Rule.h b/src/agent/legacy/trigger/Rule.h index 1192b6e..cce117a 100644 --- a/src/agent/legacy/trigger/Rule.h +++ b/src/agent/legacy/trigger/Rule.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include "IContextListener.h" namespace ctx { @@ -32,29 +32,29 @@ namespace trigger { private: struct ContextItem { std::string name; - ctx::Json option; - ContextItem(ctx::Json item) { + ctx::CtxJson1 option; + ContextItem(ctx::CtxJson1 item) { std::list keyList; item.getKeys(&keyList); name = *keyList.begin(); - ctx::Json o; + ctx::CtxJson1 o; if (item.get(name.c_str(), TRIG_RULE_KEY_OPTION, &o)) option = o.str(); } }; - ctx::Json __statement; + ctx::CtxJson1 __statement; ContextItem* __event; std::list __condition; - ctx::Json __extra; - ctx::Json __action; - ctx::Json __result; + ctx::CtxJson1 __extra; + ctx::CtxJson1 __action; + ctx::CtxJson1 __result; static RuleManager* __ruleMgr; void __clearResult(void); - bool __setConditionOptionBasedOnEvent(ctx::Json& option); + bool __setConditionOptionBasedOnEvent(ctx::CtxJson1& option); void __onContextDataPrepared(void); static gboolean __handleUninstalledRule(gpointer data); @@ -63,14 +63,14 @@ namespace trigger { int id; std::string pkgId; - Rule(int i, ctx::Json& d, const char* p, RuleManager* rm); + Rule(int i, ctx::CtxJson1& d, const char* p, RuleManager* rm); ~Rule(); int start(void); int stop(void); - void onEventReceived(std::string name, ctx::Json option, ctx::Json data); - void onConditionReceived(std::string name, ctx::Json option, ctx::Json data); + void onEventReceived(std::string name, ctx::CtxJson1 option, ctx::CtxJson1 data); + void onConditionReceived(std::string name, ctx::CtxJson1 option, ctx::CtxJson1 data); }; diff --git a/src/agent/legacy/trigger/RuleEvaluator.cpp b/src/agent/legacy/trigger/RuleEvaluator.cpp index b0e5833..6dc66b4 100644 --- a/src/agent/legacy/trigger/RuleEvaluator.cpp +++ b/src/agent/legacy/trigger/RuleEvaluator.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include #include "RuleEvaluator.h" @@ -35,7 +35,7 @@ RuleEvaluator::RuleEvaluator() } template -bool RuleEvaluator::__evaluateSingleData(T factVal, Json& comparison, std::string op) +bool RuleEvaluator::__evaluateSingleData(T factVal, CtxJson1& comparison, std::string op) { T ruleVal; comparison.get(NULL, TRIG_RULE_KEY_VALUE, &ruleVal); @@ -58,7 +58,7 @@ bool RuleEvaluator::__evaluateSingleData(T factVal, Json& comparison, std::strin } template -bool RuleEvaluator::__evaluateDualData(T factVal, Json& comparison, std::string op) +bool RuleEvaluator::__evaluateDualData(T factVal, CtxJson1& comparison, std::string op) { T ruleVal1, ruleVal2; comparison.getAt(NULL, TRIG_RULE_KEY_VALUE, 0, &ruleVal1); @@ -74,7 +74,7 @@ bool RuleEvaluator::__evaluateDualData(T factVal, Json& comparison, std::string } template -bool RuleEvaluator::__evaluateMultipleData(T factVal, Json& comparison, std::string op) +bool RuleEvaluator::__evaluateMultipleData(T factVal, CtxJson1& comparison, std::string op) { T ruleVal; for (int i = 0; comparison.getAt(NULL, TRIG_RULE_KEY_VALUE, i, &ruleVal); i++) { @@ -95,7 +95,7 @@ bool RuleEvaluator::__evaluateMultipleData(T factVal, Json& comparison, std::str } template -bool RuleEvaluator::__evaluateData(T factVal, Json& comparison) +bool RuleEvaluator::__evaluateData(T factVal, CtxJson1& comparison) { std::string op; comparison.get(NULL, TRIG_RULE_KEY_OPERATOR, &op); @@ -113,7 +113,7 @@ bool RuleEvaluator::__evaluateData(T factVal, Json& comparison) return false; } -void RuleEvaluator::__replaceSingleDataReferences(Json& eventFactData, Json& ruleComp, std::string& dataKey) +void RuleEvaluator::__replaceSingleDataReferences(CtxJson1& eventFactData, CtxJson1& ruleComp, std::string& dataKey) { std::string refVal; std::string eventRefStr; @@ -137,7 +137,7 @@ void RuleEvaluator::__replaceSingleDataReferences(Json& eventFactData, Json& rul } } -void RuleEvaluator::__replaceMultipleDataReferences(Json& eventFactData, Json& ruleComp, std::string& dataKey) +void RuleEvaluator::__replaceMultipleDataReferences(CtxJson1& eventFactData, CtxJson1& ruleComp, std::string& dataKey) { std::string refVal; std::string eventRefStr; @@ -159,7 +159,7 @@ void RuleEvaluator::__replaceMultipleDataReferences(Json& eventFactData, Json& r } } -void RuleEvaluator::__replaceDataReferences(Json eventFactData, Json& ruleComp) +void RuleEvaluator::__replaceDataReferences(CtxJson1 eventFactData, CtxJson1& ruleComp) { // Replace referencing data to actual value std::list compKeys; @@ -183,12 +183,12 @@ void RuleEvaluator::__replaceDataReferences(Json eventFactData, Json& ruleComp) } } -bool RuleEvaluator::__evaluateItem(Json& factItem, Json& ruleItem, std::string logicalOp) +bool RuleEvaluator::__evaluateItem(CtxJson1& factItem, CtxJson1& ruleItem, std::string logicalOp) { std::string name; factItem.get(NULL, FACT_KEY_NAME, &name); - Json comparison; + CtxJson1 comparison; ruleItem.get(name.c_str(), TRIG_RULE_KEY_COMPARISON, &comparison); std::list compKeys; @@ -202,7 +202,7 @@ bool RuleEvaluator::__evaluateItem(Json& factItem, Json& ruleItem, std::string l for (auto it = compKeys.begin(); it != compKeys.end(); ++it) { std::string dataKey = *it; - Json comp; + CtxJson1 comp; comparison.get(NULL, dataKey.c_str(), &comp); std::string factValStr; @@ -227,10 +227,10 @@ bool RuleEvaluator::__evaluateItem(Json& factItem, Json& ruleItem, std::string l return isConjunction; } -bool RuleEvaluator::__evaluateRuleEvent(Json& fact, Json& rule) +bool RuleEvaluator::__evaluateRuleEvent(CtxJson1& fact, CtxJson1& rule) { - Json factItem; - Json ruleItem; + CtxJson1 factItem; + CtxJson1 ruleItem; fact.get(NULL, FACT_KEY_EVENT, &factItem); rule.get(NULL, TRIG_RULE_KEY_EVENT, &ruleItem); @@ -240,13 +240,13 @@ bool RuleEvaluator::__evaluateRuleEvent(Json& fact, Json& rule) return __evaluateItem(factItem, ruleItem, eventOp); } -Json RuleEvaluator::__getConditionFact(Json& fact, Json& ruleCond) +CtxJson1 RuleEvaluator::__getConditionFact(CtxJson1& fact, CtxJson1& ruleCond) { std::list condKey; ruleCond.getKeys(&condKey); std::string ruleCondName = *(condKey.begin()); - Json factCond; + CtxJson1 factCond; for (int i = 0; fact.getAt(NULL, FACT_KEY_CONDITION, i, &factCond); i++) { // Check if fact item name is matched with condition std::string factCondName; @@ -256,8 +256,8 @@ Json RuleEvaluator::__getConditionFact(Json& fact, Json& ruleCond) } // Check if fact item option is mathced with condition - Json ruleCondOption; - Json factCondOption; + CtxJson1 ruleCondOption; + CtxJson1 factCondOption; ruleCond.get(ruleCondName.c_str(), TRIG_RULE_KEY_OPTION, &ruleCondOption); factCond.get(NULL, FACT_KEY_OPTION, &factCondOption); if (factCondOption == ruleCondOption) { @@ -269,15 +269,15 @@ Json RuleEvaluator::__getConditionFact(Json& fact, Json& ruleCond) return EMPTY_JSON_OBJECT; } -bool RuleEvaluator::__evaluateRuleCondition(Json& fact, Json& rule) +bool RuleEvaluator::__evaluateRuleCondition(CtxJson1& fact, CtxJson1& rule) { std::string ruleOp; rule.get(_TRIG_RULE_KEY_EXTRA, _TRIG_RULE_KEY_RULE_LOGICAL_OP, &ruleOp); bool isConjunction = (TRIG_RULE_LOGICAL_CONJUNCTION == ruleOp); - Json ruleCond; + CtxJson1 ruleCond; for (int i = 0; rule.getAt(NULL, TRIG_RULE_KEY_CONDITION, i, &ruleCond); i++) { - Json factCond = __getConditionFact(fact, ruleCond); + CtxJson1 factCond = __getConditionFact(fact, ruleCond); bool result; if (factCond == EMPTY_JSON_OBJECT) { @@ -298,7 +298,7 @@ bool RuleEvaluator::__evaluateRuleCondition(Json& fact, Json& rule) return isConjunction; } -bool RuleEvaluator::__replaceOptionReferences(Json eventFactData, Json& ruleOption) +bool RuleEvaluator::__replaceOptionReferences(CtxJson1 eventFactData, CtxJson1& ruleOption) { // Replace referencing option to actual value std::string refVal; @@ -332,27 +332,27 @@ bool RuleEvaluator::__replaceOptionReferences(Json eventFactData, Json& ruleOpti return true; } -bool RuleEvaluator::__replaceEventReferences(Json& fact, Json& rule) +bool RuleEvaluator::__replaceEventReferences(CtxJson1& fact, CtxJson1& rule) { // Replace referencing data/option to actual value - Json eventFactData; + CtxJson1 eventFactData; if (!fact.get(FACT_KEY_EVENT, FACT_KEY_DATA, &eventFactData)) { _E("No event data found, error"); return false; } - Json ruleCond; + CtxJson1 ruleCond; for (int i = 0; rule.getAt(NULL, TRIG_RULE_KEY_CONDITION, i, &ruleCond); i++) { std::list condKey; ruleCond.getKeys(&condKey); std::string ruleCondName = *(condKey.begin()); - Json ruleComp; + CtxJson1 ruleComp; for (int j = 0; ruleCond.getAt(ruleCondName.c_str(), TRIG_RULE_KEY_COMPARISON, j, &ruleComp); j++) { __replaceDataReferences(eventFactData, ruleComp); } - Json ruleOption; + CtxJson1 ruleOption; if (ruleCond.get(ruleCondName.c_str(), TRIG_RULE_KEY_OPTION, &ruleOption)) { __replaceOptionReferences(eventFactData, ruleOption); } @@ -361,16 +361,16 @@ bool RuleEvaluator::__replaceEventReferences(Json& fact, Json& rule) return true; } -bool RuleEvaluator::evaluateRule(Json rule, Json fact) +bool RuleEvaluator::evaluateRule(CtxJson1 rule, CtxJson1 fact) { _D("Rule is %s ", rule.str().c_str()); _D("fact is %s ", fact.str().c_str()); RuleEvaluator eval; bool ret; - Json tempJson; + CtxJson1 tempJson; if (fact.get(NULL, FACT_KEY_CONDITION, &tempJson)) { - Json ruleCopy(rule.str()); + CtxJson1 ruleCopy(rule.str()); if (!eval.__replaceEventReferences(fact, ruleCopy)) { _W("Replace failed"); } diff --git a/src/agent/legacy/trigger/RuleEvaluator.h b/src/agent/legacy/trigger/RuleEvaluator.h index 3e79682..e9c0370 100644 --- a/src/agent/legacy/trigger/RuleEvaluator.h +++ b/src/agent/legacy/trigger/RuleEvaluator.h @@ -19,7 +19,7 @@ namespace ctx { - class Json; + class CtxJson1; namespace trigger { @@ -27,24 +27,24 @@ namespace trigger { private: RuleEvaluator(); - bool __evaluateRuleEvent(ctx::Json& fact, ctx::Json& rule); - bool __evaluateRuleCondition(ctx::Json& fact, ctx::Json& rule); - bool __evaluateItem(ctx::Json& factItem, ctx::Json& ruleItem, std::string logicalOp); - template bool __evaluateData(T factVal, Json& comparison); - template bool __evaluateSingleData(T factVal, Json& comparison, std::string op); - template bool __evaluateDualData(T factVal, Json& comparison, std::string op); - template bool __evaluateMultipleData(T factVal, Json& comparison, std::string op); + bool __evaluateRuleEvent(ctx::CtxJson1& fact, ctx::CtxJson1& rule); + bool __evaluateRuleCondition(ctx::CtxJson1& fact, ctx::CtxJson1& rule); + bool __evaluateItem(ctx::CtxJson1& factItem, ctx::CtxJson1& ruleItem, std::string logicalOp); + template bool __evaluateData(T factVal, CtxJson1& comparison); + template bool __evaluateSingleData(T factVal, CtxJson1& comparison, std::string op); + template bool __evaluateDualData(T factVal, CtxJson1& comparison, std::string op); + template bool __evaluateMultipleData(T factVal, CtxJson1& comparison, std::string op); - ctx::Json __getConditionFact(ctx::Json& fact, ctx::Json& ruleCond); + ctx::CtxJson1 __getConditionFact(ctx::CtxJson1& fact, ctx::CtxJson1& ruleCond); - bool __replaceEventReferences(ctx::Json& fact, ctx::Json& rule); - void __replaceDataReferences(ctx::Json eventFactData, ctx::Json& ruleComp); - void __replaceSingleDataReferences(ctx::Json& eventFactData, ctx::Json& ruleComp, std::string& dataKey); - void __replaceMultipleDataReferences(ctx::Json& eventFactData, ctx::Json& ruleComp, std::string& dataKey); - bool __replaceOptionReferences(ctx::Json eventFactData, ctx::Json& ruleOption); + bool __replaceEventReferences(ctx::CtxJson1& fact, ctx::CtxJson1& rule); + void __replaceDataReferences(ctx::CtxJson1 eventFactData, ctx::CtxJson1& ruleComp); + void __replaceSingleDataReferences(ctx::CtxJson1& eventFactData, ctx::CtxJson1& ruleComp, std::string& dataKey); + void __replaceMultipleDataReferences(ctx::CtxJson1& eventFactData, ctx::CtxJson1& ruleComp, std::string& dataKey); + bool __replaceOptionReferences(ctx::CtxJson1 eventFactData, ctx::CtxJson1& ruleOption); public: - static bool evaluateRule(ctx::Json rule, ctx::Json data); + static bool evaluateRule(ctx::CtxJson1 rule, ctx::CtxJson1 data); }; } /* namespace trigger */ diff --git a/src/agent/legacy/trigger/RuleManager.cpp b/src/agent/legacy/trigger/RuleManager.cpp index 11a9561..5386cef 100644 --- a/src/agent/legacy/trigger/RuleManager.cpp +++ b/src/agent/legacy/trigger/RuleManager.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "RuleManager.h" #include "ContextMonitor.h" #include "Rule.h" @@ -102,13 +102,13 @@ int RuleManager::__getUninstalledApp(void) // Return number of uninstalled apps std::string q1 = "SELECT DISTINCT packageId FROM ContextTriggerRule"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q1.c_str(), &record); IF_FAIL_RETURN_TAG(ret, -1, _E, "Query package ids of registered rules failed"); - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; std::string pkgId; elem.get(NULL, "packageId", &pkgId); @@ -166,13 +166,13 @@ int RuleManager::__clearRuleOfUninstalledPackage(bool isInit) q1 += pkgList; q1 += ")"; - std::vector record; + std::vector record; ret = __dbManager.executeSync(q1.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Failed to query enabled rules of uninstalled packages"); - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; int ruleId; elem.get(NULL, "rowId", &ruleId); error = disableRule(ruleId); @@ -183,7 +183,7 @@ int RuleManager::__clearRuleOfUninstalledPackage(bool isInit) // Delete rules of uninstalled packages from DB std::string q2 = "DELETE FROM ContextTriggerRule WHERE " + pkgList; - std::vector dummy; + std::vector dummy; ret = __dbManager.executeSync(q2.c_str(), &dummy); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Failed to remove rules from db"); _D("Uninstalled packages' rules are deleted from db"); @@ -196,15 +196,15 @@ int RuleManager::__clearRuleOfUninstalledPackage(bool isInit) int RuleManager::pauseRuleWithItem(std::string& subject) { std::string q = "SELECT rowId FROM ContextTriggerRule WHERE (status=2) AND (details LIKE '%\"ITEM_NAME\":\"" + subject + "\"%');"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Failed to query rowIds to be paused"); IF_FAIL_RETURN(record.size() > 0, ERR_NONE); _D("Pause rules related to %s", subject.c_str()); - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; int rowId; elem.get(NULL, "rowId", &rowId); @@ -218,16 +218,16 @@ int RuleManager::pauseRuleWithItem(std::string& subject) int RuleManager::resumeRuleWithItem(std::string& subject) { std::string q = "SELECT rowId FROM ContextTriggerRule WHERE (status=1) AND (details LIKE '%\"ITEM_NAME\":\"" + subject + "\"%');"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query paused rule ids failed"); IF_FAIL_RETURN(record.size() > 0, ERR_NONE); _D("Resume rules related to %s", subject.c_str()); std::string qRowId; - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; int rowId; elem.get(NULL, "rowId", &rowId); @@ -243,7 +243,7 @@ bool RuleManager::__reenableRule(void) int error; std::string q = "SELECT rowId FROM ContextTriggerRule WHERE status = 2"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Query rowIds of enabled rules failed"); IF_FAIL_RETURN_TAG(record.size() > 0, true, _D, "No rule to re-enable"); @@ -252,9 +252,9 @@ bool RuleManager::__reenableRule(void) std::string qRowId; qRowId.clear(); - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; int rowId; elem.get(NULL, "rowId", &rowId); @@ -270,17 +270,17 @@ bool RuleManager::__reenableRule(void) // For rules which is failed to re-enable std::string qUpdate = "UPDATE ContextTriggerRule SET status = 1 WHERE " + qRowId; - std::vector record2; + std::vector record2; ret = __dbManager.executeSync(qUpdate.c_str(), &record2); IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to update rules as paused"); return true; } -bool RuleManager::__ruleEquals(Json& lRule, Json& rRule) +bool RuleManager::__ruleEquals(CtxJson1& lRule, CtxJson1& rRule) { // Compare event - Json lEvent, rEvent; + CtxJson1 lEvent, rEvent; lRule.get(NULL, TRIG_RULE_KEY_EVENT, &lEvent); rRule.get(NULL, TRIG_RULE_KEY_EVENT, &rEvent); @@ -306,14 +306,14 @@ bool RuleManager::__ruleEquals(Json& lRule, Json& rRule) for (int i = 0; i < lCondCnt; i++) { bool found = false; - Json lCond; + CtxJson1 lCond; lRule.getAt(NULL, TRIG_RULE_KEY_CONDITION, i, &lCond); std::string lCOp; lRule.getAt(_TRIG_RULE_KEY_EXTRA, _TRIG_RULE_KEY_CONDITION_LOGICAL_OP, i, &lCOp); for (int j = 0; j < lCondCnt; j++) { - Json rCond; + CtxJson1 rCond; rRule.getAt(NULL, TRIG_RULE_KEY_CONDITION, j, &rCond); std::string rCOp; @@ -329,7 +329,7 @@ bool RuleManager::__ruleEquals(Json& lRule, Json& rRule) } // Compare action - Json lAction, rAction; + CtxJson1 lAction, rAction; lRule.get(NULL, TRIG_RULE_KEY_ACTION, &lAction); rRule.get(NULL, TRIG_RULE_KEY_ACTION, &rAction); if (lAction != rAction) @@ -338,26 +338,26 @@ bool RuleManager::__ruleEquals(Json& lRule, Json& rRule) return true; } -int64_t RuleManager::__getDuplicatedRuleId(std::string pkgId, Json& rule) +int64_t RuleManager::__getDuplicatedRuleId(std::string pkgId, CtxJson1& rule) { std::string q = "SELECT rowId, description, details FROM ContextTriggerRule WHERE packageId = '"; q += pkgId; q += "'"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Query rowId, details by package id failed"); std::string rDesc; rule.get(NULL, TRIG_RULE_KEY_DESCRIPTION, &rDesc); - Json rDetails = rule.str(); + CtxJson1 rDetails = rule.str(); rDetails.remove(NULL, TRIG_RULE_KEY_DESCRIPTION); - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; std::string dStr; - Json details; + CtxJson1 details; elem.get(NULL, "details", &dStr); details = dStr; @@ -373,7 +373,7 @@ int64_t RuleManager::__getDuplicatedRuleId(std::string pkgId, Json& rule) // Only description is changed std::string qUpdate = "UPDATE ContextTriggerRule SET description='" + rDesc + "' WHERE rowId = " + __intToString(rowId); - std::vector dummy; + std::vector dummy; ret = __dbManager.executeSync(qUpdate.c_str(), &dummy); if (ret) { _D("Rule%lld description is updated", rowId); @@ -389,13 +389,13 @@ int64_t RuleManager::__getDuplicatedRuleId(std::string pkgId, Json& rule) return -1; } -int RuleManager::__verifyRule(Json& rule, const char* creator) +int RuleManager::__verifyRule(CtxJson1& rule, const char* creator) { ContextMonitor* ctxMonitor = ContextMonitor::getInstance(); IF_FAIL_RETURN_TAG(ctxMonitor, ERR_OUT_OF_MEMORY, _E, "Memory allocation failed"); // Event - Json event; + CtxJson1 event; rule.get(NULL, TRIG_RULE_KEY_EVENT, &event); std::list eventKey; @@ -411,7 +411,7 @@ int RuleManager::__verifyRule(Json& rule, const char* creator) } // Conditions - Json cond; + CtxJson1 cond; for (int i = 0; rule.getAt(NULL, TRIG_RULE_KEY_CONDITION, i, &cond); i++) { std::list condKey; cond.getKeys(&condKey); @@ -429,7 +429,7 @@ int RuleManager::__verifyRule(Json& rule, const char* creator) return ERR_NONE; } -int RuleManager::addRule(std::string creator, const char* pkgId, Json rule, Json* ruleId) +int RuleManager::addRule(std::string creator, const char* pkgId, CtxJson1 rule, CtxJson1* ruleId) { bool ret; int64_t rid; @@ -447,11 +447,11 @@ int RuleManager::addRule(std::string creator, const char* pkgId, Json rule, Json } // Insert rule to rule table, get rule id - Json record; + CtxJson1 record; std::string description; rule.get(NULL, TRIG_RULE_KEY_DESCRIPTION, &description); - Json details = rule.str(); + CtxJson1 details = rule.str(); details.remove(NULL, TRIG_RULE_KEY_DESCRIPTION); record.set(NULL, "details", details.str()); @@ -480,7 +480,7 @@ int RuleManager::removeRule(int ruleId) std::string query = "DELETE FROM 'ContextTriggerRule' where rowId = "; query += __intToString(ruleId); - std::vector record; + std::vector record; ret = __dbManager.executeSync(query.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Remove rule from db failed"); @@ -493,16 +493,16 @@ int RuleManager::enableRule(int ruleId) { int error; std::string query; - std::vector record; - std::vector dummy; + std::vector record; + std::vector dummy; std::string pkgId; - Json jRule; + CtxJson1 jRule; std::string tmp; std::string idStr = __intToString(ruleId); Rule* rule; - // Get rule Json by rule id; + // Get rule CtxJson1 by rule id; query = "SELECT details, packageId FROM ContextTriggerRule WHERE rowId = "; query += idStr; error = (__dbManager.executeSync(query.c_str(), &record))? ERR_NONE : ERR_OPERATION_FAILED; @@ -562,7 +562,7 @@ int RuleManager::disableRule(int ruleId) // Update db to set 'disabled' // TODO skip while clear uninstalled rule std::string query = "UPDATE ContextTriggerRule SET status = 0 WHERE rowId = "; query += __intToString(ruleId); - std::vector record; + std::vector record; ret = __dbManager.executeSync(query.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Update db failed"); @@ -587,7 +587,7 @@ int RuleManager::pauseRule(int ruleId) std::string query = "UPDATE ContextTriggerRule SET status = 1 WHERE rowId = "; query += __intToString(ruleId); - std::vector record; + std::vector record; ret = __dbManager.executeSync(query.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Update db failed"); @@ -605,7 +605,7 @@ int RuleManager::checkRule(std::string pkgId, int ruleId) std::string q = "SELECT packageId FROM ContextTriggerRule WHERE rowId ="; q += __intToString(ruleId); - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Query package id by rule id failed"); @@ -628,7 +628,7 @@ bool RuleManager::isRuleEnabled(int ruleId) std::string q = "SELECT status FROM ContextTriggerRule WHERE rowId ="; q += __intToString(ruleId); - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Query enabled by rule id failed"); @@ -638,7 +638,7 @@ bool RuleManager::isRuleEnabled(int ruleId) return (status != 0); } -int RuleManager::getRuleById(std::string pkgId, int ruleId, Json* requestResult) +int RuleManager::getRuleById(std::string pkgId, int ruleId, CtxJson1* requestResult) { std::string q = "SELECT description FROM ContextTriggerRule WHERE (packageId = '"; q += pkgId; @@ -646,7 +646,7 @@ int RuleManager::getRuleById(std::string pkgId, int ruleId, Json* requestResult) q += __intToString(ruleId); q += ")"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Query rule by rule id failed"); @@ -665,7 +665,7 @@ int RuleManager::getRuleById(std::string pkgId, int ruleId, Json* requestResult) return ERR_NONE; } -int RuleManager::getRuleIds(std::string pkgId, Json* requestResult) +int RuleManager::getRuleIds(std::string pkgId, CtxJson1* requestResult) { (*requestResult) = RULE_IDS_JSON; @@ -673,13 +673,13 @@ int RuleManager::getRuleIds(std::string pkgId, Json* requestResult) q += pkgId; q += "')"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query rules failed"); - std::vector::iterator vecEnd = record.end(); - for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { - Json elem = *vecPos; + std::vector::iterator vecEnd = record.end(); + for (std::vector::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) { + CtxJson1 elem = *vecPos; std::string id; int status; diff --git a/src/agent/legacy/trigger/RuleManager.h b/src/agent/legacy/trigger/RuleManager.h index cf47eee..2187aa2 100644 --- a/src/agent/legacy/trigger/RuleManager.h +++ b/src/agent/legacy/trigger/RuleManager.h @@ -23,7 +23,7 @@ namespace ctx { - class Json; + class CtxJson1; namespace trigger { @@ -36,12 +36,12 @@ namespace trigger { ~RuleManager(); bool init(); - int addRule(std::string creator, const char* pkgId, Json rule, Json* ruleId); + int addRule(std::string creator, const char* pkgId, CtxJson1 rule, CtxJson1* ruleId); int removeRule(int ruleId); int enableRule(int ruleId); int disableRule(int ruleId); - int getRuleById(std::string pkgId, int ruleId, Json* requestResult); - int getRuleIds(std::string pkgId, Json* requestResult); + int getRuleById(std::string pkgId, int ruleId, CtxJson1* requestResult); + int getRuleIds(std::string pkgId, CtxJson1* requestResult); int checkRule(std::string pkgId, int ruleId); bool isRuleEnabled(int ruleId); int pauseRuleWithItem(std::string& subject); @@ -53,9 +53,9 @@ namespace trigger { private: bool __reenableRule(void); - int __verifyRule(Json& rule, const char* creator); - int64_t __getDuplicatedRuleId(std::string pkgId, Json& rule); - bool __ruleEquals(Json& lRule, Json& rRule); + int __verifyRule(CtxJson1& rule, const char* creator); + int64_t __getDuplicatedRuleId(std::string pkgId, CtxJson1& rule); + bool __ruleEquals(CtxJson1& lRule, CtxJson1& rRule); int __getUninstalledApp(void); int __clearRuleOfUninstalledPackage(bool isInit = false); void __applyTemplates(void); diff --git a/src/agent/legacy/trigger/TemplateManager.cpp b/src/agent/legacy/trigger/TemplateManager.cpp index 65ddc39..6a952a1 100644 --- a/src/agent/legacy/trigger/TemplateManager.cpp +++ b/src/agent/legacy/trigger/TemplateManager.cpp @@ -79,7 +79,7 @@ bool TemplateManager::init() + "(name TEXT DEFAULT '' NOT NULL PRIMARY KEY, operation INTEGER DEFAULT 3 NOT NULL, " + "attributes TEXT DEFAULT '' NOT NULL, options TEXT DEFAULT '' NOT NULL, owner TEXT DEFAULT '' NOT NULL)"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, false, _E, "Create template table failed"); @@ -93,8 +93,8 @@ void TemplateManager::applyTemplates() { std::string subject; int operation; - Json attributes; - Json options; + CtxJson1 attributes; + CtxJson1 options; std::string owner; std::string query; query.clear(); @@ -104,7 +104,7 @@ void TemplateManager::applyTemplates() } } -void TemplateManager::registerTemplate(std::string subject, int operation, Json attributes, Json options, std::string owner) +void TemplateManager::registerTemplate(std::string subject, int operation, CtxJson1 attributes, CtxJson1 options, std::string owner) { _D("[Add template] Subject: %s, Ops: %d, Owner: %s", subject.c_str(), operation, owner.c_str()); _J("Attr", attributes); @@ -118,7 +118,7 @@ void TemplateManager::registerTemplate(std::string subject, int operation, Json + subject + "', " + __intToString(operation) + ", '" + attributes.str() + "', '" + options.str() + "', '" + owner + "'); "; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(query.c_str(), &record); IF_FAIL_VOID_TAG(ret, _E, "Update template db failed"); @@ -132,7 +132,7 @@ void TemplateManager::unregisterTemplate(std::string subject) _D("[Remove template] Subject: %s", subject.c_str()); std::string query = "DELETE FROM ContextTriggerTemplate WHERE name = '" + subject + "'; "; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(query.c_str(), &record); IF_FAIL_VOID_TAG(ret, _E, "Update template db failed"); @@ -140,7 +140,7 @@ void TemplateManager::unregisterTemplate(std::string subject) } -std::string TemplateManager::__addTemplate(std::string &subject, int &operation, Json &attributes, Json &options, std::string &owner) +std::string TemplateManager::__addTemplate(std::string &subject, int &operation, CtxJson1 &attributes, CtxJson1 &options, std::string &owner) { _D("[Add template] Subject: %s, Ops: %d, Owner: %s", subject.c_str(), operation, owner.c_str()); _J("Attr", attributes); @@ -165,7 +165,7 @@ std::string TemplateManager::__removeTemplate(std::string &subject) return query; } -int TemplateManager::getTemplate(std::string &subject, Json* tmpl) +int TemplateManager::getTemplate(std::string &subject, CtxJson1* tmpl) { if (!__contextMgr->isSupported(subject.c_str())) return ERR_NOT_SUPPORTED; @@ -173,7 +173,7 @@ int TemplateManager::getTemplate(std::string &subject, Json* tmpl) // Update latest template information std::string q = "SELECT * FROM ContextTriggerTemplate WHERE name = '" + subject + "'"; - std::vector record; + std::vector record; bool ret = __dbManager.executeSync(q.c_str(), &record); IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query template failed"); IF_FAIL_RETURN_TAG(record.size() > 0, ERR_NOT_SUPPORTED, _E, "Template(%s) not found", subject.c_str()); @@ -186,8 +186,8 @@ int TemplateManager::getTemplate(std::string &subject, Json* tmpl) tmpl->get(NULL, TRIG_TMPL_KEY_OPTION, &optStr); tmpl->get(NULL, TRIG_TMPL_KEY_ATTRIBUTE, &attrStr); - Json opt = optStr; - Json attr = attrStr; + CtxJson1 opt = optStr; + CtxJson1 attr = attrStr; tmpl->set(NULL, TRIG_TMPL_KEY_OPTION, opt); tmpl->set(NULL, TRIG_TMPL_KEY_ATTRIBUTE, attr); diff --git a/src/agent/legacy/trigger/TemplateManager.h b/src/agent/legacy/trigger/TemplateManager.h index c91ef15..69c0e06 100644 --- a/src/agent/legacy/trigger/TemplateManager.h +++ b/src/agent/legacy/trigger/TemplateManager.h @@ -17,7 +17,7 @@ #ifndef _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_ #define _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_ -#include +#include #include namespace ctx { @@ -36,8 +36,8 @@ namespace trigger { bool init(); void applyTemplates(); - int getTemplate(std::string &subject, Json* tmpl); - void registerTemplate(std::string subject, int operation, Json attributes, Json options, std::string owner); + int getTemplate(std::string &subject, CtxJson1* tmpl); + void registerTemplate(std::string subject, int operation, CtxJson1 attributes, CtxJson1 options, std::string owner); void unregisterTemplate(std::string subject); private: @@ -51,7 +51,7 @@ namespace trigger { DatabaseManager __dbManager; - std::string __addTemplate(std::string &subject, int &operation, Json &attributes, Json &options, std::string &owner); + std::string __addTemplate(std::string &subject, int &operation, CtxJson1 &attributes, CtxJson1 &options, std::string &owner); std::string __removeTemplate(std::string &subject); }; /* class TemplateManager */ diff --git a/src/agent/legacy/trigger/Trigger.cpp b/src/agent/legacy/trigger/Trigger.cpp index bb3c7aa..762bdea 100644 --- a/src/agent/legacy/trigger/Trigger.cpp +++ b/src/agent/legacy/trigger/Trigger.cpp @@ -129,7 +129,7 @@ void Trigger::__processInitialize(ContextManager* mgr) void Trigger::__addRule(RequestInfo* request) { - Json ruleId; + CtxJson1 ruleId; const char* client = request->getClient(); if (client == NULL) { @@ -152,7 +152,7 @@ void Trigger::__removeRule(RequestInfo* request) const char* pkgId = request->getPackageId(); - Json ruleId = request->getDescription(); + CtxJson1 ruleId = request->getDescription(); ruleId.get(NULL, TRIG_KEY_RULE_ID, &id); error = __ruleMgr->checkRule((pkgId)? pkgId : "", id); @@ -179,7 +179,7 @@ void Trigger::__enableRule(RequestInfo* request) const char* pkgId = request->getPackageId(); - Json ruleId = request->getDescription(); + CtxJson1 ruleId = request->getDescription(); ruleId.get(NULL, TRIG_KEY_RULE_ID, &id); error = __ruleMgr->checkRule((pkgId)? pkgId : "", id); @@ -206,7 +206,7 @@ void Trigger::__disableRule(RequestInfo* request) const char* pkgId = request->getPackageId(); - Json ruleId = request->getDescription(); + CtxJson1 ruleId = request->getDescription(); ruleId.get(NULL, TRIG_KEY_RULE_ID, &id); error = __ruleMgr->checkRule((pkgId)? pkgId : "", id); @@ -230,16 +230,16 @@ void Trigger::__getRuleById(RequestInfo* request) { int error; - Json option = request->getDescription(); + CtxJson1 option = request->getDescription(); int id; option.get(NULL, TRIG_KEY_RULE_ID, &id); const char* pkgId = request->getPackageId(); - Json readData; + CtxJson1 readData; error = __ruleMgr->getRuleById((pkgId)? pkgId : "", id, &readData); - Json dummy; + CtxJson1 dummy; request->reply(error, dummy, readData); } @@ -249,10 +249,10 @@ void Trigger::__getRuleIds(RequestInfo* request) const char* pkgId = request->getPackageId(); - Json readData; + CtxJson1 readData; error = __ruleMgr->getRuleIds((pkgId)? pkgId : "", &readData); - Json dummy; + CtxJson1 dummy; request->reply(error, dummy, readData); } @@ -260,7 +260,7 @@ void Trigger::__getTemplate(RequestInfo* request) { int error; - Json option = request->getDescription(); + CtxJson1 option = request->getDescription(); std::string name; option.get(NULL, TRIG_TMPL_KEY_SUBJECT, &name); @@ -271,9 +271,9 @@ void Trigger::__getTemplate(RequestInfo* request) return; } - Json tmpl; + CtxJson1 tmpl; error = tmplMgr->getTemplate(name, &tmpl); - Json dummy; + CtxJson1 dummy; request->reply(error, dummy, tmpl); }