napi_remote_object.h 4.0 KB
Newer Older
L
liangshenglin1 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef NAPI_IPC_OHOS_REMOTE_OBJECT_H
#define NAPI_IPC_OHOS_REMOTE_OBJECT_H

#include "iremote_object.h"
#include "iservice_registry.h"
#include "napi/native_common.h"
#include "napi/native_node_api.h"
#include "refbase.h"
#include "system_ability_manager_proxy.h"

namespace OHOS {
EXTERN_C_START
    napi_value NAPIIPCSkeletonExport(napi_env env, napi_value exports);
    napi_value NAPIRemoteProxyExport(napi_env env, napi_value exports);
    napi_value NAPIRemoteObjectExport(napi_env env, napi_value exports);
    napi_value NAPIMessageOptionExport(napi_env env, napi_value exports);
EXTERN_C_END

    // IPCSkeleton napi methods
    napi_value NAPI_IPCSkeleton_getContextObject(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_getCallingPid(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_getCallingUid(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_getCallingDeviceID(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_getLocalDeviceID(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_isLocalCalling(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_flushCommands(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_resetCallingIdentity(napi_env env, napi_callback_info info);

    napi_value NAPI_IPCSkeleton_setCallingIdentity(napi_env env, napi_callback_info info);

    // RemoteObject napi methods
L
liangshenglin1 已提交
54
    napi_value NAPI_RemoteObject_sendRequest(napi_env env, napi_callback_info info);
L
liangshenglin1 已提交
55

L
liangshenglin1 已提交
56 57 58 59
    napi_value NAPI_RemoteObject_getCallingPid(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteObject_getCallingUid(napi_env env, napi_callback_info info);

L
liangshenglin1 已提交
60
    napi_value NAPI_RemoteObject_getInterfaceDescriptor(napi_env env, napi_callback_info info);
61

L
liangshenglin1 已提交
62
    napi_value NAPI_RemoteObject_attachLocalInterface(napi_env env, napi_callback_info info);
L
liangshenglin1 已提交
63

L
liangshenglin1 已提交
64 65 66 67 68 69 70 71 72
    napi_value NAPI_RemoteObject_queryLocalInterface(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteObject_addDeathRecipient(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteObject_removeDeathRecipient(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteObject_isObjectDead(napi_env env, napi_callback_info info);

    // RemoteProxy napi methods
L
liangshenglin1 已提交
73 74
    napi_value NAPI_RemoteProxy_sendRequest(napi_env env, napi_callback_info info);

L
liangshenglin1 已提交
75 76
    napi_value NAPI_RemoteProxy_queryLocalInterface(napi_env env, napi_callback_info info);

L
liangshenglin1 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    napi_value NAPI_RemoteProxy_addDeathRecipient(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteProxy_removeDeathRecipient(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteProxy_getInterfaceDescriptor(napi_env env, napi_callback_info info);

    napi_value NAPI_RemoteProxy_isObjectDead(napi_env env, napi_callback_info info);

    sptr<IRemoteObject> NAPI_ohos_rpc_getNativeRemoteObject(napi_env env, napi_value object);

    napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteObject> target);

    struct SendRequestParam {
        sptr<IRemoteObject> target;
        uint32_t code;
92 93
        std::shared_ptr<MessageParcel> data;
        std::shared_ptr<MessageParcel> reply;
L
liangshenglin1 已提交
94
        MessageOption &option;
L
liangshenglin1 已提交
95 96 97
        napi_async_work asyncWork;
        napi_deferred deferred;
        int errCode;
98
        napi_env env;
L
liangshenglin1 已提交
99 100 101
    };
} // namespace OHOS
#endif // NAPI_IPC_OHOS_REMOTE_OBJECT_H