From a9318661e45dfb9853c6aba811670571a5ec3ea2 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Thu, 13 Nov 2003 17:44:09 +0000 Subject: [PATCH] El cliente ya se conecta, muestra en un campo de texto el log de lo que se esta haciendo, y tienen un campo de texto y un boton para mandar URI a manopla. No se si estoy usando bien el command (seguramente no), y no se que comando andan, ya que todo lo que probe me da error :-) --- Client/configure.in | 3 +- Client/include/principal.h | 9 ++++ Client/src/Makefile.am | 3 +- Client/src/client.glade | 104 +++++++++++++++++++++++++++++-------- Client/src/main.cpp | 1 + Client/src/principal.cpp | 54 ++++++++++++++++++- 6 files changed, 148 insertions(+), 26 deletions(-) diff --git a/Client/configure.in b/Client/configure.in index 4e618fe..aa5c2db 100644 --- a/Client/configure.in +++ b/Client/configure.in @@ -12,7 +12,8 @@ AC_HEADER_STDC ## pkg_modules="libgnomeui-2.0" PKG_CHECK_MODULES(PACKAGE, gtkmm-2.0 >= 2.0.0 \ - libglademm-2.0 >= 2.0.0) + libglademm-2.0 >= 2.0.0 \ + gthread-2.0) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) diff --git a/Client/include/principal.h b/Client/include/principal.h index d4270a8..c235ebf 100644 --- a/Client/include/principal.h +++ b/Client/include/principal.h @@ -6,6 +6,7 @@ #include #include #include "dlg_conectar.h" +#include "plaqui/server/controlclient.h" class Principal:public Gtk::Window { public: @@ -13,17 +14,25 @@ public: virtual ~Principal(); protected: + PlaQui::Server::ControlClient *conexion; + // Archivo XML del Padre Glib::RefPtr refXml; // Dialogo de Conectar DlgConectar *dlg_conectar; + Gtk::Entry *txt_get; + Gtk::TextView *txt_view; // Callbacks del menu y la barra virtual void on_mnu_file_exit(); virtual void on_mnu_file_connect(); virtual void on_mnu_help_about(); virtual void on_dlg_connect_ok(); + virtual void on_get_clicked(); + // Callbacks para las conexiones + void on_conexion_ok(); + void on_conexion_error(); }; #endif // _PRINCIPAL_H_ diff --git a/Client/src/Makefile.am b/Client/src/Makefile.am index a2f4a93..e47e463 100644 --- a/Client/src/Makefile.am +++ b/Client/src/Makefile.am @@ -2,6 +2,7 @@ INCLUDES = \ -I../include \ + -I../../Server/include \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ @PACKAGE_CFLAGS@ @@ -12,6 +13,6 @@ plaqui_client_SOURCES = main.cpp \ principal.cpp \ dlg_conectar.cpp -plaqui_client_LDADD = @PACKAGE_LIBS@ +plaqui_client_LDADD = @PACKAGE_LIBS@ ../../Server/src/server.a -lsocket++ diff --git a/Client/src/client.glade b/Client/src/client.glade index 52fc899..cb6fd48 100644 --- a/Client/src/client.glade +++ b/Client/src/client.glade @@ -257,18 +257,65 @@ GTK_SHADOW_ETCHED_IN - + True - label8 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + False + 0 + + + + True + URI : + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + + True + True + GET + True + GTK_RELIEF_NORMAL + + + 0 + False + False + + @@ -311,18 +358,31 @@ GTK_SHADOW_ETCHED_IN - + True - label9 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + diff --git a/Client/src/main.cpp b/Client/src/main.cpp index 11bce6b..085c2b1 100644 --- a/Client/src/main.cpp +++ b/Client/src/main.cpp @@ -8,6 +8,7 @@ int main (int argc, char **argv) { Gtk::Main client(argc, argv); + Glib::thread_init(); //Load the Glade file and instiate its widgets: Glib::RefPtr refXml; try { diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index 062aa4b..e88c896 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -7,26 +7,51 @@ 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; + txt_view = 0; + txt_get = 0; + rg->get_widget("mnu_file_connect", conect); rg->get_widget("mnu_file_exit", exit); rg->get_widget("mnu_help_about", about); 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); 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)); 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) ); + + conexion = NULL; } Principal::~Principal() { + delete conexion; } void Principal::on_dlg_connect_ok() { - std::cout << "Conectando ..." << std::endl; - std::cout << dlg_conectar->get_server_name() << ":" << dlg_conectar->get_server_port() << std::endl; + 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()); + // 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(); + } 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() @@ -71,3 +96,28 @@ void Principal::on_mnu_help_about() dlg->show();*/ } +void Principal::on_conexion_ok() +{ + txt_view->get_buffer()->insert_at_cursor("El server dice que ta' todo ok!\n"); +} + +void Principal::on_conexion_error() +{ + txt_view->get_buffer()->insert_at_cursor("El server dice que hay error\n"); +} + +void Principal::on_get_clicked() +{ + if (conexion == NULL) { + 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); + +} + -- 2.43.0