swift
Public Types | Public Member Functions | Static Public Member Functions | List of all members
swift::misc::CDBusServer Class Reference

Custom DBusServer. More...

Inheritance diagram for swift::misc::CDBusServer:
[legend]

Public Types

enum  ServerMode { SERVERMODE_P2P , SERVERMODE_SESSIONBUS , SERVERMODE_SYSTEMBUS }
 Server mode.
 
- Public Types inherited from QObject
enum  TimerId
 

Public Member Functions

 CDBusServer (const QString &address, QObject *parent=nullptr)
 Construct a server for the core service.
 
 CDBusServer (const QString &service, const QString &address, QObject *parent=nullptr)
 Construct a server for some arbitrary service.
 
 ~CDBusServer ()
 Destructor.
 
void addObject (const QString &name, QObject *object)
 Add a QObject to be exposed via DBus.
 
QDBusError lastQDBusServerError () const
 Last error.
 
const QDBusServer * qDBusServer () const
 DBus server (if using P2P)
 
bool hasQDBusServer () const
 True if using P2P.
 
void removeAllObjects ()
 Remove all objects added with addObject.
 
- Public Member Functions inherited from QObject
QBindable< QString > bindableObjectName ()
 
 QObject (QObject *parent)
 
 QT_NO_CONTEXTLESS_CONNECT QT_NO_CONTEXTLESS_CONNECT
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUMS (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG (...)
 
 Q_FLAGS (...)
 
 Q_FLAG_NS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
T qobject_cast (QObject *object)
 
T qobject_cast (const QObject *object)
 
bool blockSignals (bool block)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
bool moveToThread (QThread *targetThread)
 
bool setProperty (const char *name, QVariant &&value)
 
bool setProperty (const char *name, const QVariant &value)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::nanoseconds interval, Qt::TimerType timerType)
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
void installEventFilter (QObject *filterObj)
 
void killTimer (Qt::TimerId id)
 
void killTimer (int id)
 
void objectNameChanged (const QString &objectName)
 
void removeEventFilter (QObject *obj)
 
