[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    new kaiman patch
From:       Stefan Schimanski <1Stein () gmx ! de>
Date:       2000-08-29 16:10:54
[Download RAW message or body]

Hi,

I've tuned kaiman again today. I haven't seen any crashes with this version 
yet which may be a good sign. Please try it out! If nobody complains I will 
commit it tomorrow.

bye
  Schimmi
["kaiman.patch" (text/english)]

Only in kaiman: .deps
Common subdirectories: kaiman.head/CVS and kaiman/CVS
diff -U2 kaiman.head/KaimanStyle.cpp kaiman/KaimanStyle.cpp
--- kaiman.head/KaimanStyle.cpp	Wed Aug 16 12:19:33 2000
+++ kaiman/KaimanStyle.cpp	Mon Aug 28 12:46:26 2000
@@ -771,5 +771,4 @@
 {
     _value = 0;
-    kdDebug() << "KaimanStyleState" << endl;
 }
 
@@ -890,9 +889,7 @@
     } else if ( l_s_elem=="Digit_Small" || l_s_elem=="Digit_Small_Default" ) {
         i_smallFont = ref_s_tokens[1];
-        kdDebug() << "Digit_Small = " << i_smallFont << endl;
         return;
     } else if ( l_s_elem=="Digit_Large" || l_s_elem=="Digit_Large_Default" ) {
         i_largeFont = ref_s_tokens[1];
-        kdDebug() << "Digit_Large = " << i_largeFont << endl;
         return;
     }
@@ -1294,5 +1291,4 @@
         if ( l_kse_elem->filename=="Small" ) l_kse_elem->filename = i_smallFont;
         else if ( l_kse_elem->filename=="Large" ) l_kse_elem->filename = \
                i_largeFont;
-        kdDebug() << "numberElement filename = " << l_kse_elem->filename << endl;
     } else if( l_elementType==SliderElement ) {
         // slider items
Only in kaiman: Makefile.am~
Only in kaiman: Makefile.in
Common subdirectories: kaiman.head/Skins and kaiman/Skins
diff -U2 kaiman.head/id3.cpp kaiman/id3.cpp
--- kaiman.head/id3.cpp	Wed Aug 16 12:19:33 2000
+++ kaiman/id3.cpp	Tue Aug 29 14:33:50 2000
@@ -100,4 +100,11 @@
 
 
+void ID3Reader::stop()
+{
+    _queue.clear();
+    _timer.stop();
+}
+
+
 void ID3Reader::timeout()
 {
diff -U2 kaiman.head/id3.h kaiman/id3.h
--- kaiman.head/id3.h	Wed Aug 16 12:19:33 2000
+++ kaiman/id3.h	Tue Aug 29 14:33:50 2000
@@ -63,4 +63,5 @@
     void queue( const KURL &url, void *user );
     void dequeue( void *user );
+    void stop();
 
  signals:
diff -U2 kaiman.head/kaiman.cpp kaiman/kaiman.cpp
--- kaiman.head/kaiman.cpp	Sun Aug 27 21:58:24 2000
+++ kaiman/kaiman.cpp	Tue Aug 29 18:00:51 2000
@@ -66,13 +66,14 @@
         return true;
     return false;
-}                                                                                    \
 +}
 
 using namespace Arts;
 
 Kaiman::Kaiman( const QString &skin )
-    : _style(0), _soundServer(Reference("global:Arts_SimpleSoundServer")), \
_prefDlg(0) +    : _style(0), _prefDlg(0)
 {
     KWin::setType( this->winId(), NET::Override );
     setBackgroundMode( NoBackground );
+    setAcceptDrops(true);
 
     // init config
@@ -84,8 +85,12 @@
     _altSkin = config->readBoolEntry( "AltSkin", false );
     _mixerCommand = "kmix"; // Default mixer
+    _seeking = false;
 
-    setAcceptDrops(true);
-
-    if (!initArts()) exit(1);
+    // initialize aRts references
+    _playObject = Arts::PlayObject::null();
+    _playObjectFactory = Arts::PlayObjectFactory::null();
+    _volumeControl = Arts::StereoVolumeControl::null();
+    _soundServer = Arts::SimpleSoundServer::null();
+    _lastPolledState = Arts::posIdle;
 
     // load skin
@@ -98,5 +103,5 @@
     if ( !loadStyle( skinName, _altSkin ? "alt_skindata" : "skindata" ) ) {
         if ( !loadStyle(skinName, "skindata") ) {
-            KMessageBox::error( this, i18n("Can't load skin %1. Switching to default \
skin.").arg(skinName) ); +            KMessageBox::sorry( this, i18n("Can't load skin \
%1. Switching to default skin.").arg(skinName) );  if ( !loadStyle( DEFAULT_SKIN, \
                "skindata" ) ) {
                 KMessageBox::error( this, i18n("Can't load default skin \
%1.").arg(DEFAULT_SKIN) ); @@ -142,5 +147,5 @@
 
     // get a reference to the server to be sure that we're still connected
-    _soundServer=Reference("global:Arts_SimpleSoundServer");
+    _soundServer = Reference("global:Arts_SimpleSoundServer");
 
     // remove effect from effect chain
@@ -154,87 +159,92 @@
 bool Kaiman::initArts()
 {
-    _playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
+    if ( _soundServer.isNull() || _soundServer.error()  ) {
+        _volumeControl = Arts::StereoVolumeControl::null();
+        _soundServer = Reference("global:Arts_SimpleSoundServer");
+        _playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
 
-    if(_playObjectFactory.isNull())
-    {
-        // aRts seems not to be running, let's try to run it
-
-        // First, let's read the configuration as in kcmarts
+        if( _soundServer.isNull() || _soundServer.error() )
+        {
+            // aRts seems not to be running, let's try to run it
 
-        KConfig *config = new KConfig("kcmartsrc");
-        QCString cmdline;
- 
-        config->setGroup("Arts");
-        bool startRealtime = config->readBoolEntry("StartRealtime",false);
-        bool networkTransparent = config->readBoolEntry("NetworkTransparent",false);
-        bool x11Comm = config->readBoolEntry("X11GlobalComm",false);
+            // First, let's read the configuration as in kcmarts
+            KConfig *config = new KConfig("kcmartsrc");
+            QCString cmdline;
+
+            config->setGroup("Arts");
+            bool startRealtime = config->readBoolEntry("StartRealtime",false);
+            bool networkTransparent = \
config->readBoolEntry("NetworkTransparent",false); +            bool x11Comm = \
config->readBoolEntry("X11GlobalComm",false);  //        bool fullDuplex = \
                config->readBoolEntry("FullDuplex",false);
-        int responseTime = config->readNumEntry("ResponseTime",2);
- 
-        /* put the value of x11Comm into .mcoprc */
-        KConfig *X11CommConfig = new KConfig(QDir::homeDirPath()+"/.mcoprc");
- 
-        if(x11Comm)
-            X11CommConfig->writeEntry("GlobalComm","Arts::X11GlobalComm");
-        else
-            X11CommConfig->writeEntry("GlobalComm","Arts::TmpGlobalComm");
- 
-        X11CommConfig->sync();
-        delete X11CommConfig;
- 
-        cmdline = QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("kdeinit_wrapper")));
                
-        cmdline += " ";
-        if(startRealtime && artswrapper_check())
-            cmdline += \
                QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("artswrapper")));
                
-        else
-            cmdline += \
QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("artsd"))); +            \
int responseTime = config->readNumEntry("ResponseTime",2); +
+            /* put the value of x11Comm into .mcoprc */
+            KConfig *X11CommConfig = new KConfig(QDir::homeDirPath()+"/.mcoprc");
+
+            if(x11Comm)
+                X11CommConfig->writeEntry("GlobalComm","Arts::X11GlobalComm");
+            else
+                X11CommConfig->writeEntry("GlobalComm","Arts::TmpGlobalComm");
+
+            X11CommConfig->sync();
+            delete X11CommConfig;
+
+            cmdline = \
QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("kdeinit_wrapper"))); +  \
cmdline += " "; +            if(startRealtime && artswrapper_check())
+                cmdline += \
QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("artswrapper"))); +      \
else +                cmdline += \
QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("artsd")));  
-        if(networkTransparent)
-            cmdline += " -n";
+            if(networkTransparent)
+                cmdline += " -n";
 
-         // Full duplex seems not to work
+            // Full duplex seems not to work
 //        if(fullDuplex)
 //            cmdline += " -d";
- 
-        switch(responseTime)
-        {
-            // 8.7 ms 
+
+            switch(responseTime)
+            {
+                // 8.7 ms
             case 0: cmdline += " -F 3 -S 512";
                 break;
-            // 40 ms 
+                // 40 ms
             case 1: cmdline += " -F 7 -S 1024";
                 break;
-            // 255 ms 
+                // 255 ms
             case 2: cmdline += " -F 5 -S 8192";
                 break;
-        }
+            }
 
