extragear/multimedia/amarok

Ian Monroe ian.monroe at gmail.com
Tue Aug 29 04:17:01 UTC 2006


SVN commit 578346 by ianmonroe:

 r6509 at wasabi:  ian | 2006-08-28 23:01:03 -0500
 DAAP client shows connection errors to the user and no longer says
 "Loading" perpetually. After a failed connection, the user can now
 try again.
 Please report any problems connecting to a DAAP server where Amarok
 does not report an error.
 CCMAIL:amarok at kde.org
 


 _M            . (directory)  
 M  +3 -2      ChangeLog  
 M  +21 -5     src/mediadevice/daap/daapclient.cpp  
 M  +2 -0      src/mediadevice/daap/daapclient.h  
 M  +18 -0     src/mediadevice/daap/daapreader/authentication/contentfetcher.cpp  
 M  +8 -1      src/mediadevice/daap/daapreader/authentication/contentfetcher.h  
 M  +14 -1     src/mediadevice/daap/daapreader/reader.cpp  
 M  +7 -0      src/mediadevice/daap/daapreader/reader.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #578345:578346
@@ -20,8 +20,9 @@
     * Sort numeric columns in flat collection view numerically. (BR 130667)
     * Dynamic Collection broke flat collection view when the Filename column
       was added (BR 132874)
-    * fixed bug which prevented Amarok from creating the collection database
-      in rare cicumstances using Sqlite (BR 133072)
+    * DAAP client shows connection errors to the user and no longer says
+      "Loading" perpetually. After a failed connection, the user can now
+      try again.
 
 VERSION 1.4.2:
   FEATURES:
--- trunk/extragear/multimedia/amarok/src/mediadevice/daap/daapclient.cpp #578345:578346
@@ -476,6 +476,7 @@
         connect( reader, SIGNAL( daapBundles( const QString&, Daap::SongList ) ),
                 this, SLOT( createTree( const QString&, Daap::SongList ) ) );
         connect( reader, SIGNAL( passwordRequired() ), this, SLOT( passwordPrompt() ) );
+        connect( reader, SIGNAL( httpError( const QString& ) ), root, SLOT( httpError( const QString& ) ) );
         reader->loginRequest();
     }
     else
@@ -554,9 +555,10 @@
                                                  QString::null, m_daapClient, ( m_ip + ":3689" ).ascii() );
         setReader ( reader );
 
-        reader->connect( reader, SIGNAL( daapBundles( const QString&, Daap::SongList ) ),
+        connect( reader, SIGNAL( daapBundles( const QString&, Daap::SongList ) ),
                 m_daapClient, SLOT( createTree( const QString&, Daap::SongList ) ) );
-        reader->connect( reader, SIGNAL( passwordRequired() ), m_daapClient, SLOT( passwordPrompt() ) );
+        connect( reader, SIGNAL( passwordRequired() ), m_daapClient, SLOT( passwordPrompt() ) );
+        connect( reader, SIGNAL( httpError( const QString& ) ), this, SLOT( httpError( const QString& ) ) );
         reader->loginRequest();
         m_loaded = true;
     }
@@ -564,19 +566,22 @@
          MediaItem::setOpen( true );
 }
 
-void ServerItem::startAnimation()
+void
+ServerItem::startAnimation()
 {
     if( !m_animationTimer.isActive() )
         m_animationTimer.start( ANIMATION_INTERVAL );
 }
 
-void ServerItem::stopAnimation()
+void
+ServerItem::stopAnimation()
 {
     m_animationTimer.stop();
     setType( MediaItem::DIRECTORY ); //restore icon
 }
 
-void ServerItem::slotAnimation()
+void
+ServerItem::slotAnimation()
 {
     m_iconCounter % 2 ?
         setPixmap( 0, *m_loading1 ):
@@ -585,6 +590,17 @@
     m_iconCounter++;
 }
 
+void
+ServerItem::httpError( const QString& errorString )
+{
+    stopAnimation();
+    resetTitle();
+    amaroK::StatusBar::instance()->longMessage( i18n( "The following error occured while trying to connect to the remote server:<br>%1").arg( errorString ) );
+    m_reader->deleteLater();
+    m_reader = 0;
+    m_loaded = false;
+}
+
 #include "daapclient.moc"
 
 #endif /* AMAROK_DAAPCLIENT_CPP */
--- trunk/extragear/multimedia/amarok/src/mediadevice/daap/daapclient.h #578345:578346
@@ -116,6 +116,8 @@
         
         QString key() const { return key( m_host, m_port ); }
         static QString key( const QString& host, Q_UINT16 port ) { return host + ':' + QString::number( port ); }
+    public slots:
+        void httpError( const QString& );
     private slots:
         void slotAnimation();
 
