Rename the class Json to avoid symbol conflicts with Jsoncpp 77/132977/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 8 Jun 2017 12:28:32 +0000 (21:28 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 8 Jun 2017 12:28:32 +0000 (21:28 +0900)
Change-Id: I7826f4420ee0fa4879ce2d9e25d1a61c5279bada
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
28 files changed:
src/agent/legacy/ClientRequest.cpp
src/agent/legacy/ClientRequest.h
src/agent/legacy/ContextManager.cpp
src/agent/legacy/ContextManager.h
src/agent/legacy/ProviderHandler.cpp
src/agent/legacy/ProviderHandler.h
src/agent/legacy/ProviderLoader.cpp
src/agent/legacy/ProviderLoader.h
src/agent/legacy/Request.cpp
src/agent/legacy/Request.h
src/agent/legacy/policy/PolicyRequest.cpp
src/agent/legacy/policy/PolicyRequest.h
src/agent/legacy/trigger/ActionManager.cpp
src/agent/legacy/trigger/ActionManager.h
src/agent/legacy/trigger/ContextMonitor.cpp
src/agent/legacy/trigger/ContextMonitor.h
src/agent/legacy/trigger/FactRequest.cpp
src/agent/legacy/trigger/FactRequest.h
src/agent/legacy/trigger/IContextListener.h
src/agent/legacy/trigger/Rule.cpp
src/agent/legacy/trigger/Rule.h
src/agent/legacy/trigger/RuleEvaluator.cpp
src/agent/legacy/trigger/RuleEvaluator.h
src/agent/legacy/trigger/RuleManager.cpp
src/agent/legacy/trigger/RuleManager.h
src/agent/legacy/trigger/TemplateManager.cpp
src/agent/legacy/trigger/TemplateManager.h
src/agent/legacy/trigger/Trigger.cpp

index e625bf063ebf3ffce9625389fb1ef46128b074c9..0ae8573dbfe4c760a63588e1a03c249bd765333c 100644 (file)
@@ -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;
index 69d18e1246eae655b51b8cf2fd22a6a359e64189..e6e653b2316f0698e8c4089dd5c2a0302e522c88 100644 (file)
@@ -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;
index 7d0796652add0076fa951d0dc62e770985dc4c4c..9f5241546a60ee129e057f7b270befa36841bcf4 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <Types.h>
 #include <DBusTypes.h>
-#include <Json.h>
+#include <CtxJson1.h>
 #include <ContextProvider.h>
 #include <CustomRegister.h>
 
@@ -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");
 
index 9be24c15e8f34de5447d301340ae59d61a37e2e5..ab989102c8ced198ee968ca96f44d98e19a33203 100644 (file)
@@ -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;
 
index 62e1cf1d194455cfefb51ef27f1c6c5efa640081..d4bbc4feb981f8063996fda911911b1a64de42b2 100644 (file)
@@ -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()) {
index 58225f728e3752c066e2798c691acef34037bd65..ae2228edb3874b106b32d0b450a3310701eb998e 100644 (file)
@@ -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);
 
index 8a7d6a61e2a0da046bf9fddc5c25c0f218760bae..7ef46274caeedf858492b64c8c72d77b1df93143 100644 (file)
@@ -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);
index ab5a427ed84f24ff76af501cf4715467bc34dec1..aae6c5d892656b6f96dbb024879cc63173e4b470 100644 (file)
@@ -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);
index d900fcc0a02763ce2eb9c489a8fab5ac6d44fefb..efaa13fadafeea6e9a08405b1d1b50506c664238 100644 (file)
@@ -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;
 }
index 9750b2ffe6b75921a7f0068eded8f27192f85908..b3425a17daf321cd5bd8d617b38104d75f3a36d4 100644 (file)
@@ -18,7 +18,7 @@
 #define _CONTEXT_REQUEST_INFO_H_
 
 #include <string>
-#include <Json.h>
+#include <CtxJson1.h>
 
 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 */
index 63cf8aee33b3a34a2af85351fd1f4034dd9d96d4..cd69534c82251dd795a6477ba49da84625e873ba 100644 (file)
@@ -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;
 }
index 2ed28c776c941060a3e5415266c830a0c4440cf1..ce68fb852b1812b35e8445f9e141afdadef1a778 100644 (file)
@@ -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 */
index b45671f883ae8704fce23b98d324a0cb0411165c..332c87e0c4df93dd806524e8c3d69669491fc39d 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include <Types.h>
-#include <Json.h>
+#include <CtxJson1.h>
 #include <app_control.h>
 #include <app_control_internal.h>
 #include <bundle.h>
 
 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<std::string> 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;
index 273f450e90b78d8c68b3545237ad2cbb06964d7a..5d8c026ab08cadebff7fabf1f50dd875497f1f7b 100644 (file)
 
 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 */
 
index 5dab7f53dd3034688549ace5035f5fe720cfcec2..86d8c991248fa3b3c3c216cdcdae80a2ad41b6a7 100644 (file)
@@ -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<int, SubscrInfo*>* 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<int, SubscrInfo*>* 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<int, SubscrInfo*>* 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());
 
index 473cac25c4c451cc0186b16cb5303bb3cf5eadc0..6f65cdffefa5c2497d5b2375e3f047484e2e49b7 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <list>
 #include <map>
-#include <Json.h>
+#include <CtxJson1.h>
 #include <DBusTypes.h>
 
 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<IContextListener*> 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<int, SubscrInfo*> __subscrMap;
                std::map<int, SubscrInfo*> __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);
