1 /*************************************************** vim:set ts=4 sw=4 sts=4:
2 This class contains a single speech job.
5 (C) 2006 by Gary Cramblitt <garycramblitt@comcast.net>
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 ******************************************************************************/
38 * Object containing a speech job.
41 class SpeechJobPrivate
;
42 class SpeechJob
: public QObject
{
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
)
59 SpeechJob(KSpeech::JobPriority priority
=KSpeech::jpText
);
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
);
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. */
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:
118 QByteArray jobInfo = serialize();
119 QDataStream stream(jobInfo, QIODevice::ReadOnly);
125 qint32 sentenceCount;
130 stream >> sentenceNum;
131 stream >> sentenceCount;
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
);
144 void jobStateChanged(const QString
& appId
, int jobNum
, KSpeech::JobState state
);
150 #endif // _SPEECHJOB_H_