Coverage Report

Created: 2026-01-25 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/dbus/qdbuspendingcall_p.h
Line
Count
Source
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
// Qt-Security score:significant reason:default
5
6
//
7
//  W A R N I N G
8
//  -------------
9
//
10
// This file is not part of the public API.  This header file may
11
// change from version to version without notice, or even be
12
// removed.
13
//
14
// We mean it.
15
//
16
//
17
18
#ifndef QDBUSPENDINGCALL_P_H
19
#define QDBUSPENDINGCALL_P_H
20
21
#include <QtDBus/private/qtdbusglobal_p.h>
22
#include <qlist.h>
23
#include <qmutex.h>
24
#include <qpointer.h>
25
#include <qshareddata.h>
26
#include <qwaitcondition.h>
27
28
#include "qdbusmessage.h"
29
#include "qdbus_symbols_p.h"
30
31
#ifndef QT_NO_DBUS
32
33
QT_BEGIN_NAMESPACE
34
35
class QDBusPendingCall;
36
class QDBusPendingCallWatcher;
37
class QDBusPendingCallWatcherHelper;
38
class QDBusConnectionPrivate;
39
40
class QDBusPendingCallPrivate: public QSharedData
41
{
42
public:
43
    // {
44
    //     set only during construction:
45
    const QDBusMessage sentMessage;
46
    QDBusConnectionPrivate * const connection;
47
48
    // for the callback mechanism (see setReplyCallback and QDBusConnectionPrivate::sendWithReplyAsync)
49
    QPointer<QObject> receiver;
50
    QList<QMetaType> metaTypes;
51
    int methodIdx;
52
53
    // }
54
55
    mutable QMutex mutex;
56
    QWaitCondition waitForFinishedCondition;
57
58
    // {
59
    //    protected by the mutex above:
60
    QDBusPendingCallWatcherHelper *watcherHelper;
61
    QDBusMessage replyMessage;
62
    DBusPendingCall *pending;
63
    QString expectedReplySignature;
64
    // }
65
66
    QDBusPendingCallPrivate(const QDBusMessage &sent, QDBusConnectionPrivate *connection)
67
0
        : sentMessage(sent), connection(connection), watcherHelper(nullptr), pending(nullptr)
68
0
    { }
69
    ~QDBusPendingCallPrivate();
70
    bool setReplyCallback(QObject *target, const char *member);
71
    void waitForFinished();
72
    void waitForFinishedWithGui();
73
    void setMetaTypes(int count, const QMetaType *types);
74
    void checkReceivedSignature();
75
};
76
77
class QDBusPendingCallWatcherHelper: public QObject
78
{
79
0
    Q_OBJECT
80
0
public:
81
0
    void add(QDBusPendingCallWatcher *watcher);
82
0
83
0
    void emitSignals(const QDBusMessage &replyMessage, const QDBusMessage &sentMessage)
84
0
    {
85
0
        if (replyMessage.type() == QDBusMessage::ReplyMessage)
86
0
            emit reply(replyMessage);
87
0
        else
88
0
            emit error(QDBusError(replyMessage), sentMessage);
89
0
        emit finished();
90
0
    }
91
92
Q_SIGNALS:
93
    void finished();
94
    void reply(const QDBusMessage &msg);
95
    void error(const QDBusError &error, const QDBusMessage &msg);
96
};
97
98
QT_END_NAMESPACE
99
100
#endif // QT_NO_DBUS
101
#endif