Support custom items 48/57548/7
authorSomin Kim <somin926.kim@samsung.com>
Mon, 18 Jan 2016 07:38:30 +0000 (16:38 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Mon, 15 Feb 2016 10:09:22 +0000 (02:09 -0800)
- error code, req type added
- unregister trigger item/provider added
- json valid() function added
- is_supported modified

Change-Id: I4af9c0fd64f80ab6302755b93572ab071a40f783
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
include/context_mgr.h
include/context_mgr_iface.h
include/json.h
include/types_internal.h
src/context_mgr.cpp
src/json.cpp
src/request_handler.cpp

index 13765f0..1e663a0 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __CONTEXT_MANAGER_H__
 #define __CONTEXT_MANAGER_H__
 
+#include <stdlib.h>
+
 namespace ctx {
        /* Forward Declaration */
        class json;
@@ -36,7 +38,15 @@ namespace ctx {
 
                /*
                 */
-               bool register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options);
+               bool unregister_provider(const char *subject);
+
+               /*
+                */
+               bool register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options, const char* owner = NULL);
+
+               /*
+                */
+               bool unregister_trigger_item(const char *subject);
 
                /*
                 */
index dd29568..5d021b3 100644 (file)
@@ -27,7 +27,9 @@ namespace ctx {
        public:
                virtual ~context_manager_iface() {}
                virtual bool register_provider(const char *subject, context_provider_info &provider_info) = 0;
-               virtual bool register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options) = 0;
+               virtual bool unregister_provider(const char *subject) = 0;
+               virtual bool register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options, const char* owner = NULL) = 0;
+               virtual bool unregister_trigger_item(const char *subject) = 0;
                virtual bool publish(const char *subject, ctx::json &option, int error, ctx::json &data_updated) = 0;
                virtual bool reply_to_read(const char *subject, ctx::json &option, int error, ctx::json &data_read) = 0;
        };      /* class context_manager_iface */
index 5c35299..d6a8e32 100644 (file)
@@ -79,6 +79,7 @@ namespace ctx {
                std::string str();
 
                bool get_keys(std::list<std::string>* list);
+               bool valid();
 
                bool set(const char* path, const char* key, json& val);
                bool set(const char* path, const char* key, int val);
index 49f928c..c45b18d 100644 (file)
@@ -42,6 +42,8 @@
 #define ERR_RULE_NOT_ENABLED   (TIZEN_ERROR_CONTEXT | 0x06)
 #define ERR_INVALID_RULE               (TIZEN_ERROR_CONTEXT | 0x07)
 #define ERR_RULE_NOT_EXIST             (TIZEN_ERROR_CONTEXT | 0x08)
+#define ERR_INVALID_DATA               ERR_INVALID_RULE
+#define ERR_DATA_EXIST                 (TIZEN_ERROR_CONTEXT | 0X09)
 
 /* Logging and Error Handling */
 #define _I SLOGI
index 1bf2b2d..c447c45 100644 (file)
@@ -33,10 +33,22 @@ bool ctx::context_manager::register_provider(const char* subject, ctx::context_p
        return _instance->register_provider(subject, provider_info);
 }
 
-bool ctx::context_manager::register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options)
+bool ctx::context_manager::unregister_provider(const char* subject)
 {
        IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
-       return _instance->register_trigger_item(subject, operation, attributes, options);
+       return _instance->unregister_provider(subject);
+}
+
+bool ctx::context_manager::register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options, const char* owner)
+{
+       IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
+       return _instance->register_trigger_item(subject, operation, attributes, options, owner);
+}
+
+bool ctx::context_manager::unregister_trigger_item(const char *subject)
+{
+       IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
+       return _instance->unregister_trigger_item(subject);
 }
 
 bool ctx::context_manager::publish(const char* subject, ctx::json option, int error, ctx::json data_updated)
index 98d3f1b..063caf9 100644 (file)
@@ -125,6 +125,11 @@ void ctx::json::release()
        }
 }
 
+bool ctx::json::valid()
+{
+       return (json_node != NULL);
+}
+
 ctx::json& ctx::json::operator=(const json& j)
 {
        release();
index 4352205..8f8fc4f 100644 (file)
@@ -230,7 +230,10 @@ int ctx::request_handler::is_supported(const char* subject)
 {
        ASSERT_NOT_NULL(subject);
        IF_FAIL_RETURN_TAG(initialize(), false, _E, "Connection failed");
-       return dbus_handle->request(REQ_SUPPORT, generate_req_id(), subject, NULL, NULL, NULL);
+
+       int error = dbus_handle->request(REQ_SUPPORT, generate_req_id(), subject, NULL, NULL, NULL);
+       _D("Error: %#x", error);
+       return error;
 }
 
 bool ctx::request_handler::register_callback(const char* subject, subject_response_cb callback)