1686862fbSopenharmony_ci/* 2686862fbSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3686862fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4686862fbSopenharmony_ci * you may not use this file except in compliance with the License. 5686862fbSopenharmony_ci * You may obtain a copy of the License at 6686862fbSopenharmony_ci * 7686862fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8686862fbSopenharmony_ci * 9686862fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10686862fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11686862fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12686862fbSopenharmony_ci * See the License for the specific language governing permissions and 13686862fbSopenharmony_ci * limitations under the License. 14686862fbSopenharmony_ci */ 15686862fbSopenharmony_ci 16686862fbSopenharmony_ci#ifndef OHOS_DISTRIBUTEDWANT_OPERATION_H 17686862fbSopenharmony_ci#define OHOS_DISTRIBUTEDWANT_OPERATION_H 18686862fbSopenharmony_ci 19686862fbSopenharmony_ci#include <string> 20686862fbSopenharmony_ci#include "parcel.h" 21686862fbSopenharmony_ci#include "string_ex.h" 22686862fbSopenharmony_ci#include "uri.h" 23686862fbSopenharmony_ci 24686862fbSopenharmony_cinamespace OHOS { 25686862fbSopenharmony_cinamespace DistributedSchedule { 26686862fbSopenharmony_ciclass DistributedOperationBuilder; 27686862fbSopenharmony_ciclass DistributedOperation : public Parcelable { 28686862fbSopenharmony_ci friend class DistributedOperationBuilder; 29686862fbSopenharmony_ci friend class DistributedWant; 30686862fbSopenharmony_ci 31686862fbSopenharmony_cipublic: 32686862fbSopenharmony_ci DistributedOperation(); 33686862fbSopenharmony_ci ~DistributedOperation(); 34686862fbSopenharmony_ci DistributedOperation(const DistributedOperation& other); 35686862fbSopenharmony_ci /** 36686862fbSopenharmony_ci * @description: Obtains the value of the abilityName attribute included in this DistributedOperation. 37686862fbSopenharmony_ci * @return Returns the ability name included in this DistributedOperation. 38686862fbSopenharmony_ci */ 39686862fbSopenharmony_ci std::string GetAbilityName() const; 40686862fbSopenharmony_ci 41686862fbSopenharmony_ci /** 42686862fbSopenharmony_ci * @description: Obtains the value of the action attribute included in this DistributedOperation. 43686862fbSopenharmony_ci * @return Returns the action included in this DistributedOperation. 44686862fbSopenharmony_ci */ 45686862fbSopenharmony_ci std::string GetAction() const; 46686862fbSopenharmony_ci 47686862fbSopenharmony_ci /** 48686862fbSopenharmony_ci * @description: Obtains the value of the bundleName attribute included in this DistributedOperation. 49686862fbSopenharmony_ci * @return Returns the bundle name included in this DistributedOperation. 50686862fbSopenharmony_ci */ 51686862fbSopenharmony_ci std::string GetBundleName() const; 52686862fbSopenharmony_ci 53686862fbSopenharmony_ci /** 54686862fbSopenharmony_ci * @description: Obtains the value of the deviceId attribute included in this DistributedOperation. 55686862fbSopenharmony_ci * @return Returns the device ID included in this DistributedOperation. 56686862fbSopenharmony_ci */ 57686862fbSopenharmony_ci std::string GetDeviceId() const; 58686862fbSopenharmony_ci 59686862fbSopenharmony_ci /** 60686862fbSopenharmony_ci * @description: Obtains the value of the entities attribute included in this DistributedOperation. 61686862fbSopenharmony_ci * @return Returns the entities included in this DistributedOperation. 62686862fbSopenharmony_ci */ 63686862fbSopenharmony_ci const std::vector<std::string>& GetEntities() const; 64686862fbSopenharmony_ci 65686862fbSopenharmony_ci /** 66686862fbSopenharmony_ci * @description: Obtains the value of the flags attribute included in this DistributedOperation. 67686862fbSopenharmony_ci * @return Returns the flags included in this DistributedOperation. 68686862fbSopenharmony_ci */ 69686862fbSopenharmony_ci unsigned int GetFlags() const; 70686862fbSopenharmony_ci 71686862fbSopenharmony_ci /** 72686862fbSopenharmony_ci * @description: Obtains the value of the uri attribute included in this DistributedOperation. 73686862fbSopenharmony_ci * @return Returns the URI included in this DistributedOperation. 74686862fbSopenharmony_ci */ 75686862fbSopenharmony_ci OHOS::Uri GetUri() const; 76686862fbSopenharmony_ci 77686862fbSopenharmony_ci /** 78686862fbSopenharmony_ci * @description: Obtains the description of the ModuleName object in the DistributedOperation. 79686862fbSopenharmony_ci * @return Returns the ModuleName description in the DistributedOperation. 80686862fbSopenharmony_ci */ 81686862fbSopenharmony_ci std::string GetModuleName() const; 82686862fbSopenharmony_ci 83686862fbSopenharmony_ci bool operator==(const DistributedOperation& other) const; 84686862fbSopenharmony_ci DistributedOperation& operator=(const DistributedOperation& other); 85686862fbSopenharmony_ci 86686862fbSopenharmony_ci bool Marshalling(Parcel& parcel) const; 87686862fbSopenharmony_ci static DistributedOperation* Unmarshalling(Parcel& parcel); 88686862fbSopenharmony_ci 89686862fbSopenharmony_ciprivate: 90686862fbSopenharmony_ci /** 91686862fbSopenharmony_ci * @description: Sets a flag in a DistributedWant. 92686862fbSopenharmony_ci * @param flags Indicates the flag to set. 93686862fbSopenharmony_ci * @return Returns this DistributedWant object containing the flag. 94686862fbSopenharmony_ci */ 95686862fbSopenharmony_ci void SetFlags(unsigned int flags); 96686862fbSopenharmony_ci /** 97686862fbSopenharmony_ci * @description: Adds a flag to a DistributedWant. 98686862fbSopenharmony_ci * @param flags Indicates the flag to add. 99686862fbSopenharmony_ci * @return Returns the DistributedWant object with the added flag. 100686862fbSopenharmony_ci */ 101686862fbSopenharmony_ci void AddFlags(unsigned int flags); 102686862fbSopenharmony_ci /** 103686862fbSopenharmony_ci * @description: Removes the description of a flag from a DistributedWant. 104686862fbSopenharmony_ci * @param flags Indicates the flag to remove. 105686862fbSopenharmony_ci * @return Removes the description of a flag from a DistributedWant. 106686862fbSopenharmony_ci */ 107686862fbSopenharmony_ci void RemoveFlags(unsigned int flags); 108686862fbSopenharmony_ci 109686862fbSopenharmony_ci /** 110686862fbSopenharmony_ci * @description: Adds the description of an entity to a DistributedWant 111686862fbSopenharmony_ci * @param entity Indicates the entity description to add 112686862fbSopenharmony_ci * @return Returns this DistributedWant object containing the entity. 113686862fbSopenharmony_ci */ 114686862fbSopenharmony_ci void AddEntity(const std::string& entity); 115686862fbSopenharmony_ci 116686862fbSopenharmony_ci /** 117686862fbSopenharmony_ci * @description: Removes the description of an entity from a DistributedWant 118686862fbSopenharmony_ci * @param entity Indicates the entity description to remove. 119686862fbSopenharmony_ci * @return void 120686862fbSopenharmony_ci */ 121686862fbSopenharmony_ci void RemoveEntity(const std::string& entity); 122686862fbSopenharmony_ci 123686862fbSopenharmony_ci /** 124686862fbSopenharmony_ci * @description: Checks whether a DistributedWant contains the given entity 125686862fbSopenharmony_ci * @param entity Indicates the entity to check 126686862fbSopenharmony_ci * @return Returns true if the given entity is contained; returns false otherwise 127686862fbSopenharmony_ci */ 128686862fbSopenharmony_ci bool HasEntity(const std::string& entity) const; 129686862fbSopenharmony_ci 130686862fbSopenharmony_ci /** 131686862fbSopenharmony_ci * @description: Obtains the number of entities in a DistributedWant 132686862fbSopenharmony_ci * @return Returns the entity quantity 133686862fbSopenharmony_ci */ 134686862fbSopenharmony_ci int CountEntities() const; 135686862fbSopenharmony_ci 136686862fbSopenharmony_ci /** 137686862fbSopenharmony_ci * @description: Sets a bundle name in this DistributedWant. 138686862fbSopenharmony_ci * If a bundle name is specified in a DistributedWant, the DistributedWant will match only 139686862fbSopenharmony_ci * the abilities in the specified bundle. You cannot use this method and 140686862fbSopenharmony_ci * setPicker(ohos.aafwk.content.DistributedWant) on the same DistributedWant. 141686862fbSopenharmony_ci * @param bundleName Indicates the bundle name to set. 142686862fbSopenharmony_ci * @return Returns a DistributedWant object containing the specified bundle name. 143686862fbSopenharmony_ci */ 144686862fbSopenharmony_ci void SetBundleName(const std::string& bundleName); 145686862fbSopenharmony_ci 146686862fbSopenharmony_ci /** 147686862fbSopenharmony_ci * @description: Sets a uri in this DistributedOperation. 148686862fbSopenharmony_ci * @param uri Indicates uri object to set. 149686862fbSopenharmony_ci * @return - 150686862fbSopenharmony_ci */ 151686862fbSopenharmony_ci void SetUri(const OHOS::Uri& uri); 152686862fbSopenharmony_ci 153686862fbSopenharmony_ci /** 154686862fbSopenharmony_ci * @description: Gets a uri in this DistributedOperation. 155686862fbSopenharmony_ci * @param uri Indicates uri object to set. 156686862fbSopenharmony_ci * @return Returns a uri in this DistributedOperation. 157686862fbSopenharmony_ci */ 158686862fbSopenharmony_ci OHOS::Uri& GetUri(const OHOS::Uri& uri); 159686862fbSopenharmony_ci 160686862fbSopenharmony_ci /** 161686862fbSopenharmony_ci * @description: Sets the value of the abilityName attribute included in this DistributedOperation. 162686862fbSopenharmony_ci * @return Returns the ability name included in this DistributedOperation. 163686862fbSopenharmony_ci */ 164686862fbSopenharmony_ci void SetAbilityName(const std::string& abilityname); 165686862fbSopenharmony_ci 166686862fbSopenharmony_ci /** 167686862fbSopenharmony_ci * @description: Sets the value of the deviceId attribute included in this DistributedOperation. 168686862fbSopenharmony_ci * @param deviceid Indicates deviceid object to set. 169686862fbSopenharmony_ci * @return - 170686862fbSopenharmony_ci */ 171686862fbSopenharmony_ci void SetDeviceId(const std::string& deviceid); 172686862fbSopenharmony_ci 173686862fbSopenharmony_ci /** 174686862fbSopenharmony_ci * @description: Sets the value of the action attribute included in this DistributedOperation. 175686862fbSopenharmony_ci * @param deviceid Indicates deviceid object to set. 176686862fbSopenharmony_ci * @return - 177686862fbSopenharmony_ci */ 178686862fbSopenharmony_ci void SetAction(const std::string& action); 179686862fbSopenharmony_ci 180686862fbSopenharmony_ci /** 181686862fbSopenharmony_ci * @description: Sets the entities of this DistributedOperation. 182686862fbSopenharmony_ci * @param entities Indicates entities to set. 183686862fbSopenharmony_ci * @return - 184686862fbSopenharmony_ci */ 185686862fbSopenharmony_ci void SetEntities(const std::vector<std::string>& entities); 186686862fbSopenharmony_ci 187686862fbSopenharmony_ci /** 188686862fbSopenharmony_ci * @description: Sets an ModuleName object in the DistributedOperation. 189686862fbSopenharmony_ci * @param moduleName Indicates the ModuleName description. 190686862fbSopenharmony_ci * @return Returns this DistributedOperation object containing the ModuleName. 191686862fbSopenharmony_ci */ 192686862fbSopenharmony_ci void SetModuleName(const std::string& moduleName); 193686862fbSopenharmony_ci 194686862fbSopenharmony_ciprivate: 195686862fbSopenharmony_ci std::string abilityName_; 196686862fbSopenharmony_ci std::string action_; 197686862fbSopenharmony_ci std::string bundleName_; 198686862fbSopenharmony_ci std::string deviceId_; 199686862fbSopenharmony_ci std::string moduleName_; 200686862fbSopenharmony_ci std::vector<std::string> entities_; 201686862fbSopenharmony_ci unsigned int flags_; 202686862fbSopenharmony_ci OHOS::Uri uri_; 203686862fbSopenharmony_ci 204686862fbSopenharmony_ci // no object in parcel 205686862fbSopenharmony_ci static constexpr int VALUE_NULL = -1; 206686862fbSopenharmony_ci // object exist in parcel 207686862fbSopenharmony_ci static constexpr int VALUE_OBJECT = 1; 208686862fbSopenharmony_ci 209686862fbSopenharmony_ci bool ReadFromParcel(Parcel& parcel); 210686862fbSopenharmony_ci}; 211686862fbSopenharmony_ci} // namespace DistributedSchedule 212686862fbSopenharmony_ci} // namespace OHOS 213686862fbSopenharmony_ci#endif // OHOS_DISTRIBUTEDWANT_OPERATION_H