Fixed send information about package and added SQL script installer
This commit is contained in:
parent
5f772f4db8
commit
1fb645b003
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.8.2, 2020-05-16T01:41:19. -->
|
||||
<!-- Written by QtCreator 4.8.2, 2020-05-19T00:02:05. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -74,7 +74,7 @@ void conexion_client(int client){
|
||||
exit(EXIT_FAILURE);
|
||||
}else{
|
||||
session_manager* session = new session_manager(client);
|
||||
while(session->validate_pass());
|
||||
while(!session->validate_pass());
|
||||
session->start_dialog();
|
||||
delete (session);
|
||||
close(client);
|
||||
|
17
installDB.sql
Normal file
17
installDB.sql
Normal file
@ -0,0 +1,17 @@
|
||||
create database bin_database;
|
||||
use bin_database;
|
||||
|
||||
create table users(
|
||||
id int key not null auto_increment,
|
||||
username varchar(30),
|
||||
passwd varchar(30)
|
||||
);
|
||||
|
||||
create table packages(
|
||||
id int key not null auto_increment,
|
||||
created date default CURRENT_TIME(),
|
||||
name varchar(30),
|
||||
uses bool default false,
|
||||
user int,
|
||||
foreign key (user) references users(id)
|
||||
);
|
@ -20,19 +20,24 @@ std::string msql_acces::get_passwd(std::string username){
|
||||
}
|
||||
|
||||
std::list<std::string> msql_acces::get_pinfo(){
|
||||
sql::PreparedStatement *pstmt = con->prepareStatement("select * from packages");
|
||||
sql::PreparedStatement *pstmt =
|
||||
con->prepareStatement("select packages.name, packages.created, packages.uses, users.username "
|
||||
"from packages "
|
||||
"join users on users.id=packages.user ");
|
||||
sql::ResultSet *res = pstmt->executeQuery();
|
||||
std::list<std::string> ret;
|
||||
std::string aux;
|
||||
while(res->next()){
|
||||
aux="";
|
||||
aux += res->getString("name");
|
||||
if(res->getBoolean("uses")){
|
||||
aux+=":true";
|
||||
aux += res->getString(1);
|
||||
aux += ":"+res->getString(2);
|
||||
if(res->getBoolean(3)){
|
||||
aux+=":t";
|
||||
}else{
|
||||
aux+=":false";
|
||||
aux+=":f";
|
||||
}
|
||||
aux += ":"+res->getString("created");
|
||||
aux += ":"+res->getString(4);
|
||||
ret.push_back(aux);
|
||||
}
|
||||
delete res;
|
||||
return ret;
|
||||
|
@ -116,7 +116,7 @@ void session_manager::send_information(){
|
||||
for(std::string info : lis){
|
||||
this->write_data(info);
|
||||
}
|
||||
this->write_data("end:of:the:info");
|
||||
this->write_data("end:info");
|
||||
}
|
||||
|
||||
int session_manager::read_data(char* input, int size){
|
||||
|
Loading…
Reference in New Issue
Block a user