#include <dbusnamelistener.h>
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 |
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.
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] |
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] |
Our current understanding about the service name's state.
QDBusConnection::BusType ContextSubscriber::DBusNameListener::busType [private] |
The service bus type we are interested in.
QString ContextSubscriber::DBusNameListener::busName [private] |
The service name we are interested in.
bool ContextSubscriber::DBusNameListener::listeningStarted [private] |
QDBusConnection* ContextSubscriber::DBusNameListener::connection [private] |