• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H
17 #define OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H
18 #include <ctime>
19 #include <vector>
20 #include "iaccount_info.h"
21 #include "parcel.h"
22 namespace OHOS {
23 namespace AccountSA {
24 typedef enum {
25     ADMIN = 0,
26     NORMAL,
27     GUEST,
28     END, // the upper bound of OsAccountType.
29 } OsAccountType;
30 
31 typedef enum {
32     CONSTRAINT_NOT_EXIST = 0,
33     CONSTRAINT_TYPE_BASE,
34     CONSTRAINT_TYPE_DEVICE_OWNER,
35     CONSTRAINT_TYPE_PROFILE_OWNER,
36 } ConstraintSourceType;
37 
38 struct ConstraintSourceTypeInfo {
39     int32_t localId;
40     ConstraintSourceType typeInfo;
41 };
42 
43 class DomainAccountInfo {
44 public:
DomainAccountInfo()45     DomainAccountInfo()
46         : domain_(""), accountName_("")
47     {}
48 
DomainAccountInfo(const std::string & domain,const std::string & domainAccountName)49     DomainAccountInfo(const std::string &domain, const std::string &domainAccountName)
50         : domain_(domain), accountName_(domainAccountName)
51     {}
52 
Clear()53     void Clear()
54     {
55         domain_.clear();
56         accountName_.clear();
57     }
58     std::string domain_;
59     std::string accountName_;
60 };
61 
62 class OsAccountInfo : public IAccountInfo, public Parcelable {
63 public:
64     OsAccountInfo();
65 
66     OsAccountInfo(int localId, const std::string localName, OsAccountType type, int64_t serialNumber);
67 
68     OsAccountInfo(int localId, std::string localName, OsAccountType type, std::vector<std::string> constraints,
69         bool isVerified, std::string photo, int64_t createTime, int64_t lastLoginTime, int64_t serialNumber,
70         bool isCreateCompleted);
71 
72     int GetLocalId() const;
73 
74     void SetLocalId(int localId);
75 
76     std::string GetLocalName() const;
77 
78     void SetLocalName(const std::string localName);
79 
80     OsAccountType GetType() const;
81 
82     void SetType(OsAccountType type);
83 
84     std::vector<std::string> GetConstraints() const;
85 
86     void SetConstraints(const std::vector<std::string> constraints);
87 
88     bool GetIsVerified() const;
89 
90     void SetIsVerified(bool isVerified);
91 
92     std::string GetPhoto() const;
93 
94     void SetPhoto(const std::string photo);
95 
96     int64_t GetCreateTime() const;
97 
98     void SetCreateTime(const int64_t createTime);
99 
100     int64_t GetLastLoginTime() const;
101 
102     void SetLastLoginTime(const int64_t lastLoginTime);
103 
104     Json ToJson() const override;
105 
106     void FromJson(const Json &jsonObject) override;
107 
108     bool Marshalling(Parcel &parcel) const override;
109 
110     bool ReadFromParcel(Parcel &parcel);
111 
112     std::string ToString() const override;
113 
114     std::string GetPrimeKey() const override;
115 
116     static OsAccountInfo *Unmarshalling(Parcel &parcel);
117 
118     int64_t GetSerialNumber() const;
119 
120     void SetSerialNumber(const int64_t serialNumber);
121 
122     bool GetIsActived() const;
123 
124     void SetIsActived(const bool isActived);
125 
126     bool GetIsCreateCompleted() const;
127 
128     void SetIsCreateCompleted(const bool isCreateCompleted);
129 
130     bool SetDomainInfo(const DomainAccountInfo &domainInfo);
131 
132     void GetDomainInfo(DomainAccountInfo &domainInfo) const;
133 
134     bool GetToBeRemoved() const;
135 
136     void SetToBeRemoved(bool toBeRemoved);
137 
138 private:
139     int localId_;
140     std::string localName_;
141     OsAccountType type_;
142     std::vector<std::string> constraints_;
143     bool isVerified_;
144     std::string photo_;
145     int64_t createTime_;
146     int64_t lastLoginTime_;
147     int64_t serialNumber_;
148     bool isActived_;
149     bool isCreateCompleted_;
150     DomainAccountInfo domainInfo_;
151     bool toBeRemoved_;
152 };
153 typedef enum {
154     ERROR_MOD = 0,
155     HOT_SWITCH,
156     COLD_SWITCH,
157 } OS_ACCOUNT_SWITCH_MOD;
158 }  // namespace AccountSA
159 }  // namespace OHOS
160 
161 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H
162