• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "hc_log.h"
17 #include "hc_types.h"
18 #include "iso_task_main.h"
19 #include "iso_base_cur_task.h"
20 #include "iso_client_task.h"
21 #include "iso_server_task.h"
22 #include "pake_v1_task_main.h"
23 #include "pake_base_cur_task.h"
24 #include "pake_v1_client_task.h"
25 #include "pake_v1_server_task.h"
26 #include "protocol_task_main_mock.h"
27 
28 static bool g_isIsoSupported = true;
29 static bool g_isPakeV1Supported = true;
30 
SetPakeV1Supported(bool isSupported)31 void SetPakeV1Supported(bool isSupported)
32 {
33     g_isPakeV1Supported = isSupported;
34 }
35 
IsSupportPakeV1()36 bool IsSupportPakeV1()
37 {
38     if (g_isPakeV1Supported) {
39         LOGI("pake v1 support.");
40     } else {
41         LOGI("pake v1 not support.");
42     }
43     return g_isPakeV1Supported;
44 }
45 
CreatePakeV1SubTask(const CJson * in)46 SubTaskBase *CreatePakeV1SubTask(const CJson *in)
47 {
48     bool isClient = true;
49     if (GetBoolFromJson(in, FIELD_IS_CLIENT, &isClient) != HC_SUCCESS) {
50         LOGE("Get isClient failed.");
51         return NULL;
52     }
53     if (isClient) {
54         return CreatePakeV1ClientTask(in);
55     } else {
56         return CreatePakeV1ServerTask(in);
57     }
58 }
59 
SetIsoSupported(bool isSupported)60 void SetIsoSupported(bool isSupported)
61 {
62     g_isIsoSupported = isSupported;
63 }
64 
IsIsoSupported(void)65 bool IsIsoSupported(void)
66 {
67     if (g_isIsoSupported) {
68         LOGI("iso support.");
69     } else {
70         LOGI("iso not support.");
71     }
72     return g_isIsoSupported;
73 }
74 
CreateIsoSubTask(const CJson * in)75 SubTaskBase *CreateIsoSubTask(const CJson *in)
76 {
77     bool isClient = true;
78     if (GetBoolFromJson(in, FIELD_IS_CLIENT, &isClient) != HC_SUCCESS) {
79         LOGE("Get isClient failed.");
80         return NULL;
81     }
82     if (isClient) {
83         return CreateIsoClientTask(in);
84     } else {
85         return CreateIsoServerTask(in);
86     }
87 }