~ubuntu-branches/ubuntu/saucy/navit/saucy-proposed

« back to all changes in this revision

Viewing changes to navit/command.c

  • Committer: Package Import Robot
  • Author(s): Gilles Filippini
  • Date: 2012-01-30 21:46:45 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20120130214645-mjvkslctpagferf3
Tags: 0.5.0~svn4909+dfsg.1-1
* New upstream snapshot:
  + GUI Internal:
    . Former destinations list
    . Support for saving GUI settings
    . Made search result lists pageable when onscreen keyboard is hidden
  + GUI GTK:
    . Menu accelerators
  + New profile to calculate shortest car route
* Drop patches:
  + manpage-minus-signs.patch: applied upstream
  + search_trick: not needed anymore (search result lists now pageable)
* Update patch fix-cmake.patch: partially applied upstream
* Refresh patches:
  + icons-dir
  + qt-cmake.patch
* debian/README.source: acknowledge removal of navit/binding/win32 from
  upstream tarball

* debian/rules: s/GNU_TYPE/MULTIARCH/g

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
        return func->get_attr(object->u.data, attr_type, ret, NULL);
154
154
}
155
155
 
 
156
static int
 
157
command_object_add_attr(struct context *ctx, struct attr *object, struct attr *attr)
 
158
{
 
159
        struct object_func *func=object_func_lookup(object->type);
 
160
        if (!func || !func->add_attr)
 
161
                return 0;
 
162
        return func->add_attr(object->u.data, attr);
 
163
}
 
164
 
 
165
static int
 
166
command_object_remove_attr(struct context *ctx, struct attr *object, struct attr *attr)
 
167
{
 
168
        struct object_func *func=object_func_lookup(object->type);
 
169
        if (!func || !func->remove_attr)
 
170
                return 0;
 
171
        return func->remove_attr(object->u.data, attr);
 
172
}
 
173
 
 
174
 
156
175
static void
157
176
command_get_attr(struct context *ctx, struct result *res)
158
177
{
180
199
        struct object_func *func=object_func_lookup(res->attr.type);
181
200
        if (!func || !func->set_attr)
182
201
                return;
 
202
        if (attr_type == attr_attr_types) {
 
203
                char *attrn=g_alloca(sizeof(char)*(res->attrnlen+1));
 
204
                struct attr *tmp;
 
205
                strncpy(attrn, res->attrn, res->attrnlen);
 
206
                attrn[res->attrnlen]='\0';
 
207
                tmp=attr_new_from_text(attrn, newres->attr.u.str);
 
208
                newres->attr.u.data=tmp->u.data;
 
209
                g_free(tmp);
 
210
        }
183
211
        newres->attr.type=attr_type;
184
212
        result=func->set_attr(res->attr.u.data, &newres->attr);
185
213
        *res=*newres;
258
286
eval_value(struct context *ctx, struct result *res) {
259
287
        const char *op;
260
288
        int len,dots=0;
 
289
        struct obj_filter_t out;
 
290
        int parsed_chars;
 
291
 
261
292
        op=ctx->expr;
262
293
        res->varlen=0;
263
294
        res->var=NULL;
268
299
                op++;
269
300
        }
270
301
 
271
 
        struct obj_filter_t out;
272
 
        int parsed_chars = parse_obj_filter(op, &out);
 
302
        parsed_chars = parse_obj_filter(op, &out);
273
303
        if (parsed_chars) {
274
304
                struct attr* res_attr = filter_object(ctx->attr, out.iterator_type, out.filter_expr, out.idx);
275
305
                if (res_attr) {
404
434
                        struct object_func *func=object_func_lookup(attr_type);
405
435
                        if (func && func->create) {
406
436
                                res->attr.type=attr_type;
407
 
                                res->attr.u.data=func->create(NULL, list);
 
437
                                res->attr.u.data=func->create(list[0], list+1);
408
438
                        }
409
439
                }
 
440
        } else if (!strcmp(function,"add_attr")) {
 
441
                command_object_add_attr(ctx, &res->attr, list[0]);
 
442
        } else if (!strcmp(function,"remove_attr")) {
 
443
                command_object_remove_attr(ctx, &res->attr, list[0]);
410
444
        } else {
411
445
                if (command_object_get_attr(ctx, &res->attr, attr_callback_list, &cbl)) {
412
 
                        int valid;
 
446
                        int valid =0;
413
447
                        struct attr **out=NULL;
414
448
                        dbg(1,"function call %s from %s\n",function, attr_to_name(res->attr.type));
415
449
                        callback_list_call_attr_4(cbl.u.callback_list, attr_command, function, list, &out, &valid);
 
450
                        if (valid!=1){
 
451
                                dbg(0, "invalid command ignored: \"%s\"; see http://wiki.navit-project.org/index.php/"
 
452
                                    "The_Navit_Command_Interface for valid commands.\n", function);
 
453
                        }
416
454
                        if (out && out[0]) {
417
455
                                attr_dup_content(out[0], &res->attr);
418
456
                                attr_list_free(out);