From 552b14eeda6fc65c6246224425a03a4bf1b31154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 08:55:15 +0800 Subject: Adjust with the new allproducts function name --- client.cxx | 7 ++++--- libicclient | 2 +- qicclient/client.hxx | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client.cxx b/client.cxx index 0443ce3..8e169a2 100644 --- a/client.cxx +++ b/client.cxx @@ -1,3 +1,4 @@ +#include #include #include "qicclient/client.hxx" @@ -13,11 +14,11 @@ namespace ICClient { icclient_cleanup(); } - void Client::productAll(icclient_catalog** catalogptr + void Client::allProducts(icclient_catalog** catalogptr , size_t (*callback)(void*, size_t, size_t, void*)) { - icclient_product_all(catalogptr, callback); - emit gotProductAll(*catalogptr); + icclient_allproducts(catalogptr, callback); + emit gotAllProducts(*catalogptr); } void Client::logIn(QString const& username, QString const& password) diff --git a/libicclient b/libicclient index de7fefc..0bfbe51 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit de7fefc270ef3fd8552773e8e6424ad5885b3062 +Subproject commit 0bfbe518bf7baa28f0720b6c753b550855b495f0 diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 27ba2af..4994ad9 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -16,7 +16,7 @@ namespace ICClient { Client(char const* url, char const* certificate = nullptr); ~Client(); - void productAll(icclient_catalog** catalogptr + void allProducts(icclient_catalog** catalogptr , size_t (*callback)(void* contents , size_t size, size_t nmemb , void* userdata)); @@ -26,7 +26,7 @@ namespace ICClient { void logOut(); signals: - void gotProductAll(icclient_catalog* catalog); + void gotAllProducts(icclient_catalog* catalog); void loggedIn(QString const& username); void loggedOut(); }; -- cgit v1.2.3 From faad7cb0e18d3316173b1f4b67d83ffdfb7424d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 11:41:22 +0800 Subject: User class only a part of the libicclient version so far --- libicclient | 2 +- qicclient.pro | 2 + qicclient/user.hxx | 147 +++++++++++++++++++++++++++++++++ user.cxx | 235 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 qicclient/user.hxx create mode 100644 user.cxx diff --git a/libicclient b/libicclient index 0bfbe51..8d7952b 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit 0bfbe518bf7baa28f0720b6c753b550855b495f0 +Subproject commit 8d7952b68665b0668428d65c277eb699d7523833 diff --git a/qicclient.pro b/qicclient.pro index 7adb82e..371bd20 100644 --- a/qicclient.pro +++ b/qicclient.pro @@ -3,9 +3,11 @@ TEMPLATE = lib CONFIG += staticlib HEADERS += \ + qicclient/user.hxx \ qicclient/catalog.hxx \ qicclient/client.hxx SOURCES += \ + user.cxx \ catalog.cxx \ client.cxx INCLUDEPATH += $$PWD/libicclient diff --git a/qicclient/user.hxx b/qicclient/user.hxx new file mode 100644 index 0000000..b554cba --- /dev/null +++ b/qicclient/user.hxx @@ -0,0 +1,147 @@ +#ifndef QICCLIENT_USER_HXX +#define QICCLIENT_USER_HXX + +#include +#include + +struct icclient_user; + +namespace ICClient { + + class User : public QObject + { + Q_OBJECT + Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged) + Q_PROPERTY(QString userNick READ userNick WRITE setUserNick NOTIFY userNickChanged) + Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged) + Q_PROPERTY(QString expiration READ expiration WRITE setExpiration NOTIFY expirationChanged) + Q_PROPERTY(QString acl READ acl WRITE setAcl NOTIFY aclChanged) + Q_PROPERTY(QString modTime READ modTime WRITE setModTime NOTIFY modTimeChanged) + Q_PROPERTY(QString sNickName READ sNickName WRITE setSNickName NOTIFY sNickNameChanged) + Q_PROPERTY(QString company READ company WRITE setCompany NOTIFY companyChanged) + Q_PROPERTY(QString fName READ fName WRITE setFName NOTIFY fNameChanged) + Q_PROPERTY(QString lName READ lName WRITE setLName NOTIFY lNameChanged) + Q_PROPERTY(QString address1 READ address1 WRITE setAddress1 NOTIFY address1Changed) + Q_PROPERTY(QString address2 READ address2 WRITE setAddress2 NOTIFY address2Changed) + Q_PROPERTY(QString address3 READ address3 WRITE setAddress3 NOTIFY address3Changed) + 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 phoneDay READ phoneDay WRITE setPhoneDay NOTIFY phoneDayChanged) + 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{""} + {} + ~User() {} + + QString const& userName() const { return m_userName; } + QString const& userNick() const { return m_userNick; } + QString const& password() const { return m_password; } + QString const& expiration() const { return m_expiration; } + QString const& acl() const { return m_acl; } + QString const& modTime() const { return m_modTime; } + QString const& sNickName() const { return m_sNickName; } + QString const& company() const { return m_company; } + QString const& fName() const { return m_fName; } + QString const& lName() const { return m_lName; } + QString const& address1() const { return m_address1; } + QString const& address2() const { return m_address2; } + QString const& address3() const { return m_address3; } + 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& phoneDay() const { return m_phoneDay; } + QString const& email() const { return m_email; } + + void setUserName(QString const& userName); + void setUserNick(QString const& userNick); + void setPassword(QString const& password); + void setExpiration(QString const& expiration); + void setAcl(QString const& acl); + void setModTime(QString const& modTime); + void setSNickName(QString const& sNickName); + void setCompany(QString const& company); + void setFName(QString const& fName); + void setLName(QString const& lName); + void setAddress1(QString const& address1); + void setAddress2(QString const& address2); + void setAddress3(QString const& address3); + void setCity(QString const& city); + void setState(QString const& state); + void setZip(QString const& zip); + void setCountry(QString const& country); + void setPhoneDay(QString const& phoneDay); + void setEmail(QString const& email); + + public slots: + void update(icclient_user* user); + + signals: + void userNameChanged(); + void userNickChanged(); + void passwordChanged(); + void expirationChanged(); + void aclChanged(); + void modTimeChanged(); + void sNickNameChanged(); + void companyChanged(); + void fNameChanged(); + void lNameChanged(); + void address1Changed(); + void address2Changed(); + void address3Changed(); + void cityChanged(); + void stateChanged(); + void zipChanged(); + void countryChanged(); + void phoneDayChanged(); + void emailChanged(); + + private: + QString m_userName; + QString m_userNick; + QString m_password; + QString m_expiration; + QString m_acl; + QString m_modTime; + QString m_sNickName; + QString m_company; + QString m_fName; + QString m_lName; + QString m_address1; + QString m_address2; + QString m_address3; + QString m_city; + QString m_state; + QString m_zip; + QString m_country; + QString m_phoneDay; + QString m_email; + }; + +} + +#endif // QICCLIENT_USER_HXX diff --git a/user.cxx b/user.cxx new file mode 100644 index 0000000..2834744 --- /dev/null +++ b/user.cxx @@ -0,0 +1,235 @@ +#include +#include +#include "qicclient/user.hxx" + +namespace ICClient { + + 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_user* user) + { + if (user->username) + m_userName = user->username; + else + m_userName = ""; + if (user->usernick) + m_userNick = user->usernick; + else + m_userNick = ""; + if (user->fname) + m_fName = user->fname; + else + m_fName = ""; + if (user->lname) + m_lName = user->lname; + else + m_lName = ""; + if (user->address1) + m_address1 = user->address1; + else + m_address1 = ""; + if (user->address2) + m_address2 = user->address2; + else + m_address2 = ""; + if (user->address3) + m_address3 = user->address3; + else + m_address3 = ""; + if (user->city) + m_city = user->city; + else + m_city = ""; + if (user->state) + m_state = user->state; + else + m_state = ""; + if (user->zip) + m_zip = user->zip; + else + m_zip = ""; + if (user->country) + m_country = user->country; + else + m_country = ""; + if (user->phone_day) + m_phoneDay = user->phone_day; + else + m_phoneDay = ""; + if (user->email) + m_email = user->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(); + } + +} -- cgit v1.2.3 From f3bdb1378aba6e9ed2ff6a6b30931c9045680301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 16:21:02 +0800 Subject: Make the catalog update slot public --- qicclient/catalog.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qicclient/catalog.hxx b/qicclient/catalog.hxx index 27b4c8e..782c864 100644 --- a/qicclient/catalog.hxx +++ b/qicclient/catalog.hxx @@ -61,15 +61,15 @@ namespace ICClient { , int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; + public slots: + void update(icclient_catalog* catalog); + signals: void updated(); protected: QHash roleNames() const Q_DECL_OVERRIDE; - private slots: - void update(icclient_catalog* catalog); - private: QList products; void addProduct(Product const& product); -- cgit v1.2.3 From 564738b2a05b6dde4f4344f49eb4f14641bca366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 16:21:18 +0800 Subject: More prototypes for client --- libicclient | 2 +- qicclient/client.hxx | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/libicclient b/libicclient index 8d7952b..97d3d5e 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit 8d7952b68665b0668428d65c277eb699d7523833 +Subproject commit 97d3d5efa1d463df7440c04c429e1adfb8b02568 diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 4994ad9..131f3f4 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -5,6 +5,7 @@ #include struct icclient_catalog; +struct icclient_order; namespace ICClient { @@ -22,12 +23,39 @@ namespace ICClient { , void* userdata)); public slots: - void logIn(QString const& username, QString const& password); + /* + void order(QString const& sku); + void remove(unsigned int const& indices); + void checkout(); + */ + void logIn(QString const& username + , QString const& password); + /* + void account(QString const& firstName + , QString const& lastName + , QString const& address1 + , QString const& address2 + , QString const& city + , QString const& state + , QString const& zip + , QString const& email + , QString const& phoneDay); + void changePassword(QString const& passwordOld + , QString const& password + , QString const& verify); + */ void logOut(); + /* + void newItem(QString const& description + , QString const& comment, + QString const& price + , QString const& imagePath); + */ signals: void gotAllProducts(icclient_catalog* catalog); - void loggedIn(QString const& username); + void ordered(icclient_order* order); + void loggedIn(QString const& userName); void loggedOut(); }; -- cgit v1.2.3 From 973602595e4fa6c069839dc9a4ff88a00a8d8fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 16:46:21 +0800 Subject: Compile libicclient with -fPIC --- libicclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libicclient b/libicclient index 97d3d5e..de16cb0 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit 97d3d5efa1d463df7440c04c429e1adfb8b02568 +Subproject commit de16cb072e348fed875232c58cee7dfee5d97663 -- cgit v1.2.3 From 62d23b4337b83d2a2933c4fa4233906030e09fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 21:47:08 +0800 Subject: Freeing the catalog should be the memory allocator's responsibility --- catalog.cxx | 4 +--- libicclient | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/catalog.cxx b/catalog.cxx index 17702bc..8664cdc 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -51,11 +51,9 @@ namespace ICClient { void Catalog::update(icclient_catalog* catalog) { - if (catalog) { + if (catalog) for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); - icclient_product_freecatalog(catalog); - } emit updated(); } diff --git a/libicclient b/libicclient index de16cb0..bf59ffd 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit de16cb072e348fed875232c58cee7dfee5d97663 +Subproject commit bf59ffd31aeb3a328a489205ecbc45c194cfa5dc -- cgit v1.2.3 From 403a3a959547b594be784e833a2a453aeca7b238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 28 Sep 2019 11:26:22 +0800 Subject: libicclient update --- libicclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libicclient b/libicclient index bf59ffd..caae177 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit bf59ffd31aeb3a328a489205ecbc45c194cfa5dc +Subproject commit caae1774260ab9d493b63183e8fb0dd460ef62d8 -- cgit v1.2.3 From 4ec7c925e46cebe461cf6c8b21c35b58afb96c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 28 Sep 2019 12:50:55 +0800 Subject: Fix header guard --- qicclient/client.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 131f3f4..a8b50f4 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -1,5 +1,5 @@ -#ifndef QRTCLIENT_CLIENT_HXX -#define QRTCLIENT_CLIENT_HXX +#ifndef QICCLIENT_CLIENT_HXX +#define QICCLIENT_CLIENT_HXX #include #include @@ -61,4 +61,4 @@ namespace ICClient { } -#endif // QRTCLIENT_CLIENT_HXX +#endif // QICCLIENT_CLIENT_HXX -- cgit v1.2.3 From bffd7c68508f793fc00c7453850668f7c654e1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 28 Sep 2019 13:05:03 +0800 Subject: The app should be able to accept the catalog in QICClient's form --- client.cxx | 8 ++++---- qicclient/client.hxx | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client.cxx b/client.cxx index 8e169a2..4e832ce 100644 --- a/client.cxx +++ b/client.cxx @@ -14,11 +14,11 @@ namespace ICClient { icclient_cleanup(); } - void Client::allProducts(icclient_catalog** catalogptr - , size_t (*callback)(void*, size_t, size_t, void*)) + void Client::allProducts(size_t (*handler)(void*, size_t, size_t, void*)) { - icclient_allproducts(catalogptr, callback); - emit gotAllProducts(*catalogptr); + icclient_catalog* catalog = nullptr; + icclient_allproducts(&catalog, handler); + emit gotAllProducts(catalog); } void Client::logIn(QString const& username, QString const& password) diff --git a/qicclient/client.hxx b/qicclient/client.hxx index a8b50f4..bccd665 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -17,8 +17,7 @@ namespace ICClient { Client(char const* url, char const* certificate = nullptr); ~Client(); - void allProducts(icclient_catalog** catalogptr - , size_t (*callback)(void* contents + void allProducts(size_t (*handler)(void* contents , size_t size, size_t nmemb , void* userdata)); -- cgit v1.2.3 From 9beee6344f95d487c30e6bcdafaf9596716236c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 27 Sep 2019 21:47:08 +0800 Subject: Revert "Freeing the catalog should be the memory allocator's responsibility" This reverts commit 62d23b4337b83d2a2933c4fa4233906030e09fb6. # Conflicts: # libicclient --- catalog.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/catalog.cxx b/catalog.cxx index 8664cdc..17702bc 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -51,9 +51,11 @@ namespace ICClient { void Catalog::update(icclient_catalog* catalog) { - if (catalog) + if (catalog) { for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); + icclient_product_freecatalog(catalog); + } emit updated(); } -- cgit v1.2.3 From 7f7cb0eaac8f4030a2eb7d77182f2d2e20373278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 28 Sep 2019 15:17:10 +0800 Subject: Revert "Revert "Freeing the catalog should be the memory allocator's responsibility"" This reverts commit 9beee6344f95d487c30e6bcdafaf9596716236c0. --- catalog.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/catalog.cxx b/catalog.cxx index 17702bc..8664cdc 100644 --- a/catalog.cxx +++ b/catalog.cxx @@ -51,11 +51,9 @@ namespace ICClient { void Catalog::update(icclient_catalog* catalog) { - if (catalog) { + if (catalog) for (size_t i = 0; i < catalog->length; i++) addProduct(Product{catalog->products[i]}); - icclient_product_freecatalog(catalog); - } emit updated(); } -- cgit v1.2.3 From 9bdd26b7a36ebb4987ecdca481e48b81d3164a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 28 Sep 2019 15:50:54 +0800 Subject: Catalog memory is allocated by libicclient --- libicclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libicclient b/libicclient index caae177..7a7ad88 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit caae1774260ab9d493b63183e8fb0dd460ef62d8 +Subproject commit 7a7ad88f83b343c8185006182ff2a8ebf8a94b5c -- cgit v1.2.3 From 73851e44295b0a1e1963689036a0f60c4cbb8330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 28 Sep 2019 15:54:09 +0800 Subject: Client triggers catalog to update directly since getting all products would only be good for catalog. Besides, emitting there seems to cause crash somehow. --- client.cxx | 6 ++++-- qicclient/client.hxx | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client.cxx b/client.cxx index 4e832ce..168a0fc 100644 --- a/client.cxx +++ b/client.cxx @@ -14,11 +14,13 @@ namespace ICClient { icclient_cleanup(); } - void Client::allProducts(size_t (*handler)(void*, size_t, size_t, void*)) + void Client::allProducts(Catalog* qCatalog, size_t (*handler)(void*, size_t + , size_t, void*)) { icclient_catalog* catalog = nullptr; icclient_allproducts(&catalog, handler); - emit gotAllProducts(catalog); + if (catalog) qCatalog->update(catalog); + icclient_product_freecatalog(catalog); } void Client::logIn(QString const& username, QString const& password) diff --git a/qicclient/client.hxx b/qicclient/client.hxx index bccd665..5531d53 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -3,8 +3,8 @@ #include #include +#include "catalog.hxx" -struct icclient_catalog; struct icclient_order; namespace ICClient { @@ -17,7 +17,8 @@ namespace ICClient { Client(char const* url, char const* certificate = nullptr); ~Client(); - void allProducts(size_t (*handler)(void* contents + void allProducts(Catalog* catalog + , size_t (*handler)(void* contents , size_t size, size_t nmemb , void* userdata)); @@ -52,7 +53,6 @@ namespace ICClient { */ signals: - void gotAllProducts(icclient_catalog* catalog); void ordered(icclient_order* order); void loggedIn(QString const& userName); void loggedOut(); -- cgit v1.2.3 From 0640cec9e13edd30b85c50da9943f6fb56aec0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sun, 29 Sep 2019 07:40:23 +0800 Subject: Revert "Client triggers catalog to update directly" This reverts commit 73851e44295b0a1e1963689036a0f60c4cbb8330. --- client.cxx | 6 ++---- qicclient/client.hxx | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/client.cxx b/client.cxx index 168a0fc..4e832ce 100644 --- a/client.cxx +++ b/client.cxx @@ -14,13 +14,11 @@ namespace ICClient { icclient_cleanup(); } - void Client::allProducts(Catalog* qCatalog, size_t (*handler)(void*, size_t - , size_t, void*)) + void Client::allProducts(size_t (*handler)(void*, size_t, size_t, void*)) { icclient_catalog* catalog = nullptr; icclient_allproducts(&catalog, handler); - if (catalog) qCatalog->update(catalog); - icclient_product_freecatalog(catalog); + emit gotAllProducts(catalog); } void Client::logIn(QString const& username, QString const& password) diff --git a/qicclient/client.hxx b/qicclient/client.hxx index 5531d53..bccd665 100644 --- a/qicclient/client.hxx +++ b/qicclient/client.hxx @@ -3,8 +3,8 @@ #include #include -#include "catalog.hxx" +struct icclient_catalog; struct icclient_order; namespace ICClient { @@ -17,8 +17,7 @@ namespace ICClient { Client(char const* url, char const* certificate = nullptr); ~Client(); - void allProducts(Catalog* catalog - , size_t (*handler)(void* contents + void allProducts(size_t (*handler)(void* contents , size_t size, size_t nmemb , void* userdata)); @@ -53,6 +52,7 @@ namespace ICClient { */ signals: + void gotAllProducts(icclient_catalog* catalog); void ordered(icclient_order* order); void loggedIn(QString const& userName); void loggedOut(); -- cgit v1.2.3 From 0f63d288930a71e9705ce1b48a5e0036a9161b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sun, 29 Sep 2019 08:51:06 +0800 Subject: Swap allproducts arguments --- client.cxx | 2 +- libicclient | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.cxx b/client.cxx index 4e832ce..7ffe780 100644 --- a/client.cxx +++ b/client.cxx @@ -17,7 +17,7 @@ namespace ICClient { void Client::allProducts(size_t (*handler)(void*, size_t, size_t, void*)) { icclient_catalog* catalog = nullptr; - icclient_allproducts(&catalog, handler); + icclient_allproducts(handler, &catalog); emit gotAllProducts(catalog); } diff --git a/libicclient b/libicclient index 7a7ad88..685d975 160000 --- a/libicclient +++ b/libicclient @@ -1 +1 @@ -Subproject commit 7a7ad88f83b343c8185006182ff2a8ebf8a94b5c +Subproject commit 685d975434d9311e5afebe9f933509f8bb2ad619 -- cgit v1.2.3