sbLocalDatabaseMediaItem.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef __SBLOCALDATABASEMEDIAITEM_H__
28 #define __SBLOCALDATABASEMEDIAITEM_H__
29 
30 #include <sbILibraryResource.h>
31 #include <sbILocalDatabaseMediaItem.h>
32 #include <sbILocalDatabaseResourceProperty.h>
33 #include <sbIMediaItem.h>
34 #include <nsIClassInfo.h>
35 #include <nsIRequestObserver.h>
36 #include <sbWeakReference.h>
37 
38 #include <nsAutoPtr.h>
39 #include <nsCOMPtr.h>
40 #include <nsStringGlue.h>
41 #include <prlock.h>
42 
46 
48  public nsIClassInfo,
49  public nsIRequestObserver,
51  public sbIMediaItem
52 {
53 public:
55  NS_DECL_NSIREQUESTOBSERVER
56  NS_DECL_NSICLASSINFO
57  NS_DECL_SBILIBRARYRESOURCE
58  NS_DECL_SBILOCALDATABASEMEDIAITEM
59  NS_DECL_SBIMEDIAITEM
60 
62 
63  virtual ~sbLocalDatabaseMediaItem();
64 
65  nsresult Init(sbLocalDatabaseLibrary* aLibrary,
66  const nsAString& aGuid,
67  PRBool aOwnsLibrary = PR_TRUE);
68 
69 private:
70  nsresult EnsurePropertyBag();
71 
72 protected:
73  PRUint32 mMediaItemId;
74 
75  // Determines what kind of reference will be kept for mLibrary. If true,
76  // it will be an owning reference, if false, it will be a non-owning
77  // reference.
78  PRBool mOwnsLibrary;
79 
80  // This reference is either owning or non-owning depending on how this class
81  // was initalized. We do manual reference counting if this is to be an
82  // owning reference
84 
85  nsString mGuid;
86 
87  // When set, listeners will not be notified. This is used to signal when the
88  // item is not yet ready for notification (e.g. during the middle of creation)
89  // and when it's already been deleted.
91 
92  // A reference to the mediaItemController for this item
93  nsCOMPtr<sbIMediaItemController> mItemController;
94  // A boolean to remember if we already tried to fetch the controller
96 
97 private:
98  PRLock* mPropertyBagLock;
99  nsCOMPtr<sbILocalDatabaseResourcePropertyBag> mPropertyBag;
100 };
101 
103  public sbIIndexedMediaItem
104 {
105 public:
107  NS_DECL_NSICLASSINFO
108  NS_DECL_SBIINDEXEDMEDIAITEM
109 
110  sbLocalDatabaseIndexedMediaItem(PRUint32 aIndex, sbIMediaItem* aMediaItem) :
111  mIndex(aIndex),
112  mMediaItem(aMediaItem)
113  {
114  NS_ASSERTION(aMediaItem, "Null value passed to ctor");
115  }
116 
117 private:
118  PRUint32 mIndex;
119  nsCOMPtr<sbIMediaItem> mMediaItem;
120 };
121 
122 #endif /* __SBLOCALDATABASEMEDIAITEM_H__ */
sbLocalDatabaseLibrary * mLibrary
nsresult Init(sbLocalDatabaseLibrary *aLibrary, const nsAString &aGuid, PRBool aOwnsLibrary=PR_TRUE)
Initializes the media item.
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
nsCOMPtr< sbIMediaItemController > mItemController
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBIINDEXEDMEDIAITEM sbLocalDatabaseIndexedMediaItem(PRUint32 aIndex, sbIMediaItem *aMediaItem)
A container for a media item and its index.
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
Interface that defines a single item of media in the system.
NS_DECL_ISUPPORTS NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSICLASSINFO NS_DECL_SBILIBRARYRESOURCE NS_DECL_SBILOCALDATABASEMEDIAITEM NS_DECL_SBIMEDIAITEM sbLocalDatabaseMediaItem()