--- trunk/extragear/multimedia/amarok/src/mediadevice/daap/daapreader/authentication/contentfetcher.cpp #578345:578346
@@ -30,7 +30,9 @@
  : QHttp(hostname, port, parent, name)
  , m_hostname( hostname )
  , m_port( port )
+ , m_selfDestruct( false )
 {
+    connect( this, SIGNAL( stateChanged( int ) ), this , SLOT( checkForErrors( int ) ) );
     QCString pass = password.utf8();
     if( !password.isNull() )
     {
@@ -75,5 +77,21 @@
     request( header );
 }
 
+/**
+ *  QHttp enjoys forgetting to emit a requestFinished when there's an error
+ *  This gets around that.
+ */
+void
+ContentFetcher::checkForErrors( int /*state*/ )
+{
+    if( !m_selfDestruct && error() != 0 )
+    {
+        debug() << "there is an error? " << error() << " " << errorString() << endl;
+        m_selfDestruct = true;
+        emit httpError( errorString() );
+    }
+}
+
+
 #include "contentfetcher.moc"
 
--- trunk/extragear/multimedia/amarok/src/mediadevice/daap/daapreader/authentication/contentfetcher.h #578345:578346
@@ -34,11 +34,18 @@
 
         void getDaap( const QString & path );
         QDataStream& results();
- 
+
+    private slots:
+        void checkForErrors( int state );
+
+    signals:
+        void httpError( const QString& );
+
     private:
         QString m_hostname;
         Q_UINT16 m_port;
         QCString m_authorize;
+        bool m_selfDestruct;
         static int s_requestId; //! Apple needs this for some reason
 };
 
--- trunk/extragear/multimedia/amarok/src/mediadevice/daap/daapreader/reader.cpp #578345:578346
@@ -162,6 +162,7 @@
 Reader::logoutRequest()
 {
     ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerLogoutHttp" );
+    connect( http, SIGNAL( httpError( const QString& ) ), this, SLOT( fetchingError( const QString& ) ) );
     connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( logoutRequest( int, bool ) ) );
     http->getDaap( "/logout?" + m_loginString );
 }
@@ -176,7 +177,9 @@
 void
 Reader::loginRequest()
 {
+    DEBUG_BLOCK
     ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerHttp");
+    connect( http, SIGNAL( httpError( const QString& ) ), this, SLOT( fetchingError( const QString& ) ) );
     connect( http, SIGNAL(  responseHeaderReceived( const QHttpResponseHeader & ) )
             , this, SLOT( loginHeaderReceived( const QHttpResponseHeader & ) ) );
     http->getDaap( "/login" );
@@ -185,6 +188,7 @@
 void
 Reader::loginHeaderReceived( const QHttpResponseHeader & resp )
 {
+    DEBUG_BLOCK
     ContentFetcher* http = (ContentFetcher*) sender();
     disconnect( http, SIGNAL(  responseHeaderReceived( const QHttpResponseHeader & ) )
             , this, SLOT( loginHeaderReceived( const QHttpResponseHeader & ) ) );
@@ -197,14 +201,15 @@
     connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( loginFinished( int, bool ) ) );
 }
 
+
 void
 Reader::loginFinished( int /* id */, bool error )
 {
+    DEBUG_BLOCK
     ContentFetcher* http = (ContentFetcher*) sender();
     disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( loginFinished( int, bool ) ) );
     if( error )
     { 
-        debug() << http->error() << endl;
         http->deleteLater();
         return;
     }
@@ -219,6 +224,7 @@
 void
 Reader::updateFinished( int /*id*/, bool error )
 {
+    DEBUG_BLOCK
     ContentFetcher* http = (ContentFetcher*) sender();
     disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( updateFinished( int, bool ) ) );
     if( error )
@@ -404,5 +410,12 @@
 
     parentMap[tag].asList().append(element);
 }
+
+void
+Reader::fetchingError( const QString& error )
+{
+    const_cast< QObject* >( sender() )->deleteLater();
+    emit httpError( error );
+}
 #include "reader.moc"
 
--- trunk/extragear/multimedia/amarok/src/mediadevice/daap/daapreader/reader.h #578345:578346
@@ -24,6 +24,11 @@
 class MetaBundle;
 class ServerItem;
 class QHttpResponseHeader;
+
+namespace QHttp {
+    class Error;
+}
+
 namespace Daap {
 typedef QMap<QString, QVariant> Map;
 
@@ -72,9 +77,11 @@
             void updateFinished( int id , bool error );
             void databaseIdFinished( int id , bool error );
             void songListFinished( int id, bool error );
+            void fetchingError( const QString& error );
 
         signals:
             void daapBundles( const QString& host, Daap::SongList bundles );
+            void httpError( const QString& );
             void passwordRequired();
 
         private:



More information about the Amarok mailing list