Fix include
[kdeaccessibility.git] / kttsd / kttsd / speechjob.h
blob18c21e9f8475938cdf8db0f951f587882e9aceb7
1 /*************************************************** vim:set ts=4 sw=4 sts=4:
2 This class contains a single speech job.
3 -------------------
4 Copyright:
5 (C) 2006 by Gary Cramblitt <garycramblitt@comcast.net>
6 -------------------
7 Original author: Gary Cramblitt <garycramblitt@comcast.net>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ******************************************************************************/
24 #ifndef _SPEECHJOB_H_
25 #define _SPEECHJOB_H_
27 // Qt includes.
29 #include <QList>
30 #include <QByteArray>
32 // KDE includes.
33 #include <kspeech.h>
35 /**
36 * @class SpeechJob
38 * Object containing a speech job.
41 class SpeechJobPrivate;
42 class SpeechJob : public QObject {
44 Q_OBJECT
46 Q_PROPERTY(int jobNum READ jobNum WRITE setJobNum)
47 Q_PROPERTY(QString appId READ appId WRITE setAppId)
48 Q_PROPERTY(KSpeech::JobPriority jobPriority READ jobPriority WRITE setJobPriority)
49 Q_PROPERTY(QString talker READ talker WRITE setTalker)
50 Q_PROPERTY(KSpeech::JobState state READ state WRITE setState)
51 Q_PROPERTY(QStringList sentences READ sentences WRITE setSentences)
52 Q_PROPERTY(int sentenceCount READ sentenceCount)
53 Q_PROPERTY(int sentenceNum READ sentenceNum WRITE setSentenceNum)
54 Q_PROPERTY(int seq READ seq WRITE setSeq)
55 Q_PROPERTY(QString getNextSentence READ getNextSentence)
56 Q_PROPERTY(QByteArray serialize READ serialize)
58 public:
59 SpeechJob(KSpeech::JobPriority priority=KSpeech::jpText);
60 ~SpeechJob();
62 /** Job number. */
63 int jobNum() const;
64 void setJobNum(int jobNum);
65 /** DBUS senderId of the application that requested the speech job. */
66 QString appId() const;
67 void setAppId(const QString &appId);
68 /** Type of job. Text, Message, Warning, or Screen Reader Output */
69 KSpeech::JobPriority jobPriority() const;
70 void setJobPriority(KSpeech::JobPriority jobPriority);
71 /** Requested Talker code in which to speak the text. */
72 QString talker() const;
73 void setTalker(const QString &talker);
74 /** Job state. */
75 KSpeech::JobState state() const;
76 void setState(KSpeech::JobState state);
77 /** List of sentences in the job. */
78 QStringList sentences() const;
79 void setSentences(const QStringList &sentences);
80 /** Count of sentences in the job. */
81 int sentenceCount() const;
82 /** Current sentence begin spoken.
83 The first sentence is at 1, so if 0, not speaking. */
84 int sentenceNum() const;
85 void setSentenceNum(int sentenceNum);
86 /** Current sentence being synthesized. First sentence is 1. */
87 int seq() const;
88 void setSeq(int seq);
89 int refCount() const;
90 void incRefCount();
91 void decRefCount();
93 /**
94 * Returns the next sentence in the Job.
95 * Increments sentenceNum.
96 * If we run out of sentences, returns QString().
98 QString getNextSentence();
101 * Converts the job into a byte stream.
102 * @return A QDataStream containing information about the job.
103 * Blank if no such job.
105 * The stream contains the following elements:
106 * - int priority Job Priority
107 * - int state Job state.
108 * - QString appId DBUS senderId of the application that requested the speech job.
109 * - QString talker Language code in which to speak the text.
110 * - int sentenceNum Current sentence being spoken. Sentences are numbered starting at 1.
111 * - int sentenceCount Total number of sentences in the job.
113 * Note that sequence numbers apply to the entire job.
114 * They do not start from 1 at the beginning of each part.
116 * The following sample code will decode the stream:
117 @verbatim
118 QByteArray jobInfo = serialize();
119 QDataStream stream(jobInfo, QIODevice::ReadOnly);
120 qint32 priority;
121 qint32 state;
122 QString appId;
123 QString talker;
124 qint32 sentenceNum;
125 qint32 sentenceCount;
126 stream >> priority;
127 stream >> state;
128 stream >> appId;
129 stream >> talker;
130 stream >> sentenceNum;
131 stream >> sentenceCount;
132 @endverbatim
134 QByteArray serialize() const;
137 * Converts a job state enumerator to a displayable string.
138 * @param state Job state.
139 * @return Displayable string for job state.
141 static QString jobStateToStr(KSpeech::JobState state);
143 Q_SIGNALS:
144 void jobStateChanged(const QString& appId, int jobNum, KSpeech::JobState state);
146 private:
147 SpeechJobPrivate* d;
150 #endif // _SPEECHJOB_H_