File indexing completed on 2025-01-19 04:24:36
0001 /**************************************************************************************** 0002 * Copyright (c) 2010 Bart Cerneels <bart.cerneels@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef UMSPODCASTMETA_H 0018 #define UMSPODCASTMETA_H 0019 0020 #include "core-impl/playlists/types/file/PlaylistFile.h" 0021 #include "core/podcasts/PodcastMeta.h" 0022 0023 #include "core-impl/meta/file/File.h" 0024 0025 class QUrl; 0026 0027 namespace Podcasts { 0028 0029 class UmsPodcastEpisode; 0030 class UmsPodcastChannel; 0031 class UmsPodcastProvider; 0032 0033 0034 typedef AmarokSharedPointer<UmsPodcastEpisode> UmsPodcastEpisodePtr; 0035 typedef AmarokSharedPointer<UmsPodcastChannel> UmsPodcastChannelPtr; 0036 0037 typedef QList<UmsPodcastEpisodePtr> UmsPodcastEpisodeList; 0038 typedef QList<UmsPodcastChannelPtr> UmsPodcastChannelList; 0039 0040 class UmsPodcastEpisode : public Podcasts::PodcastEpisode 0041 { 0042 friend class UmsPodcastProvider; 0043 0044 public: 0045 static UmsPodcastEpisodePtr fromPodcastEpisodePtr( const Podcasts::PodcastEpisodePtr &episode ); 0046 static UmsPodcastEpisodePtr fromTrackPtr( const Meta::TrackPtr &track ); 0047 static Podcasts::PodcastEpisodePtr toPodcastEpisodePtr( const UmsPodcastEpisodePtr &episode ); 0048 static Podcasts::PodcastEpisodeList toPodcastEpisodeList( UmsPodcastEpisodeList episodes ); 0049 0050 explicit UmsPodcastEpisode( const UmsPodcastChannelPtr &channel ); 0051 ~UmsPodcastEpisode() override; 0052 0053 void setLocalFile( const MetaFile::TrackPtr &localFile ); 0054 0055 //PodcastEpisode methods 0056 QString title() const override; 0057 void setLocalUrl( const QUrl &localUrl ) override; 0058 0059 //Track Methods 0060 QString name() const override { return title(); } 0061 QUrl playableUrl() const override; 0062 QString notPlayableReason() const override; 0063 QString prettyName() const override { return name(); } 0064 void setTitle( const QString &title ) override; 0065 QDateTime createDate() const override; 0066 0067 Meta::AlbumPtr album() const override; 0068 Meta::ArtistPtr artist() const override; 0069 Meta::ComposerPtr composer() const override; 0070 Meta::GenrePtr genre() const override; 0071 Meta::YearPtr year() const override; 0072 0073 private: 0074 MetaFile::TrackPtr m_localFile; 0075 UmsPodcastChannelPtr m_umsChannel; 0076 }; 0077 0078 class UmsPodcastChannel : public Podcasts::PodcastChannel 0079 { 0080 friend class UmsPodcastProvider; 0081 public: 0082 static UmsPodcastChannelPtr fromPodcastChannelPtr( 0083 const Podcasts::PodcastChannelPtr &channel ); 0084 static Podcasts::PodcastChannelPtr toPodcastChannelPtr( const UmsPodcastChannelPtr &channel ); 0085 static Podcasts::PodcastChannelList toPodcastChannelList( 0086 UmsPodcastChannelList umsChannels ); 0087 0088 explicit UmsPodcastChannel( UmsPodcastProvider *provider ); 0089 UmsPodcastChannel( Podcasts::PodcastChannelPtr channel, UmsPodcastProvider *provider ); 0090 ~UmsPodcastChannel() override; 0091 0092 Podcasts::PodcastEpisodePtr addEpisode( const Podcasts::PodcastEpisodePtr &episode ) override; 0093 0094 UmsPodcastEpisodeList umsEpisodes() { return m_umsEpisodes; } 0095 void addUmsEpisode( UmsPodcastEpisodePtr episode ); 0096 0097 void setPlaylistFileSource( const QUrl &playlistFilePath ); 0098 QUrl playlistFilePath() const { return m_playlistFilePath; } 0099 0100 Podcasts::PodcastEpisodeList episodes() const override 0101 { return UmsPodcastEpisode::toPodcastEpisodeList( m_umsEpisodes ); } 0102 Playlists::PlaylistProvider *provider() const override; 0103 0104 protected: 0105 void removeEpisode( const UmsPodcastEpisodePtr &episode ); 0106 0107 private: 0108 UmsPodcastProvider *m_provider; 0109 QUrl m_playlistFilePath; 0110 Playlists::PlaylistFilePtr m_playlistFile; //used to keep track of episodes. 0111 0112 UmsPodcastEpisodeList m_umsEpisodes; 0113 }; 0114 0115 } //namespace Podcasts 0116 0117 Q_DECLARE_METATYPE( Podcasts::UmsPodcastEpisodePtr ) 0118 Q_DECLARE_METATYPE( Podcasts::UmsPodcastEpisodeList ) 0119 Q_DECLARE_METATYPE( Podcasts::UmsPodcastChannelPtr ) 0120 Q_DECLARE_METATYPE( Podcasts::UmsPodcastChannelList ) 0121 0122 #endif // UMSPODCASTMETA_H