/usr/share/gtk-doc/html/geoclue/simple-master-example.html is in libgeoclue-dev 0.12.0-1ubuntu12.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Master provider: simple example in C</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Geoclue Reference Manual">
<link rel="up" href="ch01.html" title="Using Geoclue in applications">
<link rel="prev" href="simple-example.html" title="Using basic Geoclue providers: simple example in C">
<link rel="next" href="rn01.html" title="C API">
<meta name="generator" content="GTK-Doc V1.13 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="ch01.html" title="Using Geoclue in applications">
<link rel="reference" href="rn01.html" title="C API">
<link rel="reference" href="rn02.html" title="D-Bus API">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="simple-example.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Geoclue Reference Manual</th>
<td><a accesskey="n" href="rn01.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="section" title="Master provider: simple example in C">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="simple-master-example"></a>Master provider: simple example in C</h2></div></div></div>
<p>
Here is the "Hello World" for Geoclue Master. It shows one of the advantages of
using the Master provider: Even most web service
providers can be used as signal emitting providers (master queries them whenever
network connection changes).
</p>
<pre class="programlisting">
#include <geoclue/geoclue-master.h>
static void
position_changed (GeocluePosition *position,
GeocluePositionFields fields,
int timestamp,
double latitude,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
gpointer userdata)
{
g_print ("Position changed:\n");
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
g_print ("\t%f, %f\n\n", latitude, longitude);
} else {
g_print ("\tLatitude and longitude not available.\n\n");
}
}
int main()
{
GMainLoop *loop;
GeoclueMaster *master;
GeoclueMasterClient *client;
GeocluePosition *pos;
GeocluePositionFields fields;
double lat, lon;
GError *error = NULL;
g_type_init ();
/* create a MasterClient using Master */
master = geoclue_master_get_default ();
client = geoclue_master_create_client (master, NULL, &error);
g_object_unref (master);
if (!client) {
g_printerr ("Error creating GeoclueMasterClient: %s\n", error->message);
g_error_free (error);
return 1;
}
/* Set our requirements: We want at least city level accuracy, require signals,
and allow the use of network (but not e.g. GPS) */
if (!geoclue_master_client_set_requirements (client,
GEOCLUE_ACCURACY_LEVEL_LOCALITY,
0, TRUE,
GEOCLUE_RESOURCE_NETWORK,
&error)){
g_printerr ("set_requirements failed: %s", error->message);
g_error_free (error);
g_object_unref (client);
return 1;
}
/* Get a Position object */
pos = geoclue_master_client_create_position (client, NULL);
if (!pos) {
g_printerr ("Failed to get a position object");
g_object_unref (client);
return 1;
}
/* call get_position. We do not know which provider actually provides
the answer (although we could find out using MasterClient API) */
fields = geoclue_position_get_position (pos, NULL,
&lat, &lon, NULL,
NULL, &error);
if (error) {
g_printerr ("Error in geoclue_position_get_position: %s.\n", error->message);
g_error_free (error);
error = NULL;
} else {
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
g_print ("We're at %.3f, %.3f.\n", lat, lon);
}
}
g_signal_connect (G_OBJECT (pos), "position-changed",
G_CALLBACK (position_changed), NULL);
g_print ("Waiting for position change signals...\n");
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_main_loop_unref (loop);
g_object_unref (pos);
g_object_unref (client);
return 0;
}
</pre>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.13</div>
</body>
</html>
|