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