Replace the glib-json wrapper CtxJson with jsoncpp 20/137220/1 accepted/tizen/unified/20170705.162927 submit/tizen/20170705.022841
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 3 Jul 2017 03:06:06 +0000 (12:06 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 5 Jul 2017 02:19:51 +0000 (02:19 +0000)
Change-Id: I9f77aa8aadaa01c3fd703b861b52092b17eb8b53
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
(cherry picked from commit 955735862175b3b18c9e74c3d15f9c6412537525)

CMakeLists.txt
packaging/capi-context.spec
src/context_history.cpp

index 49d5907..430be88 100644 (file)
@@ -10,7 +10,7 @@ FILE(GLOB_RECURSE SRCS src/*.cpp)
 MESSAGE("Sources: ${SRCS}")
 
 # Dependencies
-SET(DEPS "gio-2.0 context-common-legacy aul bundle capi-appfw-app-control pkgmgr-info context-app-history-client")
+SET(DEPS "gio-2.0 jsoncpp context-common-legacy aul bundle capi-appfw-app-control pkgmgr-info context-app-history-client")
 
 # Common Options
 INCLUDE(FindPkgConfig)
index b792a50..6eecaf9 100644 (file)
@@ -8,6 +8,7 @@ Source0:    %{name}-%{version}.tar.gz
 
 BuildRequires: cmake
 BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(jsoncpp)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(capi-appfw-app-control)
index 8895ad4..3770d2f 100644 (file)
@@ -15,8 +15,8 @@
  */
 
 #include <map>
+#include <json/json.h>
 #include <ContextTypes.h>
-#include <CtxJson.h>
 #include <Tuple.h>
 #include <app_history_internal.h>
 #include <app_history_types_internal.h>
@@ -41,7 +41,7 @@ typedef struct _context_history_handle_s {
 } _cx_history_handle;
 
 typedef struct _context_history_filter_handle_s {
-       ctx::CtxJson jfilter;
+       Json::Value jfilter;
 } _cx_history_filter_handle;
 
 typedef struct _context_history_list_handle_s {
@@ -120,7 +120,7 @@ EXPORT_API int context_history_filter_set_int(context_history_filter_h filter, c
        // Check filter and its data type
        IF_FAIL_RETURN_TAG(check_filter_data_int(filter_type, val), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Filter type mismatched");
 
-       filter->jfilter.set(NULL, filter_str.c_str(), val);
+       filter->jfilter[filter_str] = val;
 
        return CONTEXT_HISTORY_ERROR_NONE;
 }
@@ -143,7 +143,7 @@ EXPORT_API int context_history_filter_set_string(context_history_filter_h filter
        // Check filter and its data type
        IF_FAIL_RETURN_TAG(check_filter_data_string(filter_type, val), CONTEXT_HISTORY_ERROR_INVALID_PARAMETER, _E, "Filter type mismatched");
 
-       filter->jfilter.set(NULL, filter_str.c_str(), val);
+       filter->jfilter[filter_str] = val;
 
        return CONTEXT_HISTORY_ERROR_NONE;
 }
@@ -187,7 +187,14 @@ EXPORT_API int context_history_get_list(context_history_h handle, context_histor
        *list = new(std::nothrow) _cx_history_list_handle();
        ASSERT_ALLOC(*list);
 
-       int err = _ctx_history_query(data_type_str.c_str(), filter ? filter->jfilter.str().c_str() : "", &((*list)->cursor));
+       std::string filterStr;
+       if (filter) {
+               Json::FastWriter fw;
+               fw.omitEndingLineFeed();
+               filterStr = fw.write(filter->jfilter);
+       }
+
+       int err = _ctx_history_query(data_type_str.c_str(), filterStr.c_str(), &((*list)->cursor));
        IF_FAIL_RETURN_TAG(err == E_NONE, err, _E, "Query failed");
 
        return CONTEXT_HISTORY_ERROR_NONE;
@@ -530,11 +537,9 @@ bool check_invalid_filter(context_history_data_e data_type, context_history_filt
        }
 
        bool found = true;
-       std::list<std::string> keys;
-       filter->jfilter.getKeys(&keys);
+       std::vector<std::string> keys = filter->jfilter.getMemberNames();
 
-       for (std::list<std::string>::iterator it = keys.begin(); it != keys.end(); ++it) {
-               std::string key = (*it);
+       for (auto& key : keys) {
                found = false;
                for (int i = 1; i < FILTER_KEY_LIMIT; ++i) {
                        if (allowed[i] && key == filter_key[i]) {