26 |
#include "gpxview.h" |
#include "gpxview.h" |
27 |
#include "dbus.h" |
#include "dbus.h" |
28 |
|
|
29 |
|
#ifdef ENABLE_MAEMO_MAPPER |
30 |
#define MM_DBUS_SERVICE "com.gnuite.maemo_mapper" |
#define MM_DBUS_SERVICE "com.gnuite.maemo_mapper" |
31 |
#define MM_DBUS_PATH "/com/gnuite/maemo_mapper" |
#define MM_DBUS_PATH "/com/gnuite/maemo_mapper" |
32 |
#define MM_DBUS_INTERFACE "com.gnuite.maemo_mapper" |
#define MM_DBUS_INTERFACE "com.gnuite.maemo_mapper" |
33 |
|
#endif |
34 |
|
|
35 |
#include <glib.h> |
#include <glib.h> |
36 |
#include <dbus/dbus-glib-lowlevel.h> |
#include <dbus/dbus-glib-lowlevel.h> |
37 |
#include <dbus/dbus-glib.h> |
#include <dbus/dbus-glib.h> |
38 |
|
|
39 |
|
#ifdef ENABLE_MAEMO_MAPPER |
40 |
|
|
41 |
static DBusHandlerResult signal_filter |
static DBusHandlerResult signal_filter |
42 |
(DBusConnection *connection, DBusMessage *message, void *user_data); |
(DBusConnection *connection, DBusMessage *message, void *user_data); |
43 |
|
|
46 |
/* User data is the event loop we are running in */ |
/* User data is the event loop we are running in */ |
47 |
appdata_t *appdata = (appdata_t*)user_data; |
appdata_t *appdata = (appdata_t*)user_data; |
48 |
|
|
49 |
printf("got a dbus message from Maemo Mapper\n"); |
if(dbus_message_is_signal(message, MM_DBUS_SERVICE, |
50 |
|
"view_position_changed")) { |
|
if(dbus_message_is_signal(message, MM_DBUS_SERVICE, "view_position_changed")) { |
|
51 |
DBusError error; |
DBusError error; |
52 |
double lat, lon; |
double lat, lon; |
53 |
dbus_error_init (&error); |
dbus_error_init (&error); |
54 |
|
|
55 |
printf(" is \"view position changed\"\n"); |
printf("Received \"view position changed\"\n"); |
56 |
|
|
57 |
if(dbus_message_get_args |
if(dbus_message_get_args |
58 |
(message, &error, DBUS_TYPE_DOUBLE, &lat, DBUS_TYPE_DOUBLE, &lon, DBUS_TYPE_INVALID)) { |
(message, &error, DBUS_TYPE_DOUBLE, &lat, |
59 |
|
DBUS_TYPE_DOUBLE, &lon, DBUS_TYPE_INVALID)) { |
60 |
|
|
61 |
g_print(" Position received: %f/%f\n", (float)lat, (float)lon); |
g_print(" Position received: %f/%f\n", (float)lat, (float)lon); |
62 |
|
|
89 |
dbus_connection_setup_with_g_main(bus, NULL); |
dbus_connection_setup_with_g_main(bus, NULL); |
90 |
|
|
91 |
/* listening to messages from all objects as no path is specified */ |
/* listening to messages from all objects as no path is specified */ |
92 |
dbus_bus_add_match (bus, "type='signal',interface='"MM_DBUS_INTERFACE"'", &error); |
dbus_bus_add_match (bus, "type='signal',interface='"MM_DBUS_INTERFACE"'", |
93 |
|
&error); |
94 |
dbus_connection_add_filter(bus, signal_filter, appdata, NULL); |
dbus_connection_add_filter(bus, signal_filter, appdata, NULL); |
95 |
} |
} |
96 |
|
|
122 |
osso_rpc_free_val(&retval); |
osso_rpc_free_val(&retval); |
123 |
|
|
124 |
if(ret != OSSO_OK) |
if(ret != OSSO_OK) |
125 |
errorf(_("Unable to communicate with Maemo-Mapper. " |
errorf(_("Unable to communicate with Maemo Mapper. " |
126 |
"You need to have Maemo-Mapper installed " |
"You need to have Maemo Mapper installed " |
127 |
"to use this feature.")); |
"to use this feature.")); |
128 |
|
|
129 |
return(ret == OSSO_OK)?0:1; |
return(ret == OSSO_OK)?0:1; |
130 |
} |
} |
131 |
|
#endif |
132 |
|
|
133 |
#ifdef ENABLE_BROWSER_INTERFACE |
#ifdef ENABLE_BROWSER_INTERFACE |
134 |
int browser_url(appdata_t *appdata, char *url) { |
int browser_url(appdata_t *appdata, char *url) { |