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)
74ServiceSelectorCBE::ServiceSelectorCBE(Gtk::ComboBox *services,
76ServiceSelectorCBE::ServiceSelectorCBE(Gtk::ComboBoxEntry *services,
84 m_cbe_services = services;
85 m_btn_connect = connect;
86 m_tbtn_connect = NULL;
98#if GTK_VERSION_GE(3, 0)
99ServiceSelectorCBE::ServiceSelectorCBE(Gtk::ComboBox *services,
101ServiceSelectorCBE::ServiceSelectorCBE(Gtk::ComboBoxEntry *services,
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;
124ServiceSelectorCBE::ServiceSelectorCBE(Glib::RefPtr<Gtk::Builder> builder,
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");
Watches network client events and dispatches them as signals.
sigc::signal< void > signal_connected()
Get "connected" signal.
FawkesNetworkClient * get_client()
Get client.
sigc::signal< void > signal_disconnected()
Get "disconnected" signal.
Base class for exceptions in Fawkes.
iterator begin() noexcept
Get iterator for messages.
Simple Fawkes network client.
void connect()
Connect to remote.
void disconnect()
Disconnect socket.
bool connected() const noexcept
Check if connection is alive.
Gtk::TreeModelColumn< unsigned short > port
The port the service is running on.
Gtk::TreeModelColumn< Glib::ustring > name
The name of the service.
Gtk::TreeModelColumn< Glib::ustring > hostname
The name of the host the service is running on.
Abstract base class for widgets that allow to view the detected services of a certain type.
ServiceRecord & get_column_record()
Access the column record.
Glib::RefPtr< Gtk::ListStore > & get_list_store()
Get a reference to the model.
void on_btn_connect_clicked()
Signal handler that is called whenever the connect button is clicked or an entry in the combo box is ...
void initialize()
Initializer method.
Glib::ustring get_name()
Returns the currently selected service name (after connect)
void on_disconnected()
Signal handler for the connection terminated signal.
Gtk::Window * m_parent
The parent Gtk::Window.
void on_connected()
Signal handler for the connection established signal.
Gtk::ToolButton * m_tbtn_connect
A Gtk::ToolButton that triggers the connection.
Gtk::Button * m_btn_connect
A Gtk::Button that triggers the connection.
unsigned int get_port()
Returns the currently used port (after connect)
sigc::signal< void > signal_connected()
This signal is emitted whenever a network connection is established.
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.
ConnectionDispatcher * m_dispatcher
A ConnectionDispatcher which dispatches connection signals.
void on_service_selected()
Signal handler that is called whenever an entry is selected from the combo box.
FawkesNetworkClient * get_network_client()
Access the current network client.
sigc::signal< void > signal_disconnected()
This signal is emitted whenever a network connection is terminated.
Glib::ustring get_hostname()
Returns the currently selected hostname (after connect)
virtual ~ServiceSelectorCBE()
Destructor.
Fawkes library namespace.