sbRemoteLibraryBase.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 __SB_REMOTE_LIBRARYBASE_H__
28 #define __SB_REMOTE_LIBRARYBASE_H__
29 
30 #include "sbRemoteAPI.h"
31 #include "sbRemoteMediaItem.h"
32 #include "sbRemoteMediaList.h"
33 #include "sbRemoteSiteMediaList.h"
34 #include "sbRemoteSiteMediaItem.h"
35 #include "sbXPCScriptableStub.h"
36 
37 #include <nsIFile.h>
38 #include <nsISecurityCheckedComponent.h>
39 #include <nsIXPCScriptable.h>
40 #include <sbILibrary.h>
41 #include <sbILibraryResource.h>
42 #include <sbIMediaList.h>
43 #include <sbIMediaListListener.h>
44 #include <sbIMediaListView.h>
45 #include <sbIRemoteLibrary.h>
46 #include <sbIRemoteMediaList.h>
47 #include <sbIScriptableFilterResult.h>
48 #include <sbISecurityMixin.h>
49 #include <sbISecurityAggregator.h>
50 #include <sbIWrappedMediaList.h>
51 
52 #include <nsAutoPtr.h>
53 #include <nsCOMArray.h>
54 #include <nsCOMPtr.h>
55 #include <nsCOMArray.h>
56 #include <nsCOMPtr.h>
57 #include <nsStringGlue.h>
58 
59 #ifdef PR_LOGGING
60 extern PRLogModuleInfo *gRemoteLibraryLog;
61 #endif
62 
63 #define LOG_LIB(args) PR_LOG(gRemoteLibraryLog, PR_LOG_WARN, args)
64 #define TRACE_LIB(args) PR_LOG(gRemoteLibraryLog, PR_LOG_DEBUG, args)
65 
67 class sbIMediaItem;
68 class sbRemotePlayer;
69 
70 // PURE VIRTUAL: Inherits but doesn't impl nsIClassInfo
71 // derived classes must impl.
75  public sbISecurityAggregator,
76  public sbIRemoteLibrary,
77  public sbIRemoteMediaList,
78  public sbIWrappedMediaList,
79  public sbIMediaList,
81  public sbXPCScriptableStub
82 {
83 public:
85  NS_DECL_SBISCRIPTABLEFILTERRESULT
86  NS_DECL_SBISECURITYAGGREGATOR
87  NS_DECL_SBIREMOTELIBRARY
88  NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
89 
90  NS_FORWARD_SAFE_SBIREMOTEMEDIALIST(mRemMediaList)
91  NS_FORWARD_SAFE_SBIMEDIALIST(mRemMediaList)
92  NS_FORWARD_SAFE_SBIMEDIAITEM(mRemMediaList)
94  NS_FORWARD_SAFE_NSISECURITYCHECKEDCOMPONENT(mSecurityMixin)
95 
97 
98  sbRemoteLibraryBase(sbRemotePlayer* aRemotePlayer);
99 
100  // sbILibraryResource
101  NS_IMETHOD SetProperty( const nsAString& aID, const nsAString& aValue );
102 
103  // nsIXPCScriptable
104  NS_IMETHOD GetClassName(char **aClassName);
105  NS_IMETHOD GetScriptableFlags(PRUint32 *aScriptableFlags);
106  NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper,
107  JSContext *cx,
108  JSObject *obj,
109  jsval id,
110  PRUint32 flags,
111  JSObject **objp,
112  PRBool *_retval);
113  NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper,
114  JSContext *cx,
115  JSObject *obj,
116  jsval id,
117  jsval *vp,
118  PRBool *_retval);
119 
120  // sbIWrappedMediaList
121  virtual already_AddRefed<sbIMediaItem> GetMediaItem();
122  virtual already_AddRefed<sbIMediaList> GetMediaList();
123 
124  // Gets the GUID for the built in libraries: main, web, download
125  static nsresult GetLibraryGUID( const nsAString &aLibraryID,
126  nsAString &aLibraryGUID );
127 protected:
128  virtual ~sbRemoteLibraryBase();
129 
130  // PURE VIRTUAL: Needs to be implemented by derived class
131  // on connection to a library, set the internal remote medialist
132  virtual nsresult InitInternalMediaList() = 0;
133 
134  already_AddRefed<sbIRemoteMediaList>
135  GetMediaListBySiteID(const nsAString& aSiteID);
136 
137  already_AddRefed<sbIMediaItem>
138  FindMediaItemWithMatchingScope(const nsCOMArray<sbIMediaItem>& aMediaItems);
139 
140  PRBool mShouldScan;
141  nsCOMPtr<sbILibrary> mLibrary;
143 
144  // For holding the results of sbIMediaList enumeration methods..
147 
148  // SecurityCheckedComponent stuff
150 
152 
155 };
156 
157 #endif // __SB_REMOTE_LIBRARYBASE_H__
virtual already_AddRefed< sbIMediaItem > GetMediaItem()
already_AddRefed< sbIRemoteMediaList > GetMediaListBySiteID(const nsAString &aSiteID)
Interface used to enumerate the items in a media list.
onPageChanged aValue
Definition: FeedWriter.js:1395
sbDeviceFirmwareAutoCheckForUpdate prototype flags
A brief description of the contents of this interface.
nsISecurityCheckedComponent
NS_IMETHOD GetProperty(const nsAString &aName, nsAString &_retval)
static nsresult GetLibraryGUID(const nsAString &aLibraryID, nsAString &aLibraryGUID)
NS_IMETHOD SetProperty(const nsAString &aID, const nsAString &aValue)
NS_IMETHOD GetScriptableFlags(PRUint32 *aScriptableFlags)
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, jsval id, PRUint32 flags, JSObject **objp, PRBool *_retval)
already_AddRefed< sbIMediaItem > FindMediaItemWithMatchingScope(const nsCOMArray< sbIMediaItem > &aMediaItems)
A marker interface for objects that aggregate the security mixin.
nsRefPtr< sbRemoteMediaListBase > mRemMediaList
nsCOMPtr< nsISecurityCheckedComponent > mSecurityMixin
An interface to control a media library from remote web pages.
The result of a filtering expression in a library.
Media library abstraction.
Definition: sbILibrary.idl:82
nsCOMPtr< sbILibrary > mLibrary
NS_IMETHOD GetClassName(char **aClassName)
virtual already_AddRefed< sbIMediaList > GetMediaList()
Interface that defines a single item of media in the system.
nsCOMArray< sbIMediaItem > mEnumerationArray
nsRefPtr< sbRemotePlayer > mRemotePlayer
#define NS_FORWARD_SAFE_SBILIBRARYRESOURCE_NO_SETPROPERTY(_to)
virtual nsresult InitInternalMediaList()=0
An interface to control a media list from remote web pages.