aboutsummaryrefslogtreecommitdiff
path: root/libcontextprovider/doc/html/capi.html
diff options
context:
space:
mode:
Diffstat (limited to 'libcontextprovider/doc/html/capi.html')
-rw-r--r--libcontextprovider/doc/html/capi.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/libcontextprovider/doc/html/capi.html b/libcontextprovider/doc/html/capi.html
new file mode 100644
index 00000000..b8f520fa
--- /dev/null
+++ b/libcontextprovider/doc/html/capi.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<title>libcontextprovider: C Api</title>
+<link href="tabs.css" rel="stylesheet" type="text/css">
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.5.8 -->
+<div class="navigation" id="top">
+ <div class="tabs">
+ <ul>
+ <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
+ <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
+ <li><a href="namespaces.html"><span>Namespaces</span></a></li>
+ <li><a href="annotated.html"><span>Classes</span></a></li>
+ <li><a href="files.html"><span>Files</span></a></li>
+ </ul>
+ </div>
+</div>
+<div class="contents">
+<h1><a class="anchor" name="CApi">C Api </a></h1>The libcontextprovider library offers a simple plain-C API to be used from any C program.<h2><a class="anchor" name="Usage">
+Usage</a></h2>
+<div class="fragment"><pre class="fragment"> <a class="code" href="contextc_8cpp.html#33b9763ab39ce494e115bffcab36360f" title="Initializes and starts the service with a given bus_type and a bus_name.">context_provider_init</a>(DBUS_BUS_SESSION, <span class="stringliteral">"org.test.provider"</span>);
+
+ <a class="code" href="contextc_8cpp.html#a6873ed47e24aaa57d4a327afaf24899" title="Installs (adds) a key to be provided by the service.">context_provider_install_key</a>(<span class="stringliteral">"Battery.OnBattery"</span>, 0, NULL, NULL);
+ <a class="code" href="contextc_8cpp.html#a6873ed47e24aaa57d4a327afaf24899" title="Installs (adds) a key to be provided by the service.">context_provider_install_key</a>(<span class="stringliteral">"Battery.ChargePercentage"</span>, 0, NULL, NULL);
+
+ <a class="code" href="contextc_8cpp.html#0671fc551fe7ef0a5b51d0f9e3ffad96" title="Sets the key to a specified boolean value.">context_provider_set_boolean</a>(<span class="stringliteral">"Battery.OnBattery"</span>, 1);
+ <a class="code" href="contextc_8cpp.html#ac6f0ad56b4d250a2acb9b1af64eaa84" title="Sets the key to a specified integer value.">context_provider_set_integer</a>(<span class="stringliteral">"Battery.ChargePercentage"</span>, 55);
+</pre></div><p>
+The above code snippet starts a service at "org.test.provider" with two keys ("Battery.OnBattery", "Battery.ChargePercentage") and sets their respective values.<p>
+Note: If the provider used other D-Bus bindings than QDBus, the service name ("org.test.provider") needs to be unique, i.e., the provider process should not register it itself.<h2><a class="anchor" name="Callbacks">
+Callbacks</a></h2>
+The context_provider_install_key function and context_provider_install_group function take arguments specyfying the callback function. The callback is executed when the subscription status changes for the key or the key group (first subscriber appears or last subscriber goes away). Basing on this info the provider can manage it's resources. It's okay also to use the callback function to actually set the value.<p>
+<div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> callback_function_example(<span class="keywordtype">int</span> subscribed, <span class="keywordtype">void</span>* user_data)
+ {
+ <span class="keywordflow">if</span> (subscribed) {
+ <span class="comment">// First subscriber appeared.</span>
+ <span class="comment">// Start ie. pooling the data.</span>
+ } <span class="keywordflow">else</span> {
+ <span class="comment">// Last subscribed disappeared.</span>
+ <span class="comment">// Stop pooling data, release resources.</span>
+ }
+ }
+</pre></div> </div>
+<hr size="1"><address style="text-align: right;"><small>Generated on Fri Oct 23 08:58:39 2009 for libcontextprovider by&nbsp;
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
+</body>
+</html>