summaryrefslogtreecommitdiff
path: root/navit/binding
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-24 07:29:38 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-24 07:29:38 +0000
commit622fc44d62c38c1b60253aafda777dc91936d952 (patch)
tree2170f0880cb9076e4e7ffe3ef2b1b1783a7fcb2b /navit/binding
parenta208595ffbd2facfefe5dd7a5254695d9f1fae82 (diff)
downloadnavit-622fc44d62c38c1b60253aafda777dc91936d952.tar.gz
Add:binding_dbus:gui bindings
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2794 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/binding')
-rw-r--r--navit/binding/dbus/binding_dbus.c58
-rwxr-xr-xnavit/binding/dbus/eval.py6
2 files changed, 58 insertions, 6 deletions
diff --git a/navit/binding/dbus/binding_dbus.c b/navit/binding/dbus/binding_dbus.c
index ca24d115b..c0b2f843c 100644
--- a/navit/binding/dbus/binding_dbus.c
+++ b/navit/binding/dbus/binding_dbus.c
@@ -40,6 +40,7 @@
#include "mapset.h"
#include "search.h"
#include "callback.h"
+#include "gui.h"
#include "util.h"
@@ -113,6 +114,7 @@ resolve_object(const char *opath, char *type)
const char *oprefix;
void *ret=NULL;
char *def_navit="/default_navit";
+ char *def_gui="/default_gui";
char *def_graphics="/default_graphics";
char *def_vehicle="/default_vehicle";
char *def_mapset="/default_mapset";
@@ -146,6 +148,12 @@ resolve_object(const char *opath, char *type)
}
return NULL;
}
+ if (!strncmp(oprefix,def_gui,strlen(def_gui))) {
+ if (navit_get_attr(navit.u.navit, attr_gui, &attr, NULL)) {
+ return attr.u.gui;
+ }
+ return NULL;
+ }
if (!strncmp(oprefix,def_vehicle,strlen(def_vehicle))) {
if (navit_get_attr(navit.u.navit, attr_vehicle, &attr, NULL)) {
return attr.u.vehicle;
@@ -636,6 +644,31 @@ request_get_attr(DBusConnection *connection, DBusMessage *message, char *type, v
}
static DBusHandlerResult
+request_command(DBusConnection *connection, DBusMessage *message, char *type, void *data, int (*func)(void *data, enum attr_type type, struct attr *attr, struct attr_iter *iter))
+{
+ DBusMessageIter iter;
+ struct attr attr;
+ char *command;
+
+ if (! data)
+ data = object_get_from_message(message, type);
+ if (! data)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &command);
+ dbus_message_iter_next(&iter);
+ if (func(data, attr_callback_list, &attr, NULL)) {
+ int valid=0;
+ callback_list_call_attr_4(attr.u.callback_list, attr_command, command, NULL, NULL, &valid);
+ }
+ return empty_reply(connection, message);
+
+}
+
+static DBusHandlerResult
request_set_add_remove_attr(DBusConnection *connection, DBusMessage *message, char *type, void *data, int (*func)(void *data, struct attr *attr))
{
struct attr attr;
@@ -770,6 +803,22 @@ request_graphics_get_data(DBusConnection *connection, DBusMessage *message)
return empty_reply(connection, message);
}
+/* gui */
+
+static DBusHandlerResult
+request_gui_get_attr(DBusConnection *connection, DBusMessage *message)
+{
+ return request_get_attr(connection, message, "gui", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))gui_get_attr);
+}
+
+static DBusHandlerResult
+request_gui_command(DBusConnection *connection, DBusMessage *message)
+{
+ return request_command(connection, message, "gui", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))gui_get_attr);
+}
+
+
+
static DBusHandlerResult
request_graphics_set_attr(DBusConnection *connection, DBusMessage *message)
{
@@ -1168,7 +1217,7 @@ request_navit_evaluate(DBusConnection *connection, DBusMessage *message)
char *result;
struct attr attr;
DBusMessage *reply;
- int *error;
+ int error;
navit = object_get_from_message(message, "navit");
if (! navit)
@@ -1181,8 +1230,8 @@ request_navit_evaluate(DBusConnection *connection, DBusMessage *message)
result=command_evaluate_to_string(&attr, command, &error);
reply = dbus_message_new_method_return(message);
if (error)
- dbus_message_append_args(reply, DBUS_TYPE_INT32, error, DBUS_TYPE_INVALID);
- else
+ dbus_message_append_args(reply, DBUS_TYPE_INT32, &error, DBUS_TYPE_INVALID);
+ else if (result)
dbus_message_append_args(reply, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
dbus_connection_send (connection, reply, NULL);
dbus_message_unref (reply);
@@ -1371,6 +1420,9 @@ struct dbus_method {
{".callback","destroy", "", "", "", "", request_callback_destroy},
{".graphics","get_data", "s", "type", "ay", "data", request_graphics_get_data},
{".graphics","set_attr", "sv", "attribute,value", "", "", request_graphics_set_attr},
+ {".gui", "get_attr", "s", "attribute", "sv", "attrname,value", request_gui_get_attr},
+ {".gui", "command_parameter", "sa{sa{sv}}","command,parameter", "a{sa{sv}}", "return", request_gui_command},
+ {".gui", "command", "s", "command", "a{sa{sv}}", "return", request_gui_command},
{".navit", "draw", "", "", "", "", request_navit_draw},
{".navit", "add_message", "s", "message", "", "", request_navit_add_message},
{".navit", "set_center", "s", "(coordinates)", "", "", request_navit_set_center},
diff --git a/navit/binding/dbus/eval.py b/navit/binding/dbus/eval.py
index 2255f968b..a2e1926fd 100755
--- a/navit/binding/dbus/eval.py
+++ b/navit/binding/dbus/eval.py
@@ -5,8 +5,8 @@ bus = dbus.SessionBus()
conn = bus.get_object('org.navit_project.navit',
'/org/navit_project/navit')
iface = dbus.Interface(conn, dbus_interface='org.navit_project.navit');
-iter=iface.iter();
-navit=bus.get_object('org.navit_project.navit', conn.get_navit(iter));
-iface.iter_destroy(iter);
+iter=iface.attr_iter();
+navit=bus.get_object('org.navit_project.navit', conn.get_attr_wi('navit',iter)[1]);
+iface.attr_iter_destroy(iter);
navit_iface = dbus.Interface(navit, dbus_interface='org.navit_project.navit.navit');
print navit_iface.evaluate(sys.argv[1]);