sbLibraryListenerHelpers.h
Go to the documentation of this file.
1 /* vim: set sw=2 :miv */
2 /*
3 //
4 // BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2009 POTI, Inc.
9 // http://songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the "GPL").
13 //
14 // Software distributed under the License is distributed
15 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 // END SONGBIRD GPL
25 //
26 */
27 
28 #ifndef __SBLIBRARYLISTENERHELPERS__H__
29 #define __SBLIBRARYLISTENERHELPERS__H__
30 
31 #include "sbIDeviceLibrary.h"
32 #include "sbILocalDatabaseSimpleMediaList.h"
33 #include "sbIMediaListListener.h"
34 #include <sbStandardProperties.h>
35 
36 #include <nsAutoLock.h>
37 #include <nsCOMPtr.h>
38 #include <nsDataHashtable.h>
39 
40 #include <sbWeakReference.h>
41 
42 class sbIDevice;
43 class sbBaseDevice;
44 
49 {
50 public:
54  nsresult SetIgnoreListener(PRBool aIgnoreListener);
59  nsresult IgnoreMediaItem(sbIMediaItem * aItem);
63  nsresult UnignoreMediaItem(sbIMediaItem * aItem);
64 protected:
68  PRBool MediaItemIgnored(sbIMediaItem * aItem);
72  sbBaseIgnore() : mLock(nsAutoLock::NewLock("sbBaseIgnore::mLock")),
73  mIgnoreListenerCounter(0) {
74  mIgnored.Init();
75  NS_ASSERTION(mLock, "Failed to allocate sbBaseIgnore::mLock");
76  }
81  nsAutoLock::DestroyLock(mLock);
82  mLock = nsnull;
83  }
84 private:
85  nsDataHashtable<nsStringHashKey,PRInt32> mIgnored;
86  PRLock * mLock;
87  PRInt32 mIgnoreListenerCounter;
88 };
89 
92  public sbBaseIgnore
93 {
94 public:
96  NS_DECL_SBIDEVICELIBRARYLISTENER
97 
100 
101  nsresult Init(sbBaseDevice* aDevice);
102 
103  void Destroy();
104 
105 protected:
106  // The device owns the listener, so use a non-owning reference here
108 };
109 
111  public sbBaseIgnore
112 {
113 public:
115  NS_DECL_SBILOCALDATABASEMEDIALISTCOPYLISTENER
116 
119 
120  nsresult Init(sbBaseDevice* aDevice);
121 
122 protected:
123  // The device owns the listener, so use a non-owning reference here
125 };
126 
128  public sbBaseIgnore
129 {
130 public:
132  NS_DECL_SBIMEDIALISTLISTENER
133 
135 
136  nsresult Init(sbBaseDevice* aDevice);
137 
138 protected:
140 
141  // The device owns the listener, so use a non-owning reference here
143 };
144 
145 #endif
nsresult Init(sbBaseDevice *aDevice)
nsresult Init(sbBaseDevice *aDevice)
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
Interface used to listen to changes to a device library.
nsresult SetIgnoreListener(PRBool aIgnoreListener)
Interface used to listen to changes to a media list.
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICELIBRARYLISTENER sbBaseDeviceLibraryListener()
NS_DECL_ISUPPORTS NS_DECL_SBILOCALDATABASEMEDIALISTCOPYLISTENER sbDeviceBaseLibraryCopyListener()
nsresult UnignoreMediaItem(sbIMediaItem *aItem)
PRBool MediaItemIgnored(sbIMediaItem *aItem)
nsresult Init(sbBaseDevice *aDevice)
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIALISTLISTENER sbBaseDeviceMediaListListener()
Interface that defines a single item of media in the system.
nsresult IgnoreMediaItem(sbIMediaItem *aItem)