Fawkes API  Fawkes Development Version
fawkes::ServiceChooserDialog Class Reference

Service chooser dialog. More...

#include <>>

Inheritance diagram for fawkes::ServiceChooserDialog:

Public Member Functions

 ServiceChooserDialog (Gtk::Window &parent, FawkesNetworkClient *client, Glib::ustring title="Select Service", const char *service="_fawkes._tcp")
 Constructor. More...
 
 ServiceChooserDialog (Gtk::Window &parent, Glib::ustring title="Select Service", const char *service="_fawkes._tcp")
 Constructor. More...
 
virtual ~ServiceChooserDialog ()
 Destructor. More...
 
void get_selected_service (Glib::ustring &name, Glib::ustring &hostname, unsigned short int &port)
 Get selected service. More...
 
void get_selected_service (Glib::ustring &hostname, struct sockaddr_storage &sockaddr)
 Get selected service. More...
 
void get_raw_address (struct sockaddr *addr, socklen_t addr_size)
 Get raw address. More...
 
void run_and_connect ()
 Run dialog and try to connect. More...
 

Protected Member Functions

virtual void on_expander_changed ()
 Signal handler for expander event. More...
 

Detailed Description

Service chooser dialog.

Allows to choose a service discovered via Avahi. Use the run routine, it returns 1 if a service was selected or 0 if no service was found or the selection was cancelled. The dialog is always modal.

Author
Tim Niemueller

Definition at line 46 of file service_chooser_dialog.h.

Constructor & Destructor Documentation

◆ ServiceChooserDialog() [1/2]

fawkes::ServiceChooserDialog::ServiceChooserDialog ( Gtk::Window &  parent,
FawkesNetworkClient client,
Glib::ustring  title = "Select Service",
const char *  service = "_fawkes._tcp" 
)

Constructor.

Parameters
parentparent window
clientFawkes network client to connect on run()
titletitle of the dialog
serviceservice string

Definition at line 80 of file service_chooser_dialog.cpp.

◆ ServiceChooserDialog() [2/2]

fawkes::ServiceChooserDialog::ServiceChooserDialog ( Gtk::Window &  parent,
Glib::ustring  title = "Select Service",
const char *  service = "_fawkes._tcp" 
)

Constructor.

Parameters
parentparent window
titletitle of the dialog
serviceservice string

Definition at line 62 of file service_chooser_dialog.cpp.

◆ ~ServiceChooserDialog()

Member Function Documentation

◆ get_raw_address()

void fawkes::ServiceChooserDialog::get_raw_address ( struct sockaddr *  addr,
socklen_t  addr_size 
)

Get raw address.

Parameters
addrupon returns contains the raw representation of the IP address
addr_sizesize in bytes of addr, if addr_size is too small for an AF_INET addr an exception is thrown.

Definition at line 236 of file service_chooser_dialog.cpp.

Referenced by NetLogGuiGtkWindow::~NetLogGuiGtkWindow().

◆ get_selected_service() [1/2]

void fawkes::ServiceChooserDialog::get_selected_service ( Glib::ustring &  name,
Glib::ustring &  hostname,
unsigned short int &  port 
)

Get selected service.

If a service has been selected use this method to get the IP Address as string of the host that has the service and the port.

Parameters
namename of the service
hostnamehostname of the host associated with the service
portupon successful return contains the port
Exceptions
Exceptionthrown if no service has been selected

Definition at line 173 of file service_chooser_dialog.cpp.

References fawkes::ServiceModel::get_column_record(), fawkes::ServiceModel::ServiceRecord::ipaddr, fawkes::ServiceModel::ServiceRecord::name, fawkes::ArgumentParser::parse_hostport_s(), and fawkes::ServiceModel::ServiceRecord::port.

Referenced by run_and_connect(), and NetLogGuiGtkWindow::~NetLogGuiGtkWindow().

◆ get_selected_service() [2/2]

void fawkes::ServiceChooserDialog::get_selected_service ( Glib::ustring &  hostname,
struct sockaddr_storage &  sockaddr 
)

Get selected service.

If a service has been selected use this method to get the IP Address as string of the host that has the service and the port. May not be called for manual entry since this would require hostname resolution within the dialog. That should be handled on the caller's side.

Parameters
hostnamehostname of the host associated with the service
sockaddrupon successful return contains the sockaddr structure of the specific endpoint
Exceptions
Exceptionthrown if no service has been selected

Definition at line 210 of file service_chooser_dialog.cpp.

References fawkes::ServiceModel::get_column_record(), fawkes::ServiceModel::ServiceRecord::ipaddr, and fawkes::ServiceModel::ServiceRecord::sockaddr.

◆ on_expander_changed()

void fawkes::ServiceChooserDialog::on_expander_changed ( )
protectedvirtual

Signal handler for expander event.

Called when expander is (de-)expanded. Only works with Glibmm properties enabled, i.e. not on Maemo.

Definition at line 267 of file service_chooser_dialog.cpp.

Referenced by ~ServiceChooserDialog().

◆ run_and_connect()

void fawkes::ServiceChooserDialog::run_and_connect ( )

Run dialog and try to connect.

This runs the service chooser dialog and connects to the given service with the attached FawkesNetworkClient. If the connection couldn't be established an error dialog is shown. You should not rely on the connection to be active after calling this method, rather you should use a ConnectionDispatcher to get the "connected" signal.

Definition at line 285 of file service_chooser_dialog.cpp.

References fawkes::Exception::begin(), fawkes::FawkesNetworkClient::connect(), fawkes::FawkesNetworkClient::connected(), and get_selected_service().

Referenced by LaserGuiGtkWindow::on_connection_clicked(), LaserGuiHildonWindow::on_connection_clicked(), Bumblebee2CalibGtkWindow::~Bumblebee2CalibGtkWindow(), EclipseDebugger::~EclipseDebugger(), NaoGuiGtkWindow::~NaoGuiGtkWindow(), and SkillGuiGtkWindow::~SkillGuiGtkWindow().


The documentation for this class was generated from the following files: