File kdemm.diff of Package kdelibs3
Index: arts/knotify/knotify.cpp
===================================================================
--- arts/knotify/knotify.cpp (.../svn+ssh://coolo@svn.kde.org/home/kde/branches/KDE/3.4/kdelibs/arts/knotify) (Revision 437515)
+++ arts/knotify/knotify.cpp (.../arts/knotify) (Arbeitskopie)
@@ -5,6 +5,7 @@
2000 Matthias Ettrich (ettrich@kde.org)
2000 Waldo Bastian <bastian@kde.org>
2000-2003 Carsten Pfeiffer <pfeiffer@kde.org>
+ 2004 Allan Sandfeld Jensen <kde@carewolf.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,12 +27,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-// aRts headers
-#include <connect.h>
-#include <dispatcher.h>
-#include <flowsystem.h>
-#include <soundserver.h>
-
// QT headers
#include <qfile.h>
#include <qfileinfo.h>
@@ -59,6 +54,7 @@
#include <kstandarddirs.h>
#include <kuniqueapplication.h>
#include <kwin.h>
+#include <kdemm/factory.h>
#include "knotify.h"
#include "knotify.moc"
@@ -73,15 +69,12 @@
QString externalPlayer;
KProcess *externalPlayerProc;
- QPtrList<KDE::PlayObject> playObjects;
- QMap<KDE::PlayObject*,int> playObjectEventMap;
int externalPlayerEventId;
bool useExternal;
- bool useArts;
+ bool useKDEMM;
int volume;
QTimer *playTimer;
- KAudioManagerPlay *audioManager;
bool inStartup;
QString startupEvents;
};
@@ -95,12 +88,13 @@
KDE_EXPORT int kdemain(int argc, char **argv)
{
KAboutData aboutdata("knotify", I18N_NOOP("KNotify"),
- "3.0", I18N_NOOP("KDE Notification Server"),
+ "4.0", I18N_NOOP("KDE Notification Server"),
KAboutData::License_GPL, "(C) 1997-2003, KDE Developers");
aboutdata.addAuthor("Carsten Pfeiffer",I18N_NOOP("Current Maintainer"),"pfeiffer@kde.org");
aboutdata.addAuthor("Christian Esken",0,"esken@kde.org");
aboutdata.addAuthor("Stefan Westerfeld",I18N_NOOP("Sound support"),"stefan@space.twc.de");
aboutdata.addAuthor("Charles Samuels",I18N_NOOP("Previous Maintainer"),"charles@kde.org");
+ aboutdata.addAuthor("Allan Sandfeld Jensen",I18N_NOOP("Conversion to KDEMM"),"kde@carewolf.com");
KCmdLineArgs::init( argc, argv, &aboutdata );
KUniqueApplication::addCmdLineOptions();
@@ -115,127 +109,26 @@
KUniqueApplication app;
app.disableSessionManagement();
- // KNotify is started on KDE startup and on demand (using
- // KNotifClient::startDaemon()) whenever a KNotify event occurs. Especially
- // KWin may fire many events (e.g. when a window pops up). When we have
- // problems with aRts or the installation, we might get an infinite loop
- // of knotify crashing, popping up the crashhandler window and kwin firing
- // another event, starting knotify again...
- // We try to prevent this by tracking our startup and offer options to
- // abort this.
-
- KConfigGroup config( KGlobal::config(), "StartProgress" );
- KConfig artsKCMConfig( "kcmartsrc" );
- artsKCMConfig.setGroup( "Arts" );
- bool useArts = artsKCMConfig.readBoolEntry( "StartServer", true );
- if (useArts)
- useArts = config.readBoolEntry( "Use Arts", useArts );
- bool ok = config.readBoolEntry( "Arts Init", true );
-
- if ( useArts && !ok )
- {
- if ( KMessageBox::questionYesNo(
- 0L,
- i18n("During the previous startup, KNotify crashed while creating "
- "Arts::Dispatcher. Do you want to try again or disable "
- "aRts sound output?\n\n"
- "If you choose to disable aRts output now, you can re-enable "
- "it later or select an alternate sound player "
- "in the System Notifications control panel."),
- i18n("KNotify Problem"),
- i18n("&Try Again"),
- i18n("D&isable aRts Output"),
- "KNotifyStartProgress",
- 0 /* don't call KNotify :) */
- )
- == KMessageBox::No )
- {
- useArts = false;
- }
- }
-
- // when ArtsDispatcher crashes, we know it the next start.
- config.writeEntry( "Arts Init", false );
- config.writeEntry( "Use Arts", useArts );
- config.sync();
-
- KArtsDispatcher *dispatcher = 0;
- if ( useArts )
- {
- dispatcher = new KArtsDispatcher;
- soundServer = new KArtsServer;
- }
-
- // ok, seemed to work.
- config.writeEntry("Arts Init", useArts );
- config.sync();
-
- ok = config.readBoolEntry( "KNotify Init", true );
- if ( useArts && !ok )
- {
- if ( KMessageBox::questionYesNo(
- 0L,
- i18n("During the previous startup, KNotify crashed while instantiating "
- "KNotify. Do you want to try again or disable "
- "aRts sound output?\n\n"
- "If you choose to disable aRts output now, you can re-enable "
- "it later or select an alternate sound player "
- "in the System Notifications control panel."),
- i18n("KNotify Problem"),
- i18n("&Try Again"),
- i18n("D&isable aRts Output"),
- "KNotifyStartProgress",
- 0 /* don't call KNotify :) */
- )
- == KMessageBox::No )
- {
- useArts = false;
- delete soundServer;
- soundServer = 0L;
- delete dispatcher;
- dispatcher = 0L;
- }
- }
-
- // when KNotify instantiation crashes, we know it the next start.
- config.writeEntry( "KNotify Init", false );
- config.writeEntry( "Use Arts", useArts );
- config.sync();
-
// start notify service
- KNotify *notify = new KNotify( useArts );
+ KNotify notify( true );
- config.writeEntry( "KNotify Init", true );
- config.sync();
-
app.dcopClient()->setDefaultObject( "Notify" );
app.dcopClient()->setDaemonMode( true );
// kdDebug() << "knotify starting" << endl;
int ret = app.exec();
- delete notify;
- delete soundServer;
- delete dispatcher;
return ret;
}
}// end extern "C"
-KNotify::KNotify( bool useArts )
+KNotify::KNotify( bool useKDEMM )
: QObject(), DCOPObject("Notify")
{
d = new KNotifyPrivate;
d->globalEvents = new KConfig("knotify/eventsrc", true, false, "data");
d->globalConfig = new KConfig("knotify.eventsrc", true, false);
d->externalPlayerProc = 0;
- d->useArts = useArts;
- d->playObjects.setAutoDelete(true);
- d->audioManager = 0;
- d->inStartup = true;
- if( useArts )
- {
- connect( soundServer, SIGNAL( restartedServer() ), this, SLOT( restartedArtsd() ) );
- restartedArtsd(); //started allready need to initialize d->audioManager
- }
+ d->useKDEMM = useKDEMM;
d->volume = 100;
@@ -248,12 +141,9 @@
{
reconfigure();
- d->playObjects.clear();
-
delete d->globalEvents;
delete d->globalConfig;
delete d->externalPlayerProc;
- delete d->audioManager;
delete d;
}
@@ -268,7 +158,7 @@
// try to locate a suitable player if none is configured
if ( d->externalPlayer.isEmpty() ) {
QStringList players;
- players << "wavplay" << "aplay" << "auplay";
+ players << "wavplay" << "aplay" << "auplay" << "artsplay" << "akodeplay";
QStringList::Iterator it = players.begin();
while ( d->externalPlayer.isEmpty() && it != players.end() ) {
d->externalPlayer = KStandardDirs::findExe( *it );
@@ -417,7 +307,6 @@
bool KNotify::notifyBySound( const QString &sound, const QString &appname, int eventId )
{
if (sound.isEmpty()) {
- soundFinished( eventId, NoSoundFile );
return false;
}
@@ -431,9 +320,8 @@
if ( soundFile.isEmpty() )
soundFile = locate( "sound", sound );
}
- if ( soundFile.isEmpty() || isPlaying( soundFile ) )
+ if ( soundFile.isEmpty() )
{
- soundFinished( eventId, soundFile.isEmpty() ? NoSoundFile : FileAlreadyPlaying );
return false;
}
@@ -441,74 +329,17 @@
// kdDebug() << "KNotify::notifyBySound - trying to play file " << soundFile << endl;
if (!external) {
- //If we disabled using aRts, just return,
- //(If we don't, we'll blow up accessing the null soundServer)
- if (!d->useArts)
+ //If we disabled audio, just return,
+ if (!d->useKDEMM)
{
- soundFinished( eventId, NoSoundSupport );
return false;
}
- // play sound finally
- while( d->playObjects.count()>5 )
- abortFirstPlayObject();
-
- KDE::PlayObjectFactory factory(soundServer->server());
- if( d->audioManager )
- factory.setAudioManagerPlay( d->audioManager );
KURL soundURL;
soundURL.setPath(soundFile);
- KDE::PlayObject *playObject = factory.createPlayObject(soundURL, false);
- if (playObject->isNull())
- {
- soundFinished( eventId, NoSoundSupport );
- delete playObject;
- return false;
- }
+ return KDE::Multimedia::Factory::self()->playSoundEvent(soundFile);
- if ( d->volume != 100 )
- {
- // It works to access the playObject immediately because we don't allow
- // non-file URLs for sounds.
- Arts::StereoVolumeControl volumeControl = Arts::DynamicCast(soundServer->server().createObject("Arts::StereoVolumeControl"));
- Arts::PlayObject player = playObject->object();
- Arts::Synth_AMAN_PLAY ap = d->audioManager->amanPlay();
- if( ! volumeControl.isNull() && ! player.isNull() && ! ap.isNull() )
- {
- volumeControl.scaleFactor( d->volume/100.0 );
-
- ap.stop();
- Arts::disconnect( player, "left", ap, "left" );
- Arts::disconnect( player, "right", ap, "right" );
-
- ap.start();
- volumeControl.start();
-
- Arts::connect(player,"left",volumeControl,"inleft");
- Arts::connect(player,"right",volumeControl,"inright");
-
- Arts::connect(volumeControl,"outleft",ap,"left");
- Arts::connect(volumeControl,"outright",ap,"right");
-
- player._addChild( volumeControl, "volume" );
- }
- }
-
- playObject->play();
- d->playObjects.append( playObject );
- d->playObjectEventMap.insert( playObject, eventId );
-
- if ( !d->playTimer )
- {
- d->playTimer = new QTimer( this );
- connect( d->playTimer, SIGNAL( timeout() ), SLOT( playTimeout() ) );
- }
- if ( !d->playTimer->isActive() )
- d->playTimer->start( 1000 );
-
- return true;
-
} else if(!d->externalPlayer.isEmpty()) {
// use an external player to play the sound
KProcess *proc = d->externalPlayerProc;
@@ -520,7 +351,6 @@
}
if (proc->isRunning())
{
- soundFinished( eventId, PlayerBusy );
return false; // Skip
}
proc->clearArguments();
@@ -530,7 +360,6 @@
return true;
}
- soundFinished( eventId, Unknown );
return false;
}
@@ -659,64 +488,6 @@
d->volume = volume;
}
-void KNotify::playTimeout()
-{
- for ( QPtrListIterator< KDE::PlayObject > it(d->playObjects); *it;)
- {
- QPtrListIterator< KDE::PlayObject > current = it;
- ++it;
- if ( (*current)->state() != Arts::posPlaying )
- {
- QMap<KDE::PlayObject*,int>::Iterator eit = d->playObjectEventMap.find( *current );
- if ( eit != d->playObjectEventMap.end() )
- {
- soundFinished( *eit, PlayedOK );
- d->playObjectEventMap.remove( eit );
- }
- d->playObjects.remove( current );
- }
- }
- if ( !d->playObjects.count() )
- d->playTimer->stop();
-}
-
-bool KNotify::isPlaying( const QString& soundFile ) const
-{
- for ( QPtrListIterator< KDE::PlayObject > it(d->playObjects); *it; ++it)
- {
- if ( (*it)->mediaName() == soundFile )
- return true;
- }
-
- return false;
-}
-
-void KNotify::slotPlayerProcessExited( KProcess *proc )
-{
- soundFinished( d->externalPlayerEventId,
- (proc->normalExit() && proc->exitStatus() == 0) ? PlayedOK : Unknown );
-}
-
-void KNotify::abortFirstPlayObject()
-{
- QMap<KDE::PlayObject*,int>::Iterator it = d->playObjectEventMap.find( d->playObjects.getFirst() );
- if ( it != d->playObjectEventMap.end() )
- {
- soundFinished( it.data(), Aborted );
- d->playObjectEventMap.remove( it );
- }
- d->playObjects.removeFirst();
-}
-
-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 )
@@ -748,14 +519,6 @@
return senderWinId;
}
-void KNotify::restartedArtsd()
-{
- delete d->audioManager;
- d->audioManager = new KAudioManagerPlay( soundServer );
- d->audioManager->setTitle( i18n( "KDE System Notifications" ) );
- d->audioManager->setAutoRestoreID( "KNotify Aman Play" );
-}
-
void KNotify::sessionReady()
{
if( d->inStartup && !d->startupEvents.isEmpty())
Index: arts/knotify/Makefile.am
===================================================================
--- arts/knotify/Makefile.am (.../svn+ssh://coolo@svn.kde.org/home/kde/branches/KDE/3.4/kdelibs/arts/knotify) (Revision 437515)
+++ arts/knotify/Makefile.am (.../arts/knotify) (Arbeitskopie)
@@ -3,10 +3,13 @@
####### Files
-kde_module_LTLIBRARIES = knotify.la
+#kde_module_LTLIBRARIES = knotify.la
+bin_PROGRAMS =
+lib_LTLIBRARIES =
+kdeinit_LTLIBRARIES = knotify.la
knotify_la_SOURCES = knotify.cpp knotify.skel
-knotify_la_LIBADD = -lsoundserver_idl -lqtmcop $(LIB_KDEUI) $(top_builddir)/arts/kde/libartskde.la
+knotify_la_LIBADD = $(LIB_KDEUI) $(top_builddir)/kdemm/libkdemm.la
knotify_la_LDFLAGS = $(all_libraries) -module -avoid-version
knotify_la_METASOURCES = AUTO
Index: arts/knotify/knotify.h
===================================================================
--- arts/knotify/knotify.h (.../svn+ssh://coolo@svn.kde.org/home/kde/branches/KDE/3.4/kdelibs/arts/knotify) (Revision 437515)
+++ arts/knotify/knotify.h (.../arts/knotify) (Arbeitskopie)
@@ -23,7 +23,6 @@
#include <qobject.h>
#include <knotifyclient.h>
#include <dcopobject.h>
-#include <soundserver.h>
class KNotifyPrivate;
class KProcess;
@@ -76,19 +75,15 @@
bool notifyByStderr(const QString &text);
bool notifyByPassivePopup(const QString &text, const QString &appName,
WId winId );
- bool notifyByExecute(const QString &command,
- const QString& event,
- const QString& fromApp,
+ bool notifyByExecute(const QString &command,
+ const QString& event,
+ const QString& fromApp,
const QString& text,
int winId,
int eventId );
- bool notifyByTaskbar( WId winId );
-
- bool isPlaying( const QString& soundFile ) const;
+ bool notifyByTaskbar( WId winId );
- void soundFinished( int eventId, PlayingFinishedStatus reason );
- void abortFirstPlayObject();
-
+
WId checkWinId( const QString& appName, WId senderWinId );
/**
@@ -96,11 +91,6 @@
**/
bool isGlobal(const QString &eventname);
-private slots:
- void playTimeout();
- void slotPlayerProcessExited( KProcess *proc );
- void restartedArtsd();
-
private:
KNotifyPrivate* d;
void loadConfig();