Fawkes API  Fawkes Development Version
service_selector_cbe.h
00001 
00002 /***************************************************************************
00003  *  service_selector_cbe.h - Manages list of discovered services of given type
00004  *
00005  *  Created: Mon Sep 29 17:34:58 2008
00006  *  Copyright  2008  Daniel Beck
00007  *             2008  Tim Niemueller [www.niemueller.de]
00008  *
00009  ****************************************************************************/
00010 
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version. A runtime exception applies to
00015  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00023  */
00024 
00025 #ifndef __LIBS_GUI_UTILS_SERVICE_SELECTOR_CBE_H_
00026 #define __LIBS_GUI_UTILS_SERVICE_SELECTOR_CBE_H_
00027 
00028 #include <netcomm/fawkes/client_handler.h>
00029 
00030 #include <gtkmm.h>
00031 #ifdef HAVE_GLADEMM
00032 #  include <libglademm/xml.h>
00033 #endif
00034 
00035 namespace fawkes {
00036 #if 0 /* just to make Emacs auto-indent happy */
00037 }
00038 #endif
00039 
00040 class FawkesNetworkClient;
00041 class ServiceModel;
00042 class ConnectionDispatcher;
00043 
00044 class ServiceSelectorCBE
00045 {
00046  public:
00047 #if GTK_VERSION_GE(3,0)
00048   ServiceSelectorCBE( Gtk::ComboBox* services,
00049                       Gtk::Button* connect,
00050                       Gtk::Window* parent,
00051                       const char* service = "_fawkes._tcp" );
00052   ServiceSelectorCBE( Gtk::ComboBox* services,
00053                       Gtk::ToolButton* connect,
00054                       Gtk::Window* parent,
00055                       const char* service = "_fawkes._tcp" );
00056 #else
00057   ServiceSelectorCBE( Gtk::ComboBoxEntry* services,
00058                       Gtk::Button* connect,
00059                       Gtk::Window* parent,
00060                       const char* service = "_fawkes._tcp" );
00061   ServiceSelectorCBE( Gtk::ComboBoxEntry* services,
00062                       Gtk::ToolButton* connect,
00063                       Gtk::Window* parent,
00064                       const char* service = "_fawkes._tcp" );
00065 #endif
00066   ServiceSelectorCBE( Glib::RefPtr<Gtk::Builder> builder,
00067                       const char* cbe_name = "cbeServices",
00068                       const char* btn_name = "btnConnect",
00069                       const char* wnd_name = "wndMain",
00070                       const char* service = "_fawkes._tcp" );
00071   virtual ~ServiceSelectorCBE();
00072 
00073   FawkesNetworkClient* get_network_client();
00074   Glib::ustring get_hostname();
00075   Glib::ustring get_name();
00076   unsigned int get_port();
00077 
00078   sigc::signal<void> signal_connected();
00079   sigc::signal<void> signal_disconnected();
00080 
00081  protected:
00082   void initialize();
00083   void on_btn_connect_clicked();
00084   void on_service_selected();
00085   void on_connected();
00086   void on_disconnected();
00087 
00088  protected:
00089 #if GTK_VERSION_GE(3,0)
00090   Gtk::ComboBox        *m_cbe_services;
00091 #else
00092   Gtk::ComboBoxEntry   *m_cbe_services;
00093 #endif
00094   Gtk::Button          *m_btn_connect;
00095   Gtk::ToolButton      *m_tbtn_connect;
00096   Gtk::Window          *m_parent;
00097 
00098   ConnectionDispatcher *m_dispatcher;
00099   ServiceModel         *m_service_model;
00100 
00101  private:
00102    Glib::ustring  __hostname;
00103    Glib::ustring  __servicename;
00104    unsigned short __port;
00105 };
00106 
00107 }
00108 #endif /* __LIBS_GUI_UTILS_SERVICE_SELECTOR_CBE_H_ */