summaryrefslogtreecommitdiff
path: root/interchange.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'interchange.cxx')
-rw-r--r--interchange.cxx35
1 files changed, 25 insertions, 10 deletions
diff --git a/interchange.cxx b/interchange.cxx
index 6108547..21a1fb5 100644
--- a/interchange.cxx
+++ b/interchange.cxx
@@ -4,6 +4,7 @@
namespace QInterchange {
static Interchange* interchange;
+ static char *mv_sku = nullptr, *mv_order_item = nullptr;
static int sampleUrlLength = 0;
Interchange::Interchange(const char* sampleURL, const char* image_Dir,
@@ -70,6 +71,29 @@ namespace QInterchange {
defaultCatalog("All-Products");
}
+ void Interchange::order(const QString &sku, const QString &item,
+ const int quantity)
+ {
+ mv_sku = (char *)malloc(sku.size() + 1);
+ strcpy(mv_sku, sku.toLatin1().constData());
+ if (item.isEmpty()) {
+ mv_order_item = (char *)malloc(sku.size() + 1);
+ strcpy(mv_order_item, sku.toLatin1().constData());
+ } else {
+ mv_order_item = (char *)malloc(item.size() + 1);
+ strcpy(mv_order_item, item.toLatin1().constData());
+ }
+ interchange_ord_order(mv_sku, mv_order_item, quantity,
+ [](interchange_response *response) {
+ free(mv_sku);
+ mv_sku = nullptr;
+ free(mv_order_item);
+ mv_order_item = nullptr;
+ interchange->emitOrder(QString{response->data});
+ interchange_free_response(response);
+ });
+ }
+
void Interchange::emitPage(QString const& path, QString const& response)
{
emit gotPage(path, response);
@@ -85,17 +109,8 @@ namespace QInterchange {
emit gotProduct(response);
}
- void Interchange::emitOrder(QString const& response)
+ void Interchange::emitOrder(const QString &response)
{
emit gotOrder(response);
}
-
- void Interchange::order(QString const& sku)
- {
- interchange_ord_order(sku.toLatin1().constData(),
- [](interchange_response* response) {
- interchange->emitOrder(QString{response->data});
- interchange_free_response(response);
- });
- }
}