/usr/share/qt5/doc/qtcontacts/contactsactions.html is in qtpim5-doc-html 5.0~git20140515~29475884-0ubuntu24~7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- contactsactions.qdoc -->
<title>Qt Contacts Action API | Qt 5.0</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
// loading style sheet breaks anchors that were jumped to before
// so force jumping to anchor again
setTimeout(function() {
var anchor = location.hash;
// need to jump to different anchor first (e.g. none)
location.hash = "#";
setTimeout(function() {
location.hash = anchor;
}, 0);
}, 0);
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.0</td><td >Qt Contacts Action API</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.0.0 Reference Documentation</td>
</tr></table>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#invoking-actions-upon-targets">Invoking Actions upon Targets</a></li>
<li class="level1"><a href="#implementing-actions">Implementing Actions</a></li>
<li class="level2"><a href="#other-considerations">Other Considerations</a></li>
<li class="level2"><a href="#example-implementation">Example Implementation</a></li>
<li class="level2"><a href="#deploying-services">Deploying Services</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Contacts Action API</h1>
<span class="subtitle"></span>
<!-- $$$contactsactions.html-description -->
<div class="descr"> <a name="details"></a>
<p>The Qt Contacts API supports the concept of a generic action which may be invoked upon an <a href="qcontactactiontarget.html">action target</a> (e.g., a contact) or list thereof. The API allows clients to invoke an action upon a target (for example, to send an email to a contact) in a cross-platform manner, and allows third-party developers to provide platform-specific action plugins which may be used by clients.</p>
<a name="invoking-actions-upon-targets"></a>
<h2 id="invoking-actions-upon-targets">Invoking Actions upon Targets</h2>
<p>The client interface to actions consists of three classes: <a href="qcontactaction.html">QContactAction</a>, <a href="qcontactactiontarget.html">QContactActionTarget</a> and <a href="qcontactactiondescriptor.html">QContactActionDescriptor</a>. A <a href="qcontactactiondescriptor.html">descriptor</a> uniquely identifies a particular implementation of an <a href="qcontactaction.html">action</a>, and allows the client to query meta-data about the action. An <a href="qcontactactiontarget.html">action target</a> consists of either a contact, a detail of a contact, or a list of details of a contact.</p>
<p>The available actions may be queried by calling <a href="qcontactaction.html#availableActions">QContactAction::availableActions</a>(). This function returns the list of names of actions which are provided by the given service name, or by any service if the parameter is omitted.</p>
<p>There may be multiple implementations of any given action identified by a particular action name, since multiple third-party action providers could provide (for example) a "call" action, using various proprietary protocols and techologies. Once the client knows which action they wish to perform on a contact, they can retrieve the list of action descriptors for that action by calling <a href="qcontactaction.html#actionDescriptors">QContactAction::actionDescriptors</a>() which takes the action name as a parameter.</p>
<p>Note that there are several predefined action names including <a href="qcontactaction.html#ActionCall">QContactAction::ActionCall</a>, <a href="qcontactaction.html#ActionEmail">QContactAction::ActionEmail</a>, <a href="qcontactaction.html#ActionSms">QContactAction::ActionSms</a> etc, however there is no guarantee that all of these actions are implemented on any given platform.</p>
<p>Finally, once the client has selected a particular implementation of the action, by inspecting the action descriptor (from which they can retrieve meta-data and check that it supports the contact that they wish to perform the action on), the client may request a pointer to the action implementation by calling <a href="qcontactaction.html#action">QContactAction::action</a>() and passing the action descriptor as a parameter. Note that the client takes ownership of the returned <a href="qcontactaction.html">QContactAction</a> pointer and must delete it to avoid leaking memory. The caller is able to delete the action at any time, however doing so prior to when the action transitions to a finished state may have an undefined outcome depending on the implementation of the action.</p>
<a name="implementing-actions"></a>
<h2 id="implementing-actions">Implementing Actions</h2>
<p>If you are a third-party developer who wants to provide an action for other clients to use, you must do four things:</p>
<ul>
<li>Implement a QServicePluginInterface-derived class</li>
<li>Implement a <a href="qcontactactionfactory.html">QContactActionFactory</a>-derived class</li>
<li>Implement (one or more) <a href="qcontactaction.html">QContactAction</a>-derived classes</li>
<li>Write an XML file which describes your service plugin</li>
</ul>
<p>For more information on the QServicePluginInterface and the format of the service description XML, see the Qt Service Framework documentation. An example action plugin is provided later in this document.</p>
<p><b>Note: </b>While the plugins are loaded by the Qt Service Framework, clients of the Qt Contacts Action API are entirely shielded from this implementation detail.</p><p>The <a href="qcontactactiondescriptor.html">QContactActionDescriptor</a> class is actually a client-facing interface to an action factory, which allows the factory to provide meta-data and other implementation-specific information to clients on demand.</p>
<a name="other-considerations"></a>
<h3 >Other Considerations</h3>
<p>We recommend that action implementors provide values for the default meta-data keys (including icons and labels) documented in <a href="qcontactactiondescriptor.html">QContactActionDescriptor</a>, to allow client applications to provide meaningful user interface elements to represent the action.</p>
<p>We recommend that action implementors read the documentation of the Qt Service Framework carefully, to better understand how their implementation plugin may be updated with patch releases or major releases, and how these considerations affect the implementation of the plugin.</p>
<a name="example-implementation"></a>
<h3 >Example Implementation</h3>
<p>The following snippet provides an example of an action plugin. As previously described, the action plugin consists of a QServicePluginInterface, a <a href="qcontactactionfactory.html">QContactActionFactory</a>, and one or more <a href="qcontactaction.html">QContactAction</a> derived classes. The QServicePluginInterface-derived class merely instantiates the <a href="qcontactactionfactory.html">QContactActionFactory</a>-derived class on request for the Qt Service Framework. The <a href="qcontactactionfactory.html">QContactActionFactory</a>-derived class then instantiates the actions when required.</p>
<pre class="cpp">
<span class="comment">/*
This action plugin is capable of producing two actions which each have the
same action name, service name, interface name and implementation (minor) version,
but internally use a different implementation. This difference is reported via the
meta data function of the factory (which is exposed to clients via the descriptor
which provides a "front end" to the factory).
Example use case:
Company "Example VoIP Solutions" wants to provide a "Call" action with different implementations.
-> it provides a SINGLE plugin which provides two actions, both of which are:
- ServiceName = "Example VoIP Solution"
- InterfaceName = "org.qt-project.Qt.SampleContactsActionPlugin" (QContactActionFactory::InterfaceName)
- Major Version = "1"
- Minor Version = "1"
- ActionName = "call" (this is a custom property in the service interface xml)
-> BUT one of the actions has the custom property:
- Provider = "sip"
-> where the other action has the custom property:
- Provider = "example proprietary protocol"
-> the custom properties are available to clients via the QContactActionDescriptor::metaData() function.
*/</span>
<span class="keyword">class</span> <span class="type">QContactMultiActionPlugin</span> : <span class="keyword">public</span> <span class="type">QObject</span><span class="operator">,</span> <span class="keyword">public</span> <span class="type">QServicePluginInterface</span>
{
Q_OBJECT
Q_INTERFACES(<span class="type">QtMobility</span><span class="operator">::</span><span class="type">QServicePluginInterface</span>)
<span class="keyword">public</span>:
<span class="type">QObject</span><span class="operator">*</span> createInstance(<span class="keyword">const</span> <span class="type">QServiceInterfaceDescriptor</span><span class="operator">&</span> descriptor<span class="operator">,</span>
<span class="type">QServiceContext</span><span class="operator">*</span> context<span class="operator">,</span>
<span class="type">QAbstractSecuritySession</span><span class="operator">*</span> session);
};
<span class="keyword">class</span> <span class="type">QContactMultiActionFactory</span> : <span class="keyword">public</span> <span class="type"><a href="qcontactactionfactory.html">QContactActionFactory</a></span>
{
Q_OBJECT
<span class="keyword">public</span>:
<span class="type">QContactMultiActionFactory</span>();
<span class="operator">~</span><span class="type">QContactMultiActionFactory</span>();
<span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">></span> actionDescriptors() <span class="keyword">const</span>;
<span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">*</span> create(<span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>;
<span class="type">QSet</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span> supportedTargets(<span class="keyword">const</span> <span class="type"><a href="qcontact.html">QContact</a></span><span class="operator">&</span> contact<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>;
<span class="type"><a href="qcontactfilter.html">QContactFilter</a></span> contactFilter(<span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>;
<span class="type">QVariant</span> metaData(<span class="keyword">const</span> <span class="type">QString</span><span class="operator">&</span> key<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span><span class="operator">&</span> targets<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> parameters<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>;
bool supportsContact(<span class="keyword">const</span> <span class="type"><a href="qcontact.html">QContact</a></span><span class="operator">&</span> contact<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>;
<span class="keyword">private</span>:
<span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span> m_actionOneDescriptor;
<span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span> m_actionTwoDescriptor;
};
<span class="keyword">class</span> <span class="type">QContactActionOne</span> : <span class="keyword">public</span> <span class="type"><a href="qcontactaction.html">QContactAction</a></span>
{
Q_OBJECT
<span class="keyword">public</span>:
<span class="type">QContactActionOne</span>();
<span class="operator">~</span><span class="type">QContactActionOne</span>();
bool invokeAction(<span class="keyword">const</span> <span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">&</span> target<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params <span class="operator">=</span> <span class="type">QVariantMap</span>());
bool invokeAction(<span class="keyword">const</span> <span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span><span class="operator">&</span> targets<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params <span class="operator">=</span> <span class="type">QVariantMap</span>());
<span class="type">QVariantMap</span> results() <span class="keyword">const</span>;
State state() <span class="keyword">const</span>;
<span class="keyword">private</span> <span class="keyword">slots</span>:
<span class="type">void</span> performAction();
};
<span class="keyword">class</span> <span class="type">QContactActionTwo</span> : <span class="keyword">public</span> <span class="type"><a href="qcontactaction.html">QContactAction</a></span>
{
Q_OBJECT
<span class="keyword">public</span>:
<span class="type">QContactActionTwo</span>();
<span class="operator">~</span><span class="type">QContactActionTwo</span>();
bool invokeAction(<span class="keyword">const</span> <span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">&</span> target<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params <span class="operator">=</span> <span class="type">QVariantMap</span>());
bool invokeAction(<span class="keyword">const</span> <span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span><span class="operator">&</span> targets<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params <span class="operator">=</span> <span class="type">QVariantMap</span>());
<span class="type">QVariantMap</span> results() <span class="keyword">const</span>;
State state() <span class="keyword">const</span>;
<span class="keyword">private</span> <span class="keyword">slots</span>:
<span class="type">void</span> performAction();
};
</pre>
<p>The implementation of these classes might be something like the following (example only):</p>
<pre class="cpp">
<span class="type">QObject</span><span class="operator">*</span> <span class="type">QContactMultiActionPlugin</span><span class="operator">::</span>createInstance(<span class="keyword">const</span> <span class="type">QServiceInterfaceDescriptor</span><span class="operator">&</span> descriptor<span class="operator">,</span>
<span class="type">QServiceContext</span><span class="operator">*</span> context<span class="operator">,</span>
<span class="type">QAbstractSecuritySession</span><span class="operator">*</span> session)
{
Q_UNUSED(context);
Q_UNUSED(session);
<span class="keyword">if</span> (descriptor<span class="operator">.</span>interfaceName() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qcontactactionfactory.html">QContactActionFactory</a></span><span class="operator">::</span>InterfaceName
<span class="operator">&</span><span class="operator">&</span> descriptor<span class="operator">.</span>serviceName() <span class="operator">=</span><span class="operator">=</span> <span class="type">QString</span>(QLatin1String(<span class="string">"tst_qcontactactions:multiaction"</span>))
<span class="operator">&</span><span class="operator">&</span> descriptor<span class="operator">.</span>majorVersion() <span class="operator">=</span><span class="operator">=</span> <span class="number">1</span>
<span class="operator">&</span><span class="operator">&</span> descriptor<span class="operator">.</span>minorVersion() <span class="operator">=</span><span class="operator">=</span> <span class="number">1</span>
<span class="operator">&</span><span class="operator">&</span> descriptor<span class="operator">.</span>customAttribute(<span class="string">"ActionName"</span>) <span class="operator">=</span><span class="operator">=</span> <span class="type">QString</span>(QLatin1String(<span class="string">"call"</span>))) {
<span class="keyword">return</span> <span class="keyword">new</span> <span class="type">QContactMultiActionFactory</span>;
} <span class="keyword">else</span> {
<span class="keyword">return</span> <span class="number">0</span>;
}
}
Q_EXPORT_PLUGIN2(contacts_multiaction<span class="operator">,</span> <span class="type">QContactMultiActionPlugin</span>);
<span class="type">QContactMultiActionFactory</span><span class="operator">::</span><span class="type">QContactMultiActionFactory</span>()
: <span class="type"><a href="qcontactactionfactory.html">QContactActionFactory</a></span>()
{
m_actionOneDescriptor <span class="operator">=</span> createDescriptor(<span class="string">"call"</span><span class="operator">,</span> <span class="string">"tst_qcontactactions:multiaction"</span><span class="operator">,</span> <span class="string">"sip"</span><span class="operator">,</span> <span class="number">1</span>);
m_actionTwoDescriptor <span class="operator">=</span> createDescriptor(<span class="string">"call"</span><span class="operator">,</span> <span class="string">"tst_qcontactactions:multiaction"</span><span class="operator">,</span> <span class="string">"prop"</span><span class="operator">,</span> <span class="number">1</span>);
}
<span class="type">QContactMultiActionFactory</span><span class="operator">::</span><span class="operator">~</span><span class="type">QContactMultiActionFactory</span>()
{
}
<span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">></span> <span class="type">QContactMultiActionFactory</span><span class="operator">::</span>actionDescriptors() <span class="keyword">const</span>
{
<span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">></span> retn;
retn <span class="operator"><</span><span class="operator"><</span> m_actionOneDescriptor <span class="operator"><</span><span class="operator"><</span> m_actionTwoDescriptor;
<span class="keyword">return</span> retn;
}
<span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">*</span> <span class="type">QContactMultiActionFactory</span><span class="operator">::</span>create(<span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>
{
<span class="keyword">if</span> (which <span class="operator">=</span><span class="operator">=</span> m_actionOneDescriptor)
<span class="keyword">return</span> <span class="keyword">new</span> <span class="type">QContactActionOne</span>;
<span class="keyword">else</span> <span class="keyword">if</span> (which <span class="operator">=</span><span class="operator">=</span> m_actionTwoDescriptor)
<span class="keyword">return</span> <span class="keyword">new</span> <span class="type">QContactActionTwo</span>;
<span class="keyword">else</span>
<span class="keyword">return</span> <span class="number">0</span>;
}
<span class="type">QSet</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span> <span class="type">QContactMultiActionFactory</span><span class="operator">::</span>supportedTargets(<span class="keyword">const</span> <span class="type"><a href="qcontact.html">QContact</a></span><span class="operator">&</span> contact<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>
{
<span class="type">QSet</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span> retn;
<span class="keyword">if</span> (which <span class="operator">=</span><span class="operator">=</span> m_actionOneDescriptor <span class="operator">|</span><span class="operator">|</span> which <span class="operator">=</span><span class="operator">=</span> m_actionTwoDescriptor) {
<span class="comment">// in this example, they support the same targets.</span>
<span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">></span> pndets <span class="operator">=</span> contact<span class="operator">.</span>details<span class="operator"><</span><span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">></span>();
<span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator"><</span> pndets<span class="operator">.</span>size(); <span class="operator">+</span><span class="operator">+</span>i) {
<span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span> curr;
curr<span class="operator">.</span>setContact(contact);
curr<span class="operator">.</span>setDetails(<span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactdetail.html">QContactDetail</a></span><span class="operator">></span>() <span class="operator"><</span><span class="operator"><</span> pndets<span class="operator">.</span>at(i));
retn <span class="operator"><</span><span class="operator"><</span> curr;
}
}
<span class="keyword">return</span> retn;
}
<span class="type"><a href="qcontactfilter.html">QContactFilter</a></span> <span class="type">QContactMultiActionFactory</span><span class="operator">::</span>contactFilter(<span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>
{
<span class="keyword">if</span> (which <span class="operator">=</span><span class="operator">=</span> m_actionOneDescriptor <span class="operator">|</span><span class="operator">|</span> which <span class="operator">=</span><span class="operator">=</span> m_actionTwoDescriptor) {
<span class="type"><a href="qcontactdetailfilter.html">QContactDetailFilter</a></span> retn;
retn<span class="operator">.</span>setDetailDefinitionName(<span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">::</span>DefinitionName<span class="operator">,</span> <span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">::</span>FieldNumber);
<span class="keyword">return</span> retn;
}
<span class="keyword">return</span> <span class="type"><a href="qcontactfilter.html">QContactFilter</a></span>();
}
<span class="type">QVariant</span> <span class="type">QContactMultiActionFactory</span><span class="operator">::</span>metaData(<span class="keyword">const</span> <span class="type">QString</span><span class="operator">&</span> key<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span><span class="operator">&</span> targets<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> parameters<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>
{
Q_UNUSED(targets)
Q_UNUSED(parameters)
<span class="keyword">if</span> (key <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">::</span>MetaDataLabel)
<span class="keyword">return</span> <span class="type">QString</span>(<span class="string">"Call with VoIP"</span>);
<span class="comment">// Label etc</span>
<span class="keyword">if</span> (key <span class="operator">=</span><span class="operator">=</span> QLatin1String(<span class="string">"Provider"</span>)) {<span class="comment">// our custom metadata - just return which.actionIdentifier</span>
<span class="keyword">return</span> which<span class="operator">.</span>actionIdentifier();
}
<span class="keyword">return</span> <span class="type">QVariant</span>();
}
bool <span class="type">QContactMultiActionFactory</span><span class="operator">::</span>supportsContact(<span class="keyword">const</span> <span class="type"><a href="qcontact.html">QContact</a></span><span class="operator">&</span> contact<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qcontactactiondescriptor.html">QContactActionDescriptor</a></span><span class="operator">&</span> which) <span class="keyword">const</span>
{
<span class="keyword">if</span> (which <span class="operator">=</span><span class="operator">=</span> m_actionOneDescriptor <span class="operator">|</span><span class="operator">|</span> which <span class="operator">=</span><span class="operator">=</span> m_actionTwoDescriptor)
<span class="keyword">return</span> <span class="operator">!</span>contact<span class="operator">.</span>details<span class="operator"><</span><span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">></span>()<span class="operator">.</span>isEmpty();
<span class="keyword">return</span> <span class="keyword">false</span>;
}
<span class="type">QContactActionOne</span><span class="operator">::</span><span class="type">QContactActionOne</span>()
{
}
<span class="type">QContactActionOne</span><span class="operator">::</span><span class="operator">~</span><span class="type">QContactActionOne</span>()
{
}
bool <span class="type">QContactActionOne</span><span class="operator">::</span>invokeAction(<span class="keyword">const</span> <span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">&</span> target<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params)
{
Q_UNUSED(params)
<span class="comment">// this action only works on (contact + phone number) targets.</span>
<span class="keyword">if</span> (target<span class="operator">.</span>details()<span class="operator">.</span>size() <span class="operator">></span> <span class="number">1</span> <span class="operator">|</span><span class="operator">|</span> target<span class="operator">.</span>details()<span class="operator">.</span>at(<span class="number">0</span>)<span class="operator">.</span>definitionName() <span class="operator">!</span><span class="operator">=</span> <span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">::</span>DefinitionName)
<span class="keyword">return</span> <span class="keyword">false</span>;
<span class="type">QTimer</span><span class="operator">::</span>singleShot(<span class="number">1</span><span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(performAction()));
<span class="keyword">return</span> <span class="keyword">true</span>;
}
bool <span class="type">QContactActionOne</span><span class="operator">::</span>invokeAction(<span class="keyword">const</span> <span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span><span class="operator">&</span> targets<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params)
{
Q_UNUSED(params)
foreach (<span class="keyword">const</span> <span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">&</span> target<span class="operator">,</span> targets) {
<span class="keyword">if</span> (target<span class="operator">.</span>details()<span class="operator">.</span>size() <span class="operator">></span> <span class="number">1</span> <span class="operator">|</span><span class="operator">|</span> target<span class="operator">.</span>details()<span class="operator">.</span>at(<span class="number">0</span>)<span class="operator">.</span>definitionName() <span class="operator">!</span><span class="operator">=</span> <span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">::</span>DefinitionName) {
<span class="keyword">return</span> <span class="keyword">false</span>;
}
}
<span class="type">QTimer</span><span class="operator">::</span>singleShot(<span class="number">1</span><span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(performAction()));
<span class="keyword">return</span> <span class="keyword">true</span>;
}
<span class="type">QVariantMap</span> <span class="type">QContactActionOne</span><span class="operator">::</span>results() <span class="keyword">const</span>
{
<span class="keyword">return</span> <span class="type">QVariantMap</span>();
}
<span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">::</span>State <span class="type">QContactActionOne</span><span class="operator">::</span>state() <span class="keyword">const</span>
{
<span class="keyword">return</span> <span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">::</span>FinishedState;
}
<span class="type">void</span> <span class="type">QContactActionOne</span><span class="operator">::</span>performAction()
{
<span class="type">QMessageBox</span><span class="operator">::</span>information(<span class="number">0</span><span class="operator">,</span> <span class="string">"ActionOne"</span><span class="operator">,</span> <span class="string">"This is action one!"</span>);
<span class="keyword">emit</span> stateChanged(<span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">::</span>FinishedState);
}
<span class="type">QContactActionTwo</span><span class="operator">::</span><span class="type">QContactActionTwo</span>()
{
}
<span class="type">QContactActionTwo</span><span class="operator">::</span><span class="operator">~</span><span class="type">QContactActionTwo</span>()
{
}
bool <span class="type">QContactActionTwo</span><span class="operator">::</span>invokeAction(<span class="keyword">const</span> <span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">&</span> target<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params)
{
Q_UNUSED(params)
<span class="comment">// this action only works on (contact + phone number) targets. Note that it doesn't</span>
<span class="comment">// have to be the same as QContactActionOne -- it could have an entirely different implementation!</span>
<span class="keyword">if</span> (target<span class="operator">.</span>details()<span class="operator">.</span>size() <span class="operator">></span> <span class="number">1</span> <span class="operator">|</span><span class="operator">|</span> target<span class="operator">.</span>details()<span class="operator">.</span>at(<span class="number">0</span>)<span class="operator">.</span>definitionName() <span class="operator">!</span><span class="operator">=</span> <span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">::</span>DefinitionName)
<span class="keyword">return</span> <span class="keyword">false</span>;
<span class="type">QTimer</span><span class="operator">::</span>singleShot(<span class="number">1</span><span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(performAction()));
<span class="keyword">return</span> <span class="keyword">true</span>;
}
bool <span class="type">QContactActionTwo</span><span class="operator">::</span>invokeAction(<span class="keyword">const</span> <span class="type">QList</span><span class="operator"><</span><span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">></span><span class="operator">&</span> targets<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QVariantMap</span><span class="operator">&</span> params)
{
Q_UNUSED(params)
foreach (<span class="keyword">const</span> <span class="type"><a href="qcontactactiontarget.html">QContactActionTarget</a></span><span class="operator">&</span> target<span class="operator">,</span> targets) {
<span class="keyword">if</span> (target<span class="operator">.</span>details()<span class="operator">.</span>size() <span class="operator">></span> <span class="number">1</span> <span class="operator">|</span><span class="operator">|</span> target<span class="operator">.</span>details()<span class="operator">.</span>at(<span class="number">0</span>)<span class="operator">.</span>definitionName() <span class="operator">!</span><span class="operator">=</span> <span class="type"><a href="qcontactphonenumber.html">QContactPhoneNumber</a></span><span class="operator">::</span>DefinitionName) {
<span class="keyword">return</span> <span class="keyword">false</span>;
}
}
<span class="type">QTimer</span><span class="operator">::</span>singleShot(<span class="number">1</span><span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(performAction()));
<span class="keyword">return</span> <span class="keyword">true</span>;
}
<span class="type">QVariantMap</span> <span class="type">QContactActionTwo</span><span class="operator">::</span>results() <span class="keyword">const</span>
{
<span class="keyword">return</span> <span class="type">QVariantMap</span>();
}
<span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">::</span>State <span class="type">QContactActionTwo</span><span class="operator">::</span>state() <span class="keyword">const</span>
{
<span class="keyword">return</span> <span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">::</span>FinishedState;
}
<span class="type">void</span> <span class="type">QContactActionTwo</span><span class="operator">::</span>performAction()
{
<span class="type">QMessageBox</span><span class="operator">::</span>information(<span class="number">0</span><span class="operator">,</span> <span class="string">"ActionTwo"</span><span class="operator">,</span> <span class="string">"This is action two!"</span>);
<span class="keyword">emit</span> stateChanged(<span class="type"><a href="qcontactaction.html">QContactAction</a></span><span class="operator">::</span>FinishedState);
}
</pre>
<p>Once implemented, the plugin must be described by an XML file and installed in an appropriate location. For more information, see the Qt Service Framework documentation.</p>
<pre class="cpp">
<span class="operator"><</span><span class="operator">?</span>xml version<span class="operator">=</span><span class="string">"1.0"</span> encoding<span class="operator">=</span><span class="string">"utf-8"</span> <span class="operator">?</span><span class="operator">></span>
<span class="operator"><</span>service<span class="operator">></span>
<span class="operator"><</span>name<span class="operator">></span>tst_qcontactactions:multiaction<span class="operator"><</span><span class="operator">/</span>name<span class="operator">></span>
<span class="operator"><</span>filepath<span class="operator">></span>plugins<span class="operator">/</span>contacts<span class="operator">/</span>libcontacts_multiaction<span class="operator"><</span><span class="operator">/</span>filepath<span class="operator">></span>
<span class="operator"><</span>description<span class="operator">></span>This service provides two test <span class="type"><a href="qcontactaction.html">QContactAction</a></span> implementations <span class="keyword">for</span> testing purposes<span class="operator">.</span> It is also an example of a single plugin providing multiple actions whose descriptors are identical except <span class="keyword">for</span> their meta data<span class="operator">.</span><span class="operator"><</span><span class="operator">/</span>description<span class="operator">></span>
<span class="operator"><</span>interface<span class="operator">></span>
<span class="operator"><</span>name<span class="operator">></span>org<span class="operator">.</span>qt<span class="operator">-</span>project<span class="operator">.</span><span class="type">Qt</span><span class="operator">.</span>SampleContactsActionPlugin<span class="operator"><</span><span class="operator">/</span>name<span class="operator">></span>
<span class="operator"><</span>version<span class="operator">></span><span class="number">1.1</span><span class="operator"><</span><span class="operator">/</span>version<span class="operator">></span>
<span class="operator"><</span>capabilities<span class="operator">></span><span class="operator"><</span><span class="operator">/</span>capabilities<span class="operator">></span>
<span class="operator"><</span>customproperty key<span class="operator">=</span><span class="string">"ActionName"</span><span class="operator">></span>call<span class="operator"><</span><span class="operator">/</span>customproperty<span class="operator">></span>
<span class="operator"><</span>description<span class="operator">></span>This plugin can instantiate two different <span class="type"><a href="qcontactaction.html">QContactAction</a></span> instances; one which provides the <span class="string">"call"</span> action via the <span class="string">"sip"</span> provider<span class="operator">,</span> the other which provides the <span class="string">"call"</span> action via the <span class="string">"example proprietary protocol"</span> provider<span class="operator">.</span><span class="operator"><</span><span class="operator">/</span>description<span class="operator">></span>
<span class="operator"><</span><span class="operator">/</span>interface<span class="operator">></span>
<span class="operator"><</span><span class="operator">/</span>service<span class="operator">></span>
</pre>
<a name="deploying-services"></a>
<h3 >Deploying Services</h3>
<p>Depending on the platform, the service which provides the action must be deployed in a certain way.</p>
</div>
<!-- @@@contactsactions.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed 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.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|