| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- // This is the SIP specification of the QPyDBusReply class.
- //
- // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
- //
- // This file is part of PyQt6.
- //
- // This file may be used under the terms of the GNU General Public License
- // version 3.0 as published by the Free Software Foundation and appearing in
- // the file LICENSE included in the packaging of this file. Please review the
- // following information to ensure the GNU General Public License version 3.0
- // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
- //
- // If you do not wish to use this file under the terms of the GPL version 3.0
- // then you may purchase a commercial license. For more information contact
- // info@riverbankcomputing.com.
- //
- // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- class QPyDBusReply /PyName=QDBusReply/
- {
- %TypeHeaderCode
- #include <qpydbusreply.h>
- %End
- public:
- QPyDBusReply(const QDBusMessage &reply) /HoldGIL/;
- QPyDBusReply(const QDBusPendingCall &call) /HoldGIL/;
- QPyDBusReply(const QDBusError &error);
- QPyDBusReply(const QPyDBusReply &other) /HoldGIL/;
- ~QPyDBusReply() /HoldGIL/;
- const QDBusError &error() const /HoldGIL/;
- bool isValid() const /HoldGIL/;
- SIP_PYOBJECT value(SIP_PYOBJECT type /TypeHintValue="None"/ = 0) const /HoldGIL/;
- };
- template<TYPE>
- %MappedType QDBusReply<TYPE> /TypeHint="QDBusReply"/
- {
- %TypeHeaderCode
- #include <qdbusreply.h>
- #include <qpydbusreply.h>
- %End
- %ConvertFromTypeCode
- PyObject *value_obj;
- if (sipCpp->isValid())
- {
- // Convert the value to a Python object.
- TYPE *value = new TYPE(sipCpp->value());
- if ((value_obj = sipConvertFromNewType(value, sipType_TYPE, NULL)) == NULL)
- {
- delete value;
- return 0;
- }
- }
- else
- {
- value_obj = 0;
- }
- QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
- sipCpp->error());
- PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
- sipTransferObj);
- if (!reply_obj)
- {
- delete reply;
- return 0;
- }
- return reply_obj;
- %End
- };
- %MappedType QDBusReply<void> /TypeHint="QDBusReply"/
- {
- %TypeHeaderCode
- #include <qdbusreply.h>
- #include <qpydbusreply.h>
- %End
- %ConvertFromTypeCode
- Py_INCREF(Py_None);
- QPyDBusReply *reply = new QPyDBusReply(Py_None,
- sipCpp->isValid(), sipCpp->error());
- PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
- sipTransferObj);
- if (!reply_obj)
- {
- delete reply;
- return 0;
- }
- return reply_obj;
- %End
- };
- %MappedType QDBusReply<bool> /TypeHint="QDBusReply"/
- {
- %TypeHeaderCode
- #include <qdbusreply.h>
- #include <qpydbusreply.h>
- %End
- %ConvertFromTypeCode
- PyObject *value_obj;
- if (sipCpp->isValid())
- {
- if ((value_obj = PyBool_FromLong(sipCpp->value())) == NULL)
- return 0;
- }
- else
- {
- value_obj = 0;
- }
- QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
- sipCpp->error());
- PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
- sipTransferObj);
- if (!reply_obj)
- {
- delete reply;
- return 0;
- }
- return reply_obj;
- %End
- };
- %MappedType QDBusReply<unsigned> /TypeHint="QDBusReply"/
- {
- %TypeHeaderCode
- #include <qdbusreply.h>
- #include <qpydbusreply.h>
- %End
- %ConvertFromTypeCode
- PyObject *value_obj;
- if (sipCpp->isValid())
- {
- if ((value_obj = PyLong_FromUnsignedLong(sipCpp->value())) == NULL)
- return NULL;
- }
- else
- {
- value_obj = 0;
- }
- QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
- sipCpp->error());
- PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
- sipTransferObj);
- if (!reply_obj)
- {
- delete reply;
- return 0;
- }
- return reply_obj;
- %End
- };
- %MappedType QDBusReply<QDBusConnectionInterface::RegisterServiceReply> /TypeHint="QDBusReply"/
- {
- %TypeHeaderCode
- #include <qdbusreply.h>
- #include <qpydbusreply.h>
- %End
- %ConvertFromTypeCode
- PyObject *value_obj;
- if (sipCpp->isValid())
- {
- if ((value_obj = sipConvertFromEnum(sipCpp->value(), sipType_QDBusConnectionInterface_RegisterServiceReply)) == NULL)
- return NULL;
- }
- else
- {
- value_obj = 0;
- }
- QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
- sipCpp->error());
- PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
- sipTransferObj);
- if (!reply_obj)
- {
- delete reply;
- return NULL;
- }
- return reply_obj;
- %End
- };
- %If (Qt_6_10_0 -)
- %MappedType QDBusReply<QMap<QString, QVariant>> /TypeHint="QDBusReply"/
- {
- %TypeHeaderCode
- #include <qdbusreply.h>
- #include <qpydbusreply.h>
- %End
- %ConvertFromTypeCode
- PyObject *value_obj;
- if (sipCpp->isValid())
- {
- if ((value_obj = PyDict_New()) == NULL)
- return 0;
- QMap<QString, QVariant> value = sipCpp->value();
- QMap<QString, QVariant>::const_iterator it = value.constBegin();
- QMap<QString, QVariant>::const_iterator end = value.constEnd();
- while (it != end)
- {
- QString *k = new QString(it.key());
- PyObject *kobj = sipConvertFromNewType(k, sipType_QString,
- sipTransferObj);
- if (!kobj)
- {
- delete k;
- Py_DECREF(value_obj);
- return 0;
- }
- QVariant *v = new QVariant(it.value());
- PyObject *vobj = sipConvertFromNewType(v, sipType_QVariant,
- sipTransferObj);
- if (!vobj)
- {
- delete v;
- Py_DECREF(kobj);
- Py_DECREF(value_obj);
- return 0;
- }
- int rc = PyDict_SetItem(value_obj, kobj, vobj);
- Py_DECREF(vobj);
- Py_DECREF(kobj);
- if (rc < 0)
- {
- Py_DECREF(value_obj);
- return 0;
- }
- ++it;
- }
- }
- else
- {
- value_obj = 0;
- }
- QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
- sipCpp->error());
- PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
- sipTransferObj);
- if (!reply_obj)
- {
- delete reply;
- return 0;
- }
- return reply_obj;
- %End
- };
- %End
|