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

List:       kde-commits
Subject:    extragear/multimedia/amarok/src
From:       Alejandro Daniel Wainzinger <aikawarazuni () gmail ! com>
Date:       2008-08-11 17:07:20
Message-ID: 1218474440.041084.17058.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 845439 by awainzinger:

Factories will only check for their type of device.  This fixes crashing with mtp \
devices at startup, etc.


 M  +34 -12    MediaDeviceMonitor.cpp  
 M  +5 -2      MediaDeviceMonitor.h  
 M  +3 -3      collection/ipodcollection/IpodCollection.cpp  
 M  +9 -1      collection/mtpcollection/MtpCollection.cpp  
 M  +11 -4     collection/mtpcollection/handler/MtpHandler.cpp  


--- trunk/extragear/multimedia/amarok/src/MediaDeviceMonitor.cpp #845438:845439
@@ -72,42 +72,64 @@
     return;
 }
 
-void
-MediaDeviceMonitor::refreshDevices()
+QStringList
+MediaDeviceMonitor::getDevices()
 {
     DEBUG_BLOCK
-    /* Refresh cache */
+    /* get list of devices */
     MediaDeviceCache::instance()->refreshCache();
-    QStringList udiList = MediaDeviceCache::instance()->getAll();
+    return MediaDeviceCache::instance()->getAll();
 
-    /* check cache for supported devices */
-
-    checkDevices( udiList );
 }
 
 void
-MediaDeviceMonitor::checkDevices( const QStringList &udiList )
+MediaDeviceMonitor::checkDevices()
 {
     DEBUG_BLOCK
     /* poll udi list for supported devices */
+
+    checkDevicesForMtp();
+    checkDevicesForIpod();
+
+}
+
+void
+MediaDeviceMonitor::checkDevicesForMtp()
+{
+
+    QStringList udiList = getDevices();
+
+    /* poll udi list for supported devices */
     foreach(const QString &udi, udiList )
     {
-        /* if iPod found, emit signal */
+        /* if mtp device found, emit signal */
         if( isIpod( udi ) )
         {
             emit ipodDetected( MediaDeviceCache::instance()->volumeMountPoint(udi), \
udi );  }
-        else if( isMtp( udi ) )
+    }
+}
+
+void
+MediaDeviceMonitor::checkDevicesForIpod()
+{
+    QStringList udiList = getDevices();
+
+    /* poll udi list for supported devices */
+    foreach(const QString &udi, udiList )
+    {
+        if( isMtp( udi ) )
         {
             Solid::PortableMediaPlayer* pmp = Solid::Device( udi \
).as<Solid::PortableMediaPlayer>();  QString serial = pmp->driverHandle( "mtp" \
).toString();  debug() << "Serial is: " << serial;
             emit mtpDetected( udi, serial );
         }
-
     }
 }
 
+
+
 void
 MediaDeviceMonitor::deviceAdded(  const QString &udi )
 {
@@ -123,7 +145,7 @@
 
     // send new udi for testing
 
-    checkDevices( udiList );
+    checkDevices();
 
     return;
 }
--- trunk/extragear/multimedia/amarok/src/MediaDeviceMonitor.h #845438:845439
@@ -52,7 +52,10 @@
 
     void init(); // connect to MediaDeviceCache
 
-    void refreshDevices(); // check all connected devices
+    
+    QStringList getDevices(); // get list of devices
+    void checkDevicesForMtp();
+    void checkDevicesForIpod();
 
     signals:
         void deviceRemoved( const QString &udi );
@@ -75,7 +78,7 @@
         bool isIpod( const QString &udi );
         bool isMtp( const QString &udi );
 
-        void checkDevices( const QStringList &udiList); // scans for supported \
devices +        void checkDevices(); // scans for supported devices
 
         static MediaDeviceMonitor* s_instance;
 
--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/IpodCollection.cpp \
#845438:845439 @@ -64,11 +64,11 @@
         connect( MediaDeviceMonitor::instance(), SIGNAL( ipodDetected( const QString \
                &, const QString & ) ),
                  SLOT( ipodDetected( const QString &, const QString & ) ) );
 
