summaryrefslogtreecommitdiff
path: root/client.cxx
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-13 17:49:57 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-13 17:49:57 +0800
commitd6e1d66de6b539b6af4a7f517d84a07f17e75c2f (patch)
treece226a5aacb0de6cdee4494e60cfe5b888f96bba /client.cxx
parentf91691a987aaca4a16a2ffe8d4ad3b6c6b8c8059 (diff)
gotResults now passes icclient_fetch_t*
so the signal can be connected to some slot.
Diffstat (limited to 'client.cxx')
-rw-r--r--client.cxx27
1 files changed, 15 insertions, 12 deletions
diff --git a/client.cxx b/client.cxx
index 4321726..7b91e2d 100644
--- a/client.cxx
+++ b/client.cxx
@@ -1,15 +1,14 @@
+#include <cstddef>
#include <memory>
#include <QObject>
-#include <icclient/typedefs.h>
#include "qicclient.hxx"
#include "qicclient/ord.hxx"
-static QICClient::Client *client;
+static QICClient::Client* client;
-static void callback(icclient_catalog* catalog)
+static void handle_results(icclient_fetch_t* fetch)
{
- client->emitCatalog(catalog);
- icclient_free_catalog(catalog);
+ client->emitResults(fetch);
}
namespace QICClient {
@@ -25,22 +24,26 @@ namespace QICClient {
icclient_cleanup();
}
- void Client::results(QString const& prodGroup, icclient_handler handler)
+ void Client::results(QString const& prodGroup)
{
- icclient_results(prodGroup.toLatin1().constData(), callback, handler);
+ icclient_results(prodGroup.toLatin1().constData(), [](icclient_catalog* catalog) {
+ icclient_free_catalog(catalog);
+ }, handle_results);
}
- void Client::allProducts(icclient_handler handler)
+ void Client::allProducts()
{
- icclient_allproducts(callback, handler);
+ icclient_allproducts([](icclient_catalog* catalog) {
+ icclient_free_catalog(catalog);
+ }, handle_results);
}
- void Client::emitCatalog(icclient_catalog* catalog)
+ void Client::emitResults(icclient_fetch_t* fetch)
{
- emit gotResults(new Catalog{catalog});
+ emit gotResults(fetch);
}
- void Client::flyPage(QString const& sku,icclient_handler handler)
+ void Client::flyPage(QString const& sku,void (*handler)(icclient_fetch_t*))
{
icclient_product* product = nullptr;
icclient_flypage(sku.toLatin1().constData(), handler, &product);