sbDeviceImages.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 
25 #include <nsArrayUtils.h>
26 #include <sbIFileScan.h>
27 #include <nsIFileURL.h>
28 #include <nsNetUtil.h>
29 #include <nsCRT.h>
30 #include <nsUnicharUtils.h>
31 
32 #include "sbBaseDevice.h"
33 #include "sbDeviceImages.h"
34 #include "sbDeviceUtils.h"
35 #include <sbFileUtils.h>
36 #include <sbIDeviceCapabilities.h>
37 #include <sbIDeviceLibrarySyncSettings.h>
38 #include <sbStringUtils.h>
39 
40 nsresult
42 {
43  NS_ASSERTION(aDevLib, "aDevLib is null");
44  NS_ASSERTION(aFile, "aFile is null");
45 
46  nsCOMPtr<sbIDeviceLibrarySyncSettings> syncSettings;
47  nsresult rv = aDevLib->GetSyncSettings(getter_AddRefs(syncSettings));
48  NS_ENSURE_SUCCESS(rv, rv);
49 
50  nsCOMPtr<sbIDeviceLibraryMediaSyncSettings> mediaSyncSettings;
51  rv = syncSettings->GetMediaSettings(sbIDeviceLibrary::MEDIATYPE_IMAGE,
52  getter_AddRefs(mediaSyncSettings));
53  NS_ENSURE_SUCCESS(rv, rv);
54 
55  nsString syncFromFolder;
56  nsCOMPtr<nsIFile> syncFromFile;
57  rv = mediaSyncSettings->GetSyncFromFolder(getter_AddRefs(syncFromFile));
58  NS_ENSURE_SUCCESS(rv, rv);
59  if (!syncFromFile)
60  return NS_ERROR_NOT_AVAILABLE;
61 
62  rv = syncFromFile->GetPath(syncFromFolder);
63  NS_ENSURE_SUCCESS(rv, rv);
64 
65  if (syncFromFolder.IsEmpty())
66  return NS_ERROR_NOT_AVAILABLE;
67 
68  nsCOMPtr<nsILocalFile> baseDir;
69  rv = NS_NewLocalFile(syncFromFolder, PR_TRUE, getter_AddRefs(baseDir));
70  NS_ENSURE_SUCCESS(rv, rv);
71 
72  return CallQueryInterface(baseDir, aFile);
73 }
74 
75 sbDeviceImages::sbDeviceImages(sbBaseDevice * aBaseDevice) :
76  mBaseDevice(aBaseDevice)
77 {
78 }
79 
80 // Compute the difference between the images present locally and
81 // those provided in the device image array. You must provide a list
82 // of supported extensions. Upon return, the copy array is filled with
83 // sbIDeviceImage items which the device implementation should act upon.
84 nsresult
86  (sbIDeviceLibrary *aLibrary,
87  nsIArray *aDeviceImageArray,
88  const nsTArray<nsString> &aFileExtensionList,
89  nsIArray **retCopyArray)
90 {
91  NS_ENSURE_ARG_POINTER(retCopyArray);
92  nsresult rv;
93 
94  nsCOMPtr<nsIFile> baseDir;
95  rv = GetImagesRootFolder(aLibrary, getter_AddRefs(baseDir));
96  NS_ENSURE_SUCCESS(rv, rv);
97 
98  nsCOMPtr<nsIArray> subDirs;
99  rv = aLibrary->GetSyncFolderListByType(sbIDeviceLibrary::MEDIATYPE_IMAGE,
100  getter_AddRefs(subDirs));
101  NS_ENSURE_SUCCESS(rv, rv);
102 
103  // Create the array of files to copy
104  nsCOMPtr<nsIMutableArray> syncCopyArray =
105  do_CreateInstance("@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
106  NS_ENSURE_SUCCESS(rv, rv);
107 
108  // turn the device image array into a binary searchable array
109  PRUint32 len;
110  rv = aDeviceImageArray->GetLength(&len);
111  NS_ENSURE_SUCCESS(rv, rv);
112 
113  nsTArray< sbIDeviceImage* > searchableDeviceImageArray;
114  for (PRUint32 i=0; i<len; i++) {
115  nsCOMPtr<sbIDeviceImage> image =
116  do_QueryElementAt(aDeviceImageArray, i, &rv);
117  NS_ENSURE_SUCCESS(rv, rv);
118  searchableDeviceImageArray.AppendElement(image);
119  }
121  searchableDeviceImageArray.Sort(comp);
122 
123  // Create the array of local files
124  nsCOMPtr<nsIMutableArray> localImagesArray =
125  do_CreateInstance("@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
126  NS_ENSURE_SUCCESS(rv, rv);
127 
128  // Scan local files
129  PRUint32 numEntries;
130  rv = subDirs->GetLength(&numEntries);
131  NS_ENSURE_SUCCESS(rv, rv);
132 
133  for (PRUint32 i=0; i<numEntries; i++) {
134  nsCOMPtr<nsIFile> subDir =
135  do_QueryElementAt(subDirs, i, &rv);
136  NS_ENSURE_SUCCESS(rv, rv);
137 
138  rv = AddLocalImages(baseDir,
139  subDir,
140  aFileExtensionList,
141  PR_TRUE,
142  localImagesArray);
143  NS_ENSURE_SUCCESS(rv, rv);
144  }
145 
146  // add any local image missing from the device to the copy array
147  DiffImages(syncCopyArray, searchableDeviceImageArray, localImagesArray);
148 
149  // return sync array
150  rv = CallQueryInterface(syncCopyArray, retCopyArray);
151  NS_ENSURE_SUCCESS(rv, rv);
152 
153  return NS_OK;
154 }
155 
156 // This may be called by devices whose underlying storage lies on the
157 // filesystem to build an array of sbIDeviceImage items. aScanPath is the
158 // directory that is to be scanned. aBasePath is the base of the image
159 // directory on that filesystem. You must also provide a list of supported
160 // extensions.
161 nsresult
162 sbDeviceImages::ScanImages(nsIFile *aScanDir,
163  nsIFile *aBaseDir,
164  const nsTArray<nsString> &aFileExtensionList,
165  PRBool recursive,
166  nsIArray **retImageArray) {
167  nsresult rv;
168 
169  // turn the scan files into a uri
170  nsCOMPtr<nsIURI> scanDirUri;
171  rv = NS_NewFileURI(getter_AddRefs(scanDirUri), aScanDir);
172  NS_ENSURE_SUCCESS(rv, rv);
173 
174  // Scan for all media files in image directory.
175  nsCOMPtr<sbIFileScanQuery> fileScanQuery;
176  rv = ScanForImageFiles(scanDirUri,
177  aFileExtensionList,
178  recursive,
179  getter_AddRefs(fileScanQuery));
180  NS_ENSURE_SUCCESS(rv, rv);
181 
182  // Get the number of scanned files.
183  PRUint32 fileCount;
184  rv = fileScanQuery->GetFileCount(&fileCount);
185  NS_ENSURE_SUCCESS(rv, rv);
186 
187  // Get the base paths
188  nsString basePath;
189  rv = aBaseDir->GetPath(basePath);
190  NS_ENSURE_SUCCESS(rv, rv);
191 
192  // Create a list of sbIDeviceImage found at the scan location
193  nsCOMPtr<nsIMutableArray> imageArray =
194  do_CreateInstance("@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
195  NS_ENSURE_SUCCESS(rv, rv);
196 
197  for (PRUint32 i = 0; i < fileCount; i++) {
198  // Check for abort.
199  NS_ENSURE_FALSE(mBaseDevice->IsRequestAborted(), NS_ERROR_ABORT);
200 
201  // Get the next file URI spec.
202  nsAutoString fileURISpec;
203  rv = fileScanQuery->GetFilePath(i, fileURISpec);
204  NS_ENSURE_SUCCESS(rv, rv);
205 
206  // Get the file content type.
207  PRUint32 contentType = sbIDeviceCapabilities::CONTENT_UNKNOWN;
209  rv = sbDeviceUtils::GetFormatTypeForURL(fileURISpec, formatType);
210  if (NS_SUCCEEDED(rv))
211  contentType = formatType.ContentType;
212 
213  // Check that the file is really an image
214  if (contentType == sbIDeviceCapabilities::CONTENT_IMAGE) {
215  // Create a file URI.
216  nsCOMPtr<nsIURI> fileURI;
217  rv = NS_NewURI(getter_AddRefs(fileURI),
218  NS_ConvertUTF16toUTF8(fileURISpec).get());
219  NS_ENSURE_SUCCESS(rv, rv);
220 
221  nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(fileURI, &rv);
222  NS_ENSURE_SUCCESS(rv, rv);
223 
224  // Create an nsIFile
225  nsCOMPtr<nsIFile> file;
226  rv = fileURL->GetFile(getter_AddRefs(file));
227  NS_ENSURE_SUCCESS(rv, rv);
228 
229  // Get the file's parent directory
230  nsCOMPtr<nsIFile> parent;
231  rv = file->GetParent(getter_AddRefs(parent));
232  NS_ENSURE_SUCCESS(rv, rv);
233 
234  // Get the local path
235  nsString parentPath;
236  rv = parent->GetPath(parentPath);
237  NS_ENSURE_SUCCESS(rv, rv);
238 
239  // Subtract the image folder from the file's path
240  NS_ENSURE_TRUE(parentPath.Length() >= basePath.Length(),
241  NS_ERROR_UNEXPECTED);
242  nsString partialPath;
243  partialPath = parentPath.BeginReading() + basePath.Length();
244 
245  // Eat the first path separator if there's one
246  if (partialPath.First() == *FILE_PATH_SEPARATOR)
247  partialPath = partialPath.BeginReading() + 1;
248 
249  // Get the file name
250  nsString filename;
251  rv = file->GetLeafName(filename);
252  NS_ENSURE_SUCCESS(rv, rv);
253 
254  // Get the file size
255  PRInt64 size;
256  rv = file->GetFileSize(&size);
257  NS_ENSURE_SUCCESS(rv, rv);
258 
259  // Make a new sbIDeviceImage entry
260  nsCOMPtr<sbIDeviceImage> image = new sbDeviceImage();
261  image->SetFilename(filename);
262  image->SetSubdirectory(partialPath);
263  image->SetSize(size);
264 
265  // Add the image to the list.
266  rv = imageArray->AppendElement(image, PR_FALSE);
267  NS_ENSURE_SUCCESS(rv, rv);
268  }
269 
270  }
271 
272  // Return the array of images that were found
273  return CallQueryInterface(imageArray, retImageArray);
274 }
275 
276 // Create and return in aMediaItem a temporary media item for the local file
277 // represented by aImage and device library aLibrary.
278 nsresult
280  sbIDeviceLibrary* aLibrary,
281  sbIMediaItem** aMediaItem)
282 {
283  // Validate arguments.
284  NS_ENSURE_ARG_POINTER(aMediaItem);
285 
286  // Function variables.
287  nsresult rv;
288 
289  // Get the local image base directory.
290  nsCOMPtr<nsIFile> baseDir;
291  rv = GetImagesRootFolder(aLibrary, getter_AddRefs(baseDir));
292  NS_ENSURE_SUCCESS(rv, rv);
293  NS_ENSURE_TRUE(baseDir, NS_ERROR_UNEXPECTED);
294 
295  // Get the local device image file URI.
296  nsCOMPtr<nsIURI> imageURI;
297  nsCOMPtr<nsIFile> imageFile;
298  rv = MakeFile(aImage, baseDir, PR_TRUE, PR_FALSE, getter_AddRefs(imageFile));
299  NS_ENSURE_SUCCESS(rv, rv);
300  rv = NS_NewFileURI(getter_AddRefs(imageURI), imageFile);
301  NS_ENSURE_SUCCESS(rv, rv);
302 
303  // Create a temporary media item.
304  nsCOMPtr<sbIMediaItem>
305  item = do_CreateInstance
306  ("@songbirdnest.com/Songbird/Library/TemporaryMediaItem;1", &rv);
307  NS_ENSURE_SUCCESS(rv, rv);
308 
309  // Set up the temporary media item.
310  rv = item->SetContentType(NS_LITERAL_STRING("image"));
311  NS_ENSURE_SUCCESS(rv, rv);
312  rv = item->SetContentSrc(imageURI);
313  NS_ENSURE_SUCCESS(rv, rv);
314 
315  // Return results.
316  item.forget(aMediaItem);
317 
318  return NS_OK;
319 }
320 
321 // Create an nsIFile for an sbIDeviceImage item given the base image sync
322 // directory. The function can automatically create the needed subdirectories
323 // in which the file will reside, or to create a file object pointing at the
324 // file's parent directory rather than at the file itself.
326  nsIFile* aBaseDir,
327  PRBool aWithFilename,
328  PRBool aCreateDirectories,
329  nsIFile** retFile)
330 {
331  NS_ENSURE_ARG_POINTER(retFile);
332  NS_ENSURE_ARG_POINTER(aBaseDir);
333 
334  nsresult rv;
335 
336  // Create a local file object to point at the source file
337  nsCOMPtr<nsIFile> file;
338  rv = aBaseDir->Clone(getter_AddRefs(file));
339  NS_ENSURE_SUCCESS(rv, rv);
340 
341  // Get the image subdirectories
342  nsString subDirectories;
343  rv = aImage->GetSubdirectory(subDirectories);
344  NS_ENSURE_SUCCESS(rv, rv);
345 
346  // Add subdirectories to the file object, one by one, optionally making sure
347  // that they each exist
348  if (!subDirectories.IsEmpty()) {
349  nsTArray<nsString> subDirectoryList;
350  nsString_Split(subDirectories,
351  NS_LITERAL_STRING(FILE_PATH_SEPARATOR),
352  subDirectoryList);
353  for (PRUint32 i = 0; i < subDirectoryList.Length(); ++i) {
354  const nsString& subDirectory = subDirectoryList[i];
355  if (!subDirectory.IsEmpty()) {
356  // Append the sub-directory to the file object
357  rv = file->Append(subDirectory);
358  NS_ENSURE_SUCCESS(rv, rv);
359  // If needed, create the directory
360  if (aCreateDirectories) {
361  PRBool exists;
362  rv = file->Exists(&exists);
363  NS_ENSURE_SUCCESS(rv, rv);
364  if (!exists) {
365  rv = file->Create(nsIFile::DIRECTORY_TYPE,
367  NS_ENSURE_SUCCESS(rv, rv);
368  }
369  }
370  }
371  }
372  }
373 
374  // If needed, add the filename to the file object
375  if (aWithFilename) {
376  nsString filename;
377  rv = aImage->GetFilename(filename);
378  NS_ENSURE_SUCCESS(rv, rv);
379  rv = file->Append(filename);
380  NS_ENSURE_SUCCESS(rv, rv);
381  }
382 
383  file.forget(retFile);
384  return NS_OK;
385 }
386 
387 // ----------------------------------------------------------------------------
388 
389 // add local images to an existing array, this is used to sequentially
390 // build the list of all local files that should be synced.
391 nsresult
392 sbDeviceImages::
393  AddLocalImages(nsIFile *baseDir,
394  nsIFile *scanDir,
395  const nsTArray<nsString> aFileExtensionList,
396  PRBool recursive,
397  nsIMutableArray *localImageArray)
398 {
399  nsresult rv;
400 
401  // Scan for images at that location
402  nsCOMPtr<nsIArray> items;
403  rv = ScanImages(scanDir,
404  baseDir,
405  aFileExtensionList,
406  recursive,
407  getter_AddRefs(items));
408  NS_ENSURE_SUCCESS(rv, rv);
409 
410  // Add all elements to the main array
411  PRUint32 len;
412  rv = items->GetLength(&len);
413  NS_ENSURE_SUCCESS(rv, rv);
414 
415  for (PRUint32 i=0;i<len;i++) {
416  nsCOMPtr<sbIDeviceImage> image = do_QueryElementAt(items, i, &rv);
417  NS_ENSURE_SUCCESS(rv, rv);
418  localImageArray->AppendElement(image, PR_FALSE);
419  }
420 
421  return NS_OK;
422 }
423 
424 // search for each item that is in searchItem in the searchableImageArray.
425 // if an item does not exist, it is inserted in the diffResultsArray
426 nsresult
427 sbDeviceImages::DiffImages(nsIMutableArray *diffResultsArray,
428  nsTArray< sbIDeviceImage* > &searchableImageArray,
429  nsIArray *searchItems)
430 {
431  PRUint32 len;
432  nsresult rv = searchItems->GetLength(&len);
433  NS_ENSURE_SUCCESS(rv, rv);
434 
435  // a comparator object for binary search
437  for (PRUint32 i=0;i<len;i++) {
438  // Get the nth item
439  nsCOMPtr<sbIDeviceImage> image = do_QueryElementAt(searchItems, i, &rv);
440  NS_ENSURE_SUCCESS(rv, rv);
441  // Look for that item in the searchable array
442  if (searchableImageArray.BinaryIndexOf(image, comp) ==
443  searchableImageArray.NoIndex) {
444  // If the item was not found, add it to the diff array
445  diffResultsArray->AppendElement(image, PR_FALSE);
446  }
447  }
448  return NS_OK;
449 }
450 
451 
452 // perform the actual image scanning of a directory using a filescan object
453 nsresult
454 sbDeviceImages::ScanForImageFiles(nsIURI *aImageFilesPath,
455  const nsTArray<nsString> &aFileExtensionList,
456  PRBool recursive,
457  sbIFileScanQuery** aFileScanQuery)
458 {
459  NS_ENSURE_ARG_POINTER(aFileScanQuery);
460 
461  nsresult rv;
462 
463  // Create a file scan query object to search the device.
464  nsCOMPtr<sbIFileScanQuery> fileScanQuery =
465  do_CreateInstance("@songbirdnest.com/Songbird/FileScanQuery;1", &rv);
466  NS_ENSURE_SUCCESS(rv, rv);
467 
468  nsCOMPtr<nsIFileURL> _url = do_QueryInterface(aImageFilesPath, &rv);
469  NS_ENSURE_SUCCESS(rv, rv);
470  nsCOMPtr<nsIFile> _file;
471  rv = _url->GetFile(getter_AddRefs(_file));
472  NS_ENSURE_SUCCESS(rv, rv);
473  nsString path;
474  rv = _file->GetPath(path);
475  NS_ENSURE_SUCCESS(rv, rv);
476 
477  rv = fileScanQuery->SetDirectory(path);
478  NS_ENSURE_SUCCESS(rv, rv);
479  rv = fileScanQuery->SetRecurse(recursive);
480  NS_ENSURE_SUCCESS(rv, rv);
481  rv = fileScanQuery->SetSearchHidden(PR_TRUE);
482  NS_ENSURE_SUCCESS(rv, rv);
483  rv = fileScanQuery->SetWantLibraryContentURIs(PR_FALSE);
484  NS_ENSURE_SUCCESS(rv, rv);
485 
486  // Get the device capabilities.
487  nsCOMPtr<sbIDeviceCapabilities> caps;
488  rv = mBaseDevice->GetCapabilities(getter_AddRefs(caps));
489  NS_ENSURE_SUCCESS(rv, rv);
490 
491  // Add the file extensions to the file scan query.
492  for (PRUint32 i = 0; i < aFileExtensionList.Length(); ++i) {
493  rv = fileScanQuery->AddFileExtension(aFileExtensionList[i]);
494  NS_ENSURE_SUCCESS(rv, rv);
495  }
496 
497  // Create a file scan engine and submit the query.
498  nsCOMPtr<sbIFileScan>
499  fileScan = do_CreateInstance("@songbirdnest.com/Songbird/FileScan;1", &rv);
500  NS_ENSURE_SUCCESS(rv, rv);
501  rv = fileScan->SubmitQuery(fileScanQuery);
502  NS_ENSURE_SUCCESS(rv, rv);
503 
504  // Wait until the file scan query completes. Poll instead of using callbacks
505  // because individual item callbacks are not needed and would reduce
506  // efficiency.
507  PRBool isScanning = PR_TRUE;
508  while (isScanning) {
509  // Check for abort.
510  NS_ENSURE_FALSE(mBaseDevice->IsRequestAborted(), NS_ERROR_ABORT);
511 
512  // Check if the file scan query is still scanning.
513  rv = fileScanQuery->IsScanning(&isScanning);
514  NS_ENSURE_SUCCESS(rv, rv);
515 
516  // If still scanning, sleep a bit and check again.
517  if (isScanning)
518  PR_Sleep(PR_MillisecondsToInterval(100));
519  }
520 
521  // Return results.
522  fileScanQuery.forget(aFileScanQuery);
523 
524  return NS_OK;
525 }
526 
527 
528 // ----------------------------------------------------------------------------
529 
530 // sbDeviceImage, implements sbIDeviceImage, holds information about a device
531 // image: filename, subdirectory below the base image directory (be it on the
532 // actual device, or the sync source directory), and file size.
533 
536 
538  mSize(0)
539 {
540 }
541 
542 // Get the file size in bytes
543 NS_IMETHODIMP sbDeviceImage::GetSize(PRUint64 *aSizePtr)
544 {
545  NS_ENSURE_ARG_POINTER(aSizePtr);
546  *aSizePtr = mSize;
547  return NS_OK;
548 }
549 
550 // Set the file size in bytes
551 NS_IMETHODIMP sbDeviceImage::SetSize(PRUint64 aSize)
552 {
553  mSize = aSize;
554  return NS_OK;
555 }
556 // Get the filename
557 NS_IMETHODIMP sbDeviceImage::GetFilename(nsAString &aFilename)
558 {
559  aFilename = mFilename;
560  return NS_OK;
561 }
562 
563 // Set the filename
564 NS_IMETHODIMP sbDeviceImage::SetFilename(const nsAString &aFilename)
565 {
566  mFilename = aFilename;
567  return NS_OK;
568 }
569 
570 // Get the subdirectory. This directory is relative to either the local
571 // sync directory selected by the user, or the device image directory
572 NS_IMETHODIMP sbDeviceImage::GetSubdirectory(nsAString &aSubdirectory)
573 {
574  aSubdirectory = mSubdirectory;
575  return NS_OK;
576 }
577 
578 // Set the subdirectory
579 NS_IMETHODIMP sbDeviceImage::SetSubdirectory(const nsAString &aSubdirectory)
580 {
581  mSubdirectory = aSubdirectory;
582  return NS_OK;
583 }
584 
585 // Sorting operator.
587 {
588  nsString a_subdir;
589  nsString b_subdir;
590  const_cast<sbIDeviceImage *>(a)->GetSubdirectory(a_subdir);
591  const_cast<sbIDeviceImage *>(b)->GetSubdirectory(b_subdir);
592  PRInt32 comp = a_subdir.Compare(b_subdir, CaseInsensitiveCompare);
593  if (comp < 0) {
594  return PR_TRUE;
595  } else if (comp > 0) {
596  return PR_FALSE;
597  }
598  nsString a_filename;
599  nsString b_filename;
600  const_cast<sbIDeviceImage *>(a)->GetFilename(a_filename);
601  const_cast<sbIDeviceImage *>(b)->GetFilename(b_filename);
602  return a_filename.Compare(b_filename, CaseInsensitiveCompare) < 0;
603 }
604 
605 // Sorting operator.
607 {
608  nsString a_subdir;
609  nsString b_subdir;
610  ((sbIDeviceImage *)a)->GetSubdirectory(a_subdir);
611  ((sbIDeviceImage *)b)->GetSubdirectory(b_subdir);
612  if (!a_subdir.Equals(b_subdir, CaseInsensitiveCompare)) {
613  return PR_FALSE;
614  }
615  nsString a_filename;
616  nsString b_filename;
617  ((sbIDeviceImage *)a)->GetFilename(a_filename);
618  ((sbIDeviceImage *)b)->GetFilename(b_filename);
619  return a_filename.Equals(b_filename, CaseInsensitiveCompare);
620 }
static nsresult GetImagesRootFolder(sbIDeviceLibrary *aDevLib, nsIFile **aFile)
return NS_OK
const NS_ERROR_ABORT
PRBool Equals(const sbIDeviceImage *a, const sbIDeviceImage *b) const
const unsigned long MEDIATYPE_IMAGE
virtual PRBool IsRequestAborted()
static nsresult GetFormatTypeForURL(const nsAString &aURL, sbExtensionToContentFormatEntry_t &aFormatType)
For a URL, get format information describing it (extension, mime type, etc.
nsresult ComputeImageSyncArray(sbIDeviceLibrary *aLibrary, nsIArray *aDeviceImageArray, const nsTArray< nsString > &aFileExtensionList, nsIArray **retCopyArray)
void nsString_Split(const nsAString &aString, const nsAString &aDelimiter, nsTArray< nsString > &aSubStringArray)
nsresult ScanImages(nsIFile *aScanDir, nsIFile *aBaseDir, const nsTArray< nsString > &aFileExtensionList, PRBool recursive, nsIArray **retImageArray)
Definition: sbDeviceUtils.h:54
var _file
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICEIMAGE sbDeviceImage()
nsresult CreateTemporaryLocalMediaItem(sbIDeviceImage *aImage, sbIDeviceLibrary *aLibrary, sbIMediaItem **aMediaItem)
PRBool LessThan(const sbIDeviceImage *a, const sbIDeviceImage *b) const
PRUint32 ContentType
Definition: sbDeviceUtils.h:61
Interface that defines a single item of media in the system.
nsresult MakeFile(sbIDeviceImage *aImage, nsIFile *aBaseDir, PRBool aWithFilename, PRBool aCreateDirectories, nsIFile **retFile)
An object to scan through the files of a folder (and optionally subfolders)
#define SB_DEFAULT_DIRECTORY_PERMISSIONS
Definition: sbFileUtils.h:124
_getSelectedPageStyle s i
NS_IMPL_ISUPPORTS1(sbDeviceImage, sbIDeviceImage)
var file