fix client install comunication
This commit is contained in:
		
							parent
							
								
									7691c80fb4
								
							
						
					
					
						commit
						9eb45f329a
					
				| @ -11,20 +11,20 @@ SOURCES += \ | |||||||
|     conexion.cpp \ |     conexion.cpp \ | ||||||
|     conexion_ssl.cpp \ |     conexion_ssl.cpp \ | ||||||
|     config_reader.cpp \ |     config_reader.cpp \ | ||||||
|     vista.cpp \ |  | ||||||
|     controlador.cpp \ |  | ||||||
|     view_loggin.cpp \ |     view_loggin.cpp \ | ||||||
|     read_uses.cpp \ |     read_uses.cpp \ | ||||||
|     session_manager.cpp \ |     session_manager.cpp \ | ||||||
|     container_window.cpp |     container_window.cpp \ | ||||||
|  |     view_install.cpp \ | ||||||
|  |     controller_install.cpp | ||||||
| 
 | 
 | ||||||
| HEADERS += \ | HEADERS += \ | ||||||
|     conexion.h \ |     conexion.h \ | ||||||
|     conexion_ssl.h \ |     conexion_ssl.h \ | ||||||
|     config_reader.h \ |     config_reader.h \ | ||||||
|     vista.h \ |  | ||||||
|     controlador.h \ |  | ||||||
|     view_loggin.h \ |     view_loggin.h \ | ||||||
|     read_uses.h \ |     read_uses.h \ | ||||||
|     session_manager.h \ |     session_manager.h \ | ||||||
|     container_window.h |     container_window.h \ | ||||||
|  |     view_install.h \ | ||||||
|  |     controller_install.h | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <!DOCTYPE QtCreatorProject> | <!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> | <qtcreator> | ||||||
|  <data> |  <data> | ||||||
|   <variable>EnvironmentId</variable> |   <variable>EnvironmentId</variable> | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| #include "container_window.h" | #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=app; | ||||||
|   this->app->run(loggin); |   this->app->run(loggin); | ||||||
|   if(this->loggin.login){ |   if(this->loggin.login){ | ||||||
|       this->cont=new controlador(&install, con); |       this->cont=new controller_install(&install, sesion.get()); | ||||||
|       this->app.reset(); |       this->app.reset(); | ||||||
|       this->app=Gtk::Application::create( "org.gtkmm.examples.base"); |       this->app=Gtk::Application::create( "org.gtkmm.examples.base"); | ||||||
|       this->add(this->book); |       this->add(this->book); | ||||||
|  | |||||||
| @ -1,11 +1,13 @@ | |||||||
| #ifndef CONTAINER_WINDOW_H | #ifndef CONTAINER_WINDOW_H | ||||||
| #define CONTAINER_WINDOW_H | #define CONTAINER_WINDOW_H | ||||||
| #include "vista.h" | #include "view_install.h" | ||||||
| #include "view_loggin.h" | #include "view_loggin.h" | ||||||
| #include "controlador.h" | #include "controller_install.h" | ||||||
| #include "conexion.h" | #include "conexion.h" | ||||||
|  | #include "session_manager.h" | ||||||
| 
 | 
 | ||||||
| #include "gtkmm/notebook.h" | #include <gtkmm/notebook.h> | ||||||
|  | #include <memory> | ||||||
| 
 | 
 | ||||||
| class container_window: public Gtk::Window | class container_window: public Gtk::Window | ||||||
| { | { | ||||||
| @ -13,9 +15,10 @@ public: | |||||||
|   container_window(conexion *con, Glib::RefPtr< Gtk::Application > app); |   container_window(conexion *con, Glib::RefPtr< Gtk::Application > app); | ||||||
| private: | private: | ||||||
|   Glib::RefPtr< Gtk::Application > app; |   Glib::RefPtr< Gtk::Application > app; | ||||||
|  |   std::unique_ptr<session_manager> sesion; | ||||||
|   view_loggin loggin; |   view_loggin loggin; | ||||||
|   vista install; |   view_install install; | ||||||
|   controlador *cont; |   controller_install *cont; | ||||||
|   Gtk::Notebook book; |   Gtk::Notebook book; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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; |  | ||||||
| } |  | ||||||
| @ -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
									
								
							
							
						
						
									
										25
									
								
								controller_install.cpp
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										17
									
								
								controller_install.h
									
									
									
									
									
										Normal 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
 | ||||||
| @ -11,6 +11,7 @@ bool session_manager::loggin(std::string username, std::string passwd){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int session_manager::install_command(std::string package){ | int session_manager::install_command(std::string package){ | ||||||
|  |   this->con->write_string("exec"); | ||||||
|   read_uses uses(package); |   read_uses uses(package); | ||||||
|   this->con->write_string(package); |   this->con->write_string(package); | ||||||
|   if(uses.exist_file()){ |   if(uses.exist_file()){ | ||||||
| @ -23,3 +24,11 @@ int session_manager::install_command(std::string package){ | |||||||
|   this->con->read_string(buffer,2); |   this->con->read_string(buffer,2); | ||||||
|   return atoi(buffer.data()); |   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()); | ||||||
|  | } | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ public: | |||||||
|   conexion* con; |   conexion* con; | ||||||
|   bool loggin(std::string username, std::string passwd); |   bool loggin(std::string username, std::string passwd); | ||||||
|   int install_command(std::string package); |   int install_command(std::string package); | ||||||
|  |   int remove_command(std::string package); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // SESSION_MANAGER_H
 | #endif // SESSION_MANAGER_H
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include "vista.h" | #include "view_install.h" | ||||||
| #include <iostream> | #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); |   set_border_width(5); | ||||||
| 
 | 
 | ||||||
| @ -7,10 +7,10 @@ | |||||||
| #include <gtkmm/scrolledwindow.h> | #include <gtkmm/scrolledwindow.h> | ||||||
| #include <gtkmm/box.h> | #include <gtkmm/box.h> | ||||||
| 
 | 
 | ||||||
| class vista : public Gtk::Box | class view_install : public Gtk::Box | ||||||
| { | { | ||||||
| public: | public: | ||||||
|   vista(); |   view_install(); | ||||||
|   Gtk::Button m_button; |   Gtk::Button m_button; | ||||||
|   Gtk::Box m_VBox; |   Gtk::Box m_VBox; | ||||||
|   Gtk::ScrolledWindow m_ScrolledWindow; |   Gtk::ScrolledWindow m_ScrolledWindow; | ||||||
| @ -1,14 +1,14 @@ | |||||||
| #include "view_loggin.h" | #include "view_loggin.h" | ||||||
| #include "vista.h" | #include "view_install.h" | ||||||
| #include "controlador.h" | #include "controller_install.h" | ||||||
| 
 | 
 | ||||||
| #include <gtkmm/messagedialog.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->set_title("loggin"); | ||||||
|   this->con=con; |   this->sesi=sesi; | ||||||
|   set_border_width(5); |   set_border_width(5); | ||||||
| 
 | 
 | ||||||
|   this->user.set_text("user"); |   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 user=this->entry_user.get_text();//this->m_refTextBufferUser->get_text();
 | ||||||
|   std::string pass=this->entry_pass.get_text();//this->m_refTextBufferPass->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->login=true; | ||||||
|       this->hide(); |       this->hide(); | ||||||
|     }else{ |     }else{ | ||||||
|  | |||||||
| @ -6,13 +6,13 @@ | |||||||
| #include <gtkmm/box.h> | #include <gtkmm/box.h> | ||||||
| #include <gtkmm/label.h> | #include <gtkmm/label.h> | ||||||
| #include <gtkmm/entry.h> | #include <gtkmm/entry.h> | ||||||
| #include "conexion.h" |  | ||||||
| 
 | 
 | ||||||
|  | #include "session_manager.h" | ||||||
| class view_loggin : public Gtk::Window | class view_loggin : public Gtk::Window | ||||||
| { | { | ||||||
| public: | public: | ||||||
|   view_loggin(conexion *con); |   view_loggin(session_manager *sesi); | ||||||
|   conexion *con; |   session_manager *sesi; | ||||||
| 
 | 
 | ||||||
|   Gtk::Label user; |   Gtk::Label user; | ||||||
|   Gtk::Entry entry_user; |   Gtk::Entry entry_user; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user