diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-18 10:45:11 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-18 10:45:11 +0800 |
commit | 4870212610b467e6fca26639b8fb129c04f300dc (patch) | |
tree | 182c1cb97eeeddd86d518cf00c9525ed7a2230b1 /client.cxx | |
parent | ac8541c6cf3b5dc6936e458dde83e1eebf0ce9d2 (diff) |
Hide icclient types away from the interface
Diffstat (limited to 'client.cxx')
-rw-r--r-- | client.cxx | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -4,19 +4,21 @@ #include "qicclient.hxx" #include "qicclient/ord.hxx" -static QICClient::Client* client; +namespace QICClient { -static void responseHandler(icclient_response* response) -{ - client->emitResponse(response); -} + static Client* client; -static void catalogCallback(icclient_catalog* catalog) -{ - client->emitCatalog(catalog); -} + static void resultsHandler(icclient_response* response) + { + client->emitResults(QString{response->data}); + icclient_free_response(response); + } -namespace QICClient { + static void catalogCallback(icclient_catalog* catalog) + { + client->emitCatalog(new Catalog{catalog}); + icclient_free_catalog(catalog); + } Client::Client(char const* sampleURL, char const* image_Dir, char const* certificate) { @@ -31,12 +33,12 @@ namespace QICClient { void Client::results(QString const& prodGroup) { - icclient_results(prodGroup.toLatin1().constData(), responseHandler, nullptr); + icclient_results(prodGroup.toLatin1().constData(), resultsHandler, nullptr); } void Client::allProducts() { - icclient_allproducts(responseHandler, nullptr); + icclient_allproducts(resultsHandler, nullptr); } void Client::strapResults(QString const& prodGroup) @@ -49,16 +51,14 @@ namespace QICClient { icclient_allproducts(nullptr, catalogCallback); } - void Client::emitResponse(icclient_response* response) + void Client::emitResults(QString const& results) { - emit gotResults(QString{response->data}); - icclient_free_response(response); + emit gotResults(results); } - void Client::emitCatalog(icclient_catalog* catalog) + void Client::emitCatalog(Catalog* catalog) { - emit gotCatalog(new Catalog{catalog}); - icclient_free_catalog(catalog); + emit gotCatalog(catalog); } void Client::flyPage(QString const& sku,void (*handler)(icclient_response*)) |