sbRemoteLibrary.cpp
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 #include "sbRemoteLibrary.h"
28 
29 #include <sbClassInfoUtils.h>
30 #include <sbIMediaList.h>
31 
32 #include <prlog.h>
33 
34 /*
35  * To log this module, set the following environment variable:
36  * NSPR_LOG_MODULES=sbRemoteLibrary:5
37  * LOG_LIB defined sbRemoteLibraryBase.h/.cpp
38  */
39 #undef LOG
40 #define LOG(args) LOG_LIB(args)
41 
42 const static char* sPublicWProperties[] =
43  {
44  "library_write:scanMediaOnCreation"
45  };
46 
47 const static char* sPublicRProperties[] =
48  { // sbIMediaList
49  "library_read:name",
50  "library_read:type",
51  "library_read:length",
52 
53  // sbIRemoteLibrary
54  "library_read:scanMediaOnCreation",
55  "library_read:playlists",
56 
57  // sbIScriptableFilterResult
58  "library_read:artists",
59  "library_read:albums",
60  "library_read:genres",
61  "library_read:years",
62  "library_read:mostPlayedArtists",
63 
64  // nsIClassInfo
65  "classinfo:classDescription",
66  "classinfo:contractID",
67  "classinfo:classID",
68  "classinfo:implementationLanguage",
69  "classinfo:flags"
70  };
71 
72 const static char* sPublicMethods[] =
73  { // sbIRemoteLibrary
74  "library_write:createMediaListFromURL",
75  "library_read:getMediaList",
76  "library_read:getPlaylists",
77  "library_read:getMediaListBySiteID",
78 
79  // sbIScriptableFilterResult
80  "library_read:getArtists",
81  "library_read:getAlbums",
82  "library_read:getGenres",
83  "library_read:getYears",
84 
85  // different from the ones in sbILibrary
86  "library_write:createSimpleMediaList",
87  "library_write:createMediaItem",
88 
89  // sbIMediaList
90  "library_read:getItemByGuid",
91  "library_read:getItemByIndex",
92  "library_read:enumerateAllItems",
93  "library_read:enumerateItemsByProperty",
94  "library_read:indexOf",
95  "library_read:lastIndexOf",
96  "library_read:contains",
97  "library_write:add",
98  "library_write:addAll",
99  "library_write:addSome",
100  "library_read:getDistinctValuesForProperty",
101 
102  // sbILibraryResource
103  "library_read:getProperty",
104  "library_write:setProperty",
105  "library_read:equals"
106  };
107 
110  nsIClassInfo )
111 
112 NS_IMPL_CI_INTERFACE_GETTER7( sbRemoteLibrary,
117  sbIMediaList,
118  sbIMediaItem,
120 
121 SB_IMPL_CLASSINFO_INTERFACES_ONLY(sbRemoteLibrary)
122 
124 
125 sbRemoteLibrary::sbRemoteLibrary(sbRemotePlayer* aRemotePlayer) :
126  sbRemoteLibraryBase(aRemotePlayer)
127 {
128  LOG_LIB(("sbRemoteLibrary::sbRemoteLibrary()"));
129  mAllowDuplicates = PR_TRUE;
130 }
131 
133 {
134  LOG_LIB(("sbRemoteLibrary::~sbRemoteLibrary()"));
135 }
136 
137 
138 // ---------------------------------------------------------------------------
139 //
140 // Helper Methods
141 //
142 // ---------------------------------------------------------------------------
143 
144 // create an sbRemoteMediaList object to delegate the calls for
145 // sbIMediaList, sbIMediaItem, sbIRemoteMedialist
146 nsresult
148 {
149  LOG_LIB(("sbRemoteLibrary::InitInternalMediaList()"));
150  NS_ENSURE_STATE(mLibrary);
151 
152  nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(mLibrary);
153  NS_ENSURE_TRUE( mediaList, NS_ERROR_FAILURE );
154 
155  nsCOMPtr<sbIMediaListView> mediaListView;
156  nsresult rv = mediaList->CreateView( nsnull, getter_AddRefs(mediaListView) );
157  NS_ENSURE_SUCCESS( rv, rv );
158 
160  mediaList,
161  mediaListView );
162  NS_ENSURE_TRUE( mRemMediaList, NS_ERROR_OUT_OF_MEMORY );
163 
164  rv = mRemMediaList->Init();
165  NS_ENSURE_SUCCESS( rv, rv );
166 
167  return rv;
168 }
#define SB_IMPL_SECURITYCHECKEDCOMP_INIT(_class)
Definition: sbRemoteAPI.h:82
static const char * sPublicMethods[]
A brief description of the contents of this interface.
nsISecurityCheckedComponent
A marker interface for objects that aggregate the security mixin.
nsRefPtr< sbRemoteMediaListBase > mRemMediaList
An interface to control a media library from remote web pages.
virtual ~sbRemoteLibrary()
The result of a filtering expression in a library.
NS_IMPL_ISUPPORTS_INHERITED1(sbRemoteLibrary, sbRemoteLibraryBase, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER7(sbRemoteLibrary
nsCOMPtr< sbILibrary > mLibrary
virtual nsresult InitInternalMediaList()
Interface that defines a single item of media in the system.
nsRefPtr< sbRemotePlayer > mRemotePlayer
static const char * sPublicWProperties[]
#define SB_IMPL_CLASSINFO_INTERFACES_ONLY(_class)
static const char * sPublicRProperties[]
An interface to control a media list from remote web pages.
#define LOG_LIB(args)