index fc09d9dee02a95d4ed93e09e2aca80e36c77e931..da9212cd0f7eec9d947c321267ebc2d1c0d87143 100644 (file)
@@ -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);
index 8c54fe8f6b1540d3069d78bbb58baabd71c631f2..2c18b4a34dd2746750d714a7f8566bd49f52083e 100644 (file)
@@ -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;
index 826ab413ada032e9f0860b2298fb55b26bc42b95..1311254b105b93a987c8c9e17ddd68ce9baebef1 100644 (file)
@@ -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 */
index 33b2ef8759ab167fab4ebad158091e864083ac0c..d6bff3293195b45d0b0ecf8bec982176338d12cd 100644 (file)
@@ -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<std::string> 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);
index 1192b6e44efd345eb458814d17ded7781e83acde..cce117ad7e2ab525599c210931a80cb4cb5b8776 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <string>
 #include <list>
-#include <Json.h>
+#include <CtxJson1.h>
 #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<std::string> 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<ContextItem*> __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);
 
        };
 
index b0e58332f94a6247322d65d752ae32d020fb71fa..6dc66b491e808c0597f26cb183e369158a8cd751 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <Json.h>
+#include <CtxJson1.h>
 #include <Types.h>
 #include <TriggerRuleTypes.h>
 #include "RuleEvaluator.h"
@@ -35,7 +35,7 @@ RuleEvaluator::RuleEvaluator()
 }
 
 template <typename T>
-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 <typename T>
-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 <typename T>
-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 <typename T>
-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<std::string> 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<std::string> 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<std::string> 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<std::string> 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");
                }
index 3e796824419c6ec0a14d6161bfcb90ee241ced8a..e9c03707b7e975ac0881fb0c9677d104aea92126 100644 (file)
@@ -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 <typename T> bool __evaluateData(T factVal, Json& comparison);
-               template <typename T> bool __evaluateSingleData(T factVal, Json& comparison, std::string op);
-               template <typename T> bool __evaluateDualData(T factVal, Json& comparison, std::string op);
-               template <typename T> 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 <typename T> bool __evaluateData(T factVal, CtxJson1& comparison);
+               template <typename T> bool __evaluateSingleData(T factVal, CtxJson1& comparison, std::string op);
+               template <typename T> bool __evaluateDualData(T factVal, CtxJson1& comparison, std::string op);
+               template <typename T> 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 */
index 11a956166b9ffd9dff5127cbe08f33e1388087ad..5386cefe471d1a505bab663a3031ad87fc280363 100644 (file)
@@ -18,7 +18,7 @@
 #include <TriggerTypes.h>
 #include <TriggerRuleTypes.h>
 #include <package_manager.h>
-#include <Json.h>
+#include <CtxJson1.h>
 #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<Json> record;
+       std::vector<CtxJson1> 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<Json>::iterator vecEnd = record.end();
-       for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-               Json elem = *vecPos;
+       std::vector<CtxJson1>::iterator vecEnd = record.end();
+       for (std::vector<CtxJson1>::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<Json> record;
+               std::vector<CtxJson1> 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<Json>::iterator vecEnd = record.end();
-               for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-                       Json elem = *vecPos;
+               std::vector<CtxJson1>::iterator vecEnd = record.end();
+               for (std::vector<CtxJson1>::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<Json> dummy;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json>::iterator vecEnd = record.end();
-       for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-               Json elem = *vecPos;
+       std::vector<CtxJson1>::iterator vecEnd = record.end();
+       for (std::vector<CtxJson1>::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<Json> record;
+       std::vector<CtxJson1> 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<Json>::iterator vecEnd = record.end();
-       for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-               Json elem = *vecPos;
+       std::vector<CtxJson1>::iterator vecEnd = record.end();
+       for (std::vector<CtxJson1>::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<Json> record;
+       std::vector<CtxJson1> 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<Json>::iterator vecEnd = record.end();
-       for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-               Json elem = *vecPos;
+       std::vector<CtxJson1>::iterator vecEnd = record.end();
+       for (std::vector<CtxJson1>::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<Json> record2;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json>::iterator vecEnd = record.end();
-       for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-               Json elem = *vecPos;
+       std::vector<CtxJson1>::iterator vecEnd = record.end();
+       for (std::vector<CtxJson1>::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<Json> dummy;
+                               std::vector<CtxJson1> 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<std::string> 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<std::string> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
-       std::vector<Json> dummy;
+       std::vector<CtxJson1> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> record;
        bool ret = __dbManager.executeSync(q.c_str(), &record);
        IF_FAIL_RETURN_TAG(ret, ERR_OPERATION_FAILED, _E, "Query rules failed");
 
-       std::vector<Json>::iterator vecEnd = record.end();
-       for (std::vector<Json>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
-               Json elem = *vecPos;
+       std::vector<CtxJson1>::iterator vecEnd = record.end();
+       for (std::vector<CtxJson1>::iterator vecPos = record.begin(); vecPos != vecEnd; ++vecPos) {
+               CtxJson1 elem = *vecPos;
                std::string id;
                int status;
 
index cf47eeef7117a05e1927fdb41b2e9c581465d479..2187aa2b28d27e6fbc2be011b1cb91dbddec9a3b 100644 (file)
@@ -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);
index 65ddc3984ae0b1fcb11680094e9ba5fbc3760519..6a952a1b68c7a4236064b4209421e95640b6f746 100644 (file)
@@ -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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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<Json> record;
+       std::vector<CtxJson1> 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);
index c91ef15ae796035f0b37c38d479224224de2fe2d..69c0e066d76fda13b2972fceaa85478c48df4328 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_
 #define _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_
 
-#include <Json.h>
+#include <CtxJson1.h>
 #include <DatabaseManager.h>
 
 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 */
index bb3c7aaca54a659d3e38f1e246bcb2a444a61ab6..762bdeaf242264a89f43870bd6cd91a561d7b251 100644 (file)
@@ -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);
 }