From 1e3acb613c9bfcc87c88aa6bfde2b21330dd7dd3 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: Thu, 12 Jan 2023 15:13:44 +0800 Subject: New account wrapper --- interchange/member.hxx | 3 +++ member.cxx | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/interchange/member.hxx b/interchange/member.hxx index bd569c6..c75c7a3 100644 --- a/interchange/member.hxx +++ b/interchange/member.hxx @@ -99,6 +99,9 @@ namespace QInterchange { void setEmail(QString const& email); public slots: + void newAccount(QString const& username, + QString const& password, + QString const& confirm); void logIn(QString const& username, QString const& password); void account(QString const& firstName, QString const& lastName, QString const& address1, QString const& address2, diff --git a/member.cxx b/member.cxx index ee05be8..ab772d0 100644 --- a/member.cxx +++ b/member.cxx @@ -4,7 +4,28 @@ namespace QInterchange { - static char *unCopy, *pwCopy; + static char *unCopy, *pwCopy, *cfCopy; + + void Member::newAccount(QString const& username, + QString const& password, QString const& confirm) + { + auto unData = username.toLatin1().constData(); + unCopy = (char*)malloc(strlen(unData) + 1); + strcpy(unCopy, unData); + auto pwData = password.toLatin1().constData(); + pwCopy = (char*)malloc(strlen(pwData) + 1); + strcpy(pwCopy, pwData); + auto cfData = confirm.toLatin1().constData(); + cfCopy = (char*)malloc(strlen(cfData) + 1); + strcpy(cfCopy, cfData); + interchange_member_newaccount(unCopy, pwCopy, cfCopy, + [](interchange_response* response) { + free(unCopy); + free(pwCopy); + free(cfCopy); + interchange_free_response(response); + }, nullptr); + } void Member::logIn(QString const& username, QString const& password) { -- cgit v1.2.3