Versit PluginsIntroductionWhile the Versit API provides a convenient way to import and export vCards, it is common to encounter domain-specific vCard properties that the Versit importer and exporter classes don't support. While it would be convenient if the base Versit module could support everything, that is not possible because there may be properties with the same name that have different semantics in different domains. Local Extension with HandlersTo remedy this, some hooks are provided to allow clients to alter the behaviour of QVersitContactImporter and QVersitContactExporter. The basic mechanisms that allow this are the QVersitContactImporterPropertyHandlerV2 and the QVersitContactExporterDetailHandlerV2 interfaces. A client can supplement the importer and exporter classes by implementing these interfaces and associating them using QVersitContactImporter::setPropertyHandler() and QVersitContactExporter::setDetailHandler(). Global Extension with PluginsWhile these interfaces allow a single client to supplement the behaviour of import and export, there are many cases where the entire deployment of the Versit library will be operating under a known context. For example, the library might be deployed on a device on a particular network where all of its peers are known to support certain properties. In this situation, it's desirable for all clients of the Versit library on that device to support those properties through the Versit API. It is possible to extend the library globally by installing plugins that provide handlers automatically to all users of the library on the system. Writing a plugin involves these steps:
Please see the relevant documentation in Qt for more details on writing a plugin. Example Plugin: Backup and RestoreA plugin is provided with the Qt Versit module that provides backup and restore functionality to the exporter and importer. These can be used by creating the exporter and importer under the "backup" profile: QVersitContactExporter exporter(QVersitContactHandlerFactory::ProfileBackup); QVersitContactImporter importer(QVersitContactHandlerFactory::ProfileBackup); When applied to the exporter, this handler encodes all writable details that the exporter doesn't recognise. The format it uses to encode the detail is as follows:
For example, a detail with definition name "Pet" and fields "Name"="Rex" and "Age"=(int)14 will be exported to the vCard properties: G0.X-NOKIA-QCONTACTFIELD;DETAIL=Pet;FIELD=Name:Rex G0.X-NOKIA-QCONTACTFIELD;DETAIL=Pet;FIELD=Age;DATATYPE=INT:14 And the next detail (say, "Pet" with a field "Name"="Molly" will generate: G1.X-NOKIA-QCONTACTFIELD;DETAIL=Pet;FIELD=Name:Molly When applied to the importer, this handler decodes the properties that were generated by the exporter under the backup profile. The code for this plugin can be perused in the plugins/versit/backuphandler directory. |
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Labs au hasardAméliorer les performances de Qt lors du rendu avec plus de SIMDLes Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.
CommunautéRessources
Liens utilesContact
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.2 | |
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 ! |
Copyright © 2000-2012 - www.developpez.com