1 /* 2 * Copyright 2009-2010 Stephan Aßmus <superstippi@gmx.de> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef FILE_PLAYLIST_ITEM_H 6 #define FILE_PLAYLIST_ITEM_H 7 8 #include "PlaylistItem.h" 9 10 #include <vector> 11 12 #include <Entry.h> 13 14 using std::vector; 15 16 17 class FilePlaylistItem : public PlaylistItem { 18 public: 19 FilePlaylistItem(const entry_ref& ref); 20 FilePlaylistItem(const FilePlaylistItem& item); 21 FilePlaylistItem(const BMessage* archive); 22 virtual ~FilePlaylistItem(); 23 24 virtual PlaylistItem* Clone() const; 25 26 // archiving 27 static BArchivable* Instantiate(BMessage* archive); 28 virtual status_t Archive(BMessage* into, 29 bool deep = true) const; 30 31 // attributes 32 virtual status_t SetAttribute(const Attribute& attribute, 33 const BString& string); 34 virtual status_t GetAttribute(const Attribute& attribute, 35 BString& string) const; 36 37 virtual status_t SetAttribute(const Attribute& attribute, 38 const int32& value); 39 virtual status_t GetAttribute(const Attribute& attribute, 40 int32& value) const; 41 42 virtual status_t SetAttribute(const Attribute& attribute, 43 const int64& value); 44 virtual status_t GetAttribute(const Attribute& attribute, 45 int64& value) const; 46 47 // methods 48 virtual BString LocationURI() const; 49 virtual status_t GetIcon(BBitmap* bitmap, 50 icon_size iconSize) const; 51 52 virtual status_t MoveIntoTrash(); 53 virtual status_t RestoreFromTrash(); 54 55 status_t AddRef(const entry_ref& ref); 56 const entry_ref& Ref() const { return fRefs[0]; } 57 58 status_t AddImageRef(const entry_ref& ref); 59 const entry_ref& ImageRef() const; 60 61 protected: 62 virtual bigtime_t _CalculateDuration(); 63 // playback 64 virtual TrackSupplier* _CreateTrackSupplier() const; 65 66 private: 67 status_t _SetAttribute(const char* attrName, 68 type_code type, const void* data, 69 size_t size); 70 status_t _GetAttribute(const char* attrName, 71 type_code type, void* data, 72 size_t size) const; 73 status_t _MoveIntoTrash(vector<entry_ref>* refs, 74 vector<BString>* namesInTrash); 75 status_t _RestoreFromTrash(vector<entry_ref>* refs, 76 vector<BString>* namesInTrash); 77 78 private: 79 // always fRefs.size() == fNamesInTrash.size() 80 vector<entry_ref> fRefs; 81 vector<BString> fNamesInTrash; 82 // always fImageRefs.size() == fImageNamesInTrash.size() 83 vector<entry_ref> fImageRefs; 84 vector<BString> fImageNamesInTrash; 85 }; 86 87 #endif // FILE_PLAYLIST_ITEM_H 88