-        int status=system(cmdline);     
+            int status=system(cmdline);
 
-        if ( status!=-1 && WIFEXITED(status) )
-        {
-         // We could have a race-condition here. The correct way to do it is to
-         // make artsd fork-and-exit after starting to listen to connections
-         // (and running artsd directly instead of using kdeinit),
-         // but this is better than nothing.
-          sleep(1);
-          _soundServer=Reference("global:Arts_SimpleSoundServer");
-          _playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
+            if ( status!=-1 && WIFEXITED(status) )
+            {
+                // We could have a race-condition here. The correct way to do it is \
to +                // make artsd fork-and-exit after starting to listen to \
connections +                // (and running artsd directly instead of using \
kdeinit), +                // but this is better than nothing.
+                sleep(1);
+                _soundServer = Reference("global:Arts_SimpleSoundServer");
+                _playObjectFactory = \
Arts::Reference("global:Arts_PlayObjectFactory"); +            }
+
+            if( _playObjectFactory.isNull() )
+            {
+                kdDebug() << "Connection to the soundserver failed - make sure that \
artsd is really running." << endl; +                KMessageBox::error( 0, \
i18n("Connection to the soundserver failed - make sure that artsd is really \
running.") ); +                return false;
+            }
+        }
+
+        if ( !_soundServer.isNull() ) {
+            // create a new stereo volume control object on the server
+            _volumeControl = \
DynamicCast(_soundServer.createObject("Arts::StereoVolumeControl")); +            \
_volumeControl.start(); +            _volumeEffectID = \
_soundServer.outstack().insertBottom(_volumeControl, "Volume Control");  }
- 
-        if(_playObjectFactory.isNull())
-        {
-           KMessageBox::error( 0, i18n("Connection to the soundserver failed - make \
                sure that artsd is really running.") );
-           return false;
-        } 
     }
 
     _playObject = Arts::PlayObject::null();
-    _lastPolledState = Arts::posIdle;
-
-    // create a new stereo volume control object on the server
-    _volumeControl = \
                DynamicCast(_soundServer.createObject("Arts::StereoVolumeControl"));
-    _volumeControl.start();
-    _volumeEffectID = _soundServer.outstack().insertBottom(_volumeControl, "Volume \
Control");  
     return true;
@@ -313,14 +323,19 @@
 
     item = _style->find("Position_Slider");
-    if( item!=0 ) connect( item, SIGNAL(newValue(int)), this, SLOT(seek(int)) );
+    if( item!=0 ) {
+        connect( item, SIGNAL(newValueDrag(int)), this, SLOT(seekStart(int)) );
+        connect( item, SIGNAL(newValue(int)), this, SLOT(seekDrag(int)) );
+        connect( item, SIGNAL(newValueDrop(int)), this, SLOT(seekStop(int)) );
+    }
+
 
     KaimanStyleSlider* l_elem_volslider = \
static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider"));  if ( \
                l_elem_volslider!=0 ) {
         connect(l_elem_volslider,SIGNAL(newValue(int)),this,SLOT(setVolume(int)));
-        l_elem_volslider->setValue( _volume );
+        l_elem_volslider->setValue( _volume, 0, 100 );
     }
 
     KaimanStyleValue* volItem = \
                static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
-    if ( volItem ) volItem->setValue( _volume );
+    if ( volItem ) volItem->setValue( _volume, 0, 100 );
 
     KaimanStyleText* titleItem = \
