1 /******************************************************************************* 2 * Goggles Music Manager * 3 ******************************************************************************** 4 * Copyright (C) 2007-2021 by Sander Jansen. All Rights Reserved * 5 * --- * 6 * This program is free software: you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation, either version 3 of the License, or * 9 * (at your option) any later version. * 10 * * 11 * This program is distributed in the hope that it will be useful, * 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 * GNU General Public License for more details. * 15 * * 16 * You should have received a copy of the GNU General Public License * 17 * along with this program. If not, see http://www.gnu.org/licenses. * 18 ********************************************************************************/ 19 #ifndef GMPODCASTSOURCE_H 20 #define GMPODCASTSOURCE_H 21 22 23 /* Feed Item Flags */ 24 enum { 25 ITEM_FLAG_QUEUE = 0, 26 ITEM_FLAG_LOCAL = 1, 27 ITEM_FLAG_PLAYED = 2, 28 ITEM_FLAG_DOWNLOAD_FAILED = 3, 29 30 ITEM_QUEUE = (1<<ITEM_FLAG_QUEUE), 31 ITEM_LOCAL = (1<<ITEM_FLAG_LOCAL), 32 ITEM_PLAYED = (1<<ITEM_FLAG_PLAYED), 33 ITEM_FAILED = (1<<ITEM_FLAG_DOWNLOAD_FAILED), 34 }; 35 36 class GMSource; 37 class GMPodcastDownloader; 38 39 class GMPodcastSource : public GMSource { 40 friend class GMPodcastDownloader; 41 FXDECLARE(GMPodcastSource) 42 protected: 43 GMTrackDatabase * db = nullptr; 44 GMCoverCache * covercache = nullptr; 45 GMPodcastDownloader * downloader = nullptr; 46 FXint navailable = 0; 47 protected: GMPodcastSource()48 GMPodcastSource(){} 49 private: 50 GMPodcastSource(const GMPodcastSource&); 51 GMPodcastSource& operator=(const GMPodcastSource&); 52 protected: 53 void scheduleUpdate(); 54 void updateAvailable(); 55 void setItemFlags(FXuint add,FXuint remove,FXuint condition); 56 public: 57 enum { 58 ID_ADD_FEED = GMSource::ID_LAST, 59 ID_REFRESH_FEED, 60 ID_DOWNLOAD_FEED, 61 ID_REMOVE_FEED, 62 ID_MARK_PLAYED, 63 ID_MARK_NEW, 64 ID_FEED_UPDATER, 65 ID_LOAD_COVERS, 66 ID_DELETE_LOCAL, 67 ID_AUTO_DOWNLOAD, 68 ID_LAST 69 }; 70 public: 71 long onCmdAutoDownload(FXObject*,FXSelector,void*); 72 long onCmdAddFeed(FXObject*,FXSelector,void*); 73 long onCmdRefreshFeed(FXObject*,FXSelector,void*); 74 long onCmdDownloadFeed(FXObject*,FXSelector,void*); 75 long onCmdRemoveFeed(FXObject*,FXSelector,void*); 76 long onCmdMarkPlayed(FXObject*,FXSelector,void*); 77 long onCmdMarkNew(FXObject*,FXSelector,void*); 78 long onCmdFeedUpdated(FXObject*,FXSelector,void*); 79 long onCmdTrackPlayed(FXObject*,FXSelector,void*); 80 long onCmdLoadCovers(FXObject*,FXSelector,void*); 81 long onCmdDeleteLocal(FXObject*,FXSelector,void*); 82 long onCmdCopyTrack(FXObject*,FXSelector,void*); 83 long onCmdRequestTrack(FXObject*,FXSelector,void*); 84 protected: 85 void removeFeeds(const FXIntList&); 86 public: 87 GMPodcastSource(GMTrackDatabase * db); 88 89 void getLocalFiles(const FXIntList & ids,FXStringList&); 90 91 void refreshFeeds(); 92 93 void loadCovers() override; 94 95 void updateCovers() override; 96 97 void setLastUpdate(); 98 99 void setUpdateInterval(FXlong); 100 101 FXlong getUpdateInterval() const; 102 103 void configure(GMColumnList&) override; 104 105 FXbool hasCurrentTrack(GMSource * ) const override; 106 107 FXbool getTrack(GMTrack & info) const override; 108 109 FXbool setTrack(GMTrack & info) const override; 110 111 FXString getName() const override; 112 getAlbumName()113 const FXchar * getAlbumName() const override { return fxtr("Feeds"); } 114 115 FXIcon* getAlbumIcon() const override; 116 getCoverCache()117 GMCoverCache * getCoverCache() const override { return covercache; } 118 getType()119 FXint getType() const override { return SOURCE_PODCAST; } 120 settingKey()121 FXString settingKey() const override { return "podcast"; } 122 getSortColumn(FXbool)123 FXint getSortColumn(FXbool) const override { return HEADER_DATE; } 124 canBrowse()125 FXbool canBrowse() const override { return true; } 126 hasArtistList()127 FXbool hasArtistList() const override { return false; } 128 defaultBrowse()129 FXbool defaultBrowse() const override { return true; } 130 defaultTags()131 FXbool defaultTags() const override { return true; } 132 autoPlay()133 FXbool autoPlay() const override { return false; } 134 135 FXbool source_menu(FXMenuPane * pane) override; 136 137 FXbool source_context_menu(FXMenuPane * pane) override; 138 139 FXbool album_context_menu(FXMenuPane * pane) override; 140 141 FXbool track_context_menu(FXMenuPane * pane) override; 142 143 FXbool listTags(GMList *,FXIcon *) override; 144 listArtists(GMList *,FXIcon *,const FXIntList &)145 FXbool listArtists(GMList *,FXIcon *,const FXIntList &) override { return true; } 146 147 FXbool listAlbums(GMAlbumList *,const FXIntList &,const FXIntList &) override; 148 149 FXbool listTracks(GMTrackList * tracklist,const FXIntList & albumlist,const FXIntList & genrelist) override; 150 151 FXuint dnd_provides(FXDragType types[]) override; 152 153 virtual ~GMPodcastSource(); 154 }; 155 156 #endif 157