]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
El cliente ya se conecta, muestra en un campo de texto el log de lo que se esta
authorRicardo Markiewicz <gazer.arg@gmail.com>
Thu, 13 Nov 2003 17:44:09 +0000 (17:44 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Thu, 13 Nov 2003 17:44:09 +0000 (17:44 +0000)
 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
Client/include/principal.h
Client/src/Makefile.am
Client/src/client.glade
Client/src/main.cpp
Client/src/principal.cpp

index 4e618fea81ddedd9ff429ca89ed51a55d7b6c653..aa5c2db0a577a556c2a87c0bbf6eeca25cb739cc 100644 (file)
@@ -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)
index d4270a81f9b93ee29a1032a6312925a67dbe18d3..c235ebff15b86f023f9a64f5dacd504f1434740a 100644 (file)
@@ -6,6 +6,7 @@
 #include <gtkmm.h>
 #include <libglademm.h>
 #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<Gnome::Glade::Xml> 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_
index a2f4a9394e8673a987dd80346442da1ca7f9257a..e47e463b926c01efd6389b4ade011da42f4c2c96 100644 (file)
@@ -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++ 
 
 
index 52fc899168627299b3d6deaf574573b3c3aadc9f..cb6fd48cc1758ae067e3a3287e80014a8fc36d03 100644 (file)
                  <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
 
                  <child>
-                   <widget class="GtkLabel" id="label8">
+                   <widget class="GtkHBox" id="hbox1">
                      <property name="visible">True</property>
-                     <property name="label" translatable="yes">label8</property>
-                     <property name="use_underline">False</property>
-                     <property name="use_markup">False</property>
-                     <property name="justify">GTK_JUSTIFY_LEFT</property>
-                     <property name="wrap">False</property>
-                     <property name="selectable">False</property>
-                     <property name="xalign">0.5</property>
-                     <property name="yalign">0.5</property>
-                     <property name="xpad">0</property>
-                     <property name="ypad">0</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <widget class="GtkLabel" id="label12">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">URI : </property>
+                         <property name="use_underline">False</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkEntry" id="txt_uri">
+                         <property name="visible">True</property>
+                         <property name="can_focus">True</property>
+                         <property name="editable">True</property>
+                         <property name="visibility">True</property>
+                         <property name="max_length">0</property>
+                         <property name="text" translatable="yes"></property>
+                         <property name="has_frame">True</property>
+                         <property name="invisible_char" translatable="yes">*</property>
+                         <property name="activates_default">False</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">True</property>
+                         <property name="fill">True</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkButton" id="btn_get">
+                         <property name="visible">True</property>
+                         <property name="can_focus">True</property>
+                         <property name="label" translatable="yes">GET</property>
+                         <property name="use_underline">True</property>
+                         <property name="relief">GTK_RELIEF_NORMAL</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
                    </widget>
                  </child>
 
              <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
 
              <child>
-               <widget class="GtkLabel" id="label9">
+               <widget class="GtkScrolledWindow" id="scrolledwindow3">
                  <property name="visible">True</property>
-                 <property name="label" translatable="yes">label9</property>
-                 <property name="use_underline">False</property>
-                 <property name="use_markup">False</property>
-                 <property name="justify">GTK_JUSTIFY_LEFT</property>
-                 <property name="wrap">False</property>
-                 <property name="selectable">False</property>
-                 <property name="xalign">0.5</property>
-                 <property name="yalign">0.5</property>
-                 <property name="xpad">0</property>
-                 <property name="ypad">0</property>
+                 <property name="can_focus">True</property>
+                 <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
+                 <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+                 <property name="shadow_type">GTK_SHADOW_NONE</property>
+                 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+                 <child>
+                   <widget class="GtkTextView" id="txt_view">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="editable">True</property>
+                     <property name="justification">GTK_JUSTIFY_LEFT</property>
+                     <property name="wrap_mode">GTK_WRAP_NONE</property>
+                     <property name="cursor_visible">True</property>
+                     <property name="pixels_above_lines">0</property>
+                     <property name="pixels_below_lines">0</property>
+                     <property name="pixels_inside_wrap">0</property>
+                     <property name="left_margin">0</property>
+                     <property name="right_margin">0</property>
+                     <property name="indent">0</property>
+                     <property name="text" translatable="yes"></property>
+                   </widget>
+                 </child>
                </widget>
              </child>
 
index 11bce6b33fef3eb25c0501798899a29d47d49920..085c2b1ec8c5677f6ba1625252eae1de15231ba9 100644 (file)
@@ -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<Gnome::Glade::Xml> refXml;
        try {
index 062aa4b7455769b8c302ae2d0cfb4e606bb889bc..e88c8968c42f3a1897516bcea8a9a495d625ae17 100644 (file)
@@ -7,26 +7,51 @@
 Principal::Principal(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &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);
+
+}
+