summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2020-07-12 20:10:21 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2020-07-12 20:10:21 +0800
commitc63914cd24ec7e12c99cae034cf89afa81a9f408 (patch)
tree4a8896ce59cbeb5dc8ff4481061d5b99153c17ba
parent366624e9085cb31609eb0375546aef47ac7a57ac (diff)
member related functions move to Member class
-rw-r--r--CMakeLists.txt6
-rw-r--r--client.cxx19
m---------libicclient0
-rw-r--r--member.cxx314
-rw-r--r--qicclient/client.hxx11
-rw-r--r--qicclient/member.hxx (renamed from qicclient/user.hxx)66
-rw-r--r--user.cxx235
7 files changed, 354 insertions, 297 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bedb9ba..a0aa505 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,11 +7,11 @@ set(CMAKE_AUTOMOC ON)
find_package(Qt5Core)
add_library(${PROJECT_NAME} SHARED
- ${PROJECT_NAME}/user.hxx
+ ${PROJECT_NAME}/member.hxx
${PROJECT_NAME}/catalog.hxx
${PROJECT_NAME}/basket.hxx
${PROJECT_NAME}/client.hxx
- user.cxx
+ member.cxx
catalog.cxx
basket.cxx
client.cxx
@@ -26,7 +26,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE QICCLIENT)
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(FILES
- ${PROJECT_NAME}/user.hxx
+ ${PROJECT_NAME}/member.hxx
${PROJECT_NAME}/product.hxx
${PROJECT_NAME}/catalog.hxx
${PROJECT_NAME}/basket.hxx
diff --git a/client.cxx b/client.cxx
index 3b406ad..26d8ad9 100644
--- a/client.cxx
+++ b/client.cxx
@@ -50,23 +50,4 @@ namespace QICClient {
order.setData(c_order);
}
- void Client::logIn(size_t (*handler)(void*, size_t, size_t, void*),
- icclient_member* member, QString const& username,
- QString const& password, QString const& successPage,
- QString const& nextPage, QString const& failPage)
- {
- icclient_member_login(handler, member, username.toLatin1().constData(),
- password.toLatin1().constData(),
- successPage.toLatin1().constData(),
- nextPage.toLatin1().constData(),
- failPage.toLatin1().constData());
- emit loggedIn(member);
- }
-
- void Client::logOut()
- {
- icclient_member_logout();
- emit loggedOut();
- }
-
}
diff --git a/libicclient b/libicclient
-Subproject f2cdda353b0da0ec19679ac8753fbe2d17471fd
+Subproject 3f5ece56ba0aa55be5c6a7973866ffda432de1c
diff --git a/member.cxx b/member.cxx
new file mode 100644
index 0000000..61bbf0e
--- /dev/null
+++ b/member.cxx
@@ -0,0 +1,314 @@
+#include <cstddef>
+#include <icclient/client.h>
+#include "qicclient/member.hxx"
+
+namespace QICClient {
+
+ void Member::logIn(QString const& username, QString const& password,
+ QString const& successPage, QString const& nextPage,
+ QString const& failPage,
+ size_t (*handler)(void*, size_t, size_t, void*))
+ {
+ setData(icclient_member_login(username.toLatin1().constData(),
+ password.toLatin1().constData(),
+ successPage.toLatin1().constData(),
+ nextPage.toLatin1().constData(),
+ failPage.toLatin1().constData(),
+ handler));
+ }
+
+ void Member::setUserName(QString const& userName)
+ {
+ if (m_userName != userName) {
+ m_userName = userName;
+ emit userNameChanged();
+ }
+ }
+
+ void Member::setUserNick(QString const& userNick)
+ {
+ if (m_userNick != userNick) {
+ m_userNick = userNick;
+ emit userNickChanged();
+ }
+ }
+
+ void Member::setPassword(QString const& password)
+ {
+ if (m_password != password) {
+ m_password = password;
+ emit passwordChanged();
+ }
+ }
+
+ void Member::setExpiration(QString const& expiration)
+ {
+ if (m_expiration != expiration) {
+ m_expiration = expiration;
+ emit expirationChanged();
+ }
+ }
+
+ void Member::setAcl(QString const& acl)
+ {
+ if (m_acl != acl) {
+ m_acl = acl;
+ emit aclChanged();
+ }
+ }
+
+ void Member::setModTime(QString const& modTime)
+ {
+ if (m_modTime != modTime) {
+ m_modTime = modTime;
+ emit modTimeChanged();
+ }
+ }
+
+ void Member::setSNickName(QString const& sNickName)
+ {
+ if (m_sNickName != sNickName) {
+ m_sNickName = sNickName;
+ emit sNickNameChanged();
+ }
+ }
+
+ void Member::setCompany(QString const& company)
+ {
+ if (m_company != company) {
+ m_company = company;
+ emit companyChanged();
+ }
+ }
+
+ void Member::setFName(QString const& fName)
+ {
+ if (m_fName != fName) {
+ m_fName = fName;
+ emit fNameChanged();
+ }
+ }
+
+ void Member::setLName(QString const& lName)
+ {
+ if (m_lName != lName) {
+ m_lName = lName;
+ emit lNameChanged();
+ }
+ }
+
+ void Member::setAddress1(QString const& address1)
+ {
+ if (m_address1 != address1) {
+ m_address1 = address1;
+ emit address1Changed();
+ }
+ }
+
+ void Member::setAddress2(QString const& address2)
+ {
+ if (m_address2 != address2) {
+ m_address2 = address2;
+ emit address2Changed();
+ }
+ }
+
+ void Member::setAddress3(QString const& address3)
+ {
+ if (m_address3 != address3) {
+ m_address3 = address3;
+ emit address3Changed();
+ }
+ }
+
+ void Member::setCity(QString const& city)
+ {
+ if (m_city != city) {
+ m_city = city;
+ emit cityChanged();
+ }
+ }
+
+ void Member::setState(QString const& state)
+ {
+ if (m_state != state) {
+ m_state = state;
+ emit stateChanged();
+ }
+ }
+
+ void Member::setZip(QString const& zip)
+ {
+ if (m_zip != zip) {
+ m_zip = zip;
+ emit zipChanged();
+ }
+ }
+
+ void Member::setCountry(QString const& country)
+ {
+ if (m_country != country) {
+ m_country = country;
+ emit countryChanged();
+ }
+ }
+
+ void Member::setPhoneDay(QString const& phoneDay)
+ {
+ if (m_phoneDay != phoneDay) {
+ m_phoneDay = phoneDay;
+ emit phoneDayChanged();
+ }
+ }
+
+ void Member::setEmail(QString const& email)
+ {
+ if (m_email != email) {
+ m_email = email;
+ emit emailChanged();
+ }
+ }
+
+ void Member::setData(icclient_member* member)
+ {
+ if (member->username && m_userName != member->username) {
+ m_userName = QString{member->username};
+ emit userNameChanged();
+ } else if (m_userName != "") {
+ m_userName = "";
+ emit userNameChanged();
+ }
+ if (member->usernick && m_userNick != member->usernick) {
+ m_userNick = QString{member->usernick};
+ emit userNickChanged();
+ } else if (m_userNick != "") {
+ m_userNick = "";
+ emit userNickChanged();
+ }
+ if (member->password && m_password != member->password) {
+ m_password = QString{member->password};
+ emit passwordChanged();
+ } else if (m_password != "") {
+ m_password = "";
+ emit passwordChanged();
+ }
+ if (member->expiration && m_expiration != member->expiration) {
+ m_expiration = QString{member->expiration};
+ emit expirationChanged();
+ } else if (m_expiration != "") {
+ m_expiration = "";
+ emit expirationChanged();
+ }
+ if (member->acl && m_acl != member->acl) {
+ m_acl = QString{member->acl};
+ emit aclChanged();
+ } else if (m_acl != "") {
+ m_acl = "";
+ emit aclChanged();
+ }
+ if (member->mod_time && m_modTime != member->mod_time) {
+ m_modTime = QString{member->mod_time};
+ emit modTimeChanged();
+ } else if (m_modTime != "") {
+ m_modTime = "";
+ emit modTimeChanged();
+ }
+ if (member->s_nickname && m_sNickName != member->s_nickname) {
+ m_sNickName = QString{member->s_nickname};
+ emit sNickNameChanged();
+ } else if (m_sNickName != "") {
+ m_sNickName = "";
+ emit sNickNameChanged();
+ }
+ if (member->company && m_company != member->company) {
+ m_company = QString{member->company};
+ emit companyChanged();
+ } else if (m_company != "") {
+ m_company = "";
+ emit companyChanged();
+ }
+ if (member->fname && m_fName != member->fname) {
+ m_fName = QString{member->fname};
+ emit fNameChanged();
+ } else if (m_fName != "") {
+ m_fName = "";
+ emit fNameChanged();
+ }
+ if (member->lname && m_lName != member->lname) {
+ m_lName = QString{member->lname};
+ emit lNameChanged();
+ } else if (m_lName != "") {
+ m_lName = "";
+ emit lNameChanged();
+ }
+ if (member->address1 && m_address1 != member->address1) {
+ m_address1 = QString{member->address1};
+ emit address1Changed();
+ } else if (m_address1 != "") {
+ m_address1 = "";
+ emit address1Changed();
+ }
+ if (member->address2 && m_address2 != member->address2) {
+ m_address2 = QString{member->address2};
+ emit address2Changed();
+ } else if (m_address2 != "") {
+ m_address2 = "";
+ emit address2Changed();
+ }
+ if (member->address3 && m_address3 != member->address3) {
+ m_address3 = QString{member->address3};
+ emit address3Changed();
+ } else if (m_address3 != "") {
+ m_address3 = "";
+ emit address3Changed();
+ }
+ if (member->city && m_city != member->city) {
+ m_city = QString{member->city};
+ emit cityChanged();
+ } else if (m_city != "") {
+ m_city = "";
+ emit cityChanged();
+ }
+ if (member->state && m_state != member->state) {
+ m_state = QString{member->state};
+ emit stateChanged();
+ } else if (m_state != "") {
+ m_state = "";
+ emit stateChanged();
+ }
+ if (member->zip && m_zip != member->zip) {
+ m_zip = QString{member->zip};
+ emit zipChanged();
+ } else if (m_zip != "") {
+ m_zip = "";
+ emit zipChanged();
+ }
+ if (member->country && m_country != member->country) {
+ m_country = QString{member->country};
+ emit countryChanged();
+ } else if (m_country != "") {
+ m_country = "";
+ emit countryChanged();
+ }
+ if (member->phone_day && m_phoneDay != member->phone_day) {
+ m_phoneDay = QString{member->phone_day};
+ emit phoneDayChanged();
+ } else if (m_phoneDay != "") {
+ m_phoneDay = "";
+ emit phoneDayChanged();
+ }
+ if (member->email && m_email != member->email) {
+ m_email = QString{member->email};
+ emit emailChanged();
+ } else if (m_email != "") {
+ m_email = "";
+ emit emailChanged();
+ }
+ }
+
+ void Member::logOut()
+ {
+ icclient_member_logout(m_data);
+ }
+
+}
diff --git a/qicclient/client.hxx b/qicclient/client.hxx
index 26d540d..2f0632d 100644
--- a/qicclient/client.hxx
+++ b/qicclient/client.hxx
@@ -56,14 +56,6 @@ namespace QICClient {
void order(QString const& sku, Catalog const& catalog,
Basket& order);
- void logIn(size_t (*handler)(void*, size_t, size_t, void*),
- icclient_member* member,
- QString const& username,
- QString const& password,
- QString const& successPage = nullptr,
- QString const& nextPage = nullptr,
- QString const& failPage = nullptr);
-
public slots:
/*
void remove(unsigned int const& indices);
@@ -83,7 +75,6 @@ namespace QICClient {
, QString const& password
, QString const& verify);
*/
- void logOut();
/*
void newItem(QString const& description
, QString const& comment,
@@ -94,8 +85,6 @@ namespace QICClient {
signals:
void gotResults(Catalog* catalog);
void gotFlyPage(shared_ptr<Product> product);
- void loggedIn(icclient_member* member);
- void loggedOut();
};
}
diff --git a/qicclient/user.hxx b/qicclient/member.hxx
index bb3ca00..d4073c0 100644
--- a/qicclient/user.hxx
+++ b/qicclient/member.hxx
@@ -1,5 +1,5 @@
-#ifndef QICCLIENT_USER_HXX
-#define QICCLIENT_USER_HXX
+#ifndef QICCLIENT_MEMBER_HXX
+#define QICCLIENT_MEMBER_HXX
#include <QObject>
#include <icclient/member.h>
@@ -8,7 +8,7 @@ struct icclient_member;
namespace QICClient {
- class User : public QObject
+ class Member : public QObject
{
Q_OBJECT
Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged)
@@ -32,29 +32,38 @@ namespace QICClient {
Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
public:
- explicit User(QObject* parent = nullptr)
- : QObject{parent}
- , m_userName{""}
- , m_userNick{""}
- , m_password{""}
- , m_expiration{""}
- , m_acl{""}
- , m_modTime{""}
- , m_sNickName{""}
- , m_company{""}
- , m_fName{""}
- , m_lName{""}
- , m_address1{""}
- , m_address2{""}
- , m_address3{""}
- , m_city{""}
- , m_state{""}
- , m_zip{""}
- , m_country{""}
- , m_phoneDay{""}
- , m_email{""}
+ explicit Member(QObject* parent = nullptr) :
+ QObject{parent},
+ m_userName{""},
+ m_userNick{""},
+ m_password{""},
+ m_expiration{""},
+ m_acl{""},
+ m_modTime{""},
+ m_sNickName{""},
+ m_company{""},
+ m_fName{""},
+ m_lName{""},
+ m_address1{""},
+ m_address2{""},
+ m_address3{""},
+ m_city{""},
+ m_state{""},
+ m_zip{""},
+ m_country{""},
+ m_phoneDay{""},
+ m_email{""},
+ m_data{nullptr}
{}
- ~User() {}
+ ~Member() {}
+
+ void logIn(QString const& username, QString const& password,
+ QString const& successPage = nullptr,
+ QString const& nextPage = nullptr,
+ QString const& failPage = nullptr,
+ size_t (*handler)(void*, size_t, size_t,
+ void*) = nullptr);
+ void logOut();
QString const& userName() const { return m_userName; }
QString const& userNick() const { return m_userNick; }
@@ -95,9 +104,7 @@ namespace QICClient {
void setCountry(QString const& country);
void setPhoneDay(QString const& phoneDay);
void setEmail(QString const& email);
-
- public slots:
- void update(icclient_member* member);
+ void setData(icclient_member* member);
signals:
void userNameChanged();
@@ -140,8 +147,9 @@ namespace QICClient {
QString m_country;
QString m_phoneDay;
QString m_email;
+ icclient_member* m_data;
};
}
-#endif // QICCLIENT_USER_HXX
+#endif // QICCLIENT_MEMBER_HXX
diff --git a/user.cxx b/user.cxx
deleted file mode 100644
index eb7b7dd..0000000
--- a/user.cxx
+++ /dev/null
@@ -1,235 +0,0 @@
-#include <cstddef>
-#include <icclient/client.h>
-#include "qicclient/user.hxx"
-
-namespace QICClient {
-
- void User::setUserName(QString const& UserName)
- {
- if (m_userName != UserName) {
- m_userName = UserName;
- emit userNameChanged();
- }
- }
-
- void User::setUserNick(QString const& UserNick)
- {
- if (m_userNick != UserNick) {
- m_userNick = UserNick;
- emit userNickChanged();
- }
- }
-
- void User::setPassword(QString const& password)
- {
- if (m_password != password) {
- m_password = password;
- emit passwordChanged();
- }
- }
-
- void User::setExpiration(QString const& expiration)
- {
- if (m_expiration != expiration) {
- m_expiration = expiration;
- emit expirationChanged();
- }
- }
-
- void User::setAcl(QString const& acl)
- {
- if (m_acl != acl) {
- m_acl = acl;
- emit aclChanged();
- }
- }
-
- void User::setModTime(QString const& modTime)
- {
- if (m_modTime != modTime) {
- m_modTime = modTime;
- emit modTimeChanged();
- }
- }
-
- void User::setSNickName(QString const& sNickName)
- {
- if (m_sNickName != sNickName) {
- m_sNickName = sNickName;
- emit sNickNameChanged();
- }
- }
-
- void User::setCompany(QString const& company)
- {
- if (m_company != company) {
- m_company = company;
- emit companyChanged();
- }
- }
-
- void User::setFName(QString const& fName)
- {
- if (m_fName != fName) {
- m_fName = fName;
- emit fNameChanged();
- }
- }
-
- void User::setLName(QString const& lName)
- {
- if (m_lName != lName) {
- m_lName = lName;
- emit lNameChanged();
- }
- }
-
- void User::setAddress1(QString const& address1)
- {
- if (m_address1 != address1) {
- m_address1 = address1;
- emit address1Changed();
- }
- }
-
- void User::setAddress2(QString const& address2)
- {
- if (m_address2 != address2) {
- m_address2 = address2;
- emit address2Changed();
- }
- }
-
- void User::setAddress3(QString const& address3)
- {
- if (m_address3 != address3) {
- m_address3 = address3;
- emit address3Changed();
- }
- }
-
- void User::setCity(QString const& city)
- {
- if (m_city != city) {
- m_city = city;
- emit cityChanged();
- }
- }
-
- void User::setState(QString const& state)
- {
- if (m_state != state) {
- m_state = state;
- emit stateChanged();
- }
- }
-
- void User::setZip(QString const& zip)
- {
- if (m_zip != zip) {
- m_zip = zip;
- emit zipChanged();
- }
- }
-
- void User::setCountry(QString const& country)
- {
- if (m_country != country) {
- m_country = country;
- emit countryChanged();
- }
- }
-
- void User::setPhoneDay(QString const& phoneDay)
- {
- if (m_phoneDay != phoneDay) {
- m_phoneDay = phoneDay;
- emit phoneDayChanged();
- }
- }
-
- void User::setEmail(QString const& email)
- {
- if (m_email != email) {
- m_email = email;
- emit emailChanged();
- }
- }
-
- void User::update(icclient_member* member)
- {
- if (member->username)
- m_userName = QString{member->username};
- else
- m_userName = "";
- if (member->usernick)
- m_userNick = QString{member->usernick};
- else
- m_userNick = "";
- if (member->fname)
- m_fName = QString{member->fname};
- else
- m_fName = "";
- if (member->lname)
- m_lName = QString{member->lname};
- else
- m_lName = "";
- if (member->address1)
- m_address1 = QString{member->address1};
- else
- m_address1 = "";
- if (member->address2)
- m_address2 = QString{member->address2};
- else
- m_address2 = "";
- if (member->address3)
- m_address3 = QString{member->address3};
- else
- m_address3 = "";
- if (member->city)
- m_city = QString{member->city};
- else
- m_city = "";
- if (member->state)
- m_state = QString{member->state};
- else
- m_state = "";
- if (member->zip)
- m_zip = QString{member->zip};
- else
- m_zip = "";
- if (member->country)
- m_country = QString{member->country};
- else
- m_country = "";
- if (member->phone_day)
- m_phoneDay = QString{member->phone_day};
- else
- m_phoneDay = "";
- if (member->email)
- m_email = QString{member->email};
- else
- m_email = "";
-
- emit userNameChanged();
- emit userNickChanged();
- emit passwordChanged();
- emit expirationChanged();
- emit aclChanged();
- emit modTimeChanged();
- emit sNickNameChanged();
- emit companyChanged();
- emit fNameChanged();
- emit lNameChanged();
- emit address1Changed();
- emit address2Changed();
- emit address3Changed();
- emit cityChanged();
- emit stateChanged();
- emit zipChanged();
- emit countryChanged();
- emit phoneDayChanged();
- emit emailChanged();
- }
-
-}