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 virtual status_t SetAttribute(const Attribute& attribute, 48 const float& value); 49 virtual status_t GetAttribute(const Attribute& attribute, 50 float& value) const; 51 52 // methods 53 virtual BString LocationURI() const; 54 virtual status_t GetIcon(BBitmap* bitmap, 55 icon_size iconSize) const; 56 57 virtual status_t MoveIntoTrash(); 58 virtual status_t RestoreFromTrash(); 59 60 status_t AddRef(const entry_ref& ref); 61 const entry_ref& Ref() const { return fRefs[0]; } 62 63 status_t AddImageRef(const entry_ref& ref); 64 const entry_ref& ImageRef() const; 65 66 protected: 67 virtual bigtime_t _CalculateDuration(); 68 // playback 69 virtual TrackSupplier* _CreateTrackSupplier() const; 70 71 private: 72 status_t _SetAttribute(const char* attrName, 73 type_code type, const void* data, 74 size_t size); 75 status_t _GetAttribute(const char* attrName, 76 type_code type, void* data, 77 size_t size) const; 78 status_t _MoveIntoTrash(vector<entry_ref>* refs, 79 vector<BString>* namesInTrash); 80 status_t _RestoreFromTrash(vector<entry_ref>* refs, 81 vector<BString>* namesInTrash); 82 83 private: 84 // always fRefs.size() == fNamesInTrash.size() 85 vector<entry_ref> fRefs; 86 vector<BString> fNamesInTrash; 87 // always fImageRefs.size() == fImageNamesInTrash.size() 88 vector<entry_ref> fImageRefs; 89 vector<BString> fImageNamesInTrash; 90 }; 91 92 #endif // FILE_PLAYLIST_ITEM_H 93