• 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 "ohos_adapter/bridge/ark_net_capabilities_adapter_wrapper.h"
17 #include "ohos_adapter/bridge/ark_net_conn_callback_impl.h"
18 #include "ohos_adapter/bridge/ark_net_connection_properties_adapter_wrapper.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
ArkNetConnCallbackImpl(std::shared_ptr<OHOS::NWeb::NetConnCallback> ref)24 ArkNetConnCallbackImpl::ArkNetConnCallbackImpl(std::shared_ptr<OHOS::NWeb::NetConnCallback> ref) : real_(ref) {}
25 
NetAvailable()26 int32_t ArkNetConnCallbackImpl::NetAvailable()
27 {
28     return real_->NetAvailable();
29 }
30 
NetCapabilitiesChange(const uint32_t & netConnectType,const uint32_t & netConnectSubtype)31 int32_t ArkNetConnCallbackImpl::NetCapabilitiesChange(const uint32_t& netConnectType, const uint32_t& netConnectSubtype)
32 {
33     return real_->NetCapabilitiesChange(
34         (NWeb::NetConnectType)netConnectType, (NWeb::NetConnectSubtype)netConnectSubtype);
35 }
36 
NetConnectionPropertiesChange()37 int32_t ArkNetConnCallbackImpl::NetConnectionPropertiesChange()
38 {
39     return real_->NetConnectionPropertiesChange();
40 }
41 
NetUnavailable()42 int32_t ArkNetConnCallbackImpl::NetUnavailable()
43 {
44     return real_->NetUnavailable();
45 }
46 
OnNetCapabilitiesChanged(const ArkWebRefPtr<ArkNetCapabilitiesAdapter> capabilites)47 int32_t ArkNetConnCallbackImpl::OnNetCapabilitiesChanged(
48     const ArkWebRefPtr<ArkNetCapabilitiesAdapter> capabilites)
49 {
50     if (CHECK_REF_PTR_IS_NULL(capabilites)) {
51         return real_->OnNetCapabilitiesChanged(nullptr);
52     }
53 
54     return real_->OnNetCapabilitiesChanged(
55         std::make_shared<ArkNetCapabilitiesAdapterWrapper>(capabilites));
56 }
57 
OnNetConnectionPropertiesChanged(const ArkWebRefPtr<ArkNetConnectionPropertiesAdapter> properties)58 int32_t ArkNetConnCallbackImpl::OnNetConnectionPropertiesChanged(
59     const ArkWebRefPtr<ArkNetConnectionPropertiesAdapter> properties)
60 {
61     if (CHECK_REF_PTR_IS_NULL(properties)) {
62         return real_->OnNetConnectionPropertiesChanged(nullptr);
63     }
64 
65     return real_->OnNetConnectionPropertiesChanged(
66         std::make_shared<ArkNetConnectionPropertiesAdapterWrapper>(properties));
67 }
68 
69 } // namespace OHOS::ArkWeb
70