This file is indexed.

/usr/share/gtk-doc/html/geoclue/simple-example.html is in libgeoclue-dev 0.12.99-4.

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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Using basic Geoclue providers: simple example in C</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<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="ch01.html" title="Using Geoclue in applications">
<link rel="next" href="simple-master-example.html" title="Master provider: simple example in C">
<meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</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="ch01.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="simple-master-example.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="simple-example"></a>Using basic Geoclue providers: simple example in C</h2></div></div></div>
<p>There are several examples in the geoclue source, these are included here to 
		give a quick overview.
		</p>
<p>
			Here is a very simple example of using a specific Geoclue Position provider. 
			Note that we're using the synchronous version of the method call here, so 
			geoclue_position_get_position() will block until the response comes (or until D-Bus timeouts).
		</p>
<pre class="programlisting">
#include &lt;geoclue/geoclue-position.h&gt;

int main() 
{
	GeocluePosition *pos;
	GeocluePositionFields fields;
	double lat, lon;
	GError *error = NULL;
	
	g_type_init ();
	
	/* Create the position object */
	pos = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Hostip",
	                            "/org/freedesktop/Geoclue/Providers/Hostip");
	
	/* call get_position. Note that unneeded output variables (here 
	    timestamp, altitude and accuracy) can be left NULL */
	fields = geoclue_position_get_position (pos, NULL,
	                                        &amp;lat, &amp;lon, NULL,
	                                        NULL, &amp;error);
	if (error) {
		g_printerr ("Error in get_position: %s.\n", error-&gt;message);
		g_error_free (error);
		g_object_unref (pos);
		return 1;
	}
	
	if (fields &amp; GEOCLUE_POSITION_FIELDS_LATITUDE &amp;&amp;
	    fields &amp; GEOCLUE_POSITION_FIELDS_LONGITUDE) {
		g_print ("According to Hostip.info we're at %.3f, %.3f.\n",
		          lat, lon);
	} else {
		g_print ("Hostip does not have a valid location available.\nVisit http://www.hostip.info/ to correct this");
	}
	g_object_unref (pos);
	
	return 0;
}
		</pre>
<p>Save as test-hostip.c and compile with 
		</p>
<pre class="programlisting">
gcc `pkg-config --libs --cflags geoclue`  -o test-hostip test-hostip.c
		</pre>
<p>Here is a similarly simple example using GLib mainloop and Gypsy provider with 
		position-changed signals: 
		</p>
<pre class="programlisting">
#include &lt;geoclue/geoclue-position.h&gt;

/* device name or bluetooth address */
#define GPS_DEVICE_NAME "00:02:76:C5:81:BF" 

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 &amp; GEOCLUE_POSITION_FIELDS_LATITUDE &amp;&amp;
	    fields &amp; 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;
	GHashTable *options;
	GeocluePosition *pos;
	GError *error = NULL;
	
	g_type_init ();
	
	/* Create the position object */
	pos = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Gypsy",
	                            "/org/freedesktop/Geoclue/Providers/Gypsy");
	
	/* Set GPS device name option for Gypsy */
	options = g_hash_table_new (g_str_hash, g_str_equal);
	g_hash_table_insert (options, "org.freedesktop.Geoclue.GPSDevice", GPS_DEVICE_NAME);
	if (!geoclue_provider_set_options (GEOCLUE_PROVIDER (pos), options, &amp;error)) {
		g_printerr ("Error setting options: %s\n", error-&gt;message);
		g_error_free (error);
		g_hash_table_destroy (options);
		g_object_unref (pos);
                return 1;
	}
	g_hash_table_destroy (options);
	
	/* connect to signal */
	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);
	
	return 0;
}
		</pre>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18.1</div>
</body>
</html>