From 5607c8dbc6ba69f17b12579f7aad8cb028e33ce4 Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 15:41:40 +0800 Subject: Made the user class members more straightforward using rtclient's rt_user members. --- user.cxx | 127 ++++++++++++++++++++++++++------------------------------------- user.hxx | 57 ++++++++++------------------ 2 files changed, 71 insertions(+), 113 deletions(-) diff --git a/user.cxx b/user.cxx index 0983874..76b44e1 100644 --- a/user.cxx +++ b/user.cxx @@ -1,179 +1,156 @@ +#include #include "rtuser.h" #include "user.hxx" -void User::update(rt_user* user) -{ - if (m_isLoggedIn) { - setName(QString{user->name}); - setEmailAddress(QString{user->emailaddress}); - setOrganization(QString{user->organization}); - setRealName(QString{user->realname}); - setNickName(QString{user->nickname}); - setLang(QString{user->lang}); - setHomePhone(QString{user->homephone}); - setWorkPhone(QString{user->workphone}); - setMobilePhone(QString{user->mobilephone}); - setPagerPhone(QString{user->pagerphone}); - setAddress1(QString{user->address1}); - setAddress2(QString{user->address2}); - setCity(QString{user->city}); - setState(QString{user->state}); - setZip(QString{user->zip}); - setCountry(QString{user->country}); - setTimeZone(QString{user->timezone}); - } else { - setName(""); - setEmailAddress(""); - setOrganization(""); - setRealName(""); - setNickName(""); - setLang(""); - setHomePhone(""); - setWorkPhone(""); - setMobilePhone(""); - setPagerPhone(""); - setAddress1(""); - setAddress2(""); - setCity(""); - setState(""); - setZip(""); - setCountry(""); - setTimeZone(""); - } -} - void User::setName(QString const& name) { - if (m_name != name) { - m_name = name; + auto c_name = name.toUtf8().constData(); + if (strcmp(m_user.name, c_name)) { + strcpy(m_user.name, c_name); emit nameChanged(); } } void User::setEmailAddress(QString const& emailAddress) { - if (m_emailAddress != emailAddress) { - m_emailAddress = emailAddress; + auto c_emailAddress = emailAddress.toUtf8().constData(); + if (strcmp(m_user.emailaddress, c_emailAddress)) { + strcpy(m_user.emailaddress, c_emailAddress); emit emailAddressChanged(); } } void User::setOrganization(QString const& organization) { - if (m_organization != organization) { - m_organization = organization; + auto c_organization = organization.toUtf8().constData(); + if (strcmp(m_user.organization, c_organization)) { + strcpy(m_user.organization, c_organization); emit organizationChanged(); } } void User::setRealName(QString const& realName) { - if (m_realName != realName) { - m_realName = realName; + auto c_realName = realName.toUtf8().constData(); + if (strcmp(m_user.realname, c_realName)) { + strcpy(m_user.realname, c_realName); emit realNameChanged(); } } void User::setNickName(QString const& nickName) { - if (m_nickName != nickName) { - m_nickName = nickName; + auto c_nickName = nickName.toUtf8().constData(); + if (strcmp(m_user.nickname, c_nickName)) { + strcpy(m_user.nickname, c_nickName); emit nickNameChanged(); } } void User::setLang(QString const& lang) { - if (m_lang != lang) { - m_lang = lang; + auto c_lang = lang.toUtf8().constData(); + if (strcmp(m_user.lang, c_lang)) { + strcpy(m_user.lang, c_lang); emit langChanged(); } } void User::setHomePhone(QString const& homePhone) { - if (m_homePhone != homePhone) { - m_homePhone = homePhone; + auto c_homePhone = homePhone.toUtf8().constData(); + if (strcmp(m_user.homephone, c_homePhone)) { + strcpy(m_user.homephone, c_homePhone); emit homePhoneChanged(); } } void User::setWorkPhone(QString const& workPhone) { - if (m_workPhone != workPhone) { - m_workPhone = workPhone; + auto c_workPhone = workPhone.toUtf8().constData(); + if (strcmp(m_user.workphone, c_workPhone)) { + strcpy(m_user.workphone, c_workPhone); emit workPhoneChanged(); } } void User::setMobilePhone(QString const& mobilePhone) { - if (m_mobilePhone != mobilePhone) { - m_mobilePhone = mobilePhone; + auto c_mobilePhone = mobilePhone.toUtf8().constData(); + if (strcmp(m_user.mobilephone, c_mobilePhone)) { + strcpy(m_user.mobilephone, c_mobilePhone); emit mobilePhoneChanged(); } } void User::setPagerPhone(QString const& pagerPhone) { - if (m_pagerPhone != pagerPhone) { - m_pagerPhone = pagerPhone; + auto c_pagerPhone = pagerPhone.toUtf8().constData(); + if (strcmp(m_user.pagerphone, c_pagerPhone)) { + strcpy(m_user.pagerphone, c_pagerPhone); emit pagerPhoneChanged(); } } void User::setAddress1(QString const& address1) { - if (m_address1 != address1) { - m_address1 = address1; + auto c_address1 = address1.toUtf8().constData(); + if (strcmp(m_user.address1, c_address1)) { + strcpy(m_user.address1, c_address1); emit address1Changed(); } } void User::setAddress2(QString const& address2) { - if (m_address2 != address2) { - m_address2 = address2; + auto c_address2 = address2.toUtf8().constData(); + if (strcmp(m_user.address2, c_address2)) { + strcpy(m_user.address2, c_address2); emit address2Changed(); } } void User::setCity(QString const& city) { - if (m_city != city) { - m_city = city; + auto c_city = city.toUtf8().constData(); + if (strcmp(m_user.city, c_city)) { + strcpy(m_user.city, c_city); emit cityChanged(); } } void User::setState(QString const& state) { - if (m_state != state) { - m_state = state; + auto c_state = state.toUtf8().constData(); + if (strcmp(m_user.state, c_state)) { + strcpy(m_user.state, c_state); emit stateChanged(); } } void User::setZip(QString const& zip) { - if (m_zip != zip) { - m_zip = zip; + auto c_zip = zip.toUtf8().constData(); + if (strcmp(m_user.zip, c_zip)) { + strcpy(m_user.zip, c_zip); emit zipChanged(); } } void User::setCountry(QString const& country) { - if (m_country != country) { - m_country = country; + auto c_country = country.toUtf8().constData(); + if (strcmp(m_user.country, c_country)) { + strcpy(m_user.country, c_country); emit countryChanged(); } } void User::setTimeZone(QString const& timeZone) { - if (m_timeZone != timeZone) { - m_timeZone = timeZone; + auto c_timeZone = timeZone.toUtf8().constData(); + if (strcmp(m_user.timezone, c_timeZone)) { + strcpy(m_user.timezone, c_timeZone); emit timeZoneChanged(); } } diff --git a/user.hxx b/user.hxx index 1cac5fe..98d5f68 100644 --- a/user.hxx +++ b/user.hxx @@ -2,8 +2,7 @@ #define USER_HXX #include - -struct rt_user; +#include "rtuser.h" class User : public QObject { @@ -34,25 +33,23 @@ class User : public QObject {} ~User() {} - Q_INVOKABLE void update(rt_user* user); - - QString const& name() const { return m_name; } - 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& 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; } + QString const name() const { return QString{m_user.name}; } + QString const emailAddress() const { return QString{m_user.emailaddress}; } + QString const organization() const { return QString{m_user.organization}; } + QString const realName() const { return QString{m_user.realname}; } + QString const nickName() const { return QString{m_user.nickname}; } + QString const lang() const { return QString{m_user.lang}; } + QString const homePhone() const { return QString{m_user.homephone}; } + QString const workPhone() const { return QString{m_user.workphone}; } + QString const mobilePhone() const { return QString{m_user.mobilephone}; } + QString const pagerPhone() const { return QString{m_user.pagerphone}; } + QString const address1() const { return QString{m_user.address1}; } + QString const address2() const { return QString{m_user.address2}; } + QString const city() const { return QString{m_user.city}; } + QString const state() const { return QString{m_user.state}; } + QString const zip() const { return QString{m_user.zip}; } + QString const country() const { return QString{m_user.country}; } + QString const timeZone() const { return QString{m_user.timezone}; } bool isLoggedIn() const { return m_isLoggedIn; } void setName(QString const& name); @@ -95,23 +92,7 @@ class User : public QObject void loggedInChanged(); private: - QString m_name; - 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_address1; - QString m_address2; - QString m_city; - QString m_state; - QString m_zip; - QString m_country; - QString m_timeZone; + rt_user m_user; bool m_isLoggedIn; }; -- cgit v1.2.3 From b4f44ef2d55f42764fb599e67680f5f45bf7f20c Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 16:22:54 +0800 Subject: Revert "Made the user class members more straightforward" This reverts commit 5607c8dbc6ba69f17b12579f7aad8cb028e33ce4. On second thought, for now we don't need to use rtclient's user struct yet, to be more memory efficient with the members QString instantiations. --- user.cxx | 127 +++++++++++++++++++++++++++++++++++++-------------------------- user.hxx | 57 ++++++++++++++++++---------- 2 files changed, 113 insertions(+), 71 deletions(-) diff --git a/user.cxx b/user.cxx index 76b44e1..0983874 100644 --- a/user.cxx +++ b/user.cxx @@ -1,156 +1,179 @@ -#include #include "rtuser.h" #include "user.hxx" +void User::update(rt_user* user) +{ + if (m_isLoggedIn) { + setName(QString{user->name}); + setEmailAddress(QString{user->emailaddress}); + setOrganization(QString{user->organization}); + setRealName(QString{user->realname}); + setNickName(QString{user->nickname}); + setLang(QString{user->lang}); + setHomePhone(QString{user->homephone}); + setWorkPhone(QString{user->workphone}); + setMobilePhone(QString{user->mobilephone}); + setPagerPhone(QString{user->pagerphone}); + setAddress1(QString{user->address1}); + setAddress2(QString{user->address2}); + setCity(QString{user->city}); + setState(QString{user->state}); + setZip(QString{user->zip}); + setCountry(QString{user->country}); + setTimeZone(QString{user->timezone}); + } else { + setName(""); + setEmailAddress(""); + setOrganization(""); + setRealName(""); + setNickName(""); + setLang(""); + setHomePhone(""); + setWorkPhone(""); + setMobilePhone(""); + setPagerPhone(""); + setAddress1(""); + setAddress2(""); + setCity(""); + setState(""); + setZip(""); + setCountry(""); + setTimeZone(""); + } +} + void User::setName(QString const& name) { - auto c_name = name.toUtf8().constData(); - if (strcmp(m_user.name, c_name)) { - strcpy(m_user.name, c_name); + if (m_name != name) { + m_name = name; emit nameChanged(); } } void User::setEmailAddress(QString const& emailAddress) { - auto c_emailAddress = emailAddress.toUtf8().constData(); - if (strcmp(m_user.emailaddress, c_emailAddress)) { - strcpy(m_user.emailaddress, c_emailAddress); + if (m_emailAddress != emailAddress) { + m_emailAddress = emailAddress; emit emailAddressChanged(); } } void User::setOrganization(QString const& organization) { - auto c_organization = organization.toUtf8().constData(); - if (strcmp(m_user.organization, c_organization)) { - strcpy(m_user.organization, c_organization); + if (m_organization != organization) { + m_organization = organization; emit organizationChanged(); } } void User::setRealName(QString const& realName) { - auto c_realName = realName.toUtf8().constData(); - if (strcmp(m_user.realname, c_realName)) { - strcpy(m_user.realname, c_realName); + if (m_realName != realName) { + m_realName = realName; emit realNameChanged(); } } void User::setNickName(QString const& nickName) { - auto c_nickName = nickName.toUtf8().constData(); - if (strcmp(m_user.nickname, c_nickName)) { - strcpy(m_user.nickname, c_nickName); + if (m_nickName != nickName) { + m_nickName = nickName; emit nickNameChanged(); } } void User::setLang(QString const& lang) { - auto c_lang = lang.toUtf8().constData(); - if (strcmp(m_user.lang, c_lang)) { - strcpy(m_user.lang, c_lang); + if (m_lang != lang) { + m_lang = lang; emit langChanged(); } } void User::setHomePhone(QString const& homePhone) { - auto c_homePhone = homePhone.toUtf8().constData(); - if (strcmp(m_user.homephone, c_homePhone)) { - strcpy(m_user.homephone, c_homePhone); + if (m_homePhone != homePhone) { + m_homePhone = homePhone; emit homePhoneChanged(); } } void User::setWorkPhone(QString const& workPhone) { - auto c_workPhone = workPhone.toUtf8().constData(); - if (strcmp(m_user.workphone, c_workPhone)) { - strcpy(m_user.workphone, c_workPhone); + if (m_workPhone != workPhone) { + m_workPhone = workPhone; emit workPhoneChanged(); } } void User::setMobilePhone(QString const& mobilePhone) { - auto c_mobilePhone = mobilePhone.toUtf8().constData(); - if (strcmp(m_user.mobilephone, c_mobilePhone)) { - strcpy(m_user.mobilephone, c_mobilePhone); + if (m_mobilePhone != mobilePhone) { + m_mobilePhone = mobilePhone; emit mobilePhoneChanged(); } } void User::setPagerPhone(QString const& pagerPhone) { - auto c_pagerPhone = pagerPhone.toUtf8().constData(); - if (strcmp(m_user.pagerphone, c_pagerPhone)) { - strcpy(m_user.pagerphone, c_pagerPhone); + if (m_pagerPhone != pagerPhone) { + m_pagerPhone = pagerPhone; emit pagerPhoneChanged(); } } void User::setAddress1(QString const& address1) { - auto c_address1 = address1.toUtf8().constData(); - if (strcmp(m_user.address1, c_address1)) { - strcpy(m_user.address1, c_address1); + if (m_address1 != address1) { + m_address1 = address1; emit address1Changed(); } } void User::setAddress2(QString const& address2) { - auto c_address2 = address2.toUtf8().constData(); - if (strcmp(m_user.address2, c_address2)) { - strcpy(m_user.address2, c_address2); + if (m_address2 != address2) { + m_address2 = address2; emit address2Changed(); } } void User::setCity(QString const& city) { - auto c_city = city.toUtf8().constData(); - if (strcmp(m_user.city, c_city)) { - strcpy(m_user.city, c_city); + if (m_city != city) { + m_city = city; emit cityChanged(); } } void User::setState(QString const& state) { - auto c_state = state.toUtf8().constData(); - if (strcmp(m_user.state, c_state)) { - strcpy(m_user.state, c_state); + if (m_state != state) { + m_state = state; emit stateChanged(); } } void User::setZip(QString const& zip) { - auto c_zip = zip.toUtf8().constData(); - if (strcmp(m_user.zip, c_zip)) { - strcpy(m_user.zip, c_zip); + if (m_zip != zip) { + m_zip = zip; emit zipChanged(); } } void User::setCountry(QString const& country) { - auto c_country = country.toUtf8().constData(); - if (strcmp(m_user.country, c_country)) { - strcpy(m_user.country, c_country); + if (m_country != country) { + m_country = country; emit countryChanged(); } } void User::setTimeZone(QString const& timeZone) { - auto c_timeZone = timeZone.toUtf8().constData(); - if (strcmp(m_user.timezone, c_timeZone)) { - strcpy(m_user.timezone, c_timeZone); + if (m_timeZone != timeZone) { + m_timeZone = timeZone; emit timeZoneChanged(); } } diff --git a/user.hxx b/user.hxx index 98d5f68..1cac5fe 100644 --- a/user.hxx +++ b/user.hxx @@ -2,7 +2,8 @@ #define USER_HXX #include -#include "rtuser.h" + +struct rt_user; class User : public QObject { @@ -33,23 +34,25 @@ class User : public QObject {} ~User() {} - QString const name() const { return QString{m_user.name}; } - QString const emailAddress() const { return QString{m_user.emailaddress}; } - QString const organization() const { return QString{m_user.organization}; } - QString const realName() const { return QString{m_user.realname}; } - QString const nickName() const { return QString{m_user.nickname}; } - QString const lang() const { return QString{m_user.lang}; } - QString const homePhone() const { return QString{m_user.homephone}; } - QString const workPhone() const { return QString{m_user.workphone}; } - QString const mobilePhone() const { return QString{m_user.mobilephone}; } - QString const pagerPhone() const { return QString{m_user.pagerphone}; } - QString const address1() const { return QString{m_user.address1}; } - QString const address2() const { return QString{m_user.address2}; } - QString const city() const { return QString{m_user.city}; } - QString const state() const { return QString{m_user.state}; } - QString const zip() const { return QString{m_user.zip}; } - QString const country() const { return QString{m_user.country}; } - QString const timeZone() const { return QString{m_user.timezone}; } + Q_INVOKABLE void update(rt_user* user); + + QString const& name() const { return m_name; } + 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& 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; } void setName(QString const& name); @@ -92,7 +95,23 @@ class User : public QObject void loggedInChanged(); private: - rt_user m_user; + QString m_name; + 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_address1; + QString m_address2; + QString m_city; + QString m_state; + QString m_zip; + QString m_country; + QString m_timeZone; bool m_isLoggedIn; }; -- cgit v1.2.3 From b15e02739052557480bc272920f251cc4eed00b0 Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 16:26:03 +0800 Subject: Affirming the previous commit --- user.cxx | 42 ------------------------------------------ user.hxx | 4 ---- 2 files changed, 46 deletions(-) diff --git a/user.cxx b/user.cxx index 0983874..3da2c33 100644 --- a/user.cxx +++ b/user.cxx @@ -1,47 +1,5 @@ -#include "rtuser.h" #include "user.hxx" -void User::update(rt_user* user) -{ - if (m_isLoggedIn) { - setName(QString{user->name}); - setEmailAddress(QString{user->emailaddress}); - setOrganization(QString{user->organization}); - setRealName(QString{user->realname}); - setNickName(QString{user->nickname}); - setLang(QString{user->lang}); - setHomePhone(QString{user->homephone}); - setWorkPhone(QString{user->workphone}); - setMobilePhone(QString{user->mobilephone}); - setPagerPhone(QString{user->pagerphone}); - setAddress1(QString{user->address1}); - setAddress2(QString{user->address2}); - setCity(QString{user->city}); - setState(QString{user->state}); - setZip(QString{user->zip}); - setCountry(QString{user->country}); - setTimeZone(QString{user->timezone}); - } else { - setName(""); - setEmailAddress(""); - setOrganization(""); - setRealName(""); - setNickName(""); - setLang(""); - setHomePhone(""); - setWorkPhone(""); - setMobilePhone(""); - setPagerPhone(""); - setAddress1(""); - setAddress2(""); - setCity(""); - setState(""); - setZip(""); - setCountry(""); - setTimeZone(""); - } -} - void User::setName(QString const& name) { if (m_name != name) { diff --git a/user.hxx b/user.hxx index 1cac5fe..36ade7e 100644 --- a/user.hxx +++ b/user.hxx @@ -3,8 +3,6 @@ #include -struct rt_user; - class User : public QObject { Q_OBJECT @@ -34,8 +32,6 @@ class User : public QObject {} ~User() {} - Q_INVOKABLE void update(rt_user* user); - QString const& name() const { return m_name; } QString const& emailAddress() const { return m_emailAddress; } QString const& organization() const { return m_organization; } -- cgit v1.2.3 From 014d9ca7e0cdc1ef4b633a28ba9befddb2951179 Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 16:43:48 +0800 Subject: User password member --- pages/Password.qml | 6 ++++++ user.cxx | 8 ++++++++ user.hxx | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/pages/Password.qml b/pages/Password.qml index 7cd3d16..0edb294 100644 --- a/pages/Password.qml +++ b/pages/Password.qml @@ -9,4 +9,10 @@ PasswordForm { stackView.pop() } } + + createPassButton { + onClicked: { + User.password = passTextField.text + } + } } diff --git a/user.cxx b/user.cxx index 3da2c33..3762f81 100644 --- a/user.cxx +++ b/user.cxx @@ -8,6 +8,14 @@ void User::setName(QString const& name) } } +void User::setPassword(QString const& password) +{ + if (m_password != password) { + m_password = password; + emit passwordChanged(); + } +} + void User::setEmailAddress(QString const& emailAddress) { if (m_emailAddress != emailAddress) { diff --git a/user.hxx b/user.hxx index 36ade7e..68abbc7 100644 --- a/user.hxx +++ b/user.hxx @@ -7,6 +7,7 @@ class User : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name) + 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) @@ -33,6 +34,7 @@ class User : public QObject ~User() {} 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; } @@ -52,6 +54,7 @@ class User : public QObject bool isLoggedIn() const { return m_isLoggedIn; } 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); @@ -72,6 +75,7 @@ class User : public QObject signals: void nameChanged(); + void passwordChanged(); void emailAddressChanged(); void organizationChanged(); void realNameChanged(); @@ -92,6 +96,7 @@ class User : public QObject private: QString m_name; + QString m_password; QString m_emailAddress; QString m_organization; QString m_realName; -- cgit v1.2.3 From 2235e4736994ae902e6cff167c5550168c0a37bb Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 16:44:05 +0800 Subject: Made user name editable --- user.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user.hxx b/user.hxx index 68abbc7..18dd176 100644 --- a/user.hxx +++ b/user.hxx @@ -6,7 +6,7 @@ class User : public QObject { Q_OBJECT - Q_PROPERTY(QString name READ name) + 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) -- cgit v1.2.3 From 07c432faf992781868f4d24b417c9cabb52a33d5 Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 18:53:52 +0800 Subject: Managed to post login credentials to the RT server For now, it's just to get a response --- controller.cxx | 6 ++++++ controller.hxx | 4 ++++ main.cxx | 11 ++++++----- pages/Password.qml | 2 ++ rtclient | 2 +- worker.cxx | 5 +++++ worker.hxx | 4 ++++ 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/controller.cxx b/controller.cxx index d1271b9..015d4ac 100644 --- a/controller.cxx +++ b/controller.cxx @@ -6,9 +6,15 @@ Controller::Controller() Worker* worker = new Worker{}; worker->moveToThread(&thread); connect(&thread, &QThread::finished, worker, &QObject::deleteLater); + connect(this, &Controller::credentialsObtained, worker, &Worker::logIn); thread.start(); } +void Controller::logIn(QString const& name, QString const& password) +{ + emit credentialsObtained(name, password); +} + Controller::~Controller() { thread.quit(); diff --git a/controller.hxx b/controller.hxx index e293ec4..8b98328 100644 --- a/controller.hxx +++ b/controller.hxx @@ -10,6 +10,10 @@ class Controller : public QObject public: Controller(); ~Controller(); + Q_INVOKABLE void logIn(QString const& name, QString const& password); + + signals: + void credentialsObtained(QString const& name, QString const& password); private: QThread thread; diff --git a/main.cxx b/main.cxx index 0b52736..a29e917 100644 --- a/main.cxx +++ b/main.cxx @@ -12,13 +12,14 @@ int main(int argc, char* argv[]) qmlRegisterSingletonType("id.co.darapsa.kelakon.user", 0, 1, "User", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) - - User* user = new User{}; - return user; + return new User{}; + }); + qmlRegisterSingletonType("id.co.darapsa.kelakon.rtclient", 0, 1, "RTClient", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + return new Controller{}; }); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - Controller controller{}; - return app.exec(); } diff --git a/pages/Password.qml b/pages/Password.qml index 0edb294..a499a65 100644 --- a/pages/Password.qml +++ b/pages/Password.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import id.co.darapsa.kelakon.user 0.1 +import id.co.darapsa.kelakon.rtclient 0.1 PasswordForm { width: stackView.width @@ -13,6 +14,7 @@ PasswordForm { createPassButton { onClicked: { User.password = passTextField.text + RTClient.logIn(User.emailAddress, User.password) } } } diff --git a/rtclient b/rtclient index 89cd9ab..16b8e66 160000 --- a/rtclient +++ b/rtclient @@ -1 +1 @@ -Subproject commit 89cd9ab12cb2aa09f92e312cd0418a036dc0ed8d +Subproject commit 16b8e66c64ee8acd6ea2ce34372e52406a990d2a diff --git a/worker.cxx b/worker.cxx index 8c915f8..19ae358 100644 --- a/worker.cxx +++ b/worker.cxx @@ -7,6 +7,11 @@ Worker::Worker(QObject* parent) : rtclient_init(); } +void Worker::logIn(QString const& name, QString const& password) +{ + rtclient_login(name.toLatin1().constData(), password.toLatin1().constData()); +} + Worker::~Worker() { rtclient_cleanup(); diff --git a/worker.hxx b/worker.hxx index cdb2811..660361e 100644 --- a/worker.hxx +++ b/worker.hxx @@ -6,9 +6,13 @@ class Worker : public QObject { Q_OBJECT + public: explicit Worker(QObject* parent = nullptr); virtual ~Worker(); + + public slots: + void logIn(QString const& name, QString const& password); }; #endif // WORKER_HXX -- cgit v1.2.3 From 19ebf9e75257adc89a3d43076f8404c87b1d0c60 Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 30 Aug 2019 21:22:37 +0800 Subject: Renamed the rtclient project to librtclient --- .gitmodules | 6 +++--- kelakon.pro | 4 ++-- librtclient | 1 + rtclient | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) create mode 160000 librtclient delete mode 160000 rtclient diff --git a/.gitmodules b/.gitmodules index 4897f3d..8a122f9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "rtclient"] - path = rtclient - url = git@github.com:darapsa/rtclient.git +[submodule "librtclient"] + path = librtclient + url = git@github.com:darapsa/librtclient.git diff --git a/kelakon.pro b/kelakon.pro index 5df2f8e..f747fb5 100644 --- a/kelakon.pro +++ b/kelakon.pro @@ -17,10 +17,10 @@ SOURCES += \ RESOURCES += kelakon.qrc -INCLUDEPATH += $$PWD/rtclient +INCLUDEPATH += $$PWD/librtclient LIBS += \ - $$PWD/rtclient/librtclient.a \ + $$PWD/librtclient/librtclient.a \ -lcurl contains(ANDROID_TARGET_ARCH,arm64-v8a) { diff --git a/librtclient b/librtclient new file mode 160000 index 0000000..16b8e66 --- /dev/null +++ b/librtclient @@ -0,0 +1 @@ +Subproject commit 16b8e66c64ee8acd6ea2ce34372e52406a990d2a diff --git a/rtclient b/rtclient deleted file mode 160000 index 16b8e66..0000000 --- a/rtclient +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 16b8e66c64ee8acd6ea2ce34372e52406a990d2a -- cgit v1.2.3