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 #ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_WANT_WRAP_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_WANT_WRAP_H
18 
19 #include <map>
20 
21 #include "base/memory/ace_type.h"
22 
23 typedef struct napi_value__* napi_value;
24 typedef struct napi_env__* napi_env;
25 namespace OHOS::AAFwk {
26 class Want;
27 class WantParams;
28 } // namespace OHOS::AAFwk
29 
30 namespace OHOS::Ace {
31 class WantParamsWrap : public AceType {
32     DECLARE_ACE_TYPE(WantParamsWrap, AceType);
33 
34 public:
35     static RefPtr<WantParamsWrap> CreateWantWrap(napi_env env, napi_value value);
36 };
37 
38 class ACE_EXPORT WantWrap : public AceType {
39     DECLARE_ACE_TYPE(WantWrap, AceType);
40 
41 public:
42     static napi_value ConvertToNativeValue(const OHOS::AAFwk::Want& want, napi_env env);
43     static napi_value ConvertParamsToNativeValue(const OHOS::AAFwk::WantParams& wantParams, napi_env env);
44     static RefPtr<WantWrap> CreateWantWrap(napi_env env, napi_value value);
45     static RefPtr<WantWrap> CreateWantWrap(const std::string& bundleName, const std::string& abilityName);
46 
47     virtual void SetWantParamsFromWantWrap(void* want) = 0;
48     virtual void SetWantParam(const std::map<std::string, std::string>& params) = 0;
49     virtual std::string ToString() const = 0;
50     virtual const OHOS::AAFwk::Want& GetWant() const = 0;
51 };
52 
53 } // namespace OHOS::Ace
54 
55 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_WANT_WRAP_H
56