ContextSubscriber::DBusNameListener Class Reference

Extends the QDBusServiceWatcher; adds the possibility to do an initial check of the service status (asyncronously) and to query the status of the service any time. More...

#include <dbusnamelistener.h>

List of all members.

Public Types

enum  ServicePresence { NotPresent = 0, Present, Unknown }

Signals

void nameAppeared ()
void nameDisappeared ()

Public Member Functions

 DBusNameListener (QDBusConnection::BusType busType, const QString &busName, QObject *parent=0)
 DBusNameListener (const QDBusConnection bus, const QString &busName, QObject *parent=0)
virtual ~DBusNameListener ()
void startListening (bool nameHasOwnerCheck)
 Start listening to the service registration / unregistration over D-Bus.
ServicePresence isServicePresent () const
 Return our current understanding (not present, present, unknown) of the presence of the watched service.

Private Slots

void onNameHasOwnerFinished (QDBusPendingCallWatcher *watcher)
 Handling of the asynchronous reply of the initial query.
void setServicePresent ()
void setServiceGone ()

Private Member Functions

void init ()
 Initializes the QDBusServiceWatcher base part and connects the signals from it.

Private Attributes

ServicePresence servicePresent
 Our current understanding about the service name's state.
QDBusConnection::BusType busType
 The service bus type we are interested in.
QString busName
 The service name we are interested in.
bool listeningStarted
QDBusConnection * connection


Detailed Description

Extends the QDBusServiceWatcher; adds the possibility to do an initial check of the service status (asyncronously) and to query the status of the service any time.

When you create an instance of this class, it won't open any D-Bus connections. When startListening is called, the instance starts using the QDBusServiceWatcher to get updates when the service is registered or unregistered. It can also check the current status of the service by executing an asynchronous NameHasOwner call.

If the specified service appears on D-Bus, it will emit the nameAppeared() signal, if disappears, then the nameDisappeared() signal. An initial query and signal emission will be done if initialCheck is true, which is the default.

Anytime you can check with isServicePresent() if according to our current knowledge (last signal emission) the service is present or not. This means that if initialCheck is false, isServicePresent() can return false, even though the service is present.


Member Enumeration Documentation

Enumerator:
NotPresent 
Present 
Unknown 


Constructor & Destructor Documentation

ContextSubscriber::DBusNameListener::DBusNameListener ( QDBusConnection::BusType  busType,
const QString &  busName,
QObject *  parent = 0 
) [explicit]

ContextSubscriber::DBusNameListener::DBusNameListener ( const QDBusConnection  bus,
const QString &  busName,
QObject *  parent = 0 
) [explicit]

ContextSubscriber::DBusNameListener::~DBusNameListener (  )  [virtual]


Member Function Documentation

void ContextSubscriber::DBusNameListener::startListening ( bool  nameHasOwnerCheck  ) 

Start listening to the service registration / unregistration over D-Bus.

If nameHasOwnerCheck is true, also send a NameHasOwner query to D-Bus (asyncronously).

DBusNameListener::ServicePresence ContextSubscriber::DBusNameListener::isServicePresent (  )  const

Return our current understanding (not present, present, unknown) of the presence of the watched service.

void ContextSubscriber::DBusNameListener::onNameHasOwnerFinished ( QDBusPendingCallWatcher *  watcher  )  [private, slot]

Handling of the asynchronous reply of the initial query.

void ContextSubscriber::DBusNameListener::setServicePresent (  )  [private, slot]

void ContextSubscriber::DBusNameListener::setServiceGone (  )  [private, slot]

void ContextSubscriber::DBusNameListener::init (  )  [private]

Initializes the QDBusServiceWatcher base part and connects the signals from it.

void ContextSubscriber::DBusNameListener::nameAppeared (  )  [signal]

void ContextSubscriber::DBusNameListener::nameDisappeared (  )  [signal]


Member Data Documentation

Our current understanding about the service name's state.

QDBusConnection::BusType ContextSubscriber::DBusNameListener::busType [private]

The service bus type we are interested in.

The service name we are interested in.


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

Generated on Sun Apr 21 16:11:51 2013 for libcontextsubscriber by  doxygen 1.5.6