Changeset 90
- Timestamp:
- 07/23/08 17:42:16 (4 months ago)
- Location:
- trunk/gui/src
- Files:
-
- 3 added
- 20 modified
-
Makefile.am (modified) (1 diff)
-
controller.cpp (modified) (2 diffs)
-
controller.hpp (modified) (1 diff)
-
hal-controller.cpp (modified) (4 diffs)
-
hal-controller.hpp (modified) (2 diffs)
-
hal-device-proxy.cpp (modified) (3 diffs)
-
hal-device-proxy.hpp (modified) (1 diff)
-
hal-manager-proxy.cpp (modified) (4 diffs)
-
hal-manager-proxy.hpp (modified) (3 diffs)
-
hal-parser.cpp (modified) (6 diffs)
-
hal-parser.hpp (modified) (2 diffs)
-
host.cpp (modified) (1 diff)
-
host.hpp (modified) (3 diffs)
-
linux-kernel-monitor-client-proxy.hpp (added)
-
linux-kernel-monitor-client.cpp (added)
-
linux-kernel-monitor-client.hpp (added)
-
main-window.cpp (modified) (2 diffs)
-
main-window.hpp (modified) (1 diff)
-
notebook-page-host.cpp (modified) (1 diff)
-
process.cpp (modified) (2 diffs)
-
process.hpp (modified) (3 diffs)
-
tree-view-host.cpp (modified) (5 diffs)
-
tree-view-host.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/src/Makefile.am
r87 r90 59 59 notebook-page-host.cpp \ 60 60 hal-parser.hpp \ 61 hal-parser.cpp 61 hal-parser.cpp \ 62 linux-kernel-monitor-client.hpp \ 63 linux-kernel-monitor-client.cpp 62 64 63 65 #glkm_CFLAGS= \ -
trunk/gui/src/controller.cpp
r87 r90 60 60 } 61 61 62 void Controller::action_host_ refresh() {62 void Controller::action_host_synchronize() { 63 63 Gtk::Notebook::PageList::iterator current_page_it; 64 64 current_page_it = _pNotebookHosts->get_current(); … … 68 68 Host * present_host; 69 69 present_host = current_page->get_my_Host(); 70 PRINTD("Controller:: refresh=" + present_host->get__hostname());70 PRINTD("Controller:: synchronize=" + present_host->get__hostname()); 71 71 present_host->get_all_processes(); 72 72 } -
trunk/gui/src/controller.hpp
r87 r90 32 32 void action_host_selected(); 33 33 void action_host_connect(); 34 void action_host_ refresh();34 void action_host_synchronize(); 35 35 static Controller & instance(); 36 36 void set__pIconViewHosts(IconViewHosts * value); -
trunk/gui/src/hal-controller.cpp
r87 r90 25 25 #include "hal-manager-proxy.hpp" 26 26 #include "host.hpp" 27 #include "linux-kernel-monitor-client.hpp" 27 28 28 29 HalController::HalController(): 29 // _connection(DBus::Connection::SystemBus())30 30 _dispatcher() 31 31 { … … 40 40 } 41 41 catch (const DBus::Error& exception){ 42 std::cerr << " Connection" << std::endl;42 std::cerr << "HalController(): Connection" << std::endl; 43 43 std::cerr << exception.what() << std::endl; 44 44 std::cerr << exception.name() << std::endl; … … 56 56 _connection->exit_on_disconnect (false); 57 57 _hal_manager = new HalManagerProxy(*_connection); 58 59 DBus::Path procmon_udi = _hal_manager->get_device_udi(); 60 try { 61 _lkm_client = new LinuxKernelMonitorClient(*_connection, procmon_udi); 62 } 63 catch (const DBus::Error& exception){ 64 std::cerr << "HalController() : LinuxKernelMonitorClient" << std::endl; 65 std::cerr << exception.what() << std::endl; 66 std::cerr << exception.name() << std::endl; 67 std::cerr << exception.message() << std::endl; 68 } 69 70 58 71 } 59 72 … … 65 78 66 79 bool HalController::get_all_processes(Host & host) { 67 return _ hal_manager->get_all_processes(host);80 return _lkm_client->get_all_processes(host); 68 81 } -
trunk/gui/src/hal-controller.hpp
r87 r90 26 26 class Host; 27 27 class HalManagerProxy; 28 class LinuxKernelMonitorClient; 28 29 29 30 class HalController { … … 37 38 HalManagerProxy * _hal_manager; 38 39 DBus::Glib::BusDispatcher _dispatcher; 40 41 private: 42 LinuxKernelMonitorClient * _lkm_client; 39 43 }; 40 44 -
trunk/gui/src/hal-device-proxy.cpp
r87 r90 86 86 87 87 /** 88 * get_property :88 * get_property_string: 89 89 * @key: 90 90 * 91 91 * HAL INFO 92 92 * ======== 93 * Method: GetProperty 94 * Returns: Variant93 * Method: GetPropertyString 94 * Returns: String 95 95 * Parameters: String key 96 96 * Throws: NoSuchProperty … … 105 105 * 106 106 */ 107 DBus:: Variant HalDeviceProxy::get_property(const DBus::String & key) {107 DBus::String HalDeviceProxy::get_property_string(const DBus::String & key) { 108 108 DBus::CallMessage call; 109 109 DBus::MessageIter wi = call.writer(); 110 110 111 111 wi << key; 112 call.member("GetProperty ");112 call.member("GetPropertyString"); 113 113 114 114 //declaret out of try. scope solution … … 116 116 try { 117 117 DBus::Message reply = invoke_method(call); 118 it = reply.reader();118 it = reply.reader(); 119 119 } 120 120 catch (const DBus::Error& exception){ 121 std::cerr << "GetProperty " << std::endl;121 std::cerr << "GetPropertyString" << std::endl; 122 122 std::cerr << exception.what() << std::endl; 123 std::cerr << exception.name() << std::endl;123 std::cerr << exception.name() << std::endl; 124 124 std::cerr << exception.message() << std::endl; 125 125 } 126 126 127 DBus:: Variantargout;128 it >> argout; 127 DBus::String argout; 128 it >> argout; 129 129 130 130 return argout; -
trunk/gui/src/hal-device-proxy.hpp
r87 r90 40 40 virtual ~HalDeviceProxy(); 41 41 42 DBus:: Variant get_property(const DBus::String & key);42 DBus::String get_property_string(const DBus::String & key); 43 43 VectorString get_property_string_list(const DBus::String & key); 44 44 bool rescan(); 45 45 bool get_all_properties() throw(DBus::Error); 46 46 47 47 private: 48 48 void on_property_modified(const DBus::SignalMessage & sig ); -
trunk/gui/src/hal-manager-proxy.cpp
r87 r90 19 19 #include <dbusmm/types.h> 20 20 21 21 22 #include "hal-manager-proxy.hpp" 22 #include "host.hpp"23 #include "hal-parser.hpp"24 23 25 24 #include "config.h" 26 25 #include "debug.hpp" 27 28 29 #define DBUS_TYPE_STRUCT ((int) 'r')30 #define DBUS_TYPE_STRING ((int) 's')31 #define DBUS_TYPE_ARRAY ((int) 'a')32 #define DBUS_TYPE_VARIANT ((int) 'v')33 #define DBUS_TYPE_DICT_ENTRY ((int) 'e')34 26 35 27 /** … … 98 90 99 91 /** 100 * get_ all_processes:92 * get_device_udi: 101 93 * 102 94 * Returns: … … 107 99 * 108 100 */ 109 bool HalManagerProxy::get_all_processes(Host & host) { 101 DBus::Path HalManagerProxy::get_device_udi() { 102 DBus::Path udi; 110 103 if (_device){ 111 // PRINTD("refreshing properties"); 112 // _device->rescan(); 113 PRINTD("getting all processess"); 114 VectorString task_list = _device->get_property_string_list ("misc.task_list"); 115 HalParser h; 116 h.parse_add_processes (task_list, host); 104 udi = _device->path(); 117 105 } else { 118 PRINTD("no linux-kernel-monitor device found"); 119 } 120 } 106 PRINTD ("No procmon decive to get udi"); 107 } 108 109 return udi; 110 } 111 121 112 122 113 /** … … 154 145 } 155 146 147 156 148 /** 157 149 * find_device_by_capability: -
trunk/gui/src/hal-manager-proxy.hpp
r87 r90 31 31 #include "utils.hpp" 32 32 33 class Host;34 class HalParser;35 36 33 class HalManagerProxy : public DBus::ObjectProxy, public DBus::InterfaceProxy { 37 34 … … 39 36 HalManagerProxy(DBus::Connection& connection ); 40 37 virtual ~HalManagerProxy(); 41 bool get_all_processes(Host & host); 38 39 DBus::Path get_device_udi(); 42 40 43 41 protected: … … 53 51 54 52 #endif //_HAL_MANAGER_PROXY_HPP 53 54 55 -
trunk/gui/src/hal-parser.cpp
r87 r90 23 23 #include "hal-parser.hpp" 24 24 #include "host.hpp" 25 //#include "process.hpp"25 #include "process.hpp" 26 26 27 27 #include "config.h" … … 36 36 37 37 /** 38 * parse_ add_processes:39 * @hal_ vs_processes:38 * parse_synchronize_processes: 39 * @hal_task_list: 40 40 * @host: 41 41 * … … 52 52 * 53 53 */ 54 void HalParser::parse_add_processes(VectorString & hal_task_list, Host & host) { 55 56 // VectorString::iterator hal_task_list_it; 57 // for(hal_task_list_it = hal_task_list.begin(); hal_task_list_it != hal_task_list.end(); ++hal_task_list_it) { 54 void HalParser::parse_synchronize_processes(VectorString & hal_task_list, Host & host) { 55 56 host.print_processes(); 57 VectorString::iterator hal_task_list_it; 58 for(hal_task_list_it = hal_task_list.begin(); hal_task_list_it != hal_task_list.end(); ++hal_task_list_it) { 58 59 /* 59 60 We're going to loop processes reversed as hal_task_list goes from mayor … … 61 62 previously created parent 62 63 */ 63 VectorString::reverse_iterator hal_task_list_it;64 for(hal_task_list_it = hal_task_list.rbegin(); hal_task_list_it != hal_task_list.rend(); ++hal_task_list_it) {64 // VectorString::reverse_iterator hal_task_list_it; 65 // for(hal_task_list_it = hal_task_list.rbegin(); hal_task_list_it != hal_task_list.rend(); ++hal_task_list_it) { 65 66 VectorString parsed_process; 66 67 // TODO … … 94 95 std::cerr << exception.what() << std::endl; 95 96 } 97 98 Process process_tmp; 99 process_tmp.set__PID(PID); 100 process_tmp.set__PPID(PPID); 101 process_tmp.set__name(process_name); 102 host.add_and_synchronize_process(process_tmp); 103 } 104 host.print_processes(); 105 host.delete_all_not_synchronized(); 106 } 107 108 /** 109 * parse_add_processes: 110 * @hal_vs_processes: 111 * @host: 112 * 113 * Returns: 114 * 115 * Exceptions: 116 * 117 * Example: 118 * Line format gets defined in kernel module with this format: 119 * "%s:%d:%d\n", 120 * task->comm, 121 * task->pid, 122 * task->parent->pid 123 * 124 * / 125 void HalParser::parse_add_processes(VectorString & hal_task_list, Host & host) { 126 127 VectorString::iterator hal_task_list_it; 128 for(hal_task_list_it = hal_task_list.begin(); hal_task_list_it != hal_task_list.end(); ++hal_task_list_it) { 129 /* 130 We're going to loop processes reversed as hal_task_list goes from mayor 131 to minor PID and we want to parented processes to be able to find its 132 previously created parent 133 * / 134 // VectorString::reverse_iterator hal_task_list_it; 135 // for(hal_task_list_it = hal_task_list.rbegin(); hal_task_list_it != hal_task_list.rend(); ++hal_task_list_it) { 136 VectorString parsed_process; 137 // TODO 138 // We use iss and iss2 because working with just one doesn't work 139 // as expected. This shoul be looked up. 140 std::istringstream iss; 141 std::istringstream iss2; 142 Glib::ustring process_name; 143 int PID; 144 int PPID; 145 146 tokenize(*hal_task_list_it, ":", parsed_process); 147 148 //When we get a line without all of our process parameters, skip it 149 if (parsed_process.size() < 3) { 150 std::cerr << "ERROR:: Bad formed hal line" << std::endl; 151 PRINTD("HalParser ERROR:: Bad formed hal line "); 152 continue; 153 } 154 155 // Get each process parameter into their proper variable type and look 156 // for errors without broken program. 157 // We use at() instead of [] becuase it provide us exceptions 158 try { 159 process_name = parsed_process.at(0); 160 iss.str (parsed_process.at(1)); 161 iss >> PID; 162 iss2.str (parsed_process.at(2)); 163 iss2 >> PPID; 164 } catch (std::out_of_range exception){ 165 std::cerr << exception.what() << std::endl; 166 } 96 167 97 168 // Search for element with a value of PID and returns an iterator to it … … 112 183 113 184 } 114 185 */ 186 115 187 /** 116 188 * tokenize: -
trunk/gui/src/hal-parser.hpp
r87 r90 26 26 27 27 class Host; 28 class Process; 28 29 29 30 class HalParser { … … 31 32 HalParser(); 32 33 virtual ~HalParser(); 33 void parse_ add_processes(VectorString & hal_task_list, Host & host);34 void parse_synchronize_processes(VectorString & hal_task_list, Host & host); 34 35 35 36 private: -
trunk/gui/src/host.cpp
r87 r90 68 68 void Host::get_all_processes() { 69 69 bool result; 70 PRINTD ("Host:: getting processes " + _hostname); 70 71 result = _hal_controller->get_all_processes(*this); 72 } 73 74 void Host::add_and_synchronize_process(Process & process) { 75 76 int PID = process.get__PID(); 77 78 // Search for element with a value of PID and returns an iterator to it 79 // if found. Otherwise it returns an iterator to map::end (the 80 // element past the end of the container). 81 std::map<int, Process>::iterator process_iterator; 82 process_iterator = _task_list.find(PID); 83 if ( process_iterator == _task_list.end() ) { 84 //Process does not exists so we have to add it 85 _task_list[PID] = process; 86 _task_list[PID].set__synchronized(true); 87 88 PRINTD("Host:: process added and sync " + _task_list[PID].get__name()); 89 signal_process_added.emit(_task_list[PID]); 90 } else { 91 //Process exists so we just mark it as synchonized 92 PRINTD("Host:: process synchronized " + _task_list[PID].get__name()); 93 _task_list[PID].set__synchronized(true); 94 } 95 } 96 97 void Host::delete_all_not_synchronized() { 98 99 std::map<int, Process>::iterator process_iterator; 100 for(process_iterator = _task_list.begin(); process_iterator != _task_list.end(); ) { 101 bool synchronized = (*process_iterator).second.get__synchronized(); 102 if (synchronized) { 103 (*process_iterator).second.set__synchronized(false); 104 ++process_iterator; 105 } else { 106 PRINTD("Host:: process removed " + (*process_iterator).second.get__name()); 107 signal_process_removed.emit( (*process_iterator).second ); 108 _task_list.erase(process_iterator++); 109 } 110 } 111 /* for(process_iterator = _task_list.begin(); process_iterator != _task_list.end(); ++process_iterator) { 112 (*process_iterator).second.set__synchronized(false); 113 }*/ 114 115 } 116 117 void Host::print_processes() { 118 std::cout << "Host::print_processes() " << std::endl; 119 std::map<int, Process>::iterator process_iterator; 120 for(process_iterator = _task_list.begin(); process_iterator != _task_list.end(); ++process_iterator ) { 121 std::string sync(""); 122 if ( (*process_iterator).second.get__synchronized() ){ 123 sync = "true"; 124 } else { 125 sync = "false"; 126 } 127 std::cout << (*process_iterator).first << " => [" 128 << (*process_iterator).second.get__name() << ":" 129 << (*process_iterator).second.get__PPID() << ":" 130 << sync 131 << "]" << std::endl; 132 } 71 133 } 72 134 -
trunk/gui/src/host.hpp
r87 r90 42 42 void connect(); 43 43 void get_all_processes(); 44 void add_and_synchronize_process(Process & process); 45 void delete_all_not_synchronized(); 46 47 void print_processes(); 48 44 49 bool get_process(int PID, Process & process); 45 50 … … 54 59 Glib::ustring _description; 55 60 56 typedef sigc::signal<void, Process> type_signal_Process_added;57 58 61 Filesystem * _filesystems; 59 62 std::map<int, Process> _task_list; … … 61 64 HalController * _hal_controller; 62 65 63 friend class HalParser; 64 66 // friend class HalParser; 67 68 typedef sigc::signal<void, Process> type_signal_process_added; 69 typedef sigc::signal<void, Process> type_signal_process_removed; 70 65 71 public: 66 type_signal_Process_added signal_Process_added; 67 68 72 type_signal_process_added signal_process_added; 73 type_signal_process_removed signal_process_removed; 69 74 }; 70 75 inline const Glib::ustring Host::get__hostname() const { -
trunk/gui/src/main-window.cpp
r87 r90 154 154 std::cerr << "** ERROR ** Maybe an error loading glade file?" << std::endl; 155 155 } 156 _refPtrGlademmXml->get_widget("toolbutton_ refresh", _pToolButton_Refresh);157 if (_pToolButton_ Refresh){158 _pToolButton_ Refresh->signal_clicked().connect( sigc::mem_fun(*this,159 &MainWindow::on_clicked_toolbar_ refresh) );156 _refPtrGlademmXml->get_widget("toolbutton_synchronize", _pToolButton_Synchronize); 157 if (_pToolButton_Synchronize){ 158 _pToolButton_Synchronize->signal_clicked().connect( sigc::mem_fun(*this, 159 &MainWindow::on_clicked_toolbar_synchronize) ); 160 160 } else{ 161 161 std::cerr << "** ERROR ** Maybe an error loading glade file?" << std::endl; … … 284 284 } 285 285 286 void MainWindow::on_clicked_toolbar_ refresh(){287 PRINTD("on_clicked_toolbar_ refresh");286 void MainWindow::on_clicked_toolbar_synchronize(){ 287 PRINTD("on_clicked_toolbar_synchronize"); 288 288 Controller& c = Controller::instance(); 289 c.action_host_ refresh();290 } 291 289 c.action_host_synchronize(); 290 } 291 -
trunk/gui/src/main-window.hpp
r87 r90 79 79 void on_clicked_toolbar_select(); 80 80 void on_clicked_toolbar_connect(); 81 void on_clicked_toolbar_ refresh();81 void on_clicked_toolbar_synchronize(); 82 82 83 83 Gtk::Toolbar * _pToolbar; 84 84 Gtk::ToolButton * _pToolButton_Select; 85 85 Gtk::ToolButton * _pToolButton_Connect; 86 Gtk::ToolButton * _pToolButton_ Refresh;86 Gtk::ToolButton * _pToolButton_Synchronize; 87 87 88 88 // Main Window (Important stuff) -
trunk/gui/src/notebook-page-host.cpp
r8
