summaryrefslogtreecommitdiffstats
path: root/lib/kofficecore/KoSpeaker.cpp
blob: fd42bcf301d38094ebc687c5e4b6029ed1bc765e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
/* 
*   This file is part of the KDE/KOffice project.
*   Copyright (C) 2005, Gary Cramblitt <[email protected]>
*
*   @author Gary Cramblitt <[email protected]>
*   @since KOffice 1.5
*
*   This library is free software; you can redistribute it and/or
*   modify it under the terms of the GNU Library General Public
*   License as published by the Free Software Foundation; either
*   version 2 of the License, or (at your option) any later version.
*
*   This library is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*   Library General Public License for more details.
*
*   You should have received a copy of the GNU Library General Public License
*   along with this library; see the file COPYING.LIB.  If not, write to
*   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
*   Boston, MA 02110-1301, USA.
*/

// TQt includes.
#include <tqtimer.h>
#include <tqcursor.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>
#include <tqmenubar.h>
#include <tqlabel.h>
#include <tqbutton.h>
#include <tqcombobox.h>
#include <tqtabbar.h>
#include <tqgroupbox.h>
#include <tqlineedit.h>
#include <tqtextedit.h>
#include <tqlistview.h>
#include <tqlistbox.h>
#include <tqiconview.h>
#include <tqtable.h>
#include <tqgridview.h>
#include <tqregexp.h>
#include <tqstylesheet.h>

// KDE includes.
#include <kapplication.h>
#include <klocale.h>
#include <kglobal.h>
#include <dcopclient.h>
#include <kconfig.h>
#include <ktrader.h>
#include <kdebug.h>

// KoSpeaker includes.
#include "KoSpeaker.h"
#include "KoSpeaker.moc"

// ------------------ KoSpeakerPrivate ------------------------

class KoSpeakerPrivate
{
public:
    KoSpeakerPrivate() :
        m_versionChecked(false),
        m_enabled(false),
        m_speakFlags(0),
        m_timeout(600),
        m_timer(0),
        m_prevPointerWidget(0),
        m_prevPointerId(-1),
        m_prevFocusWidget(0),
        m_prevFocusId(-1),
        m_prevWidget(0),
        m_prevId(-1),
        m_cancelSpeakWidget(false)
        {}

    // List of text jobs.
    TQValueList<uint> m_jobNums;
    // Whether the version of KTTSD has been requested from the daemon.
    bool m_versionChecked;
    // KTTSD version string.
    TQString m_kttsdVersion;
    // Language code of last spoken text.
    TQString m_langCode;
    // Word used before speaking an accelerator letter.
    TQString m_acceleratorPrefix;
    // Whether TTS service is available or not.
    bool m_enabled;
    // TTS options.
    uint m_speakFlags;
    // Timer which implements the polling interval.
    int m_timeout;
    TQTimer* m_timer;
    // Widget and part of widget for 1) last widget under mouse pointer, 2) last widget with focus, and
    // last widget spoken.
    TQWidget* m_prevPointerWidget;
    int m_prevPointerId;
    TQWidget* m_prevFocusWidget;
    int m_prevFocusId;
    TQWidget* m_prevWidget;
    int m_prevId;
    // True when cancelSpeakWidget has been called in response to customSpeakWidget signal.
    bool m_cancelSpeakWidget;
};

// ------------------ KoSpeaker -------------------------------

KoSpeaker* KoSpeaker::KSpkr = 0L;

KoSpeaker::KoSpeaker()
{
    Q_ASSERT(!KSpkr);
    KSpkr = this;
    d = new KoSpeakerPrivate();
    readConfig(KGlobal::config());
}

KoSpeaker::~KoSpeaker()
{
    if (d->m_jobNums.count() > 0) {
        for (int i = d->m_jobNums.count() - 1; i >= 0; i--)
            removeText(d->m_jobNums[i]);
        d->m_jobNums.clear();
    }
    delete d;
    KSpkr = 0;
}

bool KoSpeaker::isEnabled() const { return d->m_enabled; }

void KoSpeaker::probe()
{
    d->m_timer->stop();
    TQWidget* w;
    TQPoint pos;
    bool spoke = false;
    if ( d->m_speakFlags & SpeakFocusWidget ) {
        w = kapp->tqfocusWidget();
        if (w) {
            spoke = maybeSayWidget(w);
            if (!spoke)
                emit customSpeakWidget(w, pos, d->m_speakFlags);
        }
    }
    if ( !spoke && d->m_speakFlags & SpeakPointerWidget ) {
        pos = TQCursor::pos();
        w = kapp->widgetAt(pos, true);
        if (w) {
            if (!maybeSayWidget(w, pos))
                emit customSpeakWidget(w, pos, d->m_speakFlags);
        }
    }
    d->m_timer->start(d->m_timeout);
}

void KoSpeaker::queueSpeech(const TQString& msg, const TQString& langCode /*= TQString()*/, bool first /*= true*/)
{
    if (!startKttsd()) return;
    int jobCount = d->m_jobNums.count();
    if (first && jobCount > 0) {
        for (int i = jobCount - 1; i >= 0; i--)
            removeText(d->m_jobNums[i]);
        d->m_jobNums.clear();
        jobCount = 0;
    }
    TQString s = msg.stripWhiteSpace();
    if (s.isEmpty()) return;
    // kdDebug() << "KoSpeaker::queueSpeech: s = [" << s << "]" << endl;
    // If no language code given, assume desktop setting.
    TQString languageCode = langCode;
    if (langCode.isEmpty())
        languageCode = KGlobal::locale()->language();
    // kdDebug() << "KoSpeaker::queueSpeech:languageCode = " << languageCode << endl;
    // If KTTSD version is 0.3.5 or later, we can use the appendText method to submit a
    // single, multi-part text job.  Otherwise, must submit separate text jobs.
    // If language code changes, then must also start a new text job so that it will
    // be spoken in correct talker.
    if (getKttsdVersion().isEmpty())
        d->m_jobNums.append(setText(s, languageCode));
    else {
        if ((jobCount == 0) || (languageCode != d->m_langCode))
            d->m_jobNums.append(setText(s, languageCode));
        else
            appendText(s, d->m_jobNums[jobCount-1]);
    }
    d->m_langCode = languageCode;
}

void KoSpeaker::startSpeech()
{
    for (uint i = 0; i < d->m_jobNums.count(); i++)
        startText(d->m_jobNums[i]);
}

void KoSpeaker::readConfig(KConfig* config)
{
    delete d->m_timer;
    d->m_timer = 0;
    config->setGroup("TTS");
    d->m_speakFlags = 0;
    if (config->readBoolEntry("SpeakPointerWidget", false)) d->m_speakFlags |= SpeakPointerWidget;
    if (config->readBoolEntry("SpeakFocusWidget", false)) d->m_speakFlags |= SpeakFocusWidget;
    if (config->readBoolEntry("SpeakTooltips", true)) d->m_speakFlags |= SpeakTooltip;
    if (config->readBoolEntry("SpeakWhatsThis", false)) d->m_speakFlags |= SpeakWhatsThis;
    if (config->readBoolEntry("SpeakDisabled", true)) d->m_speakFlags |= SpeakDisabled;
    if (config->readBoolEntry("SpeakAccelerators", true)) d->m_speakFlags |= SpeakAccelerator;
    d->m_timeout = config->readNumEntry("PollingInterval", 600);
    d->m_acceleratorPrefix = config->readEntry("AcceleratorPrefixWord", i18n("Accelerator"));
    if (d->m_speakFlags & (SpeakPointerWidget | SpeakFocusWidget)) {
        if (startKttsd()) {
            d->m_timer = new TQTimer( this );
            connect( d->m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(probe()) );
            d->m_timer->start( d->m_timeout );
        }
    }
}

