File kdemm-fix-96594.diff of Package kdelibs3

--- arts/knotify/knotify.h.sav	2005-07-22 16:43:00.000000000 +0200
+++ arts/knotify/knotify.h	2005-07-22 18:48:11.000000000 +0200
@@ -83,6 +83,7 @@ private:
                              int eventId );
 	bool notifyByTaskbar( WId winId );
 
+        void soundFinished( int eventId, PlayingFinishedStatus reason );
 
         WId checkWinId( const QString& appName, WId senderWinId );
 
@@ -91,6 +92,10 @@ private:
 	 **/
 	bool isGlobal(const QString &eventname);
 
+private slots:
+        void playTimeout();
+        void slotPlayerProcessExited( KProcess *proc );
+
 private:
     KNotifyPrivate* d;
     void loadConfig();
--- arts/knotify/knotify.cpp.sav	2005-07-22 16:43:00.000000000 +0200
+++ arts/knotify/knotify.cpp	2005-07-22 19:22:00.000000000 +0200
@@ -54,7 +54,7 @@
 #include <kstandarddirs.h>
 #include <kuniqueapplication.h>
 #include <kwin.h>
-#include <kdemm/factory.h>
+#include <kdemm/simpleplayer.h>
 
 #include "knotify.h"
 #include "knotify.moc"
@@ -69,6 +69,7 @@ public:
     QString externalPlayer;
     KProcess *externalPlayerProc;
 
+    QMap<KDE::Multimedia::SimplePlayer*,int> playObjectEventMap;
     int externalPlayerEventId;
 
     bool useExternal;
@@ -307,6 +308,7 @@ void KNotify::notify(const QString &even
 bool KNotify::notifyBySound( const QString &sound, const QString &appname, int eventId )
 {
     if (sound.isEmpty()) {
+        soundFinished( eventId, NoSoundFile );
         return false;
     }
 
@@ -322,6 +324,7 @@ bool KNotify::notifyBySound( const QStri
     }
     if ( soundFile.isEmpty() )
     {
+        soundFinished( eventId, NoSoundFile );
         return false;
     }
 
@@ -332,13 +335,24 @@ bool KNotify::notifyBySound( const QStri
         //If we disabled audio, just return,
         if (!d->useKDEMM)
         {
+            soundFinished( eventId, NoSoundSupport );
             return false;
         }
 
         KURL soundURL;
         soundURL.setPath(soundFile);
+        KDE::Multimedia::SimplePlayer* playObject = new KDE::Multimedia::SimplePlayer( this );
+        d->playObjectEventMap.insert( playObject, eventId );
+        playObject->play( soundURL );
 
-	return KDE::Multimedia::Factory::self()->playSoundEvent(soundFile);
+        if ( !d->playTimer )
+        {
+            d->playTimer = new QTimer( this );
+            connect( d->playTimer, SIGNAL( timeout() ), SLOT( playTimeout() ) );
+        }
+        if ( !d->playTimer->isActive() )
+            d->playTimer->start( 1000 );
+        return playObject->isPlaying();
 
     } else if(!d->externalPlayer.isEmpty()) {
         // use an external player to play the sound
@@ -351,6 +365,7 @@ bool KNotify::notifyBySound( const QStri
         }
         if (proc->isRunning())
         {
+           soundFinished( eventId, PlayerBusy );
            return false; // Skip
         }
         proc->clearArguments();
@@ -360,6 +375,7 @@ bool KNotify::notifyBySound( const QStri
         return true;
     }
 
+    soundFinished( eventId, Unknown );
     return false;
 }
 
@@ -488,6 +504,40 @@ void KNotify::setVolume( int volume )
     d->volume = volume;
 }
 
+void KNotify::slotPlayerProcessExited( KProcess *proc )
+{
+    soundFinished( d->externalPlayerEventId,
+                   (proc->normalExit() && proc->exitStatus() == 0) ? PlayedOK : Unknown );
+}
+
+
+void KNotify::playTimeout()
+{
+    for( QMap< KDE::Multimedia::SimplePlayer*, int >::Iterator it = d->playObjectEventMap.begin();
+         it != d->playObjectEventMap.end();
+         )
+    {
+        QMap< KDE::Multimedia::SimplePlayer*, int >::Iterator current = it;
+        ++it;
+        if ( !current.key()->isPlaying() || current.key()->totalTime() <= 0 ) // may be "playing" even if there's an error
+        {
+            soundFinished( *current, PlayedOK );
+            d->playObjectEventMap.remove( current );
+        }
+    }
+    if ( !d->playObjectEventMap.count() )
+        d->playTimer->stop();
+}
+
+void KNotify::soundFinished( int eventId, PlayingFinishedStatus reason )
+{
+    QByteArray data;
+    QDataStream stream( data, IO_WriteOnly );
+    stream << eventId << (int) reason;
+
+    DCOPClient::mainClient()->emitDCOPSignal( "KNotify", "playingFinished(int,int)", data );
+}
+
 WId KNotify::checkWinId( const QString &appName, WId senderWinId )
 {
     if ( senderWinId == 0 )
openSUSE Build Service is sponsored by