sbPropertyManager.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-2011 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 "sbPropertyManager.h"
26 #include "sbPropertiesCID.h"
27 
28 #include <nsICategoryManager.h>
29 #include <nsIGenericFactory.h>
30 #include <nsIObserverService.h>
31 #include <nsIStringBundle.h>
32 
33 #include <nsAutoLock.h>
34 #include <nsAutoPtr.h>
35 #include <nsComponentManagerUtils.h>
36 #include <nsMemory.h>
37 #include <nsServiceManagerUtils.h>
38 
39 #include "sbBooleanPropertyInfo.h"
40 #include "sbDatetimePropertyInfo.h"
41 #include "sbDurationPropertyInfo.h"
42 #include "sbNumberPropertyInfo.h"
43 #include "sbStandardProperties.h"
44 #include "sbDummyProperties.h"
46 #include "sbTextPropertyInfo.h"
47 #include "sbURIPropertyInfo.h"
48 #include "sbImagePropertyInfo.h"
61 #include <sbLockUtils.h>
63 #include <sbIPropertyBuilder.h>
64 
65 #ifdef DEBUG
66 #include <prprf.h>
67 #endif
68 
69 /*
70  * * To log this module, set the following environment variable:
71  * * NSPR_LOG_MODULES=sbPropMan:5
72  * */
73 #include <prlog.h>
74 #ifdef PR_LOGGING
75 static PRLogModuleInfo* gPropManLog = nsnull;
76 #endif
77 
78 #define LOG(args) PR_LOG(gPropManLog, PR_LOG_WARN, args)
79 #ifdef __GNUC__
80 #define __FUNCTION__ __PRETTY_FUNCTION__
81 #endif
82 
83 
84 #if !defined(SB_STRING_BUNDLE_CHROME_URL)
85  #define SB_STRING_BUNDLE_CHROME_URL "chrome://songbird/locale/songbird.properties"
86 #endif
87 
88 
89 const struct {
90  const char* propName;
91  const char* types;
93  { SB_PROPERTY_ALBUMNAME, "audio video" },
94  { SB_PROPERTY_ALBUMARTISTNAME, "audio video" },
95  { SB_PROPERTY_ARTISTNAME, "audio video" },
96  { SB_PROPERTY_GENRE, "audio video" },
97  { SB_PROPERTY_YEAR, "audio video" },
98  { SB_PROPERTY_RATING, "audio video" },
99  { SB_PROPERTY_COMPOSERNAME, "audio " },
100  { SB_PROPERTY_BITRATE, "audio " },
101  { SB_PROPERTY_SAMPLERATE, "audio " },
102  { SB_PROPERTY_BPM, "audio " },
103  { SB_PROPERTY_SHOWNAME, " video" },
104 };
105 
108 
110 : mPropIDsLock(nsnull)
111 {
112 #ifdef PR_LOGGING
113  if (!gPropManLog) {
114  gPropManLog = PR_NewLogModule("sbPropMan");
115  }
116 #endif
117 
118  PRBool success = mPropInfoHashtable.Init(100);
119  NS_ASSERTION(success,
120  "sbPropertyManager::mPropInfoHashtable failed to initialize!");
121 
122  success = mPropDependencyMap.Init(100);
123  NS_ASSERTION(success,
124  "sbPropertyManager::mPropInfoHashtable failed to initialize!");
125 
126  mPropIDsLock = PR_NewLock();
127  NS_ASSERTION(mPropIDsLock,
128  "sbPropertyManager::mPropIDsLock failed to create lock!");
129 }
130 
132 {
133  mPropInfoHashtable.Clear();
134  mPropDependencyMap.Clear();
135 
136  if(mPropIDsLock) {
137  PR_DestroyLock(mPropIDsLock);
138  }
139 }
140 
142 {
143  nsresult rv;
144 
145  rv = CreateSystemProperties();
146  NS_ENSURE_SUCCESS(rv, rv);
147 
148  rv = RegisterFilterListPickerProperties();
149  NS_ENSURE_SUCCESS(rv, rv);
150 
151  nsCOMPtr<nsIObserverService> obs =
152  do_GetService("@mozilla.org/observer-service;1");
153  if (obs) {
154  obs->NotifyObservers(nsnull, SB_PROPERTY_MANAGER_READY_CATEGORY, nsnull);
155  }
156 
157  nsCOMPtr<nsIObserver> startupNotifier =
158  do_CreateInstance("@mozilla.org/embedcomp/appstartup-notifier;1", &rv);
159  NS_ENSURE_SUCCESS(rv, rv);
160 
161  startupNotifier->Observe(nsnull, SB_PROPERTY_MANAGER_READY_CATEGORY, nsnull);
162 
163  return NS_OK;
164 }
165 
166 NS_IMETHODIMP sbPropertyManager::GetPropertyIDs(nsIStringEnumerator * *aPropertyIDs)
167 {
168  NS_ENSURE_ARG_POINTER(aPropertyIDs);
169 
170  PR_Lock(mPropIDsLock);
171  *aPropertyIDs = new sbTArrayStringEnumerator(&mPropIDs);
172  PR_Unlock(mPropIDsLock);
173 
174  NS_ENSURE_TRUE(*aPropertyIDs, NS_ERROR_OUT_OF_MEMORY);
175  NS_ADDREF(*aPropertyIDs);
176 
177  return NS_OK;
178 }
179 
180 NS_IMETHODIMP sbPropertyManager::AddPropertyInfo(sbIPropertyInfo *aPropertyInfo)
181 {
182  NS_ENSURE_ARG_POINTER(aPropertyInfo);
183 
184  nsresult rv;
185  nsAutoString id;
186  PRBool success = PR_FALSE;
187 
188  rv = aPropertyInfo->GetId(id);
189  NS_ENSURE_SUCCESS(rv, rv);
190 
191  success = mPropInfoHashtable.Put(id, aPropertyInfo);
192  NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
193 
194  PR_Lock(mPropIDsLock);
195  mPropIDs.AppendElement(id);
196  mPropDependencyMap.Clear();
197  PR_Unlock(mPropIDsLock);
198 
199  return NS_OK;
200 }
201 
202 NS_IMETHODIMP sbPropertyManager::GetPropertyInfo(const nsAString & aID,
203  sbIPropertyInfo **_retval)
204 {
205  LOG(( "sbPropertyManager::GetPropertyInfo(%s)",
206  NS_LossyConvertUTF16toASCII(aID).get() ));
207 
208  NS_ENSURE_ARG_POINTER(_retval);
209  *_retval = nsnull;
210 
211  if(mPropInfoHashtable.Get(aID, _retval)) {
212  return NS_OK;
213  }
214  else {
215  //Create default property (text) for new property id encountered.
216  nsresult rv;
217  nsRefPtr<sbTextPropertyInfo> textProperty;
218 
219  textProperty = new sbTextPropertyInfo();
220  NS_ENSURE_TRUE(textProperty, NS_ERROR_OUT_OF_MEMORY);
221 
222  rv = textProperty->Init();
223  NS_ENSURE_SUCCESS(rv, rv);
224 
225  rv = textProperty->SetId(aID);
226  NS_ENSURE_SUCCESS(rv, rv);
227 
228  nsCOMPtr<sbIPropertyInfo> propInfo = do_QueryInterface(NS_ISUPPORTS_CAST(sbITextPropertyInfo*, textProperty), &rv);
229  NS_ENSURE_SUCCESS(rv, rv);
230 
231  rv = AddPropertyInfo(propInfo);
232  NS_ENSURE_SUCCESS(rv, rv);
233 
234  //This is the only safe way to hand off the instance because the hash table
235  //may have changed and returning the instance pointer above may yield a
236  //stale pointer and cause a crash.
237  if(mPropInfoHashtable.Get(aID, _retval)) {
238  return NS_OK;
239  }
240  }
241 
242  return NS_ERROR_NOT_AVAILABLE;
243 }
244 
245 NS_IMETHODIMP sbPropertyManager::HasProperty(const nsAString &aID,
246  PRBool *_retval)
247 {
248  NS_ENSURE_ARG_POINTER(_retval);
249 
250  if(mPropInfoHashtable.Get(aID, nsnull))
251  *_retval = PR_TRUE;
252  else
253  *_retval = PR_FALSE;
254  return NS_OK;
255 }
256 
257 NS_IMETHODIMP sbPropertyManager::CreateBundle(const char *aURLSpec,
258  nsIStringBundle **_retval)
259 {
260  NS_ENSURE_ARG_POINTER(aURLSpec);
261  NS_ENSURE_ARG_POINTER(_retval);
262  *_retval = nsnull;
263 
264  nsresult rv;
265  nsCOMPtr<nsIStringBundleService> stringBundleService =
266  do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
267  NS_ENSURE_SUCCESS(rv, rv);
268 
269  nsCOMPtr<nsIStringBundle> stringBundle;
270  rv = stringBundleService->CreateBundle(aURLSpec,
271  getter_AddRefs(stringBundle));
272  NS_ENSURE_SUCCESS(rv, rv);
273 
274  *_retval = stringBundle;
275  NS_ADDREF(*_retval);
276 
277  return NS_OK;
278 }
279 
280 NS_IMETHODIMP sbPropertyManager::GetStringFromName(nsIStringBundle *aBundle,
281  const nsAString & aName,
282  nsAString & _retval)
283 {
284  NS_ENSURE_ARG_POINTER(aBundle);
285 
286  nsAutoString value;
287  nsresult rv = aBundle->GetStringFromName(aName.BeginReading(),
288  getter_Copies(value));
289  if (NS_SUCCEEDED(rv)) {
290  _retval.Assign(value);
291  }
292  else {
293  _retval.Truncate();
294 #ifdef DEBUG
295  char* message = PR_smprintf("sbPropertyManager: '%s' not found in bundle",
296  NS_LossyConvertUTF16toASCII(aName).get());
297  NS_WARNING(message);
298  PR_smprintf_free(message);
299 #endif
300  }
301 
302  return NS_OK;
303 }
304 
305 NS_IMETHODIMP sbPropertyManager::GetDependentProperties(const nsAString & aId,
306  sbIPropertyArray** _retval)
307 {
308  NS_ENSURE_ARG_POINTER(_retval);
309  nsresult rv = NS_OK;
310  PRBool success = PR_FALSE;
311 
313 
314  // Lazily init a map like: { propID: [props, that, use, propID], ... }
315  if (mPropDependencyMap.Count() == 0) {
316  nsCOMPtr<sbIMutablePropertyArray> deps;
317 
318  // First create an empty array for every known property
319  for (PRUint32 i=0; i < mPropIDs.Length(); i++) {
320  deps = do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
321  NS_ENSURE_SUCCESS(rv, rv);
322  rv = deps->SetStrict(PR_FALSE);
323  NS_ENSURE_SUCCESS(rv, rv);
324 
325  success = mPropDependencyMap.Put(mPropIDs.ElementAt(i), deps);
326  NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
327  }
328 
329  // Now populate the dependency arrays using the property infos
330  nsCOMPtr<sbIPropertyInfo> propertyInfo;
331  nsCOMPtr<sbIPropertyArray> secondarySort;
332  nsCOMPtr<sbIPropertyArray> currentDeps;
333  for (PRUint32 i=0; i < mPropIDs.Length(); i++) {
334  nsString dependentID = mPropIDs.ElementAt(i);
335  rv = GetPropertyInfo(dependentID, getter_AddRefs(propertyInfo));
336  NS_ENSURE_SUCCESS(rv, rv);
337 
338  secondarySort = nsnull;
339  rv = propertyInfo->GetSecondarySort(getter_AddRefs(secondarySort));
340 
341  if (NS_SUCCEEDED(rv) && secondarySort) {
342  PRUint32 propertyCount;
343  rv = secondarySort->GetLength(&propertyCount);
344  NS_ENSURE_SUCCESS(rv, rv);
345 
346  // Map prop id to all dependent ids
347  for (PRUint32 j=0; j < propertyCount; j++) {
348  nsCOMPtr<sbIProperty> property;
349  rv = secondarySort->GetPropertyAt(j, getter_AddRefs(property));
350  NS_ENSURE_SUCCESS(rv, rv);
351  nsString propertyID;
352  rv = property->GetId(propertyID);
353  NS_ENSURE_SUCCESS(rv, rv);
354 
355  success = mPropDependencyMap.Get(propertyID, getter_AddRefs(currentDeps));
356  NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
357  deps = do_QueryInterface(currentDeps, &rv);
358  NS_ENSURE_SUCCESS(rv, rv);
359 
360  rv = deps->AppendProperty(dependentID, EmptyString());
361  NS_ENSURE_SUCCESS(rv, rv);
362  }
363  }
364  }
365  }
366 
367  // Use the map to return all dependent properties for aID
368  success = mPropDependencyMap.Get(aId, _retval);
369  NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
370 
371  return NS_OK;
372 }
373 
375 {
376  nsresult rv;
377  // If you add or remove properties accessible to remote pages, please update
378  // the documentation in sbILibraryResource.idl as well, thanks!
379 
380  nsCOMPtr<nsIStringBundle> stringBundle;
381  rv = CreateBundle(SB_STRING_BUNDLE_CHROME_URL, getter_AddRefs(stringBundle));
382  NS_ENSURE_SUCCESS(rv, rv);
383 
384  //Ordinal
385  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_ORDINAL),
386  NS_LITERAL_STRING("property.ordinal"),
387  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
388  PR_FALSE, PR_FALSE, NULL);
389  NS_ENSURE_SUCCESS(rv, rv);
390 
391  //Guid (internal use only)
392  rv = RegisterBlob(NS_LITERAL_STRING(SB_PROPERTY_GUID), EmptyString(),
393  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
394  PR_FALSE, PR_FALSE);
395  NS_ENSURE_SUCCESS(rv, rv);
396 
397  //Storage Guid (internal use only)
398  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_STORAGEGUID), EmptyString(),
399  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
400  PR_FALSE, PR_FALSE);
401  NS_ENSURE_SUCCESS(rv, rv);
402 
403  //Outer Guid - the reverse of storage guid (internal use only)
404  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_OUTERGUID), EmptyString(),
405  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
406  PR_FALSE, PR_FALSE);
407  NS_ENSURE_SUCCESS(rv, rv);
408 
409  //List Type
410  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_LISTTYPE), EmptyString(),
411  stringBundle, PR_FALSE, PR_FALSE, 0, PR_FALSE,
412  0, PR_FALSE, PR_TRUE, PR_FALSE, nsnull);
413  NS_ENSURE_SUCCESS(rv, rv);
414 
415  //Is List
416  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ISLIST), EmptyString(),
417  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE,
418  PR_FALSE);
419  NS_ENSURE_SUCCESS(rv, rv);
420 
421  //Is Read Only (internal use)
422  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ISREADONLY), EmptyString(),
423  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
424  NS_ENSURE_SUCCESS(rv, rv);
425 
426  //Is Content Read Only (internal use)
427  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ISCONTENTREADONLY), EmptyString(),
428  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
429  NS_ENSURE_SUCCESS(rv, rv);
430 
431  //Only Custom Media Pages (internal use only)
432  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ONLY_CUSTOM_MEDIAPAGES),
433  EmptyString(), stringBundle, PR_FALSE, PR_FALSE,
434  PR_FALSE, PR_FALSE);
435  NS_ENSURE_SUCCESS(rv, rv);
436 
437  //Date created
438  rv = RegisterDateTime(NS_LITERAL_STRING(SB_PROPERTY_CREATED),
439  NS_LITERAL_STRING("property.date_created"),
441  stringBundle,
442  PR_TRUE,
443  PR_FALSE,
444  PR_FALSE,
445  PR_FALSE);
446  NS_ENSURE_SUCCESS(rv, rv);
447 
448  //Date updated
449  rv = RegisterDateTime(NS_LITERAL_STRING(SB_PROPERTY_UPDATED),
450  NS_LITERAL_STRING("property.date_updated"),
452  stringBundle,
453  PR_TRUE,
454  PR_FALSE,
455  PR_FALSE,
456  PR_FALSE);
457  NS_ENSURE_SUCCESS(rv, rv);
458 
459  //Content URL
460  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_CONTENTURL),
461  NS_LITERAL_STRING("property.content_url"),
462  stringBundle,
463  PR_TRUE,
464  PR_FALSE,
465  PR_FALSE, PR_FALSE);
466  NS_ENSURE_SUCCESS(rv, rv);
467 
468  //Content Type
469  rv = RegisterDummy(new sbDummyContentTypePropertyInfo(),
470  NS_LITERAL_STRING(SB_PROPERTY_CONTENTTYPE),
471  NS_LITERAL_STRING("property.content_type"),
472  stringBundle);
473  NS_ENSURE_SUCCESS(rv, rv);
474 
475  /* we label contentType as used in the identity because the identity
476  * calculation formula depends on the contentType, so if the contentType
477  * changes we need to recompute the identity using the new type's formula */
478  nsCOMPtr<sbIPropertyInfo> contentTypePropInfo;
479  rv = GetPropertyInfo(NS_LITERAL_STRING(SB_PROPERTY_CONTENTTYPE),
480  getter_AddRefs(contentTypePropInfo));
481  NS_ENSURE_SUCCESS(rv, rv);
482 
483  rv = contentTypePropInfo->SetUsedInIdentity(PR_TRUE);
484  NS_ENSURE_SUCCESS(rv, rv);
485 
486  //Content Length (-1, can't determine.)
487  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_CONTENTLENGTH),
488  NS_LITERAL_STRING("property.content_length"),
489  stringBundle,
490  PR_TRUE,
491  PR_FALSE,
492  -1, PR_TRUE,
493  0, PR_FALSE,
494  PR_FALSE,
495  PR_FALSE,
497  NS_ENSURE_SUCCESS(rv, rv);
498 
499  // Hash (empty string if can't determine or cannot generate).
500  rv = RegisterBlob(NS_LITERAL_STRING(SB_PROPERTY_HASH),
501  NS_LITERAL_STRING("property.content_hash"),
502  stringBundle,
503  PR_FALSE,
504  PR_FALSE,
505  PR_FALSE,
507  PR_TRUE, PR_FALSE);
508  NS_ENSURE_SUCCESS(rv, rv);
509 
510  // Metadata Hash Identity (empty string if can't determine or cannot generate).
511  rv = RegisterBlob(NS_LITERAL_STRING(SB_PROPERTY_METADATA_HASH_IDENTITY),
512  NS_LITERAL_STRING("property.metadata_hash_identity"),
513  stringBundle,
514  PR_FALSE,
515  PR_FALSE,
516  PR_FALSE,
518  PR_TRUE, PR_FALSE);
519  NS_ENSURE_SUCCESS(rv, rv);
520 
521  //Track name
522  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
523  NS_LITERAL_STRING("property.track_name"),
524  stringBundle, PR_TRUE, PR_TRUE,
525  PR_TRUE, // this property is used in identity calculations
527  PR_TRUE, PR_TRUE, PR_FALSE);
528  NS_ENSURE_SUCCESS(rv, rv);
529 
530  //Album name
531  nsCOMPtr<sbIMutablePropertyArray> albumSecondarySort =
532  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
533  NS_ENSURE_SUCCESS(rv, rv);
534 
535  rv = albumSecondarySort->SetStrict(PR_FALSE);
536  NS_ENSURE_SUCCESS(rv, rv);
537 
538  //Sorting by album will sort by album->disc no->track no->track name
539  rv = albumSecondarySort->AppendProperty(
540  NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
541  NS_LITERAL_STRING("a"));
542  NS_ENSURE_SUCCESS(rv, rv);
543 
544  rv = albumSecondarySort->AppendProperty(
545  NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
546  NS_LITERAL_STRING("a"));
547  NS_ENSURE_SUCCESS(rv, rv);
548 
549  rv = albumSecondarySort->AppendProperty(
550  NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
551  NS_LITERAL_STRING("a"));
552  NS_ENSURE_SUCCESS(rv, rv);
553 
554  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
555  NS_LITERAL_STRING("property.album_name"),
556  stringBundle, PR_TRUE, PR_TRUE,
557  PR_TRUE, // this property is used in identity calculations
559  PR_TRUE, PR_TRUE, PR_FALSE, albumSecondarySort);
560  NS_ENSURE_SUCCESS(rv, rv);
561 
562  //Artist name
563  nsCOMPtr<sbIMutablePropertyArray> artistSecondarySort =
564  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
565  NS_ENSURE_SUCCESS(rv, rv);
566 
567  rv = artistSecondarySort->SetStrict(PR_FALSE);
568  NS_ENSURE_SUCCESS(rv, rv);
569 
570  //Sorting by artist will sort by artist->album->disc no->track no->track name
571  rv = artistSecondarySort->AppendProperty(
572  NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
573  NS_LITERAL_STRING("a"));
574  NS_ENSURE_SUCCESS(rv, rv);
575 
576  rv = artistSecondarySort->AppendProperty(
577  NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
578  NS_LITERAL_STRING("a"));
579  NS_ENSURE_SUCCESS(rv, rv);
580 
581  rv = artistSecondarySort->AppendProperty(
582  NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
583  NS_LITERAL_STRING("a"));
584  NS_ENSURE_SUCCESS(rv, rv);
585 
586  rv = artistSecondarySort->AppendProperty(
587  NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
588  NS_LITERAL_STRING("a"));
589  NS_ENSURE_SUCCESS(rv, rv);
590 
591  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ARTISTNAME),
592  NS_LITERAL_STRING("property.artist_name"),
593  stringBundle, PR_TRUE, PR_TRUE,
594  PR_TRUE, // this property is used in identity calculations
596  PR_TRUE, PR_TRUE, PR_FALSE, artistSecondarySort);
597  NS_ENSURE_SUCCESS(rv, rv);
598 
599  //Track source
600  rv = RegisterTrackTypeImageLabel(NS_LITERAL_STRING(SB_PROPERTY_TRACKTYPE),
601  NS_LITERAL_STRING("property.track_source"),
602  stringBundle, PR_TRUE, PR_TRUE,
603  PR_TRUE, PR_TRUE, nsString());
604  NS_ENSURE_SUCCESS(rv, rv);
605 
606  //Duration (in usecs)
607  rv = RegisterDuration(NS_LITERAL_STRING(SB_PROPERTY_DURATION),
608  NS_LITERAL_STRING("property.duration"),
609  stringBundle, PR_TRUE, PR_FALSE, PR_TRUE, PR_TRUE);
610  NS_ENSURE_SUCCESS(rv, rv);
611 
612  //Genre
613 
614  nsCOMPtr<sbIMutablePropertyArray> genreSecondarySort =
615  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
616  NS_ENSURE_SUCCESS(rv, rv);
617 
618  rv = genreSecondarySort->SetStrict(PR_FALSE);
619  NS_ENSURE_SUCCESS(rv, rv);
620 
621  //Sorting by genre will sort by genre->artist->album->disc no->track no->track name
622  rv = genreSecondarySort->AppendProperty(
623  NS_LITERAL_STRING(SB_PROPERTY_ARTISTNAME),
624  NS_LITERAL_STRING("a"));
625  NS_ENSURE_SUCCESS(rv, rv);
626 
627  rv = genreSecondarySort->AppendProperty(
628  NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
629  NS_LITERAL_STRING("a"));
630  NS_ENSURE_SUCCESS(rv, rv);
631 
632  rv = genreSecondarySort->AppendProperty(
633  NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
634  NS_LITERAL_STRING("a"));
635  NS_ENSURE_SUCCESS(rv, rv);
636 
637  rv = genreSecondarySort->AppendProperty(
638  NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
639  NS_LITERAL_STRING("a"));
640  NS_ENSURE_SUCCESS(rv, rv);
641 
642  rv = genreSecondarySort->AppendProperty(
643  NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
644  NS_LITERAL_STRING("a"));
645  NS_ENSURE_SUCCESS(rv, rv);
646 
647  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_GENRE),
648  NS_LITERAL_STRING("property.genre"),
649  stringBundle, PR_TRUE, PR_TRUE,
650  PR_TRUE, // this property is used in identity calculations
651  0, PR_FALSE,
652  PR_TRUE, PR_TRUE, PR_FALSE, genreSecondarySort);
653  NS_ENSURE_SUCCESS(rv, rv);
654 
655  //Year
656 
657  nsCOMPtr<sbIMutablePropertyArray> yearSecondarySort =
658  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
659  NS_ENSURE_SUCCESS(rv, rv);
660 
661  rv = yearSecondarySort->SetStrict(PR_FALSE);
662  NS_ENSURE_SUCCESS(rv, rv);
663 
664  //Sorting by year will sort by year->artist->album->disc no->track no->track name
665 
666  rv = yearSecondarySort->AppendProperty(
667  NS_LITERAL_STRING(SB_PROPERTY_ARTISTNAME),
668  NS_LITERAL_STRING("a"));
669  NS_ENSURE_SUCCESS(rv, rv);
670 
671  rv = yearSecondarySort->AppendProperty(
672  NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
673  NS_LITERAL_STRING("a"));
674  NS_ENSURE_SUCCESS(rv, rv);
675 
676  rv = yearSecondarySort->AppendProperty(
677  NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
678  NS_LITERAL_STRING("a"));
679  NS_ENSURE_SUCCESS(rv, rv);
680 
681  rv = yearSecondarySort->AppendProperty(
682  NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
683  NS_LITERAL_STRING("a"));
684  NS_ENSURE_SUCCESS(rv, rv);
685 
686  rv = yearSecondarySort->AppendProperty(
687  NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
688  NS_LITERAL_STRING("a"));
689  NS_ENSURE_SUCCESS(rv, rv);
690 
691  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_YEAR),
692  NS_LITERAL_STRING("property.year"),
693  stringBundle, PR_TRUE, PR_TRUE, 0, PR_FALSE, 9999, PR_TRUE,
694  PR_TRUE, PR_TRUE, NULL, yearSecondarySort);
695  NS_ENSURE_SUCCESS(rv, rv);
696 
697  //Track number
698  nsCOMPtr<sbIMutablePropertyArray> trackSecondarySort =
699  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
700  NS_ENSURE_SUCCESS(rv, rv);
701 
702  rv = trackSecondarySort->SetStrict(PR_FALSE);
703  NS_ENSURE_SUCCESS(rv, rv);
704 
705  //Sorting by track number will sort by track no->artist->album->disc no
706  rv = trackSecondarySort->AppendProperty(
707  NS_LITERAL_STRING(SB_PROPERTY_ARTISTNAME),
708  NS_LITERAL_STRING("a"));
709  NS_ENSURE_SUCCESS(rv, rv);
710 
711  rv = trackSecondarySort->AppendProperty(
712  NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
713  NS_LITERAL_STRING("a"));
714  NS_ENSURE_SUCCESS(rv, rv);
715 
716  rv = trackSecondarySort->AppendProperty(
717  NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
718  NS_LITERAL_STRING("a"));
719  NS_ENSURE_SUCCESS(rv, rv);
720 
721  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
722  NS_LITERAL_STRING("property.track_no"),
723  stringBundle, PR_TRUE, PR_TRUE, 1, PR_TRUE, 9999, PR_TRUE,
724  PR_TRUE, PR_TRUE, NULL, trackSecondarySort);
725  NS_ENSURE_SUCCESS(rv, rv);
726 
727  //Disc Number
728  nsCOMPtr<sbIMutablePropertyArray> discSecondarySort =
729  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
730  NS_ENSURE_SUCCESS(rv, rv);
731 
732  rv = discSecondarySort->SetStrict(PR_FALSE);
733  NS_ENSURE_SUCCESS(rv, rv);
734 
735  // Sorting by disc number will sort by disc no->artist->album->track no->track name
736  rv = discSecondarySort->AppendProperty(
737  NS_LITERAL_STRING(SB_PROPERTY_ARTISTNAME),
738  NS_LITERAL_STRING("a"));
739  NS_ENSURE_SUCCESS(rv, rv);
740 
741  rv = discSecondarySort->AppendProperty(
742  NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
743  NS_LITERAL_STRING("a"));
744  NS_ENSURE_SUCCESS(rv, rv);
745 
746  rv = discSecondarySort->AppendProperty(
747  NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
748  NS_LITERAL_STRING("a"));
749  NS_ENSURE_SUCCESS(rv, rv);
750 
751  rv = discSecondarySort->AppendProperty(
752  NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
753  NS_LITERAL_STRING("a"));
754  NS_ENSURE_SUCCESS(rv, rv);
755 
756  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
757  NS_LITERAL_STRING("property.disc_no"),
758  stringBundle, PR_TRUE, PR_TRUE, 1, PR_TRUE, 999, PR_TRUE,
759  PR_TRUE, PR_TRUE, NULL, discSecondarySort);
760  NS_ENSURE_SUCCESS(rv, rv);
761 
762  //Total Discs
763  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_TOTALDISCS),
764  NS_LITERAL_STRING("property.total_discs"),
765  stringBundle, PR_FALSE, PR_TRUE, 1, PR_TRUE, 999, PR_TRUE,
766  PR_TRUE, PR_TRUE, NULL);
767  NS_ENSURE_SUCCESS(rv, rv);
768 
769  //Total tracks
770  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_TOTALTRACKS),
771  NS_LITERAL_STRING("property.total_tracks"),
772  stringBundle, PR_FALSE, PR_TRUE, 1, PR_TRUE, 9999, PR_TRUE,
773  PR_TRUE, PR_TRUE, NULL);
774  NS_ENSURE_SUCCESS(rv, rv);
775 
776  //Is part of a compilation
777  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ISPARTOFCOMPILATION),
778  NS_LITERAL_STRING("property.is_part_of_compilation"),
779  stringBundle, PR_FALSE, PR_TRUE,
780  PR_TRUE, PR_TRUE);
781  NS_ENSURE_SUCCESS(rv, rv);
782 
783  //Producer(s)
784  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_PRODUCERNAME),
785  NS_LITERAL_STRING("property.producer"),
786  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
787  PR_TRUE, PR_TRUE, PR_FALSE);
788  NS_ENSURE_SUCCESS(rv, rv);
789 
790  //Composer(s)
791  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_COMPOSERNAME),
792  NS_LITERAL_STRING("property.composer"),
793  stringBundle, PR_TRUE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
794  PR_TRUE, PR_TRUE, PR_FALSE);
795  NS_ENSURE_SUCCESS(rv, rv);
796 
797  //Conductor(s)
798  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_CONDUCTORNAME),
799  NS_LITERAL_STRING("property.conductor"),
800  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
801  PR_TRUE, PR_TRUE, PR_FALSE);
802  NS_ENSURE_SUCCESS(rv, rv);
803 
804  //Lyricist(s)
805  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_LYRICISTNAME),
806  NS_LITERAL_STRING("property.lyricist"),
807  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
808  PR_TRUE, PR_TRUE, PR_FALSE);
809  NS_ENSURE_SUCCESS(rv, rv);
810 
811  //Lyrics
812  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_LYRICS),
813  NS_LITERAL_STRING("property.lyrics"),
814  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
815  PR_TRUE, PR_TRUE, PR_FALSE);
816  NS_ENSURE_SUCCESS(rv, rv);
817 
818  //Record Label
819  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_RECORDLABELNAME),
820  NS_LITERAL_STRING("property.record_label_name"),
821  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
822  PR_TRUE, PR_TRUE, PR_FALSE);
823  NS_ENSURE_SUCCESS(rv, rv);
824 
825  //Primary image url, see bug #11618 for an explanation as to why this
826  //property is not user viewable.
827  rv = RegisterImage(NS_LITERAL_STRING(SB_PROPERTY_PRIMARYIMAGEURL),
828  NS_LITERAL_STRING("property.primary_image_url"),
829  stringBundle, PR_FALSE, PR_TRUE, PR_TRUE, PR_TRUE);
830  NS_ENSURE_SUCCESS(rv, rv);
831 
832  //Last played time
833  rv = RegisterDateTime(NS_LITERAL_STRING(SB_PROPERTY_LASTPLAYTIME),
834  NS_LITERAL_STRING("property.last_play_time"),
836  stringBundle, PR_TRUE, PR_FALSE, PR_TRUE, PR_FALSE);
837  NS_ENSURE_SUCCESS(rv, rv);
838 
839  //Number of times played
840  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_PLAYCOUNT),
841  NS_LITERAL_STRING("property.play_count"),
842  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
843  PR_TRUE, PR_FALSE, NULL);
844  NS_ENSURE_SUCCESS(rv, rv);
845 
846  //Playback position on last stop
847  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_LASTPLAYPOSITION),
848  nsString(),
849  stringBundle, PR_FALSE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
850  PR_FALSE, PR_FALSE, NULL);
851  NS_ENSURE_SUCCESS(rv, rv);
852 
853  //Last skipped time
854  rv = RegisterDateTime(NS_LITERAL_STRING(SB_PROPERTY_LASTSKIPTIME),
855  NS_LITERAL_STRING("property.last_skip_time"),
857  stringBundle, PR_TRUE, PR_FALSE, PR_TRUE, PR_FALSE);
858  NS_ENSURE_SUCCESS(rv, rv);
859 
860  //Number of times song was skipped
861  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_SKIPCOUNT),
862  NS_LITERAL_STRING("property.skip_count"),
863  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
864  PR_TRUE, PR_FALSE, NULL);
865  NS_ENSURE_SUCCESS(rv, rv);
866 
867  // Denotes the media item on the device is "new" wasn't copied from the main
868  // library
869  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ORIGIN_IS_IN_MAIN_LIBRARY),
870  EmptyString(),
871  stringBundle,
872  PR_FALSE, // User editable
873  PR_FALSE, // Remote readable
874  PR_FALSE, // Remote writable
875  PR_FALSE); // shouldSupress
876  NS_ENSURE_SUCCESS(rv, rv);
877 
878  //Bitrate
879  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_BITRATE),
880  NS_LITERAL_STRING("property.bitrate"),
881  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
882  PR_TRUE, PR_TRUE, new sbBitratePropertyUnitConverter());
883  NS_ENSURE_SUCCESS(rv, rv);
884 
885  //Channels
886  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_CHANNELS),
887  NS_LITERAL_STRING("property.channels"),
888  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
889  PR_TRUE, PR_TRUE, NULL);
890  NS_ENSURE_SUCCESS(rv, rv);
891 
892  //Samplerate
893  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_SAMPLERATE),
894  NS_LITERAL_STRING("property.samplerate"),
895  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 0, PR_FALSE,
896  PR_TRUE, PR_TRUE, new sbFrequencyPropertyUnitConverter());
897  NS_ENSURE_SUCCESS(rv, rv);
898 
899  //BPM
900  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_BPM),
901  NS_LITERAL_STRING("property.bpm"),
902  stringBundle, PR_TRUE, PR_FALSE, 0, PR_FALSE, 999, PR_TRUE,
903  PR_TRUE, PR_TRUE, NULL);
904  NS_ENSURE_SUCCESS(rv, rv);
905 
906  //Key
907  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_KEY),
908  NS_LITERAL_STRING("property.key"),
909  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
910  PR_TRUE, PR_TRUE, PR_FALSE);
911  NS_ENSURE_SUCCESS(rv, rv);
912 
913  //Language
914  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_LANGUAGE),
915  NS_LITERAL_STRING("property.language"),
916  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
917  PR_TRUE, PR_TRUE, PR_FALSE);
918  NS_ENSURE_SUCCESS(rv, rv);
919 
920  //Comment
921  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_COMMENT),
922  NS_LITERAL_STRING("property.comment"),
923  stringBundle, PR_TRUE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
924  PR_TRUE, PR_TRUE, PR_FALSE);
925  NS_ENSURE_SUCCESS(rv, rv);
926 
927  //Copyright
928  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_COPYRIGHT),
929  NS_LITERAL_STRING("property.copyright"),
930  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
931  PR_TRUE, PR_TRUE, PR_FALSE);
932  NS_ENSURE_SUCCESS(rv, rv);
933 
934  //Copyright URL
935  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_COPYRIGHTURL),
936  NS_LITERAL_STRING("property.copyright_url"),
937  stringBundle, PR_FALSE, PR_FALSE, PR_TRUE, PR_FALSE);
938  NS_ENSURE_SUCCESS(rv, rv);
939 
940  //Subtitle
941  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_SUBTITLE),
942  NS_LITERAL_STRING("property.subtitle"),
943  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
944  PR_TRUE, PR_TRUE, PR_FALSE);
945  NS_ENSURE_SUCCESS(rv, rv);
946 
947  //Metadata UUID
948  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_METADATAUUID),
949  NS_LITERAL_STRING("property.metadata_uuid"),
950  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
951  PR_TRUE, PR_TRUE);
952  NS_ENSURE_SUCCESS(rv, rv);
953 
954  //SoftwareVendor
955  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_SOFTWAREVENDOR),
956  NS_LITERAL_STRING("property.vendor"),
957  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
958  PR_TRUE, PR_TRUE, PR_FALSE);
959  NS_ENSURE_SUCCESS(rv, rv);
960 
961  //Origin URL
962  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_ORIGINURL),
963  NS_LITERAL_STRING("property.origin_url"),
964  stringBundle, PR_FALSE, PR_FALSE, PR_TRUE, PR_FALSE);
965  NS_ENSURE_SUCCESS(rv, rv);
966 
967  //Origin Library Guid (internal use only)
968  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ORIGINLIBRARYGUID), EmptyString(),
969  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
970  PR_FALSE, PR_FALSE);
971  NS_ENSURE_SUCCESS(rv, rv);
972 
973  //Origin Item Guid (internal use only)
974  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ORIGINITEMGUID), EmptyString(),
975  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
976  PR_FALSE, PR_FALSE);
977  NS_ENSURE_SUCCESS(rv, rv);
978 
979  //Import Type (internal use only)
980  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_IMPORTTYPE), EmptyString(),
981  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
982  PR_FALSE, PR_FALSE);
983  NS_ENSURE_SUCCESS(rv, rv);
984 
985  //Download destination
986  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_DESTINATION),
987  NS_LITERAL_STRING("property.destination"),
988  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
989  NS_ENSURE_SUCCESS(rv, rv);
990 
991  //Download Status Target (internal use only)
992  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DOWNLOAD_STATUS_TARGET),
993  EmptyString(),
994  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE,
995  0, PR_TRUE, PR_TRUE, PR_FALSE);
996  NS_ENSURE_SUCCESS(rv, rv);
997 
998  //Hidden
999  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_HIDDEN),
1000  NS_LITERAL_STRING("property.hidden"),
1001  stringBundle, PR_FALSE, PR_FALSE,
1002  PR_TRUE, PR_TRUE);
1003  NS_ENSURE_SUCCESS(rv, rv);
1004 
1005  //Display columns
1006  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_COLUMNSPEC),
1007  NS_LITERAL_STRING("property.column_spec"),
1008  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1009  PR_TRUE, PR_TRUE);
1010  NS_ENSURE_SUCCESS(rv, rv);
1011 
1012  //Display column widths
1013  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DEFAULTCOLUMNSPEC),
1014  NS_LITERAL_STRING("property.default_column_spec"),
1015  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1016  PR_TRUE, PR_TRUE);
1017  NS_ENSURE_SUCCESS(rv, rv);
1018 
1019  //Origin page
1020  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ORIGINPAGE),
1021  NS_LITERAL_STRING("property.origin_page"),
1022  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1023  PR_TRUE, PR_FALSE, PR_FALSE);
1024  NS_ENSURE_SUCCESS(rv, rv);
1025 
1026  //Artist detail uri
1027  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_ARTISTDETAILURL),
1028  NS_LITERAL_STRING("property.artist_detail_url"),
1029  stringBundle, PR_FALSE, PR_TRUE, PR_TRUE, PR_TRUE);
1030  NS_ENSURE_SUCCESS(rv, rv);
1031 
1032  //album detail uri
1033  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_ALBUMDETAILURL),
1034  NS_LITERAL_STRING("property.album_detail_url"),
1035  stringBundle, PR_FALSE, PR_TRUE, PR_TRUE, PR_TRUE);
1036  NS_ENSURE_SUCCESS(rv, rv);
1037 
1038  // Origin page title
1039  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ORIGINPAGETITLE),
1040  NS_LITERAL_STRING("property.origin_pagetitle"),
1041  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1042  PR_TRUE, PR_FALSE, PR_FALSE);
1043  NS_ENSURE_SUCCESS(rv, rv);
1044 
1045  // Custom type (used for css and metrics reporting)
1046  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_CUSTOMTYPE), EmptyString(),
1047  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1048  PR_TRUE, PR_FALSE, PR_FALSE);
1049  NS_ENSURE_SUCCESS(rv, rv);
1050 
1051  // Is sortable (for lists)
1052  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ISSORTABLE), EmptyString(),
1053  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
1054  NS_ENSURE_SUCCESS(rv, rv);
1055 
1056  // Download button
1057  nsRefPtr<sbDownloadButtonPropertyBuilder> dbBuilder =
1059  NS_ENSURE_TRUE(dbBuilder, NS_ERROR_OUT_OF_MEMORY);
1060 
1061  rv = dbBuilder->Init();
1062  NS_ENSURE_SUCCESS(rv, rv);
1063 
1064  dbBuilder->SetUserViewable(PR_FALSE);
1065 
1066  rv = dbBuilder->SetRemoteReadable(PR_TRUE);
1067  NS_ENSURE_SUCCESS(rv, rv);
1068 
1069  rv = dbBuilder->SetRemoteWritable(PR_TRUE);
1070  NS_ENSURE_SUCCESS(rv, rv);
1071 
1072  nsCOMPtr<sbIPropertyInfo> propertyInfo;
1073  rv = dbBuilder->Get(getter_AddRefs(propertyInfo));
1074  NS_ENSURE_SUCCESS(rv, rv);
1075 
1076  rv = AddPropertyInfo(propertyInfo);
1077  NS_ENSURE_SUCCESS(rv, rv);
1078 
1079  // Download details
1080  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DOWNLOAD_DETAILS),
1081  NS_LITERAL_STRING("property.download_details"),
1082  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1083  PR_TRUE, PR_TRUE, PR_FALSE);
1084  NS_ENSURE_SUCCESS(rv, rv);
1085 
1086  // Rating
1087  nsRefPtr<sbRatingPropertyBuilder> rBuilder = new sbRatingPropertyBuilder();
1088  NS_ENSURE_TRUE(rBuilder, NS_ERROR_OUT_OF_MEMORY);
1089 
1090  rv = rBuilder->Init();
1091  NS_ENSURE_SUCCESS(rv, rv);
1092 
1093  rBuilder->SetUserViewable(PR_TRUE);
1094 
1095  rv = rBuilder->SetPropertyID(NS_LITERAL_STRING(SB_PROPERTY_RATING));
1096  NS_ENSURE_SUCCESS(rv, rv);
1097 
1098  rv = rBuilder->SetDisplayNameKey(NS_LITERAL_STRING("property.rating"));
1099  NS_ENSURE_SUCCESS(rv, rv);
1100 
1101  rv = rBuilder->SetRemoteReadable(PR_TRUE);
1102  NS_ENSURE_SUCCESS(rv, rv);
1103 
1104  rv = rBuilder->SetRemoteWritable(PR_TRUE);
1105  NS_ENSURE_SUCCESS(rv, rv);
1106 
1107  rv = rBuilder->Get(getter_AddRefs(propertyInfo));
1108  NS_ENSURE_SUCCESS(rv, rv);
1109 
1110  rv = AddPropertyInfo(propertyInfo);
1111  NS_ENSURE_SUCCESS(rv, rv);
1112 
1113  // Status Property
1114  nsRefPtr<sbStatusPropertyBuilder> statusBuilder =
1116  NS_ENSURE_TRUE(statusBuilder, NS_ERROR_OUT_OF_MEMORY);
1117 
1118  rv = statusBuilder->Init();
1119  NS_ENSURE_SUCCESS(rv, rv);
1120 
1121  statusBuilder->SetUserViewable(PR_FALSE);
1122 
1123  rv = statusBuilder->SetPropertyID(NS_LITERAL_STRING(SB_PROPERTY_CDRIP_STATUS));
1124  NS_ENSURE_SUCCESS(rv, rv);
1125 
1126  rv = statusBuilder->SetDisplayNameKey(NS_LITERAL_STRING("property.cdrip_status"));
1127  NS_ENSURE_SUCCESS(rv, rv);
1128 
1129  rv = statusBuilder->SetLabelKey(NS_LITERAL_STRING("property.cdrip_status"));
1130  NS_ENSURE_SUCCESS(rv, rv);
1131 
1132  rv = statusBuilder->SetCompletedLabelKey(NS_LITERAL_STRING("property.cdrip_completed"));
1133  NS_ENSURE_SUCCESS(rv, rv);
1134 
1135  rv = statusBuilder->SetFailedLabelKey(NS_LITERAL_STRING("property.cdrip_failed"));
1136  NS_ENSURE_SUCCESS(rv, rv);
1137 
1138  rv = statusBuilder->SetRemoteReadable(PR_TRUE);
1139  NS_ENSURE_SUCCESS(rv, rv);
1140 
1141  rv = statusBuilder->SetRemoteWritable(PR_TRUE);
1142  NS_ENSURE_SUCCESS(rv, rv);
1143 
1144  rv = statusBuilder->Get(getter_AddRefs(propertyInfo));
1145  NS_ENSURE_SUCCESS(rv, rv);
1146 
1147  rv = AddPropertyInfo(propertyInfo);
1148  NS_ENSURE_SUCCESS(rv, rv);
1149 
1150  // CD disc hash.
1151  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_CDDISCHASH),
1152  EmptyString(),
1153  stringBundle,
1154  PR_FALSE,
1155  PR_FALSE,
1156  PR_FALSE,
1157  0,
1158  PR_FALSE,
1159  PR_FALSE,
1160  PR_FALSE);
1161  NS_ENSURE_SUCCESS(rv, rv);
1162 
1163  // Go To Source
1164  nsRefPtr<sbOriginPageImagePropertyBuilder> iBuilder = new sbOriginPageImagePropertyBuilder();
1165  NS_ENSURE_TRUE(iBuilder, NS_ERROR_OUT_OF_MEMORY);
1166 
1167  rv = iBuilder->Init();
1168  NS_ENSURE_SUCCESS(rv, rv);
1169 
1170  iBuilder->SetUserViewable(PR_FALSE);
1171 
1172  rv = iBuilder->SetPropertyID(NS_LITERAL_STRING(SB_PROPERTY_ORIGINPAGEIMAGE));
1173  NS_ENSURE_SUCCESS(rv, rv);
1174 
1175  rv = iBuilder->SetDisplayNameKey(NS_LITERAL_STRING("property.origin_page_image"));
1176  NS_ENSURE_SUCCESS(rv, rv);
1177 
1178  rv = iBuilder->SetRemoteReadable(PR_TRUE);
1179  NS_ENSURE_SUCCESS(rv, rv);
1180 
1181  rv = iBuilder->SetRemoteWritable(PR_TRUE);
1182  NS_ENSURE_SUCCESS(rv, rv);
1183 
1184  rv = iBuilder->SetUserEditable(PR_FALSE);
1185  NS_ENSURE_SUCCESS(rv, rv);
1186 
1187  rv = iBuilder->Get(getter_AddRefs(propertyInfo));
1188  NS_ENSURE_SUCCESS(rv, rv);
1189 
1190  rv = AddPropertyInfo(propertyInfo);
1191  NS_ENSURE_SUCCESS(rv, rv);
1192 
1193  // Artist detail image link
1194  rv = RegisterImageLink(NS_LITERAL_STRING(SB_PROPERTY_ARTISTDETAIL),
1195  NS_LITERAL_STRING("property.artist_detail_image"),
1196  stringBundle,
1197  PR_FALSE, PR_TRUE, PR_TRUE, PR_TRUE,
1198  NS_LITERAL_STRING(SB_PROPERTY_ARTISTDETAILURL));
1199 
1200  // Album detail image link
1201  rv = RegisterImageLink(NS_LITERAL_STRING(SB_PROPERTY_ALBUMDETAIL),
1202  NS_LITERAL_STRING("property.album_detail_image"),
1203  stringBundle,
1204  PR_FALSE, PR_TRUE, PR_TRUE, PR_TRUE,
1205  NS_LITERAL_STRING(SB_PROPERTY_ALBUMDETAILURL));
1206 
1207  //Remote API scope URL
1208  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_RAPISCOPEURL),
1209  NS_LITERAL_STRING("property.rapi_scope_url"),
1210  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
1211  NS_ENSURE_SUCCESS(rv, rv);
1212 
1213  // Remote API SiteID
1214  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_RAPISITEID),
1215  NS_LITERAL_STRING("property.rapi_site_id"),
1216  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1217  PR_TRUE, PR_FALSE);
1218  NS_ENSURE_SUCCESS(rv, rv);
1219 
1220  // MediaListName
1221  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_MEDIALISTNAME),
1222  NS_LITERAL_STRING("property.media_list_name"),
1223  stringBundle, PR_FALSE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
1224  PR_TRUE, PR_TRUE, PR_FALSE);
1225  NS_ENSURE_SUCCESS(rv, rv);
1226 
1227  // Disable downloading
1228  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_DISABLE_DOWNLOAD),
1229  EmptyString(),
1230  stringBundle, PR_FALSE, PR_FALSE,
1231  PR_TRUE, PR_TRUE);
1232  NS_ENSURE_SUCCESS(rv, rv);
1233 
1234  // Enable auto-download
1235  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ENABLE_AUTO_DOWNLOAD),
1236  EmptyString(),
1237  stringBundle, PR_FALSE, PR_FALSE,
1238  PR_TRUE, PR_TRUE);
1239  NS_ENSURE_SUCCESS(rv, rv);
1240 
1241  // Exclude from playback history?
1242  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_EXCLUDE_FROM_HISTORY),
1243  EmptyString(), stringBundle, PR_FALSE, PR_FALSE,
1244  PR_TRUE, PR_TRUE);
1245  NS_ENSURE_SUCCESS(rv, rv);
1246 
1247  // Transfer policy
1248  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_TRANSFER_POLICY),
1249  EmptyString(),
1250  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1251  PR_FALSE, PR_FALSE);
1252  NS_ENSURE_SUCCESS(rv, rv);
1253 
1254  // Default MediaPage URL
1255  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_DEFAULT_MEDIAPAGE_URL),
1256  NS_LITERAL_STRING("property.default_mediapage_url"),
1257  stringBundle,
1258  PR_FALSE,
1259  PR_FALSE,
1260  PR_FALSE, PR_FALSE);
1261  NS_ENSURE_SUCCESS(rv, rv);
1262 
1263  // Availability
1264  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_AVAILABILITY),
1265  NS_LITERAL_STRING("property.availability"),
1266  stringBundle,
1267  PR_FALSE, PR_FALSE,
1268  0, PR_FALSE, 0, PR_FALSE,
1269  PR_FALSE, PR_FALSE, NULL);
1270 
1271  // Album/Artist Name
1272 
1273  nsCOMPtr<sbIMutablePropertyArray> albumArtistSecondarySort =
1274  do_CreateInstance(SB_MUTABLEPROPERTYARRAY_CONTRACTID, &rv);
1275  NS_ENSURE_SUCCESS(rv, rv);
1276 
1277  rv = albumArtistSecondarySort->SetStrict(PR_FALSE);
1278  NS_ENSURE_SUCCESS(rv, rv);
1279 
1280  //Sorting by album/artist will sort by album/artist->album->disc no->track no->track name
1281  rv = albumArtistSecondarySort->AppendProperty(
1282  NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
1283  NS_LITERAL_STRING("a"));
1284  NS_ENSURE_SUCCESS(rv, rv);
1285 
1286  rv = albumArtistSecondarySort->AppendProperty(
1287  NS_LITERAL_STRING(SB_PROPERTY_DISCNUMBER),
1288  NS_LITERAL_STRING("a"));
1289  NS_ENSURE_SUCCESS(rv, rv);
1290 
1291  rv = albumArtistSecondarySort->AppendProperty(
1292  NS_LITERAL_STRING(SB_PROPERTY_TRACKNUMBER),
1293  NS_LITERAL_STRING("a"));
1294  NS_ENSURE_SUCCESS(rv, rv);
1295 
1296  rv = albumArtistSecondarySort->AppendProperty(
1297  NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME),
1298  NS_LITERAL_STRING("a"));
1299  NS_ENSURE_SUCCESS(rv, rv);
1300 
1301  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ALBUMARTISTNAME),
1302  NS_LITERAL_STRING("property.albumartistname"),
1303  stringBundle, PR_TRUE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
1304  PR_TRUE, PR_TRUE, PR_FALSE, albumArtistSecondarySort);
1305  NS_ENSURE_SUCCESS(rv, rv);
1306 
1307  //Peristent ID of the object on the device (internal use only)
1308  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DEVICE_PERSISTENT_ID),
1309  EmptyString(),
1310  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1311  PR_FALSE, PR_FALSE);
1312  NS_ENSURE_SUCCESS(rv, rv);
1313 
1314  //Playcount when last sync'd (internal use only)
1315  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_LAST_SYNC_PLAYCOUNT),
1316  EmptyString(),
1317  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1318  PR_FALSE, PR_FALSE);
1319  NS_ENSURE_SUCCESS(rv, rv);
1320 
1321  //Skip count when last sync'd (internal use only)
1322  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_LAST_SYNC_SKIPCOUNT),
1323  EmptyString(),
1324  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1325  PR_FALSE, PR_FALSE);
1326  NS_ENSURE_SUCCESS(rv, rv);
1327 
1328  // Last sync time (internal use only)
1329  rv = RegisterDateTime(NS_LITERAL_STRING(SB_PROPERTY_LAST_SYNC_TIME),
1330  EmptyString(),
1332  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
1333  NS_ENSURE_SUCCESS(rv, rv);
1334 
1335  //Smart medialist state (internal use)
1336  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_SMARTMEDIALIST_STATE),
1337  EmptyString(),
1338  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE, PR_FALSE,
1339  PR_FALSE);
1340  NS_ENSURE_SUCCESS(rv, rv);
1341 
1342  //Playlist dummy property for smart medialists internal use
1343  rv = RegisterDummy(new sbDummyPlaylistPropertyInfo(),
1344  NS_LITERAL_STRING(SB_DUMMYPROPERTY_SMARTMEDIALIST_PLAYLIST),
1345  NS_LITERAL_STRING("property.dummy.playlist"),
1346  stringBundle);
1347  NS_ENSURE_SUCCESS(rv, rv);
1348 
1349  //Created first-run smart playlists (internal use)
1350  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_CREATED_FIRSTRUN_SMARTPLAYLISTS), EmptyString(),
1351  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
1352  NS_ENSURE_SUCCESS(rv, rv);
1353 
1354  //Download media list Guid (internal use only)
1355  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DOWNLOAD_MEDIALIST_GUID),
1356  EmptyString(),
1357  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1358  PR_FALSE, PR_FALSE);
1359  NS_ENSURE_SUCCESS(rv, rv);
1360 
1361  // Play queue media list Guid (internal use only)
1362  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_PLAYQUEUE_MEDIALIST_GUID),
1363  EmptyString(),
1364  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1365  PR_FALSE, PR_FALSE);
1366  NS_ENSURE_SUCCESS(rv, rv);
1367 
1368  //Denote that the library is a device library (internal use)
1369  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DEVICE_LIBRARY_GUID),
1370  EmptyString(),
1371  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1372  PR_TRUE, PR_TRUE);
1373  NS_ENSURE_SUCCESS(rv, rv);
1374 
1375  // iTunes Guid (for import/export from/to iTunes)
1376  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_ITUNES_GUID),
1377  EmptyString(),
1378  stringBundle, PR_FALSE, PR_FALSE, PR_FALSE, 0, PR_FALSE,
1379  PR_TRUE, PR_TRUE);
1380  NS_ENSURE_SUCCESS(rv, rv);
1381 
1382  // Should Rip (for cd devices)
1383  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_SHOULDRIP),
1384  NS_LITERAL_STRING("property.shouldrip"),
1385  stringBundle,
1386  PR_FALSE, PR_TRUE, PR_FALSE, PR_FALSE, PR_FALSE);
1387  NS_ENSURE_SUCCESS(rv, rv);
1388 
1389  //Whether a media file is DRM protected
1390  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_ISDRMPROTECTED),
1391  EmptyString(), stringBundle, PR_FALSE, PR_FALSE,
1392  PR_FALSE, PR_FALSE);
1393  NS_ENSURE_SUCCESS(rv, rv);
1394 
1395  // If true, don't write metadata to contents (use with libraries and media
1396  // lists)
1397  rv = RegisterBoolean(NS_LITERAL_STRING(SB_PROPERTY_DONT_WRITE_METADATA),
1398  EmptyString(),
1399  stringBundle,
1400  PR_FALSE,
1401  PR_FALSE,
1402  PR_FALSE,
1403  PR_FALSE);
1404  NS_ENSURE_SUCCESS(rv, rv);
1405 
1406  // video properties
1407  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_KEYWORDS),
1408  NS_LITERAL_STRING("property.keywords"),
1409  stringBundle, PR_TRUE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
1410  PR_TRUE, PR_TRUE, PR_FALSE);
1411  NS_ENSURE_SUCCESS(rv, rv);
1412 
1413  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_DESCRIPTION),
1414  NS_LITERAL_STRING("property.description"),
1415  stringBundle, PR_TRUE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
1416  PR_TRUE, PR_TRUE, PR_FALSE);
1417  NS_ENSURE_SUCCESS(rv, rv);
1418 
1419  rv = RegisterText(NS_LITERAL_STRING(SB_PROPERTY_SHOWNAME),
1420  NS_LITERAL_STRING("property.showName"),
1421  stringBundle, PR_TRUE, PR_TRUE, PR_FALSE, 0, PR_FALSE,
1422  PR_TRUE, PR_TRUE, PR_FALSE);
1423  NS_ENSURE_SUCCESS(rv, rv);
1424 
1425  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_EPISODENUMBER),
1426  NS_LITERAL_STRING("property.episodeNumber"),
1427  stringBundle, PR_TRUE, PR_TRUE, 1, PR_TRUE, 0,
1428  PR_FALSE, PR_TRUE, PR_TRUE, nsnull);
1429  NS_ENSURE_SUCCESS(rv, rv);
1430 
1431  rv = RegisterNumber(NS_LITERAL_STRING(SB_PROPERTY_SEASONNUMBER),
1432  NS_LITERAL_STRING("property.seasonNumber"),
1433  stringBundle, PR_TRUE, PR_TRUE, 1, PR_TRUE, 0,
1434  PR_FALSE, PR_TRUE, PR_TRUE, nsnull);
1435  NS_ENSURE_SUCCESS(rv, rv);
1436 
1437  // Playlist URL
1438  rv = RegisterURI(NS_LITERAL_STRING(SB_PROPERTY_PLAYLISTURL),
1439  NS_LITERAL_STRING("property.playlist_url"),
1440  stringBundle,
1441  PR_FALSE,
1442  PR_FALSE,
1443  PR_FALSE, PR_FALSE);
1444  NS_ENSURE_SUCCESS(rv, rv);
1445 
1446  // Attempted to fetch artwork remotely (internal use)
1447  rv = RegisterBoolean
1448  (NS_LITERAL_STRING(SB_PROPERTY_ATTEMPTED_REMOTE_ART_FETCH),
1449  EmptyString(),
1450  stringBundle,
1451  PR_FALSE,
1452  PR_FALSE,
1453  PR_FALSE,
1454  PR_FALSE);
1455  NS_ENSURE_SUCCESS(rv, rv);
1456 
1457  return NS_OK;
1458 }
1459 
1460 nsresult
1461 sbPropertyManager::RegisterFilterListPickerProperties()
1462 {
1463  nsresult rv;
1464 
1465  nsCOMPtr<nsICategoryManager> cm =
1466  do_GetService("@mozilla.org/categorymanager;1", &rv);
1467  NS_ENSURE_SUCCESS(rv, rv);
1468 
1469  for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sFilterListPickerProperties); i++) {
1470  // due to mozbug 364864 this never gets persisted in compreg.dat :(
1471  rv = cm->AddCategoryEntry("filter-list-picker-properties",
1474  PR_FALSE,
1475  PR_TRUE,
1476  nsnull);
1477  NS_ENSURE_SUCCESS(rv, rv);
1478  }
1479 
1480  return NS_OK;
1481 }
1482 
1483 nsresult
1484 sbPropertyManager::RegisterBlob(const nsAString& aPropertyID,
1485  const nsAString& aDisplayKey,
1486  nsIStringBundle* aStringBundle,
1487  PRBool aUserViewable,
1488  PRBool aUserEditable,
1489  PRBool aUsedInIdentity,
1490  PRUint32 aNullSort,
1491  PRBool aHasNullSort,
1492  PRBool aRemoteReadable,
1493  PRBool aRemoteWritable)
1494 {
1495  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1496 
1497  nsRefPtr<sbPropertyInfo> blobProperty(new sbPropertyInfo());
1498  NS_ENSURE_TRUE(blobProperty, NS_ERROR_OUT_OF_MEMORY);
1499 
1500  nsresult rv = blobProperty->Init();
1501  NS_ENSURE_SUCCESS(rv, rv);
1502 
1503  rv = blobProperty->SetId(aPropertyID);
1504  NS_ENSURE_SUCCESS(rv, rv);
1505 
1506  if (!aDisplayKey.IsEmpty()) {
1507  nsAutoString displayValue;
1508  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1509  if(NS_SUCCEEDED(rv)) {
1510  rv = blobProperty->SetDisplayName(displayValue);
1511  NS_ENSURE_SUCCESS(rv, rv);
1512  }
1513 
1514  rv = blobProperty->SetLocalizationKey(aDisplayKey);
1515  NS_ENSURE_SUCCESS(rv, rv);
1516  }
1517 
1518  if (aHasNullSort) {
1519  rv = blobProperty->SetNullSort(aNullSort);
1520  NS_ENSURE_SUCCESS(rv, rv);
1521  }
1522 
1523  rv = blobProperty->SetUserViewable(aUserViewable);
1524  NS_ENSURE_SUCCESS(rv, rv);
1525 
1526  rv = blobProperty->SetUserEditable(aUserEditable);
1527  NS_ENSURE_SUCCESS(rv, rv);
1528 
1529  rv = blobProperty->SetUsedInIdentity(aUsedInIdentity);
1530  NS_ENSURE_SUCCESS(rv, rv);
1531 
1532  nsCOMPtr<sbIPropertyInfo> propInfo =
1533  do_QueryInterface(NS_ISUPPORTS_CAST(sbIPropertyInfo*, blobProperty), &rv);
1534  NS_ENSURE_SUCCESS(rv, rv);
1535 
1536  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
1537  NS_ENSURE_SUCCESS(rv, rv);
1538 
1539  rv = AddPropertyInfo(propInfo);
1540  NS_ENSURE_SUCCESS(rv, rv);
1541 
1542  return NS_OK;
1543 }
1544 
1545 nsresult
1546 sbPropertyManager::RegisterText(const nsAString& aPropertyID,
1547  const nsAString& aDisplayKey,
1548  nsIStringBundle* aStringBundle,
1549  PRBool aUserViewable,
1550  PRBool aUserEditable,
1551  PRBool aUsedInIdentity,
1552  PRUint32 aNullSort,
1553  PRBool aHasNullSort,
1554  PRBool aRemoteReadable,
1555  PRBool aRemoteWritable,
1556  PRBool aCompressWhitespace,
1557  sbIPropertyArray* aSecondarySort)
1558 {
1559  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1560 
1561  nsRefPtr<sbTextPropertyInfo> textProperty(new sbTextPropertyInfo());
1562  NS_ENSURE_TRUE(textProperty, NS_ERROR_OUT_OF_MEMORY);
1563 
1564  nsresult rv = textProperty->Init();
1565  NS_ENSURE_SUCCESS(rv, rv);
1566 
1567  rv = textProperty->SetId(aPropertyID);
1568  NS_ENSURE_SUCCESS(rv, rv);
1569 
1570  if (!aDisplayKey.IsEmpty()) {
1571  nsAutoString displayValue;
1572  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1573  if(NS_SUCCEEDED(rv)) {
1574  rv = textProperty->SetDisplayName(displayValue);
1575  NS_ENSURE_SUCCESS(rv, rv);
1576  }
1577 
1578  rv = textProperty->SetLocalizationKey(aDisplayKey);
1579  NS_ENSURE_SUCCESS(rv, rv);
1580  }
1581 
1582  if (aHasNullSort) {
1583  rv = textProperty->SetNullSort(aNullSort);
1584  NS_ENSURE_SUCCESS(rv, rv);
1585  }
1586 
1587  rv = textProperty->SetUserViewable(aUserViewable);
1588  NS_ENSURE_SUCCESS(rv, rv);
1589 
1590  rv = textProperty->SetUserEditable(aUserEditable);
1591  NS_ENSURE_SUCCESS(rv, rv);
1592 
1593  rv = textProperty->SetUsedInIdentity(aUsedInIdentity);
1594  NS_ENSURE_SUCCESS(rv, rv);
1595 
1596  if (aSecondarySort) {
1597  rv = textProperty->SetSecondarySort(aSecondarySort);
1598  NS_ENSURE_SUCCESS(rv, rv);
1599  }
1600 
1601  if (!aCompressWhitespace) {
1602  rv = textProperty->SetNoCompressWhitespace(!aCompressWhitespace);
1603  NS_ENSURE_SUCCESS(rv, rv);
1604  }
1605 
1606  nsCOMPtr<sbIPropertyInfo> propInfo =
1607  do_QueryInterface(NS_ISUPPORTS_CAST(sbITextPropertyInfo*, textProperty), &rv);
1608  NS_ENSURE_SUCCESS(rv, rv);
1609 
1610  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
1611  NS_ENSURE_SUCCESS(rv, rv);
1612 
1613  rv = AddPropertyInfo(propInfo);
1614  NS_ENSURE_SUCCESS(rv, rv);
1615 
1616  return NS_OK;
1617 }
1618 
1619 nsresult
1620 sbPropertyManager::RegisterTrackTypeImageLabel(const nsAString& aPropertyID,
1621  const nsAString& aDisplayKey,
1622  nsIStringBundle* aStringBundle,
1623  PRBool aUserViewable,
1624  PRBool aUserEditable,
1625  PRBool aRemoteReadable,
1626  PRBool aRemoteWritable,
1627  const nsAString& aUrlPropertyID)
1628 {
1629  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1630  nsresult rv;
1631 
1632  nsRefPtr<sbTrackTypeImageLabelPropertyInfo> trackTypeProperty(
1634  NS_ENSURE_TRUE(trackTypeProperty, NS_ERROR_OUT_OF_MEMORY);
1635 
1636  rv = trackTypeProperty->Init();
1637  NS_ENSURE_SUCCESS(rv, rv);
1638 
1639  rv = trackTypeProperty->SetPropertyID(aPropertyID);
1640  NS_ENSURE_SUCCESS(rv, rv);
1641 
1642  if (!aDisplayKey.IsEmpty()) {
1643  nsAutoString displayValue;
1644  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1645  if(NS_SUCCEEDED(rv)) {
1646  rv = trackTypeProperty->SetDisplayName(displayValue);
1647  NS_ENSURE_SUCCESS(rv, rv);
1648  }
1649 
1650  rv = trackTypeProperty->SetLocalizationKey(aDisplayKey);
1651  NS_ENSURE_SUCCESS(rv, rv);
1652  }
1653 
1654  rv = trackTypeProperty->SetUserViewable(aUserViewable);
1655  NS_ENSURE_SUCCESS(rv, rv);
1656 
1657  rv = trackTypeProperty->SetUserEditable(aUserEditable);
1658  NS_ENSURE_SUCCESS(rv, rv);
1659 
1660  rv = trackTypeProperty->SetRemoteReadable(aRemoteReadable);
1661  NS_ENSURE_SUCCESS(rv, rv);
1662 
1663  rv = trackTypeProperty->SetRemoteWritable(aRemoteWritable);
1664  NS_ENSURE_SUCCESS(rv, rv);
1665 
1666  rv = AddPropertyInfo(trackTypeProperty);
1667  NS_ENSURE_SUCCESS(rv, rv);
1668 
1669  return NS_OK;
1670 }
1671 
1672 nsresult
1673 sbPropertyManager::RegisterDateTime(const nsAString& aPropertyID,
1674  const nsAString& aDisplayKey,
1675  PRInt32 aType,
1676  nsIStringBundle* aStringBundle,
1677  PRBool aUserViewable,
1678  PRBool aUserEditable,
1679  PRBool aRemoteReadable,
1680  PRBool aRemoteWritable)
1681 {
1682  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1683 
1684  nsRefPtr<sbDatetimePropertyInfo>
1685  datetimeProperty(new sbDatetimePropertyInfo());
1686  NS_ENSURE_TRUE(datetimeProperty, NS_ERROR_OUT_OF_MEMORY);
1687 
1688  nsresult rv = datetimeProperty->Init();
1689  NS_ENSURE_SUCCESS(rv, rv);
1690 
1691  rv = datetimeProperty->SetId(aPropertyID);
1692  NS_ENSURE_SUCCESS(rv, rv);
1693 
1694  rv = datetimeProperty->SetTimeType(aType);
1695  NS_ENSURE_SUCCESS(rv, rv);
1696 
1697  if (!aDisplayKey.IsEmpty()) {
1698  nsAutoString displayValue;
1699  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1700  if(NS_SUCCEEDED(rv)) {
1701  rv = datetimeProperty->SetDisplayName(displayValue);
1702  NS_ENSURE_SUCCESS(rv, rv);
1703  }
1704 
1705  rv = datetimeProperty->SetLocalizationKey(aDisplayKey);
1706  NS_ENSURE_SUCCESS(rv, rv);
1707  }
1708 
1709  rv = datetimeProperty->SetUserViewable(aUserViewable);
1710  NS_ENSURE_SUCCESS(rv, rv);
1711 
1712  rv = datetimeProperty->SetUserEditable(aUserEditable);
1713  NS_ENSURE_SUCCESS(rv, rv);
1714 
1715  nsCOMPtr<sbIPropertyInfo> propInfo =
1716  do_QueryInterface(NS_ISUPPORTS_CAST(sbIDatetimePropertyInfo*, datetimeProperty), &rv);
1717  NS_ENSURE_SUCCESS(rv, rv);
1718 
1719  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
1720  NS_ENSURE_SUCCESS(rv, rv);
1721 
1722  rv = AddPropertyInfo(propInfo);
1723  NS_ENSURE_SUCCESS(rv, rv);
1724 
1725  return NS_OK;
1726 }
1727 
1728 nsresult
1729 sbPropertyManager::RegisterDuration(const nsAString& aPropertyID,
1730  const nsAString& aDisplayKey,
1731  nsIStringBundle* aStringBundle,
1732  PRBool aUserViewable,
1733  PRBool aUserEditable,
1734  PRBool aRemoteReadable,
1735  PRBool aRemoteWritable)
1736 {
1737  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1738 
1739  nsRefPtr<sbDurationPropertyInfo>
1740  durationProperty(new sbDurationPropertyInfo());
1741  NS_ENSURE_TRUE(durationProperty, NS_ERROR_OUT_OF_MEMORY);
1742 
1743  nsresult rv = durationProperty->Init();
1744  NS_ENSURE_SUCCESS(rv, rv);
1745 
1746  rv = durationProperty->SetId(aPropertyID);
1747  NS_ENSURE_SUCCESS(rv, rv);
1748 
1749  if (!aDisplayKey.IsEmpty()) {
1750  nsAutoString displayValue;
1751  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1752  if(NS_SUCCEEDED(rv)) {
1753  rv = durationProperty->SetDisplayName(displayValue);
1754  NS_ENSURE_SUCCESS(rv, rv);
1755  }
1756 
1757  rv = durationProperty->SetLocalizationKey(aDisplayKey);
1758  NS_ENSURE_SUCCESS(rv, rv);
1759  }
1760 
1761  rv = durationProperty->SetUserViewable(aUserViewable);
1762  NS_ENSURE_SUCCESS(rv, rv);
1763 
1764  rv = durationProperty->SetUserEditable(aUserEditable);
1765  NS_ENSURE_SUCCESS(rv, rv);
1766 
1767  nsRefPtr<sbIPropertyUnitConverter> propConverter = new sbDurationPropertyUnitConverter();
1768  rv = durationProperty->SetUnitConverter(propConverter);
1769  NS_ENSURE_SUCCESS(rv, rv);
1770 
1771  nsCOMPtr<sbIPropertyInfo> propInfo =
1772  do_QueryInterface(NS_ISUPPORTS_CAST(sbIDurationPropertyInfo*, durationProperty), &rv);
1773  NS_ENSURE_SUCCESS(rv, rv);
1774 
1775  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
1776  NS_ENSURE_SUCCESS(rv, rv);
1777 
1778  rv = AddPropertyInfo(propInfo);
1779  NS_ENSURE_SUCCESS(rv, rv);
1780 
1781  return NS_OK;
1782 }
1783 
1784 nsresult
1785 sbPropertyManager::RegisterURI(const nsAString& aPropertyID,
1786  const nsAString& aDisplayKey,
1787  nsIStringBundle* aStringBundle,
1788  PRBool aUserViewable,
1789  PRBool aUserEditable,
1790  PRBool aRemoteReadable,
1791  PRBool aRemoteWritable)
1792 {
1793  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1794 
1795  nsRefPtr<sbURIPropertyInfo> uriProperty(new sbURIPropertyInfo());
1796  NS_ENSURE_TRUE(uriProperty, NS_ERROR_OUT_OF_MEMORY);
1797 
1798  nsresult rv = uriProperty->Init();
1799  NS_ENSURE_SUCCESS(rv, rv);
1800 
1801  rv = uriProperty->SetId(aPropertyID);
1802  NS_ENSURE_SUCCESS(rv, rv);
1803 
1804  if (!aDisplayKey.IsEmpty()) {
1805  nsAutoString displayValue;
1806  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1807  if(NS_SUCCEEDED(rv)) {
1808  rv = uriProperty->SetDisplayName(displayValue);
1809  NS_ENSURE_SUCCESS(rv, rv);
1810  }
1811 
1812  rv = uriProperty->SetLocalizationKey(aDisplayKey);
1813  NS_ENSURE_SUCCESS(rv, rv);
1814  }
1815 
1816  rv = uriProperty->SetUserViewable(aUserViewable);
1817  NS_ENSURE_SUCCESS(rv, rv);
1818 
1819  rv = uriProperty->SetUserEditable(aUserEditable);
1820  NS_ENSURE_SUCCESS(rv, rv);
1821 
1822  nsCOMPtr<sbIPropertyInfo> propInfo =
1823  do_QueryInterface(NS_ISUPPORTS_CAST(sbIURIPropertyInfo*, uriProperty), &rv);
1824  NS_ENSURE_SUCCESS(rv, rv);
1825 
1826  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
1827  NS_ENSURE_SUCCESS(rv, rv);
1828 
1829  rv = AddPropertyInfo(propInfo);
1830  NS_ENSURE_SUCCESS(rv, rv);
1831 
1832  return NS_OK;
1833 }
1834 
1835 nsresult
1836 sbPropertyManager::RegisterImage(const nsAString& aPropertyID,
1837  const nsAString& aDisplayKey,
1838  nsIStringBundle* aStringBundle,
1839  PRBool aUserViewable,
1840  PRBool aUserEditable,
1841  PRBool aRemoteReadable,
1842  PRBool aRemoteWritable)
1843 {
1844  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1845  nsresult rv;
1846 
1847  // translate the display name
1848  nsAutoString displayName(aDisplayKey);
1849  if (!aDisplayKey.IsEmpty()) {
1850  rv = GetStringFromName(aStringBundle, aDisplayKey, displayName);
1851  }
1852 
1853  // create the image property
1854  nsRefPtr<sbImagePropertyInfo> imageProperty(
1855  new sbImagePropertyInfo(aPropertyID, displayName, aDisplayKey,
1856  aRemoteReadable, aRemoteWritable, aUserViewable,
1857  aUserEditable));
1858  NS_ENSURE_TRUE(imageProperty, NS_ERROR_OUT_OF_MEMORY);
1859 
1860  rv = AddPropertyInfo(imageProperty);
1861  NS_ENSURE_SUCCESS(rv, rv);
1862 
1863  return NS_OK;
1864 }
1865 
1866 nsresult
1867 sbPropertyManager::RegisterImageLink(const nsAString& aPropertyID,
1868  const nsAString& aDisplayKey,
1869  nsIStringBundle* aStringBundle,
1870  PRBool aUserViewable,
1871  PRBool aUserEditable,
1872  PRBool aRemoteReadable,
1873  PRBool aRemoteWritable,
1874  const nsAString& aUrlPropertyID)
1875 {
1876  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1877  nsresult rv;
1878 
1879  // translate the display name
1880  nsAutoString displayName(aDisplayKey);
1881  if (!aDisplayKey.IsEmpty()) {
1882  rv = GetStringFromName(aStringBundle, aDisplayKey, displayName);
1883  }
1884 
1885  // create the image property
1886  nsRefPtr<sbImageLinkPropertyInfo> imageLinkProperty(
1887  new sbImageLinkPropertyInfo(aPropertyID, displayName, aDisplayKey,
1888  aRemoteReadable, aRemoteWritable, aUserViewable,
1889  aUserEditable, aUrlPropertyID));
1890  NS_ENSURE_TRUE(imageLinkProperty, NS_ERROR_OUT_OF_MEMORY);
1891 
1892  rv = AddPropertyInfo(imageLinkProperty);
1893  NS_ENSURE_SUCCESS(rv, rv);
1894 
1895  return NS_OK;
1896 }
1897 
1898 nsresult
1899 sbPropertyManager::RegisterNumber(const nsAString& aPropertyID,
1900  const nsAString& aDisplayKey,
1901  nsIStringBundle* aStringBundle,
1902  PRBool aUserViewable,
1903  PRBool aUserEditable,
1904  PRInt32 aMinValue,
1905  PRBool aHasMinValue,
1906  PRInt32 aMaxValue,
1907  PRBool aHasMaxValue,
1908  PRBool aRemoteReadable,
1909  PRBool aRemoteWritable,
1910  sbIPropertyUnitConverter *aUnitConverter,
1911  sbIPropertyArray* aSecondarySort)
1912 {
1913  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1914 
1915  nsRefPtr<sbNumberPropertyInfo> numberProperty(new sbNumberPropertyInfo());
1916  NS_ENSURE_TRUE(numberProperty, NS_ERROR_OUT_OF_MEMORY);
1917 
1918  nsresult rv = numberProperty->Init();
1919  NS_ENSURE_SUCCESS(rv, rv);
1920 
1921  rv = numberProperty->SetId(aPropertyID);
1922  NS_ENSURE_SUCCESS(rv, rv);
1923 
1924  if (aHasMinValue) {
1925  rv = numberProperty->SetMinValue(aMinValue);
1926  NS_ENSURE_SUCCESS(rv, rv);
1927  }
1928 
1929  if (aHasMaxValue) {
1930  rv = numberProperty->SetMaxValue(aMaxValue);
1931  NS_ENSURE_SUCCESS(rv, rv);
1932  }
1933 
1934  if (!aDisplayKey.IsEmpty()) {
1935  nsAutoString displayValue;
1936  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1937  if(NS_SUCCEEDED(rv)) {
1938  rv = numberProperty->SetDisplayName(displayValue);
1939  NS_ENSURE_SUCCESS(rv, rv);
1940  }
1941 
1942  rv = numberProperty->SetLocalizationKey(aDisplayKey);
1943  NS_ENSURE_SUCCESS(rv, rv);
1944  }
1945 
1946  rv = numberProperty->SetUserViewable(aUserViewable);
1947  NS_ENSURE_SUCCESS(rv, rv);
1948 
1949  rv = numberProperty->SetUserEditable(aUserEditable);
1950  NS_ENSURE_SUCCESS(rv, rv);
1951 
1952  rv = numberProperty->SetUnitConverter(aUnitConverter);
1953  NS_ENSURE_SUCCESS(rv, rv);
1954 
1955  if (aSecondarySort) {
1956  rv = numberProperty->SetSecondarySort(aSecondarySort);
1957  NS_ENSURE_SUCCESS(rv, rv);
1958  }
1959 
1960  nsCOMPtr<sbIPropertyInfo> propInfo =
1961  do_QueryInterface(NS_ISUPPORTS_CAST(sbINumberPropertyInfo*, numberProperty), &rv);
1962  NS_ENSURE_SUCCESS(rv, rv);
1963 
1964  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
1965  NS_ENSURE_SUCCESS(rv, rv);
1966 
1967  rv = AddPropertyInfo(propInfo);
1968  NS_ENSURE_SUCCESS(rv, rv);
1969 
1970  return NS_OK;
1971 }
1972 
1973 nsresult
1974 sbPropertyManager::RegisterBoolean(const nsAString &aPropertyID,
1975  const nsAString &aDisplayKey,
1976  nsIStringBundle* aStringBundle,
1977  PRBool aUserViewable,
1978  PRBool aUserEditable,
1979  PRBool aRemoteReadable,
1980  PRBool aRemoteWritable,
1981  PRBool aShouldSuppress)
1982 {
1983  LOG(( "sbPropertyManager::RegisterBoolean(%s)",
1984  NS_LossyConvertUTF16toASCII(aPropertyID).get() ));
1985  NS_ASSERTION(aStringBundle, "aStringBundle is null");
1986 
1987  nsRefPtr<sbBooleanPropertyInfo> booleanProperty(new sbBooleanPropertyInfo());
1988  NS_ENSURE_TRUE(booleanProperty, NS_ERROR_OUT_OF_MEMORY);
1989 
1990  nsresult rv = booleanProperty->Init();
1991  NS_ENSURE_SUCCESS(rv, rv);
1992 
1993  rv = booleanProperty->SetId(aPropertyID);
1994  NS_ENSURE_SUCCESS(rv, rv);
1995 
1996  if (!aDisplayKey.IsEmpty()) {
1997  nsAutoString displayValue;
1998  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
1999  if(NS_SUCCEEDED(rv)) {
2000  rv = booleanProperty->SetDisplayName(displayValue);
2001  NS_ENSURE_SUCCESS(rv, rv);
2002  }
2003 
2004  rv = booleanProperty->SetLocalizationKey(aDisplayKey);
2005  NS_ENSURE_SUCCESS(rv, rv);
2006  }
2007 
2008  rv = booleanProperty->SetUserViewable(aUserViewable);
2009  NS_ENSURE_SUCCESS(rv, rv);
2010 
2011  rv = booleanProperty->SetUserEditable(aUserEditable);
2012  NS_ENSURE_SUCCESS(rv, rv);
2013 
2014  rv = booleanProperty->SetSuppressSelect(aShouldSuppress);
2015  NS_ENSURE_SUCCESS(rv, rv);
2016 
2017  nsCOMPtr<sbIPropertyInfo> propInfo =
2018  do_QueryInterface(NS_ISUPPORTS_CAST(sbIBooleanPropertyInfo*, booleanProperty), &rv);
2019  NS_ENSURE_SUCCESS(rv, rv);
2020 
2021  rv = SetRemoteAccess(propInfo, aRemoteReadable, aRemoteWritable);
2022  NS_ENSURE_SUCCESS(rv, rv);
2023 
2024  rv = AddPropertyInfo(propInfo);
2025  NS_ENSURE_SUCCESS(rv, rv);
2026 
2027  return NS_OK;
2028 }
2029 
2030 nsresult
2031 sbPropertyManager::RegisterDummy(sbDummyPropertyInfo *dummyProperty,
2032  const nsAString &aPropertyID,
2033  const nsAString &aDisplayKey,
2034  nsIStringBundle* aStringBundle)
2035 {
2036  nsresult rv = dummyProperty->Init();
2037  NS_ENSURE_SUCCESS(rv, rv);
2038 
2039  rv = dummyProperty->SetId(aPropertyID);
2040  NS_ENSURE_SUCCESS(rv, rv);
2041 
2042  if (!aDisplayKey.IsEmpty()) {
2043  nsAutoString displayValue;
2044  rv = GetStringFromName(aStringBundle, aDisplayKey, displayValue);
2045  if(NS_SUCCEEDED(rv)) {
2046  rv = dummyProperty->SetDisplayName(displayValue);
2047  NS_ENSURE_SUCCESS(rv, rv);
2048  }
2049 
2050  rv = dummyProperty->SetLocalizationKey(aDisplayKey);
2051  NS_ENSURE_SUCCESS(rv, rv);
2052  }
2053 
2054  nsCOMPtr<sbIPropertyInfo> propInfo = do_QueryInterface(NS_ISUPPORTS_CAST(sbIDummyPropertyInfo*, dummyProperty), &rv);
2055  NS_ENSURE_SUCCESS(rv, rv);
2056 
2057  rv = AddPropertyInfo(propInfo);
2058  NS_ENSURE_SUCCESS(rv, rv);
2059 
2060  return NS_OK;
2061 }
2062 
2063 nsresult
2064 sbPropertyManager::SetRemoteAccess(sbIPropertyInfo* aProperty,
2065  PRBool aRemoteReadable,
2066  PRBool aRemoteWritable)
2067 {
2068  nsresult rv = NS_OK;
2069 
2070  rv = aProperty->SetRemoteReadable(aRemoteReadable);
2071  NS_ENSURE_SUCCESS(rv, rv);
2072 
2073  rv = aProperty->SetRemoteWritable(aRemoteWritable);
2074  NS_ENSURE_SUCCESS(rv, rv);
2075 
2076  return NS_OK;
2077 }
#define SB_PROPERTY_TOTALDISCS
#define SB_PROPERTY_IMPORTTYPE
#define SB_PROPERTY_SHOULDRIP
return NS_OK
#define SB_PROPERTY_KEYWORDS
#define SB_PROPERTY_CDRIP_STATUS
#define SB_PROPERTY_MEDIALISTNAME
virtual nsresult Init()
#define SB_PROPERTY_PLAYCOUNT
#define SB_PROPERTY_METADATAUUID
#define SB_PROPERTY_TRACKTYPE
#define SB_PROPERTY_ORIGINLIBRARYGUID
#define SB_PROPERTY_SAMPLERATE
#define SB_PROPERTY_SEASONNUMBER
#define SB_PROPERTY_HASH
#define SB_PROPERTY_RAPISITEID
#define SB_PROPERTY_ORIGINURL
#define SB_PROPERTY_LYRICS
The property information specific to date/time fields.
#define SB_PROPERTY_CHANNELS
menuItem id
Definition: FeedWriter.js:971
#define SB_PROPERTY_ALBUMARTISTNAME
#define SB_PROPERTY_ISCONTENTREADONLY
#define SB_PROPERTY_RATING
#define SB_PROPERTY_ISDRMPROTECTED
#define SB_PROPERTY_ORDINAL
The property information specific to URL/URI fields.
NS_IMPL_THREADSAFE_ISUPPORTS1(sbPropertyManager, sbIPropertyManager) sbPropertyManager
#define SB_PROPERTY_CONDUCTORNAME
#define SB_PROPERTY_HIDDEN
#define SB_PROPERTY_MANAGER_READY_CATEGORY
#define SB_PROPERTY_DEVICE_PERSISTENT_ID
const long TIMETYPE_DATETIME
Long date format, 2007-03-28 12:33:01 , no milliseconds.
#define SB_PROPERTY_SHOWNAME
#define SB_PROPERTY_ARTISTDETAIL
#define SB_MUTABLEPROPERTYARRAY_CONTRACTID
The property information specific to date/time fields.
#define SB_DUMMYPROPERTY_SMARTMEDIALIST_PLAYLIST
#define SB_PROPERTY_LYRICISTNAME
#define SB_PROPERTY_ONLY_CUSTOM_MEDIAPAGES
The property information specific to numeric fields.
#define SB_PROPERTY_RAPISCOPEURL
#define SB_PROPERTY_LASTPLAYPOSITION
#define SB_PROPERTY_EXCLUDE_FROM_HISTORY
const char * types
#define SB_PROPERTY_DESCRIPTION
#define SB_PROPERTY_LASTPLAYTIME
#define SB_PROPERTY_TOTALTRACKS
nsTArray< nsString > mPropIDs
#define SB_PROPERTY_ISSORTABLE
#define SB_PROPERTY_METADATA_HASH_IDENTITY
#define LOG(args)
#define SB_PROPERTY_BITRATE
#define SB_PROPERTY_LAST_SYNC_TIME
#define SB_PROPERTY_DONT_WRITE_METADATA
#define SB_PROPERTY_STORAGEGUID
#define SB_PROPERTY_CONTENTLENGTH
#define SB_PROPERTY_PLAYQUEUE_MEDIALIST_GUID
#define SB_PROPERTY_ORIGINPAGEIMAGE
const char * propName
#define SB_PROPERTY_ORIGINPAGE
nsInterfaceHashtableMT< nsStringHashKey, sbIPropertyArray > mPropDependencyMap
#define SB_PROPERTY_CREATED
#define SB_PROPERTY_OUTERGUID
#define SB_PROPERTY_COLUMNSPEC
#define SB_PROPERTY_ATTEMPTED_REMOTE_ART_FETCH
#define SB_PROPERTY_UPDATED
#define SB_PROPERTY_GENRE
#define SB_PROPERTY_ENABLE_AUTO_DOWNLOAD
#define SB_PROPERTY_CONTENTTYPE
#define SB_PROPERTY_DESTINATION
#define SB_PROPERTY_CDDISCHASH
#define SB_PROPERTY_SOFTWAREVENDOR
#define SB_PROPERTY_KEY
#define SB_PROPERTY_DURATION
NS_IMETHOD SetDisplayName(const nsAString &aDisplayName)
The property information specific to text fields.
#define SB_PROPERTY_ISREADONLY
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...
#define SB_PROPERTY_DEFAULTCOLUMNSPEC
#define SB_PROPERTY_GUID
#define SB_PROPERTY_COPYRIGHT
#define SB_PROPERTY_DISCNUMBER
#define SB_PROPERTY_ORIGIN_IS_IN_MAIN_LIBRARY
#define SB_STRING_BUNDLE_CHROME_URL
#define SB_PROPERTY_DEVICE_LIBRARY_GUID
GstMessage * message
An interface used to recognize a dummy metadata property.
#define SB_PROPERTY_ARTISTNAME
#define SB_PROPERTY_SMARTMEDIALIST_STATE
#define SB_PROPERTY_LAST_SYNC_SKIPCOUNT
#define SB_PROPERTY_BPM
_updateCookies aName
#define SB_PROPERTY_RECORDLABELNAME
Property unit converter interface This is an interface songbird property converter, used to convert a property value between its various units representations.
#define SB_PROPERTY_CREATED_FIRSTRUN_SMARTPLAYLISTS
countRef value
Definition: FeedWriter.js:1423
#define SB_PROPERTY_ALBUMNAME
#define SB_PROPERTY_LANGUAGE
#define SB_PROPERTY_ARTISTDETAILURL
#define SB_PROPERTY_COMPOSERNAME
#define SB_PROPERTY_EPISODENUMBER
The property information specific to boolean properties.
NS_METHOD CreateSystemProperties()
#define SB_PROPERTY_YEAR
#define SB_PROPERTY_DISABLE_DOWNLOAD
#define SB_PROPERTY_ALBUMDETAIL
#define SB_PROPERTY_ALBUMDETAILURL
#define SB_PROPERTY_DOWNLOAD_STATUS_TARGET
#define SB_PROPERTY_LISTTYPE
#define SB_PROPERTY_PRODUCERNAME
#define SB_PROPERTY_LASTSKIPTIME
#define SB_PROPERTY_PLAYLISTURL
#define SB_PROPERTY_TRACKNAME
#define SB_PROPERTY_AVAILABILITY
#define SB_PROPERTY_COMMENT
const struct @18 sFilterListPickerProperties[]
#define SB_PROPERTY_ISLIST
const unsigned long SORT_NULL_BIG
Causes null values to be infinitely large.
#define SB_PROPERTY_CUSTOMTYPE
#define SB_PROPERTY_COPYRIGHTURL
#define SB_PROPERTY_CONTENTURL
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
nsInterfaceHashtableMT< nsStringHashKey, sbIPropertyInfo > mPropInfoHashtable
#define SB_PROPERTY_SUBTITLE
#define SB_PROPERTY_ORIGINITEMGUID
#define SB_PROPERTY_ITUNES_GUID
const long TIMETYPE_TIMESTAMP
Timestamp format, respects unix time, microsecond format.
_getSelectedPageStyle s i
#define SB_PROPERTY_PRIMARYIMAGEURL
Manager for system wide metadata properties.
#define SB_PROPERTY_TRANSFER_POLICY
#define SB_PROPERTY_DOWNLOAD_MEDIALIST_GUID
NS_IMETHOD SetLocalizationKey(const nsAString &aLocalizationKey)
#define SB_PROPERTY_ORIGINPAGETITLE
#define SB_PROPERTY_SKIPCOUNT
#define SB_PROPERTY_DOWNLOAD_DETAILS
#define SB_PROPERTY_LAST_SYNC_PLAYCOUNT
var cm
NS_IMETHOD SetId(const nsAString &aID)
#define SB_PROPERTY_DEFAULT_MEDIAPAGE_URL
#define SB_PROPERTY_TRACKNUMBER
#define SB_PROPERTY_ISPARTOFCOMPILATION