Commit cf212ed4 authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko Committed by Randeep

[IOT-2912] cpp provisioning

cpp provisioning refactoing

Bug: https://jira.iotivity.org/browse/IOT-2912
Change-Id: Ic80a6a9df54d1f6930ea779ad0a95dcd5b843c1c
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent 142cfc81
......@@ -335,7 +335,8 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayNumListen
try
{
OCStackResult result = OCSecure::registerDisplayNumCallback(displayMutualVerifNumCB);
OC::DisplayNumContext *displayNumContext = new OC::DisplayNumContext(displayMutualVerifNumCB);
OCStackResult result = OCSecure::registerDisplayNumCallback(displayNumContext);
if (OC_STACK_OK != result)
{
ThrowOcException(result, "Failed to set Listner");
......@@ -420,7 +421,8 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setConfirmNumListen
try
{
OCStackResult result = OCSecure::registerUserConfirmCallback(confirmMutualVerifNumCB);
OC::UserConfirmNumContext* userConfirmNumContext = new OC::UserConfirmNumContext(confirmMutualVerifNumCB);
OCStackResult result = OCSecure::registerUserConfirmCallback(userConfirmNumContext);
if (OC_STACK_OK != result)
{
ThrowOcException(result, "Failed to set Listner");
......
......@@ -468,7 +468,7 @@ namespace OC
* @param displayNumCB Callback which is to be registered.
* @return OC_STACK_OK in case of success and other value otherwise.
*/
static OCStackResult registerDisplayNumCallback(DisplayNumCB displayNumCB);
static OCStackResult registerDisplayNumCallback(void *ctx);
/**
* API to De-register Callback for displaying verifNum in verification Just-Works
......@@ -482,7 +482,7 @@ namespace OC
*@param userConfirmCB Callback which is to be registered.
* @return OC_STACK_OK in case of success and other value otherwise.
*/
static OCStackResult registerUserConfirmCallback(UserConfirmNumCB userConfirmCB);
static OCStackResult registerUserConfirmCallback(void* ctx);
/**
* API to De-register Callback for getting user confirmation in verification Just-Works
......
......@@ -769,13 +769,15 @@ int main(void)
std::cout << "!!Error - registerInputPinCallback failed." << std::endl;
}
result = OCSecure::registerDisplayNumCallback(displayMutualVerifNumCB);
OC::DisplayNumContext *displayNumContext = new OC::DisplayNumContext(displayMutualVerifNumCB);
result = OCSecure::registerDisplayNumCallback(displayNumContext);
if (result != OC_STACK_OK)
{
std::cout<< "!!Error - setDisplayVerifNumCB failed."<<std::endl;
}
result = OCSecure::registerUserConfirmCallback(confirmMutualVerifNumCB);
OC::UserConfirmNumContext* userConfirmNumContext = new OC::UserConfirmNumContext(confirmMutualVerifNumCB);
result = OCSecure::registerUserConfirmCallback(userConfirmNumContext);
if (result != OC_STACK_OK)
{
std::cout<< "!!Error - setConfirmVerifNumCB failed."<<std::endl;
......
......@@ -837,11 +837,11 @@ namespace OC
return res;
}
OCStackResult OCSecure::registerDisplayNumCallback(DisplayNumCB displayNumCB)
OCStackResult OCSecure::registerDisplayNumCallback(void *ctx)
{
if(!displayNumCB)
if(!ctx)
{
oclog() << "Failed to register callback for display.";
oclog() << "Failed set context";
return OC_STACK_INVALID_CALLBACK;
}
......@@ -855,9 +855,8 @@ namespace OC
auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
if (cLock)
{
DisplayNumContext* context = new DisplayNumContext(displayNumCB);
std::lock_guard<std::recursive_mutex> lock(*cLock);
SetDisplayNumCB(static_cast<void*>(context), &OCSecure::displayNumCallbackWrapper);
SetDisplayNumCB(ctx, &OCSecure::displayNumCallbackWrapper);
result = OC_STACK_OK;
}
else
......@@ -906,11 +905,11 @@ namespace OC
return res;
}
OCStackResult OCSecure::registerUserConfirmCallback(UserConfirmNumCB userConfirmCB)
OCStackResult OCSecure::registerUserConfirmCallback(void* ctx)
{
if(!userConfirmCB)
if(!ctx)
{
oclog() << "Failed to set callback for confirming verifying callback.";
oclog() << "Failed to set context";
return OC_STACK_INVALID_CALLBACK;
}
......@@ -924,9 +923,8 @@ namespace OC
auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
if (cLock)
{
UserConfirmNumContext* context = new UserConfirmNumContext(userConfirmCB);
std::lock_guard<std::recursive_mutex> lock(*cLock);
SetUserConfirmCB(static_cast<void*>(context), &OCSecure::confirmUserCallbackWrapper);
SetUserConfirmCB(ctx, &OCSecure::confirmUserCallbackWrapper);
result = OC_STACK_OK;
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment