25 #include <gui_utils/connection_dispatcher.h> 26 #include <gui_utils/service_model.h> 27 #include <gui_utils/service_selector_cbe.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,
104 Gtk::Window * parent,
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) 158 Gtk::Entry *ent = static_cast<Gtk::Entry *>(
m_cbe_services->get_child());
160 char *fawkes_ip = getenv(
"FAWKES_IP");
162 ent->set_text(fawkes_ip);
164 ent->set_text(
"localhost");
271 hostname_ = entry->get_text();
273 Glib::ustring::size_type pos;
274 if ((pos = hostname_.find(
':')) != Glib::ustring::npos) {
275 Glib::ustring host =
"";
276 unsigned int port = 1234567;
277 std::istringstream is(hostname_.replace(pos, 1,
" "));
281 if (port != 1234567 && host.size()) {
287 servicename_ = hostname_;
296 client->
connect(hostname_.c_str(), port_);
298 Glib::ustring message = *(e.
begin());
305 md.set_title(
"Connection failed");
333 client->
connect(hostname_.c_str(), port_);
335 Glib::ustring message = *(e.
begin());
342 md.set_title(
"Connection failed");
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.