28 #include <sbIMediaFileManager.h>
29 #include <sbIPropertyManager.h>
30 #include <sbIWatchFolderService.h>
33 #include <nsBaseHashtable.h>
34 #include <nsHashKeys.h>
36 #include <nsIPrefBranch.h>
37 #include <nsStringGlue.h>
40 #include <nsNetUtil.h>
42 #define SB_MEDIAFILEMANAGER_DESCRIPTION \
43 "Songbird Media File Manager Implementation"
45 #define SB_MEDIAFILEMANAGER_CID \
50 {0x8d, 0x6a, 0xe1, 0x78, 0x4d, 0xbd, 0x2d, 0x89} \
54 #define PREF_MFM_ROOT "songbird.media_management.library."
55 #define PREF_MFM_FILEFORMAT "format.file"
56 #define PREF_MFM_DEFPROPERTY "default.property."
57 #define PREF_MFM_PADTRACKNUM "pad_track_num"
60 #define STRING_MFM_UNKNOWNPROP "mediamanager.nonexistingproperty"
61 #define STRING_MFM_UNKNOWNPROP_EMPTY "mediamanager.nonexistingproperty.empty"
62 #define STRING_MFM_RECORDINGS_FOLDER "mediamanager.recordings_dir"
70 NS_DECL_SBIMEDIAFILEMANAGER
89 nsresult
Delete(nsIFile *aItemFile,
97 const nsAString & aTotalTrackCountStr,
98 nsString & aOutString);
101 typedef nsTArray<nsString> NameTemplate;
102 typedef nsBaseHashtable<nsStringHashKey,
104 NameTemplate> NameTemplateMap;
105 typedef nsBaseHashtable<nsStringHashKey,
107 nsIFile *> MediaFoldersMap;
109 nsresult InitMediaFoldersMap(nsIPropertyBag2 * aProperties);
114 nsresult GetMediaFolder(nsIFile * aFile,
117 nsresult InitFolderNameTemplates(nsIPropertyBag2 * aProperties);
119 nsresult GetFolderNameTemplate(
sbIMediaItem * aMediaItem,
120 NameTemplate & aNameTemplate);
122 nsresult CheckDirectoryForDeletion_Recursive(nsIFile *aDir);
124 void RemoveBadCharacters(nsString& aStringToParse);
126 nsresult GetUnknownValue(nsString aPropertyKey,
127 nsString& aUnknownValue);
129 nsresult GetFormattedFileFolder(
const NameTemplate & aNameTemplate,
131 PRBool aAppendProperty,
133 nsString aFileExtension,
142 nsresult CheckManagementFolder(
sbIMediaItem * aMediaItem);
145 nsCOMPtr<nsIPrefBranch> mPrefBranch;
146 nsCOMPtr<nsINetUtil> mNetUtil;
147 nsCOMPtr<sbIPropertyManager> mPropertyManager;
148 nsCOMPtr<sbIWatchFolderService> mWatchFolderService;
151 MediaFoldersMap mMediaFolders;
154 NameTemplate mTrackNameTemplate;
155 NameTemplateMap mFolderNameTemplates;