Add:vehicle_gypsy:Option to send dbus message for enabling gps at startup
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 10 Feb 2011 11:27:12 +0000 (11:27 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 10 Feb 2011 11:27:12 +0000 (11:27 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4124 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/attr_def.h
navit/navit/vehicle/gypsy/Makefile.am
navit/navit/vehicle/gypsy/vehicle_gypsy.c

index d051086..69ee95e 100644 (file)
@@ -338,6 +338,10 @@ ATTR(http_header)
 ATTR(progress)
 ATTR(sample_dir)
 ATTR(sample_suffix)
+ATTR(dbus_destination)
+ATTR(dbus_path)
+ATTR(dbus_interface)
+ATTR(dbus_method)
 ATTR2(0x0003ffff,type_string_end)
 ATTR2(0x00040000,type_special_begin)
 ATTR(order)
index ed6aba4..1e997f2 100644 (file)
@@ -1,5 +1,5 @@
 include $(top_srcdir)/Makefile.inc
-AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=vehicle_gypsy
+AM_CPPFLAGS = @NAVIT_CFLAGS@ @DBUS_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=vehicle_gypsy
 modulevehicle_LTLIBRARIES = libvehicle_gypsy.la
 libvehicle_gypsy_la_SOURCES = vehicle_gypsy.c
 libvehicle_gypsy_la_LIBADD = @GYPSY_LIBS@
index ae4a150..a49e9bd 100644 (file)
 #include <gypsy/gypsy-course.h>
 #include <gypsy/gypsy-position.h>
 #include <gypsy/gypsy-satellite.h>
+#ifdef USE_BINDING_DBUS
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <sys/types.h>
+#include <unistd.h>
+#endif
 #include <string.h>
 #include <glib.h>
 #include <math.h>
@@ -429,6 +438,29 @@ vehicle_gypsy_new_gypsy(struct vehicle_methods *meth,
        struct vehicle_priv *ret;
        struct attr *source, *retry_int;
 
+#if defined(USE_BINDING_DBUS) && defined(HAVE_UNISTD_H)
+       DBusConnection *conn;
+       DBusMessage *message;
+       dbus_uint32_t serial,pid=getpid();
+       struct attr *destination,*path,*interface,*method;
+
+       destination=attr_search(attrs, NULL, attr_dbus_destination);
+       path=attr_search(attrs, NULL, attr_dbus_path);
+       interface=attr_search(attrs, NULL, attr_dbus_interface);
+       method=attr_search(attrs, NULL, attr_dbus_method);
+       if (destination && path && interface && method) {
+               conn=dbus_bus_get(DBUS_BUS_SESSION, NULL);
+               if (conn) {
+                       message=dbus_message_new_method_call(destination->u.str,path->u.str,interface->u.str,method->u.str);
+                       dbus_message_append_args(message, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
+                       dbus_connection_send(conn, message, &serial);
+                       dbus_message_unref(message);
+                       dbus_connection_unref(conn);
+               } else {
+                       dbg(0,"failed to connect to session bus\n");
+               }
+       }
+#endif
        dbg(1, "enter\n");
        source = attr_search(attrs, NULL, attr_source);
        ret = g_new0(struct vehicle_priv, 1);