コード例 #1
0
    template<> void freeOwnedGPtr<GeoclueAccuracy>(GeoclueAccuracy* accuracy)
    {
        if (!accuracy)
            return;

        geoclue_accuracy_free(accuracy);
    }
コード例 #2
0
static void
mnp_wc_get_position_cb (GeocluePosition       *position,
                        GeocluePositionFields  fields,
                        int                    timestamp,
                        double                 latitude,
                        double                 longitude,
                        double                 altitude,
                        GeoclueAccuracy       *accuracy,
                        GError                *error,
                        gpointer               userdata)
{
    MnpWorldClockPrivate *priv = GET_PRIVATE (userdata);
    GeoclueAccuracy *n_accuracy;

    if (error) {
        g_warning ("Unable to get position: %s\n", error->message);
        return;
    }

    printf("POSI: %lf %lf\n", latitude, longitude);
    n_accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_DETAILED, 0, 0);
    geoclue_reverse_geocode_position_to_address_async (priv->geo_reverse_geocode,
            latitude,
            longitude,
            n_accuracy,
            mnp_wc_reverse_geocode_cb,
            userdata);

    geoclue_accuracy_free (n_accuracy);

}
コード例 #3
0
static void
finalize (GObject *object)
{
	GeoclueGypsy *gypsy = GEOCLUE_GYPSY (object);

	geoclue_accuracy_free (gypsy->accuracy);
        g_free (gypsy->device_name);

	((GObjectClass *) geoclue_gypsy_parent_class)->finalize (object);
}
コード例 #4
0
ファイル: geoclue-localnet.c プロジェクト: Aktrisa/geoclue
static void
free_gateway_list (GSList *gateways)
{
	GSList *l;
	
	l = gateways;
	while (l) {
		Gateway *gw;
		
		gw = l->data;
		g_free (gw->mac);
		g_hash_table_destroy (gw->address);
		geoclue_accuracy_free (gw->accuracy);
		g_free (gw);
		
		l = l->next;
	}
	g_slist_free (gateways);
}
コード例 #5
0
ファイル: position-example.c プロジェクト: Aktrisa/geoclue
int main (int argc, char** argv)
{
	gchar *service, *path;
	GeocluePosition *pos = NULL;
	GeocluePositionFields fields;
	int timestamp;
	double lat, lon;
	GeoclueAccuracy *accuracy = NULL;
	GMainLoop *mainloop;
	GError *error = NULL;
	
	g_type_init();
	
	if (argc < 2 || argc % 2 != 0) {
		g_printerr ("Usage:\n  position-example <provider_name> [option value]\n");
		return 1;
	}

	g_print ("Using provider '%s'\n", argv[1]);
	service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
	path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
	
	mainloop = g_main_loop_new (NULL, FALSE);
	
	/* Create new GeocluePosition */
	pos = geoclue_position_new (service, path);
	if (pos == NULL) {
		g_printerr ("Error while creating GeocluePosition object.\n");
		return 1;
	}

	g_free (service);
	g_free (path);
	
        if (argc > 2) {
                GHashTable *options;

                options = parse_options (argc, argv);
                if (!geoclue_provider_set_options (GEOCLUE_PROVIDER (pos), options, &error)) {
                        g_printerr ("Error setting options: %s\n", 
                                    error->message);
                        g_error_free (error);
                        error = NULL;
                }
                g_hash_table_destroy (options);
        }
	
	/* Query current position. We're not interested in altitude 
	   this time, so leave it NULL. Same can be done with all other
	   arguments that aren't interesting to the client */
	fields = geoclue_position_get_position (pos, &timestamp, 
	                                        &lat, &lon, NULL, 
	                                        &accuracy, &error);
	if (error) {
		g_printerr ("Error getting position: %s\n", error->message);
		g_error_free (error);
		g_object_unref (pos);
		return 1;
	}
	
	/* Print out coordinates if they are valid */
	if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
	    fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
		
		GeoclueAccuracyLevel level;
		double horiz_acc;
		
		geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL);
		g_print ("Current position:\n");
		g_print ("\t%f, %f\n", lat, lon);
		g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc);
		
	} else {
		g_print ("Latitude and longitude not available.\n");
	}

	geoclue_accuracy_free (accuracy);

	g_signal_connect (G_OBJECT (pos), "position-changed",
			  G_CALLBACK (position_changed_cb), NULL);

	g_main_loop_run (mainloop);
	return 0;
	
}