summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/attr_def.h1
-rw-r--r--navit/main.c35
-rw-r--r--navit/main.h2
-rw-r--r--navit/navit.c8
4 files changed, 44 insertions, 2 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index 0bcf4f6c6..199be1fad 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -225,6 +225,7 @@ ATTR(osd)
ATTR(plugin)
ATTR(speech)
ATTR(coord)
+ATTR(private_data)
ATTR2(0x0008ffff,type_object_end)
ATTR2(0x00090000,type_coord_begin)
ATTR2(0x0009ffff,type_coord_end)
diff --git a/navit/main.c b/navit/main.c
index a54778254..18499a66e 100644
--- a/navit/main.c
+++ b/navit/main.c
@@ -44,6 +44,7 @@
#include "route.h"
#include "navigation.h"
#include "event.h"
+#include "callback.h"
#include "navit_nls.h"
#if HAVE_API_WIN32_BASE
#include <windows.h>
@@ -53,6 +54,9 @@
struct map_data *map_data_default;
+struct callback_list *cbl;
+
+
static void sigchld(int sig)
{
#if !defined(_WIN32) && !defined(__CEGCC__)
@@ -120,16 +124,45 @@ void
main_add_navit(struct navit *nav)
{
navit=g_list_prepend(navit, nav);
+ callback_list_call_2(cbl, nav, 1);
}
void
main_remove_navit(struct navit *nav)
{
navit=g_list_remove(navit, nav);
+ callback_list_call_2(cbl, nav, 0);
if (! navit)
event_main_loop_quit();
}
+int
+main_add_attr(struct attr *attr)
+{
+ switch (attr->type)
+ {
+ case attr_callback:
+ callback_list_add(cbl, attr->u.callback);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int
+main_remove_attr(struct attr *attr)
+{
+ switch (attr->type)
+ {
+ case attr_callback:
+ callback_list_remove(cbl, attr->u.callback);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
#ifdef HAVE_API_WIN32
void
setenv(char *var, char *val, int overwrite)
@@ -186,7 +219,7 @@ main_init(char *program)
#ifndef _WIN32
signal(SIGCHLD, sigchld);
#endif
-
+ cbl=callback_list_new();
setenv("LC_NUMERIC","C",1);
setlocale(LC_ALL,"");
setlocale(LC_NUMERIC,"C");
diff --git a/navit/main.h b/navit/main.h
index d51979c04..f39e8e270 100644
--- a/navit/main.h
+++ b/navit/main.h
@@ -28,6 +28,8 @@ void main_iter_destroy(struct iter *iter);
struct navit * main_get_navit(struct iter *iter);
void main_add_navit(struct navit *nav);
void main_remove_navit(struct navit *nav);
+int main_add_attr(struct attr *attr);
+int main_remove_attr(struct attr *attr);
void main_init(char *program);
void main_init_nls(void);
int main(int argc, char **argv);
diff --git a/navit/navit.c b/navit/navit.c
index bf30cd713..5ef477d63 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -506,10 +506,10 @@ navit_new(struct attr *parent, struct attr **attrs)
g.lat=53.13;
g.lng=11.70;
- main_add_navit(this_);
this_->self.type=attr_navit;
this_->self.u.navit=this_;
this_->attr_cbl=callback_list_new();
+ main_add_navit(this_);
#if !defined(_WIN32) && !defined(__CEGCC__)
f=popen("pidof /usr/bin/ipaq-sleep","r");
@@ -1150,6 +1150,7 @@ navit_init(struct navit *this_)
return;
}
graphics_init(this_->gra);
+#if 0
l=this_->vehicles;
while (l) {
dbg(1,"parsed one vehicle\n");
@@ -1160,6 +1161,7 @@ navit_init(struct navit *this_)
vehicle_set_attr(nv->vehicle, &this_->self, NULL);
l=g_list_next(l);
}
+#endif
if (this_->mapsets) {
ms=this_->mapsets->data;
if (this_->route) {
@@ -1816,6 +1818,10 @@ navit_add_vehicle(struct navit *this_, struct vehicle *v)
navit_set_vehicle(this_, nv);
if ((vehicle_get_attr(v, attr_animate, &animate, NULL)))
nv->animate_cursor=animate.u.num;
+ nv->callback.type=attr_callback;
+ nv->callback.u.callback=callback_new_2(callback_cast(navit_vehicle_update), this_, nv);
+ vehicle_add_attr(nv->vehicle, &nv->callback);
+ vehicle_set_attr(nv->vehicle, &this_->self, NULL);
return 1;
}