• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 OHOS_SESSION_ROUTER_STACK_LISTENER_H
17 #define OHOS_SESSION_ROUTER_STACK_LISTENER_H
18 
19 #include <iremote_broker.h>
20 #include <iremote_object.h>
21 
22 #include "wm_common.h"
23 
24 namespace OHOS::Rosen {
25 
26 class RouterStackInfo : public Parcelable {
27 public:
28     RouterStackInfo() = default;
29 
RouterStackInfo(int32_t winId,std::string routerStackInfo)30     RouterStackInfo(int32_t winId, std::string routerStackInfo) : winId_(winId), routerStackInfo_(routerStackInfo) {};
31 
32     ~RouterStackInfo() = default;
33 
Marshalling(Parcel & parcel)34     bool Marshalling(Parcel &parcel) const
35     {
36         return parcel.WriteInt32(winId_) && parcel.WriteString(routerStackInfo_) &&
37             parcel.WriteInt32(static_cast<int32_t>(errCode_));
38     }
39 
Unmarshalling(Parcel & parcel)40     static RouterStackInfo *Unmarshalling(Parcel &parcel)
41     {
42         auto routerStackInfo = new (std::nothrow) RouterStackInfo();
43         if (routerStackInfo == nullptr) {
44             return nullptr;
45         }
46         int32_t errCode = 0;
47         bool res =
48             parcel.ReadInt32(routerStackInfo->winId_) && parcel.ReadString(routerStackInfo->routerStackInfo_)
49                 && parcel.ReadInt32(errCode);
50         routerStackInfo->errCode_ = static_cast<WMError>(errCode);
51         if (!res) {
52             delete routerStackInfo;
53             return nullptr;
54         }
55         return routerStackInfo;
56     }
57 
58     int32_t winId_{0};
59     std::string routerStackInfo_;
60     WMError errCode_ = WMError::WM_OK;
61 };
62 
63 class ISessionRouterStackListener : public IRemoteBroker {
64 public:
65     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISessionRouterStackListener");
66 
67     enum class SessionRouterStackListenerMessage : uint32_t {
68         TRANS_ID_GET_ROUTER_STACK_INFO = 0,
69     };
70 
SendRouterStackInfo(const sptr<RouterStackInfo> & routerStackInfo)71     virtual void SendRouterStackInfo(const sptr<RouterStackInfo>& routerStackInfo) {};
72 };
73 } // namespace OHOS
74 #endif //OHOS_SESSION_ROUTER_STACK_LISTENER_H