Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qdbusserver.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qdbusserver.h"
6#include "qdbusconnection_p.h"
8#include "qdbusutil_p.h"
9
10#include <QtCore/private/qlocking_p.h>
11
12#ifndef QT_NO_DBUS
13
15
30{
31 if (address.isEmpty())
32 return;
33
34 if (!qdbus_loadLibDBus())
35 return;
36
38 if (!instance)
39 return;
40
41 emit instance->serverRequested(address, this);
42 Q_ASSERT(d != nullptr);
43
44 QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)),
45 this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection);
46}
47
55{
56#ifdef Q_OS_UNIX
57 // Use Unix sockets on Unix systems only
58 const QString address = QStringLiteral("unix:tmpdir=/tmp");
59#else
60 const QString address = QStringLiteral("tcp:");
61#endif
62
63 if (!qdbus_loadLibDBus())
64 return;
65
67 if (!instance)
68 return;
69
70 emit instance->serverRequested(address, this);
71 Q_ASSERT(d != nullptr);
72
73 QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)),
74 this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection);
75}
76
81{
82 if (!d)
83 return;
84
86 if (!manager)
87 return;
88
89 QMutexLocker locker(&manager->mutex);
90 QWriteLocker writeLocker(&d->lock);
91 for (const QString &name : std::as_const(d->serverConnectionNames))
92 manager->removeConnection(name);
93 d->serverConnectionNames.clear();
94 locker.unlock();
95
96 d->serverObject = nullptr;
97 d->ref.storeRelaxed(0);
98 d->deleteLater();
99}
100
107{
108 return d && d->server && q_dbus_server_get_is_connected(d->server);
109}
110
117{
119}
120
125{
127 if (d && d->server) {
128 char *c = q_dbus_server_get_address(d->server);
130 q_dbus_free(c);
131 }
132
133 return addr;
134}
135
147{
148 if (!d)
149 return;
150
152}
153
162{
163 if (!d)
164 return false;
165
167}
168
177
178#include "moc_qdbusserver.cpp"
179
180#endif // QT_NO_DBUS
void storeRelaxed(T newValue) noexcept
static QDBusConnectionManager * instance()
void serverRequested(const QString &address, void *server)
\inmodule QtDBus
Definition qdbuserror.h:21
bool isAnonymousAuthenticationAllowed() const
QDBusError lastError() const
Returns the last error that happened in this server.
bool isConnected() const
Returns true if this QDBusServer object is connected.
QString address() const
Returns the address this server is associated with.
QDBusServer(const QString &address, QObject *parent=nullptr)
Constructs a QDBusServer with the given address, and the given parent.
void setAnonymousAuthenticationAllowed(bool value)
virtual ~QDBusServer()
Destructs a QDBusServer.
\inmodule QtCore
Definition qmutex.h:317
void unlock() noexcept
Unlocks this mutex locker.
Definition qmutex.h:323
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
void deleteLater()
\threadsafe
Definition qobject.cpp:2352
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
\inmodule QtCore
QString disconnectedErrorMessage()
Combined button and popup list for selecting options.
@ QueuedConnection
bool qdbus_loadLibDBus()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLuint name
const GLubyte * c
GLenum const void * addr
GLuint GLuint64EXT address
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)
#define emit
QObject::connect nullptr
QNetworkAccessManager manager
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent