sbLocalDatabaseDiffingService.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 __SB_LOCALDATABASEDIFFINGSERVICE_H__
26 #define __SB_LOCALDATABASEDIFFINGSERVICE_H__
27 
28 #include <sbILibraryDiffingService.h>
29 
30 #include <nsIClassInfo.h>
31 #include <nsIGenericFactory.h>
32 #include <nsIThread.h>
33 
34 #include <sbILibrary.h>
35 #include <sbILibraryChangeset.h>
36 #include <sbIMediaItem.h>
37 #include <sbIMediaList.h>
38 #include <sbIMediaListListener.h>
39 #include <sbIPropertyArray.h>
40 #include <sbIPropertyManager.h>
41 
42 #include <nsAutoPtr.h>
43 #include <nsCOMPtr.h>
44 #include <nsInterfaceHashtable.h>
45 #include <nsTArray.h>
46 
47 #include <sbLibraryChangeset.h>
48 
49 class sbLDBDSEnumerator;
50 
52  public nsIClassInfo
53 {
54 public:
56  NS_DECL_NSICLASSINFO
57  NS_DECL_SBILIBRARYDIFFINGSERVICE
58 
60 
61  static NS_METHOD RegisterSelf(nsIComponentManager* aCompMgr,
62  nsIFile* aPath,
63  const char* aLoaderStr,
64  const char* aType,
65  const nsModuleComponentInfo *aInfo);
66 
71  nsresult Init();
72 
73 protected:
77  nsresult GetPropertyIDs(nsIStringEnumerator **aPropertyIDs);
78 
86  nsresult CreateLibraryChangeFromItems(sbIMediaItem *aSourceItem,
87  sbIMediaItem *aDestinationItem,
88  sbILibraryChange **aLibraryChange);
89 
90  nsresult CreateItemAddedLibraryChange(sbIMediaItem *aSourceItem,
91  sbILibraryChange **aLibraryChange);
92 
93  nsresult CreateItemMovedLibraryChange(sbIMediaItem *aSourceItem,
94  PRUint32 aItemOrdinal,
95  sbILibraryChange **aLibraryChange);
96 
97  nsresult CreateItemDeletedLibraryChange(sbIMediaItem *aDestinationItem,
98  sbILibraryChange **aLibraryChange);
99 
108  nsresult CreatePropertyChangesFromProperties(sbIPropertyArray *aSourceProperties,
109  sbIPropertyArray *aDestinationProperties,
110  nsIArray **aPropertyChanges);
111 
120  nsresult CreateLibraryChangesetFromLists(sbIMediaList *aSourceList,
121  sbIMediaList *aDestinationList,
122  sbILibraryChangeset **aLibraryChangeset);
123 
133  nsresult CreateChanges(sbIMediaList * aSrcLibrary,
134  sbIMediaList * aDestLibrary,
135  sbLDBDSEnumerator * aSrcEnum,
136  sbLDBDSEnumerator * aDestEnum,
137  nsIArray ** aChanges);
146  nsresult CreateLibraryChangesetFromLibraries(sbILibrary *aSourceLibrary,
147  sbILibrary *aDestinationLibrary,
148  sbILibraryChangeset **aLibraryChangeset);
149 
150  nsresult CreateLibraryChangesetFromListsToLibrary(nsIArray *aSourceLists,
151  sbILibrary *aDestinationLibrary,
152  sbILibraryChangeset **aLibraryChangeset);
153 
163  nsresult AddToUniqueItemList(
164  sbIMediaItem* aSourceItem,
165  sbIPropertyArray* aUniquePropSet,
166  nsInterfaceHashtable<nsStringHashKey, sbIMediaItem>& aUniqueItemList,
167  nsTArray<nsString>& aUniqueItemGUIDList,
168  nsTHashtable<nsStringHashKey>& aUniqueItemPropTable);
169 
173  static PLDHashOperator Enumerator(nsIDHashKey* aEntry, void* userArg);
174 private:
175  ~sbLocalDatabaseDiffingService();
176 
177 protected:
178  nsCOMPtr<nsIThread> mProcessorThread;
179  nsCOMPtr<sbIPropertyManager> mPropertyManager;
180 
181 // XXXAus: These are placeholders for future implementation.
182 // nsInterfaceHashtableMT<> mObservers;
183 // nsInterfaceHashtableMT<> mChangesets;
184 };
185 
186 #endif /* __SB_LOCALDATABASEDIFFINGSERVICE_H__ */
_updateCookies aPath
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBILIBRARYDIFFINGSERVICE sbLocalDatabaseDiffingService()
nsresult CreatePropertyChangesFromProperties(sbIPropertyArray *aSourceProperties, sbIPropertyArray *aDestinationProperties, nsIArray **aPropertyChanges)
nsCOMPtr< sbIPropertyManager > mPropertyManager
static NS_METHOD RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
nsresult CreateLibraryChangesetFromLists(sbIMediaList *aSourceList, sbIMediaList *aDestinationList, sbILibraryChangeset **aLibraryChangeset)
Library and media list diffing service.
nsresult CreateItemDeletedLibraryChange(sbIMediaItem *aDestinationItem, sbILibraryChange **aLibraryChange)
nsresult CreateItemMovedLibraryChange(sbIMediaItem *aSourceItem, PRUint32 aItemOrdinal, sbILibraryChange **aLibraryChange)
sbLibraryChangeset Definition.
A brief description of the contents of this interface.
nsresult AddToUniqueItemList(sbIMediaItem *aSourceItem, sbIPropertyArray *aUniquePropSet, nsInterfaceHashtable< nsStringHashKey, sbIMediaItem > &aUniqueItemList, nsTArray< nsString > &aUniqueItemGUIDList, nsTHashtable< nsStringHashKey > &aUniqueItemPropTable)
nsresult CreateLibraryChangesetFromLibraries(sbILibrary *aSourceLibrary, sbILibrary *aDestinationLibrary, sbILibraryChangeset **aLibraryChangeset)
nsresult CreateLibraryChangesetFromListsToLibrary(nsIArray *aSourceLists, sbILibrary *aDestinationLibrary, sbILibraryChangeset **aLibraryChangeset)
nsresult CreateItemAddedLibraryChange(sbIMediaItem *aSourceItem, sbILibraryChange **aLibraryChange)
nsresult CreateChanges(sbIMediaList *aSrcLibrary, sbIMediaList *aDestLibrary, sbLDBDSEnumerator *aSrcEnum, sbLDBDSEnumerator *aDestEnum, nsIArray **aChanges)
Media library abstraction.
Definition: sbILibrary.idl:82
Interface that defines a single item of media in the system.
nsresult CreateLibraryChangeFromItems(sbIMediaItem *aSourceItem, sbIMediaItem *aDestinationItem, sbILibraryChange **aLibraryChange)
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
static PLDHashOperator Enumerator(nsIDHashKey *aEntry, void *userArg)
nsresult GetPropertyIDs(nsIStringEnumerator **aPropertyIDs)