1 /*
2  * Copyright (C) 2023 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 NETMANAGER_EXT_MDNS_BASE_CONTEXT_H
17 #define NETMANAGER_EXT_MDNS_BASE_CONTEXT_H
18 
19 #include "base_context.h"
20 #include "event_manager.h"
21 
22 #include "mdns_callback_observer.h"
23 #include "mdns_service_info.h"
24 
25 namespace OHOS {
26 namespace NetManagerStandard {
27 class MDnsBaseContext : public BaseContext {
28 public:
29     MDnsBaseContext() = delete;
30     explicit MDnsBaseContext(napi_env env, EventManager *manager);
31 
32     MDnsServiceInfo &GetServiceInfo();
33     void SetServiceInfo(const MDnsServiceInfo &info);
34     void ParseServiceInfo(napi_env env, napi_value value);
35     void ParseAddressObj(napi_env env, napi_value obj);
36     void ParseAttributeObj(napi_env env, napi_value obj, TxtRecord &attrMap);
37     bool GetAttributeObj(napi_env env, napi_value obj, uint32_t &len);
38     std::string GetContextIdString(napi_env env, napi_value obj);
39 
40 private:
41     MDnsServiceInfo serviceInfo_;
42 };
43 } // namespace NetManagerStandard
44 } // namespace OHOS
45 #endif /* NETMANAGER_EXT_MDNS_BASE_CONTEXT_H */
46