Commit 3317ef6f authored by Jussi Kukkonen's avatar Jussi Kukkonen

Plazes backend (C version, with civic location)

This is modified from hostip-backend, at the moment it's
mostly copy-pasted: should refactor that.
The current version supports civic location (country, locality,
postalcode, street, text), but not connectivity event monitoring
(libconic).
parent 82d2ba40
SUBDIRS = map_yahoo position_manual geocode_yahoo position_hostip position_gpsd
SUBDIRS = map_yahoo \
position_manual \
geocode_yahoo \
position_hostip \
position_gpsd \
position_plazes
......@@ -17,69 +17,101 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef ___GEOCLUESERVER_PLAZES_H__
#define ___GEOCLUESERVER_PLAZES_H__
#ifndef __GEOCLUE_POSITION_SERVER_H__
#define __GEOCLUE_POSITION_SERVER_H__
#define DBUS_API_SUBJECT_TO_CHANGE
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <glib.h>
#define GEOCLUESERVER_PLAZES_DBUS_SERVICE "org.foinse_project.geoclue"
#define GEOCLUESERVER_PLAZES_DBUS_PATH "/org/foinse_project/geoclue"
#define GEOCLUESERVER_PLAZES_DBUS_INTERFACE "org.foinse_project.geoclue"
#ifdef HAVE_LIBCONIC
#include <conicconnection.h>
#endif
G_BEGIN_DECLS
#define GEOCLUE_POSITION_DBUS_SERVICE "org.foinse_project.geoclue.position.plazes"
#define GEOCLUE_POSITION_DBUS_PATH "/org/foinse_project/geoclue/position/plazes"
#define GEOCLUE_POSITION_DBUS_INTERFACE "org.foinse_project.geoclue.position"
#define GEOCLUESERVER_PLAZES_TYPE (geoclueserver_plazes_get_type ())
#define GEOCLUESERVER_PLAZES(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GEOCLUESERVER_PLAZES_TYPE, GeoclueserverPlazes))
#define GEOCLUESERVER_PLAZES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEOCLUESERVER_PLAZES_TYPE, GeoclueserverPlazesClass))
#define IS_GEOCLUESERVER_PLAZES(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GEOCLUESERVER_PLAZES_TYPE))
#define IS_GEOCLUESERVER_PLAZES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEOCLUESERVER_PLAZES_TYPE))
#define GEOCLUESERVER_PLAZES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEOCLUESERVER_PLAZES_TYPE, GeoclueserverPlazesClass))
G_BEGIN_DECLS
//Let's create a geoclueserver object that has one method of geoclueserver
typedef struct _GeoclueserverPlazes GeoclueserverPlazes;
typedef struct _GeoclueserverPlazesClass GeoclueserverPlazesClass;
//Let's create a geoclue_position object that has one method of geoclue_position
typedef struct GeocluePosition GeocluePosition;
typedef struct GeocluePositionClass GeocluePositionClass;
GType geoclueserver_plazes_get_type (void);
struct GeoclueserverPlazes
GType geoclue_position_get_type (void);
struct GeocluePosition
{
GObject parent;
GMainLoop* loop;
gdouble current_lat;
gdouble current_lon;
gboolean is_current_valid;
#ifdef HAVE_LIBCONIC
ConIcConnection* net_connection;
DBusConnection* dbus_connection;
#endif
};
struct GeoclueserverPlazesClass
struct GeocluePositionClass
{
GObjectClass parent;
DBusGConnection *connection;
/* Signals */
void (*current_position_changed) (GeoclueserverPlazes*, gdouble, gdouble );
void (*current_position_changed) (GeocluePosition*, gdouble, gdouble );
};
#define TYPE_GEOCLUE_POSITION (geoclue_position_get_type ())
#define GEOCLUE_POSITION(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_GEOCLUE_POSITION, GeocluePosition))
#define GEOCLUE_POSITION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GEOCLUE_POSITION, GeocluePositionClass))
#define IS_GEOCLUE_POSITION(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_GEOCLUE_POSITION))
#define IS_GEOCLUE_POSITION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GEOCLUE_POSITION))
#define GEOCLUE_POSITION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GEOCLUE_POSITION, GeocluePositionClass))
gboolean geoclue_position_version (GeocluePosition *obj, gint* OUT_major, gint* OUT_minor, gint* OUT_micro, GError **error);
gboolean geoclue_position_service_provider(GeocluePosition *obj, char** name, GError **error);
gboolean geoclue_position_current_position(GeocluePosition *obj, gdouble* OUT_latitude, gdouble* OUT_longitude, GError **error );
gboolean geoclue_position_current_position_error(GeocluePosition *obj, gdouble* OUT_latitude_error, gdouble* OUT_longitude_error, GError **error );
gboolean geoclue_position_current_altitude(GeocluePosition *obj, gdouble* OUT_altitude, GError **error );
gboolean geoclue_position_current_velocity(GeocluePosition *obj, gdouble* OUT_north_velocity, gdouble* OUT_east_velocity, GError **error );
gboolean geoclue_position_current_time(GeocluePosition *obj, gint* OUT_year, gint* OUT_month, gint* OUT_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclue_position_satellites_in_view(GeocluePosition *obj, GArray** OUT_prn_numbers, GError **error );
gboolean geoclue_position_satellites_data(GeocluePosition *obj, const gint IN_prn_number, gdouble* OUT_elevation, gdouble* OUT_azimuth, gdouble* OUT_signal_noise_ratio, GError **error );
gboolean geoclue_position_sun_rise(GeocluePosition *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclue_position_sun_set(GeocluePosition *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclue_position_moon_rise(GeocluePosition *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclue_position_moon_set(GeocluePosition *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclue_position_civic_location (GeocluePosition* obj,
char** OUT_country,
char** OUT_region,
char** OUT_locality,
char** OUT_area,
char** OUT_postalcode,
char** OUT_street,
char** OUT_building,
char** OUT_floor,
char** OUT_room,
char** OUT_text,
GError** error);
gboolean geoclue_position_service_available(GeocluePosition *obj, gboolean* OUT_available, char** OUT_reason, GError** error);
gboolean geoclue_position_shutdown(GeocluePosition *obj, GError** error);
gboolean geoclueserver_plazes_version (GeoclueserverPlazes *obj, gint* OUT_major, gint* OUT_minor, gint* OUT_micro, GError **error);
gboolean geoclueserver_plazes_service_provider(GeoclueserverPlazes *obj, char** name, GError **error);
gboolean geoclueserver_plazes_current_position(GeoclueserverPlazes *obj, gdouble* OUT_latitude, gdouble* OUT_longitude, GError **error );
gboolean geoclueserver_plazes_current_position_error(GeoclueserverPlazes *obj, gdouble* OUT_latitude_error, gdouble* OUT_longitude_error, GError **error );
gboolean geoclueserver_plazes_current_altitude(GeoclueserverPlazes *obj, gdouble* OUT_altitude, GError **error );
gboolean geoclueserver_plazes_current_velocity(GeoclueserverPlazes *obj, gdouble* OUT_north_velocity, gdouble* OUT_east_velocity, GError **error );
gboolean geoclueserver_plazes_current_time(GeoclueserverPlazes *obj, gint* OUT_year, gint* OUT_month, gint* OUT_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclueserver_plazes_satellites_in_view(GeoclueserverPlazes *obj, GArray** OUT_prn_numbers, GError **error );
gboolean geoclueserver_plazes_satellites_data(GeoclueserverPlazes *obj, const gint IN_prn_number, gdouble* OUT_elevation, gdouble* OUT_azimuth, gdouble* OUT_signal_noise_ratio, GError **error );
gboolean geoclueserver_plazes_sun_rise(GeoclueserverPlazes *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclueserver_plazes_sun_set(GeoclueserverPlazes *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclueserver_plazes_moon_rise(GeoclueserverPlazes *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclueserver_plazes_moon_set(GeoclueserverPlazes *obj, const gdouble IN_latitude, const gdouble IN_longitude, const gint IN_year, const gint IN_month, const gint IN_day, gint* OUT_hours, gint* OUT_minutes, gint* OUT_seconds, GError **error );
gboolean geoclueserver_plazes_geocode(GeoclueserverPlazes *obj, const char * IN_street, const char * IN_city, const char * IN_state, const char * IN_zip, gdouble* OUT_latitude, gdouble* OUT_longitude, gint* OUT_return_code, GError **error );
gboolean geoclueserver_plazes_geocode_free_text(GeoclueserverPlazes *obj, const char * IN_free_text, gdouble* OUT_latitude, gdouble* OUT_longitude, gint* OUT_return_code, GError **error );
G_END_DECLS
G_END_DECLS
#endif
......@@ -114,6 +114,7 @@ AC_OUTPUT(
backend/geocode_yahoo/Makefile
backend/position_manual/Makefile
backend/position_hostip/Makefile
backend/position_plazes/Makefile
backend/position_gpsd/Makefile
)
......
......@@ -65,25 +65,25 @@ int main (int argc, char** argv)
g_debug ("current position query failed");
} else {
g_debug ("current position query ok");
printf ("You are at %f %f\n\n", lat, lon);
printf ("You are at %f %f\n", lat, lon);
}
gchar* locality = NULL;
gchar* country = NULL;
gchar* locality = NULL;
gchar* postalcode = NULL;
gchar* street = NULL;
gchar* text = NULL;
g_debug ("Querying civic location");
if (geoclue_position_civic_location (&country, NULL, &locality, NULL,NULL, NULL, NULL, NULL,NULL, NULL) != GEOCLUE_POSITION_SUCCESS) {
if (geoclue_position_civic_location (&country, NULL, &locality, NULL, &postalcode, &street, NULL, NULL,NULL, &text) != GEOCLUE_POSITION_SUCCESS) {
g_debug ("civic location query failed");
} else {
g_debug ("civic location query ok");
if (locality && country) {
printf("You are in %s, %s\n\n", locality, country);
}else if (country){
/*TODO: This is never reached. Investigate why pointers are non-null
when there's no data? */
printf("You are in %s\n\n", country);
}
if (country) printf ("Country: %s\n", country);
if (locality) printf ("Locality: %s\n", locality);
if (postalcode) printf ("Postalcode: %s\n", postalcode);
if (street) printf ("Street: %s\n", street);
if (text) printf ("Text: %s\n", text);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment