fix client install comunication
This commit is contained in:
parent
9f7dbd6cf7
commit
5f772f4db8
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.8.2, 2020-05-11T02:55:05. -->
|
||||
<!-- Written by QtCreator 4.8.2, 2020-05-16T01:41:19. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -75,7 +75,7 @@ void conexion_client(int client){
|
||||
}else{
|
||||
session_manager* session = new session_manager(client);
|
||||
while(session->validate_pass());
|
||||
session->execute();
|
||||
session->start_dialog();
|
||||
delete (session);
|
||||
close(client);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ void conexion_client(SSL_CTX *ctx,int client){
|
||||
else {
|
||||
session_manager* session = new session_manager_ssl(ssl);
|
||||
while(!session->validate_pass());
|
||||
session->execute();
|
||||
session->start_dialog();
|
||||
//SSL_write(ssl,std::to_string(la->execute()).data() , sizeof (int));
|
||||
delete (session);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
virtual std::list<std::string> get_pinfo()=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;
|
||||
};
|
||||
|
||||
#endif // DATA_ACCES_H
|
||||
|
@ -52,3 +52,14 @@ void msql_acces::write_remove(std::string package){
|
||||
pstmt->setString(1,package);
|
||||
pstmt->executeUpdate();
|
||||
}
|
||||
|
||||
bool msql_acces::get_package_exists(std::string package){
|
||||
sql::PreparedStatement *pstmt = con->prepareStatement("select count(id) from packages where name=?");
|
||||
pstmt->setString(1,package);
|
||||
sql::ResultSet *res = pstmt->executeQuery();
|
||||
int ret=0;
|
||||
while(res->next())
|
||||
ret = res->getInt(1);
|
||||
|
||||
return ret>0;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
std::list<std::string> get_pinfo();
|
||||
void write_install(std::string package, std::string user);
|
||||
void write_remove(std::string);
|
||||
bool get_package_exists(std::string package);
|
||||
private:
|
||||
sql::Connection *con;
|
||||
sql::Driver *driver;
|
||||
|
@ -45,8 +45,9 @@ void session_manager::start_dialog(){
|
||||
}
|
||||
|
||||
int session_manager::execute(){
|
||||
char* n_package = new char[256];
|
||||
this->read_data(n_package, 256);
|
||||
char* n_package = new char[250];
|
||||
this->read_data(n_package, 5);
|
||||
this->read_data(n_package, 250);
|
||||
char* use_conf=new char[256];
|
||||
this->read_data(use_conf,2);
|
||||
if(strcmp(use_conf,"y")==0){
|
||||
@ -62,7 +63,9 @@ int session_manager::execute(){
|
||||
if(result=="err"){
|
||||
return -1;
|
||||
}else{
|
||||
this->data->write_install(n_package, user);
|
||||
if(!this->data->get_package_exists(result)){
|
||||
this->data->write_install(result, user);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -74,7 +77,7 @@ int session_manager::remove(){
|
||||
if(result=="err"){
|
||||
return -1;
|
||||
}else{
|
||||
this->data->write_remove(n_package);
|
||||
this->data->write_remove(result);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user