From 13ead70d9771f21bc2378e2deece2f7b129f4cae Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Thu, 13 Nov 2003 20:15:41 +0000 Subject: [PATCH] Para enviar comando ahora hay 3 campos : Target, Command y Argumentos, para poder hacer pruebas bien. * Para ver : Cuando se envia server/stop el server no se apaga! --- Client/include/principal.h | 2 +- Client/src/client.glade | 137 ++++++++++++++++++++++++++++++++----- Client/src/principal.cpp | 45 ++++++++---- 3 files changed, 151 insertions(+), 33 deletions(-) diff --git a/Client/include/principal.h b/Client/include/principal.h index c235ebf..0b1472f 100644 --- a/Client/include/principal.h +++ b/Client/include/principal.h @@ -21,7 +21,7 @@ protected: // Dialogo de Conectar DlgConectar *dlg_conectar; - Gtk::Entry *txt_get; + Gtk::Entry *txt_target, *txt_command, *txt_args; Gtk::TextView *txt_view; // Callbacks del menu y la barra diff --git a/Client/src/client.glade b/Client/src/client.glade index cb6fd48..353d6e1 100644 --- a/Client/src/client.glade +++ b/Client/src/client.glade @@ -253,38 +253,92 @@ True 0 - 0.5 + 0 GTK_SHADOW_ETCHED_IN - + True + 3 + 3 False - 0 + 0 + 0 - + True - URI : + Target : False False GTK_JUSTIFY_LEFT False False - 0.5 + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Command : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Arguments : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 0.5 0 0 - 0 - False - False + 0 + 1 + 2 + 3 + fill + - + True True True @@ -296,9 +350,53 @@ False - 0 - True - True + 1 + 2 + 0 + 1 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + @@ -306,14 +404,17 @@ True True - GET + Enviar True GTK_RELIEF_NORMAL - 0 - False - False + 2 + 3 + 0 + 3 + fill + fill @@ -340,7 +441,7 @@ True - True + False diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index e88c896..09bf9c2 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -7,9 +7,9 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::Window(co),refXml(rg) { Gtk::MenuItem *conect=0, *exit=0, *about=0; - Gtk::Button *btn_get=0; + Gtk::Button *btn_get=0, *bar_connect=0; txt_view = 0; - txt_get = 0; + txt_target = txt_command = txt_args = 0; rg->get_widget("mnu_file_connect", conect); rg->get_widget("mnu_file_exit", exit); @@ -17,10 +17,14 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & rg->get_widget_derived("dlgConectar", dlg_conectar); rg->get_widget("btn_get", btn_get); rg->get_widget("txt_view", txt_view); - rg->get_widget("txt_uri", txt_get); + rg->get_widget("txt_target", txt_target); + rg->get_widget("txt_command", txt_command); + rg->get_widget("txt_args", txt_args); + rg->get_widget("bar_connect", bar_connect); dlg_conectar->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_connect_ok) ); conect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); + bar_connect->signal_clicked().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit)); about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about)); btn_get->signal_clicked().connect( SigC::slot(*this, &Principal::on_get_clicked) ); @@ -38,20 +42,29 @@ void Principal::on_dlg_connect_ok() if (conexion == NULL) { std::cout << "Conectando ..." << std::endl; // Creo la conexion - conexion = new PlaQui::Server::ControlClient(dlg_conectar->get_server_name(), dlg_conectar->get_server_port()); + try { + conexion = new PlaQui::Server::ControlClient(dlg_conectar->get_server_name(), dlg_conectar->get_server_port()); + } + catch (...) { + txt_view->get_buffer()->insert_at_cursor("NO SE PUDO CREAR OBJETO\n"); + return; + } + // Conecto las seƱales conexion->signal_ok_received().connect( SigC::slot(*this, &Principal::on_conexion_ok) ); conexion->signal_error_received().connect( SigC::slot(*this, &Principal::on_conexion_error) ); // Lanzo la conexion! - conexion->run(); + // + try { + conexion->run(); + } + catch (...) { + txt_view->get_buffer()->insert_at_cursor("no se puede correr ->run()!!!\n"); + } } else { std::cout << "Ya estas conectado" << std::endl; } dlg_conectar->hide(); - - // mando algo para ver que me dice - PlaQui::Server::Command command("/", "status"); - conexion->send(command); } void Principal::on_mnu_file_exit() @@ -112,12 +125,16 @@ void Principal::on_get_clicked() txt_view->get_buffer()->insert_at_cursor("SIN CONEXION\n"); } - txt_view->get_buffer()->insert_at_cursor("Enviada URI : "); - txt_view->get_buffer()->insert_at_cursor(txt_get->get_text()); - txt_view->get_buffer()->insert_at_cursor("\n"); - PlaQui::Server::Command command(txt_get->get_text(), ""); - conexion->send(command); + PlaQui::Server::Command command(txt_target->get_text(), txt_command->get_text()); + command.add_arg( txt_args->get_text() ); + txt_view->get_buffer()->insert_at_cursor("Enviando comando\n"); + try { + conexion->send(command); + } + catch (...) { + txt_view->get_buffer()->insert_at_cursor("EXCEPTION EN conexion->send !!\n"); + } } -- 2.43.0