summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-18 21:31:37 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-18 21:31:37 +0800
commit582ad4435408bdc19a007315e2c41770174cd606 (patch)
tree31abd30ae87ecf62410509e5d10663549206a8e1
parenta01bfc11355f041eb4225d5d104fee83e17db444 (diff)
Conform to updated libicclient function names
-rw-r--r--admin.cxx1
-rw-r--r--catalog.cxx3
-rw-r--r--client.cxx59
-rw-r--r--member.cxx1
-rw-r--r--qicclient.hxx29
-rw-r--r--qicclient/catalog.hxx6
-rw-r--r--qicclient/product.hxx2
7 files changed, 46 insertions, 55 deletions
diff --git a/admin.cxx b/admin.cxx
index c15b3c5..bd8a391 100644
--- a/admin.cxx
+++ b/admin.cxx
@@ -1,4 +1,3 @@
-#include <memory>
#include <icclient/typedefs.h>
#include <icclient/admin.h>
#include "qicclient/admin.hxx"
diff --git a/catalog.cxx b/catalog.cxx
index e978858..2cee7c2 100644
--- a/catalog.cxx
+++ b/catalog.cxx
@@ -1,10 +1,9 @@
#include <cstddef>
-#include <icclient.h>
#include "qicclient/catalog.hxx"
namespace QICClient {
- Catalog::Catalog(icclient_catalog* catalog, QObject* parent) :
+ Catalog::Catalog(struct icclient_catalog* catalog, QObject* parent) :
QAbstractListModel{parent},
m_data{catalog}
{
diff --git a/client.cxx b/client.cxx
index c4e574b..40aa342 100644
--- a/client.cxx
+++ b/client.cxx
@@ -1,6 +1,3 @@
-#include <cstddef>
-#include <memory>
-#include <QObject>
#include "qicclient.hxx"
#include "qicclient/ord.hxx"
@@ -8,71 +5,73 @@ namespace QICClient {
static Client* client;
- static void resultsHandler(icclient_response* response)
+ Client::Client(char const* sampleURL, char const* image_Dir, char const* certificate)
{
- client->emitResults(QString{response->data});
- icclient_free_response(response);
+ client = this;
+ icclient_init(sampleURL, image_Dir, certificate);
}
- static void catalogCallback(icclient_catalog* catalog)
+ Client::~Client()
{
- client->emitCatalog(new Catalog{catalog});
- icclient_free_catalog(catalog);
+ icclient_cleanup();
}
- Client::Client(char const* sampleURL, char const* image_Dir, char const* certificate)
+ static void catalogHandler(icclient_response* response)
{
- client = this;
- icclient_init(sampleURL, image_Dir, certificate);
+ client->emitCatalog(QString{response->data});
+ icclient_free_response(response);
}
- Client::~Client()
+ static void catalogCallback(struct icclient_catalog* catalog)
{
- icclient_cleanup();
+ icclient_free_catalog(catalog);
}
- void Client::results(QString const& prodGroup)
+ void Client::catalog(QString const& prodGroup)
{
- icclient_results(prodGroup.toLatin1().constData(), resultsHandler, nullptr);
+ icclient_catalog(prodGroup.toLatin1().constData(), catalogHandler, nullptr);
}
void Client::allProducts()
{
- icclient_allproducts(resultsHandler, nullptr);
+ icclient_allproducts(catalogHandler, nullptr);
+ }
+
+ static void productHandler(icclient_response* response)
+ {
+ client->emitProduct(QString{response->data});
+ icclient_free_response(response);
}
- void Client::strapResults(QString const& prodGroup)
+ void Client::product(QString const& sku)
{
- icclient_results(prodGroup.toLatin1().constData(), nullptr, catalogCallback);
+ icclient_product(sku.toLatin1().constData(), productHandler, nullptr);
}
- void Client::strapAllProducts()
+ void Client::defaultCatalog(QString const& prodGroup)
{
- icclient_allproducts(nullptr, catalogCallback);
+ icclient_catalog(prodGroup.toLatin1().constData(), nullptr, catalogCallback);
}
- void Client::emitResults(QString const& results)
+ void Client::defaultAllProducts()
{
- emit gotResults(results);
+ icclient_allproducts(nullptr, catalogCallback);
}
- void Client::emitCatalog(Catalog* catalog)
+ void Client::emitCatalog(QString const& catalog)
{
emit gotCatalog(catalog);
}
- void Client::flyPage(QString const& sku,void (*handler)(icclient_response*))
+ void Client::emitProduct(QString const& product)
{
- icclient_product* product = nullptr;
- icclient_flypage(sku.toLatin1().constData(), handler, &product);
- if (product) emit gotFlyPage(shared_ptr<Product>{new Product{product}});
+ emit gotProduct(product);
}
void Client::order(QString const& sku, Catalog const& catalog, Ord& order)
{
auto c_order = order.data();
- icclient_ord_order(sku.toLatin1().constData(), catalog.constData(),
- &c_order);
+ icclient_ord_order(sku.toLatin1().constData(), catalog.constData(), &c_order);
order.setData(c_order);
}
diff --git a/member.cxx b/member.cxx
index 4498bcc..cc6bdad 100644
--- a/member.cxx
+++ b/member.cxx
@@ -1,4 +1,3 @@
-#include <memory>
#include <icclient/typedefs.h>
#include <icclient/member.h>
#include "qicclient/member.hxx"
diff --git a/qicclient.hxx b/qicclient.hxx
index 3b7f0d5..da1fa61 100644
--- a/qicclient.hxx
+++ b/qicclient.hxx
@@ -3,11 +3,9 @@
#include <QObject>
#include "qicclient/catalog.hxx"
-#include <icclient.h>
namespace QICClient {
- using std::shared_ptr;
class Ord;
class Client : public QObject
@@ -27,46 +25,43 @@ namespace QICClient {
*/
~Client();
/*!
- * \brief For fetching data about a specific product.
- * \param sku The SKU of the item to order.
- * \param handler A pointer to a cURL write function callback.
- */
- void flyPage(QString const& sku, void (*handler)(icclient_response*));
- /*!
* \brief For putting an item to a cart.
* \param sku The SKU of the item to order.
* \param catalog The catalog from which the item is.
* \param order The order.
*/
void order(QString const& sku, Catalog const& catalog, Ord& order);
- void emitResults(QString const& response);
- void emitCatalog(Catalog* catalog);
+ void emitCatalog(QString const& response);
+ void emitProduct(QString const& response);
public slots:
/*!
* \brief For fetching products that belong a specific group.
* \param prodGroup The name of the product group.
*/
- void results(QString const& prodGroup);
+ void catalog(QString const& prodGroup);
/*!
* \brief For fetching data about all active products.
*/
void allProducts();
/*!
+ * \brief For fetching data about a specific product.
+ * \param sku The SKU of the item to order.
+ */
+ void product(QString const& sku);
+ /*!
* \brief For fetching products that belong a specific group.
* \param prodGroup The name of the product group.
- * \param handler A C style pointer to function for custom handling.
*/
- void strapResults(QString const& prodGroup);
+ void defaultCatalog(QString const& prodGroup);
/*!
* \brief For fetching data about all active products.
*/
- void strapAllProducts();
+ void defaultAllProducts();
signals:
- void gotResults(QString const& results);
- void gotCatalog(Catalog* catalog);
- void gotFlyPage(shared_ptr<Product> product);
+ void gotCatalog(QString const& response);
+ void gotProduct(QString const& response);
};
}
diff --git a/qicclient/catalog.hxx b/qicclient/catalog.hxx
index 244f4f0..4deeff3 100644
--- a/qicclient/catalog.hxx
+++ b/qicclient/catalog.hxx
@@ -13,11 +13,11 @@ namespace QICClient {
Q_OBJECT
public:
- Catalog(icclient_catalog* catalog, QObject* parent = nullptr);
+ Catalog(struct icclient_catalog* catalog, QObject* parent = nullptr);
~Catalog();
int rowCount(QModelIndex const& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
- icclient_catalog const* constData() const { return m_data; }
+ struct icclient_catalog const* constData() const { return m_data; }
protected:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
@@ -25,7 +25,7 @@ namespace QICClient {
private:
void addProduct(Product const& product);
QList<Product> products;
- icclient_catalog* m_data;
+ struct icclient_catalog* m_data;
};
}
diff --git a/qicclient/product.hxx b/qicclient/product.hxx
index 18b850a..980132b 100644
--- a/qicclient/product.hxx
+++ b/qicclient/product.hxx
@@ -20,7 +20,7 @@ namespace QICClient {
CrossSellRole
};
- Product(icclient_product* product) :
+ Product(struct icclient_product* product) :
price{product->price},
weight{product->weight}
{