mot-agent: Fixed the issue of multiple MOT at once
authorsaerome.kim <saerome.kim@samsung.com>
Tue, 16 Jan 2018 01:38:01 +0000 (10:38 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:40 +0000 (19:38 +0900)
src/companion-manager/include/comp_mot_agent.h
src/mot-agent/ma-subowner.c

index 53c498025bb25d896e0c001dc2d97cd053c7f193..8288ba5fc19b1e5c54508b6f13f5da47adada04a 100755 (executable)
  #ifndef __COMP_MOT_AGENT_H__
  #define __COMP_MOT_AGENT_H__
 
- int agent_dbus_start();
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int agent_dbus_start();
 int agent_dbus_stop();
 
 int agent_enable();
@@ -36,4 +40,8 @@ int agent_remove_mo_at_device(char* uuid_str);
 int agent_remove_cred_at_local(char* uuid_str);
 int agent_remove_myowned_device(char* uuid_str);
 
- #endif /* __COMP_MOT_AGENT_H__ */
\ No newline at end of file
+#ifdef __cplusplus
+}
+#endif
+
+ #endif /* __COMP_MOT_AGENT_H__ */
index ecfd201f6c4627f95c0443bd55bd2b9cdfe48c84..7934bbc6a829acca0de7bc55c810d59c97bdd718 100644 (file)
@@ -941,6 +941,7 @@ static gpointer _mot_func(gpointer data)
        ma_req_cb_s *con = (ma_req_cb_s *)data;
 
        OCProvisionDev_t *src_dev = NULL;
+       OCProvisionDev_t *clone_dev = NULL;
        OicUuid_t *uuid_target = NULL;
 
        if (!con->uuid_target_str) {
@@ -954,11 +955,15 @@ static gpointer _mot_func(gpointer data)
                MA_LOGE("We can't find in MOT dev list");
                goto MOT_ENDED;
        }
+       /* Copy subject device and related information */
+       clone_dev = PMCloneOCProvisionDev(src_dev);
+       /* To do ACL provisioning only one */
+       clone_dev->next = NULL;
 
        g_client->g_doneCB = false;
 
        OCProvisionDev_t* dev = NULL;
-       LL_FOREACH(src_dev, dev) {
+       LL_FOREACH(clone_dev, dev) {
                if(OIC_PRECONFIG_PIN == dev->doxm->oxmSel) {
                        /* Pre-Configured PIN initialization */
                        const char* testPreconfigPin = con->pin;/* Ex) "12341234" */
@@ -971,7 +976,7 @@ static gpointer _mot_func(gpointer data)
                }
        }
 
-       ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb);
+       ret = OCDoMultipleOwnershipTransfer(g_client, clone_dev, _mot_cb);
        if (OC_STACK_OK != ret )  {
                MA_LOGE( "OCDoMultipleOwnershipTransfer: ret = %d (%s)", ret, _error_to_string(ret));
                goto MOT_ENDED;
@@ -990,6 +995,8 @@ MOT_ENDED:
        net_ma_emit_mot_done(ma_dbus_get_object(), (int)ret);
        if (uuid_target)
                g_free(uuid_target);
+       if (clone_dev)
+               PMDeleteDeviceList(clone_dev);
        _request_cleanup(data);
        g_thread_exit(GINT_TO_POINTER (1));