bool KoSpeaker::maybeSayWidget(TQWidget* w, const TQPoint& pos /*=TQPoint()*/)
{
    if (!w) return false;

    int id = -1;
    TQString text;

    if (w->inherits("TQViewportWidget")) {
        w = w->parentWidget();
        if (!w) return false;
    }

    // Handle widgets that have multiple parts.

    if ( w->inherits(TQMENUBAR_OBJECT_NAME_STRING) ) {
        TQMenuBar* menuBar = dynamic_cast<TQMenuBar *>(w);
        if (pos == TQPoint()) {
            for (uint i = 0; i < menuBar->count(); ++i)
                if (menuBar->isItemActive(menuBar->idAt(i))) {
                    id = menuBar->idAt(i);
                    break;
                }
        }
            // TODO: This doesn't work.  Need way to figure out the TQMenuItem underneath mouse pointer.
            // id = menuBarItemAt(menuBar, pos);
        if ( id != -1 )
            text = menuBar->text(id);
    }
    else
    if (w->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
        TQPopupMenu* popupMenu = dynamic_cast<TQPopupMenu *>(w);
        if (pos == TQPoint()) {
            for (uint i = 0; i < popupMenu->count(); ++i)
                if (popupMenu->isItemActive(popupMenu->idAt(i))) {
                    id = popupMenu->idAt(i);
                    break;
                }
        } else
            id = popupMenu->idAt(popupMenu->mapFromGlobal(pos));
        if ( id != -1 )
            text = popupMenu->text(id);
    }
    else
    if (w->inherits(TQTABBAR_OBJECT_NAME_STRING)) {
        TQTabBar* tabBar = dynamic_cast<TQTabBar *>(w);
        TQTab* tab = 0;
        if (pos == TQPoint())
            tab = tabBar->tabAt(tabBar->currentTab());
        else
            tab = tabBar->selectTab(tabBar->mapFromGlobal(pos));
        if (tab) {
            id = tab->identifier();
            text = tab->text();
        }
    }
    else
    if (w->inherits(TQLISTVIEW_OBJECT_NAME_STRING)) {
        TQListView* lv = dynamic_cast<TQListView *>(w);
        TQListViewItem* item = 0;
        if (pos == TQPoint())
            item = lv->currentItem();
        else
            item = lv->itemAt(lv->viewport()->mapFromGlobal(pos));
        if (item) {
            id = lv->itemPos(item);
            text = item->text(0);
            for (int col = 1; col < lv->columns(); ++col)
                if (!item->text(col).isEmpty()) text += ". " + item->text(col);
        }
    }
    else
    if (w->inherits(TQLISTBOX_OBJECT_NAME_STRING)) {
        TQListBox* lb = dynamic_cast<TQListBox *>(w);
        // qt docs say coordinates are in "on-screen" coordinates.  What does that mean?
        TQListBoxItem* item = 0;
        if (pos == TQPoint())
            item = lb->item(lb->currentItem());
        else
            item = lb->itemAt(lb->mapFromGlobal(pos));
        if (item) {
            id = lb->index(item);
            text = item->text();
        }
    }
    else
    if (w->inherits(TQICONVIEW_OBJECT_NAME_STRING)) {
        TQIconView* iv = dynamic_cast<TQIconView *>(w);
        TQIconViewItem* item = 0;
        if (pos == TQPoint())
            item = iv->currentItem();
        else
            item = iv->tqfindItem(iv->viewportToContents(iv->viewport()->mapFromGlobal(pos)));
        if (item) {
            id = item->index();
            text = item->text();
        }
    }
    else
    if (w->inherits(TQTABLE_OBJECT_NAME_STRING)) {
        TQTable* tbl = dynamic_cast<TQTable *>(w);
        int row = -1;
        int col = -1;
        if (pos == TQPoint()) {
            row = tbl->currentRow();
            col = tbl->currentColumn();
        } else {
            TQPoint p = tbl->viewportToContents(tbl->viewport()->mapFromGlobal(pos));
            row = tbl->rowAt(p.y());
            col = tbl->columnAt(p.x());
        }
        if (row >= 0 && col >= 0) {
            id = (row * tbl->numCols()) + col;
            text = tbl->text(row, col);
        }
    }
    else
    if (w->inherits(TQGRIDVIEW_OBJECT_NAME_STRING)) {
        TQGridView* gv = dynamic_cast<TQGridView *>(w);
        // TODO: TQGridView does not have a "current" row or column.  Don't think they can even get focus?
        int row = -1;
        int col = -1;
        if (pos != TQPoint()) {
            TQPoint p = gv->viewportToContents(gv->viewport()->mapFromGlobal(pos));
            row = gv->rowAt(p.y());
            col = gv->columnAt(p.x());
        }
        if (row >= 0 && col >= 0)
            id = (row * gv->numCols()) + col;
    }

    if (pos == TQPoint()) {
        if ( w == d->m_prevFocusWidget && id == d->m_prevFocusId) return false;
        d->m_prevFocusWidget = w;
        d->m_prevFocusId = id;
    } else {
        if ( w == d->m_prevPointerWidget && id == d->m_prevPointerId) return false;
        d->m_prevPointerWidget = w;
        d->m_prevPointerId = id;
    }
    if (w == d->m_prevWidget && id == d->m_prevId) return false;
    d->m_prevWidget = w;
    d->m_prevId = id;

    // kdDebug() << " w = " << w << endl;

    d->m_cancelSpeakWidget = false;
    emit customSpeakNewWidget(w, pos, d->m_speakFlags);
    if (d->m_cancelSpeakWidget) return true;

    // Handle simple, single-part widgets.
    if ( w->inherits(TQBUTTON_OBJECT_NAME_STRING) )
        text = dynamic_cast<TQButton *>(w)->text();
    else
    if (w->inherits(TQCOMBOBOX_OBJECT_NAME_STRING))
        text = dynamic_cast<TQComboBox *>(w)->currentText();
    else 
    if (w->inherits(TQLINEEDIT_OBJECT_NAME_STRING))
        text = dynamic_cast<TQLineEdit *>(w)->text();
    else 
    if (w->inherits(TQTEXTEDIT_OBJECT_NAME_STRING))
        text = dynamic_cast<TQTextEdit *>(w)->text();
    else
    if (w->inherits(TQLABEL_OBJECT_NAME_STRING))
        text = dynamic_cast<TQLabel *>(w)->text();
    else
    if (w->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) {
        // TODO: Should calculate this number from font size?
        if (w->mapFromGlobal(pos).y() < 30)
            text = dynamic_cast<TQGroupBox *>(w)->title();
    }
//    else
//     if (w->inherits("TQWhatsThat")) {
//         text = dynamic_cast<TQWhatsThat *>(w)->text();
//     }

    text = text.stripWhiteSpace();
    if (!text.isEmpty()) {
        if (text.right(1) == ".")
            text += " ";
        else
            text += ". ";
    }
    if (d->m_speakFlags & SpeakTooltip || text.isEmpty()) {
        // kdDebug() << "pos = " << pos << endl;
        // TQPoint p = w->mapFromGlobal(pos);
        // kdDebug() << "p = " << p << endl;
        TQString t = TQToolTip::textFor(w, pos);
        t = t.stripWhiteSpace();
        if (!t.isEmpty()) {
            if (t.right(1) != ".") t += ".";
            text += t + " ";
        }
    }

    if (d->m_speakFlags & SpeakWhatsThis || text.isEmpty()) {
        TQString t = TQWhatsThis::textFor(w, pos);
        t = t.stripWhiteSpace();
        if (!t.isEmpty()) {
            if (t.right(1) != ".") t += ".";
            text += t + " ";
        }
    }

    if (d->m_speakFlags & SpeakDisabled) {
        if (!w->isEnabled())
            text += i18n("A grayed widget", "Disabled. ");
    }

    return sayWidget(text);
}

