changed method to get remote service in app-comm-service 03/80203/1
authorkmook <kmook.choi@samsung.com>
Fri, 15 Jul 2016 07:45:55 +0000 (16:45 +0900)
committerkmook <kmook.choi@samsung.com>
Fri, 15 Jul 2016 07:45:55 +0000 (16:45 +0900)
Change-Id: I691ff8accc3f521f71102bb1913a5b58be812693
Signed-off-by: kmook <kmook.choi@samsung.com>
daemon/service_provider/app_comm_service_info.h
daemon/service_provider/app_comm_service_provider.cpp

index 56c56bb..57a1b68 100755 (executable)
@@ -222,14 +222,23 @@ namespace conv {
        typedef vector<application_instance*> application_instance_list_t;
 
        // service information to handle app-to-app service with specific device 'id'
-       class app_comm_service_info : public service_info_base {
+       class app_comm_service_info : public service_info_base, public Result_Base {
                public:
-                       ~app_comm_service_info()
+                       void onSuccess(Service service)
                        {
-                               if (service_obj != NULL) {
-                                       delete service_obj;
-                               }
+                               _D("getByUri : service name : %s", service.getName().c_str() ? service.getName().c_str() : "name is NULL");
+                               service_obj = service;
+                               get_service_result = true;
+                       }
+
+                       void onError(Error)
+                       {
+                               _D("getByUri Error");
+                               get_service_result = false;
+                       }
 
+                       ~app_comm_service_info()
+                       {
                                if (registered_request != NULL) {
                                        delete registered_request;
                                }
@@ -241,8 +250,9 @@ namespace conv {
                                }
                        }
                        std::string id;
-                       Service* service_obj;
+                       Service service_obj;
                        bool is_local;
+                       bool get_service_result;
                        conv::request* registered_request;
 
                        application_instance_list_t application_instance_list;
index 7412454..31a4078 100755 (executable)
@@ -109,8 +109,8 @@ int conv::app_comm_service_provider::load_service_info(request* request_obj)
                        ASSERT_ALLOC(svc_info);
 
                        _D("uri : %s", uri.c_str());
-                       svc_info->service_obj = new(std::nothrow) Service(id, version, name, type, uri);
-                       ASSERT_ALLOC(svc_info->service_obj);
+                       Service::getByURI(uri, 2000, svc_info);
+                       IF_FAIL_RETURN_TAG(svc_info->get_service_result == true, CONV_ERROR_INVALID_OPERATION, _E, "getByURI failed");
                        svc_info->is_local = false;
                        client_obj->add_service_info(_type, id, (service_info_base*)svc_info);
 
@@ -183,7 +183,7 @@ int conv::app_comm_service_provider::start_request(request* request_obj)
                svc_info->application_instance_list.push_back(app_info);
        } else {
                _D("COMMUNCATION_START : uri : %s, channel_id : %s", uri.c_str(), channel_id.c_str());
-               Application* application = new(std::nothrow) Application(svc_info->service_obj, uri, channel_id);
+               Application* application = new(std::nothrow) Application(&(svc_info->service_obj), uri, channel_id);
                ASSERT_ALLOC(application);
 
                // add listeners