Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
Files:
The server task tutorial deomonstrates how to develop server task plugins. Server task plugins allow to dynamically extend the Qt Extended server even after the deployment process.
Each server task plugin must inherit from ServerTaskPlugin. It describes the various attributes of the task. During its startup phase the server loads all plugins which inherit from ServerTaskPlugin. Once it is time to actually start the server task provided by the plugin ServerTaskPlugin::initTask() is called which returns a reference to the new task object.
#include <ServerTaskPlugin> class ExampleTaskPlugin : public ServerTaskPlugin { Q_OBJECT public: ExampleTaskPlugin( QObject* parent = 0 ); virtual ~ExampleTaskPlugin(); //name of task QByteArray name() const; //initialises task QObject* initTask( void* createArg = 0 ) const; //returns true if started in demand bool demand() const; };
The implementation of the plugin class may look like this:
ExampleTaskPlugin::ExampleTaskPlugin(QObject* parent) : ServerTaskPlugin( parent ) { } ExampleTaskPlugin::~ExampleTaskPlugin() { } QByteArray ExampleTaskPlugin::name() const { return QByteArray("ExampleTask"); } QObject* ExampleTaskPlugin::initTask(void* createArg ) const { Q_UNUSED( createArg ); return new ExampleTask(); } bool ExampleTaskPlugin::demand() const { return true; } QTOPIA_EXPORT_PLUGIN( ExampleTaskPlugin )
function | description |
---|---|
ServerTaskPlugin() | The constructor is called immediately after startup of the server in order to identify all available server task plugins. |
ServerTaskPlugin::initTask() | Initialises/starts the task. |
ServerTaskPlugin::name() | This function returns the name of the task. This name may be used in conjunction with Task.cfg or QtopiaServerApplication::qtopiaTask(). |
ServerTaskPlugin::demand() | If this function returns false this task will be started automatically unless otherwise specified byTask.cfg. If this function returns true this task is only started if another server task explicitly requests a reference to it. |
The subsequent example task implementation does nothing and is only provided for the sake of completeness:
#include "exampletask.h"
#include <qtopiaglobal.h>
#include <QDebug>
class ExampleTask: public QObject
{
public:
ExampleTask( QObject* parent = 0 ) : QObject(parent)
{
//server task code
}
~ExampleTask()
{
}
};
Due to the fact that server task plugins don't have access to symbols in the server and vice versa some limitations apply:
Copyright © 2009 Nokia | Trademarks | Qt Extended 4.4.3 |