Detailed Description
The QtopiaAbstractService class provides an interface to messages on a QCop service which simplifies remote slot invocations
Service messages in Qt Extended are sent with QtopiaServiceRequest. They consist of a service name, a message name, and a list of parameter values. Qt Extended dispatches service messages to the applications associated with the service name, on the application's QPE/Application/appname channel, where appname is the application's name.
Client applications can listen for service messages on the application channel directly, using QtopiaChannel, but it is cleaner and less error-prone to create an instance of QtopiaAbstractService instead.
The use of QtopiaAbstractService will be demonstrated using the Time service. This has a single message called editTime() which asks the service to pop up a dialog allowing the user to edit the current time.
class TimeService : public QtopiaAbstractService
{
Q_OBJECT
public:
TimeService( QObject *parent = 0 );
public slots:
void editTime();
};
TimeService::TimeService( QObject *parent )
: QtopiaAbstractService( "Time", parent )
{
publishAll();
}
The call to publishAll() causes all public slots within TimeService to be automatically registered as Service messages. This can be useful if the service has many message types.
The client can send a request to the service using QtopiaServiceRequest:
QtopiaServiceRequest req( "Time", "editTime()" );
req.send();
See also QtopiaService, QtopiaIpcAdaptor, QtopiaIpcEnvelope, QtopiaServiceRequest, and QtopiaChannel.
Member Function Documentation
QtopiaAbstractService::QtopiaAbstractService ( const QString & service, QObject * parent = 0 )
Construct a remote service object for service and attach it to parent.
QtopiaAbstractService::~QtopiaAbstractService ()
Destroy this QCop service handling object.
void QtopiaAbstractService::publishAll () [protected]
Publishes all slots on this object within subclasses of QtopiaAbstractService. This is typically called from a subclass constructor.