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