xref: /haiku/src/apps/mediaplayer/playlist/FilePlaylistItem.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
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 	// playback
56 	virtual	TrackSupplier*		CreateTrackSupplier() const;
57 
58 			status_t			AddRef(const entry_ref& ref);
59 			const entry_ref&	Ref() const { return fRefs[0]; }
60 
61 			status_t			AddImageRef(const entry_ref& ref);
62 			const entry_ref&	ImageRef() const;
63 
64 private:
65 			status_t			_SetAttribute(const char* attrName,
66 									type_code type, const void* data,
67 									size_t size);
68 			status_t			_GetAttribute(const char* attrName,
69 									type_code type, void* data,
70 									size_t size);
71 			status_t			_MoveIntoTrash(vector<entry_ref>* refs,
72 									vector<BString>* namesInTrash);
73 			status_t			_RestoreFromTrash(vector<entry_ref>* refs,
74 									vector<BString>* namesInTrash);
75 
76 private:
77 	// always fRefs.size() == fNamesInTrash.size()
78 			vector<entry_ref>	fRefs;
79 			vector<BString>		fNamesInTrash;
80 	// always fImageRefs.size() == fImageNamesInTrash.size()
81 			vector<entry_ref>	fImageRefs;
82 			vector<BString>		fImageNamesInTrash;
83 };
84 
85 #endif // FILE_PLAYLIST_ITEM_H
86