summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt14
-rw-r--r--Doxyfile6
-rw-r--r--README.md6
-rw-r--r--admin.cxx22
-rw-r--r--catalog.cxx8
-rw-r--r--client.cxx82
-rw-r--r--interchange.cxx82
-rw-r--r--interchange.hxx (renamed from qicclient.hxx)14
-rw-r--r--interchange/admin.hxx (renamed from qicclient/admin.hxx)16
-rw-r--r--interchange/catalog.hxx (renamed from qicclient/catalog.hxx)14
-rw-r--r--interchange/member.hxx (renamed from qicclient/member.hxx)16
-rw-r--r--interchange/ord.hxx (renamed from qicclient/ord.hxx)16
-rw-r--r--interchange/product.hxx (renamed from qicclient/product.hxx)10
-rw-r--r--member.cxx20
-rw-r--r--ord.cxx8
15 files changed, 167 insertions, 167 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0535438..a950ce7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
-project(qicclient)
+project(interchange)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core)
set(HDRS
@@ -12,7 +12,7 @@ set(HDRS
set(SRCS
${PROJECT_NAME}.hxx
${HDRS}
- client.cxx
+ interchange.cxx
catalog.cxx
ord.cxx
member.cxx
@@ -23,15 +23,15 @@ if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
link_directories(/usr/local/lib)
endif()
if (EMSCRIPTEN OR IOS)
- add_library(${PROJECT_NAME} STATIC ${SRCS})
+ add_library(q${PROJECT_NAME} STATIC ${SRCS})
else()
- add_library(${PROJECT_NAME} SHARED ${SRCS})
+ add_library(q${PROJECT_NAME} SHARED ${SRCS})
endif()
-target_link_libraries(${PROJECT_NAME}
+target_link_libraries(q${PROJECT_NAME}
Qt5::Core
- icclient
+ interchange
)
include(GNUInstallDirs)
-install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(TARGETS q${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${PROJECT_NAME}.hxx DESTINATION include)
install(FILES ${HDRS} DESTINATION include/${PROJECT_NAME})
diff --git a/Doxyfile b/Doxyfile
index 7c08d38..5a2f2e7 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
-PROJECT_NAME = qicclient
+PROJECT_NAME = qinterchange
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@@ -829,8 +829,8 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
-INPUT = qicclient.hxx \
- qicclient \
+INPUT = interchange.hxx \
+ interchange \
README.md
# This tag can be used to specify the character encoding of the source files
diff --git a/README.md b/README.md
index c90d9fe..da2655b 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
-# Qt Core wrapper for [libicclient](http://darapsa.org/libicclient)
+# Qt Core wrapper for [libinterchange](http://darapsa.org/libinterchange)
# Building
## Getting
```sh
-$ git clone git://darapsa.org/qicclient.git
-$ cd qicclient
+$ git clone git://darapsa.org/qinterchange.git
+$ cd qinterchange
$ mkdir build && cd build
```
diff --git a/admin.cxx b/admin.cxx
index 2cbd7ae..48e64a1 100644
--- a/admin.cxx
+++ b/admin.cxx
@@ -1,8 +1,8 @@
-#include <icclient.h>
-#include <icclient/admin.h>
-#include "qicclient/admin.hxx"
+#include <interchange.h>
+#include <interchange/admin.h>
+#include "interchange/admin.hxx"
-namespace QICClient {
+namespace Interchange {
static char *unCopy, *pwCopy;
@@ -14,10 +14,10 @@ namespace QICClient {
auto pwData = password.toLatin1().constData();
pwCopy = (char*)malloc(strlen(pwData) + 1);
strcpy(pwCopy, pwData);
- icclient_admin_login(unCopy, pwCopy, [](icclient_response* response) {
+ interchange_admin_login(unCopy, pwCopy, [](interchange_response* response) {
free(unCopy);
free(pwCopy);
- icclient_free_response(response);
+ interchange_free_response(response);
}, nullptr);
}
@@ -50,7 +50,7 @@ namespace QICClient {
}
}
- void Admin::setData(icclient_admin* data)
+ void Admin::setData(interchange_admin* data)
{
if (data && data->username && m_userName != data->username) {
m_userName = QString{data->username};
@@ -74,22 +74,22 @@ namespace QICClient {
}
void Admin::newAdmin(QString const& userName, QString const& password, QString const& name, bool super,
- enum icclient_admin_group group)
+ enum interchange_admin_group group)
{
- icclient_admin_new_admin(userName.toLatin1().constData(), password.toLatin1().constData(),
+ interchange_admin_new_admin(userName.toLatin1().constData(), password.toLatin1().constData(),
name.toLatin1().constData(), super, group, nullptr);
}
void Admin::newItem(QString const& description, QString const& comment,
QString const& price, QString const& imagePath)
{
- icclient_admin_new_item(description.toLatin1().constData(), comment.toLatin1().constData(),
+ interchange_admin_new_item(description.toLatin1().constData(), comment.toLatin1().constData(),
price.toLatin1().constData(), imagePath.toLatin1().constData(), nullptr);
}
void Admin::logOut()
{
- icclient_admin_logout(m_data, nullptr);
+ interchange_admin_logout(m_data, nullptr);
setData(nullptr);
}
diff --git a/catalog.cxx b/catalog.cxx
index 2cee7c2..244544c 100644
--- a/catalog.cxx
+++ b/catalog.cxx
@@ -1,9 +1,9 @@
#include <cstddef>
-#include "qicclient/catalog.hxx"
+#include "interchange/catalog.hxx"
-namespace QICClient {
+namespace Interchange {
- Catalog::Catalog(struct icclient_catalog* catalog, QObject* parent) :
+ Catalog::Catalog(struct interchange_catalog* catalog, QObject* parent) :
QAbstractListModel{parent},
m_data{catalog}
{
@@ -12,7 +12,7 @@ namespace QICClient {
Catalog::~Catalog()
{
- icclient_free_catalog(m_data);
+ interchange_free_catalog(m_data);
}
int Catalog::rowCount(QModelIndex const& parent) const
diff --git a/client.cxx b/client.cxx
deleted file mode 100644
index 28a97fb..0000000
--- a/client.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "qicclient.hxx"
-#include "qicclient/ord.hxx"
-
-namespace QICClient {
-
- static Client* client;
-
- Client::Client(char const* sampleURL, char const* image_Dir, char const* certificate)
- {
- client = this;
- icclient_init(sampleURL, image_Dir, certificate);
- }
-
- Client::~Client()
- {
- icclient_cleanup();
- }
-
- void Client::catalog(QString const& prodGroup)
- {
- icclient_catalog(prodGroup.toLatin1().constData(), [](icclient_response* response) {
- client->emitCatalog(QString{response->data});
- icclient_free_response(response);
- }, nullptr);
- }
-
- void Client::allProducts()
- {
- catalog("All-Products");
- }
-
- void Client::product(QString const& sku)
- {
- icclient_product(sku.toLatin1().constData(), [](icclient_response* response) {
- client->emitProduct(QString{response->data});
- icclient_free_response(response);
- }, nullptr);
- }
-
- void Client::page(QString const& path)
- {
- icclient_page(path.toLatin1().constData(), [](icclient_response* response) {
- client->emitPage(QString{response->data});
- icclient_free_response(response);
- });
- }
-
- void Client::defaultCatalog(QString const& prodGroup)
- {
- icclient_catalog(prodGroup.toLatin1().constData(), nullptr, [](struct icclient_catalog* catalog) {
- icclient_free_catalog(catalog);
- });
- }
-
- void Client::defaultAllProducts()
- {
- defaultCatalog("All-Products");
- }
-
- void Client::emitCatalog(QString const& response)
- {
- emit gotCatalog(response);
- }
-
- void Client::emitProduct(QString const& response)
- {
- emit gotProduct(response);
- }
-
- void Client::emitPage(QString const& response)
- {
- emit gotPage(response);
- }
-
- 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);
- order.setData(c_order);
- }
-
-}
diff --git a/interchange.cxx b/interchange.cxx
new file mode 100644
index 0000000..6886ba9
--- /dev/null
+++ b/interchange.cxx
@@ -0,0 +1,82 @@
+#include "interchange.hxx"
+#include "interchange/ord.hxx"
+
+namespace Interchange {
+
+ static Interchange* interchange;
+
+ Interchange::Interchange(char const* sampleURL, char const* image_Dir, char const* certificate)
+ {
+ interchange = this;
+ interchange_init(sampleURL, image_Dir, certificate);
+ }
+
+ Interchange::~Interchange()
+ {
+ interchange_cleanup();
+ }
+
+ void Interchange::catalog(QString const& prodGroup)
+ {
+ interchange_catalog(prodGroup.toLatin1().constData(), [](interchange_response* response) {
+ interchange->emitCatalog(QString{response->data});
+ interchange_free_response(response);
+ }, nullptr);
+ }
+
+ void Interchange::allProducts()
+ {
+ catalog("All-Products");
+ }
+
+ void Interchange::product(QString const& sku)
+ {
+ interchange_product(sku.toLatin1().constData(), [](interchange_response* response) {
+ interchange->emitProduct(QString{response->data});
+ interchange_free_response(response);
+ }, nullptr);
+ }
+
+ void Interchange::page(QString const& path)
+ {
+ interchange_page(path.toLatin1().constData(), [](interchange_response* response) {
+ interchange->emitPage(QString{response->data});
+ interchange_free_response(response);
+ });
+ }
+
+ void Interchange::defaultCatalog(QString const& prodGroup)
+ {
+ interchange_catalog(prodGroup.toLatin1().constData(), nullptr, [](struct interchange_catalog* catalog) {
+ interchange_free_catalog(catalog);
+ });
+ }
+
+ void Interchange::defaultAllProducts()
+ {
+ defaultCatalog("All-Products");
+ }
+
+ void Interchange::emitCatalog(QString const& response)
+ {
+ emit gotCatalog(response);
+ }
+
+ void Interchange::emitProduct(QString const& response)
+ {
+ emit gotProduct(response);
+ }
+
+ void Interchange::emitPage(QString const& response)
+ {
+ emit gotPage(response);
+ }
+
+ void Interchange::order(QString const& sku, Catalog const& catalog, Ord& order)
+ {
+ auto c_order = order.data();
+ interchange_ord_order(sku.toLatin1().constData(), catalog.constData(), &c_order);
+ order.setData(c_order);
+ }
+
+}
diff --git a/qicclient.hxx b/interchange.hxx
index e52145e..e25a32c 100644
--- a/qicclient.hxx
+++ b/interchange.hxx
@@ -1,14 +1,14 @@
-#ifndef QICCLIENT_HXX
-#define QICCLIENT_HXX
+#ifndef INTERCHANGE_HXX
+#define INTERCHANGE_HXX
#include <QObject>
-#include "qicclient/catalog.hxx"
+#include "interchange/catalog.hxx"
-namespace QICClient {
+namespace Interchange {
class Ord;
- class Client : public QObject
+ class Interchange : public QObject
{
Q_OBJECT
@@ -19,11 +19,11 @@ namespace QICClient {
* \param image_Dir The value of the IMAGE_DIR setting in products/variable.txt.
* \param certificate Path to the CA certificate file.
*/
- Client(char const* sampleURL, char const* image_Dir, char const* certificate = nullptr);
+ Interchange(char const* sampleURL, char const* image_Dir, char const* certificate = nullptr);
/*!
* \brief Destructor.
*/
- ~Client();
+ ~Interchange();
/*!
* \brief For putting an item to a cart.
* \param sku The SKU of the item to order.
diff --git a/qicclient/admin.hxx b/interchange/admin.hxx
index 34202a4..3a800ac 100644
--- a/qicclient/admin.hxx
+++ b/interchange/admin.hxx
@@ -1,12 +1,12 @@
-#ifndef QICCLIENT_ADMIN_HXX
-#define QICCLIENT_ADMIN_HXX
+#ifndef INTERCHANGE_ADMIN_HXX
+#define INTERCHANGE_ADMIN_HXX
#include <QObject>
-#include <icclient/admin.h>
+#include <interchange/admin.h>
-struct icclient_admin;
+struct interchange_admin;
-namespace QICClient {
+namespace Interchange {
class Admin : public QObject
{
@@ -39,7 +39,7 @@ namespace QICClient {
public slots:
void logIn(QString const& username, QString const& password);
void newAdmin(QString const& userName, QString const& password, QString const& name, bool super,
- enum icclient_admin_group group);
+ enum interchange_admin_group group);
void newItem(QString const& description, QString const& comment, QString const& price,
QString const& imagePath);
void logOut();
@@ -55,8 +55,8 @@ namespace QICClient {
QString m_password;
QString m_name;
bool m_super;
- icclient_admin* m_data;
- inline void setData(icclient_admin* data);
+ interchange_admin* m_data;
+ inline void setData(interchange_admin* data);
};
}
diff --git a/qicclient/catalog.hxx b/interchange/catalog.hxx
index 2c7274c..8946113 100644
--- a/qicclient/catalog.hxx
+++ b/interchange/catalog.hxx
@@ -1,12 +1,12 @@
-#ifndef QICCLIENT_CATALOG_HXX
-#define QICCLIENT_CATALOG_HXX
+#ifndef INTERCHANGE_CATALOG_HXX
+#define INTERCHANGE_CATALOG_HXX
#include <QAbstractListModel>
#include "product.hxx"
-struct icclient_catalog;
+struct interchange_catalog;
-namespace QICClient {
+namespace Interchange {
class Catalog : public QAbstractListModel
{
@@ -14,11 +14,11 @@ namespace QICClient {
public:
Catalog(QObject* parent = nullptr) : QAbstractListModel{parent} {}
- Catalog(struct icclient_catalog* catalog, QObject* parent = nullptr);
+ Catalog(struct interchange_catalog* catalog, QObject* parent = nullptr);
~Catalog();
int rowCount(QModelIndex const& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
- struct icclient_catalog const* constData() const { return m_data; }
+ struct interchange_catalog const* constData() const { return m_data; }
protected:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
@@ -26,7 +26,7 @@ namespace QICClient {
private:
void addProduct(Product const& product);
QList<Product> products;
- struct icclient_catalog* m_data;
+ struct interchange_catalog* m_data;
};
}
diff --git a/qicclient/member.hxx b/interchange/member.hxx
index 3d0e45f..d4b1836 100644
--- a/qicclient/member.hxx
+++ b/interchange/member.hxx
@@ -1,12 +1,12 @@
-#ifndef QICCLIENT_MEMBER_HXX
-#define QICCLIENT_MEMBER_HXX
+#ifndef INTERCHANGE_MEMBER_HXX
+#define INTERCHANGE_MEMBER_HXX
#include <QObject>
-#include <icclient/member.h>
+#include <interchange/member.h>
-struct icclient_member;
+struct interchange_member;
-namespace QICClient {
+namespace Interchange {
class Member : public QObject
{
@@ -76,7 +76,7 @@ namespace QICClient {
QString const& country() const { return m_country; }
QString const& phoneDay() const { return m_phoneDay; }
QString const& email() const { return m_email; }
- icclient_member* data() { return m_data; }
+ interchange_member* data() { return m_data; }
void setUserName(QString const& userName);
void setUserNick(QString const& userNick);
@@ -150,8 +150,8 @@ namespace QICClient {
QString m_country;
QString m_phoneDay;
QString m_email;
- icclient_member* m_data;
- inline void setData(icclient_member* data);
+ interchange_member* m_data;
+ inline void setData(interchange_member* data);
};
}
diff --git a/qicclient/ord.hxx b/interchange/ord.hxx
index 5ece6de..afe77cc 100644
--- a/qicclient/ord.hxx
+++ b/interchange/ord.hxx
@@ -1,19 +1,19 @@
-#ifndef QICCLIENT_ORD_HXX
-#define QICCLIENT_ORD_HXX
+#ifndef INTERCHANGE_ORD_HXX
+#define INTERCHANGE_ORD_HXX
#include <QAbstractListModel>
-#include <icclient/ord.h>
+#include <interchange/ord.h>
#include "member.hxx"
#include "product.hxx"
-namespace QICClient {
+namespace Interchange {
struct Item
{
enum ItemRoles {
QuantityRole = Product::PriceRole + 1
};
- Item(icclient_ord_item* item) :
+ Item(interchange_ord_item* item) :
product{item->product},
quantity{item->quantity} {}
Product product;
@@ -42,8 +42,8 @@ namespace QICClient {
int rowCount(QModelIndex const& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
Q_DECL_OVERRIDE;
- struct icclient_ord_order* data() { return m_data; }
- void setData(struct icclient_ord_order* order);
+ struct interchange_ord_order* data() { return m_data; }
+ void setData(struct interchange_ord_order* order);
double subtotal() const { return m_subtotal; }
double shipping() const { return m_shipping; }
double totalCost() const { return m_totalCost; }
@@ -60,7 +60,7 @@ namespace QICClient {
private:
void addItem(Item const& item);
QList<Item> items;
- struct icclient_ord_order* m_data;
+ struct interchange_ord_order* m_data;
double m_subtotal;
double m_shipping;
double m_totalCost;
diff --git a/qicclient/product.hxx b/interchange/product.hxx
index 57f9641..a7f3587 100644
--- a/qicclient/product.hxx
+++ b/interchange/product.hxx
@@ -1,9 +1,9 @@
-#ifndef QICCLIENT_PRODUCT_HXX
-#define QICCLIENT_PRODUCT_HXX
+#ifndef INTERCHANGE_PRODUCT_HXX
+#define INTERCHANGE_PRODUCT_HXX
-#include <icclient.h>
+#include <interchange.h>
-namespace QICClient {
+namespace Interchange {
struct Product
{
@@ -21,7 +21,7 @@ namespace QICClient {
};
Product() {}
- Product(struct icclient_product* product) :
+ Product(struct interchange_product* product) :
price{product->price},
weight{product->weight}
{
diff --git a/member.cxx b/member.cxx
index fb473ea..6b11d53 100644
--- a/member.cxx
+++ b/member.cxx
@@ -1,8 +1,8 @@
-#include <icclient.h>
-#include <icclient/member.h>
-#include "qicclient/member.hxx"
+#include <interchange.h>
+#include <interchange/member.h>
+#include "interchange/member.hxx"
-namespace QICClient {
+namespace Interchange {
static char *unCopy, *pwCopy;
@@ -14,10 +14,10 @@ namespace QICClient {
auto pwData = password.toLatin1().constData();
pwCopy = (char*)malloc(strlen(pwData) + 1);
strcpy(pwCopy, pwData);
- icclient_member_login(unCopy, pwCopy, [](icclient_response* response) {
+ interchange_member_login(unCopy, pwCopy, [](interchange_response* response) {
free(unCopy);
free(pwCopy);
- icclient_free_response(response);
+ interchange_free_response(response);
}, nullptr);
}
@@ -173,7 +173,7 @@ namespace QICClient {
}
}
- void Member::setData(icclient_member* data)
+ void Member::setData(interchange_member* data)
{
if (data && data->username && m_userName != data->username) {
m_userName = QString{data->username};
@@ -278,7 +278,7 @@ namespace QICClient {
QString const& city, QString const& state, QString const& zip,
QString const& email, QString const& phoneDay)
{
- icclient_member_account(firstName.toLatin1().constData(),
+ interchange_member_account(firstName.toLatin1().constData(),
lastName.toLatin1().constData(),
address1.toLatin1().constData(),
address2.toLatin1().constData(),
@@ -290,14 +290,14 @@ namespace QICClient {
void Member::changePassword(QString const& passwordOld, QString const& password,
QString const& verify)
{
- icclient_member_changepassword(passwordOld.toLatin1().constData(),
+ interchange_member_changepassword(passwordOld.toLatin1().constData(),
password.toLatin1().constData(),
verify.toLatin1().constData());
}
void Member::logOut()
{
- icclient_member_logout(m_data);
+ interchange_member_logout(m_data);
setData(nullptr);
}
diff --git a/ord.cxx b/ord.cxx
index 1de7447..1c103e8 100644
--- a/ord.cxx
+++ b/ord.cxx
@@ -1,8 +1,8 @@
#include <algorithm>
#include <memory>
-#include "qicclient/ord.hxx"
+#include "interchange/ord.hxx"
-namespace QICClient {
+namespace Interchange {
int Ord::rowCount(QModelIndex const& parent) const
{
@@ -60,7 +60,7 @@ namespace QICClient {
emit rowCountChanged();
}
- void Ord::setData(struct icclient_ord_order* order)
+ void Ord::setData(struct interchange_ord_order* order)
{
if (!order) return;
this->m_data = order;
@@ -73,6 +73,6 @@ namespace QICClient {
void Ord::checkout(Member& member)
{
- icclient_ord_checkout(m_data, member.data());
+ interchange_ord_checkout(m_data, member.data());
}
}