add send info
This commit is contained in:
parent
e5078b4969
commit
726d990d20
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.8.2, 2020-05-07T01:43:45. -->
|
||||
<!-- Written by QtCreator 4.8.2, 2020-05-11T02:55:05. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -2,12 +2,14 @@
|
||||
#define DATA_ACCES_H
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
class data_acces
|
||||
{
|
||||
public:
|
||||
data_acces();
|
||||
virtual std::string get_passwd(std::string username) = 0;
|
||||
virtual std::list<std::string> get_pinfo()=0;
|
||||
};
|
||||
|
||||
#endif // DATA_ACCES_H
|
||||
|
@ -18,3 +18,22 @@ std::string msql_acces::get_passwd(std::string username){
|
||||
delete res;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::list<std::string> msql_acces::get_pinfo(){
|
||||
sql::PreparedStatement *pstmt = con->prepareStatement("select * from packages");
|
||||
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";
|
||||
}else{
|
||||
aux+=":false";
|
||||
}
|
||||
aux += ":"+res->getString("created");
|
||||
}
|
||||
delete res;
|
||||
return ret;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ class msql_acces : public data_acces
|
||||
public:
|
||||
msql_acces();
|
||||
std::string get_passwd(std::string username);
|
||||
std::list<std::string> get_pinfo();
|
||||
private:
|
||||
sql::Connection *con;
|
||||
sql::Driver *driver;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "session_manager.h"
|
||||
#include "msql_acces.h"
|
||||
|
||||
#include "config_package.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <iostream>
|
||||
@ -44,6 +44,7 @@ void session_manager::start_dialog(){
|
||||
int session_manager::execute(){
|
||||
char* n_package = new char[256];
|
||||
this->read_data(n_package, 256);
|
||||
config_package conf = config_package(n_package);
|
||||
this->args=new char*[4];
|
||||
this->args[0]="emerge";
|
||||
this->args[1]="--ask";
|
||||
@ -69,7 +70,11 @@ int session_manager::execute(){
|
||||
}
|
||||
|
||||
void session_manager::send_information(){
|
||||
|
||||
std::list<std::string> lis=this->data->get_pinfo();
|
||||
for(std::string info : lis){
|
||||
this->write_data(info);
|
||||
}
|
||||
this->write_data("end:of:the:info");
|
||||
}
|
||||
|
||||
int session_manager::read_data(char* input, int size){
|
||||
|
Loading…
Reference in New Issue
Block a user