Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 1943

qt-mobility-doc-1.2.0-13.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- versitplugins.qdoc -->
  <title>Qt Mobility 1.2: Versit Plugins</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li>Versit Plugins</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#introduction">Introduction</a></li>
<li class="level1"><a href="#local-extension-with-handlers">Local Extension with Handlers</a></li>
<li class="level1"><a href="#global-extension-with-plugins">Global Extension with Plugins</a></li>
<li class="level2"><a href="#example-plugin-backup-and-restore">Example Plugin: Backup and Restore</a></li>
</ul>
</div>
<h1 class="title">Versit Plugins</h1>
<span class="subtitle"></span>
<!-- $$$versitplugins.html-description -->
<div class="descr"> <a name="details"></a>
<a name="introduction"></a>
<h2>Introduction</h2>
<p>While the <a href="versit.html">Versit API</a> 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.</p>
<a name="local-extension-with-handlers"></a>
<h2>Local Extension with Handlers</h2>
<p>To remedy this, some hooks are provided to allow clients to alter the behaviour of <a href="qversitcontactimporter.html">QVersitContactImporter</a> and <a href="qversitcontactexporter.html">QVersitContactExporter</a>. The basic mechanisms that allow this are the <a href="qversitcontactimporterpropertyhandlerv2.html">QVersitContactImporterPropertyHandlerV2</a> and the <a href="qversitcontactexporterdetailhandlerv2.html">QVersitContactExporterDetailHandlerV2</a> interfaces. A client can supplement the importer and exporter classes by implementing these interfaces and associating them using <a href="qversitcontactimporter.html#setPropertyHandler">QVersitContactImporter::setPropertyHandler</a>() and <a href="qversitcontactexporter.html#setDetailHandler">QVersitContactExporter::setDetailHandler</a>().</p>
<a name="global-extension-with-plugins"></a>
<h2>Global Extension with Plugins</h2>
<p>While 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.</p>
<p>Writing a plugin involves these steps:</p>
<ul>
<li>Implement a handler class that inherits from <a href="qversitcontacthandler.html">QVersitContactHandler</a>.</li>
<li>Implement a plugin class that inherits from <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> and <a href="qversitcontacthandlerfactory.html">QVersitContactHandlerFactory</a> and implements the createHandler() function to create the handler class.</li>
<li>Include the following two lines at the top of the factory declaration:<pre class="cpp"> Q_OBJECT
 <a href="http://qt.nokia.com/doc/4.7/qobject.html#Q_INTERFACES">Q_INTERFACES</a>(<span class="type">QtMobility</span><span class="operator">::</span><span class="type"><a href="qversitcontacthandlerfactory.html">QVersitContactHandlerFactory</a></span>)</pre>
</li>
<li>Export the plugin using the Q_EXPORT_PLUGIN2 macro.</li>
<li>Build the plugin using a suitable <tt>.pro</tt> file.</li>
<li>Deploy the plugin in the <tt>plugins/versit</tt> directory.</li>
</ul>
<p>Please see the relevant documentation in Qt for more details on writing a plugin.</p>
<a name="example-plugin-backup-and-restore"></a>
<h3>Example Plugin: Backup and Restore</h3>
<p>A plugin is provided with the Qt Versit module that provides backup and restore functionality to the exporter and importer.</p>
<p>These can be used by creating the exporter and importer under the &quot;backup&quot; profile:</p>
<pre class="cpp"> <span class="type"><a href="qversitcontactexporter.html">QVersitContactExporter</a></span> exporter(<span class="type"><a href="qversitcontacthandlerfactory.html">QVersitContactHandlerFactory</a></span><span class="operator">::</span>ProfileBackup);</pre>
<pre class="cpp"> <span class="type"><a href="qversitcontactimporter.html">QVersitContactImporter</a></span> importer(<span class="type"><a href="qversitcontacthandlerfactory.html">QVersitContactHandlerFactory</a></span><span class="operator">::</span>ProfileBackup);</pre>
<p>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:</p>
<ul>
<li>All generated properties will have the name X-NOKIA-QCONTACTFIELD</li>
<li>All generated properties will have a single Versit group, and all properties generated from a single detail will have the same group.</li>
<li>All generated properties will have at least the parameters DETAIL, which holds the definition name of the <a href="qcontactdetail.html">QContactDetail</a> from which it was generated, and FIELD, which holds the name of the field within the detail from which it was generated.</li>
<li>If the field is of type <a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a> or <a href="http://qt.nokia.com/doc/4.7/qbytearray.html">QByteArray</a>, the property's value is set directly to the value of the field. (For a <a href="http://qt.nokia.com/doc/4.7/qbytearray.html">QByteArray</a> value, the <a href="qversitwriter.html">QVersitWriter</a> will base-64 encode it.)</li>
<li>If the field is of type bool, int, uint, <a href="http://qt.nokia.com/doc/4.7/qdate.html">QDate</a>, <a href="http://qt.nokia.com/doc/4.7/qtime.html">QTime</a>, <a href="http://qt.nokia.com/doc/4.7/qdatetime.html">QDateTime</a> or <a href="http://qt.nokia.com/doc/4.7/qurl.html">QUrl</a> a the property's value is set to a string representation of the field. A parameter DATATYPE is added to the property with value BOOL, INT, UINT, DATE, TIME or DATETIME depending on the type.</li>
<li>If the field is of some other type, the field value is encoded to a <a href="http://qt.nokia.com/doc/4.7/qbytearray.html">QByteArray</a> via <a href="http://qt.nokia.com/doc/4.7/qdatastream.html">QDataStream</a> (and the resulting byte array is base-64 encoded by the <a href="qversitwriter.html">QVersitWriter</a>). In this case, the parameter DATATYPE=VARIANT is added to the Versit property.</li>
</ul>
<p>For example, a detail with definition name &quot;Pet&quot; and fields &quot;Name&quot;=&quot;Rex&quot; and &quot;Age&quot;=(int)14 will be exported to the vCard properties:</p>
<pre class="cpp"> G0<span class="operator">.</span>X<span class="operator">-</span>NOKIA<span class="operator">-</span>QCONTACTFIELD;DETAIL<span class="operator">=</span>Pet;FIELD<span class="operator">=</span>Name:Rex
 G0<span class="operator">.</span>X<span class="operator">-</span>NOKIA<span class="operator">-</span>QCONTACTFIELD;DETAIL<span class="operator">=</span>Pet;FIELD<span class="operator">=</span>Age;DATATYPE<span class="operator">=</span>INT:<span class="number">14</span></pre>
<p>And the next detail (say, &quot;Pet&quot; with a field &quot;Name&quot;=&quot;Molly&quot; will generate:</p>
<pre class="cpp"> G1<span class="operator">.</span>X<span class="operator">-</span>NOKIA<span class="operator">-</span>QCONTACTFIELD;DETAIL<span class="operator">=</span>Pet;FIELD<span class="operator">=</span>Name:Molly</pre>
<p>When applied to the importer, this handler decodes the properties that were generated by the exporter under the backup profile.</p>
<p>The code for this plugin can be perused in the <tt>plugins/versit/backuphandler</tt> directory.</p>
</div>
<!-- @@@versitplugins.html -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU
    Free Documentation License version 1.3</a>
    as published by the Free Software Foundation.</p>
</div>
</body>
</html>