Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdbuscontext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qdbusmessage.h"
5#include "qdbusconnection.h"
7
8#include "qdbuscontext.h"
9#include "qdbuscontext_p.h"
10
11#ifndef QT_NO_DBUS
12
14
16{
17 // determine if this is an adaptor or not
18 if (qobject_cast<QDBusAbstractAdaptor *>(obj))
19 obj = obj->parent();
20
22
23 void *ptr = obj->qt_metacast("QDBusContext");
24 QDBusContext *q_ptr = reinterpret_cast<QDBusContext *>(ptr);
25 if (q_ptr) {
26 QDBusContextPrivate *old = q_ptr->d_ptr;
27 q_ptr->d_ptr = newContext;
28 return old;
29 }
30
31 return nullptr;
32}
33
71 : d_ptr(nullptr)
72{
73}
74
81
91{
92 return d_ptr;
93}
94
99{
100 return d_ptr->connection;
101}
102
107{
108 return d_ptr->message;
109}
110
117{
118 return message().isDelayedReply();
119}
120
140
148void QDBusContext::sendErrorReply(const QString &name, const QString &msg) const
149{
150 setDelayedReply(true);
151 connection().send(message().createErrorReply(name, msg));
152}
153
163{
164 setDelayedReply(true);
165 connection().send(message().createErrorReply(type, msg));
166}
167
169
170#endif // QT_NO_DBUS
\inmodule QtDBus
bool send(const QDBusMessage &message) const
Sends the message over this connection, without waiting for a reply.
const QDBusMessage & message
static QDBusContextPrivate * set(QObject *obj, QDBusContextPrivate *newContext)
QDBusConnection connection
The QDBusContext class allows slots to determine the D-Bus context of the calls.
void setDelayedReply(bool enable) const
Sets whether this call will have a delayed reply or not.
bool isDelayedReply() const
Returns true if this call will have a delayed reply.
void sendErrorReply(const QString &name, const QString &msg=QString()) const
Sends an error name as a reply to the caller.
bool calledFromDBus() const
Returns true if we are processing a D-Bus call.
QDBusContext()
Constructs an empty QDBusContext.
QDBusConnection connection() const
Returns the connection from which this call was received.
const QDBusMessage & message() const
Returns the message that generated this call.
~QDBusContext()
An empty destructor.
ErrorType
In order to facilitate verification of the most common D-Bus errors generated by the D-Bus implementa...
Definition qdbuserror.h:24
\inmodule QtDBus
bool isDelayedReply() const
Returns the delayed reply flag, as set by setDelayedReply().
void setDelayedReply(bool enable) const
Sets whether the message will be replied later (if enable is true) or if an automatic reply should be...
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
static ControlElement< T > * ptr(QWidget *widget)
GLenum type
GLboolean enable
GLuint name
GLhandleARB obj
[2]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QObject::connect nullptr