• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • arts
 

arts

  • arts
  • knotify
knotify.cpp
1/*
2 Copyright (c) 1997 Christian Esken (esken@kde.org)
3 2000 Charles Samuels (charles@kde.org)
4 2000 Stefan Schimanski (1Stein@gmx.de)
5 2000 Matthias Ettrich (ettrich@kde.org)
6 2000 Waldo Bastian <bastian@kde.org>
7 2000-2003 Carsten Pfeiffer <pfeiffer@kde.org>
8
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, or (at your option)
12 any later version.
13
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.
18
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*/
23
24// C headers
25#include <fcntl.h>
26#include <sys/types.h>
27#include <sys/stat.h>
28
29#include <config.h>
30#ifndef WITHOUT_ARTS
31// aRts headers
32#include <connect.h>
33#include <dispatcher.h>
34#include <flowsystem.h>
35#include <qiomanager.h>
36#include <soundserver.h>
37#endif
38
39// QT headers
40#include <tqfile.h>
41#include <tqfileinfo.h>
42#include <tqstringlist.h>
43#include <tqtextstream.h>
44
45// KDE headers
46#include <dcopclient.h>
47#include <tdeaboutdata.h>
48#ifndef WITHOUT_ARTS
49#include <kartsdispatcher.h>
50#include <kartsserver.h>
51#endif
52#include <tdecmdlineargs.h>
53#include <tdeconfig.h>
54#include <kdebug.h>
55#include <tdeglobal.h>
56#include <tdelocale.h>
57#include <tdemessagebox.h>
58#include <kpassivepopup.h>
59#include <kiconloader.h>
60#include <kmacroexpander.h>
61#ifndef WITHOUT_ARTS
62#include <kplayobjectfactory.h>
63#include <kaudiomanagerplay.h>
64#endif
65#include <tdeprocess.h>
66#include <tdestandarddirs.h>
67#include <tdeuniqueapplication.h>
68#include <twin.h>
69
70#include "knotify.h"
71#include "knotify.moc"
72
73class KNotifyPrivate
74{
75 public:
76 TDEConfig* globalEvents;
77 TDEConfig* globalConfig;
78 TQMap<TQString, TDEConfig*> events;
79 TQMap<TQString, TDEConfig*> configs;
80 TQString externalPlayer;
81 TDEProcess *externalPlayerProc;
82
83#ifndef WITHOUT_ARTS
84 TQPtrList<KDE::PlayObject> playObjects;
85 TQMap<KDE::PlayObject*,int> playObjectEventMap;
86 KAudioManagerPlay *audioManager;
87#endif
88 int externalPlayerEventId;
89
90 bool useExternal;
91 bool useArts;
92 int volume;
93 TQTimer *playTimer;
94 bool inStartup;
95 TQString startupEvents;
96};
97
98// Yes, it's ugly to put this here, but this facilitates the cautious startup
99// procedure.
100#ifndef WITHOUT_ARTS
101 KArtsServer *soundServer = 0;
102#endif
103
104extern "C"{
105 TDE_EXPORT int kdemain(int argc, char **argv) {
106 TDEAboutData aboutdata("knotify", I18N_NOOP("KNotify"),
107 "3.0", I18N_NOOP("TDE Notification Server"),
108 TDEAboutData::License_GPL, "(C) 1997-2003, KDE Developers");
109 aboutdata.addAuthor("Carsten Pfeiffer",I18N_NOOP("Current Maintainer"),"pfeiffer@kde.org");
110 aboutdata.addAuthor("Christian Esken",0,"esken@kde.org");
111 aboutdata.addAuthor("Stefan Westerfeld",I18N_NOOP("Sound support"),"stefan@space.twc.de");
112 aboutdata.addAuthor("Charles Samuels",I18N_NOOP("Previous Maintainer"),"charles@kde.org");
113
114 TDECmdLineArgs::init( argc, argv, &aboutdata );
115 TDEUniqueApplication::addCmdLineOptions();
116
117 // initialize application
118 if ( !TDEUniqueApplication::start() ) {
119 kdDebug() << "Running knotify found" << endl;
120 return 0;
121 }
122
123 TDEUniqueApplication app;
124 app.disableSessionManagement();
125
126 // KNotify is started on KDE startup and on demand (using
127 // KNotifClient::startDaemon()) whenever a KNotify event occurs. Especially
128 // KWin may fire many events (e.g. when a window pops up). When we have
129 // problems with aRts or the installation, we might get an infinite loop
130 // of knotify crashing, popping up the crashhandler window and twin firing
131 // another event, starting knotify again...
132 // We try to prevent this by tracking our startup and offer options to
133 // abort this.
134
135#ifndef WITHOUT_ARTS
136 TDEConfigGroup config( TDEGlobal::config(), "StartProgress" );
137 TDEConfig artsKCMConfig( "kcmartsrc" );
138 artsKCMConfig.setGroup( "Arts" );
139 bool useArts = artsKCMConfig.readBoolEntry( "StartServer", true );
140 if (useArts) {
141 useArts = config.readBoolEntry( "Use Arts", useArts );
142 }
143 bool ok = config.readBoolEntry( "Arts Init", true );
144
145 if ( useArts && !ok ) {
146 if ( KMessageBox::questionYesNo(
147 0L,
148 i18n("During the previous startup, KNotify crashed while creating "
149 "Arts::Dispatcher. Do you want to try again or disable "
150 "aRts sound output?\n\n"
151 "If you choose to disable aRts output now, you can re-enable "
152 "it later or select an alternate sound player "
153 "in the System Notifications control panel."),
154 i18n("KNotify Problem"),
155 i18n("&Try Again"),
156 i18n("D&isable aRts Output"),
157 "KNotifyStartProgress",
158 0 /* don't call KNotify :) */
159 )
160 == KMessageBox::No ) {
161 useArts = false;
162 }
163 }
164
165 // when ArtsDispatcher crashes, we know it the next start.
166 config.writeEntry( "Arts Init", false );
167 config.writeEntry( "Use Arts", useArts );
168 config.sync();
169
170 KArtsDispatcher *dispatcher = 0;
171 if ( useArts ) {
172 dispatcher = new KArtsDispatcher;
173 soundServer = new KArtsServer;
174 }
175
176 // ok, seemed to work.
177 config.writeEntry("Arts Init", useArts );
178 config.sync();
179
180 ok = config.readBoolEntry( "KNotify Init", true );
181 if ( useArts && !ok ) {
182 if ( KMessageBox::questionYesNo(
183 0L,
184 i18n("During the previous startup, KNotify crashed while instantiating "
185 "KNotify. Do you want to try again or disable "
186 "aRts sound output?\n\n"
187 "If you choose to disable aRts output now, you can re-enable "
188 "it later or select an alternate sound player "
189 "in the System Notifications control panel."),
190 i18n("KNotify Problem"),
191 i18n("&Try Again"),
192 i18n("D&isable aRts Output"),
193 "KNotifyStartProgress",
194 0 /* don't call KNotify :) */
195 )
196 == KMessageBox::No ) {
197 useArts = false;
198 delete soundServer;
199 soundServer = 0L;
200 delete dispatcher;
201 dispatcher = 0L;
202 }
203 }
204
205 // when KNotify instantiation crashes, we know it the next start.
206 config.writeEntry( "KNotify Init", false );
207 config.writeEntry( "Use Arts", useArts );
208 config.sync();
209
210 // start notify service
211 KNotify *notify = new KNotify( useArts );
212
213 config.writeEntry( "KNotify Init", true );
214 config.sync();
215
216#else
217
218 // start notify service, without aRts
219 KNotify *notify = new KNotify( false );
220
221#endif
222
223 app.dcopClient()->setDefaultObject( "Notify" );
224 app.dcopClient()->setDaemonMode( true );
225 // kdDebug() << "knotify starting" << endl;
226
227 int ret = app.exec();
228 delete notify;
229#ifndef WITHOUT_ARTS
230 delete soundServer;
231 delete dispatcher;
232#endif
233 return ret;
234 }
235} // end extern "C"
236
237KNotify::KNotify( bool useArts )
238 : TQObject(), DCOPObject("Notify")
239{
240 d = new KNotifyPrivate;
241 d->globalEvents = new TDEConfig("knotify/eventsrc", true, false, "data");
242 d->globalConfig = new TDEConfig("knotify.eventsrc", true, false);
243 d->externalPlayerProc = 0;
244 d->useArts = useArts;
245 d->inStartup = true;
246#ifndef WITHOUT_ARTS
247 d->playObjects.setAutoDelete(true);
248 d->audioManager = 0;
249 if( useArts ) {
250 connect( soundServer, TQ_SIGNAL( restartedServer() ), this, TQ_SLOT( restartedArtsd() ) );
251 restartedArtsd(); //started allready need to initialize d->audioManager
252 }
253#endif
254 d->volume = 100;
255 d->playTimer = 0;
256
257 loadConfig();
258}
259
260KNotify::~KNotify()
261{
262 reconfigure();
263
264#ifndef WITHOUT_ARTS
265 d->playObjects.clear();
266
267 delete d->globalEvents;
268 delete d->globalConfig;
269 delete d->externalPlayerProc;
270 delete d->audioManager;
271#endif
272 delete d;
273}
274
275
276void KNotify::loadConfig() {
277 // load external player settings
278 TDEConfig *kc = TDEGlobal::config();
279 kc->setGroup("Misc");
280 d->useExternal = kc->readBoolEntry( "Use external player", false );
281 d->externalPlayer = kc->readPathEntry("External player");
282
283 // try to locate a suitable player if none is configured
284 if ( d->externalPlayer.isEmpty() ) {
285 TQStringList players;
286 players << "wavplay" << "aplay" << "auplay";
287 TQStringList::Iterator it = players.begin();
288 while ( d->externalPlayer.isEmpty() && it != players.end() ) {
289 d->externalPlayer = TDEStandardDirs::findExe( *it );
290 ++it;
291 }
292 }
293
294 // load default volume
295 d->volume = kc->readNumEntry( "Volume", 100 );
296}
297
298
299void KNotify::reconfigure()
300{
301 tdeApp->config()->reparseConfiguration();
302 loadConfig();
303
304 // clear loaded config files
305 d->globalConfig->reparseConfiguration();
306 for ( TQMapIterator<TQString,TDEConfig*> it = d->configs.begin(); it != d->configs.end(); ++it ) {
307 delete it.data();
308 }
309 d->configs.clear();
310}
311
312
313void KNotify::notify(const TQString &event, const TQString &fromApp,
314 const TQString &text, TQString sound, TQString file,
315 int present, int level)
316{
317 notify( event, fromApp, text, sound, file, present, level, 0, 1 );
318}
319
320void KNotify::notify(const TQString &event, const TQString &fromApp,
321 const TQString &text, TQString sound, TQString file,
322 int present, int level, int winId)
323{
324 notify( event, fromApp, text, sound, file, present, level, winId, 1 );
325}
326
327void KNotify::notify(const TQString &event, const TQString &fromApp,
328 const TQString &text, TQString sound, TQString file,
329 int present, int level, int winId, int eventId )
330{
331 // kdDebug() << "event=" << event << " fromApp=" << fromApp << " text=" << text << " sound=" << sound <<
332 // " file=" << file << " present=" << present << " level=" << level << " winId=" << winId << " eventId=" << eventId << endl;
333 if( d->inStartup ) {
334 d->startupEvents += "(" + event + ":" + fromApp + ")";
335 }
336
337 TQString commandline;
338 TDEConfig *eventsFile = NULL;
339 TDEConfig *configFile = NULL;
340
341 // check for valid events
342 if ( !event.isEmpty() ) {
343
344 // get config file
345 if ( d->events.contains( fromApp ) ) {
346 eventsFile = d->events[fromApp];
347 }
348 else {
349 eventsFile=new TDEConfig(locate("data", fromApp+"/eventsrc"),true,false);
350 d->events.insert( fromApp, eventsFile );
351 }
352 if ( d->configs.contains( fromApp) ) {
353 configFile = d->configs[fromApp];
354 }
355 else {
356 configFile=new TDEConfig(fromApp+".eventsrc",true,false);
357 d->configs.insert( fromApp, configFile );
358 }
359
360 if ( !eventsFile->hasGroup( event ) && isGlobal(event) ) {
361 eventsFile = d->globalEvents;
362 configFile = d->globalConfig;
363 }
364
365 eventsFile->setGroup( event );
366 configFile->setGroup( event );
367
368 // get event presentation
369 if ( present==-1 ) {
370 present = configFile->readNumEntry( "presentation", -1 );
371 }
372 if ( present==-1 ) {
373 present = eventsFile->readNumEntry( "default_presentation", 0 );
374 }
375
376 // get sound file name
377 if( present & KNotifyClient::Sound ) {
378 TQString theSound = configFile->readPathEntry( "soundfile" );
379 if ( theSound.isEmpty() ) {
380 theSound = eventsFile->readPathEntry( "default_sound" );
381 }
382 if ( !theSound.isEmpty() ) {
383 sound = theSound;
384 }
385 }
386
387 // get log file name
388 if( present & KNotifyClient::Logfile ) {
389 TQString theFile = configFile->readPathEntry( "logfile" );
390 if ( theFile.isEmpty() ) {
391 theFile = eventsFile->readPathEntry( "default_logfile" );
392 }
393 if ( !theFile.isEmpty() ) {
394 file = theFile;
395 }
396 }
397
398 // get default event level
399 if( present & KNotifyClient::Messagebox ) {
400 level = eventsFile->readNumEntry( "level", 0 );
401 }
402
403 // get command line
404 if (present & KNotifyClient::Execute ) {
405 commandline = configFile->readPathEntry( "commandline" );
406 if ( commandline.isEmpty() ) {
407 commandline = eventsFile->readPathEntry( "default_commandline" );
408 }
409 }
410 }
411
412 // emit event
413 if ( present & KNotifyClient::Sound ) { // && TQFile(sound).isReadable()
414 notifyBySound( sound, fromApp, eventId );
415 }
416
417 if ( present & KNotifyClient::Execute ) {
418 notifyByExecute( commandline, event, fromApp, text, winId, eventId );
419 }
420
421 if ( present & KNotifyClient::Logfile ) { // && TQFile(file).isWritable()
422 notifyByLogfile( text, file );
423 }
424
425 if ( present & KNotifyClient::Stderr ) {
426 notifyByStderr( text );
427 }
428
429 if ( present & KNotifyClient::Taskbar ) {
430 notifyByTaskbar( checkWinId( fromApp, winId ));
431 }
432
433 if ( present & KNotifyClient::PassivePopup ) {
434 notifyByPassivePopup( text, fromApp, eventsFile, checkWinId( fromApp, winId ));
435 }
436 else if ( present & KNotifyClient::Messagebox ) {
437 notifyByMessagebox( text, level, checkWinId( fromApp, winId ));
438 }
439
440 TQByteArray qbd;
441 TQDataStream ds(qbd, IO_WriteOnly);
442 ds << event << fromApp << text << sound << file << present << level << winId << eventId;
443 emitDCOPSignal("notifySignal(TQString,TQString,TQString,TQString,TQString,int,int,int,int)", qbd);
444}
445
446
447bool KNotify::notifyBySound( const TQString &sound, const TQString &appname, int eventId )
448{
449 if (sound.isEmpty()) {
450 soundFinished( eventId, NoSoundFile );
451 return false;
452 }
453
454 bool external = d->useExternal && !d->externalPlayer.isEmpty();
455 // get file name
456 TQString soundFile(sound);
457 if ( TQFileInfo(sound).isRelative() ) {
458 TQString search = TQString("%1/sounds/%2").arg(appname).arg(sound);
459 soundFile = TDEGlobal::instance()->dirs()->findResource("data", search);
460 if ( soundFile.isEmpty() ) {
461 soundFile = locate( "sound", sound );
462 }
463 }
464 if ( soundFile.isEmpty() || isPlaying( soundFile ) ) {
465 soundFinished( eventId, soundFile.isEmpty() ? NoSoundFile : FileAlreadyPlaying );
466 return false;
467 }
468
469
470 // kdDebug() << "KNotify::notifyBySound - trying to play file " << soundFile << endl;
471
472 if (!external) {
473 //If we disabled using aRts, just return,
474 //(If we don't, we'll blow up accessing the null soundServer)
475 if (!d->useArts)
476 {
477 soundFinished( eventId, NoSoundSupport );
478 return false;
479 }
480
481#ifndef WITHOUT_ARTS
482 // play sound finally
483 while( d->playObjects.count()>5 ) {
484 abortFirstPlayObject();
485 }
486
487 KDE::PlayObjectFactory factory(soundServer->server());
488 if( d->audioManager ) {
489 factory.setAudioManagerPlay( d->audioManager );
490 }
491 KURL soundURL;
492 soundURL.setPath(soundFile);
493 KDE::PlayObject *playObject = factory.createPlayObject(soundURL, false);
494
495 if (playObject->isNull()) {
496 soundFinished( eventId, NoSoundSupport );
497 delete playObject;
498 return false;
499 }
500
501 if ( d->volume != 100 ) {
502 // It works to access the playObject immediately because we don't allow
503 // non-file URLs for sounds.
504 Arts::StereoVolumeControl volumeControl = Arts::DynamicCast(soundServer->server().createObject("Arts::StereoVolumeControl"));
505 Arts::PlayObject player = playObject->object();
506 Arts::Synth_AMAN_PLAY ap = d->audioManager->amanPlay();
507 if( ! volumeControl.isNull() && ! player.isNull() && ! ap.isNull() ) {
508 volumeControl.scaleFactor( d->volume/100.0 );
509
510 ap.stop();
511 Arts::disconnect( player, "left", ap, "left" );
512 Arts::disconnect( player, "right", ap, "right" );
513
514 ap.start();
515 volumeControl.start();
516
517 Arts::connect(player,"left",volumeControl,"inleft");
518 Arts::connect(player,"right",volumeControl,"inright");
519
520 Arts::connect(volumeControl,"outleft",ap,"left");
521 Arts::connect(volumeControl,"outright",ap,"right");
522
523 player._addChild( volumeControl, "volume" );
524 }
525 }
526
527 playObject->play();
528 d->playObjects.append( playObject );
529 d->playObjectEventMap.insert( playObject, eventId );
530
531 if ( !d->playTimer ) {
532 d->playTimer = new TQTimer( this );
533 connect( d->playTimer, TQ_SIGNAL( timeout() ), TQ_SLOT( playTimeout() ) );
534 }
535 if ( !d->playTimer->isActive() ) {
536 d->playTimer->start( 1000 );
537 }
538#endif
539 return true;
540 }
541 else if(!d->externalPlayer.isEmpty()) {
542 // use an external player to play the sound
543 TDEProcess *proc = d->externalPlayerProc;
544 if (!proc) {
545 proc = d->externalPlayerProc = new TDEProcess;
546 connect( proc, TQ_SIGNAL( processExited( TDEProcess * )), TQ_SLOT( slotPlayerProcessExited( TDEProcess * )));
547 }
548 if (proc->isRunning()) {
549 soundFinished( eventId, PlayerBusy );
550 return false; // Skip
551 }
552 proc->clearArguments();
553 (*proc) << d->externalPlayer << TQFile::encodeName( soundFile ).data();
554 d->externalPlayerEventId = eventId;
555 proc->start(TDEProcess::NotifyOnExit);
556 return true;
557 }
558
559 soundFinished( eventId, Unknown );
560 return false;
561}
562
563bool KNotify::notifyByMessagebox(const TQString &text, int level, WId winId)
564{
565 // ignore empty messages
566 if ( text.isEmpty() ) {
567 return false;
568 }
569
570 // display message box for specified event level
571 switch( level ) {
572 default:
573 case KNotifyClient::Notification:
574 KMessageBox::informationWId( winId, text, i18n("Notification"), 0, false );
575 break;
576 case KNotifyClient::Warning:
577 KMessageBox::sorryWId( winId, text, i18n("Warning"), false );
578 break;
579 case KNotifyClient::Error:
580 KMessageBox::errorWId( winId, text, i18n("Error"), false );
581 break;
582 case KNotifyClient::Catastrophe:
583 KMessageBox::errorWId( winId, text, i18n("Catastrophe!"), false );
584 break;
585 }
586
587 return true;
588}
589
590bool KNotify::notifyByPassivePopup( const TQString &text,
591 const TQString &appName,
592 TDEConfig* eventsFile,
593 WId senderWinId )
594{
595 TDEIconLoader iconLoader( appName );
596 if ( eventsFile != NULL ) {
597 TDEConfigGroup config( eventsFile, "!Global!" );
598 TQString iconName = config.readEntry( "IconName", appName );
599 TQPixmap icon = iconLoader.loadIcon( iconName, TDEIcon::Small );
600 TQString title = config.readEntry( "Comment", appName );
601 KPassivePopup::message(title, text, icon, senderWinId);
602 }
603 else {
604 kdError() << "No events for app " << appName << "defined!" <<endl;
605 }
606
607 return true;
608}
609
610bool KNotify::notifyByExecute(const TQString &command, const TQString& event,
611 const TQString& fromApp, const TQString& text,
612 int winId, int eventId) {
613 if (!command.isEmpty()) {
614 // kdDebug() << "executing command '" << command << "'" << endl;
615 TQMap<TQChar,TQString> subst;
616 subst.insert( 'e', event );
617 subst.insert( 'a', fromApp );
618 subst.insert( 's', text );
619 subst.insert( 'w', TQString::number( winId ));
620 subst.insert( 'i', TQString::number( eventId ));
621 TQString execLine = KMacroExpander::expandMacrosShellQuote( command, subst );
622 if ( execLine.isEmpty() ) {
623 execLine = command; // fallback
624 }
625
626 TDEProcess p;
627 p.setUseShell(true);
628 p << execLine;
629 p.start(TDEProcess::DontCare);
630 return true;
631 }
632 return false;
633}
634
635
636bool KNotify::notifyByLogfile(const TQString &text, const TQString &file)
637{
638 // ignore empty messages
639 if ( text.isEmpty() ) {
640 return true;
641 }
642
643 // open file in append mode
644 TQFile logFile(file);
645 if ( !logFile.open(IO_WriteOnly | IO_Append) ) {
646 return false;
647 }
648
649 // append msg
650 TQTextStream strm( &logFile );
651 strm << "- KNotify " << TQDateTime::currentDateTime().toString() << ": ";
652 strm << text << endl;
653
654 // close file
655 logFile.close();
656 return true;
657}
658
659bool KNotify::notifyByStderr(const TQString &text)
660{
661 // ignore empty messages
662 if ( text.isEmpty() ) {
663 return true;
664 }
665
666 // open stderr for output
667 TQTextStream strm( stderr, IO_WriteOnly );
668
669 // output msg
670 strm << "KNotify " << TQDateTime::currentDateTime().toString() << ": ";
671 strm << text << endl;
672
673 return true;
674}
675
676bool KNotify::notifyByTaskbar( WId win )
677{
678 if( win == 0 ) {
679 return false;
680 }
681 KWin::demandAttention( win );
682 return true;
683}
684
685bool KNotify::isGlobal(const TQString &eventname)
686{
687 return d->globalEvents->hasGroup( eventname );
688}
689
690void KNotify::setVolume( int volume )
691{
692 if ( volume<0 ) volume=0;
693 if ( volume>=100 ) volume=100;
694 d->volume = volume;
695}
696
697void KNotify::playTimeout()
698{
699#ifndef WITHOUT_ARTS
700 for ( TQPtrListIterator< KDE::PlayObject > it(d->playObjects); *it;) {
701 TQPtrListIterator< KDE::PlayObject > current = it;
702 ++it;
703 if ( (*current)->state() != Arts::posPlaying ) {
704 TQMap<KDE::PlayObject*,int>::Iterator eit = d->playObjectEventMap.find( *current );
705 if ( eit != d->playObjectEventMap.end() ) {
706 soundFinished( *eit, PlayedOK );
707 d->playObjectEventMap.remove( eit );
708 }
709 d->playObjects.remove( current );
710 }
711 }
712 if ( !d->playObjects.count() ) {
713 d->playTimer->stop();
714 }
715#endif
716}
717
718bool KNotify::isPlaying( const TQString& soundFile ) const
719{
720#ifndef WITHOUT_ARTS
721 for ( TQPtrListIterator< KDE::PlayObject > it(d->playObjects); *it; ++it) {
722 if ( (*it)->mediaName() == soundFile ) {
723 return true;
724 }
725 }
726#endif
727 return false;
728}
729
730void KNotify::slotPlayerProcessExited( TDEProcess *proc )
731{
732 soundFinished( d->externalPlayerEventId, (proc->normalExit() && proc->exitStatus() == 0) ? PlayedOK : Unknown );
733}
734
735void KNotify::abortFirstPlayObject()
736{
737#ifndef WITHOUT_ARTS
738 TQMap<KDE::PlayObject*,int>::Iterator it = d->playObjectEventMap.find( d->playObjects.getFirst() );
739 if ( it != d->playObjectEventMap.end() ) {
740 soundFinished( it.data(), Aborted );
741 d->playObjectEventMap.remove( it );
742 }
743 d->playObjects.removeFirst();
744#endif
745}
746
747void KNotify::soundFinished( int eventId, PlayingFinishedStatus reason )
748{
749 TQByteArray data;
750 TQDataStream stream( data, IO_WriteOnly );
751 stream << eventId << (int) reason;
752
753 DCOPClient::mainClient()->emitDCOPSignal( "KNotify", "playingFinished(int,int)", data );
754}
755
756WId KNotify::checkWinId( const TQString &appName, WId senderWinId )
757{
758 if ( senderWinId == 0 ) {
759 TQCString senderId = tdeApp->dcopClient()->senderId();
760 TQCString compare = (appName + "-mainwindow").latin1();
761 int len = compare.length();
762 // kdDebug() << "notifyByPassivePopup: appName=" << appName << " sender=" << senderId << endl;
763
764 QCStringList objs = tdeApp->dcopClient()->remoteObjects( senderId );
765 for (QCStringList::ConstIterator it = objs.begin(); it != objs.end(); ++it ) {
766 TQCString obj( *it );
767 if ( obj.left(len) == compare) {
768 // kdDebug( ) << "found " << obj << endl;
769 TQCString replyType;
770 TQByteArray data, replyData;
771
772 if ( tdeApp->dcopClient()->call(senderId, obj, "getWinID()", data, replyType, replyData) ) {
773 TQDataStream answer(replyData, IO_ReadOnly);
774 if (replyType == "int") {
775 answer >> senderWinId;
776 // kdDebug() << "SUCCESS, found getWinID(): type='" << TQString(replyType)
777 // << "' senderWinId=" << senderWinId << endl;
778 }
779 }
780 }
781 }
782 }
783 return senderWinId;
784}
785
786void KNotify::restartedArtsd()
787{
788#ifndef WITHOUT_ARTS
789 delete d->audioManager;
790 d->audioManager = new KAudioManagerPlay( soundServer );
791 d->audioManager->setTitle( i18n( "Trinity System Notifications" ) );
792 d->audioManager->setAutoRestoreID( "KNotify Aman Play" );
793#endif
794}
795
796void KNotify::sessionReady()
797{
798 if( d->inStartup && !d->startupEvents.isEmpty()) {
799 kdDebug() << "There were knotify events while startup:" << d->startupEvents << endl;
800 }
801 d->inStartup = false;
802}
KArtsDispatcher
KArtsDispatcher ensures that an instance of Arts::Dispatcher using an Arts::QIOManager exists.
Definition: kartsdispatcher.h:65
KArtsServer
KArtsServer is a wrapper to conveniently get a reference to a SoundServer, and restart artsd when nec...
Definition: kartsserver.h:38
KArtsServer::server
Arts::SoundServerV2 server(void)
Get a verified reference to the SoundServerV2, (re)starting artsd using the kcontrol-specified settin...
Definition: kartsserver.cpp:47
KAudioManagerPlay
KDE Wrapper for Arts::Synth_AMAN_PLAY.
Definition: kaudiomanagerplay.h:39
KDE::PlayObjectFactory
This class implements a factory to create KDE::PlayObjects for a given URL and mimetype.
Definition: kplayobjectfactory.h:80
KDE::PlayObject
This class acts as a general interface to the KDE multimedia framework.
Definition: kplayobject.h:189
KDE::PlayObject::isNull
bool isNull()
return true if this != 0.
Definition: kplayobject.cpp:289
KDE::PlayObject::object
Arts::PlayObject object()
Returns the internal Arts::PlayObject.
Definition: kplayobject.cpp:284
KDE::PlayObject::play
void play()
causes the PlayObject to start the play back.
Definition: kplayobject.cpp:173
KMessageBox::questionYesNo
static int questionYesNo(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
KMessageBox::sorryWId
static void sorryWId(WId parent_id, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
KMessageBox::informationWId
static void informationWId(WId parent_id, const TQString &text, const TQString &caption=TQString::null, const TQString &dontShowAgainName=TQString::null, int options=Notify)
KMessageBox::errorWId
static void errorWId(WId parent_id, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
KPassivePopup::message
static KPassivePopup * message(const TQString &text, TQWidget *parent, const char *name=0)
KURL
KURL::setPath
void setPath(const TQString &path)
KWin::demandAttention
static void demandAttention(WId win, bool set=true)
TDEAboutData
TDEApplication::disableSessionManagement
void disableSessionManagement()
TDEApplication::dcopClient
static DCOPClient * dcopClient()
TDECmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noTDEApp=false)
TDEConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
TDEConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
TDEConfigBase::hasGroup
bool hasGroup(const TQString &group) const
TDEConfigBase::readPathEntry
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
TDEConfigBase::setGroup
void setGroup(const TQString &group)
TDEConfigGroup
TDEConfig
TDEGlobal::config
static TDEConfig * config()
TDEGlobal::instance
static TDEInstance * instance()
TDEIconLoader
TDEIcon::Small
Small
TDEInstance::dirs
TDEStandardDirs * dirs() const
I18N_NOOP
#define I18N_NOOP(x)
TDEProcess
TDEProcess::isRunning
bool isRunning() const
TDEProcess::start
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
TDEProcess::exitStatus
int exitStatus() const
TDEProcess::clearArguments
void clearArguments()
TDEProcess::DontCare
DontCare
TDEProcess::NotifyOnExit
NotifyOnExit
TDEProcess::setUseShell
void setUseShell(bool useShell, const char *shell=0)
TDEProcess::normalExit
bool normalExit() const
TDEStandardDirs::findExe
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)
TDEStandardDirs::findResource
TQString findResource(const char *type, const TQString &filename) const
TDEUniqueApplication
TDEUniqueApplication::start
static bool start()
TDEUniqueApplication::addCmdLineOptions
static void addCmdLineOptions()
kdError
kdbgstream kdError(int area=0)
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
locate
TQString locate(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())
KMacroExpander::expandMacrosShellQuote
TQString expandMacrosShellQuote(const TQString &str, const TQMap< TQChar, TQString > &map, TQChar c='%')
KNotifyClient::event
int event(const TQString &message, const TQString &text=TQString::null) TDE_DEPRECATED
KNotifyClient::Execute
Execute
KNotifyClient::Taskbar
Taskbar
KNotifyClient::PassivePopup
PassivePopup
tdelocale.h

arts

Skip menu "arts"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

arts

Skip menu "arts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for arts by doxygen 1.9.4
This website is maintained by Timothy Pearson.