• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_DSCHED_CONTINUE_EVENT_H
17 #define OHOS_DSCHED_CONTINUE_EVENT_H
18 
19 #include <string>
20 
21 #include "cJSON.h"
22 
23 #include "ability_info.h"
24 #include "caller_info.h"
25 #include "distributed_sched_interface.h"
26 #include "distributedWant/distributed_want_params.h"
27 #include "want.h"
28 
29 namespace OHOS {
30 namespace DistributedSchedule {
31 typedef enum {
32     DSCHED_CONTINUE_INVALID_EVENT = -1,
33     DSCHED_CONTINUE_REQ_PULL_EVENT = 0,
34     DSCHED_CONTINUE_REPLY_EVENT = 1,
35     DSCHED_CONTINUE_DATA_EVENT = 2,
36 
37     DSHCED_CONTINUE_REQ_PUSH_EVENT = 3,
38     DSHCED_CONTINUE_ABILITY_EVENT = 4,
39     DSHCED_CONTINUE_SEND_DATA_EVENT = 5,
40 
41     DSCHED_CONTINUE_COMPLETE_EVENT = 6,
42     DSCHED_CONTINUE_END_EVENT = 7
43 } DSchedContinueEventType;
44 
45 typedef enum {
46     DSCHED_CONTINUE_CMD_MIN = 0,
47     DSCHED_CONTINUE_CMD_START = 1,
48     DSCHED_CONTINUE_CMD_DATA = 2,
49     DSCHED_CONTINUE_CMD_REPLY = 3,
50     DSCHED_CONTINUE_CMD_END = 4,
51 } DSchedContinueCommand;
52 
53 class DSchedContinueCmdBase {
54 public:
55     DSchedContinueCmdBase() = default;
56     virtual ~DSchedContinueCmdBase() = default;
57     virtual int32_t Marshal(std::string &jsonStr);
58     virtual int32_t Unmarshal(const std::string &jsonStr);
59 public:
60     int32_t version_ = 0;
61     int32_t serviceType_ = 0;
62     int32_t subServiceType_ = 0;
63     int32_t command_ = 0;
64     std::string srcDeviceId_;
65     std::string srcBundleName_;
66     std::string srcDeveloperId_ = "";
67     std::string dstDeviceId_;
68     std::string dstBundleName_;
69     std::string dstDeveloperId_ = "";
70     std::string continueType_;
71     int32_t continueByType_ = 0;
72     int32_t sourceMissionId_ = 0;
73     int32_t dmsVersion_ = 0;
74 };
75 
76 class DSchedContinueStartCmd : public DSchedContinueCmdBase {
77 public:
78     int32_t Marshal(std::string &jsonStr);
79     int32_t Unmarshal(const std::string &jsonStr);
80 
81 public:
82     int32_t direction_ = 0;
83     int32_t appVersion_ = 0;
84     DistributedWantParams wantParams_;
85 };
86 
87 class DSchedContinueDataCmd : public DSchedContinueCmdBase {
88 public:
89     int32_t Marshal(std::string &jsonStr);
90     int32_t Unmarshal(const std::string &jsonStr);
91 
92 private:
93     bool MarshalInner(cJSON* rootValue);
94     int32_t MarshalCallerInfo(std::string &jsonStr);
95     int32_t MarshalAccountInfo(std::string &jsonStr);
96     int32_t UnmarshalParcel(const std::string &jsonStr);
97     bool UnmarshalWantParcel(cJSON* rootValue);
98     int32_t UnmarshalCallerInfo(const std::string &jsonStr);
99     int32_t UnmarshalCallerInfoExtra(const std::string &jsonStr);
100     int32_t UnmarshalAccountInfo(const std::string &jsonStr);
101 
102 public:
103     using AccountInfo = IDistributedSched::AccountInfo;
104 
105     OHOS::AAFwk::Want want_;
106     AppExecFwk::CompatibleAbilityInfo abilityInfo_;
107     int32_t requestCode_;
108     CallerInfo callerInfo_;
109     AccountInfo accountInfo_;
110 };
111 
112 class DSchedContinueReplyCmd : public DSchedContinueCmdBase {
113 public:
114     int32_t Marshal(std::string &jsonStr);
115     int32_t Unmarshal(const std::string &jsonStr);
116 
117 public:
118     int32_t replyCmd_ = 0;
119     int32_t appVersion_ = 0;
120     int32_t result_ = 0;
121     std::string reason_;
122 };
123 
124 class DSchedContinueEndCmd : public DSchedContinueCmdBase {
125 public:
126     int32_t Marshal(std::string &jsonStr);
127     int32_t Unmarshal(const std::string &jsonStr);
128 
129 public:
130     int32_t result_;
131 };
132 }  // namespace DistributedSchedule
133 }  // namespace OHOS
134 #endif  // OHOS_DSCHED_CONTINUE_EVENT_H
135