summaryrefslogtreecommitdiff
path: root/client.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'client.cxx')
-rw-r--r--client.cxx59
1 files changed, 29 insertions, 30 deletions
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);
}