added internal setting APIs 02/80602/3
authorkmook <kmook.choi@samsung.com>
Tue, 19 Jul 2016 04:52:05 +0000 (13:52 +0900)
committerkmook <kmook.choi@samsung.com>
Tue, 19 Jul 2016 11:08:33 +0000 (20:08 +0900)
Change-Id: Iedc1b0cddecd1873109570a77e04f22e6d5daa57
Signed-off-by: kmook <kmook.choi@samsung.com>
12 files changed:
common/common.h
daemon/service_mgr_impl.cpp
daemon/service_mgr_impl.h
daemon/service_provider/app_comm_service_provider.cpp
daemon/service_provider/app_comm_service_provider.h
daemon/service_provider/remote_app_control_service_provider.cpp
daemon/service_provider/remote_app_control_service_provider.h
daemon/service_provider_base.h
daemon/util.cpp
daemon/util.h
lib/conv_lib.cpp
lib/include/d2d_conv_internal.h

index 5deb901..7e77fd5 100644 (file)
@@ -78,8 +78,8 @@
 #define CONV_RESOURCE_TYPE_TIZEN_D2D_SERVICE   "x.org.tizen.d2d-service"
 
 #define CONV_URI_SMARTVIEW_APP_COMMUNICATION "/tizen/app-communication"
-#define CONV_URI_SMARTVIEW_REMOTE_APP_CONTROL "/tizen/remote-app-control"
-#define CONV_URI_SMARTVIEW_TIZEN_D2D_SERVICE "/tizen/d2d-service"
+#define CONV_URI_REMOTE_APP_CONTROL "/tizen/remote-app-control"
+#define CONV_URI_TIZEN_D2D_SERVICE "/tizen/d2d-service"
 
 #define CONV_PRIVILEGE_INTERNET                        "internet"
 #define CONV_PRIVILEGE_BLUETOOTH               "bluetooth"
