Classes | Public Member Functions | Protected Member Functions | Protected Attributes

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:
Inheritance graph
[legend]

List of all members.

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.

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"  ) 
ServiceModel::ServiceModel ( fawkes::AvahiThread avahi_thread  ) 

Constructor.

Parameters:
avahi_thread an AvahiThread that already watches for the desired type of services

Definition at line 104 of file service_model.cpp.

References m_avahi, m_service_list, and m_service_record.

ServiceModel::~ServiceModel (  )  [virtual]

Destructor.

Definition at line 113 of file service_model.cpp.

References fawkes::Thread::cancel(), fawkes::Thread::join(), and m_avahi.


Member Function Documentation

void ServiceModel::all_for_now (  )  [protected, virtual]

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 
) [protected, virtual]

Failed to browse for a given service.

Parameters:
name name of the service
type type of the service
domain domain of the service

Implements fawkes::ServiceBrowseHandler.

Definition at line 152 of file service_model.cpp.

void ServiceModel::cache_exhausted (  )  [protected, virtual]

Cache exhausted.

Implements fawkes::ServiceBrowseHandler.

Definition at line 147 of file service_model.cpp.

ServiceModel::ServiceRecord & ServiceModel::get_column_record (  ) 
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.

References m_service_list.

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

void ServiceModel::on_service_added (  )  [protected, virtual]
void ServiceModel::on_service_removed (  )  [protected, virtual]
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 
) [protected, virtual]

A service has been announced on the network.

Parameters:
name name of the service
type type of the service
domain domain of the service
host_name name of the host that provides the service
addr pointer to sockaddr struct of appropriate type for address
addr_size size of addr struct
port port of the service
txt list of txt records.
flags extra 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, m_added_services, m_signal_service_added, fawkes::ServiceModel::ServiceAddedRecord::name, fawkes::ServiceModel::ServiceAddedRecord::port, fawkes::LockQueue< Type >::push_locked(), and fawkes::ServiceModel::ServiceAddedRecord::type.

void ServiceModel::service_removed ( const char *  name,
const char *  type,
const char *  domain 
) [protected, virtual]

A service has been removed from the network.

Parameters:
name name of the service
type type of the service
domain domain of the service

Implements fawkes::ServiceBrowseHandler.

Definition at line 185 of file service_model.cpp.

References fawkes::ServiceModel::ServiceRemovedRecord::domain, m_removed_services, m_signal_service_removed, fawkes::ServiceModel::ServiceRemovedRecord::name, fawkes::LockQueue< Type >::push_locked(), and fawkes::ServiceModel::ServiceRemovedRecord::type.


Member Data Documentation

Queue that holds the newly added services.

Definition at line 103 of file service_model.h.

Referenced by on_service_added(), and service_added().

Avahi thread.

Definition at line 115 of file service_model.h.

Referenced by ServiceModel(), and ~ServiceModel().

Queue that holds the recently removed services.

Definition at line 104 of file service_model.h.

Referenced by on_service_removed(), and service_removed().

Storage object.

Definition at line 112 of file service_model.h.

Referenced by get_list_store(), on_service_added(), on_service_removed(), and ServiceModel().

Column record class.

Definition at line 113 of file service_model.h.

Referenced by get_column_record(), on_service_added(), on_service_removed(), and ServiceModel().

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

Definition at line 106 of file service_model.h.

Referenced by service_added(), and ServiceModel().

This signal is emitted whenever a service is removed.

Definition at line 107 of file service_model.h.

Referenced by service_removed(), and ServiceModel().


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