diff --git a/ClienteTFG.pro b/ClienteTFG.pro index 4bc575d..fbc297e 100644 --- a/ClienteTFG.pro +++ b/ClienteTFG.pro @@ -17,7 +17,6 @@ SOURCES += \ container_window.cpp \ view_install.cpp \ controller_install.cpp \ - controller_remove.cpp \ view_info.cpp \ controller_info.cpp \ view_user_info.cpp \ @@ -34,7 +33,6 @@ HEADERS += \ container_window.h \ view_install.h \ controller_install.h \ - controller_remove.h \ view_info.h \ controller_info.h \ view_user_info.h \ diff --git a/conexion.cpp b/conexion.cpp index f8aae4c..b09a9a3 100644 --- a/conexion.cpp +++ b/conexion.cpp @@ -46,11 +46,3 @@ ssize_t conexion::write_string(std::string entrada){ return write(this->fd,entrada.data(),entrada.size()); } -bool conexion::check_pass(std::string usernem, std::string pass){ - this->write_string(usernem); - this->write_string(pass); - std::string result; - this->read_string(result,4); - return result=="pass"; -} - diff --git a/conexion.h b/conexion.h index a28b820..d594e3a 100644 --- a/conexion.h +++ b/conexion.h @@ -9,7 +9,6 @@ public: virtual ssize_t read_string(std::string &entrada, int size); virtual ssize_t write_string(std::string entrada); - bool check_pass(std::string usernem, std::string pass); protected: config_reader *config; int fd; diff --git a/container_window.cpp b/container_window.cpp index 3a84bdf..4dc857f 100644 --- a/container_window.cpp +++ b/container_window.cpp @@ -8,13 +8,15 @@ container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application if(this->loggin.login){ this->cont_inst=new controller_install(&install, sesion.get()); this->cont_info=new controller_info(&info, sesion.get()); - this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this); this->app.reset(); this->app=Gtk::Application::create( "org.gtkmm.examples.base"); this->add(this->book); this->book.append_page(install,"build"); this->book.append_page(this->info,"info"); - this->book.append_page(this->uinfo,"users"); + if(this->loggin.admin){ + this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this); + this->book.append_page(this->uinfo,"users"); + } this->show_all_children(); this->app->run(*this); } diff --git a/controller_remove.cpp b/controller_remove.cpp deleted file mode 100644 index 32d71fb..0000000 --- a/controller_remove.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "controller_remove.h" - -controller_remove::controller_remove(view_remove *vis, session_manager *sesi) -{ - this->view=vis; - this->session=sesi; - this->add_controlers(); -} - -void controller_remove::add_controlers(){ - this->view->m_button.signal_clicked().connect(sigc::mem_fun(this, - &controller_remove::on_button_clicked)); -} - -void controller_remove::on_button_clicked(){ - this->session->remove_command(this->view->entry.get_text()); -} diff --git a/controller_remove.h b/controller_remove.h deleted file mode 100644 index 101bbce..0000000 --- a/controller_remove.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONTROLLER_REMOVE_H -#define CONTROLLER_REMOVE_H - -#include "view_remove.h" -#include "session_manager.h" - -class controller_remove -{ -public: - controller_remove(view_remove *view, session_manager *session); -private: - view_remove *view; - session_manager *session; - void add_controlers(); - void on_button_clicked(); -}; - -#endif // CONTROLLER_REMOVE_H diff --git a/session_manager.cpp b/session_manager.cpp index d045ce5..28a8e19 100644 --- a/session_manager.cpp +++ b/session_manager.cpp @@ -7,7 +7,17 @@ session_manager::session_manager(conexion* con) } bool session_manager::loggin(std::string username, std::string passwd){ - return this->con->check_pass(username, passwd); + this->con->write_string(username); + this->con->write_string(passwd); + std::string result; + this->con->read_string(result,4); + return result=="pass"; +} + +bool session_manager::admin(){ + std::string result; + this->con->read_string(result,5); + return result=="admin"; } int session_manager::install_command(std::string package){ diff --git a/session_manager.h b/session_manager.h index 6628bd3..6d82853 100644 --- a/session_manager.h +++ b/session_manager.h @@ -12,6 +12,7 @@ public: session_manager(conexion* con); conexion* con; bool loggin(std::string username, std::string passwd); + bool admin(); int install_command(std::string package); int remove_command(std::string package); std::list get_packages_info(); diff --git a/view_loggin.cpp b/view_loggin.cpp index b62ca7c..4f5934e 100644 --- a/view_loggin.cpp +++ b/view_loggin.cpp @@ -43,6 +43,7 @@ void view_loggin::on_button_clicked(){ if(sesi->loggin(user, pass)){ this->login=true; + this->admin=sesi->admin(); this->hide(); }else{ this->login=false; diff --git a/view_loggin.h b/view_loggin.h index a6963e7..808ad7a 100644 --- a/view_loggin.h +++ b/view_loggin.h @@ -28,6 +28,7 @@ public: void on_button_clicked(); bool login; + bool admin; }; #endif // VIEW_LOGGIN_H