1
0
mirror of https://gitlab.com/comunic/comunicterm synced 2024-07-03 14:09:16 +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 -= app_bundle
CONFIG -= qt CONFIG -= qt
LIBS += -lboost_system -lcrypto -lssl -lcpprest LIBS += -lboost_system -lcrypto -lssl -lcpprest -lncurses
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \
api_request.cpp \ api_request.cpp \
apiresponse.cpp apiresponse.cpp \
loginscreen.cpp
HEADERS += \ HEADERS += \
config.h \ config.h \
api_request.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 <iostream>
#include "api_request.h" #include "api_request.h"
#include "loginscreen.h"
using namespace std; using namespace std;
int main() int main()
{ {
cout << "Comunic Term (c) Pierre HUBERT" << endl; cout << "Comunic Term (c) Pierre HUBERT" << endl;
auto req = ApiRequest("user/getInfosMultiple"); // First, we need to sign in user
req.addArg("usersID", "1"); if(!LoginScreen().exec()) {
auto res = req.exec(); cerr << "Could not sign in user!" << endl;
cout << "code: " << res.code() << endl; return -1;
cout << "content" << res.content().serialize() << endl; }
cout << "First name found: " << res.object().at("1").as_object().at(U("firstName")).as_string() << endl;
return 0; return 0;
} }