1 /****************************************************************************************
2  * Copyright (c) 2009 Alejandro Wainzinger <aikawarazuni@gmail.com>                     *
3  * Copyright (c) 2010 Bart Cerneels <bart.cerneels@kde.org>                             *
4  *                                                                                      *
5  * This program is free software; you can redistribute it and/or modify it under        *
6  * the terms of the GNU General Public License as published by the Free Software        *
7  * Foundation; either version 2 of the License, or (at your option) any later           *
8  * version.                                                                             *
9  *                                                                                      *
10  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
12  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
13  *                                                                                      *
14  * You should have received a copy of the GNU General Public License along with         *
15  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
16  ****************************************************************************************/
17 
18 #ifndef PODCASTCAPABILITY_H
19 #define PODCASTCAPABILITY_H
20 
21 #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h"
22 #include "core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastMeta.h"
23 
24 namespace Handler
25 {
26     class MEDIADEVICECOLLECTION_EXPORT PodcastCapability : public Handler::Capability
27     {
28         public:
29             ~PodcastCapability() override;
30 
31             /**
32              * This method initializes iteration over some list of Podcast structs
33              * e.g. with libgpod, this initializes a GList to the beginning of
34              * the list of Podcasts
35              */
36             virtual void prepareToParsePodcasts() = 0;
37 
38             /**
39              * This method runs a test to see if we have reached the end of
40              * the list of Podcasts to be parsed on the device, e.g. in libgpod
41              * this tests if cur != NULL, i.e. if(cur)
42              */
43             virtual bool isEndOfParsePodcastsList() = 0;
44 
45             /**
46              * This method moves the iterator to the next Podcast on the list of
47              * Podcast structs, e.g. with libgpod, cur = cur->next where cur
48              * is a GList*
49              */
50             virtual void prepareToParseNextPodcast() = 0;
51 
52             /**
53              * This method attempts to access the special struct of the
54              * next Podcast, so that information can then be parsed from it.
55              * For libgpod, this is m_currPodcast = ( Itdb_Podcast * ) cur->data
56              */
57             virtual void nextPodcastToParse() = 0;
58 
59             /**
60              * This method checks if the Podcast should be parsed, or skipped.
61              * Certain Podcasts, like the master Podcast on the iPod, do not
62              * need to be or should not be parsed.
63              * @return true if should not parse, false otherwise.
64              */
65             virtual bool shouldNotParseNextPodcast() = 0;
66 
67             /**
68              * This method initializes iteration over some list of track structs
69              * that correspond to a Podcast struct
70              * e.g. with libgpod, this initializes a GList to the beginning of
71              * the list of tracks
72              */
73             virtual void prepareToParsePodcastEpisode() = 0;
74 
75             /**
76              * This method runs a test to see if we have reached the end of
77              * the list of episode in the Podcast to be parsed on the device, e.g. in libgpod
78              * this tests if cur != NULL, i.e. if(cur)
79              */
80             virtual bool isEndOfParsePodcast() = 0;
81 
82             /**
83              * This method moves the iterator to the next track on the Podcast of
84              * track structs, e.g. with libgpod, cur = cur->next where cur
85              * is a GList*
86              */
87             virtual void prepareToParseNextPodcastEpisode() = 0;
88 
89             /**
90              * This method attempts to access the special struct of the
91              * next track on the Podcast, so that information can then be parsed from it.
92              * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data
93              */
94             virtual void nextPodcastEpisodeToParse() = 0;
95 
96             /**
97              * Returns a MediaDeviceTrackPtr that is associated with the currently parsed track struct.
98              * @return A MediaDeviceTrackPtr to currently parsed track struct
99              */
100             virtual MediaDevicePodcastEpisodePtr libGetEpisodePtrForEpisodeStruct() = 0;
101 
102             /**
103              * Returns a string containing the Podcast name of the currently parsed Podcast struct, if available.
104              * @return A string with the name of the currently parsed Podcast
105              */
106             virtual QString libGetPodcastName() = 0;
107 
108             /**
109              * Adds a podcast
110              */
111             virtual void addPodcast( const Podcasts::PodcastChannelPtr &channel ) = 0;
112 
113             /**
114              * Deletes a particular Podcast from the device
115              * @param channel the channel to remove
116              */
117             virtual void removePodcast( const MediaDevicePodcastChannelPtr &channel ) = 0;
118 
119             /**
120              * Deletes a particular Podcast Episode from the device
121              * @param episode the episode to remove
122              */
123             virtual void removePodcastEpisode( const MediaDevicePodcastEpisodePtr &episode ) = 0;
124 
125             /**
126              * This method must create a two-way association of the current Podcasts::Podcast
127              * to the special struct provided by the library to read/write information.
128              * For example, for libgpod one would associate Itdb_Podcast*.  It makes
129              * the most sense to use a QHash since it is fastest lookup and order
130              * does not matter.
131              * @param channel The channel to two-way associate with a library list struct
132              */
setAssociatePodcast(const MediaDevicePodcastChannelPtr & channel)133             virtual void setAssociatePodcast( const MediaDevicePodcastChannelPtr &channel ) { Q_UNUSED( channel ) }
134 
capabilityInterfaceType()135             static Type capabilityInterfaceType() { return Handler::Capability::Podcast; }
136     };
137 }
138 
139 #endif
140