title: Get sender PID from DBUS
body: <p>I have spent four hours in deep searching :), but didn't find: How to get PID from DBUS sender under Qt.</p>
  
  <p>From other dbus libs it's quite simple:</p>
  
  <blockquote>
    <p>Call dbus_message_get_sender to get the caller's D-Bus id, and then call    GetConnectionUnixProcessID to get the pid of the process that sent the message.  </p>
  </blockquote>
  
  <p>How to do it from Qt ?
  I have try to use this code, but it's returns my PID not a client application.</p>
  
  <pre><code>class ServerAdaptor: public QDBusAbstractAdaptor
  {
  public Q_SLOTS:
  
   // this method shared through the D-BUS and called from different application (client)
   bool Show(const QString &amp;in0)
   { 
      QDBusConnection connection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "org.freedesktop.DBus");
  
      if( connection.isConnected() )
      {
         qDebug() &lt;&lt; "Sender PID " &lt;&lt; connection.interface()-&gt;servicePid(  QDBusConnection::sender().baseService() ).value();
      }
  
   }
  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>How to get PID from remote application through D-BUS (Qt)</p>
  
  <pre><code>// this class receive D-BUS methods
  class Server: public QObject, protected QDBusContext {
  
  public slots:
  
      bool SomeMethod( const QString &amp;name ) 
      {
       qDebug() &lt;&lt; "PID is: " &lt;&lt; connection().interface()-&gt;servicePid( message().service() ); 
      }
  </code></pre>
  
  <p>}</p>