static_cast<KaimanStyleText*>(_style->find("Title")); @@ -342,32 +357,40 @@
 bool Kaiman::play( const KURL &url ) {
     QString file = url.directory( false )+url.fileName();
-    kdDebug() << " Kaiman::play " << file << endl;
-    _playObject = _playObjectFactory.createPlayObject( file.ascii() );
-
-    if ( _playObjectFactory.error() ) {
-       // If connection to artsd was broken, try to reestablish it again
 
-       if (!initArts()) return false;
+    if ( !_playObjectFactory.isNull() ) {
+        _playObject = _playObjectFactory.createPlayObject( file.ascii() );
+        if ( !_playObject.isNull() ) {
+            _playObject.play();
+            return _playObject.state()==Arts::posPlaying;
+        } else
+            return false;
+    } else
+        return false;
+}
 
-       // Cool, we were able to connect.
 
-       _playObject = _playObjectFactory.createPlayObject( file.ascii() );
+bool Kaiman::play( MediaFile *media )
+{
+    // reconnect to arts
+    if ( !initArts() ) {
+        stop();
+        return false;
     }
 
-    if ( _playObject.isNull() ) return false;
+    if ( !play(media->url()) ) {
+        stop();
+        return false;
+    }
 
-    _playObject.play();
-    return _playObject.state()==Arts::posPlaying;
+    return true;
 }
 
 
-bool Kaiman::play( MediaFile *media )
+bool Kaiman::playNext( bool reverse )
 {
-    return play( media->url() );
-}
-
+    // reconnect to arts
+    if ( !initArts() ) return false;
 
-bool Kaiman::tryPlay( bool reverse )
-{
+    // try to play files
     for ( int tries = _mediaManager->count();
           tries>0;
@@ -376,5 +399,5 @@
         // try to play active media file
         MediaFile *media = _mediaManager->active();
-        if ( media && play(media) )
+        if ( media && play(media->url()) )
             return true;
 
@@ -393,18 +416,15 @@
 {
     if( !_playObject.isNull() ) {
-        if ( _playObject.state()==Arts::posPlaying ) {
-            // We are playing => Pause
+        if ( _playObject.state()==Arts::posPlaying )
             pause();
-            return;
-        }
-
-        if ( _playObject.state()==Arts::posPaused ) {
+        else
             _playObject.play();
-            return;
-        }
-    }
+    } else {
+        _mediaManager->start( false );
+        if ( _shuffle ) _mediaManager->shuffle();
 
-    _mediaManager->start( false );
-    tryPlay(false);
+        if ( !playNext(false) )
+            stop();
+    }
 }
 
@@ -412,11 +432,9 @@
 void Kaiman::pause()
 {
-    if(!_playObject.isNull()) {
-        if ( _lastPolledState==Arts::posPaused ) {
+    if( !_playObject.isNull() ) {
+        if ( _lastPolledState==Arts::posPaused )
             _playObject.play();
-        }
-        else {
+        else
             _playObject.pause();
-        }
     }
 }
@@ -425,10 +443,16 @@
 void Kaiman::stop()
 {
-    if(!_playObject.isNull()) {
-        Arts::poTime l_t_zero(0,0,0,"samples");
-        _playObject.seek(l_t_zero);
+    if( !_playObject.isNull() ) {
+        Arts::poTime l_t_zero( 0, 0, 0, "samples" );
+        _playObject.seek( l_t_zero );
         _playObject.halt();
-        _mediaManager->reset();
     }
+
+    _playObject = Arts::PlayObject::null();
+    _volumeControl = Arts::StereoVolumeControl::null();
+    _soundServer = Arts::SimpleSoundServer::null();
+    _lastPolledState = Arts::posIdle;
+
+    _mediaManager->reset();
 }
 
@@ -436,4 +460,5 @@
 void Kaiman::clear()
 {
+    stop();
     _mediaManager->clear();
 }
@@ -443,5 +468,5 @@
 {
     if ( _shuffle ) _mediaManager->shuffle(); else _mediaManager->next( false, \
                _looping );
-    tryPlay( false );
+    if ( !playNext(false) ) stop();
 }
 
@@ -450,5 +475,30 @@
 {
     if ( _shuffle ) _mediaManager->shuffle(); else _mediaManager->next( true, \
                _looping );
-    tryPlay( true );
+    if ( !playNext(true) ) stop();
+}
+
+
+void Kaiman::seekStart( int /*value*/ )
+{
+    _seeking = true;
+}
+
+
+void Kaiman::seekDrag( int value )
+{
+    KaimanStyleValue* posItem =
+        static_cast<KaimanStyleValue*>(_style->find("Position_Item"));
+    if ( posItem ) posItem->setValue( value );
+
+    KaimanStyleSlider* posSlider =
+        static_cast<KaimanStyleSlider*>(_style->find("Position_Slider"));
+    if ( posSlider ) posSlider->setValue( value );
+}
+
+
+void Kaiman::seekStop( int value )
+{
+    seek( value );
+    _seeking = false;
 }
 
@@ -456,5 +506,5 @@
 void Kaiman::seek( int sec )
 {
-    if ( !_playObject.isNull() ) {
+   if ( !_playObject.isNull() ) {
         Arts::poTime t;
         t.seconds = sec;
@@ -505,13 +555,13 @@
     if ( vol<0 ) vol=0;
     if ( vol>=100 ) vol=100;
-
     _volume = vol;
-    float volume = pow(2.0,(400.0 - (100-vol)*12 )/200.0);
-    if ( vol==1200 ) volume = 0.0;
 
-    _volumeControl.scaleFactor(volume);
+    if ( !_volumeControl.isNull() )
+        _volumeControl.scaleFactor(vol/100.0);
 
-    KaimanStyleValue* item = \
                static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
-    if ( item ) item->setValue( vol );
+    KaimanStyleSlider* l_elem_volslider = \
static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider")); +    \
KaimanStyleValue* l_elem_volitem = \
static_cast<KaimanStyleValue*>(_style->find("Volume_Item")); +    if ( \
l_elem_volslider!=0 ) l_elem_volslider->setValue( _volume, 0, 100 ); +    if ( \
l_elem_volitem!=0 ) l_elem_volitem->setValue( _volume, 0, 100 );  }
 
@@ -520,11 +570,4 @@
 {
     setVolume( _volume+10 );
-
-    KaimanStyleSlider* l_elem_volslider = \
                static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider"));
-    KaimanStyleValue* l_elem_volitem = \
                static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
-    if ( l_elem_volitem!=0 && l_elem_volslider ) {
-        l_elem_volslider->setValue( _volume );
-        l_elem_volitem->setValue( _volume );
-    }
 }
 
@@ -533,11 +576,4 @@
 {
     setVolume( _volume-10 );
-
-    KaimanStyleSlider* l_elem_volslider = \
                static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider"));
-    KaimanStyleValue* l_elem_volitem = \
                static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
-    if ( l_elem_volitem!=0 && l_elem_volslider ) {
-        l_elem_volslider->setValue( _volume );
-        l_elem_volitem->setValue( _volume );
-    }
 }
 
@@ -638,5 +674,5 @@
 void Kaiman::updateArtsDisplay()
 {
- long sec = 0;
+    long sec = 0;
     long all = 0;
     int percent = 0;
@@ -653,10 +689,13 @@
 
     // update play position
-    KaimanStyleValue* posItem = \
                static_cast<KaimanStyleValue*>(_style->find("Position_Item"));
-    if ( posItem ) posItem->setValue( sec, 0, all );
-
-    KaimanStyleSlider* posSlider =
-        static_cast<KaimanStyleSlider*>(_style->find("Position_Slider"));
-    if ( posSlider ) posSlider->setValue( sec, 0, all );
+    if ( !_seeking ) {
+        KaimanStyleValue* posItem =
+            static_cast<KaimanStyleValue*>(_style->find("Position_Item"));
+        if ( posItem ) posItem->setValue( sec, 0, all );
+
+        KaimanStyleSlider* posSlider =
+            static_cast<KaimanStyleSlider*>(_style->find("Position_Slider"));
+        if ( posSlider ) posSlider->setValue( sec, 0, all );
+    }
 
     // update time
@@ -730,22 +769,24 @@
 
 void Kaiman::pollArts() {
-    if (! _playObject.isNull() ) {
-        KaimanStyleButton* l_elem_pause =
+    KaimanStyleButton* l_elem_pause =
             static_cast<KaimanStyleButton*>(_style->find("Pause_Button"));
-        KaimanStyleButton* l_elem_play =
+    KaimanStyleButton* l_elem_play =
             static_cast<KaimanStyleButton*>(_style->find("Play_Button"));
-        KaimanStyleState* status = \
static_cast<KaimanStyleState*>(_style->find("Status_Item")); +    KaimanStyleState* \
status = static_cast<KaimanStyleState*>(_style->find("Status_Item"));  
+    if ( !_playObject.isNull() ) {
         // check play object state and update buttons
-        int newPolledState = _playObject.state();
-        switch ( newPolledState ) {
+        int oldPolledState = _lastPolledState;
+        _lastPolledState = _playObject.state();
+        switch ( _lastPolledState ) {
             case Arts::posIdle:
-                if ( _lastPolledState==Arts::posPlaying ) {
-                    if ( _mediaManager->active() )
-                        next();
-                }
                 if ( l_elem_pause!=0 ) l_elem_pause->setLit(false);
                 if ( l_elem_play!=0 ) l_elem_play->setLit(false);
                 if ( status ) status->setValue( 0 );
+
+                if ( oldPolledState==Arts::posPlaying ) {
+                    if ( _mediaManager->active() )
+                        next();
+                }
                 break;
 
@@ -761,5 +802,10 @@
                 break;
         }
-        _lastPolledState = newPolledState; ;
+    } else {
+        if ( _lastPolledState!=Arts::posIdle ) stop();
+
+        if ( l_elem_pause!=0 ) l_elem_pause->setLit(false);
+        if ( l_elem_play!=0 ) l_elem_play->setLit(false);
+        if ( status ) status->setValue( 0 );
     }
 
diff -U2 kaiman.head/kaiman.h kaiman/kaiman.h
--- kaiman.head/kaiman.h	Sun Aug 27 21:58:24 2000
+++ kaiman/kaiman.h	Mon Aug 28 16:29:05 2000
@@ -76,5 +76,9 @@
     bool play( const KURL &url );
     bool play( MediaFile *media );
-    bool tryPlay( bool reverse );
+    bool playNext( bool reverse );
+
+    void seekStart( int value );
+    void seekDrag( int value );
+    void seekStop( int value );
 
     void applyPref();
@@ -106,4 +110,5 @@
     bool _altSkin;
     int _volume;
+    bool _seeking;
     KaimanPrefDlg *_prefDlg;
 };
diff -U2 kaiman.head/kaimanui.rc kaiman/kaimanui.rc
--- kaiman.head/kaimanui.rc	Sun Aug 27 21:58:24 2000
+++ kaiman/kaimanui.rc	Tue Aug 29 14:39:41 2000
@@ -1,4 +1,4 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="kaiman" version="2">
+<kpartgui name="kaiman" version="3">
 
 <MenuBar>
@@ -17,7 +17,8 @@
 	<Action name="add_files"/>
 	<Action name="add_dir"/>
-	<Action name="add_playlist"/>
 	<Separator/>
 	<Action name="remove"/>
+	<Separator/>
+	<Action name="stop"/>
 </ToolBar>
 
diff -U2 kaiman.head/main.cpp kaiman/main.cpp
--- kaiman.head/main.cpp	Sun Aug 27 23:03:23 2000
+++ kaiman/main.cpp	Tue Aug 29 16:30:02 2000
@@ -100,9 +100,9 @@
 {
   KAboutData aboutData( "kaiman", I18N_NOOP("Kaiman"),
-                        "0.3", description, KAboutData::License_GPL, "(c) 2000 \
Stefan Schimanski, Christian Esken"); +                        "0.3.1", description, \
KAboutData::License_GPL, "(c) 2000 Stefan Schimanski, Christian Esken");  \
                aboutData.addAuthor("Stefan Schimanski", 0, "1Stein@gmx.de");
-  aboutData.addAuthor("Christian Esken", "Style engine + first implementation", \
                "esken@kde.org");
-  aboutData.addAuthor("Stefan Westerfeld", "aRts", "stefan@space.twc.de");
-  aboutData.addAuthor("Martin Vogt", "Audio/Video codecs", "mvogt@rhrk.uni-kl.de");
+  aboutData.addAuthor("Christian Esken", I18N_NOOP("First implementation, style \
engine"), "esken@kde.org"); +  aboutData.addAuthor("Stefan Westerfeld", \
I18N_NOOP("aRts"), "stefan@space.twc.de"); +  aboutData.addAuthor("Martin Vogt", \
I18N_NOOP("Audio/Video codecs"), "mvogt@rhrk.uni-kl.de");  
   KCmdLineArgs::init( argc, argv, &aboutData );
@@ -112,5 +112,5 @@
 
   if (!KUniqueApplication::start())
-       exit(0);
+      return 0;
 
   KaimanApp app;
diff -U2 kaiman.head/playlistwin.cpp kaiman/playlistwin.cpp
--- kaiman.head/playlistwin.cpp	Sun Aug 27 21:58:24 2000
+++ kaiman/playlistwin.cpp	Tue Aug 29 17:58:15 2000
@@ -40,4 +40,5 @@
 #include <qpalette.h>
 #include <soundserver.h>
+#include <kstddirs.h>
 
 #include "playlistwin.h"
@@ -310,13 +311,27 @@
 
 
-/*************************************************************/
+void MediaListView::stopLoading()
+{
+    _ID3Reader.stop();
+}
+
+
+/*********************************************************************************/
 
 
 MediaManager::MediaManager( const QString &title, const char *name )
-    : MediaManagerBase( name ), _dirLister( 0 )
+    : MediaManagerBase( name ), _dirLister( 0 ), _title( title )
 {
-    setCaption( title );
+    setCaption( _title );
     initFileExtensions();
 
+    // create directory lister
+    _dirLister = new KDirLister;
+    _dirLister->setNameFilter( allFilesFilter() );
+    connect( _dirLister, SIGNAL(completed()), this, SLOT(dirListerCompleted()) );
+    connect( _dirLister, SIGNAL(newItems(const KFileItemList&)),
+             this, SLOT(dirListerNewItems(const KFileItemList&)) );
+    _dirQueue.setAutoDelete( true );
+
     // create list view
     _list = new MediaListView( this, "MediaListView" );
@@ -343,6 +358,7 @@
     (void)new KAction( i18n("Add &Directory"), "folder", 0, this, SLOT(addDir()),
                        actionCollection(), "add_dir" );
-    (void)new KAction( i18n("Add &Playlist"), "tar", 0, this, SLOT(addPlaylist()),
-                       actionCollection(), "add_playlist" );
+    KAction *stop = new KAction( i18n( "&Stop Loading" ), "stop", Key_Escape, this, \
SLOT(stopLoading()), +                                 actionCollection(), "stop" );
+    stop->setEnabled( false );
 
     createGUI( "kaimanui.rc" );
@@ -353,6 +369,5 @@
 {
     // save config
-    if ( _fileName.url().length()>0 )
-        save();
+    savePlaylist( fileName() );
 
     KConfig *config = kapp->config();
@@ -366,4 +381,13 @@
 
 
+KURL MediaManager::fileName()
+{
+    if ( !_fileName.isMalformed() )
+        return _fileName;
+    else
+        return KURL( kapp->dirs()->saveLocation( "data", "kaiman/" ) + "default.m3u" \
); +}
+
+
 void MediaManager::initFileExtensions()
 {
@@ -433,4 +457,5 @@
 void MediaManager::clear()
 {
+    stopLoading();
     _list->clear();
     emit stop();
@@ -446,5 +471,5 @@
         QTextStream stream( &reader );
 
-        MediaFileItem *last = 0;
+        QListViewItem *last = _list->lastItem();
         while ( !stream.eof() ) {
             QString file = stream.readLine();
@@ -469,16 +494,5 @@
     addPlaylist( url );
     _fileName = url;
-}
-
-
-void MediaManager::addPlaylist()
-{
-    KURL url = KFileDialog::getOpenURL( _baseURL.directory(), "*.m3u|" + i18n("m3u \
                Playlists"),
-                                        this, i18n("Add Playlist") );
-    if ( !url.isMalformed() ) {
-        addPlaylist( url );
-    } else
-        if ( url.url().length()!=0 )
-            KMessageBox::error( this, i18n("Invalid filename: %1").arg(url.url()) );
+    setCaption( url.fileName() );
 }
 
@@ -503,4 +517,8 @@
     // create file filter
     QString filter;
+    filter += allFilesFilter() + "|" + i18n("All Media Files");
+    filter += "\n*|" + i18n("All Files");
+    filter += "\n*.m3u|" + i18n("m3u Playlists");
+
     for ( unsigned idx=0; idx<_fileExtensions.count(); idx++ ) {
         QString fileType = "*." + _fileExtensions[idx] + "|" +
@@ -510,6 +528,4 @@
     }
 
-    filter.prepend( allFilesFilter() + "|" + i18n("All Media Files") + "\n" );
-
     // open file dialog
     KURL::List urls = KFileDialog::getOpenURLs( _baseURL.directory(), filter,
@@ -523,7 +539,28 @@
         for ( KURL::List::Iterator url=urls.begin(); url!=urls.end(); ++url ) {
 
-            if ( !(*url).isMalformed() )
-                last = _list->addNewItem( *url, last );
+            if ( !(*url).isMalformed() ) {
+                if ( (*url).fileName().right(4)==".m3u" )
+                    addPlaylist( *url );
+                else
+                    last = _list->addNewItem( *url, last );
+            }
         }
+
+/*        KAction *stop = actionCollection()->action( "stop" );
+          if ( stop ) stop->setEnabled( true );*/
+    }
+}
+
+
+void MediaManager::addDirectory( const KURL &url )
+{
+    if ( !url.isMalformed() ) {
+        if ( _dirLister->isFinished() )
+            _dirLister->openURL( url, false );
+        else
+            _dirQueue.enqueue( new KURL(url) );
+
+        KAction *stop = actionCollection()->action( "stop" );
+        if ( stop ) stop->setEnabled( true );
     }
 }
@@ -535,11 +572,5 @@
                                                      this, i18n("Add Directory") );
     if ( dir.length()>0 ) {
-         KDirLister *dirLister = new KDirLister;
-         dirLister->setNameFilter( allFilesFilter() );
-         dirLister->openURL( KURL(dir), false );
-         _dirLister = dirLister;
-         connect( _dirLister, SIGNAL(completed()), this, SLOT(dirListerCompleted()) \
                );
-         connect( _dirLister, SIGNAL(newItems(const KFileItemList&)),
-                  this, SLOT(dirListerNewItems(const KFileItemList&)) );
+        addDirectory( KURL(dir) );
     }
 }
@@ -550,5 +581,7 @@
     KFileItemListIterator it( items );
     for (; it.current(); ++it ) {
-        if ( !it.current()->isDir() )
+        if ( it.current()->isDir() )
+            addDirectory( it.current()->url() );
+        else
             addURL( it.current()->url() );
     }
@@ -559,6 +592,14 @@
 {
     kdDebug() << "dirLister completed" << endl;
-    delete _dirLister;
-    _dirLister = 0;
+    _dirLister->stop();
+
+    if ( _dirQueue.isEmpty() ) {
+        KAction *stop = actionCollection()->action( "stop" );
+        if ( stop ) stop->setEnabled( false );
+    } else {
+        KURL url( *_dirQueue.head() );
+        _dirLister->openURL( url, false );
+        _dirQueue.dequeue();
+    }
 }
 
@@ -592,10 +633,14 @@
 void MediaManager::addURL( const KURL &url )
 {
-    if ( !url.isMalformed() ) {
-        _list->addNewItem( url, 0 );
-        _list->triggerUpdate();
-    } else
-        if ( url.url().length()!=0 )
-            KMessageBox::error( this, i18n("Invalid filename: %1").arg(url.url()) );
+    if ( url.fileName().right(4)==".m3u" )
+        addPlaylist( url );
+    else {
+        if ( !url.isMalformed() ) {
+            _list->addNewItem( url, 0 );
+            _list->triggerUpdate();
+        } else
+            if ( url.url().length()!=0 )
+                KMessageBox::error( this, i18n("Invalid filename: \
%1").arg(url.url()) ); +    }
 }
 
@@ -629,7 +674,8 @@
                                         this, i18n("Save Playlist") ) ;
     if ( !url.isMalformed() ) {
-        if ( savePlaylist( url ) )
+        if ( savePlaylist( url ) ) {
             _fileName = url;
-        else
+            setCaption( url.fileName() );
+        } else
             KMessageBox::error( this, i18n("Can't save playlist.") );
     } else
@@ -643,6 +689,16 @@
     clear();
     _fileName = QString();
+    setCaption( _title );
 }
 
 
+void MediaManager::stopLoading()
+{
+    _dirQueue.clear();
+    _dirLister->stop();
+
+    KAction *stop = actionCollection()->action( "stop" );
+    if ( stop ) stop->setEnabled( false );
+}
+
 #include "playlistwin.moc"
diff -U2 kaiman.head/playlistwin.h kaiman/playlistwin.h
--- kaiman.head/playlistwin.h	Sun Aug 27 21:58:24 2000
+++ kaiman/playlistwin.h	Tue Aug 29 17:55:22 2000
@@ -21,4 +21,5 @@
 
 #include <klistview.h>
+#include <qqueue.h>
 #include "playlist.h"
 #include "id3.h"
@@ -28,4 +29,5 @@
 class MediaSetItem;
 class MediaViewItem;
+class KDirLister;
 
 
@@ -72,5 +74,6 @@
  public slots:
     void playSelected();
-    void removeSelected();    
+    void removeSelected();
+    void stopLoading();
 
  protected slots:
@@ -108,5 +111,5 @@
     int position();
 
-    KURL fileName() { return _fileName; };
+    KURL fileName();
     QString aRtsFileMask();
      
@@ -117,6 +120,6 @@
     void loadPlaylist( const KURL &url );
     bool savePlaylist( const KURL &url );
+    void addDirectory( const KURL &url );
 
-    void addPlaylist();
     void addFiles();
     void addDir();
@@ -126,4 +129,5 @@
     void saveAs();
     void openNew();
+    void stopLoading();
 
  protected slots:
@@ -138,6 +142,8 @@
     KURL _fileName;
     KURL _baseURL;
-    QObject *_dirLister;
+    KDirLister *_dirLister;
     QStringList _fileExtensions;
+    QQueue<KURL> _dirQueue;
+    QString _title;
 };
 


_______________________________________________
Kde-multimedia mailing list
Kde-multimedia@master.kde.org
http://master.kde.org/mailman/listinfo/kde-multimedia


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic