source: src-qt4/pc-usermanager/user.cpp @ 1620346

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 1620346 was 1620346, checked in by Kris Moore <kris@…>, 16 months ago

Initial import of PC-BSD /current/ SVN repo

  • Property mode set to 100755
File size: 4.0 KB
Line 
1/***************************************************************************
2 *   Copyright (C) 2005, 2012 by Tim McCormick   *
3 *   tim@pcbsd.org   *
4 *                                                                         *
5 *   Permission is hereby granted, free of charge, to any person obtaining *
6 *   a copy of this software and associated documentation files (the       *
7 *   "Software"), to deal in the Software without restriction, including   *
8 *   without limitation the rights to use, copy, modify, merge, publish,   *
9 *   distribute, sublicense, and/or sell copies of the Software, and to    *
10 *   permit persons to whom the Software is furnished to do so, subject to *
11 *   the following conditions:                                             *
12 *                                                                         *
13 *   The above copyright notice and this permission notice shall be        *
14 *   included in all copies or substantial portions of the Software.       *
15 *                                                                         *
16 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
17 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
18 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
20 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
21 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
22 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
23 ***************************************************************************/
24
25#include <unistd.h>
26       
27#include "user.h"
28#include <QDebug>
29
30User::User() {
31    username = "Not set";
32    uid = -1;
33    gid = -1;
34    home = "Not set";
35    shell = "Not set";
36    fullname = "Not set";
37    status = 0;
38    password = "";
39    deleteHome = false;
40}
41
42User::User(QString username, int uid, int gid, QString home, QString shell, QString fullname) {
43    this->username = username;
44    this->uid = uid;
45    this->gid = gid;
46    this->home = home;
47    this->shell = shell;
48    this->fullname = fullname;
49    status = 0;
50    this->password = "";
51}
52
53User::User(QString username, QString home, QString shell, QString fullname, QString password, int gid, bool isNew, int uid)
54{
55    this->username = username;
56    this->home = home;
57    this->shell = shell;
58    this->fullname = fullname;
59    status = 0;
60    if (isNew) { status = 2; }
61    this->uid = uid;
62    this->gid = gid;
63   
64    setPassword(password);
65}
66
67User::~User() {
68   
69}
70
71QString User::getUsername() {
72    return username;
73}
74
75int User::getUid() {
76    return uid;
77}
78
79int User::getGid() {
80    return gid;
81}
82
83QString User::getHome() {
84    return home;
85}
86
87QString User::getShell() {
88    return shell;
89}
90
91QString User::getFullname() {
92    return fullname;
93}
94
95bool User::getChanges() {
96    return status == 1;
97}
98
99void User::setChanges() {
100    if (status == 0) { status = 1; }
101}
102
103void User::setGid(int gid) {
104    this->gid = gid;
105}
106
107void User::setHome(QString home) {
108    this->home = home;
109}
110
111void User::setShell(QString shell) {
112    this->shell = shell;
113}
114
115void User::setFullname(QString fullname) {
116    this->fullname = fullname;
117}
118
119bool User::getNew()
120{
121    return status == 2;
122}
123
124void User::setNew()
125{
126    status = 2;
127}
128
129void User::setPassword(QString password)
130{
131    this->password = crypt(password.toAscii(), "KG");
132    qDebug("Done with crypt now........");
133    setChanges();
134}
135
136QString User::getPassword()
137{
138    return password;
139}
140
141bool User::getDeleted()
142{
143    return status == 3;
144}
145
146void User::setDeleted()
147{
148    status = 3;
149}
150
151uint User::getStatus()
152{
153    return status;
154}
155
156void User::setStatus(uint status)
157{
158    this->status = status;
159}
160
161/**
162 * @param deleteHome is true if the home directory should be deleted
163 */
164void User::setDeleteHome(bool deleteHome)
165{
166    this->deleteHome = deleteHome;
167}
168
169/**
170  * @return true if the home directory should be deleted
171  */
172bool User::getDeleteHome()
173{
174    return deleteHome;
175}
Note: See TracBrowser for help on using the repository browser.