From 64ea94aad7253df25798263d6bd1c8c49ceb393d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Wed, 11 Jan 2023 11:27:08 +0800 Subject: Conform to new API --- controller.cxx | 20 ++++++++++---------- handler.c | 16 ++++++++-------- namatoko.pro | 10 +++++----- registration.c | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/controller.cxx b/controller.cxx index 5bf63e3..877c163 100644 --- a/controller.cxx +++ b/controller.cxx @@ -1,18 +1,18 @@ #include -#include -#include +#include +#include #include "controller.hxx" static QQmlApplicationEngine* engine; static QString* certFile = nullptr; static Controller* controller; -using namespace QICClient; -static Client* shop = nullptr; +using namespace QInterchange; +static Interchange* shop = nullptr; static Catalog* allProducts = nullptr; extern "C" { - void sign_up(char const*, char const*, void (*)(icclient_response*)); - struct icclient_catalog* catalog(char const*, char const*); + void sign_up(char const*, char const*, void (*)(interchange_response*)); + struct interchange_catalog* catalog(char const*, char const*); } Controller::Controller(QObject* parent) : QObject{parent} @@ -38,11 +38,11 @@ void Controller::signUp(QString const& brand) #endif controller = this; sign_up(brand.toLatin1().constData(), certFile ? certFile->toLatin1().constData() : nullptr, - [](icclient_response* response) { + [](interchange_response* response) { const_cast(response->data)[response->numBytes] = '\0'; QString brand{response->data}; - icclient_free_response(response); - shop = new Client{QString{QString{SECURE_SERVER} % "/" % brand}.toLatin1().constData(), + interchange_free_response(response); + shop = new Interchange{QString{QString{SECURE_SERVER} % "/" % brand}.toLatin1().constData(), QString{"/" % brand % "/images"}.toLatin1().constData(), certFile ? certFile->toLatin1().constData() : nullptr}; if (certFile) delete certFile; @@ -63,7 +63,7 @@ void Controller::link(QString const& brand) void Controller::allProducts(QString const& brand) { - connect(shop, &Client::gotCatalog, [brand](QString const& response) { + connect(shop, &Interchange::gotCatalog, [brand](QString const& response) { ::allProducts = new Catalog{catalog(response.toLatin1().constData(), QString{"/" % brand % "/images"}.toLatin1().constData())}; engine->rootContext()->setContextProperty("catalog", ::allProducts); diff --git a/handler.c b/handler.c index 37469ba..782a3e2 100644 --- a/handler.c +++ b/handler.c @@ -2,12 +2,12 @@ #include #include #include -#include +#include #define SUBDIR "/items" static void recurse_catalog(TidyDoc doc, TidyNode tnod, const char *image_dir, - struct icclient_catalog **catalog) + struct interchange_catalog **catalog) { for (TidyNode child = tidyGetChild(tnod); child; child = tidyGetNext(child)) { ctmbstr name = tidyNodeGetName(child); @@ -29,8 +29,8 @@ static void recurse_catalog(TidyDoc doc, TidyNode tnod, const char *image_dir, } if (bail) continue; - struct icclient_product *product = malloc(sizeof(struct icclient_product)); - memset(product, '\0', sizeof(struct icclient_product)); + struct interchange_product *product = malloc(sizeof(struct interchange_product)); + memset(product, '\0', sizeof(struct interchange_product)); for (TidyAttr attr = tidyAttrFirst(child); attr; attr = tidyAttrNext(attr)) { name = tidyAttrName(attr); ctmbstr value = tidyAttrValue(attr); @@ -47,19 +47,19 @@ static void recurse_catalog(TidyDoc doc, TidyNode tnod, const char *image_dir, } } (*catalog)->length++; - *catalog = realloc(*catalog, sizeof(struct icclient_catalog) - + sizeof(struct icclient_product *[(*catalog)->length])); + *catalog = realloc(*catalog, sizeof(struct interchange_catalog) + + sizeof(struct interchange_product *[(*catalog)->length])); (*catalog)->products[(*catalog)->length - 1] = product; } } -struct icclient_catalog *catalog(const char *response, const char *image_dir) +struct interchange_catalog *catalog(const char *response, const char *image_dir) { TidyDoc tdoc = tidyCreate(); TidyBuffer output = {0}; tidyParseString(tdoc, response); tidySaveBuffer(tdoc, &output); - struct icclient_catalog *catalog = malloc(sizeof(struct icclient_catalog)); + struct interchange_catalog *catalog = malloc(sizeof(struct interchange_catalog)); catalog->length = 0; recurse_catalog(tdoc, tidyGetRoot(tdoc), image_dir, &catalog); tidyBufFree(&output); diff --git a/namatoko.pro b/namatoko.pro index 3c00904..72fcdd0 100644 --- a/namatoko.pro +++ b/namatoko.pro @@ -24,8 +24,8 @@ wasm { LIBS += -ltidy } LIBS += \ - -licclient -!android: LIBS += -lqicclient + -linterchange +!android: LIBS += -lqinterchange android { QT += svg PREFIX = $$ANDROID_NDK_PATH/toolchains/llvm/prebuilt/$$ANDROID_NDK_HOST/sysroot/usr @@ -36,15 +36,15 @@ android { LIBS += \ -L$$PREFIX/lib/$$TRIPLE/$$API \ -L$$QT_ANDROID_LIBDIR \ - -lqicclient_$$ANDROID_TARGET_ARCH \ + -lqinterchange_$$ANDROID_TARGET_ARCH \ -ltidy ANDROID_EXTRA_LIBS += \ $$PREFIX/lib/$$TRIPLE/$$API/libcrypto_1_1.so \ $$PREFIX/lib/$$TRIPLE/$$API/libssl_1_1.so \ $$PREFIX/lib/$$TRIPLE/$$API/libcurl.so \ $$PREFIX/lib/$$TRIPLE/$$API/libtidy.so \ - $$PREFIX/lib/$$TRIPLE/$$API/libicclient.so \ - $$QT_ANDROID_LIBDIR/libqicclient_$${ANDROID_TARGET_ARCH}.so + $$PREFIX/lib/$$TRIPLE/$$API/libinterchange.so \ + $$QT_ANDROID_LIBDIR/libqinterchange_$${ANDROID_TARGET_ARCH}.so assets.path = /assets assets.files = $$CA_BUNDLE INSTALLS += assets diff --git a/registration.c b/registration.c index 5f21f74..d63f087 100644 --- a/registration.c +++ b/registration.c @@ -1,6 +1,6 @@ #include #include -#include +#include #ifdef DEBUG #ifdef __ANDROID__ @@ -19,11 +19,11 @@ struct container { CURL *curl; - void (*handler)(icclient_response *); - icclient_response *response; + void (*handler)(interchange_response *); + interchange_response *response; }; -static size_t append(char *data, size_t size, size_t nmemb, icclient_response *response) +static size_t append(char *data, size_t size, size_t nmemb, interchange_response *response) { size_t realsize = size * nmemb; response->data = realloc(response->data, response->numBytes + realsize + 1); @@ -58,7 +58,7 @@ static int async(void *arg) } #endif -void sign_up(const char *brand, const char *certificate, void (*handler)(icclient_response *)) +void sign_up(const char *brand, const char *certificate, void (*handler)(interchange_response *)) { char *data = malloc(strlen(brand) + 1); strcpy(data, brand); @@ -72,7 +72,7 @@ void sign_up(const char *brand, const char *certificate, void (*handler)(icclien attr.requestData = data; attr.requestDataSize = strlen(data); attr.onsuccess = handler; - attr.onerror = icclient_free_response; + attr.onerror = interchange_free_response; emscripten_fetch(&attr, "registration"); #else curl_global_init(CURL_GLOBAL_SSL); @@ -85,7 +85,7 @@ void sign_up(const char *brand, const char *certificate, void (*handler)(icclien #endif curl_easy_setopt(curl, CURLOPT_URL, SECURE_SERVER"/registration"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, append); - icclient_response *response = malloc(sizeof(icclient_response)); + interchange_response *response = malloc(sizeof(interchange_response)); response->data = malloc(1); response->numBytes = 0; response->userData = data; -- cgit v1.2.3