qpydbusreply.sip 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. // This is the SIP specification of the QPyDBusReply class.
  2. //
  3. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of PyQt6.
  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. class QPyDBusReply /PyName=QDBusReply/
  20. {
  21. %TypeHeaderCode
  22. #include <qpydbusreply.h>
  23. %End
  24. public:
  25. QPyDBusReply(const QDBusMessage &reply) /HoldGIL/;
  26. QPyDBusReply(const QDBusPendingCall &call) /HoldGIL/;
  27. QPyDBusReply(const QDBusError &error);
  28. QPyDBusReply(const QPyDBusReply &other) /HoldGIL/;
  29. ~QPyDBusReply() /HoldGIL/;
  30. const QDBusError &error() const /HoldGIL/;
  31. bool isValid() const /HoldGIL/;
  32. SIP_PYOBJECT value(SIP_PYOBJECT type /TypeHintValue="None"/ = 0) const /HoldGIL/;
  33. };
  34. template<TYPE>
  35. %MappedType QDBusReply<TYPE> /TypeHint="QDBusReply"/
  36. {
  37. %TypeHeaderCode
  38. #include <qdbusreply.h>
  39. #include <qpydbusreply.h>
  40. %End
  41. %ConvertFromTypeCode
  42. PyObject *value_obj;
  43. if (sipCpp->isValid())
  44. {
  45. // Convert the value to a Python object.
  46. TYPE *value = new TYPE(sipCpp->value());
  47. if ((value_obj = sipConvertFromNewType(value, sipType_TYPE, NULL)) == NULL)
  48. {
  49. delete value;
  50. return 0;
  51. }
  52. }
  53. else
  54. {
  55. value_obj = 0;
  56. }
  57. QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
  58. sipCpp->error());
  59. PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
  60. sipTransferObj);
  61. if (!reply_obj)
  62. {
  63. delete reply;
  64. return 0;
  65. }
  66. return reply_obj;
  67. %End
  68. };
  69. %MappedType QDBusReply<void> /TypeHint="QDBusReply"/
  70. {
  71. %TypeHeaderCode
  72. #include <qdbusreply.h>
  73. #include <qpydbusreply.h>
  74. %End
  75. %ConvertFromTypeCode
  76. Py_INCREF(Py_None);
  77. QPyDBusReply *reply = new QPyDBusReply(Py_None,
  78. sipCpp->isValid(), sipCpp->error());
  79. PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
  80. sipTransferObj);
  81. if (!reply_obj)
  82. {
  83. delete reply;
  84. return 0;
  85. }
  86. return reply_obj;
  87. %End
  88. };
  89. %MappedType QDBusReply<bool> /TypeHint="QDBusReply"/
  90. {
  91. %TypeHeaderCode
  92. #include <qdbusreply.h>
  93. #include <qpydbusreply.h>
  94. %End
  95. %ConvertFromTypeCode
  96. PyObject *value_obj;
  97. if (sipCpp->isValid())
  98. {
  99. if ((value_obj = PyBool_FromLong(sipCpp->value())) == NULL)
  100. return 0;
  101. }
  102. else
  103. {
  104. value_obj = 0;
  105. }
  106. QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
  107. sipCpp->error());
  108. PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
  109. sipTransferObj);
  110. if (!reply_obj)
  111. {
  112. delete reply;
  113. return 0;
  114. }
  115. return reply_obj;
  116. %End
  117. };
  118. %MappedType QDBusReply<unsigned> /TypeHint="QDBusReply"/
  119. {
  120. %TypeHeaderCode
  121. #include <qdbusreply.h>
  122. #include <qpydbusreply.h>
  123. %End
  124. %ConvertFromTypeCode
  125. PyObject *value_obj;
  126. if (sipCpp->isValid())
  127. {
  128. if ((value_obj = PyLong_FromUnsignedLong(sipCpp->value())) == NULL)
  129. return NULL;
  130. }
  131. else
  132. {
  133. value_obj = 0;
  134. }
  135. QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
  136. sipCpp->error());
  137. PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
  138. sipTransferObj);
  139. if (!reply_obj)
  140. {
  141. delete reply;
  142. return 0;
  143. }
  144. return reply_obj;
  145. %End
  146. };
  147. %MappedType QDBusReply<QDBusConnectionInterface::RegisterServiceReply> /TypeHint="QDBusReply"/
  148. {
  149. %TypeHeaderCode
  150. #include <qdbusreply.h>
  151. #include <qpydbusreply.h>
  152. %End
  153. %ConvertFromTypeCode
  154. PyObject *value_obj;
  155. if (sipCpp->isValid())
  156. {
  157. if ((value_obj = sipConvertFromEnum(sipCpp->value(), sipType_QDBusConnectionInterface_RegisterServiceReply)) == NULL)
  158. return NULL;
  159. }
  160. else
  161. {
  162. value_obj = 0;
  163. }
  164. QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
  165. sipCpp->error());
  166. PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
  167. sipTransferObj);
  168. if (!reply_obj)
  169. {
  170. delete reply;
  171. return NULL;
  172. }
  173. return reply_obj;
  174. %End
  175. };
  176. %If (Qt_6_10_0 -)
  177. %MappedType QDBusReply<QMap<QString, QVariant>> /TypeHint="QDBusReply"/
  178. {
  179. %TypeHeaderCode
  180. #include <qdbusreply.h>
  181. #include <qpydbusreply.h>
  182. %End
  183. %ConvertFromTypeCode
  184. PyObject *value_obj;
  185. if (sipCpp->isValid())
  186. {
  187. if ((value_obj = PyDict_New()) == NULL)
  188. return 0;
  189. QMap<QString, QVariant> value = sipCpp->value();
  190. QMap<QString, QVariant>::const_iterator it = value.constBegin();
  191. QMap<QString, QVariant>::const_iterator end = value.constEnd();
  192. while (it != end)
  193. {
  194. QString *k = new QString(it.key());
  195. PyObject *kobj = sipConvertFromNewType(k, sipType_QString,
  196. sipTransferObj);
  197. if (!kobj)
  198. {
  199. delete k;
  200. Py_DECREF(value_obj);
  201. return 0;
  202. }
  203. QVariant *v = new QVariant(it.value());
  204. PyObject *vobj = sipConvertFromNewType(v, sipType_QVariant,
  205. sipTransferObj);
  206. if (!vobj)
  207. {
  208. delete v;
  209. Py_DECREF(kobj);
  210. Py_DECREF(value_obj);
  211. return 0;
  212. }
  213. int rc = PyDict_SetItem(value_obj, kobj, vobj);
  214. Py_DECREF(vobj);
  215. Py_DECREF(kobj);
  216. if (rc < 0)
  217. {
  218. Py_DECREF(value_obj);
  219. return 0;
  220. }
  221. ++it;
  222. }
  223. }
  224. else
  225. {
  226. value_obj = 0;
  227. }
  228. QPyDBusReply *reply = new QPyDBusReply(value_obj, sipCpp->isValid(),
  229. sipCpp->error());
  230. PyObject *reply_obj = sipConvertFromNewType(reply, sipType_QPyDBusReply,
  231. sipTransferObj);
  232. if (!reply_obj)
  233. {
  234. delete reply;
  235. return 0;
  236. }
  237. return reply_obj;
  238. %End
  239. };
  240. %End