<div dir="ltr"><div dir="ltr"><p>I'm trying to use PyQt5's DBus module to interact with the KDE 
PowerManagerAgent on a linux system. When calling the AddInhibition method I need to send 
the first paramter as an uint32 (Unsigned int), but the code sends the 
value as a singed int. </p>

<p>The code is written using Python 3 and using Pyqt5<br></p>

<pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln">class PowerChangeInhibitor:<br>    def __init__(self):<br>        self.dBusService = 'org.kde.Solid.PowerManagement.PolicyAgent'<br>        self.dBusPath = '/org/kde/Solid/PowerManagement/PolicyAgent'<br>        self.dBusInterface = 'org.kde.Solid.PowerManagement.PolicyAgent'<br>        self.cookies = []<br>        <br>    def ActivateInhibition(self, interruptSession, changeProfile, changeScreenSettings,who, reason):<br><br>        <br>        self.dBus = QtDBus.QDBusConnection.sessionBus()<br>        if interruptSession:<br>            #dBusInterface = QtDBus.QDBusInterface(self.dBusService, self.dBusPath,'' , self.dBus) <br>            #reply = dBusInterface.call('AddInhibition',1,who,reason)<br>            <br>            msg = QtDBus.QDBusMessage.createMethodCall(self.dBusService, self.dBusPath,self.dBusInterface,'AddInhibition')<br> <br>            <code><span class="gmail-pln">#unsignedValue = 1                                                   # writes 1 but typed as int32<br>            </span></code>#unsignedValue = ctypes.c_uint(1)                                    # Type not registered <br>            #unsignedValue = struct.unpack_from("I", struct.pack("i", 1))        # Type not registered<br>            #unsignedValue = QtCore.QByteArray(b'0x01')[0]                       # Type not registered <br>            #unsignedValue =  bytes(1)                                           # Type not registered<br>            #unsignedValue = QtDBus.QDBusVariant(1)                              # array of bytes "0x01"<br>            #unsignedValue = QtDBus.QDBusVariant(1)[0]                           # QDBusVariant does not support indexing<br>            #unsignedValue = QtDBus.QDBusVariant().setVariant(ctypes.c_uint(1))  # Variant contained QVariantInvalid<br>            unsignedValue =  QtDBus.QDBusVariant(ctypes.c_uint(1))                # Type not registered<br><br>            msg << <b>unsignedValue</b> << who << reason<br>            reply = QtDBus.QDBusReply(self.dBus.call(msg))<br>            if reply.isValid():<br>                self.cookies.append(reply.value())<br><br>  </span></code></pre><pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln"><font face="arial,helvetica,sans-serif">I have commented out previous attempts with their results on the right. Using dbus-monitor I can see that the part where i'm struggeling is getting QDBusInterface to emit the desired UNIT32 type info.<br><br></font></span></code></pre><pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln"><font face="arial,helvetica,sans-serif">Any pointers on how I pass an unsigned int as an argument to my QDBusMessage ?<br><br></font></span></code></pre><pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln"><font face="arial,helvetica,sans-serif">Thanks in advance<br></font></span></code></pre><pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pun"></span></code></pre></div></div>