Sophie

Sophie

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

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" />
<!-- bluetoothtransferplugin.qdoc -->
  <title>Qt Mobility 1.2: Bluetooth Transfer Plugin Example</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><a href="http://qt.nokia.com/doc/4.7/all-examples.html">Examples</a></li>
<li>Bluetooth Transfer Plugin Example</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#registering-the-service">Registering the Service</a></li>
<li class="level1"><a href="#writing-the-plugin">Writing the Plugin</a></li>
</ul>
</div>
<h1 class="title">Bluetooth Transfer Plugin Example</h1>
<span class="subtitle"></span>
<!-- $$$bluetoothtransferplugin-description -->
<div class="descr"> <a name="details"></a>
<p>Files:</p>
<ul>
<li><a href="bluetoothtransferplugin-bluetoothtransfer-cpp.html">bluetoothtransferplugin/bluetoothtransfer.cpp</a></li>
<li><a href="bluetoothtransferplugin-bluetoothtransfer-h.html">bluetoothtransferplugin/bluetoothtransfer.h</a></li>
<li><a href="bluetoothtransferplugin-bluetoothtransferplugin-cpp.html">bluetoothtransferplugin/bluetoothtransferplugin.cpp</a></li>
<li><a href="bluetoothtransferplugin-bluetoothtransferplugin-h.html">bluetoothtransferplugin/bluetoothtransferplugin.h</a></li>
<li><a href="bluetoothtransferplugin-bluetoothtransferservice-xml.html">bluetoothtransferplugin/bluetoothtransferservice.xml</a></li>
<li><a href="bluetoothtransferplugin-bluetoothtransferplugin-pro.html">bluetoothtransferplugin/bluetoothtransferplugin.pro</a></li>
</ul>
<p>This example shows how to write a service plugin for the <a href="service-frameworks.html">Service Framework</a>.</p>
<a name="registering-the-service"></a>
<h2>Registering the Service</h2>
<p>The service can be registered by using the function <a href="qservicemanager.html#addService">addService()</a>, this takes a path to the XML file that describes the service, <i>bluetoothtransferservice.xml</i>.</p>
<a name="writing-the-plugin"></a>
<h2>Writing the Plugin</h2>
<p>To implement a plugin it is necessary to create a new plugin class derived from <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> and <a href="qserviceplugininterface.html">QServicePluginInterface</a>. The function <a href="qserviceplugininterface.html#createInstance">QServicePluginInterface::createInstance</a>() is implemented to return the appropriate instantiated object based on the interface name passed into the function. Since there is only one interface name for this example there is no test involved, so we can simply create the object implementing the service and return its pointer.</p>
<pre class="cpp"> <span class="keyword">return</span> <span class="keyword">new</span> BluetoothTransfer(<span class="keyword">this</span>);</pre>
<p>The implementation of the service BluetoothTransfer is simply a test function for this example. The BluetoothTransfer class is very simple, with only an empty constructor and the sendFile() function</p>
<pre class="cpp"> <span class="type">void</span> BluetoothTransfer<span class="operator">::</span>sendFile(<span class="keyword">const</span> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstring.html">QString</a></span> <span class="operator">&amp;</span>path)
 {
     <a href="http://qt.nokia.com/doc/4.7/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;BluetoothTransfer::sendFile()&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> path;
 }</pre>
</div>
<!-- @@@bluetoothtransferplugin -->
  <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>