add read users list

This commit is contained in:
Guillermo Roche 2020-05-20 00:10:05 +02:00
parent 1fb645b003
commit 0b1bb18f83
7 changed files with 59 additions and 2 deletions

23
.qmake.stash Normal file
View File

@ -0,0 +1,23 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 9
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9 \
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/x86_64-pc-linux-gnu \
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/backward \
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include \
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include-fixed \
/usr/include
QMAKE_CXX.LIBDIRS = \
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0 \
/usr/lib64 \
/lib64 \
/usr/x86_64-pc-linux-gnu/lib \
/usr/lib \
/lib

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2020-05-19T00:02:05. -->
<!-- Written by QtCreator 4.8.2, 2020-05-20T00:08:38. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -10,6 +10,7 @@ public:
data_acces();
virtual std::string get_passwd(std::string username) = 0;
virtual std::list<std::string> get_pinfo()=0;
virtual std::list<std::string> get_uinfo()=0;
virtual void write_install(std::string package, std::string user)=0;
virtual void write_remove(std::string)=0;
virtual bool get_package_exists(std::string package)=0;

View File

@ -43,6 +43,27 @@ std::list<std::string> msql_acces::get_pinfo(){
return ret;
}
std::list<std::string> msql_acces::get_uinfo(){
sql::PreparedStatement *pstmt =
con->prepareStatement("select username,admin from users");
sql::ResultSet *res = pstmt->executeQuery();
std::list<std::string> ret;
std::string aux;
while(res->next()){
aux="";
aux += res->getString(1);
//aux += ":"+res->getString(2);
if(res->getBoolean(2)){
aux+=":t";
}else{
aux+=":f";
}
ret.push_back(aux);
}
delete res;
return ret;
}
void msql_acces::write_install(std::string package, std::string user){
sql::PreparedStatement *pstmt =
con->prepareStatement("insert into packages(name,user) values(?,(select id from users where username=?))");

View File

@ -14,6 +14,7 @@ public:
msql_acces();
std::string get_passwd(std::string username);
std::list<std::string> get_pinfo();
std::list<std::string> get_uinfo();
void write_install(std::string package, std::string user);
void write_remove(std::string);
bool get_package_exists(std::string package);

View File

@ -38,7 +38,9 @@ void session_manager::start_dialog(){
this->send_information();
}else if(strcmp(buffer, "remv")==0){
this->remove();
}else if(strcmp(buffer,"exit")){
}else if(strcmp(buffer,"uinf")==0){
this->send_user_info();
}else if(strcmp(buffer,"exit")==0){
break;
}
}
@ -119,6 +121,14 @@ void session_manager::send_information(){
this->write_data("end:info");
}
void session_manager::send_user_info(){
std::list<std::string> lis=this->data->get_uinfo();
for(std::string info : lis){
this->write_data(info);
}
this->write_data("end:info");
}
int session_manager::read_data(char* input, int size){
return read(this->fd, input, size);
}

View File

@ -10,6 +10,7 @@ public:
int execute();
int remove();
void send_information();
void send_user_info();
bool validate_pass();
private:
std::string appli_command(char comand[], char* n_package);