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