qpermissions.sip 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // qpermissions.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtCore Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. %If (Qt_6_5_0 -)
  22. %If (PyQt_Permissions)
  23. class QPermission /TypeHintIn="Union[QBluetoothPermission, QCalendarPermission, QCameraPermission, QContactsPermission, QLocationPermission, QMicrophonePermission]"/
  24. {
  25. %TypeHeaderCode
  26. #include <qpermissions.h>
  27. %End
  28. %ConvertToTypeCode
  29. // Note that we don't allow sub-classes of the typed permissions.
  30. const sipTypeDef *td = sipTypeFromPyTypeObject(Py_TYPE(sipPy));
  31. if (!sipIsErr)
  32. return (td == sipType_QBluetoothPermission ||
  33. td == sipType_QCalendarPermission ||
  34. td == sipType_QCameraPermission ||
  35. td == sipType_QContactsPermission ||
  36. td == sipType_QLocationPermission ||
  37. td == sipType_QMicrophonePermission);
  38. void *cpp = sipConvertToType(sipPy, td, sipTransferObj, SIP_NOT_NONE, NULL, sipIsErr);
  39. if (*sipIsErr)
  40. return 0;
  41. if (td == sipType_QBluetoothPermission)
  42. *sipCppPtr = new QPermission(*reinterpret_cast<QBluetoothPermission *>(cpp));
  43. else if (td == sipType_QCalendarPermission)
  44. *sipCppPtr = new QPermission(*reinterpret_cast<QCalendarPermission *>(cpp));
  45. else if (td == sipType_QCameraPermission)
  46. *sipCppPtr = new QPermission(*reinterpret_cast<QCameraPermission *>(cpp));
  47. else if (td == sipType_QContactsPermission)
  48. *sipCppPtr = new QPermission(*reinterpret_cast<QContactsPermission *>(cpp));
  49. else if (td == sipType_QLocationPermission)
  50. *sipCppPtr = new QPermission(*reinterpret_cast<QLocationPermission *>(cpp));
  51. else if (td == sipType_QMicrophonePermission)
  52. *sipCppPtr = new QPermission(*reinterpret_cast<QMicrophonePermission *>(cpp));
  53. return sipGetState(sipTransferObj);
  54. %End
  55. public:
  56. QPermission();
  57. Qt::PermissionStatus status() const;
  58. QMetaType type() const;
  59. SIP_PYOBJECT value() const;
  60. %MethodCode
  61. const sipTypeDef *td = SIP_NULLPTR;
  62. void *perm = SIP_NULLPTR;
  63. QMetaType mt = sipCpp->type();
  64. if (mt == QMetaType::fromType<QBluetoothPermission>())
  65. {
  66. std::optional<QBluetoothPermission> opt_perm = sipCpp->value<QBluetoothPermission>();
  67. if (opt_perm)
  68. {
  69. perm = new QBluetoothPermission(opt_perm.value());
  70. td = sipType_QBluetoothPermission;
  71. }
  72. }
  73. else if (mt == QMetaType::fromType<QCalendarPermission>())
  74. {
  75. std::optional<QCalendarPermission> opt_perm = sipCpp->value<QCalendarPermission>();
  76. if (opt_perm)
  77. {
  78. perm = new QCalendarPermission(opt_perm.value());
  79. td = sipType_QCalendarPermission;
  80. }
  81. }
  82. else if (mt == QMetaType::fromType<QCameraPermission>())
  83. {
  84. std::optional<QCameraPermission> opt_perm = sipCpp->value<QCameraPermission>();
  85. if (opt_perm)
  86. {
  87. perm = new QCameraPermission(opt_perm.value());
  88. td = sipType_QCameraPermission;
  89. }
  90. }
  91. else if (mt == QMetaType::fromType<QContactsPermission>())
  92. {
  93. std::optional<QContactsPermission> opt_perm = sipCpp->value<QContactsPermission>();
  94. if (opt_perm)
  95. {
  96. perm = new QContactsPermission(opt_perm.value());
  97. td = sipType_QContactsPermission;
  98. }
  99. }
  100. else if (mt == QMetaType::fromType<QLocationPermission>())
  101. {
  102. std::optional<QLocationPermission> opt_perm = sipCpp->value<QLocationPermission>();
  103. if (opt_perm)
  104. {
  105. perm = new QLocationPermission(opt_perm.value());
  106. td = sipType_QLocationPermission;
  107. }
  108. }
  109. else if (mt == QMetaType::fromType<QMicrophonePermission>())
  110. {
  111. std::optional<QMicrophonePermission> opt_perm = sipCpp->value<QMicrophonePermission>();
  112. if (opt_perm)
  113. {
  114. perm = new QMicrophonePermission(opt_perm.value());
  115. td = sipType_QMicrophonePermission;
  116. }
  117. }
  118. if (perm)
  119. {
  120. sipRes = sipConvertFromNewType(perm, td, SIP_NULLPTR);
  121. }
  122. else
  123. {
  124. sipRes = Py_None;
  125. Py_INCREF(sipRes);
  126. }
  127. %End
  128. };
  129. %End
  130. %End
  131. %If (Qt_6_5_0 -)
  132. %If (PyQt_Permissions)
  133. class QLocationPermission
  134. {
  135. %TypeHeaderCode
  136. #include <qpermissions.h>
  137. %End
  138. public:
  139. QLocationPermission();
  140. QLocationPermission(const QLocationPermission &other);
  141. ~QLocationPermission();
  142. enum Accuracy
  143. {
  144. Approximate,
  145. Precise,
  146. };
  147. void setAccuracy(QLocationPermission::Accuracy accuracy);
  148. QLocationPermission::Accuracy accuracy() const;
  149. enum Availability
  150. {
  151. WhenInUse,
  152. Always,
  153. };
  154. void setAvailability(QLocationPermission::Availability availability);
  155. QLocationPermission::Availability availability() const;
  156. };
  157. %End
  158. %End
  159. %If (Qt_6_5_0 -)
  160. %If (PyQt_Permissions)
  161. class QCalendarPermission
  162. {
  163. %TypeHeaderCode
  164. #include <qpermissions.h>
  165. %End
  166. public:
  167. QCalendarPermission();
  168. QCalendarPermission(const QCalendarPermission &other);
  169. ~QCalendarPermission();
  170. enum AccessMode
  171. {
  172. ReadOnly,
  173. ReadWrite,
  174. };
  175. void setAccessMode(QCalendarPermission::AccessMode mode);
  176. QCalendarPermission::AccessMode accessMode() const;
  177. };
  178. %End
  179. %End
  180. %If (Qt_6_5_0 -)
  181. %If (PyQt_Permissions)
  182. class QContactsPermission
  183. {
  184. %TypeHeaderCode
  185. #include <qpermissions.h>
  186. %End
  187. public:
  188. QContactsPermission();
  189. QContactsPermission(const QContactsPermission &other);
  190. ~QContactsPermission();
  191. enum AccessMode
  192. {
  193. ReadOnly,
  194. ReadWrite,
  195. };
  196. void setAccessMode(QContactsPermission::AccessMode mode);
  197. QContactsPermission::AccessMode accessMode() const;
  198. };
  199. %End
  200. %End
  201. %If (Qt_6_5_0 -)
  202. %If (PyQt_Permissions)
  203. class QCameraPermission
  204. {
  205. %TypeHeaderCode
  206. #include <qpermissions.h>
  207. %End
  208. public:
  209. QCameraPermission();
  210. QCameraPermission(const QCameraPermission &other);
  211. ~QCameraPermission();
  212. };
  213. %End
  214. %End
  215. %If (Qt_6_5_0 -)
  216. %If (PyQt_Permissions)
  217. class QMicrophonePermission
  218. {
  219. %TypeHeaderCode
  220. #include <qpermissions.h>
  221. %End
  222. public:
  223. QMicrophonePermission();
  224. QMicrophonePermission(const QMicrophonePermission &other);
  225. ~QMicrophonePermission();
  226. };
  227. %End
  228. %End
  229. %If (Qt_6_5_0 -)
  230. %If (PyQt_Permissions)
  231. class QBluetoothPermission
  232. {
  233. %TypeHeaderCode
  234. #include <qpermissions.h>
  235. %End
  236. public:
  237. QBluetoothPermission();
  238. QBluetoothPermission(const QBluetoothPermission &other);
  239. ~QBluetoothPermission();
  240. %If (Qt_6_6_0 -)
  241. enum CommunicationMode
  242. {
  243. Access,
  244. Advertise,
  245. Default,
  246. };
  247. %End
  248. %If (Qt_6_6_0 -)
  249. typedef QFlags<QBluetoothPermission::CommunicationMode> CommunicationModes;
  250. %End
  251. %If (Qt_6_6_0 -)
  252. void setCommunicationModes(QBluetoothPermission::CommunicationModes modes);
  253. %End
  254. %If (Qt_6_6_0 -)
  255. QBluetoothPermission::CommunicationModes communicationModes() const;
  256. %End
  257. };
  258. %End
  259. %End