sbLocalDatabaseDynamicMediaList.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2009 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27 */
28 
29 #ifndef __SB_LOCAL_DATABASE_DYNAMIC_MEDIALIST_H__
30 #define __SB_LOCAL_DATABASE_DYNAMIC_MEDIALIST_H__
31 
32 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 //
35 // Songbird dynamic media list defs.
36 //
37 //------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------
39 
45 //------------------------------------------------------------------------------
46 //
47 // Songbird dynamic media list imported services.
48 //
49 //------------------------------------------------------------------------------
50 
51 // Songbird imports.
52 #include <sbILocalDatabaseMediaItem.h>
53 #include <sbIMediaList.h>
54 #include <sbIDynamicMediaList.h>
55 #include <sbWeakReference.h>
56 
57 // Mozilla imports.
58 #include <nsIClassInfo.h>
59 #include <nsStringGlue.h>
60 
61 //------------------------------------------------------------------------------
62 //
63 // Songbird dynamic media list macros.
64 //
65 //------------------------------------------------------------------------------
66 
67 /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
68 #define NS_FORWARD_SAFE_SBIMEDIALIST_ALL_BUT_TYPE(_to) \
69  NS_IMETHOD GetName(nsAString & aName) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetName(aName); } \
70  NS_IMETHOD SetName(const nsAString & aName) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetName(aName); } \
71  NS_IMETHOD GetLength(PRUint32 *aLength) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetLength(aLength); } \
72  NS_IMETHOD GetItemByGuid(const nsAString & aGuid, sbIMediaItem **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetItemByGuid(aGuid, _retval); } \
73  NS_IMETHOD GetItemByIndex(PRUint32 aIndex, sbIMediaItem **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetItemByIndex(aIndex, _retval); } \
74  NS_IMETHOD GetListContentType(PRUint16* _retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetListContentType(_retval); } \
75  NS_IMETHOD EnumerateAllItems(sbIMediaListEnumerationListener *aEnumerationListener, PRUint16 aEnumerationType) { return !_to ? NS_ERROR_NULL_POINTER : _to->EnumerateAllItems(aEnumerationListener, aEnumerationType); } \
76  NS_IMETHOD EnumerateItemsByProperty(const nsAString & aPropertyID, const nsAString & aPropertyValue, sbIMediaListEnumerationListener *aEnumerationListener, PRUint16 aEnumerationType) { return !_to ? NS_ERROR_NULL_POINTER : _to->EnumerateItemsByProperty(aPropertyID, aPropertyValue, aEnumerationListener, aEnumerationType); } \
77  NS_IMETHOD EnumerateItemsByProperties(sbIPropertyArray *aProperties, sbIMediaListEnumerationListener *aEnumerationListener, PRUint16 aEnumerationType) { return !_to ? NS_ERROR_NULL_POINTER : _to->EnumerateItemsByProperties(aProperties, aEnumerationListener, aEnumerationType); } \
78  NS_IMETHOD GetItemsByProperty(const nsAString & aPropertyID, const nsAString & aPropertyValue, nsIArray **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetItemsByProperty(aPropertyID, aPropertyValue, _retval); } \
79  NS_IMETHOD GetItemCountByProperty(const nsAString & aPropertyID, const nsAString & aPropertyValue, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetItemCountByProperty(aPropertyID, aPropertyValue, _retval); } \
80  NS_IMETHOD GetItemsByProperties(sbIPropertyArray *aProperties, nsIArray **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetItemsByProperties(aProperties, _retval); } \
81  NS_IMETHOD IndexOf(sbIMediaItem *aMediaItem, PRUint32 aStartFrom, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IndexOf(aMediaItem, aStartFrom, _retval); } \
82  NS_IMETHOD LastIndexOf(sbIMediaItem *aMediaItem, PRUint32 aStartFrom, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->LastIndexOf(aMediaItem, aStartFrom, _retval); } \
83  NS_IMETHOD Contains(sbIMediaItem *aMediaItem, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Contains(aMediaItem, _retval); } \
84  NS_IMETHOD GetIsEmpty(PRBool *aIsEmpty) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsEmpty(aIsEmpty); } \
85  NS_IMETHOD GetUserEditableContent(PRBool *aUserEditableContent) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUserEditableContent(aUserEditableContent); } \
86  NS_IMETHOD Add(sbIMediaItem *aMediaItem) { return !_to ? NS_ERROR_NULL_POINTER : _to->Add(aMediaItem); } \
87  NS_IMETHOD AddItem(sbIMediaItem *aMediaItem, sbIMediaItem ** aNewMediaItem) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddItem(aMediaItem, aNewMediaItem); } \
88  NS_IMETHOD AddAll(sbIMediaList *aMediaList) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddAll(aMediaList); } \
89  NS_IMETHOD AddSome(nsISimpleEnumerator *aMediaItems) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddSome(aMediaItems); } \
90  NS_IMETHOD AddMediaItems(nsISimpleEnumerator *aMediaItems, sbIAddMediaItemsListener *aListener, PRBool aAsync) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddMediaItems(aMediaItems, aListener, aAsync); } \
91  NS_IMETHOD Remove(sbIMediaItem *aMediaItem) { return !_to ? NS_ERROR_NULL_POINTER : _to->Remove(aMediaItem); } \
92  NS_IMETHOD RemoveByIndex(PRUint32 aIndex) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveByIndex(aIndex); } \
93  NS_IMETHOD RemoveSome(nsISimpleEnumerator *aMediaItems) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveSome(aMediaItems); } \
94  NS_IMETHOD Clear(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Clear(); } \
95  NS_IMETHOD AddListener(sbIMediaListListener *aListener, PRBool aOwnsWeak, PRUint32 aFlags, sbIPropertyArray *aPropertyFilter) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddListener(aListener, aOwnsWeak, aFlags, aPropertyFilter); } \
96  NS_IMETHOD RemoveListener(sbIMediaListListener *aListener) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveListener(aListener); } \
97  NS_IMETHOD CreateView(sbIMediaListViewState* aState, sbIMediaListView **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->CreateView(aState, _retval); } \
98  NS_IMETHOD GetDistinctValuesForProperty(const nsAString& aPropertyID, nsIStringEnumerator** _retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDistinctValuesForProperty(aPropertyID, _retval); } \
99  NS_IMETHOD RunInBatchMode(sbIMediaListBatchCallback *aCallback, nsISupports *aUserData) { return !_to ? NS_ERROR_NULL_POINTER : _to->RunInBatchMode(aCallback, aUserData); }
100 
101 /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
102 #define SB_FORWARD_SAFE_SBILOCALDATABASEMEDIAITEM(_to) \
103  NS_SCRIPTABLE NS_IMETHOD GetMediaItemId(PRUint32 *aMediaItemId) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetMediaItemId(aMediaItemId); } \
104  NS_SCRIPTABLE NS_IMETHOD GetPropertyBag(sbILocalDatabaseResourcePropertyBag * *aPropertyBag) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPropertyBag(aPropertyBag); } \
105  NS_SCRIPTABLE NS_IMETHOD SetPropertyBag(sbILocalDatabaseResourcePropertyBag * aPropertyBag) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetPropertyBag(aPropertyBag); } \
106  NS_IMETHOD_(void) SetSuppressNotifications(PRBool aSuppress) { if (_to) _to->SetSuppressNotifications(aSuppress); }
107 
108 
109 //------------------------------------------------------------------------------
110 //
111 // Songbird dynamic media list classes.
112 //
113 //------------------------------------------------------------------------------
114 
121  public sbIMediaList,
122  public sbIDynamicMediaList,
124 {
125  //----------------------------------------------------------------------------
126  //
127  // Public interface.
128  //
129  //----------------------------------------------------------------------------
130 
131 public:
132 
133  //
134  // Interface implementations.
135  //
136 
138  NS_DECL_NSICLASSINFO
139  NS_DECL_SBIDYNAMICMEDIALIST
140  NS_FORWARD_SAFE_SBILIBRARYRESOURCE(mBaseMediaList)
141  NS_FORWARD_SAFE_SBIMEDIAITEM(mBaseMediaList)
144 
145 
146  //
147  // sbIMediaList interface implementation.
148  //
149 
150  NS_IMETHOD GetType(nsAString& aType);
151 
152 
153  //
154  // Public services.
155  //
156 
164  static nsresult New(sbIMediaItem* aInner,
165  sbIMediaList** aMediaList);
166 
168 
169 
170  //----------------------------------------------------------------------------
171  //
172  // Private interface.
173  //
174  //----------------------------------------------------------------------------
175 
176  //
177  // Internal fields.
178  //
179  // mBaseMediaList Base media list.
180  // mBaseLocalDatabaseMediaList
181  // Base media list as an sbILocalDatabaseMediaItem.
182  //
183 
186 
187 
188  //
189  // Private services.
190  //
191 
192  sbLocalDatabaseDynamicMediaList();
193 
194  nsresult Initialize(sbIMediaItem* aInner);
195 };
196 
197 #endif // __SB_LOCAL_DATABASE_DYNAMIC_MEDIALIST_H__
198 
static nsresult New(sbIMediaItem *aInner, sbIMediaList **aMediaList)
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
A brief description of the contents of this interface.
nsCOMPtr< sbILocalDatabaseMediaItem > mBaseLocalDatabaseMediaList
NS_IMETHOD GetType(nsAString &aType)
The type of media list (eg "simple")
#define SB_FORWARD_SAFE_SBILOCALDATABASEMEDIAITEM(_to)
Interface that defines a single item of media in the system.
#define NS_FORWARD_SAFE_SBIMEDIALIST_ALL_BUT_TYPE(_to)