From d190a7ecceef9690e2ea841963e1624d2028e262 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 8 Jan 2020 17:43:04 +0100 Subject: [PATCH] Show basic window --- ComunicTerm.pro | 8 ++++--- loginscreen.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ loginscreen.h | 13 +++++++++++ main.cpp | 13 ++++++----- 4 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 loginscreen.cpp create mode 100644 loginscreen.h diff --git a/ComunicTerm.pro b/ComunicTerm.pro index 9dc0493..8d23111 100644 --- a/ComunicTerm.pro +++ b/ComunicTerm.pro @@ -3,14 +3,16 @@ CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt -LIBS += -lboost_system -lcrypto -lssl -lcpprest +LIBS += -lboost_system -lcrypto -lssl -lcpprest -lncurses SOURCES += \ main.cpp \ api_request.cpp \ - apiresponse.cpp + apiresponse.cpp \ + loginscreen.cpp HEADERS += \ config.h \ api_request.h \ - apiresponse.h + apiresponse.h \ + loginscreen.h diff --git a/loginscreen.cpp b/loginscreen.cpp new file mode 100644 index 0000000..ba482c5 --- /dev/null +++ b/loginscreen.cpp @@ -0,0 +1,61 @@ +#include +#include + +#include + +#include "loginscreen.h" + +using namespace std; + +LoginScreen::LoginScreen() +{ + +} + +bool LoginScreen::exec() +{ + initscr(); /* Start curses mode */ + keypad(stdscr, TRUE); // Listen to function keys + + + printw("ComunicTerm"); /* Print Hello World */ + refresh(); /* Print it on to the real screen */ + + + // Get screen size + int row, col; + getmaxyx(stdscr, row, col); + + const string msg = "Light client"; + mvprintw(0, (col-static_cast(msg.length())), msg.c_str()); + refresh(); + + + int startX = (row-4*2)/2; + int startY = (col-50)/2; + + + mvprintw(startX, startY, "Please login to your Comunic account:"); + + // Ask for email + wattron(stdscr, A_REVERSE); + mvprintw(startX+2, startY, "Email address:"); + wattroff(stdscr, A_REVERSE); + + + // Ask for password + wattron(stdscr, A_REVERSE); + mvprintw(startX+4, startY, "Password:"); + wattroff(stdscr, A_REVERSE); + + // Validate button + wattron(stdscr, A_REVERSE); + mvprintw(startX+6, startY, "Login"); + wattroff(stdscr, A_REVERSE); + + refresh(); + + + getch(); /* Wait for user input */ + endwin(); /* End curses mode */ +} diff --git a/loginscreen.h b/loginscreen.h new file mode 100644 index 0000000..3579f81 --- /dev/null +++ b/loginscreen.h @@ -0,0 +1,13 @@ +/** + * Login screen + * + * @author Pierre HUBERT + */ + +class LoginScreen +{ +public: + LoginScreen(); + + bool exec(); +}; diff --git a/main.cpp b/main.cpp index bb8d080..e094a1f 100644 --- a/main.cpp +++ b/main.cpp @@ -1,18 +1,19 @@ #include #include "api_request.h" +#include "loginscreen.h" + using namespace std; int main() { cout << "Comunic Term (c) Pierre HUBERT" << endl; - auto req = ApiRequest("user/getInfosMultiple"); - req.addArg("usersID", "1"); - auto res = req.exec(); - cout << "code: " << res.code() << endl; - cout << "content" << res.content().serialize() << endl; - cout << "First name found: " << res.object().at("1").as_object().at(U("firstName")).as_string() << endl; + // First, we need to sign in user + if(!LoginScreen().exec()) { + cerr << "Could not sign in user!" << endl; + return -1; + } return 0; }