diff options
-rw-r--r-- | .gitmodules | 6 | ||||
-rw-r--r-- | controller.cxx | 6 | ||||
-rw-r--r-- | controller.hxx | 4 | ||||
-rw-r--r-- | kelakon.pro | 4 | ||||
m--------- | librtclient | 0 | ||||
-rw-r--r-- | main.cxx | 11 | ||||
-rw-r--r-- | pages/Password.qml | 8 | ||||
m--------- | rtclient | 0 | ||||
-rw-r--r-- | user.cxx | 50 | ||||
-rw-r--r-- | user.hxx | 11 | ||||
-rw-r--r-- | worker.cxx | 5 | ||||
-rw-r--r-- | worker.hxx | 4 |
12 files changed, 52 insertions, 57 deletions
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/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/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 +Subproject 16b8e66c64ee8acd6ea2ce34372e52406a990d2 @@ -12,13 +12,14 @@ int main(int argc, char* argv[]) qmlRegisterSingletonType<User>("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<User>("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 7cd3d16..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 @@ -9,4 +10,11 @@ PasswordForm { stackView.pop() } } + + createPassButton { + onClicked: { + User.password = passTextField.text + RTClient.logIn(User.emailAddress, User.password) + } + } } diff --git a/rtclient b/rtclient deleted file mode 160000 -Subproject 89cd9ab12cb2aa09f92e312cd0418a036dc0ed8 @@ -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) { @@ -50,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) { @@ -3,12 +3,11 @@ #include <QObject> -struct rt_user; - 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) Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged) @@ -34,9 +33,8 @@ class User : public QObject {} ~User() {} - Q_INVOKABLE void update(rt_user* 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; } @@ -56,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); @@ -76,6 +75,7 @@ class User : public QObject signals: void nameChanged(); + void passwordChanged(); void emailAddressChanged(); void organizationChanged(); void realNameChanged(); @@ -96,6 +96,7 @@ class User : public QObject private: QString m_name; + QString m_password; QString m_emailAddress; QString m_organization; QString m_realName; @@ -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(); @@ -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 |