diff --git a/ClienteTFG.pro b/ClienteTFG.pro index fa23e6b..94e0832 100644 --- a/ClienteTFG.pro +++ b/ClienteTFG.pro @@ -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 diff --git a/ClienteTFG.pro.user b/ClienteTFG.pro.user index 5c54b86..9a8c889 100644 --- a/ClienteTFG.pro.user +++ b/ClienteTFG.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/container_window.cpp b/container_window.cpp index 5b8db55..abc8e9b 100644 --- a/container_window.cpp +++ b/container_window.cpp @@ -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); diff --git a/container_window.h b/container_window.h index bdab77d..45a23b1 100644 --- a/container_window.h +++ b/container_window.h @@ -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 +#include 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 sesion; view_loggin loggin; - vista install; - controlador *cont; + view_install install; + controller_install *cont; Gtk::Notebook book; }; diff --git a/controlador.cpp b/controlador.cpp deleted file mode 100644 index 3a0fb19..0000000 --- a/controlador.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "controlador.h" - -#include - -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; -} diff --git a/controlador.h b/controlador.h deleted file mode 100644 index 10f7023..0000000 --- a/controlador.h +++ /dev/null @@ -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 diff --git a/controller_install.cpp b/controller_install.cpp new file mode 100644 index 0000000..40e8fe8 --- /dev/null +++ b/controller_install.cpp @@ -0,0 +1,25 @@ +#include "controller_install.h" + +#include + +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); +} diff --git a/controller_install.h b/controller_install.h new file mode 100644 index 0000000..8df626e --- /dev/null +++ b/controller_install.h @@ -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 diff --git a/session_manager.cpp b/session_manager.cpp index 5be03ac..a7bd62b 100644 --- a/session_manager.cpp +++ b/session_manager.cpp @@ -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()); +} diff --git a/session_manager.h b/session_manager.h index e08b23a..985bcd6 100644 --- a/session_manager.h +++ b/session_manager.h @@ -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 diff --git a/vista.cpp b/view_install.cpp similarity index 90% rename from vista.cpp rename to view_install.cpp index 460f11f..80340b4 100644 --- a/vista.cpp +++ b/view_install.cpp @@ -1,7 +1,7 @@ -#include "vista.h" +#include "view_install.h" #include -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); diff --git a/vista.h b/view_install.h similarity index 88% rename from vista.h rename to view_install.h index db4d5e6..13e0405 100644 --- a/vista.h +++ b/view_install.h @@ -7,10 +7,10 @@ #include #include -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; diff --git a/view_loggin.cpp b/view_loggin.cpp index ad9fe6c..b62ca7c 100644 --- a/view_loggin.cpp +++ b/view_loggin.cpp @@ -1,14 +1,14 @@ #include "view_loggin.h" -#include "vista.h" -#include "controlador.h" +#include "view_install.h" +#include "controller_install.h" #include -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{ diff --git a/view_loggin.h b/view_loggin.h index 1f31516..a6963e7 100644 --- a/view_loggin.h +++ b/view_loggin.h @@ -6,13 +6,13 @@ #include #include #include -#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;