SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / libkttsd / filterproc.cpp
blobad970a150323dac52c8f58c901b99fcc767deea6
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 Filter Processing class.
3 This is the interface definition for text filters.
4 -------------------
5 Copyright:
6 (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
7 -------------------
8 Original author: Gary Cramblitt <garycramblitt@comcast.net>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************************************************************************/
25 // FilterProc includes.
26 #include "filterproc.h"
28 // KDE includes.
29 #include <kdebug.h>
31 /**
32 * Constructor.
34 KttsFilterProc::KttsFilterProc( QObject *parent, const QVariantList &) :
35 QObject(parent)
37 // kDebug() << "KttsFilterProc::KttsFilterProc: Running";
40 /**
41 * Destructor.
43 KttsFilterProc::~KttsFilterProc()
45 // kDebug() << "KttsFilterProc::~KttsFilterProc: Running";
48 /**
49 * Initialize the filter.
50 * @param config Settings object.
51 * @param configGroup Settings Group.
52 * @return False if filter is not ready to filter.
54 * Note: The parameters are for reading from kttsdrc file. Plugins may wish to maintain
55 * separate configuration files of their own.
57 bool KttsFilterProc::init(KConfig *config, const QString &configGroup){
58 kDebug() << "PlugInProc::init: Running";
59 return false;
62 /**
63 * Returns True if this filter is a Sentence Boundary Detector.
64 * If so, the filter should implement @ref setSbRegExp() .
65 * @return True if this filter is a SBD.
67 /*virtual*/ bool KttsFilterProc::isSBD() { return false; }
69 /**
70 * Returns True if the plugin supports asynchronous processing,
71 * i.e., supports asyncConvert method.
72 * @return True if this plugin supports asynchronous processing.
74 * If the plugin returns True, it must also implement @ref getState .
75 * It must also emit @ref filteringFinished when filtering is completed.
76 * If the plugin returns True, it must also implement @ref stopFiltering .
77 * It must also emit @ref filteringStopped when filtering has been stopped.
79 /*virtual*/ bool KttsFilterProc::supportsAsync() { return false; }
81 /**
82 * Convert input, returning output. Runs synchronously.
83 * @param inputText Input text.
84 * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
85 * use for synthing the text. Useful for extracting hints about
86 * how to filter the text. For example, languageCode.
87 * @param appId The DCOP appId of the application that queued the text.
88 * Also useful for hints about how to do the filtering.
90 /*virtual*/ QString KttsFilterProc::convert(const QString& inputText, TalkerCode* /*talkerCode*/,
91 const QString& /*appId*/)
93 return inputText;
96 /**
97 * Convert input. Runs asynchronously.
98 * @param inputText Input text.
99 * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
100 * use for synthing the text. Useful for extracting hints about
101 * how to filter the text. For example, languageCode.
102 * @param appId The DCOP appId of the application that queued the text.
103 * Also useful for hints about how to do the filtering.
104 * @return False if the filter cannot perform the conversion.
106 * When conversion is completed, emits signal @ref filteringFinished. Calling
107 * program may then call @ref getOutput to retrieve converted text. Calling
108 * program must call @ref ackFinished to acknowledge the conversion.
110 /*virtual*/ bool KttsFilterProc::asyncConvert(const QString& /*inputText*/,
111 TalkerCode* /*talkerCode*/, const QString& /*appId*/) { return false; }
114 * Waits for a previous call to asyncConvert to finish.
116 /*virtual*/ void KttsFilterProc::waitForFinished() { }
119 * Returns the state of the Filter.
121 /*virtual*/ int KttsFilterProc::getState() { return fsIdle; }
124 * Returns the filtered output.
126 /*virtual*/ QString KttsFilterProc::getOutput() { return QString(); }
129 * Acknowledges the finished filtering.
131 /*virtual*/ void KttsFilterProc::ackFinished() { }
134 * Stops filtering. The filteringStopped signal will emit when filtering
135 * has in fact stopped and state returns to fsIdle;
137 /*virtual*/ void KttsFilterProc::stopFiltering() { }
140 * Did this filter do anything? If the filter returns the input as output
141 * unmolested, it should return False when this method is called.
143 /*virtual*/ bool KttsFilterProc::wasModified() { return true; }
146 * Set Sentence Boundary Regular Expression.
147 * This method will only be called if the application overrode the default.
149 * @param re The sentence delimiter regular expression.
151 /*virtual*/ void KttsFilterProc::setSbRegExp(const QString& /*re*/) { }
153 #include "filterproc.moc"