Ejemplo n.º 1
0
static void
osd_rocket_init(struct navit *nav)
{
    struct rocket *rocket=g_new0(struct rocket, 1);
    struct attr attr;
    rocket->navit=nav;
    rocket->callback=callback_new_1(callback_cast(pedestrian_rocket_idle), rocket);
    if (navit_get_attr(nav, attr_layout, &attr, NULL))
        rocket->layout=attr.u.layout;
    if (navit_get_attr(nav, attr_callback_list, &attr, NULL)) {
        dbg(0,"ok\n");
        command_add_table(attr.u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), rocket);
    }
}
Ejemplo n.º 2
0
static PyObject *
navit_get_attr_py(navitObject *self, PyObject *args)
{
	char *name;
	struct attr attr;
	if (!PyArg_ParseTuple(args, "s", &name))
		return NULL;
	if (!navit_get_attr(self->navit, attr_from_name(name), &attr, NULL)) {
		dbg(0,"get_attr not ok\n");
		Py_RETURN_NONE;
	}
	dbg(0,"get_attr ok\n");
	return python_object_from_attr(&attr);
}
Ejemplo n.º 3
0
static void button_bookmark(GtkWidget *widget, struct search_param *search)
{
	struct pcoord *c=NULL;
	GtkTreeIter iter;
	char *desc;
	struct attr attr;

	if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
		return;
	gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
	if (c) {
		navit_get_attr(search->nav, attr_bookmarks, &attr, NULL);
		desc=description(search, &iter);
		bookmarks_add_bookmark(attr.u.bookmarks, c, desc);
		g_free(desc);
	}
}
Ejemplo n.º 4
0
static void
popup_set_bookmark(struct navit *nav, struct pcoord *pc)
{
    struct attr attr;
	struct coord c;
	struct coord_geo g;
	char buffer[1024];
	char buffer_geo[1024];
	c.x = pc->x;
	c.y = pc->y;
	transform_to_geo(pc->pro, &c, &g);
	coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
	sprintf(buffer,"Map Point %s", buffer_geo);
	if (!gui_add_bookmark(navit_get_gui(nav), pc, buffer)) {
        navit_get_attr(nav, attr_bookmarks, &attr, NULL);
		bookmarks_add_bookmark(attr.u.bookmarks, pc, buffer);
    }
}
Ejemplo n.º 5
0
static void
bookmarks_emit_dbus_signal(struct bookmarks *this_, struct pcoord *c, const char *description,int create)
{
    struct attr attr1,attr2,attr3,attr4,cb,*attr_list[5];
	int valid=0;
	attr1.type=attr_type;
	attr1.u.str="bookmark";
    attr2.type=attr_data;
    attr2.u.str=create ? "create" : "delete";
	attr3.type=attr_data;
	attr3.u.str=(char *)description;
    attr4.type=attr_coord;
    attr4.u.pcoord=c;
	attr_list[0]=&attr1;
	attr_list[1]=&attr2;
    attr_list[2]=&attr3;
    attr_list[3]=&attr4;
	attr_list[4]=NULL;
	if (navit_get_attr(this_->parent->u.navit, attr_callback_list, &cb, NULL))
		callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
}
Ejemplo n.º 6
0
/**
 * @brief Sets the layout to \a new_layout_name extracted from \a message
 * @param connection The DBusConnection object through which \a message arrived
 * @param message The DBusMessage containing the name of the layout
 * @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
 */