-    // force refresh to scan for ipod
-    // NOTE: perhaps a signal/slot mechanism would make more sense
-    MediaDeviceMonitor::instance()->refreshDevices();
+    // scan for ipods
 
+    MediaDeviceMonitor::instance()->checkDevicesForIpod();
 
+
     return;
 }
 
--- trunk/extragear/multimedia/amarok/src/collection/mtpcollection/MtpCollection.cpp \
#845438:845439 @@ -68,7 +68,7 @@
 
     // force refresh to scan for mtp, begin signal/slot process
 
-    MediaDeviceMonitor::instance()->refreshDevices();
+    MediaDeviceMonitor::instance()->checkDevicesForMtp();
 
 
     return;
@@ -79,6 +79,10 @@
 {
     MtpCollection* coll = 0;
 
+    debug() << "Udi is: " << udi;
+
+    debug() << "Udi is in map: " << (m_collectionMap.contains( udi ) ? "true" : \
"false" ); +
      if( !m_collectionMap.contains( udi ) )
         {
             // create new collection
@@ -92,15 +96,19 @@
                // begin signal/slot construction process
                coll->init();
         }
+        else
+            debug() << "MTP Collection for this device is already made: " << udi;
 
 }
 
 void
 MtpCollectionFactory::slotCollectionSucceeded( MtpCollection *coll )
 {
+    DEBUG_BLOCK
     connect( coll, SIGNAL( collectionDisconnected( const QString &) ),
              SLOT( slotCollectionDisconnected( const QString & ) ) );
     m_collectionMap.insert( coll->udi(), coll );
+    debug() << "Inserted into the collectionMap: " << coll->udi();
     emit newCollection( coll );
     debug() << "emitting new mtp collection";
 }
--- trunk/extragear/multimedia/amarok/src/collection/mtpcollection/handler/MtpHandler.cpp \
#845438:845439 @@ -45,6 +45,7 @@
 #include <QFileInfo>
 #include <QString>
 #include <QStringList>
+#include <QTextStream>
 #include <QTime>
 
 using namespace Mtp;
@@ -117,6 +118,7 @@
 
     if( m_success )
     {
+        debug() << "Got mtp list, connecting to device using thread";
         ThreadWeaver::Weaver::instance()->enqueue( new WorkerThread( numrawdevices, \
rawdevices, serial, this ) );  }
     else
@@ -344,12 +346,15 @@
         trackmeta->genre = qstrdup( track->genre()->prettyName().toUtf8() );
     }
 
+    // TODO: port to Qt4
+
     if( track->year() > 0 )
     {
         QString date;
-        QTextOStream( &date ) << track->year() << "0101T0000.0";
+        QTextStream( &date ) << track->year() << "0101T0000.0";
         trackmeta->date = qstrdup( date.toUtf8() );
     }
+
     else
     {
         trackmeta->date = qstrdup( "00010101T0000.0" );
@@ -609,7 +614,7 @@
 MtpHandler::deleteTrackFromDevice( const Meta::MtpTrackPtr &track )
 {
     DEBUG_BLOCK
-    
+
     //If nothing is left in a folder, delete the folder
     u_int32_t object_id = track->id();
 
@@ -633,7 +638,7 @@
     debug() << "object deleted";
 
     return true;
-    
+
 }
 
 int
@@ -723,7 +728,7 @@
     if( track->year() > 0 )
     {
         QString date;
-        QTextOStream( &date ) << track->year() << "0101T0000.0";
+        QTextStream( &date ) << track->year() << "0101T0000.0";
         trackmeta->date = qstrdup( date.toUtf8() );
     }
     else
@@ -1061,7 +1066,9 @@
 void
 MtpHandler::slotDeviceMatchSucceeded()
 {
+    DEBUG_BLOCK
     getDeviceInfo();
+    debug() << "Device matches serial, emitting succeeded()";
     emit succeeded();
 }
 void


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

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