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 #include "js_insight_intent_driver_utils.h"
17
18 #include <cstdint>
19
20 #include "ability_state.h"
21 #include "napi_common_want.h"
22 #include "napi_remote_object.h"
23 #include "js_runtime.h"
24 #include "js_runtime_utils.h"
25
26 namespace OHOS {
27 namespace AbilityRuntime {
CreateJsExecuteResult(napi_env env,const AppExecFwk::InsightIntentExecuteResult & result)28 napi_value CreateJsExecuteResult(napi_env env, const AppExecFwk::InsightIntentExecuteResult &result)
29 {
30 napi_value objValue = nullptr;
31 napi_create_object(env, &objValue);
32
33 napi_set_named_property(env, objValue, "code", CreateJsValue(env, result.code));
34 if (result.result != nullptr) {
35 napi_set_named_property(env, objValue, "result",
36 OHOS::AppExecFwk::CreateJsWantParams(env, *result.result));
37 }
38 if (result.uris.size() > 0) {
39 napi_set_named_property(env, objValue, "uris", CreateNativeArray(env, result.uris));
40 }
41 napi_set_named_property(env, objValue, "flags", CreateJsValue(env, result.flags));
42 return objValue;
43 }
44 } // namespace AbilityRuntime
45 } // namespace OHOS
46