@@ -153,4 +153,7 @@ enum request_type {
 #define CONV_JSON_APP_CONTROL                  "app_control"
 #define CONV_JSON_REPLY                                        "reply"
 
+#define CONV_SETTING_VALUE_SERVICE_APP_TO_APP_COMMUNICATION 0x0001
+#define CONV_SETTING_VALUE_SERVICE_REMOTE_APP_CONTROL 0x0002
+
 #endif
index 0e415d4..0a82932 100755 (executable)
@@ -23,7 +23,7 @@
 #include <iotcon.h>
 
 static conv::service_manager_impl *_instance;
-static iotcon_resource_h iotcon_resource;
+static iotcon_resource_h iotcon_resource = NULL;
 
 using namespace std;
 
@@ -35,20 +35,55 @@ conv::service_manager_impl::~service_manager_impl()
 {
 }
 
+int conv::service_manager_impl::handle_vconf_update(keynode_t *node)
+{
+       activation_state = vconf_keynode_get_int(node);
+
+       if ( activation_state == 1 ) {
+               register_discovery_info();
+       } else {
+               unregister_discovery_info();
+       }
+
+       return CONV_ERROR_NONE;
+}
+
+static void vconf_update_cb(keynode_t *node, void* user_data)
+{
+       conv::service_manager_impl* instance = static_cast<conv::service_manager_impl*>(user_data);
+       IF_FAIL_VOID_TAG(instance, _E, "static_cast failed");
+
+       instance->handle_vconf_update(node);
+}
+
 int conv::service_manager_impl::init()
 {
        register_provider(new(std::nothrow) conv::app_comm_service_provider());
        register_provider(new(std::nothrow) conv::remote_app_control_service_provider());
 
-       register_discovery_info();
+       int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE, &activation_state);
+
+       if ( error < 0 ) {
+               _E("vconf error (%d)", error);
+               // temporary code
+               activation_state = 1;
+       }
+
+       if ( activation_state == 1 ) {
+               register_discovery_info();
+       } else {
+               unregister_discovery_info();
+       }
+
+       error = vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE, vconf_update_cb, this);
+//     IF_FAIL_RETURN_TAG(error >= 0, CONV_ERROR_INVALID_OPERATION, _E, "vconf error (%d)", error);
+
        return CONV_ERROR_NONE;
 }
 
 int conv::service_manager_impl::release()
 {
-       int error = iotcon_resource_destroy(iotcon_resource);
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource destroy failed");
-       iotcon_resource = NULL;
+       unregister_discovery_info();
 
        for (service_provider_list_t::iterator it = provider_list.begin(); it != provider_list.end(); ++it) {
                (*it)->release();
@@ -79,6 +114,8 @@ int conv::service_manager_impl::handle_request(request* request_obj)
                if ( (*it)->get_type().compare(type) == 0 )
                {
                        _D("found service provider");
+                       error = (*it)->check_activation_state();
+                       IF_FAIL_CATCH_TAG(error == CONV_ERROR_NONE, _E, "service provider is not activated");
 
                        error = (*it)->load_service_info(request_obj);
                        IF_FAIL_CATCH_TAG(error == CONV_ERROR_NONE, _E, "%d, service_info load error", error);
@@ -164,10 +201,14 @@ int conv::service_manager_impl::register_provider(conv::service_provider_base *p
                return CONV_ERROR_INVALID_PARAMETER;
        }
 
-       if (provider->init() != CONV_ERROR_NONE) {
-               _E("Provider initialization failed");
-               delete provider;
-               return CONV_ERROR_INVALID_OPERATION;
+       if (provider->check_activation_state() == CONV_ERROR_NONE) {
+               if (provider->init() != CONV_ERROR_NONE) {
+                       _E("Provider initialization failed");
+                       delete provider;
+                       return CONV_ERROR_INVALID_OPERATION;
+               }
+       } else {
+               _D("provider is not activated. init pending");
        }
 
        provider_list.push_back(provider);
@@ -339,6 +380,8 @@ static void iotcon_request_cb(iotcon_resource_h resource, iotcon_request_h reque
 
 int conv::service_manager_impl::register_discovery_info()
 {
+       IF_FAIL_RETURN_TAG(iotcon_resource == NULL, CONV_ERROR_INVALID_PARAMETER, _E, "resource for discovery is already registered");
+
        // register resource
        int properties;
        iotcon_resource_interfaces_h resource_ifaces = NULL;
@@ -358,7 +401,7 @@ int conv::service_manager_impl::register_discovery_info()
 
        iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
 
-       error = iotcon_resource_create(CONV_URI_SMARTVIEW_TIZEN_D2D_SERVICE, resource_types, resource_ifaces, properties, iotcon_request_cb, this, &iotcon_resource);
+       error = iotcon_resource_create(CONV_URI_TIZEN_D2D_SERVICE, resource_types, resource_ifaces, properties, iotcon_request_cb, this, &iotcon_resource);
        IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource creation failed");
 
        _D("device info registered as resource");
@@ -368,3 +411,16 @@ int conv::service_manager_impl::register_discovery_info()
        return CONV_ERROR_NONE;
 }
 
+int conv::service_manager_impl::unregister_discovery_info()
+{
+       IF_FAIL_RETURN_TAG(iotcon_resource != NULL, CONV_ERROR_INVALID_PARAMETER, _E, "resource for discovery is already unregistered");
+
+       int error = iotcon_resource_destroy(iotcon_resource);
+       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource destroy failed");
+       iotcon_resource = NULL;
+
+
+       _D("device info unregistered");
+       return CONV_ERROR_NONE;
+}
+
index 5c64451..3b7602b 100644 (file)
@@ -20,6 +20,7 @@
 #include <iotcon.h>
 #include <glib.h>
 #include <vector>
+#include <vconf.h>
 #include "manager_iface.h"
 #include "request.h"
 #include "service_provider_base.h"
@@ -35,12 +36,16 @@ namespace conv {
                        int handle_request(request* request_obj);
 
                        int get_service_info_for_discovery(json* service_json);
+                       int handle_vconf_update(keynode_t *node);
 
                private:
+                       int activation_state;
+
                        typedef std::list<service_provider_base*> service_provider_list_t;
 
                        int register_provider(service_provider_base *provider_base);
                        int register_discovery_info();
+                       int unregister_discovery_info();
                        service_provider_list_t provider_list;
        };
 
index 31a4078..dccfaae 100755 (executable)
  * limitations under the License.
  */
 
+#include <net_connection.h>
 #include "app_comm_service_provider.h"
 #include "../client_mgr_impl.h"
-#include <net_connection.h>
+#include "../util.h"
 
 using namespace std;
 
+static void vconf_update_cb(keynode_t *node, void* user_data)
+{
+       conv::app_comm_service_provider* instance = static_cast<conv::app_comm_service_provider*>(user_data);
+       IF_FAIL_VOID_TAG(instance, _E, "static_cast failed");
+
+       instance->handle_vconf_update(node);
+}
+
 conv::app_comm_service_provider::app_comm_service_provider()
 {
        _type = CONV_SERVICE_TYPE_SMARTVIEW_APP_COMMUNICATION;
        _resource_type = CONV_RESOURCE_TYPE_SMARTVIEW_APP_COMMUNICATION;
        _uri = CONV_URI_SMARTVIEW_APP_COMMUNICATION;
+       if (conv::util::is_service_activated(CONV_SETTING_VALUE_SERVICE_APP_TO_APP_COMMUNICATION))
+               _activation_state = 1;
+       else
+               _activation_state = 0;
+
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
+}
+
+int conv::app_comm_service_provider::handle_vconf_update(keynode_t *node)
+{
+       int current_state = vconf_keynode_get_int(node);
+
+       if ((CONV_SETTING_VALUE_SERVICE_APP_TO_APP_COMMUNICATION & current_state) > 0) {
+               _activation_state = 1;
+               init();
+       } else {
+               _activation_state = 0;
+               release();
+       }
+
+       return CONV_ERROR_NONE;
 }
 
 conv::app_comm_service_provider::~app_comm_service_provider()
@@ -39,11 +69,14 @@ int conv::app_comm_service_provider::init()
 
 int conv::app_comm_service_provider::release()
 {
+       _D("app_comm_service_provider release done");
        return CONV_ERROR_NONE;
 }
 
 int conv::app_comm_service_provider::load_service_info(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        string client;
        conv::client* client_obj = NULL;
        int is_local = 0;
@@ -123,6 +156,8 @@ int conv::app_comm_service_provider::load_service_info(request* request_obj)
 
 int conv::app_comm_service_provider::start_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/start requested");
        app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
 
@@ -210,6 +245,8 @@ int conv::app_comm_service_provider::start_request(request* request_obj)
 
 int conv::app_comm_service_provider::stop_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/stop requested");
        app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
 
@@ -250,6 +287,8 @@ int conv::app_comm_service_provider::stop_request(request* request_obj)
 
 int conv::app_comm_service_provider::get_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/get requested");
        app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
 
@@ -342,6 +381,8 @@ int conv::app_comm_service_provider::send_response(json payload, request* reques
 
 int conv::app_comm_service_provider::set_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/set requested");
        app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
 
@@ -387,6 +428,8 @@ int conv::app_comm_service_provider::set_request(request* request_obj)
 
 int conv::app_comm_service_provider::register_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/recv requested");
        app_comm_service_info *svc_info = reinterpret_cast<app_comm_service_info*>(request_obj->service_info);
 
@@ -415,6 +458,8 @@ int conv::app_comm_service_provider::register_request(request* request_obj)
 
 int conv::app_comm_service_provider::get_service_info_for_discovery(json* json_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
+
        json_obj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_APP_TO_APP_COMMUNICATION);
 
        // set data for service handle
index ec204a7..02fb33b 100644 (file)
@@ -20,6 +20,7 @@
 #include <iotcon.h>
 #include <glib.h>
 #include <vector>
+#include <vconf.h>
 #include "../service_provider_base.h"
 #include "app_comm_service_info.h"
 
@@ -40,6 +41,7 @@ namespace conv {
                        int register_request(request* request_obj);
                        int load_service_info(request* request_obj);
                        int get_service_info_for_discovery(json* json_obj);
+                       int handle_vconf_update(keynode_t *node);
 
                private:
                        int send_response(json payload, request* request_obj);
index c57bdee..689ea4e 100755 (executable)
@@ -19,6 +19,7 @@
 #include <app_control_internal.h>
 #include "remote_app_control_service_provider.h"
 #include "../client_mgr_impl.h"
+#include "../util.h"
 
 using namespace std;
 
@@ -46,11 +47,26 @@ static int get_req_id()
 static std::map<int, app_control_cb_info_s> app_control_cb_map;
 static std::map<int, response_cb_info_s> response_cb_map;
 
+static void vconf_update_cb(keynode_t *node, void* user_data)
+{
+       conv::remote_app_control_service_provider* instance = static_cast<conv::remote_app_control_service_provider*>(user_data);
+       IF_FAIL_VOID_TAG(instance, _E, "static_cast failed");
+
+       instance->handle_vconf_update(node);
+}
+
 conv::remote_app_control_service_provider::remote_app_control_service_provider()
 {
        _type = CONV_SERVICE_TYPE_REMOTE_APP_CONTROL;
        _resource_type = CONV_RESOURCE_TYPE_REMOTE_APP_CONTROL;
-       _uri = CONV_URI_SMARTVIEW_REMOTE_APP_CONTROL;
+       _uri = CONV_URI_REMOTE_APP_CONTROL;
+       iotcon_resource = NULL;
+       if (conv::util::is_service_activated(CONV_SETTING_VALUE_SERVICE_REMOTE_APP_CONTROL))
+               _activation_state = 1;
+       else
+               _activation_state = 0;
+
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, vconf_update_cb, this);
 }
 
 conv::remote_app_control_service_provider::~remote_app_control_service_provider()
@@ -59,6 +75,21 @@ conv::remote_app_control_service_provider::~remote_app_control_service_provider(
        response_cb_map.clear();
 }
 
+int conv::remote_app_control_service_provider::handle_vconf_update(keynode_t *node)
+{
+       int current_state = vconf_keynode_get_int(node);
+
+       if ((CONV_SETTING_VALUE_SERVICE_REMOTE_APP_CONTROL & current_state) > 0) {
+               _activation_state = 1;
+               init();
+       } else {
+               _activation_state = 0;
+               release();
+       }
+
+       return CONV_ERROR_NONE;
+}
+
 static int _send_response(iotcon_request_h request, iotcon_representation_h repr,
                iotcon_response_result_e result)
 {
@@ -261,49 +292,59 @@ void conv::remote_app_control_service_provider::iotcon_request_cb(iotcon_resourc
 
 int conv::remote_app_control_service_provider::init()
 {
-       // register resource
-       int properties;
-       iotcon_resource_interfaces_h resource_ifaces = NULL;
-       iotcon_resource_types_h resource_types = NULL;
-       int error;
+       if (iotcon_resource == NULL) {
+               // register resource
+               int properties;
+               iotcon_resource_interfaces_h resource_ifaces = NULL;
+               iotcon_resource_types_h resource_types = NULL;
+               int error;
 
-       properties = IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE;
+               properties = IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE;
 
-       error = iotcon_resource_types_create(&resource_types);
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "rt creation failed");
+               error = iotcon_resource_types_create(&resource_types);
+               IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "rt creation failed");
 
-       iotcon_resource_types_add(resource_types, _resource_type.c_str());
+               iotcon_resource_types_add(resource_types, _resource_type.c_str());
 
-       error = iotcon_resource_interfaces_create(&resource_ifaces);
+               error = iotcon_resource_interfaces_create(&resource_ifaces);
 
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "ri creation failed");
+               IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "ri creation failed");
 
-       iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
+               iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
 
 
-       error = iotcon_resource_create(CONV_URI_SMARTVIEW_REMOTE_APP_CONTROL, resource_types, resource_ifaces, properties, iotcon_request_cb, NULL, &iotcon_resource);
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource creation failed");
+               error = iotcon_resource_create(CONV_URI_REMOTE_APP_CONTROL, resource_types, resource_ifaces, properties, iotcon_request_cb, NULL, &iotcon_resource);
+               IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource creation failed");
 
-       iotcon_resource_types_destroy(resource_types);
-       iotcon_resource_interfaces_destroy(resource_ifaces);
+               iotcon_resource_types_destroy(resource_types);
+               iotcon_resource_interfaces_destroy(resource_ifaces);
 
-       _D("remote_app_control_service_provider init done");
+               _D("remote_app_control_service_provider init done");
+       } else {
+               _D("remote_app_control_service_provider is already initiated");
+       }
 
        return CONV_ERROR_NONE;
 }
 
 int conv::remote_app_control_service_provider::release()
 {
-       // unregister resource
-       int error = iotcon_resource_destroy(iotcon_resource);
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource destroy failed");
-       iotcon_resource = NULL;
+       if (iotcon_resource == NULL) {
+               _D("remote_app_control_service_provider is already released");
+       } else {
+               // unregister resource
+               int error = iotcon_resource_destroy(iotcon_resource);
+               IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource destroy failed");
+               iotcon_resource = NULL;
+       }
 
        return CONV_ERROR_NONE;
 }
 
 int conv::remote_app_control_service_provider::start_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/start requested");
        int error;
 
@@ -346,6 +387,8 @@ int conv::remote_app_control_service_provider::start_request(request* request_ob
 
 int conv::remote_app_control_service_provider::stop_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/stop requested");
 
        remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
@@ -364,6 +407,8 @@ int conv::remote_app_control_service_provider::stop_request(request* request_obj
 
 int conv::remote_app_control_service_provider::get_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        return CONV_ERROR_NONE;
 }
 
@@ -429,6 +474,8 @@ static void on_response(iotcon_remote_resource_h resource, iotcon_error_e err,
 
 int conv::remote_app_control_service_provider::set_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
        int error;
 
@@ -476,6 +523,8 @@ int conv::remote_app_control_service_provider::set_request(request* request_obj)
 
 int conv::remote_app_control_service_provider::register_request(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        _D("communcation/recv requested");
        remote_app_control_service_info *svc_info = reinterpret_cast<remote_app_control_service_info*>(request_obj->service_info);
 
@@ -506,6 +555,8 @@ int conv::remote_app_control_service_provider::register_request(request* request
 
 int conv::remote_app_control_service_provider::load_service_info(request* request_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_INVALID_OPERATION, _E, "service provider is not activated");
+
        string client;
        conv::client* client_obj = NULL;
 
@@ -554,7 +605,7 @@ int conv::remote_app_control_service_provider::load_service_info(request* reques
                svc_info->device_address = device_address;
 
                svc_info->iotcon_info_obj.address = device_address;
-               svc_info->iotcon_info_obj.uri = CONV_URI_SMARTVIEW_REMOTE_APP_CONTROL;
+               svc_info->iotcon_info_obj.uri = CONV_URI_REMOTE_APP_CONTROL;
                svc_info->iotcon_info_obj.resource_type = _resource_type;
 
                //save service info
@@ -569,6 +620,8 @@ int conv::remote_app_control_service_provider::load_service_info(request* reques
 
 int conv::remote_app_control_service_provider::get_service_info_for_discovery(json* json_obj)
 {
+       IF_FAIL_RETURN_TAG(_activation_state == 1, CONV_ERROR_NOT_SUPPORTED, _E, "service provider is not activated");
+
        json_obj->set(NULL, CONV_JSON_DISCOVERY_SERVICE_TYPE, CONV_SERVICE_REMOTE_APP_CONTROL);
 
        // set data for service handle
index 939e9e4..e726942 100644 (file)
@@ -20,6 +20,7 @@
 #include <iotcon.h>
 #include <glib.h>
 #include <vector>
+#include <vconf.h>
 #include "../service_provider_base.h"
 #include "remote_app_control_service_info.h"
 
@@ -39,6 +40,7 @@ namespace conv {
                        int register_request(request* request_obj);
                        int load_service_info(request* request_obj);
                        int get_service_info_for_discovery(json* json_obj);
+                       int handle_vconf_update(keynode_t *node);
 
                private:
                        iotcon_resource_h iotcon_resource;
index 10f1dcb..a4e8c60 100644 (file)
@@ -35,6 +35,13 @@ namespace conv {
                        virtual int register_request(request* request_obj) = 0;
                        virtual int load_service_info(request* request_obj) = 0;
                        virtual int get_service_info_for_discovery(json* json_obj) = 0;
+                       int check_activation_state() {
+                               if (_activation_state == 1) {
+                                       return CONV_ERROR_NONE;
+                               } else {
+                                       return CONV_ERROR_INVALID_OPERATION;
+                               }
+                       }
 
                        std::string get_type() {
                                return _type;
@@ -52,6 +59,7 @@ namespace conv {
                        std::string _type;
                        std::string _resource_type;
                        std::string _uri;
+                       int _activation_state;
        };      /* class service_provider_base */
 }
 
index 6215caf..a1436a9 100755 (executable)
@@ -161,3 +161,20 @@ std::string conv::util::get_device_id()
 
        return g_device_id;
 }
+
+bool conv::util::is_service_activated(int service_value)
+{
+       int current_state;
+       int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, &current_state);
+
+       if (error != 0) {
+               _D("vconf_get_int failed %d", error);
+               return false;
+       }
+
+       if ((service_value & current_state) > 0) {
+               return true;
+       } else {
+               return false;
+       }
+}
index 910aece..44ee9ea 100644 (file)
@@ -28,6 +28,7 @@ namespace conv {
                std::string get_device_name();
                std::string get_p2p_mac_address();
                std::string get_device_id();
+               bool is_service_activated(int service_value);
 
                typedef void (*timer_function)(void *data);
                void* misc_start_timer(timer_function function, unsigned int interval, void *data);
index 2797bd4..f88f0aa 100755 (executable)
@@ -22,6 +22,7 @@
 #include <map>
 #include <string>
 #include <cstring>
+#include <vconf.h>
 
 #include "common.h"
 #include "d2d_conv_service.h"
@@ -236,3 +237,34 @@ EXTAPI int conv_device_foreach_service(conv_device_h handle, conv_service_foreac
        //LCOV_EXCL_STOP
 }
 
+EXTAPI int conv_internal_set_activation_state(int activation_state)
+{
+       int error = vconf_set_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE, activation_state);
+       IF_FAIL_RETURN_TAG(error >= 0, CONV_ERROR_INVALID_OPERATION, _E, "vconf error (%d)", error);
+
+       return CONV_ERROR_NONE;
+}
+
+EXTAPI int conv_internal_get_activation_state(int* activation_state)
+{
+       int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE, activation_state);
+       IF_FAIL_RETURN_TAG(error >= 0, CONV_ERROR_INVALID_OPERATION, _E, "vconf error (%d)", error);
+
+       return CONV_ERROR_NONE;
+}
+
+EXTAPI int conv_internal_set_service_activation_state(int activation_state)
+{
+       int error = vconf_set_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, activation_state);
+       IF_FAIL_RETURN_TAG(error >= 0, CONV_ERROR_INVALID_OPERATION, _E, "vconf error (%d)", error);
+
+       return CONV_ERROR_NONE;
+}
+
+EXTAPI int conv_internal_get_service_activation_state(int* activation_state)
+{
+       int error = vconf_get_int(VCONFKEY_SETAPPL_D2D_CONVERGENCE_SERVICE, activation_state);
+       IF_FAIL_RETURN_TAG(error >= 0, CONV_ERROR_INVALID_OPERATION, _E, "vconf error (%d)", error);
+
+       return CONV_ERROR_NONE;
+}
index af36059..327bbda 100755 (executable)
@@ -32,6 +32,18 @@ extern "C" {
  */
 
 /**
+ * @brief      The internal value to set app-to-app communication service
+ * @since_tizen 3.0
+ */
+#define CONV_INTERNAL_SERVICE_APP_TO_APP_COMMUNICATION 0x0001
+
+/**
+ * @brief      The internal value to set remote app-control service
+ * @since_tizen 3.0
+ */
+#define CONV_INTERNAL_SERVICE_REMOTE_APP_CONTROL 0x0002
+
+/**
  * @brief              Exports json string from channel.
  * @since_tizen 3.0
  * @remarks            The @a value must be released using free().
@@ -67,6 +79,70 @@ int conv_channel_internal_export_to_string(conv_channel_h handle, char** value);
  */
 int conv_payload_internal_export_to_string(conv_payload_h handle, char** value);
 
+/**
+ * @brief              Set D2D convergence activation state
+ * @since_tizen 3.0
+ *
+ * @param[in]  activation_state                The activation state to set
+ *
+ * @return             0 on success, otherwise a negative error value
+ * @retval             #CONV_ERROR_NONE                                        Successful
+ * @retval             #CONV_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval             #CONV_ERROR_NOT_SUPPORTED               Not supported
+ * @retval             #CONV_ERROR_NO_DATA                             No Data
+ * @retval             #CONV_ERROR_OUT_OF_MEMORY                       Out of memory
+ *
+ */
+int conv_internal_set_activation_state(int activation_state);
+
+/**
+ * @brief              Get D2D convergence activation state
+ * @since_tizen 3.0
+ *
+ * @param[out] activation_state                The current activation state
+ *
+ * @return             0 on success, otherwise a negative error value
+ * @retval             #CONV_ERROR_NONE                                        Successful
+ * @retval             #CONV_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval             #CONV_ERROR_NOT_SUPPORTED               Not supported
+ * @retval             #CONV_ERROR_NO_DATA                             No Data
+ * @retval             #CONV_ERROR_OUT_OF_MEMORY                       Out of memory
+ *
+ */
+int conv_internal_get_activation_state(int* activation_state);
+
+/**
+ * @brief              Set D2D convergence activation state of services
+ * @since_tizen 3.0
+ *
+ * @param[in]  activation_state                The activation state to set
+ *
+ * @return             0 on success, otherwise a negative error value
+ * @retval             #CONV_ERROR_NONE                                        Successful
+ * @retval             #CONV_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval             #CONV_ERROR_NOT_SUPPORTED               Not supported
+ * @retval             #CONV_ERROR_NO_DATA                             No Data
+ * @retval             #CONV_ERROR_OUT_OF_MEMORY                       Out of memory
+ *
+ */
+int conv_internal_set_service_activation_state(int activation_state);
+
+/**
+ * @brief              Get D2D convergence activation state of services
+ * @since_tizen 3.0
+ *
+ * @param[in]  activation_state                The activation state to set
+ *
+ * @return             0 on success, otherwise a negative error value
+ * @retval             #CONV_ERROR_NONE                                        Successful
+ * @retval             #CONV_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @retval             #CONV_ERROR_NOT_SUPPORTED               Not supported
+ * @retval             #CONV_ERROR_NO_DATA                             No Data
+ * @retval             #CONV_ERROR_OUT_OF_MEMORY                       Out of memory
+ *
+ */
+int conv_internal_get_service_activation_state(int* activation_state);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */