1 // This is the implementation of the QPyDBusPendingReply class.
2 //
3 // Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
4 //
5 // This file is part of PyQt5.
6 //
7 // This file may be used under the terms of the GNU General Public License
8 // version 3.0 as published by the Free Software Foundation and appearing in
9 // the file LICENSE included in the packaging of this file.  Please review the
10 // following information to ensure the GNU General Public License version 3.0
11 // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 //
13 // If you do not wish to use this file under the terms of the GPL version 3.0
14 // then you may purchase a commercial license.  For more information contact
15 // info@riverbankcomputing.com.
16 //
17 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 
20 
21 #include <Python.h>
22 
23 #include "qpydbuspendingreply.h"
24 
25 #include "sipAPIQtDBus.h"
26 
27 
28 // Default ctor.
QPyDBusPendingReply()29 QPyDBusPendingReply::QPyDBusPendingReply() : QDBusPendingReply<void>()
30 {
31 }
32 
33 
34 // Copy a reply.
QPyDBusPendingReply(const QPyDBusPendingReply & other)35 QPyDBusPendingReply::QPyDBusPendingReply(const QPyDBusPendingReply &other)
36         : QDBusPendingReply<void>(other)
37 {
38 }
39 
40 
41 // Extract a reply from another pending call.
QPyDBusPendingReply(const QDBusPendingCall & call)42 QPyDBusPendingReply::QPyDBusPendingReply(const QDBusPendingCall &call)
43         : QDBusPendingReply<void>(call)
44 {
45 }
46 
47 
48 // Extract a reply from a message.
QPyDBusPendingReply(const QDBusMessage & reply)49 QPyDBusPendingReply::QPyDBusPendingReply(const QDBusMessage &reply)
50         : QDBusPendingReply<void>(reply)
51 {
52 }
53 
54 
55 // Return the value of the reply.  The GIL should be held.
value(PyObject * type) const56 PyObject *QPyDBusPendingReply::value(PyObject *type) const
57 {
58     QVariant val;
59 
60     // This will wait for the call to complete.
61     Py_BEGIN_ALLOW_THREADS
62     val = argumentAt(0);
63     Py_END_ALLOW_THREADS
64 
65     return pyqt5_qtdbus_from_qvariant_by_type(val, type);
66 }
67