summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-18 10:09:12 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-18 10:09:12 +0800
commita7e82434ad76c9a254f81dd116b8efe4c7a7208e (patch)
treea94c1de86d7833b66a524db62dd2c36109c4ad3a
parent4f0a8bdb67c1dea70e92465ff91bdefb6073dcdd (diff)
Interface for setting successPage
-rw-r--r--admin.cxx11
-rw-r--r--interchange/admin.hxx5
-rw-r--r--interchange/member.hxx2
-rw-r--r--member.cxx27
4 files changed, 35 insertions, 10 deletions
diff --git a/admin.cxx b/admin.cxx
index 4c65c7b..9a49a1f 100644
--- a/admin.cxx
+++ b/admin.cxx
@@ -4,10 +4,11 @@
namespace QInterchange {
- static char *unCopy, *pwCopy, *npCopy, *fpCopy;
+ static char *unCopy, *pwCopy, *npCopy, *spCopy, *fpCopy;
void Admin::logIn(QString const& username, QString const& password,
- QString const& nextPage, QString const& failPage)
+ QString const& nextPage, QString const& successPage,
+ QString const& failPage)
{
auto unData = username.toLatin1().constData();
unCopy = (char*)malloc(strlen(unData) + 1);
@@ -18,14 +19,18 @@ namespace QInterchange {
auto npData = nextPage.toLatin1().constData();
npCopy = (char*)malloc(strlen(npData) + 1);
strcpy(npCopy, npData);
+ auto spData = successPage.toLatin1().constData();
+ spCopy = (char*)malloc(strlen(spData) + 1);
+ strcpy(spCopy, spData);
auto fpData = failPage.toLatin1().constData();
fpCopy = (char*)malloc(strlen(fpData) + 1);
strcpy(fpCopy, fpData);
- interchange_admin_login(unCopy, pwCopy, npCopy, fpCopy,
+ interchange_admin_login(unCopy, pwCopy, npCopy, spCopy, fpCopy,
[](interchange_response* response) {
free(unCopy);
free(pwCopy);
free(npCopy);
+ free(spCopy);
free(fpCopy);
interchange_free_response(response);
}, nullptr);
diff --git a/interchange/admin.hxx b/interchange/admin.hxx
index 1f00df4..4642e76 100644
--- a/interchange/admin.hxx
+++ b/interchange/admin.hxx
@@ -39,8 +39,9 @@ namespace QInterchange {
public slots:
void logIn(QString const& username,
QString const& password,
- QString const& nextPage = nullptr,
- QString const& failPage = nullptr);
+ QString const& nextPage = "",
+ QString const& successPage = "",
+ QString const& failPage = "");
void newAdmin(QString const& userName, QString const& password, QString const& name, bool super,
enum interchange_admin_group group);
void newItem(QString const& description, QString const& comment, QString const& price,
diff --git a/interchange/member.hxx b/interchange/member.hxx
index 5137071..9b54493 100644
--- a/interchange/member.hxx
+++ b/interchange/member.hxx
@@ -82,10 +82,12 @@ namespace QInterchange {
QString const& password,
QString const& confirm,
QString const& nextPage = "",
+ QString const& successPage = "",
QString const& failPage = "");
void logIn(QString const& userName,
QString const& passWord,
QString const& nextPage = "",
+ QString const& successPage = "",
QString const& failPage = "");
void account();
void setAccount(QString const& firstName,
diff --git a/member.cxx b/member.cxx
index 420f76c..c716c83 100644
--- a/member.cxx
+++ b/member.cxx
@@ -5,7 +5,7 @@
namespace QInterchange {
static Member* member;
- static char *unCopy, *pwCopy, *vCopy, *npCopy, *fpCopy;
+ static char *unCopy, *pwCopy, *vCopy, *npCopy, *spCopy, *fpCopy;
static interchange_member* mPtr;
Member::Member(interchange_member data, QObject* parent) :
@@ -98,7 +98,8 @@ namespace QInterchange {
void Member::newAccount(QString const& username,
QString const& password, QString const& verify,
- QString const& nextPage, QString const& failPage)
+ QString const& nextPage, QString const& successPage,
+ QString const& failPage)
{
unCopy = (char*)malloc(username.size() + 1);
strcpy(unCopy, username.toLatin1().constData());
@@ -112,6 +113,12 @@ namespace QInterchange {
npCopy = (char*)malloc(nextPage.size() + 1);
strcpy(npCopy, nextPage.toLatin1().constData());
}
+ if (successPage.isEmpty())
+ spCopy = nullptr;
+ else {
+ spCopy = (char*)malloc(successPage.size() + 1);
+ strcpy(spCopy, successPage.toLatin1().constData());
+ }
if (failPage.isEmpty())
fpCopy = nullptr;
else {
@@ -119,11 +126,13 @@ namespace QInterchange {
strcpy(fpCopy, failPage.toLatin1().constData());
}
interchange_member_newaccount(unCopy, pwCopy, vCopy, npCopy,
- fpCopy, [](interchange_response* response) {
+ spCopy, fpCopy,
+ [](interchange_response* response) {
free(unCopy);
free(pwCopy);
free(vCopy);
if (npCopy) free(npCopy);
+ if (spCopy) free(spCopy);
if (fpCopy) free(fpCopy);
member->emitCreation(QString{response->data});
interchange_free_response(response);
@@ -131,7 +140,8 @@ namespace QInterchange {
}
void Member::logIn(QString const& username, QString const& password,
- QString const& nextPage, QString const& failPage)
+ QString const& nextPage, QString const& successPage,
+ QString const& failPage)
{
unCopy = (char*)malloc(username.size() + 1);
strcpy(unCopy, username.toLatin1().constData());
@@ -143,17 +153,24 @@ namespace QInterchange {
npCopy = (char*)malloc(nextPage.size() + 1);
strcpy(npCopy, nextPage.toLatin1().constData());
}
+ if (successPage.isEmpty())
+ spCopy = nullptr;
+ else {
+ spCopy = (char*)malloc(successPage.size() + 1);
+ strcpy(spCopy, successPage.toLatin1().constData());
+ }
if (failPage.isEmpty())
fpCopy = nullptr;
else {
fpCopy = (char*)malloc(failPage.size() + 1);
strcpy(fpCopy, failPage.toLatin1().constData());
}
- interchange_member_login(unCopy, pwCopy, npCopy, fpCopy,
+ interchange_member_login(unCopy, pwCopy, npCopy, spCopy, fpCopy,
[](interchange_response* response) {
free(unCopy);
free(pwCopy);
if (npCopy) free(npCopy);
+ if (spCopy) free(spCopy);
if (fpCopy) free(fpCopy);
member->emitLogin(QString{response->data});
interchange_free_response(response);