Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fawkes::ServiceModel Class Reference

Abstract base class for widgets that allow to view the detected services of a certain type. More...

#include <gui_utils/service_model.h>

Inheritance diagram for fawkes::ServiceModel:

Classes

struct  ServiceAddedRecord
 Data structure to hold information about a newly added services. More...
class  ServiceRecord
 Detects services and manages information about detected services. More...
struct  ServiceRemovedRecord
 Data structure to hold information about a recently removed services. More...

Public Member Functions

 ServiceModel (const char *service="_fawkes._tcp")
 Constructor.
 ServiceModel (fawkes::AvahiThread *avahi_thread)
 Constructor.
virtual ~ServiceModel ()
 Destructor.
Glib::RefPtr< Gtk::ListStore > & get_list_store ()
 Get a reference to the model.
ServiceRecordget_column_record ()
 Access the column record.
- Public Member Functions inherited from fawkes::ServiceBrowseHandler
virtual ~ServiceBrowseHandler ()
 Virtual destructor.

Protected Member Functions

void all_for_now ()
 All results have been retrieved.
void cache_exhausted ()
 Cache exhausted.
void browse_failed (const char *name, const char *type, const char *domain)
 Failed to browse for a given service.
void service_added (const char *name, const char *type, const char *domain, const char *host_name, const struct sockaddr *addr, const socklen_t addr_size, uint16_t port, std::list< std::string > &txt, int flags)
 A service has been announced on the network.
void service_removed (const char *name, const char *type, const char *domain)
 A service has been removed from the network.
virtual void on_service_added ()
 Signal handler for the service-added signal.
virtual void on_service_removed ()
 Signal handler for the service-removed signal.

Protected Attributes

fawkes::LockQueue
< ServiceAddedRecord
m_added_services
 Queue that holds the newly added services.
fawkes::LockQueue
< ServiceRemovedRecord
m_removed_services
 Queue that holds the recently removed services.
Glib::Dispatcher m_signal_service_added
 This signal is emitted whenever a new service has been added.
Glib::Dispatcher m_signal_service_removed
 This signal is emitted whenever a service is removed.
Glib::RefPtr< Gtk::ListStore > m_service_list
 Storage object.
ServiceRecord m_service_record
 Column record class.
fawkes::AvahiThreadm_avahi
 Avahi thread.

Detailed Description

Abstract base class for widgets that allow to view the detected services of a certain type.

Author
Daniel Beck

Definition at line 34 of file service_model.h.

Constructor & Destructor Documentation

ServiceModel::ServiceModel ( const char *  service = "_fawkes._tcp")

Constructor.

Parameters
servicethe service identifier

Definition at line 86 of file service_model.cpp.

ServiceModel::ServiceModel ( fawkes::AvahiThread avahi_thread)

Constructor.

Parameters
avahi_threadan AvahiThread that already watches for the desired type of services

Definition at line 104 of file service_model.cpp.

ServiceModel::~ServiceModel ( )
virtual

Destructor.

Definition at line 113 of file service_model.cpp.

References fawkes::Thread::cancel().

Member Function Documentation

void ServiceModel::all_for_now ( )
protectedvirtual

All results have been retrieved.

If you read the DNS-SD specs you will see that there is no explicit "not existent" or "end of records" message - it cannot be. But after some time it is assumed that there are no more records. If that is the case this method is called.

Implements fawkes::ServiceBrowseHandler.

Definition at line 142 of file service_model.cpp.

void ServiceModel::browse_failed ( const char *  name,
const char *  type,
const char *  domain 
)
protectedvirtual

Failed to browse for a given service.

Parameters
namename of the service
typetype of the service
domaindomain of the service

Implements fawkes::ServiceBrowseHandler.

Definition at line 152 of file service_model.cpp.

void ServiceModel::cache_exhausted ( )
protectedvirtual

Cache exhausted.

Implements fawkes::ServiceBrowseHandler.

Definition at line 147 of file service_model.cpp.

Glib::RefPtr< Gtk::ListStore > & ServiceModel::get_list_store ( )

Get a reference to the model.

Returns
a reference to the model

Definition at line 127 of file service_model.cpp.

Referenced by fawkes::ServiceSelectorCBE::initialize().

void ServiceModel::on_service_removed ( )
protectedvirtual
void ServiceModel::service_added ( const char *  name,
const char *  type,
const char *  domain,
const char *  host_name,
const struct sockaddr *  addr,
const socklen_t  addr_size,
uint16_t  port,
std::list< std::string > &  txt,
int  flags 
)
protectedvirtual

A service has been announced on the network.

Parameters
namename of the service
typetype of the service
domaindomain of the service
host_namename of the host that provides the service
addrpointer to sockaddr struct of appropriate type for address
addr_sizesize of addr struct
portport of the service
txtlist of txt records.
flagsextra flags, see Avahi documentation

Implements fawkes::ServiceBrowseHandler.

Definition at line 159 of file service_model.cpp.

References fawkes::ServiceModel::ServiceAddedRecord::domain, fawkes::ServiceModel::ServiceAddedRecord::hostname, fawkes::ServiceModel::ServiceAddedRecord::ipaddr, fawkes::ServiceModel::ServiceAddedRecord::name, fawkes::ServiceModel::ServiceAddedRecord::port, and fawkes::ServiceModel::ServiceAddedRecord::type.

void ServiceModel::service_removed ( const char *  name,
const char *  type,
const char *  domain 
)
protectedvirtual

A service has been removed from the network.

Parameters
namename of the service
typetype of the service
domaindomain of the service

Implements fawkes::ServiceBrowseHandler.

Definition at line 185 of file service_model.cpp.

References fawkes::ServiceModel::ServiceRemovedRecord::domain, fawkes::ServiceModel::ServiceRemovedRecord::name, and fawkes::ServiceModel::ServiceRemovedRecord::type.

Member Data Documentation

fawkes::ServiceModel::m_added_services
protected

Queue that holds the newly added services.

Definition at line 103 of file service_model.h.

fawkes::ServiceModel::m_avahi
protected

Avahi thread.

Definition at line 115 of file service_model.h.

fawkes::ServiceModel::m_removed_services
protected

Queue that holds the recently removed services.

Definition at line 104 of file service_model.h.

fawkes::ServiceModel::m_service_list
protected

Storage object.

Definition at line 112 of file service_model.h.

fawkes::ServiceModel::m_service_record
protected

Column record class.

Definition at line 113 of file service_model.h.

fawkes::ServiceModel::m_signal_service_added
protected

This signal is emitted whenever a new service has been added.

Definition at line 106 of file service_model.h.

fawkes::ServiceModel::m_signal_service_removed
protected

This signal is emitted whenever a service is removed.

Definition at line 107 of file service_model.h.


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