diff --git a/ServidorTFG.pro.user b/ServidorTFG.pro.user index b894de6..d43094f 100644 --- a/ServidorTFG.pro.user +++ b/ServidorTFG.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/conexion.cpp b/conexion.cpp index f429cd2..b4024ab 100644 --- a/conexion.cpp +++ b/conexion.cpp @@ -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); diff --git a/installDB.sql b/installDB.sql new file mode 100644 index 0000000..9321f8e --- /dev/null +++ b/installDB.sql @@ -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) +); \ No newline at end of file diff --git a/msql_acces.cpp b/msql_acces.cpp index f8b65f3..c3beda8 100644 --- a/msql_acces.cpp +++ b/msql_acces.cpp @@ -20,19 +20,24 @@ std::string msql_acces::get_passwd(std::string username){ } std::list 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 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; diff --git a/session_manager.cpp b/session_manager.cpp index 9d65c01..92b8ee7 100644 --- a/session_manager.cpp +++ b/session_manager.cpp @@ -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){