25 #include <gui_utils/service_selector_cbe.h> 26 #include <gui_utils/service_model.h> 27 #include <gui_utils/connection_dispatcher.h> 28 #include <netcomm/fawkes/client.h> 73 #if GTK_VERSION_GE(3,0) 84 m_cbe_services = services;
85 m_btn_connect = connect;
86 m_tbtn_connect = NULL;
98 #if GTK_VERSION_GE(3,0) 103 Gtk::ToolButton* connect,
105 const char* service )
109 m_cbe_services = services;
110 m_btn_connect = NULL;
111 m_tbtn_connect = connect;
125 const char* cbe_name,
126 const char* btn_name,
127 const char* wnd_name,
128 const char* service )
132 builder->get_widget(wnd_name,
m_parent);
143 #if GTK_VERSION_GE(3,0) 145 throw Exception(
"Service combo box does not have an entry, fix UI file?");
149 #if GTK_VERSION_GE(3,0) 157 Gtk::Entry *ent =
static_cast<Gtk::Entry *
>(
m_cbe_services->get_child());
160 char * fawkes_ip = getenv(
"FAWKES_IP");
161 if (fawkes_ip) ent->set_text(fawkes_ip);
162 else ent->set_text(
"localhost");
220 return __servicename;
272 __hostname = entry->get_text();
274 Glib::ustring::size_type pos;
275 if ((pos = __hostname.find(
':')) != Glib::ustring::npos)
277 Glib::ustring host =
"";
278 unsigned int port = 1234567;
279 std::istringstream is(__hostname.replace(pos, 1,
" "));
283 if (port != 1234567 && host.size())
290 __servicename = __hostname;
302 client->
connect( __hostname.c_str(), __port );
306 Glib::ustring message = *(e.
begin());
307 Gtk::MessageDialog md(*
m_parent, message,
false,
308 Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
310 md.set_title(
"Connection failed");
339 client->
connect( __hostname.c_str(), __port );
343 Glib::ustring message = *(e.
begin());
344 Gtk::MessageDialog md(*
m_parent, message,
false,
345 Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
347 md.set_title(
"Connection failed");
359 {
m_tbtn_connect->set_stock_id( Gtk::StockID(
"gtk-disconnect") ); }
Abstract base class for widgets that allow to view the detected services of a certain type...
ServiceRecord & get_column_record()
Access the column record.
sigc::signal< void > signal_disconnected()
Get "disconnected" signal.
sigc::signal< void > signal_connected()
Get "connected" signal.
Gtk::TreeModelColumn< Glib::ustring > hostname
The name of the host the service is running on.
void on_btn_connect_clicked()
Signal handler that is called whenever the connect button is clicked or an entry in the combo box is ...
Simple Fawkes network client.
Gtk::Window * m_parent
The parent Gtk::Window.
sigc::signal< void > signal_disconnected()
This signal is emitted whenever a network connection is terminated.
void on_disconnected()
Signal handler for the connection terminated signal.
Fawkes library namespace.
void disconnect()
Disconnect socket.
void connect()
Connect to remote.
Glib::RefPtr< Gtk::ListStore > & get_list_store()
Get a reference to the model.
void initialize()
Initializer method.
unsigned int get_port()
Returns the currently used port (after connect)
ServiceModel * m_service_model
A liststore which contains information about detected services.
Gtk::ComboBoxEntry * m_cbe_services
A Gtk::ComboBox that lists all available services.
Base class for exceptions in Fawkes.
ServiceSelectorCBE(Gtk::ComboBoxEntry *services, Gtk::Button *connect, Gtk::Window *parent, const char *service="_fawkes._tcp")
Construtor.
Glib::ustring get_name()
Returns the currently selected service name (after connect)
void on_service_selected()
Signal handler that is called whenever an entry is selected from the combo box.
iterator begin()
Get iterator for messages.
Glib::ustring get_hostname()
Returns the currently selected hostname (after connect)
Gtk::TreeModelColumn< unsigned short > port
The port the service is running on.
ConnectionDispatcher * m_dispatcher
A ConnectionDispatcher which dispatches connection signals.
FawkesNetworkClient * get_network_client()
Access the current network client.
void on_connected()
Signal handler for the connection established signal.
Gtk::ToolButton * m_tbtn_connect
A Gtk::ToolButton that triggers the connection.
sigc::signal< void > signal_connected()
This signal is emitted whenever a network connection is established.
Gtk::TreeModelColumn< Glib::ustring > name
The name of the service.
Gtk::Button * m_btn_connect
A Gtk::Button that triggers the connection.
bool connected() const
Check if connection is alive.
FawkesNetworkClient * get_client()
Get client.
Watches network client events and dispatches them as signals.
virtual ~ServiceSelectorCBE()
Destructor.