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

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

SVN commit 995010 by awainzinger:

Add write capability for Handler/IpodHandler.

 M  +2 -0      ipodcollection/CMakeLists.txt  
 M  +8 -0      ipodcollection/handler/IpodHandler.cpp  
 M  +1 -0      ipodcollection/handler/IpodHandler.h  
 A             ipodcollection/handler/capabilities/IpodWriteCapability.cpp   \
[License: GPL (v2+)]  A             \
ipodcollection/handler/capabilities/IpodWriteCapability.h   [License: GPL (v2+)]  M  \
+66 -55    mediadevicecollection/handler/MediaDeviceHandler.cpp    M  +9 -2      \
mediadevicecollection/handler/MediaDeviceHandler.h    A             \
mediadevicecollection/handler/capabilities/WriteCapability.cpp   [License: GPL (v2+)] \
A             mediadevicecollection/handler/capabilities/WriteCapability.h   \
[License: GPL (v2+)]


--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/CMakeLists.txt \
#995009:995010 @@ -40,7 +40,9 @@
     set(amarok_collection-ipodcollection_PART_SRCS
 	IpodCollection.cpp
 	handler/IpodHandler.cpp
+	handler/capabilities/IpodPlaylistCapability.cpp
 	handler/capabilities/IpodReadCapability.cpp
+	handler/capabilities/IpodWriteCapability.cpp	
 	support/IpodDeviceInfo.cpp
 	support/IpodConnectionAssistant.cpp)
 	kde4_add_plugin(amarok_collection-ipodcollection WITH_PREFIX \
                ${amarok_collection-ipodcollection_PART_SRCS})
