Commit e5727d5d authored by Keith Preston's avatar Keith Preston

: Added applet, gconf keys, and gpsd back. gpsd works for polling but not...

: Added applet, gconf keys, and gpsd back.   gpsd works for polling but not for interrupt callback yet.
parent e3a16210
SUBDIRS = geoclue example backend
SUBDIRS = geoclue example backend applet data
EXTRA_DIST = geoclue.pc.in
DISTCLEANFILES = geoclue.pc
......
<oaf_info>
<oaf_server iid="OAFIID:GeoclueApplet_Factory" type="exe"
location="/usr/lib/gnome-panel/geoclue-applet">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Geoclue Applet Factory"/>
<oaf_attribute name="description" type="string" value="Factory to create the geoclue applet"/>
</oaf_server>
<oaf_server iid="OAFIID:GeoclueApplet" type="factory"
location="OAFIID:GeoclueApplet_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Geoclue Applet"/>
<oaf_attribute name="description" type="string" value="A geoclue applet"/>
<oaf_attribute name="panel:category" type="string" value="Accessories"/>
<oaf_attribute name="panel:icon" type="string" value="geoclue.png"/>
</oaf_server>
</oaf_info>
\ No newline at end of file
#FIX ME remove hard coded paths
bin_PROGRAMS = geoclue-applet
bindir = /usr/lib/gnome-panel
geoclue_applet_SOURCES = geoclue_applet.c
AM_CPPFLAGS = $(APPLET_CFLAGS) $(DEPS_CFLAGS) -I$(top_srcdir)
AM_LDFLAGS = $(APPLET_LIBS) $(DEPS_LIBS) $(top_builddir)/geoclue/libgeoclue.la
EXTRA_DIST = \
geoclue.png \
GNOME_geoclue.server
pixdir = /usr/share/pixmaps
pix_DATA = geoclue.png
bonobodir = /usr/lib/bonobo/servers
bonobo_DATA = GNOME_geoclue.server
#include <string.h>
#include <panel-applet.h>
#include <gtk/gtkimage.h>
#include <geoclue/position.h>
#include <glib.h>
static gboolean
on_button_press (GtkWidget *event_box,
GdkEventButton *event,
gpointer data)
{
static int window_shown;
static GtkWidget *window, *label;
/* Don't react to anything other than the left mouse button;
return FALSE so the event is passed to the default handler */
if (event->button != 1)
return FALSE;
if (!window_shown) {
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
geoclue_position_init();
gdouble lat, lon;
geoclue_position_current_position(&lat, &lon);
gchar* text = g_strdup_printf("You are at %f %f\n", lat, lon);
label = GTK_WIDGET(gtk_label_new (text));
free(text);
geoclue_position_close();
gtk_container_add (GTK_CONTAINER (window), label);
gtk_widget_show_all (window);
}
else
gtk_widget_hide (GTK_WIDGET (window));
window_shown = !window_shown;
return TRUE;
}
static gboolean
geoclue_applet_fill (PanelApplet *applet,
const gchar *iid,
gpointer data)
{
GtkWidget *image;
if (strcmp (iid, "OAFIID:GeoclueApplet") != 0)
return FALSE;
image = gtk_image_new_from_file ("/usr/share/pixmaps/geoclue.png");
GtkWidget *event_box;
event_box = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (event_box), image);
g_signal_connect (G_OBJECT (event_box),
"button_press_event",
G_CALLBACK (on_button_press),
image);
gtk_container_add (GTK_CONTAINER (applet), event_box);
gtk_widget_show_all (GTK_WIDGET (applet));
return TRUE;
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GeoclueApplet_Factory",
PANEL_TYPE_APPLET,
"The Geoclue Applet",
"0",
geoclue_applet_fill,
NULL);
SUBDIRS = map_yahoo position_manual geocode_yahoo position_hostip
SUBDIRS = map_yahoo position_manual geocode_yahoo position_hostip position_gpsd
......@@ -22,6 +22,8 @@ AM_CPPFLAGS = $(YAHOO_CFLAGS) -I$(top_srcdir)
AM_LDFLAGS = $(YAHOO_LIBS)
EXTRA_DIST = \
geoclue_geocode_server_yahoo.h \
geocode_yahoo.desc \
$(service_in_files)
BUILT_SOURCES = \
......@@ -32,6 +34,13 @@ CLEANFILES = \
geoclue_geocode_server_glue.h \
$(service_files)
backendregistrationdir = $(datadir)/geoclue/backend
backendregistration_DATA = \
geocode_yahoo.desc
geoclue_geocode_server_glue.h:../../geoclue/geocode_glue.xml
$(DBUS_BINDING_TOOL) --prefix=geoclue_geocode --mode=glib-server $< | sed 's;\data = user_data;\data = (DBusGAsyncData\*)user_data;g' > $@
......@@ -371,6 +371,19 @@ gboolean geoclue_geocode_lat_lon_to_address(GeoclueGeocode *obj, gdouble IN_lati
gboolean geoclue_geocode_service_available(GeoclueGeocode *obj, gboolean* OUT_available, char** OUT_reason, GError** error)
{
return TRUE;
}
gboolean geoclue_geocode_shutdown(GeoclueGeocode *obj, GError** error)
{
g_main_loop_quit (obj->loop);
return TRUE;
}
......@@ -383,8 +396,7 @@ int main( int argc,
g_thread_init (NULL);
GMainLoop* loop = g_main_loop_new(NULL,TRUE);
/*
......@@ -398,14 +410,16 @@ int main( int argc,
GeoclueGeocode* obj = NULL;
obj = GEOCLUE_GEOCODE(g_type_create_instance (geoclue_geocode_get_type()));
obj->loop = g_main_loop_new(NULL,TRUE);
g_main_loop_run(loop);
g_main_loop_run(obj->loop);
g_object_unref(obj);
g_main_loop_unref(loop);
g_main_loop_unref(obj->loop);
return 0;
......
......@@ -45,7 +45,7 @@ struct GeoclueGeocode
{
GObject parent;
GMainLoop* loop;
};
struct GeoclueGeocodeClass
......@@ -71,6 +71,10 @@ gboolean geoclue_geocode_to_lat_lon (GeoclueGeocode *obj, const char * IN_street
gboolean geoclue_geocode_free_text_to_lat_lon (GeoclueGeocode *obj, const char * IN_free_text, gdouble* OUT_latitude, gdouble* OUT_longitude, gint* OUT_return_code, GError **error );
gboolean geoclue_geocode_lat_lon_to_address(GeoclueGeocode *obj, gdouble IN_latitude, gdouble IN_longitude, char ** OUT_street, char ** OUT_city, char ** OUT_state, char ** OUT_zip, gint* OUT_return_code, GError **error );
gboolean geoclue_geocode_service_available(GeoclueGeocode *obj, gboolean* OUT_available, char** OUT_reason, GError** error);
gboolean geoclue_geocode_shutdown(GeoclueGeocode *obj, GError** error);
......
org.foinse_project.geoclue.geocode.yahoo
/org/foinse_project/geoclue/geocode/yahoo
org.foinse_project.geoclue.geocode
Yahoo Geocoding API
\ No newline at end of file
......@@ -22,8 +22,11 @@ AM_CPPFLAGS = $(YAHOO_CFLAGS) -I$(top_srcdir)
AM_LDFLAGS = $(YAHOO_LIBS)
EXTRA_DIST = \
geoclue_map_server_yahoo.h \
map_yahoo.desc \
$(service_in_files)
BUILT_SOURCES = \
geoclue_map_signal_marshal.c \
geoclue_map_signal_marshal.h \
......@@ -36,6 +39,12 @@ CLEANFILES = \
geoclue_map_server_glue.h \
$(service_files)
backendregistrationdir = $(datadir)/geoclue/backend
backendregistration_DATA = \
map_yahoo.desc
geoclue_map_server_glue.h:../../geoclue/map_glue.xml
$(DBUS_BINDING_TOOL) --prefix=geoclue_map --mode=glib-server $< | sed 's;\data = user_data;\data = (DBusGAsyncData\*)user_data;g' > $@
......
......@@ -508,6 +508,16 @@ gboolean geoclue_map_find_zoom_level (GeoclueMap *obj, const gdouble IN_latitude
}
gboolean geoclue_map_service_available(GeoclueMap *obj, gboolean* OUT_available, char** OUT_reason, GError** error)
{
return TRUE;
}
gboolean geoclue_map_shutdown(GeoclueMap *obj, GError** error)
{
g_main_loop_quit (obj->loop);
return TRUE;
}
......@@ -521,8 +531,7 @@ int main( int argc,
g_thread_init (NULL);
GMainLoop* loop = g_main_loop_new(NULL,TRUE);
/*
......@@ -536,14 +545,17 @@ int main( int argc,
GeoclueMap* obj = NULL;
obj = GEOCLUE_MAP(g_type_create_instance (geoclue_map_get_type()));
obj->loop = g_main_loop_new(NULL,TRUE);
g_main_loop_run(loop);
g_main_loop_run(obj->loop);
g_object_unref(obj);
g_main_loop_unref(loop);
g_main_loop_unref(obj->loop);
return 0;
......
......@@ -52,6 +52,8 @@ struct GeoclueMap
gboolean pending_request;
GMainLoop* loop;
};
......@@ -86,6 +88,8 @@ gboolean geoclue_map_latlong_to_offset(GeoclueMap *obj, const gdouble IN_latitud
gboolean geoclue_map_offset_to_latlong(GeoclueMap *obj, const int IN_x_offset,const int IN_y_offset, const gint IN_zoom, const gdouble IN_center_latitude, const gdouble IN_center_longitude, gdouble* OUT_latitude, gdouble* OUT_longitude, GError **error );
gboolean geoclue_map_find_zoom_level (GeoclueMap *obj, const gdouble IN_latitude_top_left, const gdouble IN_longitude_top_left, const gdouble IN_latitude_bottom_right, const gdouble IN_longitude_bottom_right, const gint IN_width, const gint IN_height, gint* OUT_zoom, GError** error);
gboolean geoclue_map_service_available(GeoclueMap *obj, gboolean* OUT_available, char** OUT_reason, GError** error);
gboolean geoclue_map_shutdown(GeoclueMap *obj, GError** error);
......
org.foinse_project.geoclue.map.yahoo
/org/foinse_project/geoclue/map/yahoo
org.foinse_project.geoclue.map
Yahoo Maps API
\ No newline at end of file
bin_PROGRAMS = geoclue-position-server-gpsd
geoclue_position_server_gpsd_SOURCES = geoclue_position_server_gpsd.c \
geoclue_position_signal_marshal.c
service_in_files = org.foinse_project.geoclue.position.gpsd.service.in
service_files = $(service_in_files:.service.in=.service)
# D-Bus service descriptor installation
servicedir = $(DBUS_SERVICES_DIR)
service_DATA = $(service_files)
execdir = @bindir@
$(service_DATA): $(service_in_files) Makefile
for f in $(service_in_files) ; do \
sed -e 's;@execdir@;$(execdir);' $< > $@ ;\
done
AM_CPPFLAGS = $(YAHOO_CFLAGS) -I$(top_srcdir)
AM_LDFLAGS = $(YAHOO_LIBS) ../../geoclue/libgeoclue.la -lgps
EXTRA_DIST = \
geoclue_position_server_gpsd.h \
position_gpsd.desc \
$(service_in_files)
BUILT_SOURCES = \
geoclue_position_signal_marshal.c \
geoclue_position_signal_marshal.h \
geoclue_position_server_glue.h \
$(service_files)
CLEANFILES = \
geoclue_position_signal_marshal.c \
geoclue_position_signal_marshal.h \
geoclue_position_server_glue.h \
$(service_files)
backendregistrationdir = $(datadir)/geoclue/backend
backendregistration_DATA = \
position_gpsd.desc
geoclue_position_server_glue.h:../../geoclue/position_glue.xml
$(DBUS_BINDING_TOOL) --prefix=geoclue_position --mode=glib-server $< | sed 's;\data = user_data;\data = (DBusGAsyncData\*)user_data;g' > $@
geoclue_position_signal_marshal.h:../../geoclue/position_signal_marshal.list
glib-genmarshal --prefix _geoclue_position --header $< > $@
geoclue_position_signal_marshal.c:../../geoclue/position_signal_marshal.list
glib-genmarshal --prefix _geoclue_position --body $< > $@
/* Geoclue - A DBus api and wrapper for geography information
* Copyright (C) 2006 Garmin
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <geoclue_position_server_gpsd.h>
#include <geoclue_position_server_glue.h>
#include <geoclue_position_signal_marshal.h>
#include <dbus/dbus-glib-bindings.h>
#include <libxml/xmlreader.h>
#include <libsoup/soup.h>
#include <fcntl.h>
#include <stdlib.h>
#include <math.h>
#define PROGRAM_HEIGHT 640
#define PROGRAM_WIDTH 480
#define DEFAULT_LAT 38.857
#define DEFAULT_LON -94.8
#define DEFAULT_ZOOM 8
#define DEFAULT_LAT_STRING "38.857"
#define DEFAULT_LON_STRING "-94.8"
#define DEFAULT_ZOOM_STRING "8"
G_DEFINE_TYPE(GeocluePosition, geoclue_position, G_TYPE_OBJECT)
enum {
CURRENT_POSITION_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
//Default handler
void geoclue_position_current_position_changed(GeocluePosition* obj, gdouble lat, gdouble lon)
{
g_print("Current Position Changed\n");
}
static void
geoclue_position_init (GeocluePosition *obj)
{
GError *error = NULL;
DBusGProxy *driver_proxy;
GeocluePositionClass *klass = GEOCLUE_POSITION_GET_CLASS(obj);
guint request_ret;
dbus_g_connection_register_g_object (klass->connection,
GEOCLUE_POSITION_DBUS_PATH ,
G_OBJECT (obj));
driver_proxy = dbus_g_proxy_new_for_name (klass->connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
if(!org_freedesktop_DBus_request_name (driver_proxy,
GEOCLUE_POSITION_DBUS_SERVICE,
0, &request_ret,
&error))
{
g_printerr("Unable to register geoclue service: %s", error->message);
g_error_free (error);
}
}
static void
geoclue_position_class_init (GeocluePositionClass *klass)
{
GError *error = NULL;
klass->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
signals[CURRENT_POSITION_CHANGED] =
g_signal_new ("current_position_changed",
TYPE_GEOCLUE_POSITION,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GeocluePositionClass, current_position_changed),
NULL,
NULL,
_geoclue_position_VOID__DOUBLE_DOUBLE,
G_TYPE_NONE, 2 ,G_TYPE_DOUBLE, G_TYPE_DOUBLE);
klass->current_position_changed = geoclue_position_current_position_changed;
if (klass->connection == NULL)
{
g_printerr("Unable to connect to dbus: %s", error->message);
g_error_free (error);
return;
}
dbus_g_object_type_install_info (TYPE_GEOCLUE_POSITION, &dbus_glib_geoclue_position_object_info);
}
gboolean geoclue_position_version (GeocluePosition *obj, gint* OUT_major, gint* OUT_minor, gint* OUT_micro, GError **error)
{
*OUT_major = 1;
*OUT_minor = 0;
*OUT_micro = 0;
return TRUE;
}
gboolean geoclue_position_service_provider(GeocluePosition *obj, char** name, GError **error)
{
*name = "gpsd";
return TRUE;
}
gboolean geoclue_position_current_position(GeocluePosition *obj, gdouble* OUT_latitude, gdouble* OUT_longitude, GError **error )
{
g_print(" Querying GPSD\n");
gps_query(obj->gpsdata, "w+x\n");
*OUT_latitude = obj->gpsdata->fix.latitude;
*OUT_longitude = obj->gpsdata->fix.longitude;
g_print("Sending back %f %f\n", *OUT_latitude, *OUT_longitude);
//*OUT_latitude = obj->gpsdata->newdata.latitude;
//*OUT_longitude = obj->gpsdata->newdata.longitude;
// g_print("Sending back %f %f\n", *OUT_latitude, *OUT_longitude);
return TRUE;
}
gboolean geoclue_position_current_position_error(GeocluePosition *obj, gdouble* OUT_latitude_error, gdouble* OUT_longitude_error, GError **error )
{
return FALSE;
}
gboolean geoclue_position_current_altitude(GeocluePosition *obj, gdouble* OUT_altitude, GError **error )
{
return FALSE;
}
gboolean geoclue_position_current_velocity(GeocluePosition *obj, gdouble* OUT_north_velocity, gdouble* OUT_east_velocity, GError **error )
{
return FALSE;
}
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 )
{
return FALSE;
}
gboolean geoclue_position_satellites_in_view(GeocluePosition *obj, GArray** OUT_prn_numbers, GError **error )
{
return FALSE;
}
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 )
{
return FALSE;
}
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 )
{
return FALSE;
}
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 )
{
return FALSE;
}
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 )
{
return FALSE;
}
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 )
{
return FALSE;
}
gboolean geoclue_position_service_available(GeocluePosition *obj, gboolean* OUT_available, char** OUT_reason, GError** error)
{
return TRUE;
}
gboolean geoclue_position_shutdown(GeocluePosition *obj, GError** error)
{
g_main_loop_quit (obj->loop);
return TRUE;
}
static void update_gps(struct gps_data_t *gpsdata,
char *message,
size_t len, int level)
{
g_print("Callback %s\n", message);
}
int main(int argc, char **argv)
{
guint request_name_result;
g_type_init ();
g_thread_init (NULL);
printf("Starting GPSD\n");
/*
* this initialize the library and check potential ABI mismatches
* between the version it was compiled for and the actual shared
* library used.
*/
LIBXML_TEST_VERSION
GeocluePosition* obj = NULL;
obj = GEOCLUE_POSITION(g_type_create_instance (geoclue_position_get_type()));
obj->loop = g_main_loop_new(NULL,TRUE);
char *server = NULL, *port = DEFAULT_GPSD_PORT;
obj->gpsdata = gps_open(server, port);
if(obj->gpsdata)
{
gps_set_raw_hook(obj->gpsdata, update_gps);
printf("Success running main loop\n");
g_main_loop_run(obj->loop);
gps_close(obj->gpsdata);
g_object_unref(obj);
g_main_loop_unref(obj->loop);
}
else
{
g_printerr("Cannot Find GPSD\n");
}
return(0);
}
/* Geoclue - A DBus api and wrapper for geography information
* Copyright (C) 2006 Garmin
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU