Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QRemoteServiceRegister Class Reference

The QRemoteServiceRegister class manages instances of remote service objects. More...

 #include <QRemoteServiceRegister>

Inherits QObject.

Public Types

class Entry
enum InstanceType { GlobalInstance, PrivateInstance }

Properties

  • 1 property inherited from QObject

Public Functions

QRemoteServiceRegister ( QObject * parent = 0 )
~QRemoteServiceRegister ()
Entry createEntry ( const QString & serviceName, const QString & interfaceName, const QString & version )
void publishEntries ( const QString & ident )
bool quitOnLastInstanceClosed () const
void setQuitOnLastInstanceClosed ( const bool quit )
SecurityFilter setSecurityFilter ( SecurityFilter filter )
  • 29 public functions inherited from QObject

Signals

void allInstancesClosed ()
void instanceClosed ( const QRemoteServiceRegister::Entry & entry )

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QRemoteServiceRegister class manages instances of remote service objects.

This class registers and publishes IPC based service objects. It owns the service's objects and uess the platform specific IPC mechanism to publish the service.

In order for the remote services to be discoverable by QServiceManager each QRemoteServiceRegister::Entry must be registered with the same information in the XML description, otherwise no corresponding QServiceInterfaceDescriptor can be found.

The following XML descriptor is used for subsequent examples.

 <SFW version="1.1">
 <service>
     <name>MyService</name>
     <ipcaddress>my_executable</ipcaddress>
     <description>My service example</description>
     <interface>
         <name>com.nokia.qt.example.myService</name>
         <version>1.0</version>
         <description>My private service</description>
         <capabilities></capabilities>
     </interface>
 </service>
 </SFW>

The snippet belows demonstrates how an application can register the class MyClass as a remote service, which is published and accessible to clients who wish to load service object instances.

 int main(int argc, char** argv)
 {
     QCoreApplication app(argc, argv);

     QRemoteServiceRegister *serviceRegister = new QRemoteServiceRegister();

     QRemoteServiceRegister::Entry myService;
     myService = serviceRegister->createEntry<MyClass>(
         "MyService", "com.nokia.qt.example.myservice", "1.0");

     serviceRegister->publishEntries("my_service");

     return app.exec();
     delete serviceRegister;
 }

By default all entries are created as QRemoteServiceRegister::GlobalInstance types. This can be changed by calling QRemoteServiceRegister::Entry::setInstantiationType() on the entry. Once the service register has been published the associated service entries can no longer be changed.

See also QRemoteServiceRegister::Entry.

Member Type Documentation

enum QRemoteServiceRegister::InstanceType

Defines the two types of instances for a registration entry

ConstantValueDescription
QRemoteServiceRegister::GlobalInstance0New requests for a service gets the same service instance
QRemoteServiceRegister::PrivateInstance1New requests for a service gets a new service instance

Property Documentation

quitOnLastInstanceClosed : bool

This property holds terminate the service when all clients have closed all objects. Default value is true.

Access functions:

bool quitOnLastInstanceClosed () const
void setQuitOnLastInstanceClosed ( const bool quit )

Member Function Documentation

QRemoteServiceRegister::QRemoteServiceRegister ( QObject * parent = 0 )

Creates a service register instance with the given parent.

QRemoteServiceRegister::~QRemoteServiceRegister ()

Destroys the service register instance

void QRemoteServiceRegister::allInstancesClosed () [signal]

This signal is emitted whenever all service instances have been closed. This indicates that the last connected client has either shutdown or released the loaded service object.

See also instanceClosed().

Entry QRemoteServiceRegister::createEntry ( const QString & serviceName, const QString & interfaceName, const QString & version )

Creates an entry on our remote instance manager. The serviceName, interfaceName and version must match the service XML descriptor in order for the remote service to be discoverable.

See also publishEntries().

void QRemoteServiceRegister::instanceClosed ( const QRemoteServiceRegister::Entry & entry ) [signal]

This signal is emitted whenever a created instance has been closed. This indicates that a connected client has either shutdown or released the loaded service object.

entry is supplied to identify which registered service entry the closed instance belonged to.

See also allInstancesClosed().

void QRemoteServiceRegister::publishEntries ( const QString & ident )

Publishes every service QRemoteServiceRegister::Entry that has been created using createEntry(). The ident is the service specific IPC address under which the service can be reached.

This address must match the address provided in the services XML descriptor, otherwise the service will not be discoverable. In some cases this may also cause the IPC rendezvous feature to fail.

See also createEntry().

SecurityFilter QRemoteServiceRegister::setSecurityFilter ( SecurityFilter filter )

Allows a security filter to be set which can access QRemoteServiceRegister::QRemoteServiceRegisterCredentials.

The filter is a function pointer where the function code implements possible permission checks and returns true or false. If a connecting client fails the security filter it will be denied access and unable to obtain a valid service instance.

The following snippet is an example of how to use the security filter feature.

 bool myFunction(const void *p)
 {
     const QRemoteServiceRegisterCredentials *cred =
         (const struct QRemoteServiceRegisterCredentials *)p;

     // allow the superuser
     if (cred->uid == 0)
         return true;

     return false;
 }

 int main(int argc, char** argv)
 {
     ...

     QRemoteServiceRegister* serviceRegister = new QRemoteServiceRegister();
     service->setSecurityFilter(myFunction);

     ...
 }
X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Implémenter un mutex en lecture et en écriture

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.1
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web