~jbicha/hud/build-depend-on-valac-not-gir

« back to all changes in this revision

Viewing changes to src/hudvoice.c

  • Committer: Tarmac
  • Author(s): Ted Gould, Pete Woods, Antti Kaijanmäki, Ted Gould, Albert Astals, Ryan Lortie, Łukasz 'sil2100' Zemczak, Albert Astals Cid, Mathieu Trudel-Lapierre, Kaleo, Tarmac, Ricardo Salveti de Araujo, Michael Terry, Automatic PS uploader
  • Date: 2013-04-10 16:04:51 UTC
  • mfrom: (227.3.148 phablet)
  • Revision ID: tarmac-20130410160451-o3owpv3zaxulm5of
HUD 2.0 Merge.

Approved by PS Jenkins bot, Mathieu Trudel-Lapierre.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#define G_LOG_DOMAIN "hudvoice"
 
19
 
 
20
#include "hudvoice.h"
 
21
#include "hudsphinx.h"
 
22
#include "hudjulius.h"
 
23
 
 
24
/**
 
25
 * HudVoiceace:
 
26
 * @g_iface: the #GTypeInterface
 
27
 * @query: virtual function pointer for hud_voice_query()
 
28
 *
 
29
 * This is the interface vtable for #HudVoice.
 
30
 **/
 
31
 
 
32
G_DEFINE_INTERFACE (HudVoice, hud_voice, G_TYPE_OBJECT)
 
33
 
 
34
static void
 
35
hud_voice_default_init (HudVoiceInterface *iface)
 
36
{
 
37
}
 
38
 
 
39
HudVoice *
 
40
hud_voice_new (HudQueryIfaceComCanonicalHudQuery *skel, const gchar *device,
 
41
    GError **error)
 
42
{
 
43
  if (hud_julius_is_installed())
 
44
    return HUD_VOICE(hud_julius_new (skel));
 
45
 
 
46
  return HUD_VOICE(hud_sphinx_new (skel, device, error));
 
47
}
 
48
 
 
49
 
 
50
/**
 
51
 * hud_voice_query:
 
52
 * @voice: a #HudVoice
 
53
 * @source: a #HudSource to interrogate #HudItem s from
 
54
 * @result: the text result of the voice query will be returned here
 
55
 * @error: if the method returns FALSE, an error will be provdided here
 
56
 *
 
57
 * Run a voice query against the given source.
 
58
 * 
 
59
 * It is your resposibility to free the returned result and error.
 
60
 **/
 
61
gboolean
 
62
hud_voice_query (HudVoice *self, HudSource *source, gchar **result,
 
63
    GError **error)
 
64
{
 
65
  g_debug ("voice query on %s %p", G_OBJECT_TYPE_NAME (self), self);
 
66
  HudVoiceInterface *iface = HUD_VOICE_GET_IFACE (self);
 
67
  g_return_val_if_fail(iface != NULL, FALSE);
 
68
  g_return_val_if_fail(iface->query != NULL, FALSE);
 
69
  return iface->query(self, source, result, error);
 
70
}