QDBusAbstractInterface Class Reference

[ QtDBus module]

The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding, allowing access to remote interfaces 更多...

继承 QObject .

Inherited by QDBusConnectionInterface and QDBusInterface .

方法


详细描述

The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding, allowing access to remote interfaces

Generated-code classes also derive from QDBusAbstractInterface, all methods described here are also valid for generated-code classes. In addition to those described here, generated-code classes provide member functions for the remote methods, which allow for compile-time checking of the correct parameters and return values, as well as property type-matching and signal parameter-matching.


方法文档编制

QDBusAbstractInterface.__init__ ( self , QString  service , QString  path , str  interface , QDBusConnection   connection , QObject   parent )

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

QDBusPendingCall QDBusAbstractInterface.asyncCall ( self , QString  方法 , QVariant  arg1  = QVariant(), QVariant  arg2  = QVariant(), QVariant  arg3  = QVariant(), QVariant  arg4  = QVariant(), QVariant  arg5  = QVariant(), QVariant  arg6  = QVariant(), QVariant  arg7  = QVariant(), QVariant  arg8  = QVariant())

Calls the method 方法 on this interface and passes the parameters to this function to the method.

The parameters to call are passed on to the remote function via D-Bus as input arguments. The returned QDBusPendingCall object can be used to find out information about the reply.

This function can be used with up to 8 parameters, passed in arguments arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 and arg8 . If you need more than 8 parameters or if you have a variable number of parameters to be passed, use asyncCallWithArgumentList ().

It can be used the following way:

 QString value = retrieveValue();
 QDBusPendingCall pcall = interface->asyncCall(QLatin1String("Process"), value);
 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
 QObject.connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
                  this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
			

This example illustrates function calling with 0, 1 and 2 parameters and illustrates different parameter types passed in each (the first call to "ProcessWorkUnicode" will contain one Unicode string, the second call to "ProcessWork" will contain one string and one byte array).

该函数在 Qt 4.5 引入。

QDBusPendingCall QDBusAbstractInterface.asyncCallWithArgumentList ( self , QString  方法 , list-of-QVariant  args )

Places a call to the remote method specified by 方法 on this interface, using args as arguments. This function 返回 QDBusPendingCall object that can be used to track the status of the reply and access its contents once it has arrived.

Normally, you should place calls using asyncCall ().

注意: 此函数是 thread-safe .

该函数在 Qt 4.5 引入。

QDBusMessage QDBusAbstractInterface.call ( self , QString  方法 , QVariant  arg1  = QVariant(), QVariant  arg2  = QVariant(), QVariant  arg3  = QVariant(), QVariant  arg4  = QVariant(), QVariant  arg5  = QVariant(), QVariant  arg6  = QVariant(), QVariant  arg7  = QVariant(), QVariant  arg8  = QVariant())

Calls the method 方法 on this interface and passes the parameters to this function to the method.

The parameters to call are passed on to the remote function via D-Bus as input arguments. Output arguments are returned in the QDBusMessage reply. If the reply is an error reply, lastError () will also be set to the contents of the error message.

This function can be used with up to 8 parameters, passed in arguments arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 and arg8 . If you need more than 8 parameters or if you have a variable number of parameters to be passed, use callWithArgumentList ().

It can be used the following way:

 QString value = retrieveValue();
 QDBusMessage reply;
 QDBusReply<int> api = interface->call(QLatin1String("GetAPIVersion"));
 if (api >= 14)
   reply = interface->call(QLatin1String("ProcessWorkUnicode"), value);
 else
   reply = interface->call(QLatin1String("ProcessWork"), QLatin1String("UTF-8"), value.toUtf8());
			

This example illustrates function calling with 0, 1 and 2 parameters and illustrates different parameter types passed in each (the first call to "ProcessWorkUnicode" will contain one Unicode string, the second call to "ProcessWork" will contain one string and one byte array).

QDBusMessage QDBusAbstractInterface.call ( self , QDBus.CallMode   mode , QString  方法 , QVariant  arg1  = QVariant(), QVariant  arg2  = QVariant(), QVariant  arg3  = QVariant(), QVariant  arg4  = QVariant(), QVariant  arg5  = QVariant(), QVariant  arg6  = QVariant(), QVariant  arg7  = QVariant(), QVariant  arg8  = QVariant())

这是重载函数。

Calls the method 方法 on this interface and passes the parameters to this function to the method. If mode is NoWaitForReply , then this function will return immediately after placing the call, without waiting for a reply from the remote method. Otherwise, mode indicates whether this function should activate the Qt Event Loop while waiting for the reply to arrive.

This function can be used with up to 8 parameters, passed in arguments arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 and arg8 . If you need more than 8 parameters or if you have a variable number of parameters to be passed, use callWithArgumentList ().

If this function reenters the Qt event loop in order to wait for the reply, it will exclude user input. During the wait, it may deliver signals and other method calls to your application. Therefore, it must be prepared to handle a reentrancy whenever a call is placed with call ().

QDBusMessage QDBusAbstractInterface.callWithArgumentList ( self , QDBus.CallMode   mode , QString  方法 , list-of-QVariant  args )

Places a call to the remote method specified by 方法 on this interface, using args as arguments. This function returns the message that was received as a reply, which can be a normal QDBusMessage.ReplyMessage (indicating success) or QDBusMessage.ErrorMessage (if the call failed). The mode parameter specifies how this call should be placed.

If the call succeeds, lastError () will be cleared; otherwise, it will contain the error this call produced.

Normally, you should place calls using call ().

警告: 若使用 UseEventLoop , your code must be prepared to deal with any reentrancy: other method calls and signals may be delivered before this function returns, as well as other Qt queued signals and events.

注意: 此函数是 thread-safe .

bool QDBusAbstractInterface.callWithCallback ( self , QString  方法 , list-of-QVariant  args , QObject   receiver , SLOT()  returnMethod , SLOT()  errorMethod )

Places a call to the remote method specified by 方法 on this interface, using args as arguments. This function returns immediately after queueing the call. The reply from the remote function is delivered to the returnMethod on object receiver . If an error occurs, the errorMethod on object receiver is called instead.

This function returns true if the queueing succeeds. It does not indicate that the executed call succeeded. If it fails, the errorMethod is called. If the queueing failed, this function returns false and no slot will be called.

returnMethod must have as its parameters the types returned by the function call. Optionally, it may have a QDBusMessage parameter as its last or only parameter. The errorMethod must have a QDBusError as its only parameter.

该函数在 Qt 4.3 引入。

另请参阅 QDBusError and QDBusMessage .

object QDBusAbstractInterface.callWithCallback ( self , QString  方法 , list-of-QVariant  args , callable  returnMethod , callable  errorMethod )

这是重载函数。

This function is deprecated. Please use the overloaded version.

Places a call to the remote method specified by 方法 on this interface, using args as arguments. This function returns immediately after queueing the call. The reply from the remote function or any errors emitted by it are delivered to the slot slot on object receiver .

This function returns true if the queueing succeeded: it does not indicate that the call succeeded. If it failed, the slot will be called with an error message. lastError () will not be set under those circumstances.

另请参阅 QDBusError and QDBusMessage .

bool QDBusAbstractInterface.callWithCallback ( self , QString  方法 , list-of-QVariant  args , QObject   receiver , SLOT()  slot )

object QDBusAbstractInterface.callWithCallback ( self , QString  方法 , list-of-QVariant  args , callable  slot )

QDBusConnection QDBusAbstractInterface.connection ( self )

Returns the connection this interface is assocated with.

QDBusAbstractInterface.connectNotify ( self , SIGNAL()  signal )

QDBusAbstractInterface.disconnectNotify ( self , SIGNAL()  signal )

QString QDBusAbstractInterface.interface ( self )

Returns the name of this interface.

bool QDBusAbstractInterface.isValid ( self )

Returns true if this is a valid reference to a remote object. It returns false if there was an error during the creation of this interface (for instance, if the remote application does not exist).

Note: when dealing with remote objects, it is not always possible to determine if it exists when creating a QDBusInterface .

QDBusError QDBusAbstractInterface.lastError ( self )

Returns the error the last operation produced, or an invalid error if the last operation did not produce an error.

QString QDBusAbstractInterface.path ( self )

QString QDBusAbstractInterface.service ( self )

Returns the name of the service this interface is associated with.

QDBusAbstractInterface.setTimeout ( self , int  timeout )

Sets the timeout in milliseconds for all future DBus calls to timeout . -1 means the default DBus timeout (usually 25 seconds).

该函数在 Qt 4.8 引入。

另请参阅 timeout ().

int QDBusAbstractInterface.timeout ( self )

Returns the current value of the timeout in milliseconds. -1 means the default DBus timeout (usually 25 seconds).

该函数在 Qt 4.8 引入。

另请参阅 setTimeout ().