fix client install comunication

This commit is contained in:
Guillermo Roche 2020-05-16 20:52:10 +02:00
parent 7691c80fb4
commit 9eb45f329a
14 changed files with 82 additions and 66 deletions

View File

@ -11,20 +11,20 @@ SOURCES += \
conexion.cpp \
conexion_ssl.cpp \
config_reader.cpp \
vista.cpp \
controlador.cpp \
view_loggin.cpp \
read_uses.cpp \
session_manager.cpp \
container_window.cpp
container_window.cpp \
view_install.cpp \
controller_install.cpp
HEADERS += \
conexion.h \
conexion_ssl.h \
config_reader.h \
vista.h \
controlador.h \
view_loggin.h \
read_uses.h \
session_manager.h \
container_window.h
container_window.h \
view_install.h \
controller_install.h

View File

@ -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>

View File

@ -1,11 +1,12 @@
#include "container_window.h"
container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application > app):loggin(con)
container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application > app):
sesion(new session_manager(con)),loggin(sesion.get())
{
this->app=app;
this->app->run(loggin);
if(this->loggin.login){
this->cont=new controlador(&install, con);
this->cont=new controller_install(&install, sesion.get());
this->app.reset();
this->app=Gtk::Application::create( "org.gtkmm.examples.base");
this->add(this->book);

View File

@ -1,11 +1,13 @@
#ifndef CONTAINER_WINDOW_H
#define CONTAINER_WINDOW_H
#include "vista.h"
#include "view_install.h"
#include "view_loggin.h"
#include "controlador.h"
#include "controller_install.h"
#include "conexion.h"
#include "session_manager.h"
#include "gtkmm/notebook.h"
#include <gtkmm/notebook.h>
#include <memory>
class container_window: public Gtk::Window
{
@ -13,9 +15,10 @@ public:
container_window(conexion *con, Glib::RefPtr< Gtk::Application > app);
private:
Glib::RefPtr< Gtk::Application > app;
std::unique_ptr<session_manager> sesion;
view_loggin loggin;
vista install;
controlador *cont;
view_install install;
controller_install *cont;
Gtk::Notebook book;
};

View File

@ -1,24 +0,0 @@
#include "controlador.h"
#include <iostream>
controlador::controlador(vista *vis, conexion *con)
{
this->vis=vis;
this->con=con;
this->add_controlers();
}
void controlador::add_controlers(){
vis->m_button.signal_clicked().connect(sigc::mem_fun(this,
&controlador::on_button_clicked));
}
void controlador::on_button_clicked(){
std::string text = vis->m_refTextBuffer1->get_text();
std::cout << text << std::endl;
this->con->write_string("exec");
this->con->write_string(text);
this->con->read_string(text,10);
std::cout << text << std::endl;
}

View File

@ -1,16 +0,0 @@
#ifndef CONTROLADOR_H
#define CONTROLADOR_H
#include "vista.h"
#include "conexion.h"
class controlador
{
public:
controlador(vista*, conexion*);
private:
vista *vis;
conexion *con;
void add_controlers();
void on_button_clicked();
};
#endif // CONTROLADOR_H

25
controller_install.cpp Normal file
View File

@ -0,0 +1,25 @@
#include "controller_install.h"
#include <iostream>
controller_install::controller_install(view_install *vis, session_manager *sesi)
{
this->vis=vis;
this->sesi=sesi;
this->add_controlers();
}
void controller_install::add_controlers(){
vis->m_button.signal_clicked().connect(sigc::mem_fun(this,
&controller_install::on_button_clicked));
}
void controller_install::on_button_clicked(){
std::string text = vis->m_refTextBuffer1->get_text();
/*std::cout << text << std::endl;
this->con->write_string("exec");
this->con->write_string(text);
this->con->read_string(text,10);
std::cout << text << std::endl;*/
this->sesi->install_command(text);
}

17
controller_install.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef CONTROLADOR_H
#define CONTROLADOR_H
#include "view_install.h"
#include "conexion.h"
#include "session_manager.h"
class controller_install
{
public:
controller_install(view_install*, session_manager*);
private:
view_install *vis;
session_manager *sesi;
void add_controlers();
void on_button_clicked();
};
#endif // CONTROLADOR_H

View File

@ -11,6 +11,7 @@ bool session_manager::loggin(std::string username, std::string passwd){
}
int session_manager::install_command(std::string package){
this->con->write_string("exec");
read_uses uses(package);
this->con->write_string(package);
if(uses.exist_file()){
@ -23,3 +24,11 @@ int session_manager::install_command(std::string package){
this->con->read_string(buffer,2);
return atoi(buffer.data());
}
int session_manager::remove_command(std::string package){
this->con->write_string("remv");
this->con->write_string(package);
std::string buffer;
this->con->read_string(buffer,2);
return atoi(buffer.data());
}

View File

@ -12,6 +12,7 @@ public:
conexion* con;
bool loggin(std::string username, std::string passwd);
int install_command(std::string package);
int remove_command(std::string package);
};
#endif // SESSION_MANAGER_H

View File

@ -1,7 +1,7 @@
#include "vista.h"
#include "view_install.h"
#include <iostream>
vista::vista():m_button("send"),m_VBox(Gtk::ORIENTATION_VERTICAL)
view_install::view_install():m_button("send"),m_VBox(Gtk::ORIENTATION_VERTICAL)
{
set_border_width(5);

View File

@ -7,10 +7,10 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/box.h>
class vista : public Gtk::Box
class view_install : public Gtk::Box
{
public:
vista();
view_install();
Gtk::Button m_button;
Gtk::Box m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;

View File

@ -1,14 +1,14 @@
#include "view_loggin.h"
#include "vista.h"
#include "controlador.h"
#include "view_install.h"
#include "controller_install.h"
#include <gtkmm/messagedialog.h>
view_loggin::view_loggin(conexion *con):box_user(Gtk::ORIENTATION_HORIZONTAL), box_pass(Gtk::ORIENTATION_HORIZONTAL),button("check"), box(Gtk::ORIENTATION_VERTICAL)
view_loggin::view_loggin(session_manager *sesi):box_user(Gtk::ORIENTATION_HORIZONTAL), box_pass(Gtk::ORIENTATION_HORIZONTAL),button("check"), box(Gtk::ORIENTATION_VERTICAL)
{
this->set_title("loggin");
this->con=con;
this->sesi=sesi;
set_border_width(5);
this->user.set_text("user");
@ -41,7 +41,7 @@ void view_loggin::on_button_clicked(){
std::string user=this->entry_user.get_text();//this->m_refTextBufferUser->get_text();
std::string pass=this->entry_pass.get_text();//this->m_refTextBufferPass->get_text();
if(con->check_pass(user,pass)){
if(sesi->loggin(user, pass)){
this->login=true;
this->hide();
}else{

View File

@ -6,13 +6,13 @@
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/entry.h>
#include "conexion.h"
#include "session_manager.h"
class view_loggin : public Gtk::Window
{
public:
view_loggin(conexion *con);
conexion *con;
view_loggin(session_manager *sesi);
session_manager *sesi;
Gtk::Label user;
Gtk::Entry entry_user;