bool KoSpeaker::sayWidget(const TQString& msg)
{
    TQString s = msg;
    if (d->m_speakFlags & SpeakAccelerator) {
        int amp = s.tqfind("&");
        if (amp >= 0) {
            TQString acc = s.mid(++amp,1);
            acc = acc.stripWhiteSpace();
            if (!acc.isEmpty())
                s += ". " + d->m_acceleratorPrefix + " " + acc + ".";
        }
    }
    s.remove("&");
    if (TQStyleSheet::mightBeRichText(s)) {
        // kdDebug() << "richtext" << endl;
        s.tqreplace(TQRegExp("</?[pbius]>"), "");
        s.tqreplace(TQRegExp("</?h\\d>"), "");
        s.tqreplace(TQRegExp("<(br|hr)>"), " ");
        s.tqreplace(TQRegExp(
            "</?(qt|center|li|pre|div|span|em|strong|big|small|sub|sup|code|tt|font|nobr|ul|ol|dl|dt)>"), "");
        s.tqreplace(TQRegExp("</?(table|tr|th|td).*>"), "");
        s.tqreplace(TQRegExp("</?a\\s.+>"), "");
        // Replace <img source="small|frame_text"> with "small frame_text image. "
        s.tqreplace(TQRegExp("<img\\s.*(?:source=|src=)\"([^|\"]+)[|]?([^|\"]*)\">"), "\\1 \\2 image. ");
    }
    if (s.isEmpty()) return false;
    s.tqreplace("Ctrl+", i18n("control plus "));
    s.tqreplace("Alt+", i18n("alt plus "));
    s.tqreplace("+", i18n(" plus "));
    sayScreenReaderOutput(s, "");
    return true;
}

// This doesn't work.  Anybody know how to find the menu item underneath mouse pointer
// in a TQMenuBar?
// int KoSpeaker::menuBarItemAt(TQMenuBar* m, const TQPoint& p)
// {
//     for (uint i = 0; i < m->count(); i++) {
//         int id = m->idAt(i);
//         TQMenuItem* mi = m->findItem(id);
//         TQWidget* w = mi->widget();
//         if (w->rect().tqcontains(w->mapFromGlobal(p))) return id;
//     }
//     return -1;
// }

/*static*/ bool KoSpeaker::isKttsdInstalled()
{
     KTrader::OfferList offers = KTrader::self()->query("DCOP/Text-to-Speech", "Name == 'KTTSD'");
     return (offers.count() > 0);
}