--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/IpodHandler.cpp \
#995009:995010 @@ -1772,6 +1772,10 @@
     {
         case Handler::Capability::Readable:
             return true;
+        case Handler::Capability::Playlist:
+            return true;
+        case Handler::Capability::Writable:
+            return true;
 
         default:
             return false;
@@ -1785,6 +1789,10 @@
     {
         case Handler::Capability::Readable:
             return new Handler::IpodReadCapability( this );
+        case Handler::Capability::Playlist:
+            return new Handler::IpodPlaylistCapability( this );
+        case Handler::Capability::Writable:
+            return new Handler::IpodWriteCapability( this );
 
         default:
             return 0;
--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/IpodHandler.h \
#995009:995010 @@ -105,6 +105,7 @@
 =======
 >>>>>>> Add capabilities for Media Devices, totally separate from general Capability \
being used for Collections, Tracks etc.  I have the plan to make them all use one \
base class, but with separate enums for each set of types, since it makes 0 sense to \
check a track for capabilities of a collection.  Added ReadCapability, and \
implemented for Ipods.:src/collection/ipodcollection/handler/IpodHandler.h  friend \
class Handler::IpodReadCapability; +    friend class Handler::IpodWriteCapability;
 
     public slots:
         void slotInitializeIpod();
--- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/MediaDeviceHandler.cpp \
#995009:995010 @@ -53,6 +53,9 @@
 MediaDeviceHandler::MediaDeviceHandler( QObject *parent )
 : QObject( parent )
 , m_memColl( qobject_cast<MediaDeviceCollection*>(parent) )
+, m_pc( 0 )
+, m_rc( 0 )
+, m_wc( 0 )
 {
     DEBUG_BLOCK
 
@@ -100,24 +103,24 @@
 MediaDeviceHandler::setBasicMediaDeviceTrackInfo( const Meta::TrackPtr& srcTrack, \
MediaDeviceTrackPtr destTrack )  {
     DEBUG_BLOCK
-           libSetTitle( destTrack, srcTrack->name() );
-           libSetAlbum( destTrack, srcTrack->album()->name() );
-           libSetArtist( destTrack, srcTrack->artist()->name() );
-           libSetComposer( destTrack, srcTrack->composer()->name() );
-           libSetGenre( destTrack, srcTrack->genre()->name() );
-           libSetYear( destTrack, srcTrack->year()->name() );
-           libSetLength( destTrack, srcTrack->length() );
-           libSetTrackNumber( destTrack, srcTrack->trackNumber() );
-           libSetComment( destTrack, srcTrack->comment() );
-           libSetDiscNumber( destTrack, srcTrack->discNumber() );
-           libSetBitrate( destTrack, srcTrack->bitrate() );
-           libSetSamplerate( destTrack, srcTrack->sampleRate() );
+           m_wc->libSetTitle( destTrack, srcTrack->name() );
+           m_wc->libSetAlbum( destTrack, srcTrack->album()->name() );
+           m_wc->libSetArtist( destTrack, srcTrack->artist()->name() );
+           m_wc->libSetComposer( destTrack, srcTrack->composer()->name() );
+           m_wc->libSetGenre( destTrack, srcTrack->genre()->name() );
+           m_wc->libSetYear( destTrack, srcTrack->year()->name() );
+           m_wc->libSetLength( destTrack, srcTrack->length() );
+           m_wc->libSetTrackNumber( destTrack, srcTrack->trackNumber() );
+           m_wc->libSetComment( destTrack, srcTrack->comment() );
+           m_wc->libSetDiscNumber( destTrack, srcTrack->discNumber() );
+           m_wc->libSetBitrate( destTrack, srcTrack->bitrate() );
+           m_wc->libSetSamplerate( destTrack, srcTrack->sampleRate() );
            //libSetBpm( destTrack, srcTrack->bpm() );
-           libSetFileSize( destTrack, srcTrack->filesize() );
-           libSetPlayCount( destTrack, srcTrack->playCount() );
-           libSetLastPlayed( destTrack, srcTrack->lastPlayed() );
-           libSetRating( destTrack, srcTrack->rating() );
-           libSetType( destTrack, srcTrack->type() );
+           m_wc->libSetFileSize( destTrack, srcTrack->filesize() );
+           m_wc->libSetPlayCount( destTrack, srcTrack->playCount() );
+           m_wc->libSetLastPlayed( destTrack, srcTrack->lastPlayed() );
+           m_wc->libSetRating( destTrack, srcTrack->rating() );
+           m_wc->libSetType( destTrack, srcTrack->type() );
            //libSetPlayableUrl( destTrack, srcTrack );
 /*
            if( srcTrack->album()->hasImage() )
@@ -265,8 +268,21 @@
 MediaDeviceHandler::copyTrackListToDevice(const Meta::TrackList tracklist)
 {
 
-        DEBUG_BLOCK
+    DEBUG_BLOCK
 
+    if( !m_wc )
+    {
+        if( this->hasCapabilityInterface( Handler::Capability::Writable ) )
+        {
+            m_wc = this->create<Handler::WriteCapability>();
+            if( !m_wc )
+            {
+                debug() << "Handler does not have \
MediaDeviceHandler::WriteCapability. Aborting copy."; +                return;
+            }
+        }
+    }
+
     bool isDupe;
     bool hasDupe;
     QString format;
@@ -294,7 +310,7 @@
 
         format = track->type();
 
-        if( !supportedFormats().contains( format ) )
+        if( !(m_wc->supportedFormats().contains( format )) )
         {
              QString error = "Unsupported format: " + format;
              m_tracksFailed.insert( track, error );
@@ -385,7 +401,7 @@
 
     // prepare to copy
 
-    prepareToCopy();
+    m_wc->prepareToCopy();
 
     m_numTracksToCopy = m_tracksToCopy.count();
     m_tracksCopying.clear();
@@ -443,11 +459,11 @@
 
     // find path to copy to
 
-    findPathToCopy( track, destTrack );
+    m_wc->findPathToCopy( track, destTrack );
 
     // Create a track struct, associate it to destTrack
 
-    libCreateTrack( destTrack );
+    m_wc->libCreateTrack( destTrack );
 
     // Fill the track struct of the destTrack with info from the track parameter as \
source  
@@ -455,13 +471,13 @@
 
     // set up the play url
 
-    libSetPlayableUrl( destTrack, track );
+    m_wc->libSetPlayableUrl( destTrack, track );
 
     m_trackSrcDst[ track ] = destTrack; // associate source with destination, for \
finalizing copy  
     // Copy the file to the device
 
-    success = libCopyTrack( track, destTrack );
+    success = m_wc->libCopyTrack( track, destTrack );
 
     return success;
 }
@@ -477,11 +493,11 @@
 
     // Add the track struct into the database, if the library needs to
 
-    addTrackInDB( destTrack );
+    m_wc->addTrackInDB( destTrack );
 
     // Inform subclass that a track has been added to the db
 
-    databaseChanged();
+    m_wc->databaseChanged();
 
     // Add the new Meta::MediaDeviceTrackPtr into the device collection
 
@@ -534,6 +550,19 @@
 {
     DEBUG_BLOCK
 
+    if( !m_wc )
+    {
+        if( this->hasCapabilityInterface( Handler::Capability::Writable ) )
+        {
+            m_wc = this->create<Handler::WriteCapability>();
+            if( !m_wc )
+            {
+                debug() << "Handler does not have \
MediaDeviceHandler::WriteCapability. Aborting remove."; +                return;
+            }
+        }
+    }
+
     // Init the list of tracks to be deleted
 
     m_tracksToDelete = tracks;
@@ -550,7 +579,7 @@
      connect( this, SIGNAL( databaseWritten(bool)),
               this, SLOT( slotDatabaseWritten(bool)), Qt::QueuedConnection );
 
-    prepareToDelete();
+    m_wc->prepareToDelete();
 
     m_numTracksToRemove = m_tracksToDelete.count();
 
@@ -585,7 +614,7 @@
 
     // Remove the physical file from the device, perhaps using a libcall, or KIO
 
-    libDeleteTrackFile( devicetrack );
+    m_wc->libDeleteTrackFile( devicetrack );
 
 
 }
@@ -598,11 +627,11 @@
 
     // Remove the track struct from the db, references to it
 
-    removeTrackFromDB( devicetrack );
+    m_wc->removeTrackFromDB( devicetrack );
 
     // delete the struct associated with this track
 
-    libDeleteTrack( devicetrack );
+    m_wc->libDeleteTrack( devicetrack );
 
     // remove from titlemap
 
@@ -614,7 +643,7 @@
 
     // Inform subclass that a track has been removed from
 
-    databaseChanged();
+    m_wc->databaseChanged();
 
     emit incrementProgress();
 
@@ -745,9 +774,12 @@
 
     if( !m_rc )
     {
+        debug() << "RC does not exist";
         if( this->hasCapabilityInterface( Handler::Capability::Readable ) )
         {
+            debug() << "Has read capability interface";
             m_rc = this->create<Handler::ReadCapability>();
+            debug() << "Created rc";
             if( !m_rc )
             {
                 debug() << "Handler does not have \
MediaDeviceHandler::ReadCapability. Aborting parse."; @@ -832,7 +864,7 @@
         }
     }
 
-#if 0
+
     if( m_pc )
     {
         // Register the playlist provider with the playlistmanager
@@ -889,27 +921,6 @@
 
     }
 
-#endif
-
-    // Inform the provider of these new playlists
-/*
-    foreach( Meta::MediaDevicePlaylistPtr playlist, playlists )
-        {
-
-        }
-*/
-
-
-    // HACK: add a blank playlist
-    /*
-    TrackList tracks;
-    MediaDeviceTrackPtr tp( new MediaDeviceTrack( 0 ) );
-    TrackPtr track = TrackPtr::staticCast( tp );
-    MediaDevicePlaylistPtr list(  new MediaDevicePlaylist(  "Testlist",  tracks ) );
-    m_provider->addPlaylist( list );
-    */
-
-
     // Finally, assign the created maps to the collection
 
     debug() << "Setting memcoll stuff";
@@ -1010,8 +1021,8 @@
 
     setBasicMediaDeviceTrackInfo( track, trackPtr );
 
-    updateTrack( trackPtr );
-    databaseChanged();
+    m_wc->updateTrack( trackPtr );
+    m_wc->databaseChanged();
 }
 
 void
--- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/MediaDeviceHandler.h \
#995009:995010 @@ -20,11 +20,10 @@
 #define MEDIADEVICEHANDLER_H
 
 #include "MediaDeviceHandlerCapability.h"
+#include "capabilities/PlaylistCapability.h"
 #include "capabilities/ReadCapability.h"
-#include "capabilities/PlaylistCapability.h"
 #include "capabilities/WriteCapability.h"
 
-
 #include "MediaDeviceMeta.h"
 #include "MemoryCollection.h"
 #include "Meta.h"
@@ -226,6 +225,7 @@
     MediaDeviceHandler( QObject *parent );
 
 <<<<<<< HEAD:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
+<<<<<<< HEAD:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
 =======
     /// Parsing of Tracks in Playlists on Device
     /// NOTE: not required by devices with no playlists, just reimplement empty \
functions @@ -452,7 +452,10 @@
     */
     // md:write
     virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) \
}; +=======
 
+>>>>>>> Add write capability for \
Handler/IpodHandler.:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
 +
     MediaDeviceCollection   *m_memColl; /// Associated collection
 
     bool m_success;
@@ -560,9 +563,13 @@
 <<<<<<< HEAD:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
     Handler::PlaylistCapability *m_pc;
     Handler::ReadCapability     *m_rc;
+<<<<<<< HEAD:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
 =======
     Handler::ReadCapability *m_rc;
 >>>>>>> Add capabilities for Media Devices, totally separate from general Capability \
being used for Collections, Tracks etc.  I have the plan to make them all use one \
base class, but with separate enums for each set of types, since it makes 0 sense to \
check a track for capabilities of a collection.  Added ReadCapability, and \
implemented for Ipods.:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
 +=======
+    Handler::WriteCapability    *m_wc;
+>>>>>>> Add write capability for \
Handler/IpodHandler.:src/collection/mediadevicecollection/handler/MediaDeviceHandler.h
  
 };
 


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

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