client->g_doneCB = true;
}
-static void _unpair_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool has_error)
-{
- ma_subowner_s *client = (ma_subowner_s *)ctx;
-
- if (!has_error) {
- MA_LOGD("unpair SUCCEEDED");
- } else {
- MA_LOGD( "unpair FAILED ");
- _print_result_list((const OCProvisionResult_t*) arr, nOfRes);
- }
- client->g_doneCB = true;
-}
-
static gpointer _provisioning_acl_func(gpointer data)
{
OCStackResult ret = OC_STACK_OK;
return NULL;
}
-static gpointer _unpair_func(gpointer data)
-{
- OCStackResult ret = OC_STACK_OK;
- ma_req_cb_s *con = (ma_req_cb_s *)data;
-
- OicUuid_t *uuid = NULL;
-
- if (!con->target_to_revoke) {
- MA_LOGE("Some parameters are wrong");
- MA_LOGE("%s", con->target_to_revoke );
- goto PVACL_ERROR;
- }
-
- uuid = _convert_uuid(con->target_to_revoke);
-
- g_client->g_doneCB = false;
- MA_LOGI(" unpair device..");
-
- ret = OCRemoveDeviceWithUuid((void*) g_client, CALLBACK_TIMEOUT_5S, uuid, _unpair_cb );
- if (OC_STACK_OK != ret) {
- MA_LOGD( "OCRemoveDevice API error: %d (%s)", ret, _error_to_string(ret));
- goto PVACL_ERROR;
- }
-
- ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
- if (ret) {
- MA_LOGE( "OCRemoveDevice Faild = %d", errno);
- goto PVACL_ERROR;
- }
- /* display the pairwise-provisioned result */
- MA_LOGI(" Provision pairwise Successfully");
-
-PVACL_ERROR:
- /* Notify ACL result */
- net_ma_emit_unpair_done(ma_dbus_get_object(), (int)ret);
- if (uuid)
- g_free(uuid);
- _request_cleanup(con);
- g_thread_exit(GINT_TO_POINTER (1));
- return NULL;
-}
-
-static int _provisioning_unpair(ma_service *service, gchar *target)
-{
- ma_req_cb_s *con = NULL;
- con = g_malloc0(sizeof(ma_req_cb_s));
- if (NULL == con) {
- MA_LOGE( "g_malloc0() Fail=%d", errno);
- /* Unset d2ds status 'pending' */
- g_atomic_int_set(&service->pending, 0);
- return MA_ERROR_OUT_OF_MEMORY;
- }
-
- con->userdata = service;
- con->cid = MA_UNPAIR;
-
- con->target_to_revoke = g_strdup(target);
-
- con->thread = g_thread_try_new("unpair_device", _unpair_func, con, NULL);
- if (!con->thread) {
- MA_LOGE("Failed to create thread");
- _request_cleanup(con);
- return MA_ERROR_OUT_OF_MEMORY;
- }
- g_thread_unref(con->thread);
-#ifdef TIMEOUT_USED
- con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _ma_timeout_cb, con);
-#endif
- return MA_ERROR_NONE;
-}
static int _provisioning_pairwise_link(ma_service *service, gchar *target_1, gchar *subject_1,
gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1,
client->g_doneCB = true;
}
+static void _unlink_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool has_error)
+{
+ ma_subowner_s *client = (ma_subowner_s *)ctx;
+
+ if (!has_error) {
+ MA_LOGD("unlink SUCCEEDED");
+ } else {
+ MA_LOGD( "unlink FAILED ");
+ _print_result_list((const OCProvisionResult_t*) arr, nOfRes);
+ }
+ client->g_doneCB = true;
+}
+
+static gpointer _unlink_provisioning_func(gpointer data)
+{
+ OCStackResult ret = OC_STACK_OK;
+ ma_req_cb_s *con = (ma_req_cb_s *)data;
+
+ OicUuid_t *uuid = NULL;
+ OCProvisionDev_t *dev1 = NULL;
+ OCProvisionDev_t *dev2 = NULL;
+
+ if (!con->uuid_dev1 ) {
+ MA_LOGE("dev1 is NULL");
+ goto PVPWS_ERROR;
+ }
+ if (!con->uuid_dev2) {
+ MA_LOGE("dev2 is NULL");
+ goto PVPWS_ERROR;
+ }
+
+ uuid = _convert_uuid(con->uuid_dev1);
+ dev1 = _get_dev_by_uuid(g_client->g_mowned_list, uuid);
+ if (!dev1) {
+ MA_LOGE("We can't find in MOWNED dev list");
+ goto PVPWS_ERROR;
+ }
+ g_free(uuid);
+
+ uuid = _convert_uuid(con->uuid_dev2);
+ dev2 = _get_dev_by_uuid(g_client->g_mowned_list, uuid);
+ if (!dev2) {
+ MA_LOGE("We can't find in MOWNED dev list");
+ goto PVPWS_ERROR;
+ }
+ g_free(uuid);
+
+ /* To do ACL provisioning only one */
+ dev1->next = NULL;
+
+ /* To do ACL provisioning only one */
+ dev2->next = NULL;
+
+ g_client->g_doneCB = false;
+
+ MA_LOGI("Provisioning Selected Pairwise Devices..");
+ ret = OCUnlinkDevices((void*) g_client,dev1,dev2,_unlink_cb );
+
+ if (OC_STACK_OK != ret) {
+ MA_LOGD( "OCUnlinkDevices API error: %d (%s)", ret, _error_to_string(ret));
+ goto PVPWS_ERROR;
+ }
+
+ ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
+ if (ret) {
+ MA_LOGE( "OCUnlinkDevices Faild = %d", errno);
+ goto PVPWS_ERROR;
+ }
+
+ /* display the pairwise-provisioned result */
+ MA_LOGI("Unlink Devices");
+
+ return 0;
+
+PVPWS_ERROR:
+ /* Notify ACL result */
+ net_ma_emit_unpair_done(ma_dbus_get_object(), (int)ret);
+
+ if (uuid)
+ g_free(uuid);
+ _request_cleanup(con);
+
+ g_thread_exit(GINT_TO_POINTER (1));
+
+ return NULL;
+}
+
static gpointer _cred_provisioning_func(gpointer data)
{
OCStackResult ret = OC_STACK_OK;
return MA_ERROR_NONE;
}
+static int _provisioning_unlink(ma_service *service,
+ gchar *uuid_dev1, gchar *uuid_dev2)
+{
+ ma_req_cb_s *con = NULL;
+ con = g_malloc0(sizeof(ma_req_cb_s));
+ if (!con) {
+ MA_LOGE( "g_malloc0() Fail=%d", errno);
+ /* Unset d2ds status 'pending' */
+ g_atomic_int_set(&service->pending, 0);
+ return MA_ERROR_OUT_OF_MEMORY;
+ }
+
+ con->userdata = service;
+ con->cid = MA_UNPAIR;
+
+ if (!uuid_dev1 ||!uuid_dev2) {
+ MA_LOGE( "Invaild Prameters");
+ _request_cleanup(con);
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ con->uuid_dev1 = g_strdup(uuid_dev1);
+ con->uuid_dev2 = g_strdup(uuid_dev2);
+
+ con->thread = g_thread_try_new("prov_unlink", _unlink_provisioning_func,
+ con, NULL);
+ if (!con->thread) {
+ MA_LOGE("Failed to create thread");
+ _request_cleanup(con);
+ return MA_ERROR_OUT_OF_MEMORY;
+ }
+ g_thread_unref(con->thread);
+#ifdef TIMEOUT_USED
+ con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _ma_timeout_cb,
+ con);
+#endif
+ return MA_ERROR_NONE;
+}
+
int ma_request_enable(ma_service *service)
{
int ret = MA_ERROR_NONE;
}
-int ma_request_unpair(ma_service *service, gchar *uuid_dev)
+int ma_request_unpair(ma_service *service, gchar *uuid_dev1,
+ gchar *uuid_dev2)
{
int ret = MA_ERROR_NONE;
ma_check_null_ret_error("service", service, FALSE);
- MA_LOGD("[IPC] Unpair device");
+ MA_LOGD("[IPC] Unlink devices");
/* If we are working now? */
if (g_atomic_int_get(&service->pending))
return MA_ERROR_IN_PROGRESS;
- if (!uuid_dev) {
- MA_LOGE("uuid_dev = %s", uuid_dev);
-
+ if (!uuid_dev1 || !uuid_dev2) {
+ MA_LOGE("uuid_dev1 = %s", uuid_dev1);
+ MA_LOGE("uuid_dev2 = %s", uuid_dev2);
return MA_ERROR_INVALID_PARAMETER;
}
/* Set d2ds status 'pending' */
g_atomic_int_set(&service->pending, 1);
- ret = _provisioning_unpair(service, uuid_dev);
+ ret = _provisioning_unlink(service, uuid_dev1, uuid_dev2);
return ret;
-
}
-
int ma_request_remove_mo(ma_service *service, gchar* uuid_str);
int ma_request_prov_acl(ma_service *service, gchar *target, gchar *subject,
gchar *rsrc_uri, gchar *rsrc_type, gchar *rsrc_interface, int permission);
-int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2);
-int ma_request_unpair(ma_service *service, gchar *uuid_dev);
+int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1,
+ gchar *uuid_dev2);
+int ma_request_unpair(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2);
int ma_request_get_ownerid(ma_service *service, gchar **uuid_str);
int ma_request_disable(ma_service *service);
int ma_request_pairwise(ma_service *service, gchar *target_1, gchar *subject_1,
- gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1,
- gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2);
+ gchar *rsrc_uri_1, gchar *rsrc_type_1,
+ gchar *rsrc_interface_1, int permission_1,
+ gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2,
+ gchar *rsrc_type_2, gchar *rsrc_interface_2,
+ int permission_2);
#ifdef __cplusplus
}