void setObjectName (QAnyStringView name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
QList< QByteArray > dynamicPropertyNames () const const
 
QList< T > findChildren (QAnyStringView name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
QObject * parent () const const
 
QString objectName () const const
 
QThread * thread () const const
 
QVariant property (const char *name) const const
 
T findChild (QAnyStringView name, Qt::FindChildOptions options) const const
 
T findChild (Qt::FindChildOptions options) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool inherits (const char *className) const const
 
bool isQmlExposed () const const
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
virtual const QMetaObject * metaObject () const const
 
const QObjectList & children () const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 

Static Public Member Functions

static const QString & coreServiceName ()
 Default service name.
 
static const QString & coreServiceName (const QDBusConnection &connection)
 Service name, empty if is P2P connection.
 
static const QStringList & getLogCategories ()
 Log categories.
 
static const QDBusConnection & defaultConnection ()
 Default connection.
 
static const QString & sessionBusAddress ()
 Address denoting a session bus server.
 
static const QString & systemBusAddress ()
 Address denoting a system bus server.
 
static QDBusConnection connectToDBus (const QString &dbusAddress, const QString &name={})
 Connect to DBus.
 
static void disconnectFromDBus (const QDBusConnection &connection, const QString &dBusAddress)
 Disconnect from Bus/Peer to peer.
 
static QString p2pAddress (const QString &host, const QString &port="")
 Address denoting a P2P server at the given host and port. More...
 
static const QString & p2pConnectionName ()
 P2P connection name.
 
static QString normalizeAddress (const QString &address)
 Turn something like 127.0.0.1:45000 into "tcp:host=127.0.0.1,port=45000". More...
 
static ServerMode modeOfAddress (QString address)
 Return the server mode of the given address.
 
static const QString & modeToString (ServerMode mode)
 Mode to string.
 
static bool isQtDBusAddress (const QString &address)
 True if a valid Qt DBus address, e.g. "unix:tmpdir=/tmp", "tcp:host=127.0.0.1,port=45000".
 
static bool isSessionOrSystemAddress (const QString &address)
 True if address is session or system bus address. More...
 
static bool isP2PAddress (const QString &address)
 False if address is session or system bus address.
 
static bool isP2PConnection (const QDBusConnection &connection)
 False if address is session or system bus connection.
 
static bool dBusAddressToHostAndPort (const QString &dbusAddress, QString &o_host, int &o_port)
 Extract host and port from a DBus address.
 
static bool dBusAddressToHostAndPort (const QString &dbusAddress, QString &o_host, QString &o_port)
 Extract host and port from a DBus address.
 
static bool isQtDefaultConnection (const QDBusConnection &connection)
 Is the given connection one of the default connections?
 
static bool isDBusAvailable (const QString &host, int port, int timeoutMs=1500)
 Is there a DBus server running at the given address? More...
 
static bool isDBusAvailable (const QString &host, int port, QString &message, int timeoutMs=1500)
 Is there a DBus server running at the given address? More...
 
static bool isDBusAvailable (const QString &dbusAddress, QString &message, int timeoutMs=1500)
 Is there a DBus server running at the given address? More...
 
static bool isDBusAvailable (const QString &dbusAddress, int timeoutMs=1500)
 Is there a DBus server running at the given address? More...
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
 Invalid
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
virtual void timerEvent (QTimerEvent *event)
 
QObject * sender () const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
int senderSignalIndex () const const
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Custom DBusServer.

This class implements a custom DBusServer for DBus peer connections, but can also be used with session or system bus. For session/system bus this class represents no real server, but more a wrapper for QDBusConnection and object registration.

Definition at line 33 of file dbusserver.h.

Member Function Documentation

◆ isDBusAvailable() [1/4]

bool swift::misc::CDBusServer::isDBusAvailable ( const QString &  dbusAddress,
int  timeoutMs = 1500 
)
static

Is there a DBus server running at the given address?

Note
This is an incomplete test showing too optimistic results for session DBus

Definition at line 481 of file dbusserver.cpp.

◆ isDBusAvailable() [2/4]

bool swift::misc::CDBusServer::isDBusAvailable ( const QString &  dbusAddress,
QString &  message,
int  timeoutMs = 1500 
)
static

Is there a DBus server running at the given address?

Note
This is an incomplete test showing too optimistic results for session DBus

Definition at line 456 of file dbusserver.cpp.

◆ isDBusAvailable() [3/4]

bool swift::misc::CDBusServer::isDBusAvailable ( const QString &  host,
int  port,
int  timeoutMs = 1500 
)
static

Is there a DBus server running at the given address?

Note
This is an incomplete test showing too optimistic results for session DBus

Definition at line 445 of file dbusserver.cpp.

◆ isDBusAvailable() [4/4]

bool swift::misc::CDBusServer::isDBusAvailable ( const QString &  host,
int  port,
QString &  message,
int  timeoutMs = 1500 
)
static

Is there a DBus server running at the given address?

Note
This is an incomplete test showing too optimistic results for session DBus

Definition at line 451 of file dbusserver.cpp.

◆ isSessionOrSystemAddress()

bool swift::misc::CDBusServer::isSessionOrSystemAddress ( const QString &  address)
static

True if address is session or system bus address.

Remarks
actually swift does NOT support system DBus anymore

Definition at line 178 of file dbusserver.cpp.

◆ normalizeAddress()

QString swift::misc::CDBusServer::normalizeAddress ( const QString &  address)
static

Turn something like 127.0.0.1:45000 into "tcp:host=127.0.0.1,port=45000".

Note
Handles also "session" and "system" as valid address while CDBusServer::p2pAddress is for P2P addresses only.

Definition at line 405 of file dbusserver.cpp.

◆ p2pAddress()

QString swift::misc::CDBusServer::p2pAddress ( const QString &  host,
const QString &  port = "" 
)
static

Address denoting a P2P server at the given host and port.

Remarks
Port number may be embedding in the host string after a colon.
Returns
p2p address like "tcp:host=foo.bar.com,port=1234"

Definition at line 358 of file dbusserver.cpp.


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