sbPlayQueueLibraryListener.cpp
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 
31 
32 #include <prlog.h>
33 
38 #ifdef PR_LOGGING
39  static PRLogModuleInfo* gPlayQueueLibraryListenerLog = nsnull;
40 #define TRACE(args) PR_LOG(gPlayQueueLibraryListenerLog, PR_LOG_DEBUG, args)
41 #define LOG(args) PR_LOG(gPlayQueueLibraryListenerLog, PR_LOG_WARN, args)
42 # ifdef __GNUC__
43 #define __FUNCTION__ __PRETTY_FUNCTION__
44 #endif /* __GNUC__ */
45 #else
46 #define TRACE(args) /* nothing */
47 #define LOG(args) /* nothing */
48 #endif
49 
50 
53 
55  : mShouldIgnore(PR_FALSE)
56 {
57  #if PR_LOGGING
58  if (!gPlayQueueLibraryListenerLog) {
59  gPlayQueueLibraryListenerLog = PR_NewLogModule("sbPlayQueueLibraryListener");
60  }
61  #endif /* PR_LOGGING */
62  TRACE(("%s[%p]", __FUNCTION__, this));
63 }
64 
65 sbPlayQueueLibraryListener::~sbPlayQueueLibraryListener()
66 {
67  TRACE(("%s[%p]", __FUNCTION__, this));
68 }
69 
70 PRBool
72 {
73  TRACE(("%s[%p]", __FUNCTION__, this));
74  return mShouldIgnore;
75 }
76 
77 NS_IMETHODIMP
78 sbPlayQueueLibraryListener::OnBeforeListCleared(sbIMediaList* aMediaList,
79  PRBool aExcludeLists,
80  PRBool *aNoMoreForBatch)
81 {
82  TRACE(("%s[%p]", __FUNCTION__, this));
83 
84  // If the entire library is being cleared, the play queue service's mediaList
85  // will get a notification that it is being cleared. Ignore that notification
86  // to prevent recursing into calls to clear the libary.
87  mShouldIgnore = PR_TRUE;
88  return NS_OK;
89 }
90 
91 NS_IMETHODIMP
92 sbPlayQueueLibraryListener::OnListCleared(sbIMediaList* aMediaList,
93  PRBool aExcludeLists,
94  PRBool* aNoMoreForBatch)
95 {
96  TRACE(("%s[%p]", __FUNCTION__, this));
97  mShouldIgnore = PR_FALSE;
98  return NS_OK;
99 }
100 
101 // For the time being, we don't care about other listener methods on the
102 // library, so just ignore them and cancel batch notifications where possible.
103 
104 NS_IMETHODIMP
105 sbPlayQueueLibraryListener::OnBatchBegin(sbIMediaList* aMediaList)
106 {
107  return NS_OK;
108 }
109 
110 NS_IMETHODIMP
111 sbPlayQueueLibraryListener::OnBatchEnd(sbIMediaList* aMediaList)
112 {
113  return NS_OK;
114 }
115 
116 NS_IMETHODIMP
117 sbPlayQueueLibraryListener::OnItemAdded(sbIMediaList* aMediaList,
118  sbIMediaItem* aMediaItem,
119  PRUint32 aIndex,
120  PRBool* aNoMoreForBatch)
121 {
122  if (aNoMoreForBatch) {
123  *aNoMoreForBatch = PR_TRUE;
124  }
125  return NS_OK;
126 }
127 
128 NS_IMETHODIMP
129 sbPlayQueueLibraryListener::OnBeforeItemRemoved(sbIMediaList* aMediaList,
130  sbIMediaItem* aMediaItem,
131  PRUint32 aIndex,
132  PRBool* aNoMoreForBatch)
133 {
134  if (aNoMoreForBatch) {
135  *aNoMoreForBatch = PR_TRUE;
136  }
137  return NS_OK;
138 }
139 
140 NS_IMETHODIMP
141 sbPlayQueueLibraryListener::OnAfterItemRemoved(sbIMediaList* aMediaList,
142  sbIMediaItem* aMediaItem,
143  PRUint32 aIndex,
144  PRBool* aNoMoreForBatch)
145 {
146  if (aNoMoreForBatch) {
147  *aNoMoreForBatch = PR_TRUE;
148  }
149  return NS_OK;
150 }
151 
152 NS_IMETHODIMP
153 sbPlayQueueLibraryListener::OnItemUpdated(sbIMediaList* aMediaList,
154  sbIMediaItem* aMediaItem,
155  sbIPropertyArray* aProperties,
156  PRBool* aNoMoreForBatch)
157 {
158  if (aNoMoreForBatch) {
159  *aNoMoreForBatch = PR_TRUE;
160  }
161  return NS_OK;
162 }
163 
164 NS_IMETHODIMP
165 sbPlayQueueLibraryListener::OnItemMoved(sbIMediaList* aMediaList,
166  PRUint32 aFromIndex,
167  PRUint32 aToIndex,
168  PRBool* aNoMoreForBatch)
169 {
170  if (aNoMoreForBatch) {
171  *aNoMoreForBatch = PR_TRUE;
172  }
173  return NS_OK;
174 }
175 
return NS_OK
#define TRACE(args)
A brief description of the contents of this interface.
Interface used to listen to changes to a media list.
NS_IMPL_ISUPPORTS1(sbPlayQueueLibraryListener, sbIMediaListListener)
Interface that defines a single item of media in the system.
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIALISTLISTENER sbPlayQueueLibraryListener()
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
Helper class to listen to play queue library notifications.