#include "srmresourcestrings.h"
#include "cainterface.h"
#include "oxmverifycommon.h"
+#include "octhread.h"
#define TAG "OIC_VERIFY_COMMON"
static DisplayNumContext_t gDisplayNumContext = { .callback = NULL, .context = NULL };
static UserConfirmContext_t gUserConfirmContext = { .callback = NULL, .context = NULL };
+static UserAsyncConfirmContext_t gUserAsyncConfirmContext = { .callback = NULL, .context = NULL, .userConfirm = false, .userConfirmResult = false };
static InputStateContext_t gInputStateContext = { .callback = NULL, .context = NULL };
+extern oc_cond g_condWait;
void SetDisplayNumCB(void * ptr, DisplayNumCallback displayNumCB)
{
return OC_STACK_OK;
}
+OCStackResult VerifyUserConfirm()
+{
+ OIC_LOG(DEBUG, TAG, "IN VerifyUserConfirm");
+ OIC_LOG_V(DEBUG, TAG, "gVerifyOption: %d", (int) gVerifyOption);
+ if (gVerifyOption)
+ {
+ if (!gUserAsyncConfirmContext.callback)
+ {
+ OIC_LOG(ERROR, TAG, "Callback to get user confirmation not registered");
+ return OC_STACK_ERROR;
+ }
+ OIC_LOG(DEBUG, TAG, "calling userAsyncConfirmCallback");
+ gUserAsyncConfirmContext.callback(&gUserAsyncConfirmContext);
+ }
+ OIC_LOG(DEBUG, TAG, "OUT VerifyUserConfirm");
+ return OC_STACK_OK;
+}
+
+void GetAsyncVerifyUserResult(bool * result, bool * confirm)
+{
+ *result = gUserAsyncConfirmContext.userConfirmResult;
+ *confirm = gUserAsyncConfirmContext.userConfirm;
+ return;
+}
+
+void SetAsyncUserConfirmCB(void * ptr, UserConfirmCallback userConfirmCB)
+{
+ OIC_LOG(DEBUG, TAG, "IN SetAsyncUserConfirmCB");
+ if (NULL == userConfirmCB)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set callback to confirm mutualVerifNum");
+ return;
+ }
+ gUserAsyncConfirmContext.callback = userConfirmCB;
+ gUserAsyncConfirmContext.context = ptr;
+ OIC_LOG(DEBUG, TAG, "OUT SetAsyncUserConfirmCB");
+}
+
+void* UnsetAsyncUserConfirmCB()
+{
+ OIC_LOG(DEBUG, TAG, "IN UnsetAsyncUserConfirmCB");
+ void *prevctx = gUserAsyncConfirmContext.context;
+ gUserAsyncConfirmContext.callback = NULL;
+ gUserAsyncConfirmContext.context = NULL;
+ OIC_LOG(DEBUG, TAG, "OUT UnsetAsyncUserConfirmCB");
+ return prevctx;
+}
+
+OCStackResult SendUserConfirm(bool confirmed)
+{
+ gUserAsyncConfirmContext.userConfirmResult = confirmed;
+ gUserAsyncConfirmContext.userConfirm = true;
+ oc_cond_signal(g_condWait);
+ return OC_STACK_OK;
+}
+
OCStackResult NotifyInputState(void)
{
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);