summaryrefslogtreecommitdiff
path: root/navit/speech/dbus/speech_dbus.c
blob: a3d60620c42e75fa087a6ace7cc513265d7f65b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
 * Navit, a modular navigation system.
 * Copyright (C) 2005-2008 Navit Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */

#include <stdlib.h>
#include <glib.h>
#include "config.h"
#include "item.h"
#include "plugin.h"
#include "navit.h"
#include "attr.h"
#include "callback.h"
#include "speech.h"

struct speech_priv {
    struct navit *nav;
};

static int speech_dbus_say(struct speech_priv *this, const char *text) {
    struct attr attr1,attr2,cb,*attr_list[3];
    int valid=0;
    attr1.type=attr_type;
    attr1.u.str="speech";
    attr2.type=attr_data;
    attr2.u.str=(char *)text;
    attr_list[0]=&attr1;
    attr_list[1]=&attr2;
    attr_list[2]=NULL;
    if (navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
        callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
    return 0;
}

static void speech_dbus_destroy(struct speech_priv *this) {
    g_free(this);
}

static struct speech_methods speech_dbus_meth = {
    speech_dbus_destroy,
    speech_dbus_say,
};

static struct speech_priv *speech_dbus_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
    struct speech_priv *this;
    if (!parent || parent->type != attr_navit)
        return NULL;
    this=g_new(struct speech_priv,1);
    this->nav=parent->u.navit;
    *meth=speech_dbus_meth;
    return this;
}


void plugin_init(void) {
    plugin_register_category_speech("dbus", speech_dbus_new);
}