1 /* 2 * Copyright (C) 2021-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 #ifndef WIFI_NAPI_P2P_H_ 17 #define WIFI_NAPI_P2P_H_ 18 19 #include "wifi_napi_utils.h" 20 #include "wifi_p2p.h" 21 22 namespace OHOS { 23 namespace Wifi { 24 napi_value GetP2pLinkedInfo(napi_env env, napi_callback_info info); 25 napi_value GetCurrentGroup(napi_env env, napi_callback_info info); 26 napi_value GetP2pDevices(napi_env env, napi_callback_info info); 27 napi_value CreateGroup(napi_env env, napi_callback_info info); 28 napi_value RemoveGroup(napi_env env, napi_callback_info info); 29 napi_value P2pConnect(napi_env env, napi_callback_info info); 30 napi_value P2pCancelConnect(napi_env env, napi_callback_info info); 31 napi_value StartDiscoverDevices(napi_env env, napi_callback_info info); 32 napi_value StopDiscoverDevices(napi_env env, napi_callback_info info); 33 napi_value DeletePersistentGroup(napi_env env, napi_callback_info info); 34 napi_value SetDeviceName(napi_env env, napi_callback_info info); 35 36 class QueryP2pDeviceAsyncContext : public AsyncContext { 37 public: 38 std::vector<WifiP2pDevice> vecP2pDevices; 39 40 QueryP2pDeviceAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)41 : AsyncContext(env, work, deferred) {} 42 43 QueryP2pDeviceAsyncContext() = delete; 44 ~QueryP2pDeviceAsyncContext()45 ~QueryP2pDeviceAsyncContext() override {} 46 }; 47 48 class P2pLinkedInfoAsyncContext : public AsyncContext { 49 public: 50 WifiP2pLinkedInfo linkedInfo; 51 52 P2pLinkedInfoAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)53 : AsyncContext(env, work, deferred) {} 54 55 P2pLinkedInfoAsyncContext() = delete; 56 ~P2pLinkedInfoAsyncContext()57 ~P2pLinkedInfoAsyncContext() override {} 58 }; 59 60 class P2pGroupInfoAsyncContext : public AsyncContext { 61 public: 62 WifiP2pGroupInfo groupInfo; 63 64 P2pGroupInfoAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)65 : AsyncContext(env, work, deferred) {} 66 67 P2pGroupInfoAsyncContext() = delete; 68 ~P2pGroupInfoAsyncContext()69 ~P2pGroupInfoAsyncContext() override {} 70 }; 71 } // namespace Wifi 72 } // namespace OHOS 73 74 #endif 75