sbPlayQueueExternalLibraryListener.h
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 #ifndef __SBPLAYQUEUEEXTERNALLIBRARYLISTENER_H__
26 #define __SBPLAYQUEUEEXTERNALLIBRARYLISTENER_H__
27 
33 #include <nsAutoLock.h>
34 #include <nsCOMPtr.h>
35 #include <nsCOMArray.h>
36 #include <nsVoidArray.h>
37 
38 #include <prlock.h>
39 
40 #include <sbILibrary.h>
41 #include <sbIMediaListListener.h>
42 #include <sbIPropertyArray.h>
43 
44 #include <list>
45 
52 public:
54  : mItem(aItem),
55  mUpdate(aUpdate)
56  {}
57 
58  bool operator==(sbPropertyUpdate rhs);
59 
60  nsCOMPtr<sbIMediaItem> mItem;
61  nsCOMPtr<sbIPropertyArray> mUpdate;
62 };
63 
70 {
71 public:
73  NS_DECL_SBIMEDIALISTLISTENER
74 
76 
82  nsresult SetMasterLibrary(sbILibrary* aLibrary);
83 
87  nsresult AddExternalLibrary(sbILibrary* aLibrary);
88 
93  nsresult SetPropertiesNoSync(sbIMediaItem* aMediaItem,
94  sbIPropertyArray* aProperties);
95 
99  nsresult RemoveListeners();
100 
101 private:
102  virtual ~sbPlayQueueExternalLibraryListener();
103 
108  typedef std::list<sbPropertyUpdate> Updates;
109  typedef std::list<sbPropertyUpdate>::iterator UpdateIter;
110  Updates mUpdates;
111 
116  nsresult GenerateUpdates(sbIMediaItem* aMediaItem,
117  sbIPropertyArray* aProperties,
118  Updates& updates);
119 
123  PRLock* mUpdateLock;
124 
128  nsCOMPtr<sbILibrary> mMasterLibrary;
129 
133  nsCOMArray<sbILibrary> mExternalLibraries;
134 };
135 
136 #endif /* __SBPLAYQUEUEEXTERNALLIBRARYLISTENER_H__ */
nsresult AddExternalLibrary(sbILibrary *aLibrary)
Add an external library to listen to.
sbPropertyUpdate(sbIMediaItem *aItem, sbIPropertyArray *aUpdate)
Class to allow items in a "master" internal library to stay in sync with duplicates in other librarie...
Interface used to listen to changes to a media list.
nsresult SetPropertiesNoSync(sbIMediaItem *aMediaItem, sbIPropertyArray *aProperties)
Set properties on an item, but don't synchronize to duplicates in other libraries.
bool operator==(sbPropertyUpdate rhs)
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIALISTLISTENER sbPlayQueueExternalLibraryListener()
Media library abstraction.
Definition: sbILibrary.idl:82
nsresult RemoveListeners()
Removes all listeners so the libraries can shut down.
nsresult SetMasterLibrary(sbILibrary *aLibrary)
Set the master library. Items that are in this library with duplicates in external libraries...
Interface that defines a single item of media in the system.
Class to hold onto property updates to make sure we're not applying them more than once...
nsCOMPtr< sbIPropertyArray > mUpdate
nsCOMPtr< sbIMediaItem > mItem
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...