static DBusHandlerResult
request_navit_set_layout(DBusConnection *connection, DBusMessage *message)
{
	char *new_layout_name;
	struct navit *navit;
	struct attr attr;
	struct attr_iter *iter;

	navit=object_get_from_message(message, "navit");
	if (! navit)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	
    if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &new_layout_name, DBUS_TYPE_INVALID))
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	
    iter=navit_attr_iter_new();
	while(navit_get_attr(navit, attr_layout, &attr, iter)) {
		if (strcmp(attr.u.layout->name, new_layout_name) == 0) {
			navit_set_attr(navit, &attr);
		}
	}
	return empty_reply(connection, message);
}
Ejemplo n.º 7
0
static void *
resolve_object(const char *opath, char *type)
{
	char *prefix;
	void *ret=NULL;
	char *def_navit="/default_navit";
	char *def_graphics="/default_graphics";
	struct attr attr;

	if (strncmp(opath, object_path, strlen(object_path))) {
		dbg(0,"wrong object path %s\n",opath);
		return NULL;
	}
	prefix=g_strdup_printf("%s/%s/", object_path, type);
	if (!strncmp(prefix, opath, strlen(prefix))) {
		ret=object_get(opath);
		g_free(prefix);
		return ret;
	}
	g_free(prefix);
	prefix=opath+strlen(object_path);
	if (!strncmp(prefix,def_navit,strlen(def_navit))) {
		prefix+=strlen(def_navit);
		struct navit *navit=main_get_navit(NULL);
		if (!prefix[0]) {
			dbg(0,"default_navit\n");
			return navit;
		}
		if (!strncmp(prefix,def_graphics,strlen(def_graphics))) {
			if (navit_get_attr(navit, attr_graphics, &attr, NULL)) {
				return attr.u.graphics;
			}
			return NULL;
		}
	}
	return NULL;
}
Ejemplo n.º 8
0
static DBusHandlerResult
request_navit_get_attr(DBusConnection *connection, DBusMessage *message)
{
    struct navit *navit;
    DBusMessageIter iter;
    char * attr_type = NULL;
    struct attr attr;
    navit = object_get_from_message(message, "navit");
    if (! navit)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    dbus_message_iter_init(message, &iter);
    dbus_message_iter_get_basic(&iter, &attr_type);
    attr.type = attr_from_name(attr_type); 
    dbg(0, "attr value: 0x%x string: %s\n", attr.type, attr_type);

    if (attr.type == attr_none)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
    
    if (attr.type > attr_type_item_begin && attr.type < attr_type_item_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if (attr.type > attr_type_int_begin && attr.type < attr_type_boolean_begin)
    {
        dbg(0, "int detected\n");
        if(navit_get_attr(navit, attr.type, &attr, NULL)) {
            dbg(0, "%s = %i\n", attr_type, attr.u.num);
            return reply_simple_as_variant(connection, message, attr.u.num, DBUS_TYPE_INT32);
        }
    }

    else if(attr.type > attr_type_boolean_begin && attr.type < attr_type_int_end)
    {
        dbg(0, "bool detected\n");
        if(navit_get_attr(navit, attr.type, &attr, NULL)) {
            dbg(0, "%s = %i\n", attr_type, attr.u.num);
            return reply_simple_as_variant(connection, message, attr.u.num, DBUS_TYPE_BOOLEAN);
        }
    }

    else if(attr.type > attr_type_string_begin && attr.type < attr_type_string_end)
    {
        dbg(0, "string detected\n");
        if(navit_get_attr(navit, attr.type, &attr, NULL)) {
            dbg(0, "%s = %s\n", attr_type, &attr.u.layout);
            return reply_simple_as_variant(connection, message, &attr.u.layout, DBUS_TYPE_STRING);
        }
    }

#if 0
    else if(attr.type > attr_type_special_begin && attr.type < attr_type_special_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_double_begin && attr.type < attr_type_double_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_coord_geo_begin && attr.type < attr_type_coord_geo_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_color_begin && attr.type < attr_type_color_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_object_begin && attr.type < attr_type_object_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_coord_begin && attr.type < attr_type_coord_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_pcoord_begin && attr.type < attr_type_pcoord_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_callback_begin && attr.type < attr_type_callback_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
#endif
    else {
        dbg(0, "zomg really unhandled111\n");
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
    }

    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
Ejemplo n.º 9
0
static void
pedestrian_cmd_pedestrian_rocket(struct rocket *rocket)
{
    struct attr attr;
    int max=0;
#if 0
    int i,step=10;
#endif
    rocket->a=2;
    rocket->g=1;
    rocket->t=100;
    rocket->hog=0;
    rocket->v=0;
    rocket->vscale=10;
    if (! navit_get_attr(rocket->navit, attr_graphics, &attr, NULL))
        return;
    rocket->gra=attr.u.graphics;
    if (! navit_get_attr(rocket->navit, attr_transformation, &attr, NULL))
        return;
    rocket->trans=attr.u.transformation;
    if (! navit_get_attr(rocket->navit, attr_displaylist, &attr, NULL))
        return;
    rocket->dl=attr.u.displaylist;
    if (! navit_get_attr(rocket->navit, attr_mapset, &attr, NULL))
        return;
    rocket->ms=attr.u.mapset;
    transform_set_hog(rocket->trans, max);
    transform_set_order_base(rocket->trans, 14);
    transform_set_scale(rocket->trans, transform_get_scale(rocket->trans));
    transform_setup_source_rect(rocket->trans);
    graphics_overlay_disable(rocket->gra, 1);
    graphics_draw(rocket->gra, rocket->dl, rocket->ms, rocket->trans, rocket->layout, 0, NULL, 0);
    sensors_locked=1;
    if (!rocket->idle)
        rocket->idle=event_add_idle(50, rocket->callback);
#if 0
    while (hog >= 0) {
        transform_set_hog(trans, hog);
#if 0
        graphics_draw(gra, dl, ms, trans, layout, 0, NULL);
#else
        graphics_displaylist_draw(gra, dl, trans, layout, 0);
#endif
        v=v+a-g;
        if (t > 0)
            t--;
        else
            a=0;
        hog=hog+v/vscale;
    }
#if 0
    for (i = 0 ; i < max ; i+=step) {
        transform_set_hog(trans, i);
        graphics_displaylist_draw(gra, dl, trans, layout, 0);
    }
    for (i = max ; i >= 0 ; i-=step) {
        transform_set_hog(trans, i);
        graphics_displaylist_draw(gra, dl, trans, layout, 0);
    }
#endif
#endif
}