summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controller.cxx5
m---------librtclient0
-rw-r--r--user.cxx168
-rw-r--r--user.hxx126
-rw-r--r--worker.cxx2
-rw-r--r--worker.hxx3
6 files changed, 209 insertions, 95 deletions
diff --git a/controller.cxx b/controller.cxx
index a08e633..9d77cf4 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -1,5 +1,6 @@
#include <QQmlApplicationEngine>
#include "worker.hxx"
+#include "user.hxx"
#include "controller.hxx"
Controller::Controller(QObject* parent) : QObject{parent}
@@ -14,6 +15,10 @@ Controller::Controller(QObject* parent) : QObject{parent}
connect(appWindow, SIGNAL(logIn(QString, QString)),
worker, SLOT(logIn(QString, QString)));
+ auto user = engine->singletonInstance<User*>(User::typeId);
+ connect(worker, SIGNAL(logged(rt_user*))
+ , user, SLOT(update(rt_user*)));
+
thread.start();
}
diff --git a/librtclient b/librtclient
-Subproject 5fe434e35b65a42bc365404a7a6c3436a2a99a8
+Subproject 100c098d55faad03366dffad8572b2d9f75dc93
diff --git a/user.cxx b/user.cxx
index 3762f81..822de61 100644
--- a/user.cxx
+++ b/user.cxx
@@ -1,5 +1,14 @@
+#include "rtclient.h"
#include "user.hxx"
+void User::setId(QString const& id)
+{
+ if (m_id != id) {
+ m_id = id;
+ emit idChanged();
+ }
+}
+
void User::setName(QString const& name)
{
if (m_name != name) {
@@ -24,14 +33,6 @@ void User::setEmailAddress(QString const& emailAddress)
}
}
-void User::setOrganization(QString const& organization)
-{
- if (m_organization != organization) {
- m_organization = organization;
- emit organizationChanged();
- }
-}
-
void User::setRealName(QString const& realName)
{
if (m_realName != realName) {
@@ -48,43 +49,11 @@ void User::setNickName(QString const& nickName)
}
}
-void User::setLang(QString const& lang)
-{
- if (m_lang != lang) {
- m_lang = lang;
- emit langChanged();
- }
-}
-
-void User::setHomePhone(QString const& homePhone)
-{
- if (m_homePhone != homePhone) {
- m_homePhone = homePhone;
- emit homePhoneChanged();
- }
-}
-
-void User::setWorkPhone(QString const& workPhone)
-{
- if (m_workPhone != workPhone) {
- m_workPhone = workPhone;
- emit workPhoneChanged();
- }
-}
-
-void User::setMobilePhone(QString const& mobilePhone)
-{
- if (m_mobilePhone != mobilePhone) {
- m_mobilePhone = mobilePhone;
- emit mobilePhoneChanged();
- }
-}
-
-void User::setPagerPhone(QString const& pagerPhone)
+void User::setOrganization(QString const& organization)
{
- if (m_pagerPhone != pagerPhone) {
- m_pagerPhone = pagerPhone;
- emit pagerPhoneChanged();
+ if (m_organization != organization) {
+ m_organization = organization;
+ emit organizationChanged();
}
}
@@ -136,18 +105,115 @@ void User::setCountry(QString const& country)
}
}
-void User::setTimeZone(QString const& timeZone)
+void User::setHomePhone(QString const& homePhone)
{
- if (m_timeZone != timeZone) {
- m_timeZone = timeZone;
- emit timeZoneChanged();
+ if (m_homePhone != homePhone) {
+ m_homePhone = homePhone;
+ emit homePhoneChanged();
}
}
-void User::setLoggedIn(bool isLoggedIn)
+void User::setWorkPhone(QString const& workPhone)
{
- if (m_isLoggedIn != isLoggedIn) {
- m_isLoggedIn = isLoggedIn;
+ if (m_workPhone != workPhone) {
+ m_workPhone = workPhone;
+ emit workPhoneChanged();
+ }
+}
+
+void User::setMobilePhone(QString const& mobilePhone)
+{
+ if (m_mobilePhone != mobilePhone) {
+ m_mobilePhone = mobilePhone;
+ emit mobilePhoneChanged();
+ }
+}
+
+void User::setPagerPhone(QString const& pagerPhone)
+{
+ if (m_pagerPhone != pagerPhone) {
+ m_pagerPhone = pagerPhone;
+ emit pagerPhoneChanged();
+ }
+}
+
+void User::setLang(QString const& lang)
+{
+ if (m_lang != lang) {
+ m_lang = lang;
+ emit langChanged();
+ }
+}
+
+void User::setPrivileged(bool privileged)
+{
+ if (m_privileged != privileged) {
+ m_privileged = privileged;
+ emit privilegedChanged();
+ }
+}
+
+void User::setDisabled(bool disabled)
+{
+ if (m_disabled != disabled) {
+ m_disabled = disabled;
+ emit disabledChanged();
+ }
+}
+
+void User::setLoggedIn(bool loggedIn)
+{
+ if (m_loggedIn != loggedIn) {
+ m_loggedIn = loggedIn;
emit loggedInChanged();
}
}
+
+void User::update(rt_user* user)
+{
+ if (user) {
+ m_id = user->id;
+ m_emailAddress = user->emailaddress;
+ m_realName = user->realname;
+ m_nickName = user->nickname;
+ m_gecos = user->gecos;
+ m_organization = user->organization;
+ m_address1 = user->address1;
+ m_address2 = user->address2;
+ m_city = user->city;
+ m_state = user->state;
+ m_zip = user->zip;
+ m_country = user->country;
+ m_homePhone = user->homephone;
+ m_workPhone = user->workphone;
+ m_mobilePhone = user->mobilephone;
+ m_pagerPhone = user->pagerphone;
+ m_lang = user->lang;
+ m_privileged = user->privileged;
+ m_disabled = user->disabled;
+ m_loggedIn = true;
+ rtclient_userfree(user);
+ } else {
+ m_id = "";
+ m_name = "";
+ m_password = "";
+ m_emailAddress = "";
+ m_realName = "";
+ m_nickName = "";
+ m_organization = "";
+ m_address1 = "";
+ m_address2 = "";
+ m_city = "";
+ m_state = "";
+ m_zip = "";
+ m_country = "";
+ m_homePhone = "";
+ m_workPhone = "";
+ m_mobilePhone = "";
+ m_pagerPhone = "";
+ m_lang = "";
+ m_privileged = false;
+ m_disabled = true;
+ m_loggedIn = false;
+ }
+}
diff --git a/user.hxx b/user.hxx
index 3bb9b7e..a870852 100644
--- a/user.hxx
+++ b/user.hxx
@@ -6,115 +6,155 @@
class User : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY(QString emailAddress READ emailAddress WRITE setEmailAddress NOTIFY emailAddressChanged)
- Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged)
Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged)
Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
- Q_PROPERTY(QString lang READ lang WRITE setLang NOTIFY langChanged)
- Q_PROPERTY(QString homePhone READ homePhone WRITE setHomePhone NOTIFY homePhoneChanged)
- Q_PROPERTY(QString workPhone READ workPhone WRITE setWorkPhone NOTIFY workPhoneChanged)
- Q_PROPERTY(QString mobilePhone READ mobilePhone WRITE setMobilePhone NOTIFY mobilePhoneChanged)
- Q_PROPERTY(QString pagerPhone READ pagerPhone WRITE setPagerPhone NOTIFY pagerPhoneChanged)
+ Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged)
Q_PROPERTY(QString address1 READ address1 WRITE setAddress1 NOTIFY address1Changed)
Q_PROPERTY(QString address2 READ address2 WRITE setAddress2 NOTIFY address2Changed)
Q_PROPERTY(QString city READ city WRITE setCity NOTIFY cityChanged)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(QString zip READ zip WRITE setZip NOTIFY zipChanged)
Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
- Q_PROPERTY(QString timeZone READ timeZone WRITE setTimeZone NOTIFY timeZoneChanged)
- Q_PROPERTY(bool isLoggedIn READ isLoggedIn WRITE setLoggedIn NOTIFY loggedInChanged)
+ Q_PROPERTY(QString homePhone READ homePhone WRITE setHomePhone NOTIFY homePhoneChanged)
+ Q_PROPERTY(QString workPhone READ workPhone WRITE setWorkPhone NOTIFY workPhoneChanged)
+ Q_PROPERTY(QString mobilePhone READ mobilePhone WRITE setMobilePhone NOTIFY mobilePhoneChanged)
+ Q_PROPERTY(QString pagerPhone READ pagerPhone WRITE setPagerPhone NOTIFY pagerPhoneChanged)
+ Q_PROPERTY(QString lang READ lang WRITE setLang NOTIFY langChanged)
+ Q_PROPERTY(bool privileged READ privileged WRITE setPrivileged NOTIFY privilegedChanged)
+ Q_PROPERTY(bool disabled READ disabled WRITE setDisabled NOTIFY disabledChanged)
+ Q_PROPERTY(bool loggedIn READ loggedIn WRITE setLoggedIn NOTIFY loggedInChanged)
public:
- explicit User(bool isLoggedIn = false, QObject* parent = nullptr) :
- QObject{parent},
- m_isLoggedIn{isLoggedIn}
- {}
+ explicit User(QObject* parent = nullptr)
+ : QObject{parent}
+ , m_id{""}
+ , m_name{""}
+ , m_password{""}
+ , m_emailAddress{""}
+ , m_realName{""}
+ , m_nickName{""}
+ , m_organization{""}
+ , m_gecos{""}
+ , m_address1{""}
+ , m_address2{""}
+ , m_city{""}
+ , m_state{""}
+ , m_zip{""}
+ , m_country{""}
+ , m_homePhone{""}
+ , m_workPhone{""}
+ , m_mobilePhone{""}
+ , m_pagerPhone{""}
+ , m_contactInfo{""}
+ , m_comments{""}
+ , m_lang{""}
+ , m_privileged{false}
+ , m_disabled{true}
+ , m_loggedIn{false}
+ {}
~User() {}
inline static int typeId;
+ QString const& id() const { return m_id; }
QString const& name() const { return m_name; }
QString const& password() const { return m_password; }
QString const& emailAddress() const { return m_emailAddress; }
- QString const& organization() const { return m_organization; }
QString const& realName() const { return m_realName; }
QString const& nickName() const { return m_nickName; }
- QString const& lang() const { return m_lang; }
- QString const& homePhone() const { return m_homePhone; }
- QString const& workPhone() const { return m_workPhone; }
- QString const& mobilePhone() const { return m_mobilePhone; }
- QString const& pagerPhone() const { return m_pagerPhone; }
+ QString const& organization() const { return m_organization; }
QString const& address1() const { return m_address1; }
QString const& address2() const { return m_address2; }
QString const& city() const { return m_city; }
QString const& state() const { return m_state; }
QString const& zip() const { return m_zip; }
QString const& country() const { return m_country; }
- QString const& timeZone() const { return m_timeZone; }
- bool isLoggedIn() const { return m_isLoggedIn; }
+ QString const& homePhone() const { return m_homePhone; }
+ QString const& workPhone() const { return m_workPhone; }
+ QString const& mobilePhone() const { return m_mobilePhone; }
+ QString const& pagerPhone() const { return m_pagerPhone; }
+ QString const& lang() const { return m_lang; }
+ bool privileged() const { return m_privileged; }
+ bool disabled() const { return m_disabled; }
+ bool loggedIn() const { return m_loggedIn; }
+ void setId(QString const& id);
void setName(QString const& name);
void setPassword(QString const& password);
void setEmailAddress(QString const& emailAddress);
- void setOrganization(QString const& organization);
void setRealName(QString const& realName);
void setNickName(QString const& nickName);
- void setLang(QString const& lang);
- void setHomePhone(QString const& homePhone);
- void setWorkPhone(QString const& workPhone);
- void setMobilePhone(QString const& mobilePhone);
- void setPagerPhone(QString const& pagerPhone);
+ void setOrganization(QString const& organization);
void setAddress1(QString const& address1);
void setAddress2(QString const& address2);
void setCity(QString const& city);
void setState(QString const& state);
void setZip(QString const& zip);
void setCountry(QString const& country);
- void setTimeZone(QString const& timeZone);
- void setLoggedIn(bool isLoggedIn);
+ void setHomePhone(QString const& homePhone);
+ void setWorkPhone(QString const& workPhone);
+ void setMobilePhone(QString const& mobilePhone);
+ void setPagerPhone(QString const& pagerPhone);
+ void setLang(QString const& lang);
+ void setPrivileged(bool privileged);
+ void setDisabled(bool disabled);
+ void setLoggedIn(bool loggedIn);
signals:
+ void idChanged();
void nameChanged();
void passwordChanged();
void emailAddressChanged();
- void organizationChanged();
void realNameChanged();
void nickNameChanged();
- void langChanged();
- void homePhoneChanged();
- void workPhoneChanged();
- void mobilePhoneChanged();
- void pagerPhoneChanged();
+ void organizationChanged();
+ void gecosChanged();
void address1Changed();
void address2Changed();
void cityChanged();
void stateChanged();
void zipChanged();
void countryChanged();
- void timeZoneChanged();
+ void homePhoneChanged();
+ void workPhoneChanged();
+ void mobilePhoneChanged();
+ void pagerPhoneChanged();
+ void langChanged();
+ void privilegedChanged();
+ void disabledChanged();
void loggedInChanged();
+ private slots:
+ void update(struct rt_user* user);
+
private:
+ QString m_id;
QString m_name;
QString m_password;
QString m_emailAddress;
- QString m_organization;
QString m_realName;
QString m_nickName;
- QString m_lang;
- QString m_homePhone;
- QString m_workPhone;
- QString m_mobilePhone;
- QString m_pagerPhone;
+ QString m_organization;
+ QString m_gecos;
QString m_address1;
QString m_address2;
QString m_city;
QString m_state;
QString m_zip;
QString m_country;
- QString m_timeZone;
- bool m_isLoggedIn;
+ QString m_homePhone;
+ QString m_workPhone;
+ QString m_mobilePhone;
+ QString m_pagerPhone;
+ QString m_contactInfo;
+ QString m_comments;
+ QString m_lang;
+ bool m_privileged;
+ bool m_disabled;
+ bool m_loggedIn;
};
#endif // USER_HXX
diff --git a/worker.cxx b/worker.cxx
index bdb29e0..d5d3197 100644
--- a/worker.cxx
+++ b/worker.cxx
@@ -11,7 +11,7 @@ void Worker::logIn(QString const& name, QString const& password)
rtclient_login(name.toLatin1().constData(), password.toLatin1().constData());
struct rt_user *user = NULL;
rtclient_userget(&user, name.toLatin1().constData());
- if (user) rtclient_userfree(user);
+ if (user) emit logged(user);
}
void Worker::search(QString const& owner)
diff --git a/worker.hxx b/worker.hxx
index 130d1c6..c406db9 100644
--- a/worker.hxx
+++ b/worker.hxx
@@ -14,6 +14,9 @@ class Worker : public QObject
public slots:
void logIn(QString const& name, QString const& password);
void search(QString const& owner);
+
+ signals:
+ void logged(struct rt_user* user);
};
#endif // WORKER_HXX