1 /* 2 * Copyright (c) 2023 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_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SHARING_CENTER_H 17 #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SHARING_CENTER_H 18 19 #include <errors.h> 20 #include <vector> 21 #include <string> 22 #include <tuple> 23 #include "visibility.h" 24 namespace OHOS::DistributedData { 25 class API_EXPORT SharingCenter { 26 public: 27 enum Role { 28 ROLE_NIL = -1, 29 ROLE_INVITER, 30 ROLE_INVITEE, 31 ROLE_BUTT 32 }; 33 34 enum Confirmation { 35 CFM_NIL = -1, 36 CFM_UNKNOWN, 37 CFM_ACCEPTED, 38 CFM_REJECTED, 39 CFM_SUSPENDED, 40 CFM_UNAVAILABLE, 41 CFM_BUTT 42 }; 43 44 struct Privilege { 45 bool writable = false; 46 bool readable = false; 47 bool creatable = false; 48 bool deletable = false; 49 bool shareable = false; 50 }; 51 52 struct Participant { 53 std::string identity; 54 int32_t role = Role::ROLE_NIL; 55 int32_t state = Confirmation::CFM_NIL; 56 Privilege privilege; 57 std::string attachInfo; 58 }; 59 60 using Participants = std::vector<Participant>; 61 using Results = std::tuple<int32_t, std::string, std::vector<std::pair<int32_t, std::string>>>; 62 using QueryResults = std::tuple<int32_t, std::string, Participants>; 63 enum CloudShareModule { 64 CLOUD_SHARE_MODULE_ID = 12, 65 }; 66 static const ErrCode SHARING_ERR_OFFSET = ErrCodeOffset(SUBSYS_DISTRIBUTEDDATAMNG, CLOUD_SHARE_MODULE_ID); 67 enum SharingCode : int32_t { 68 SUCCESS = 0, 69 REPEATED_REQUEST, 70 NOT_INVITER, 71 NOT_INVITER_OR_INVITEE, 72 OVER_QUOTA, 73 TOO_MANY_PARTICIPANTS, 74 INVALID_ARGS, 75 NETWORK_ERROR, 76 CLOUD_DISABLED, 77 SERVER_ERROR, 78 INNER_ERROR, 79 INVALID_INVITATION, 80 RATE_LIMIT, 81 IPC_ERROR, 82 NOT_SUPPORT, 83 CUSTOM_ERROR = 1000, 84 }; 85 86 virtual Results Share(int32_t userId, const std::string &bundleName, const std::string &sharingRes, 87 const Participants &participants); 88 virtual Results Unshare(int32_t userId, const std::string &bundleName, const std::string &sharingRes, 89 const Participants &participants); 90 virtual std::pair<int32_t, std::string> Exit(int32_t userId, const std::string &bundleName, 91 const std::string &sharingRes); 92 virtual Results ChangePrivilege(int32_t userId, const std::string &bundleName, const std::string &sharingRes, 93 const Participants &participants); 94 virtual QueryResults Query(int32_t userId, const std::string &bundleName, const std::string &sharingRes); 95 virtual QueryResults QueryByInvitation(int32_t userId, const std::string &bundleName, 96 const std::string &invitation); 97 virtual std::tuple<int32_t, std::string, std::string> ConfirmInvitation(int32_t userId, 98 const std::string &bundleName, const std::string &invitation, int32_t confirmation); 99 virtual std::pair<int32_t, std::string> ChangeConfirmation(int32_t userId, 100 const std::string &bundleName, const std::string &sharingRes, int32_t confirmation); 101 }; 102 } // namespace OHOS::DistributedData 103 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SHARING_CENTER_H 104