bool KoSpeaker::startKttsd()
{
    DCOPClient *client = kapp->dcopClient();
    // If KTTSD not running, start it.
    if (!client->isApplicationRegistered("kttsd"))
    {
        TQString error;
        if (kapp->startServiceByDesktopName("kttsd", TQStringList(), &error)) {
            kdDebug() << "KoSpeaker::startKttsd: error starting KTTSD service: " << error << endl;
            d->m_enabled = false;
        } else
            d->m_enabled = true;
    } else
        d->m_enabled = true;
    return d->m_enabled;
}

TQString KoSpeaker::getKttsdVersion()
{
    // Determine which version of KTTSD is running.  Note that earlier versions of KSpeech interface
    // did not support version() method, so we must manually marshall this call ourselves.
    if (d->m_enabled) {
        if (!d->m_versionChecked) {
            DCOPClient *client = kapp->dcopClient();
            TQByteArray  data;
            TQCString    replyType;
            TQByteArray  replyData;
            if ( client->call("kttsd", "KSpeech", "version()", data, replyType, replyData, true) ) {
                TQDataStream arg(replyData, IO_ReadOnly);
                arg >> d->m_kttsdVersion;
                kdDebug() << "KoSpeaker::startKttsd: KTTSD version = " << d->m_kttsdVersion << endl;
            }
            d->m_versionChecked = true;
        }
    }
    return d->m_kttsdVersion;
}

void KoSpeaker::sayScreenReaderOutput(const TQString &msg, const TQString &talker)
{
    if (msg.isEmpty()) return;
    DCOPClient *client = kapp->dcopClient();
    TQByteArray  data;
    TQCString    replyType;
    TQByteArray  replyData;
    TQDataStream arg(data, IO_WriteOnly);
    arg << msg << talker;
    if ( !client->call("kttsd", "KSpeech", "sayScreenReaderOutput(TQString,TQString)",
        data, replyType, replyData, true) ) {
        kdDebug() << "KoSpeaker::sayScreenReaderOutput: failed" << endl;
    }
}

uint KoSpeaker::setText(const TQString &text, const TQString &talker)
{
    if (text.isEmpty()) return 0;
    DCOPClient *client = kapp->dcopClient();
    TQByteArray  data;
    TQCString    replyType;
    TQByteArray  replyData;
    TQDataStream arg(data, IO_WriteOnly);
    arg << text << talker;
    uint jobNum = 0;
    if ( !client->call("kttsd", "KSpeech", "setText(TQString,TQString)",
        data, replyType, replyData, true) ) {
        kdDebug() << "KoSpeaker::sayText: failed" << endl;
    } else {
        TQDataStream arg2(replyData, IO_ReadOnly);
        arg2 >> jobNum;
    }
    return jobNum;
}

int KoSpeaker::appendText(const TQString &text, uint jobNum /*=0*/)
{
    if (text.isEmpty()) return 0;
    DCOPClient *client = kapp->dcopClient();
    TQByteArray  data;
    TQCString    replyType;
    TQByteArray  replyData;
    TQDataStream arg(data, IO_WriteOnly);
    arg << text << jobNum;
    int partNum = 0;
    if ( !client->call("kttsd", "KSpeech", "appendText(TQString,uint)",
        data, replyType, replyData, true) ) {
        kdDebug() << "KoSpeaker::appendText: failed" << endl;
    } else {
        TQDataStream arg2(replyData, IO_ReadOnly);
        arg2 >> partNum;
    }
    return partNum;
}

void KoSpeaker::startText(uint jobNum /*=0*/)
{
    DCOPClient *client = kapp->dcopClient();
    TQByteArray  data;
    TQCString    replyType;
    TQByteArray  replyData;
    TQDataStream arg(data, IO_WriteOnly);
    arg << jobNum;
    if ( !client->call("kttsd", "KSpeech", "startText(uint)",
        data, replyType, replyData, true) ) {
        kdDebug() << "KoSpeaker::startText: failed" << endl;
    }
}

void KoSpeaker::removeText(uint jobNum /*=0*/)
{
    DCOPClient *client = kapp->dcopClient();
    TQByteArray  data;
    TQCString    replyType;
    TQByteArray  replyData;
    TQDataStream arg(data, IO_WriteOnly);
    arg << jobNum;
    if ( !client->call("kttsd", "KSpeech", "removeText(uint)",
        data, replyType, replyData, true) ) {
        kdDebug() << "KoSpeaker::removeText: failed" << endl;
    }
}