diff --git a/ClienteTFG.pro b/ClienteTFG.pro index 940dd5f..60d7745 100644 --- a/ClienteTFG.pro +++ b/ClienteTFG.pro @@ -20,7 +20,9 @@ SOURCES += \ view_remove.cpp \ controller_remove.cpp \ view_info.cpp \ - controller_info.cpp + controller_info.cpp \ + view_user_info.cpp \ + controller_user_info.cpp HEADERS += \ conexion.h \ @@ -35,4 +37,6 @@ HEADERS += \ view_remove.h \ controller_remove.h \ view_info.h \ - controller_info.h + controller_info.h \ + view_user_info.h \ + controller_user_info.h diff --git a/ClienteTFG.pro.user b/ClienteTFG.pro.user index b2f83b3..5ae0ad5 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 f3cf284..93197ec 100644 --- a/container_window.cpp +++ b/container_window.cpp @@ -9,12 +9,14 @@ container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application this->cont_inst=new controller_install(&install, sesion.get()); this->cont_rem=new controller_remove(&remove, sesion.get()); this->cont_info=new controller_info(&info, sesion.get()); + this->con_uinfo=new controller_user_info(&uinfo, sesion.get()); 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(remove,"remove"); this->book.append_page(this->info,"info"); + this->book.append_page(this->uinfo,"users"); this->show_all_children(); this->app->run(*this); } diff --git a/container_window.h b/container_window.h index f8f7597..2f7e9d1 100644 --- a/container_window.h +++ b/container_window.h @@ -9,6 +9,8 @@ #include "controller_remove.h" #include "view_info.h" #include "controller_info.h" +#include "view_user_info.h" +#include "controller_user_info.h" #include #include @@ -24,9 +26,11 @@ private: view_install install; view_remove remove; view_info info; + view_user_info uinfo; controller_install *cont_inst; controller_remove *cont_rem; controller_info *cont_info; + controller_user_info *con_uinfo; Gtk::Notebook book; }; diff --git a/controller_info.cpp b/controller_info.cpp index 6dd91b4..8b3b538 100644 --- a/controller_info.cpp +++ b/controller_info.cpp @@ -1,13 +1,5 @@ #include "controller_info.h" -#include - -std::string get_first(std::string &info){ - int pos = info.find(":"); - std::string ret = info.substr(0, pos); - info=info.substr(pos+1, info.size()+1); - return ret; -} controller_info::controller_info(view_info *view, session_manager *sesion) { @@ -25,9 +17,11 @@ void controller_info::load_info(){ row[this->view->m_Columns.r_config]=(get_first(data)=="t"); row[this->view->m_Columns.r_user]=get_first(data); } - /*row[this->view->m_Columns.r_name] = "firefox"; - row[this->view->m_Columns.r_date] = "2020-10-2"; - row[this->view->m_Columns.r_config] = true; - row[this->view->m_Columns.r_user] = "pepe";*/ } +std::string controller_info::get_first(std::string &info){ + int pos = info.find(":"); + std::string ret = info.substr(0, pos); + info=info.substr(pos+1, info.size()+1); + return ret; +} diff --git a/controller_info.h b/controller_info.h index 1e2b92a..9055108 100644 --- a/controller_info.h +++ b/controller_info.h @@ -12,6 +12,7 @@ private: view_info *view; session_manager *sesion; void load_info(); + std::string get_first(std::string &info); }; #endif // CONTROLLER_INFO_H diff --git a/controller_user_info.cpp b/controller_user_info.cpp new file mode 100644 index 0000000..34f543a --- /dev/null +++ b/controller_user_info.cpp @@ -0,0 +1,25 @@ +#include "controller_user_info.h" + + +controller_user_info::controller_user_info(view_user_info *view, session_manager *sesion) +{ + this->view=view; + this->sesion=sesion; + this->load_info(); +} + +void controller_user_info::load_info(){ + std::list list=this->sesion->get_users_info(); + for(std::string data:list){ + Gtk::TreeModel::Row row = *(this->view->m_refTreeModel->append()); + row[this->view->m_Columns.r_user]=get_first(data); + row[this->view->m_Columns.r_admin]=(get_first(data)=="t"); + } +} + +std::string controller_user_info::get_first(std::string &info){ + int pos = info.find(":"); + std::string ret = info.substr(0, pos); + info=info.substr(pos+1, info.size()+1); + return ret; +} diff --git a/controller_user_info.h b/controller_user_info.h new file mode 100644 index 0000000..e7a9db4 --- /dev/null +++ b/controller_user_info.h @@ -0,0 +1,18 @@ +#ifndef CONTROLLER_USER_INFO_H +#define CONTROLLER_USER_INFO_H + +#include "view_user_info.h" +#include "session_manager.h" + +class controller_user_info +{ +public: + controller_user_info(view_user_info *view, session_manager *session); +private: + view_user_info *view; + session_manager *sesion; + void load_info(); + std::string get_first(std::string &info); +}; + +#endif // CONTROLLER_USER_INFO_H diff --git a/session_manager.cpp b/session_manager.cpp index dd51e88..80221a2 100644 --- a/session_manager.cpp +++ b/session_manager.cpp @@ -46,3 +46,17 @@ std::list session_manager::get_packages_info(){ } return ret; } + +std::list session_manager::get_users_info(){ + std::list ret; + std::string read; + this->con->write_string("uinf"); + while(true){ + this->con->read_string(read,256); + if(read=="end:info"){ + break; + } + ret.push_back(read); + } + return ret; +} diff --git a/session_manager.h b/session_manager.h index 82b634c..393daa6 100644 --- a/session_manager.h +++ b/session_manager.h @@ -15,6 +15,7 @@ public: int install_command(std::string package); int remove_command(std::string package); std::list get_packages_info(); + std::list get_users_info(); }; #endif // SESSION_MANAGER_H diff --git a/view_user_info.cpp b/view_user_info.cpp new file mode 100644 index 0000000..b9604ec --- /dev/null +++ b/view_user_info.cpp @@ -0,0 +1,11 @@ +#include "view_user_info.h" + +view_user_info::view_user_info() +{ + this->m_refTreeModel = Gtk::ListStore::create(this->m_Columns); + this->tree.set_model(this->m_refTreeModel); + + tree.append_column("user", m_Columns.r_user); + tree.append_column("config", m_Columns.r_admin); + this->add(this->tree); +} diff --git a/view_user_info.h b/view_user_info.h new file mode 100644 index 0000000..f383e56 --- /dev/null +++ b/view_user_info.h @@ -0,0 +1,26 @@ +#ifndef VIEW_USER_INFO_H +#define VIEW_USER_INFO_H + +#include +#include +#include + +class view_user_info: public Gtk::Box +{ +public: + view_user_info(); + Gtk::TreeView tree; + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { + public: + ModelColumns() + { add(r_user); add(r_admin); } + Gtk::TreeModelColumn r_user; + Gtk::TreeModelColumn r_admin; + }; + + ModelColumns m_Columns; + Glib::RefPtr m_refTreeModel; +}; + +#endif // VIEW_USER_INFO_H