1
0
mirror of https://gitlab.com/comunic/comunicterm synced 2024-12-25 13:08:54 +00:00

Show basic window

This commit is contained in:
Pierre HUBERT 2020-01-08 17:43:04 +01:00
parent b7ef4ddf40
commit d190a7ecce
4 changed files with 86 additions and 9 deletions

View File

@ -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

61
loginscreen.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <ncurses.h>
#include <string.h>
#include <string>
#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<int>(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 */
}

13
loginscreen.h Normal file
View File

@ -0,0 +1,13 @@
/**
* Login screen
*
* @author Pierre HUBERT
*/
class LoginScreen
{
public:
LoginScreen();
bool exec();
};

View File

@ -1,18 +1,19 @@
#include <iostream>
#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;
}