1 /***************************************************** vim:set ts=4 sw=4 sts=4:
4 Command-line utility for sending commands to KTTSD service via D-Bus.
5 --------------------------------------------------------------------
7 (C) 2006 by Gary Cramblitt <garycramblitt@comcast.net>
9 Original author: Gary Cramblitt <garycramblitt@comcast.net>
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 ******************************************************************************/
30 #include <kaboutdata.h>
31 #include <kapplication.h>
32 #include <kcmdlineargs.h>
42 int main(int argc
, char *argv
[])
45 "kspeak", 0, ki18n("kspeak"),
46 "0.1.0", ki18n("A utility for sending speech commands to KTTSD service via D-Bus."),
47 KAboutData::License_GPL
, ki18n("Copyright 2006, Gary Cramblitt <garycramblitt@comcast.net>"));
48 aboutdata
.addAuthor(ki18n("Gary Cramblitt"), ki18n("Maintainer"),"garycramblitt@comcast.net");
50 KCmdLineArgs::init(argc
, argv
, &aboutdata
);
51 // Tell which options are supported
53 KCmdLineOptions options
;
55 options
.add("echo", ki18n("Echo commands. [off]"));
57 options
.add("replies", ki18n("Show KTTSD D-Bus replies. [off]"));
59 options
.add("signals", ki18n("Show KTTSD D-Bus signals. [off]"));
61 options
.add("startkttsd", ki18n("Start KTTSD if not already running. [off]"));
63 options
.add("nostoponerror", ki18n("Continue on error."));
64 options
.add("+scriptfile", ki18n("Name of script to run. Use '-' for stdin."));
65 options
.add("!+[args...]", ki18n("Optional arguments passed to script."));
66 options
.add("", ki18n("Type 'help' for kspeak commands."));
67 KCmdLineArgs::addCmdLineOptions(options
);
69 KApplication
app(false);
71 KCmdLineArgs
*args
= KCmdLineArgs::parsedArgs();
72 if (args
->count() == 0) KCmdLineArgs::usageError(i18n("No script file specified"));
74 // Create KSpeak object.
75 KSpeak
kspeak(args
, 0);
76 kspeak
.setEcho(args
->isSet("echo"));
77 kspeak
.setStopOnError(args
->isSet("stoponerror"));
78 kspeak
.setShowReply(args
->isSet("replies"));
79 kspeak
.setShowSignals(args
->isSet("signals"));
80 if (!kspeak
.isKttsdRunning(args
->isSet("startkttsd"))) exit (1);
83 int result
= app
.exec();