[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:       2009-07-11 16:52:44
Message-ID: 1247331164.010189.31049.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 994984 by awainzinger:

Add PlaylistCapability to Handler, IpodHandler.

 M  +1 -0      CMakeLists.txt  
 M  +2 -0      collection/ipodcollection/handler/IpodHandler.h  
 A             collection/ipodcollection/handler/capabilities/IpodPlaylistCapability.cpp \
[License: GPL (v2+)]  A             \
collection/ipodcollection/handler/capabilities/IpodPlaylistCapability.h   [License: \
GPL (v2+)]  D             \
collection/ipodcollection/handler/capabilities/IpodReadCapability.cpp.orig    D       \
collection/mediadevicecollection/CMakeLists.txt    M  +51 -32    \
collection/mediadevicecollection/handler/MediaDeviceHandler.cpp    M  +4 -83     \
collection/mediadevicecollection/handler/MediaDeviceHandler.h    A             \
collection/mediadevicecollection/handler/capabilities/PlaylistCapability.cpp   \
collection/mediadevicecollection/handler/capabilities/ReadCapability.cpp#994983 \
[License: GPL (v2+)]  A             \
collection/mediadevicecollection/handler/capabilities/PlaylistCapability.h   \
[License: GPL (v2+)]  M  +2 -0      \
collection/mediadevicecollection/handler/capabilities/ReadCapability.cpp  


--- trunk/extragear/multimedia/amarok/src/CMakeLists.txt #994983:994984
@@ -80,6 +80,7 @@
   collection/mediadevicecollection/CollectionCapabilityMediaDevice.cpp
   collection/mediadevicecollection/handler/MediaDeviceHandler.cpp
   collection/mediadevicecollection/handler/MediaDeviceHandlerCapability.cpp
+  collection/mediadevicecollection/handler/capabilities/PlaylistCapability.cpp
   collection/mediadevicecollection/handler/capabilities/ReadCapability.cpp
   collection/mediadevicecollection/playlist/MediaDevicePlaylist.cpp
   collection/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.cpp
--- trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/IpodHandler.h \
#994983:994984 @@ -30,6 +30,7 @@
 #include <gpod/itdb.h>
 }
 
+#include "IpodPlaylistCapability.h"
 #include "IpodReadCapability.h"
 
 #include "MediaDeviceMeta.h"
@@ -98,6 +99,7 @@
     virtual bool hasCapabilityInterface( Handler::Capability::Type type ) const;
     virtual Handler::Capability* createCapabilityInterface( \
Handler::Capability::Type type );  
+    friend class Handler::IpodPlaylistCapability;
     friend class Handler::IpodReadCapability;
 
     public slots:
--- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/MediaDeviceHandler.cpp \
#994983:994984 @@ -820,57 +820,76 @@
     }
 
 
-    // Register the playlist provider with the playlistmanager
+    if( !m_pc )
+    {
+        if( this->hasCapabilityInterface( Handler::Capability::Playlist ) )
+        {
+            m_pc = this->create<Handler::PlaylistCapability>();
+            if( !m_pc )
+            {
+                debug() << "Handler does not have \
MediaDeviceHandler::PlaylistCapability. Not parsing playlists."; +            }
+        }
+    }
 
-    // register a playlist provider for this type of device
-    debug() << "adding provider";
-    m_provider = new MediaDeviceUserPlaylistProvider();
+#if 0
+    if( m_pc )
+    {
+        // Register the playlist provider with the playlistmanager
 
-    // Begin parsing the playlists
+        // register a playlist provider for this type of device
+        debug() << "adding provider";
+        m_provider = new MediaDeviceUserPlaylistProvider();
 
-    Meta::MediaDevicePlaylistList playlists;
+        // Begin parsing the playlists
 
-    for ( prepareToParsePlaylists(); !isEndOfParsePlaylistsList(); \
                prepareToParseNextPlaylist() )
-    {
-        nextPlaylistToParse();
+        Meta::MediaDevicePlaylistList playlists;
 
-        if( shouldNotParseNextPlaylist() )
-            continue;
+        for ( m_pc->prepareToParsePlaylists(); !(m_pc->isEndOfParsePlaylistsList()); \
m_pc->prepareToParseNextPlaylist() ) +        {
+            m_pc->nextPlaylistToParse();
 
-        // Create a new track list
+            if( m_pc->shouldNotParseNextPlaylist() )
+                continue;
 
-        Meta::TrackList tracklist;
+            // Create a new track list
 
-        for ( prepareToParsePlaylistTracks(); !isEndOfParsePlaylist(); \
                prepareToParseNextPlaylistTrack() )
-        {
-            nextPlaylistTrackToParse();
-            // Grab the track associated with the next struct
-            Meta::TrackPtr track = Meta::TrackPtr::staticCast( \
                libGetTrackPtrForTrackStruct() );
-            // if successful, add it into the list at the end.
-            // it is assumed that the list has some presorted order
-            // and this is left to the library
+            Meta::TrackList tracklist;
 
-            if ( track )
-                tracklist << track;
+            for ( m_pc->prepareToParsePlaylistTracks(); \
!(m_pc->isEndOfParsePlaylist()); m_pc->prepareToParseNextPlaylistTrack() ) +          \
{ +                m_pc->nextPlaylistTrackToParse();
+                // Grab the track associated with the next struct
+                Meta::TrackPtr track = Meta::TrackPtr::staticCast( \
m_pc->libGetTrackPtrForTrackStruct() ); +                // if successful, add it \
into the list at the end. +                // it is assumed that the list has some \
presorted order +                // and this is left to the library
 
+                if ( track )
+                    tracklist << track;
 
-        }
 
-        // Make a playlist out of this tracklist
+            }
 
-        Meta::MediaDevicePlaylistPtr playlist( new Meta::MediaDevicePlaylist( \
libGetPlaylistName(), tracklist ) ); +            // Make a playlist out of this \
tracklist  
-        // Insert the new playlist into the list of playlists
+            Meta::MediaDevicePlaylistPtr playlist( new Meta::MediaDevicePlaylist( \
m_pc->libGetPlaylistName(), tracklist ) );  
-        //playlists << playlist;
+            // Insert the new playlist into the list of playlists
 
-        // Inform the provider of the new playlist
+            //playlists << playlist;
 
-        m_provider->addPlaylist( playlist );
+            // Inform the provider of the new playlist
+
+            m_provider->addPlaylist( playlist );
+        }
+
+        The::playlistManager()->addProvider(  m_provider,  m_provider->category() );
+        m_provider->sendUpdated();
+
     }
 
-    The::playlistManager()->addProvider(  m_provider,  m_provider->category() );
-    m_provider->sendUpdated();
+#endif
 
     // Inform the provider of these new playlists
 /*
--- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/MediaDeviceHandler.h \
#994983:994984 @@ -21,6 +21,7 @@
 
 #include "MediaDeviceHandlerCapability.h"
 #include "capabilities/ReadCapability.h"
+#include "capabilities/PlaylistCapability.h"
 #include "MediaDeviceMeta.h"
 #include "MemoryCollection.h"
 #include "Meta.h"
@@ -221,74 +222,6 @@
 
     MediaDeviceHandler( QObject *parent );
 
-    /// Parsing of Tracks in Playlists on Device
-    /// NOTE: not required by devices with no playlists, just reimplement empty \
                functions
-
-    /** This method initializes iteration over some list of playlist structs
-    *  e.g. with libgpod, this initializes a GList to the beginning of
-    *  the list of playlists
-    */
-
-    virtual void prepareToParsePlaylists() = 0;
-
-    /** This method runs a test to see if we have reached the end of
-    *  the list of playlists to be parsed on the device, e.g. in libgpod
-    *  this tests if cur != NULL, i.e. if(cur)
-    */
-
-    virtual bool isEndOfParsePlaylistsList() = 0;
-
-    /** This method moves the iterator to the next playlist on the list of
-    *  playlist structs, e.g. with libgpod, cur = cur->next where cur
-    *  is a GList*
-    */
-
-    virtual void prepareToParseNextPlaylist() = 0;
-
-    /** This method attempts to access the special struct of the
-    *  next playlist, so that information can then be parsed from it.
-    *  For libgpod, this is m_currplaylist = ( Itdb_Playlist * ) cur->data
-    */
-
-    virtual void nextPlaylistToParse() = 0;
-
-    /** This method checks if the playlist should be parsed, or skipped.
-    *  Certain playlists, like the master playlist on the iPod, do not
-    *  need to be or should not be parsed.
-    *  @return true if should not parse, false otherwise.
-    */
-
-    virtual bool shouldNotParseNextPlaylist() = 0;
-
-    /** This method initializes iteration over some list of track structs
-    *  that correspond to a playlist struct
-    *  e.g. with libgpod, this initializes a GList to the beginning of
-    *  the list of tracks
-    */
-
-    virtual void prepareToParsePlaylistTracks() = 0;
-
-    /** This method runs a test to see if we have reached the end of
-    *  the list of tracks in the playlist to be parsed on the device, e.g. in \
                libgpod
-    *  this tests if cur != NULL, i.e. if(cur)
-    */
-
-    virtual bool isEndOfParsePlaylist() = 0;
-
-    /** This method moves the iterator to the next track on the playlist of
-    *  track structs, e.g. with libgpod, cur = cur->next where cur
-    *  is a GList*
-    */
-
-    virtual void prepareToParseNextPlaylistTrack() = 0;
-
-    /** This method attempts to access the special struct of the
-    *  next track on the playlist, so that information can then be parsed from it.
-    *  For libgpod, this is m_currtrack = (Itdb_Track*) cur->data
-    */
-
-    virtual void nextPlaylistTrackToParse() = 0;
-
     /** Returns a list of formats supported by the device, all in lowercase
     *  For example mp3, mpeg, aac.  This is used to avoid copying unsupported
     *  types to a particular device.
@@ -353,20 +286,6 @@
 // md:write
     virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ) = 0;
 
-    /** Returns a MediaDeviceTrackPtr that is associated with the currently parsed \
                track struct.
-    *  This is mainly used in playlist parsing, and can be ignored otherwise.
-    *  @return A MediaDeviceTrackPtr to currently parsed track struct
-    */
-// md:plist
-    virtual Meta::MediaDeviceTrackPtr libGetTrackPtrForTrackStruct() = 0;
-
-    /** Returns a string containing the playlist name of the currently parsed \
                playlist struct, if available.
-    *  Only override if your library uses names.
-    *  @return A string with the name of the currently parsed playlist
-    */
-// md:plist
-    virtual QString libGetPlaylistName() = 0;
-
     /** Adds the newly created track struct now populated with info into the
     *  database struct of the particular device, e.g. into the itdb for Ipods.
     *  MTP devices automatically add the track into the database upon copying,
@@ -374,6 +293,7 @@
     *  @param track The track whose associated track struct is to be added \
     into the database.
     */
+
 // md:write
     virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) = 0;
 
@@ -543,7 +463,8 @@
     QMutex m_mutex; /// A make certain operations atomic when threads are at play
 
     /// Capability-related variables
-    Handler::ReadCapability *m_rc;
+    Handler::PlaylistCapability *m_pc;
+    Handler::ReadCapability     *m_rc;
 
 };
 
--- trunk/extragear/multimedia/amarok/src/collection/mediadevicecollection/handler/capabilities/ReadCapability.cpp \
#994983:994984 @@ -20,3 +20,5 @@
 {
     // nothing to do here
 }
+
+#include "ReadCapability.moc"


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

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