32 #include <nsIAtomService.h>
33 #include <nsIClassInfoImpl.h>
34 #include <nsIDOMElement.h>
35 #include <nsIObjectOutputStream.h>
36 #include <nsIObjectInputStream.h>
37 #include <nsIObserverService.h>
38 #include <nsIProgrammingLanguage.h>
39 #include <nsIStringBundle.h>
40 #include <nsIStringEnumerator.h>
41 #include <nsITreeBoxObject.h>
42 #include <nsITreeColumns.h>
43 #include <nsIVariant.h>
44 #include <sbIClickablePropertyInfo.h>
45 #include <sbILocalDatabaseLibrary.h>
46 #include <sbILocalDatabasePropertyCache.h>
47 #include <sbILibrary.h>
48 #include <sbILibraryConstraints.h>
49 #include <sbIDevice.h>
50 #include <sbIDeviceManager.h>
51 #include <sbIMediacoreEvent.h>
52 #include <sbIMediacoreEventTarget.h>
53 #include <sbIMediacoreManager.h>
54 #include <sbIMediacoreSequencer.h>
55 #include <sbIMediacoreStatus.h>
56 #include <sbIMediaListView.h>
57 #include <sbIMediaList.h>
58 #include <sbIMediaItem.h>
59 #include <sbIMediaItemController.h>
60 #include <sbIPropertyArray.h>
61 #include <sbIPropertyInfo.h>
62 #include <sbIPropertyManager.h>
63 #include <sbIPropertyUnitConverter.h>
64 #include <sbISortableMediaListView.h>
65 #include <sbITreeViewPropertyInfo.h>
67 #include <nsComponentManagerUtils.h>
69 #include <nsServiceManagerUtils.h>
70 #include <nsThreadUtils.h>
71 #include <nsUnicharUtils.h>
94 static PRLogModuleInfo* gLocalDatabaseTreeViewLog = nsnull;
95 #define TRACE(args) PR_LOG(gLocalDatabaseTreeViewLog, PR_LOG_DEBUG, args)
96 #define LOG(args) PR_LOG(gLocalDatabaseTreeViewLog, PR_LOG_WARN, args)
102 #define PROGRESS_VALUE_UNSET -1
103 #define PROGRESS_VALUE_COMPLETE 101
105 #define SB_STRING_BUNDLE_CHROME_URL "chrome://songbird/locale/songbird.properties"
107 #define BAD_CSS_CHARS "/.:# !@$%^&*(),?;'\"<>~=+`\\|[]{}"
125 mTreeBoxObject(aTreeBoxObject)
127 NS_ASSERTION(aTreeBoxObject,
"aTreeBoxObject is null");
131 mTreeBoxObject->BeginUpdateBatch();
132 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to begin");
140 mTreeBoxObject->EndUpdateBatch();
141 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to end");
145 nsITreeBoxObject* mTreeBoxObject;
154 mArray->SuppressInvalidation(PR_TRUE);
158 mArray->SuppressInvalidation(PR_FALSE);
161 nsCOMPtr<sbILocalDatabaseGUIDArray> mArray;
165 sbLocalDatabaseTreeView::SelectionListSavingEnumeratorCallback(PRUint32 aIndex,
166 const nsAString& aId,
167 const nsAString& aGuid,
170 NS_ENSURE_ARG_POINTER(aUserData);
173 NS_ENSURE_STATE(list);
175 nsString guid(aGuid);
176 PRBool success = list->Put(aId, guid);
177 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
183 sbLocalDatabaseTreeView::SelectionListGuidsEnumeratorCallback(PRUint32 aIndex,
184 const nsAString& aId,
185 const nsAString& aGuid,
188 NS_ENSURE_ARG_POINTER(aUserData);
190 nsTArray<nsString>* list =
static_cast<nsTArray<nsString>*
>(aUserData);
191 NS_ENSURE_STATE(list);
193 nsString* appended = list->AppendElement(aGuid);
194 NS_ENSURE_TRUE(appended, NS_ERROR_OUT_OF_MEMORY);
222 sbLocalDatabaseTreeView::sbLocalDatabaseTreeView() :
224 mMediaListView(nsnull),
225 mViewSelection(nsnull),
227 mManageSelection(PR_FALSE),
228 mHaveSavedSelection(PR_FALSE),
231 mSelectionIsAll(PR_FALSE),
232 mFakeAllRow(PR_FALSE),
233 mIsListeningToPlayback(PR_FALSE),
234 mShouldPreventRebuild(PR_FALSE),
235 mFirstCachedRow(NOT_SET),
236 mLastCachedRow(NOT_SET),
240 if (!gLocalDatabaseTreeViewLog) {
241 gLocalDatabaseTreeViewLog = PR_NewLogModule(
"sbLocalDatabaseTreeView");
250 if (mPlayQueueService) {
252 nsCOMPtr<sbIPlayQueueServiceListener> playQueueServiceListener =
255 if (NS_SUCCEEDED(rv)) {
256 mPlayQueueService->RemoveListener(playQueueServiceListener);
260 if (mViewSelection) {
261 nsCOMPtr<sbIMediaListViewSelectionListener> selectionListener =
264 if (NS_SUCCEEDED(rv))
265 mViewSelection->RemoveListener(selectionListener);
270 do_GetService(
"@mozilla.org/observer-service;1", &rv);
272 if (NS_SUCCEEDED(rv)) {
276 NS_ASSERTION(!mIsListeningToPlayback,
"Still listening when dtor called");
288 NS_ENSURE_ARG_POINTER(aMediaListView);
289 NS_ENSURE_ARG_POINTER(aArray);
295 NS_ENSURE_TRUE(!aState, NS_ERROR_INVALID_ARG);
296 PRUint32 arrayLength;
297 rv = aCurrentSort->GetLength(&arrayLength);
298 NS_ENSURE_SUCCESS(rv, rv);
299 NS_ENSURE_STATE(arrayLength);
302 NS_ENSURE_ARG_POINTER(aState);
306 NS_ENSURE_SUCCESS(rv, rv);
308 mMediaListView = aMediaListView;
313 rv = mArray->GetIsDistinct(&isDistinct);
314 NS_ENSURE_SUCCESS(rv, rv);
317 mListType = eDistinct;
318 mManageSelection = PR_TRUE;
319 mFakeAllRow = PR_TRUE;
320 mSelectionIsAll = PR_TRUE;
323 mManageSelection = PR_FALSE;
325 rv = mArray->GetBaseTable(baseTable);
326 NS_ENSURE_SUCCESS(rv, rv);
328 if (baseTable.EqualsLiteral(
"media_items")) {
329 mListType = eLibrary;
332 if (baseTable.EqualsLiteral(
"simple_media_lists")) {
336 return NS_ERROR_UNEXPECTED;
344 if (!mManageSelection) {
345 nsCOMPtr<sbIMediaListViewSelection> viewSelection;
346 rv = mMediaListView->GetSelection(getter_AddRefs(viewSelection));
347 NS_ENSURE_TRUE(viewSelection, NS_ERROR_UNEXPECTED);
348 mViewSelection = viewSelection;
350 nsCOMPtr<sbIMediaListViewSelectionListener> selectionListener =
352 NS_ENSURE_SUCCESS(rv, rv);
354 rv = mViewSelection->AddListener(selectionListener);
355 NS_ENSURE_SUCCESS(rv, rv);
358 rv = mArray->GetPropertyCache(getter_AddRefs(mPropertyCache));
359 NS_ENSURE_SUCCESS(rv, rv);
361 nsCOMPtr<sbILocalDatabaseGUIDArrayListener>
listener =
363 NS_ENSURE_SUCCESS(rv, rv);
365 rv = mArray->SetListener(listener);
366 NS_ENSURE_SUCCESS(rv, rv);
368 rv = mArray->GetFetchSize(&mFetchSize);
369 NS_ENSURE_SUCCESS(rv, rv);
371 PRBool success = mSelectionList.Init();
372 NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
373 mHaveSavedSelection = PR_FALSE;
380 LOG((
"sbLocalDatabaseTreeView::Init[0x%.8x] - restoring %s",
381 this, NS_LossyConvertUTF16toASCII(buff).
get()));
384 rv = aState->
mSort->GetProperty(mCurrentSortProperty);
385 NS_ENSURE_SUCCESS(rv, rv);
388 rv = aState->
mSort->GetIsAscending(&isAscending);
389 NS_ENSURE_SUCCESS(rv, rv);
390 mCurrentSortDirectionIsAscending = isAscending;
392 if (mManageSelection) {
394 if (!mSelectionIsAll) {
397 mHaveSavedSelection = PR_TRUE;
403 nsCOMPtr<sbIProperty> property;
404 rv = aCurrentSort->GetPropertyAt(0, getter_AddRefs(property));
405 NS_ENSURE_SUCCESS(rv, rv);
407 rv =
property->GetId(mCurrentSortProperty);
408 NS_ENSURE_SUCCESS(rv, rv);
411 rv =
property->GetValue(value);
412 NS_ENSURE_SUCCESS(rv, rv);
414 mCurrentSortDirectionIsAscending = value.EqualsLiteral(
"a");
418 nsCOMPtr<nsIStringBundleService> bundleService =
419 do_GetService(
"@mozilla.org/intl/stringbundle;1", &rv);
420 NS_ENSURE_SUCCESS(rv, rv);
422 nsCOMPtr<nsIStringBundle> stringBundle;
424 getter_AddRefs(stringBundle));
425 NS_ENSURE_SUCCESS(rv, rv);
427 rv = stringBundle->GetStringFromName(NS_LITERAL_STRING(
"library.all").
get(),
428 getter_Copies(mLocalizedAll));
430 mLocalizedAll.AssignLiteral(
"library.all");
435 if (mListType != eDistinct) {
436 nsCOMPtr<nsISupportsWeakReference> weakRef =
437 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
438 NS_ENSURE_SUCCESS(rv, rv);
440 rv = weakRef->GetWeakReference(getter_AddRefs(mMediacoreManager));
441 NS_ENSURE_SUCCESS(rv, rv);
446 do_GetService(
"@songbirdnest.com/Songbird/playqueue/service;1", &rv);
447 NS_ENSURE_SUCCESS(rv, rv);
449 nsCOMPtr<sbIMediaList> queueList;
450 rv = mPlayQueueService->GetMediaList(getter_AddRefs(queueList));
451 NS_ENSURE_SUCCESS(rv, rv);
453 nsCOMPtr<sbIMediaList> viewList;
454 rv = mMediaListView->GetMediaList(getter_AddRefs(viewList));
455 NS_ENSURE_SUCCESS(rv, rv);
457 PRBool isViewOfQueue;
458 rv = queueList->Equals(viewList, &isViewOfQueue);
459 NS_ENSURE_SUCCESS(rv, rv);
462 rv = mPlayQueueService->GetIndex(&mPlayQueueIndex);
463 NS_ENSURE_SUCCESS(rv, rv);
466 nsCOMPtr<sbIPlayQueueServiceListener> playQueueServiceListener =
468 NS_ENSURE_SUCCESS(rv, rv);
470 rv = mPlayQueueService->AddListener(playQueueServiceListener);
471 NS_ENSURE_SUCCESS(rv, rv);
475 mPlayQueueService = nsnull;
479 nsCOMPtr<sbIDeviceManager2> deviceManager =
480 do_GetService(
"@songbirdnest.com/Songbird/DeviceManager;2", &rv);
481 NS_ENSURE_SUCCESS(rv, rv);
483 nsCOMPtr<sbIDevice> device;
484 rv = deviceManager->GetDeviceForItem(viewList, getter_AddRefs(device));
485 if (NS_FAILED(rv) || !device) {
487 mViewingDeviceContent = PR_FALSE;
491 mViewingDeviceContent = PR_TRUE;
496 do_GetService(
"@mozilla.org/observer-service;1", &rv);
497 NS_ENSURE_SUCCESS(rv, rv);
499 rv = observerService->AddObserver(
this,
502 NS_ENSURE_SUCCESS(rv, rv);
510 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - Rebuild()",
this));
512 if (mShouldPreventRebuild) {
513 LOG((
"sbLocalDatabaseTreeView - Rebuild() mShouldPreventRebuild == true"
514 ", skipping rebuild."));
521 nsCOMPtr<sbIPropertyArray> sort;
522 rv = mArray->GetCurrentSort(getter_AddRefs(sort));
523 NS_ENSURE_SUCCESS(rv, rv);
525 nsCOMPtr<sbIProperty> property;
526 rv = sort->GetPropertyAt(0, getter_AddRefs(property));
527 NS_ENSURE_SUCCESS(rv, rv);
529 nsString arraySortProperty;
530 rv =
property->GetId(arraySortProperty);
531 NS_ENSURE_SUCCESS(rv, rv);
533 PRBool arraySortDirectionIsAscending;
535 rv =
property->GetValue(direction);
536 NS_ENSURE_SUCCESS(rv, rv);
537 arraySortDirectionIsAscending = direction.EqualsLiteral(
"a");
539 if (!arraySortProperty.Equals(mCurrentSortProperty) ||
540 arraySortDirectionIsAscending != mCurrentSortDirectionIsAscending) {
542 mCurrentSortProperty = arraySortProperty;
543 mCurrentSortDirectionIsAscending = arraySortDirectionIsAscending;
545 rv = UpdateColumnSortAttributes(arraySortProperty,
546 arraySortDirectionIsAscending);
547 NS_ENSURE_SUCCESS(rv, rv);
552 rv = GetRowCount(&oldRowCount);
553 NS_ENSURE_SUCCESS(rv, rv);
554 rv = mArray->GetLength(&mArrayLength);
555 NS_ENSURE_SUCCESS(rv, rv);
557 rv = GetRowCount(&newRowCount);
558 NS_ENSURE_SUCCESS(rv, rv);
560 if (mTreeBoxObject) {
564 PRInt32 delta = newRowCount - oldRowCount;
568 rv = mTreeBoxObject->RowCountChanged(oldRowCount, delta);
569 NS_ENSURE_SUCCESS(rv, rv);
571 rv = mTreeBoxObject->Invalidate();
572 NS_ENSURE_SUCCESS(rv, rv);
577 if (mManageSelection) {
587 mShouldPreventRebuild = aShouldPreventRebuild;
593 return mShouldPreventRebuild;
599 mMediaListView = nsnull;
600 mViewSelection = nsnull;
611 nsISupportsArray* aAtomArray)
613 NS_ASSERTION(!aProperties.IsEmpty(),
"Don't give this an empty string");
614 NS_ASSERTION(aAtomArray,
"Null pointer!");
616 const PRUnichar* current, *end;
617 aProperties.BeginReading(¤t, &end);
619 static const PRUnichar sSpaceChar =
' ';
622 nsCOMPtr<nsIAtomService> atomService =
623 do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv);
624 NS_ENSURE_SUCCESS(rv, rv);
629 while (current < end && *current == sSpaceChar) {
634 if (current == end) {
639 const PRUnichar* firstChar = current;
642 while (current < end && *current != sSpaceChar) {
646 nsString token(Substring(firstChar, current));
649 nsCOMPtr<nsIAtom> atom;
650 rv = atomService->GetAtom(token, getter_AddRefs(atom));
651 NS_ENSURE_SUCCESS(rv, rv);
654 if (aAtomArray->IndexOf(atom) != -1) {
658 rv = aAtomArray->AppendElement(atom);
659 NS_ENSURE_SUCCESS(rv, rv);
661 }
while (current < end);
667 PRBool
intersection(PRInt32 start1, PRInt32 end1, PRInt32 start2, PRInt32 end2, PRInt32 & intersectStart, PRInt32 & intersectEnd) {
668 PRBool
const result = end1 >= start2 && start1 <= end2;
670 intersectStart = start2;
673 intersectStart = start1;
682 sbLocalDatabaseTreeView::GetCellPropertyValue(PRInt32 aIndex,
683 nsITreeColumn *aTreeColumn,
686 NS_ENSURE_ARG_POINTER(aTreeColumn);
697 rv = GetPropertyForTreeColumn(aTreeColumn, bind);
698 NS_ENSURE_SUCCESS(rv, rv);
702 _retval.AppendInt(aIndex + 1);
707 if (mTreeBoxObject) {
710 rv = mTreeBoxObject->GetFirstVisibleRow(&first);
711 NS_ENSURE_SUCCESS(rv, rv);
712 rv = mTreeBoxObject->GetLastVisibleRow(&last);
713 NS_ENSURE_SUCCESS(rv, rv);
716 if (first >= 0 && last >= 0) {
719 PRInt32 length = last - first + 1;
721 if (mFirstCachedRow != NOT_SET && mFirstCachedRow > first) {
723 first = std::max(
std::min(first, mFirstCachedRow - length + 1),
726 if (mLastCachedRow != NOT_SET && mLastCachedRow < last) {
728 last =
std::min(std::max(last, mLastCachedRow + length - 1),
729 (PRInt32)mArrayLength + (mFakeAllRow ? 1 : 0) - 1);
731 length = last - first + 1;
733 PRInt32 intersectStart;
734 PRInt32 intersectEnd;
737 mFirstCachedRow, mLastCachedRow,
738 intersectStart, intersectEnd);
741 length -= (intersectEnd - intersectStart + 1);
745 mGuidWorkArray.SetCapacity(length);
746 mGuidWorkArray.Reset();
747 for (PRInt32 row = first;
748 row <= last && static_cast<PRUint32>(row) < mArrayLength;
752 if ((row >= mFirstCachedRow && row <= mLastCachedRow) ||
753 (mFakeAllRow && row == 0)) {
758 rv = mArray->GetGuidByIndex(TreeToArray(row), guid);
759 NS_ENSURE_SUCCESS(rv, rv);
761 rv = mGuidWorkArray.Append(guid);
762 NS_ENSURE_SUCCESS(rv, rv);
765 rv = mPropertyCache->CacheProperties(const_cast<PRUnichar const **>(
766 mGuidWorkArray.AsCharArray()),
767 mGuidWorkArray.Length());
768 NS_ENSURE_SUCCESS(rv, rv);
770 mFirstCachedRow =
first;
771 mLastCachedRow = last;
776 nsCOMPtr<sbILocalDatabaseResourcePropertyBag> bag;
777 rv = GetBag(aIndex, getter_AddRefs(bag));
778 NS_ENSURE_SUCCESS(rv, rv);
781 rv = bag->GetProperty(bind, value);
782 NS_ENSURE_SUCCESS(rv, rv);
785 nsCOMPtr<sbIPropertyInfo> info;
786 rv = mPropMan->GetPropertyInfo(bind, getter_AddRefs(info));
787 NS_ENSURE_SUCCESS(rv, rv);
790 nsCOMPtr<sbIPropertyUnitConverter>
converter;
791 rv = info->GetUnitConverter(getter_AddRefs(converter));
792 NS_ENSURE_SUCCESS(rv, rv);
798 rv = converter->AutoFormat(value,
804 rv = info->Format(value, _retval);
816 sbLocalDatabaseTreeView::SaveSelectionList()
818 NS_ASSERTION(mManageSelection,
819 "SaveSelectionList() called but we're not managing selection");
822 if (mHaveSavedSelection)
826 if (mSelectionIsAll) {
830 nsresult rv = EnumerateSelection(SelectionListSavingEnumeratorCallback,
833 NS_ENSURE_SUCCESS(rv, rv);
835 mHaveSavedSelection = PR_TRUE;
842 sbLocalDatabaseTreeView::RestoreSelection()
846 "RestoreSelection() called but we're not managing selection");
849 if (!mRealSelection) {
854 if (mSelectionIsAll) {
855 rv = mRealSelection->Select(0);
856 NS_ENSURE_SUCCESS(rv, rv);
858 else if (mHaveSavedSelection) {
860 rv = mRealSelection->ClearSelection();
861 NS_ENSURE_SUCCESS(rv, rv);
866 for (PRUint32
i = 0;
i < mArrayLength;
i++) {
868 if (!mSelectionList.Count()) {
874 rv = GetUniqueIdForIndex(
i,
id);
875 NS_ENSURE_SUCCESS(rv, rv);
878 if (mSelectionList.Get(
id, nsnull)) {
880 mSelectionList.Remove(
id);
883 PRInt32 row = ArrayToTree(
i);
884 rv = mRealSelection->ToggleSelect(row);
885 NS_ENSURE_SUCCESS(rv, rv);
893 mSelectionList.Clear();
894 mHaveSavedSelection = PR_FALSE;
901 sbLocalDatabaseTreeView::EnumerateSelection(sbSelectionEnumeratorCallbackFunc aFunc,
904 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - EnumerateSelection()",
this));
906 if (mRealSelection) {
913 nsresult rv = mRealSelection->GetRangeCount(&rangeCount);
914 NS_ENSURE_SUCCESS(rv, rv);
916 for (PRInt32
i = 0;
i < rangeCount;
i++) {
919 rv = mRealSelection->GetRangeAt(
i, &min, &max);
920 NS_ENSURE_SUCCESS(rv, rv);
922 if (min >= 0 && max >= 0) {
923 for (PRInt32 j = min; j <= max; j++) {
930 PRUint32 index = TreeToArray(j);
931 rv = GetUniqueIdForIndex(index,
id);
932 NS_ENSURE_SUCCESS(rv, rv);
935 rv = mArray->GetGuidByIndex(index, guid);
936 NS_ENSURE_SUCCESS(rv, rv);
938 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SaveSelectionList() - "
939 "saving %s from index %d guid %s",
940 this, NS_ConvertUTF16toUTF8(
id).
get(), index,
941 NS_ConvertUTF16toUTF8(guid).
get()));
943 rv = aFunc(index,
id, guid, aUserData);
944 NS_ENSURE_SUCCESS(rv, rv);
948 NS_WARNING(
"Bad value returned from nsTreeSelection::GetRangeAt");
958 sbLocalDatabaseTreeView::GetUniqueIdForIndex(PRUint32 aIndex, nsAString& aId)
965 if (mListType == eDistinct) {
966 rv = mArray->GetSortPropertyValueByIndex(aIndex, aId);
967 NS_ENSURE_SUCCESS(rv, rv);
972 nsCOMPtr<sbIMediaList> list;
973 rv = mMediaListView->GetMediaList(getter_AddRefs(list));
974 NS_ENSURE_SUCCESS(rv, rv);
977 rv = list->GetGuid(guid);
978 NS_ENSURE_SUCCESS(rv, rv);
983 rv = mArray->GetGuidByIndex(aIndex, guid);
984 NS_ENSURE_SUCCESS(rv, rv);
989 rv = mArray->GetRowidByIndex(aIndex, &rowid);
990 NS_ENSURE_SUCCESS(rv, rv);
998 sbLocalDatabaseTreeView::SetSelectionIsAll(PRBool aSelectionIsAll) {
1000 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SetSelectionIsAll(%d)",
1001 this, aSelectionIsAll));
1002 NS_ASSERTION(mManageSelection,
1003 "SetSelectionIsAll() called but we're not managing selection");
1005 mSelectionIsAll = aSelectionIsAll;
1009 if (mSelectionIsAll) {
1010 ClearSelectionList();
1016 sbLocalDatabaseTreeView::ClearSelectionList() {
1018 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - ClearSelectionList()",
this));
1019 NS_ASSERTION(mManageSelection,
1020 "ClearSelectionList() called but we're not managing selection");
1022 mSelectionList.Clear();
1023 mHaveSavedSelection = PR_FALSE;
1027 sbLocalDatabaseTreeView::UpdateColumnSortAttributes(
const nsAString& aProperty,
1032 if (!mTreeBoxObject) {
1033 NS_WARNING(
"Unable to update column sort attributes, no box object!");
1037 nsCOMPtr<nsITreeColumns>
columns;
1038 rv = mTreeBoxObject->GetColumns(getter_AddRefs(columns));
1039 NS_ENSURE_SUCCESS(rv, rv);
1042 rv = columns->GetCount(&count);
1043 NS_ENSURE_SUCCESS(rv, rv);
1045 for (PRInt32
i = 0;
i <
count;
i++) {
1046 nsCOMPtr<nsITreeColumn> column;
1047 rv = columns->GetColumnAt(
i, getter_AddRefs(column));
1048 NS_ENSURE_SUCCESS(rv, rv);
1051 NS_WARNING(
"Failed to find column!");
1055 nsCOMPtr<nsIDOMElement>
element;
1056 rv = column->GetElement(getter_AddRefs(element));
1057 NS_ENSURE_SUCCESS(rv, rv);
1060 rv = element->GetAttribute(NS_LITERAL_STRING(
"bind"), bind);
1061 NS_ENSURE_SUCCESS(rv, rv);
1063 if (bind.Equals(aProperty)) {
1064 rv = element->SetAttribute(NS_LITERAL_STRING(
"sortActive"),
1065 NS_LITERAL_STRING(
"true"));
1066 NS_ENSURE_SUCCESS(rv, rv);
1070 direction.AssignLiteral(
"ascending");
1073 direction.AssignLiteral(
"descending");
1075 rv = element->SetAttribute(NS_LITERAL_STRING(
"sortDirection"),
1077 NS_ENSURE_SUCCESS(rv, rv);
1080 rv = element->RemoveAttribute(NS_LITERAL_STRING(
"sortActive"));
1081 NS_ENSURE_SUCCESS(rv, rv);
1082 rv = element->RemoveAttribute(NS_LITERAL_STRING(
"sortDirection"));
1083 NS_ENSURE_SUCCESS(rv, rv);
1093 NS_ENSURE_ARG_POINTER(aState);
1097 nsRefPtr<sbLocalDatabaseTreeViewState> state =
1099 NS_ENSURE_TRUE(state, NS_ERROR_OUT_OF_MEMORY);
1102 NS_ENSURE_SUCCESS(rv, rv);
1105 NS_ENSURE_SUCCESS(rv, rv);
1107 rv = state->mSort->Init(mCurrentSortProperty,
1108 mCurrentSortDirectionIsAscending);
1109 NS_ENSURE_SUCCESS(rv, rv);
1111 if (mSelectionIsAll) {
1112 state->mSelectionIsAll = PR_TRUE;
1116 &state->mSelectionList);
1117 rv = EnumerateSelection(SelectionListSavingEnumeratorCallback,
1118 &state->mSelectionList);
1119 NS_ENSURE_SUCCESS(rv, rv);
1125 state->ToString(buff);
1126 LOG((
"sbLocalDatabaseTreeView::GetState[0x%.8x] - returning %s",
1127 this, NS_LossyConvertUTF16toASCII(buff).
get()));
1131 state.forget(aState);
1137 sbLocalDatabaseTreeView::SetSort(
const nsAString& aProperty, PRBool aDirection)
1139 LOG((
"sbLocalDatabaseTreeView[0x%.8x] - SetSort(%s, %d)",
1140 this, NS_LossyConvertUTF16toASCII(aProperty).
get(), aDirection));
1144 nsCOMPtr<sbIMediaList> list;
1145 rv = mMediaListView->GetMediaList(getter_AddRefs(list));
1146 NS_ENSURE_SUCCESS(rv, rv);
1148 nsString isSortable;
1150 NS_ENSURE_SUCCESS(rv, rv);
1152 if (isSortable.Equals(NS_LITERAL_STRING(
"0"))) {
1154 return NS_ERROR_FAILURE;
1159 nsString sortProperty;
1160 sortProperty = aProperty;
1167 if (mListType != eDistinct) {
1168 NS_ENSURE_STATE(mMediaListView);
1170 nsCOMPtr<sbIMutablePropertyArray> newSort =
1172 NS_ENSURE_SUCCESS(rv, rv);
1174 rv = newSort->SetStrict(PR_FALSE);
1175 NS_ENSURE_SUCCESS(rv, rv);
1177 rv = newSort->AppendProperty(aProperty,
1179 NS_LITERAL_STRING(
"a") :
1180 NS_LITERAL_STRING(
"d"));
1181 NS_ENSURE_SUCCESS(rv, rv);
1183 nsCOMPtr<sbISortableMediaListView> sortable =
1185 NS_ENSURE_SUCCESS(rv, rv);
1187 rv = sortable->SetSort(newSort);
1188 NS_ENSURE_SUCCESS(rv, rv);
1194 rv = mArray->ClearSorts();
1195 NS_ENSURE_SUCCESS(rv, rv);
1197 rv = mArray->AddSort(sortProperty, aDirection);
1198 NS_ENSURE_SUCCESS(rv, rv);
1200 rv = mArray->Invalidate(PR_FALSE);
1201 NS_ENSURE_SUCCESS(rv, rv);
1204 mCurrentSortProperty = aProperty;
1205 mCurrentSortDirectionIsAscending = aDirection;
1207 rv = UpdateColumnSortAttributes(aProperty, aDirection);
1208 NS_ENSURE_SUCCESS(rv, rv);
1214 sbLocalDatabaseTreeView::InvalidateRowsByGuid(
const nsAString& aGuid)
1216 LOG((
"sbLocalDatabaseTreeView[0x%.8x] - InvalidateRowsByGuid(%s)",
1217 this, NS_LossyConvertUTF16toASCII(aGuid).
get()));
1219 if (mTreeBoxObject) {
1222 nsresult rv = mTreeBoxObject->GetFirstVisibleRow(&first);
1223 NS_ENSURE_SUCCESS(rv, rv);
1224 rv = mTreeBoxObject->GetLastVisibleRow(&last);
1225 NS_ENSURE_SUCCESS(rv, rv);
1227 if (first >= 0 && last >= 0) {
1229 rv = mArray->GetLength(&length);
1230 NS_ENSURE_SUCCESS(rv, rv);
1232 PRInt32 rowCount = ArrayToTree(length);
1234 if (last >= rowCount)
1235 last = rowCount - 1;
1237 for (PRInt32 row = first; row <= last; row++) {
1239 rv = mArray->GetGuidByIndex(TreeToArray(row), guid);
1240 NS_ENSURE_SUCCESS(rv, rv);
1241 if (guid.Equals(aGuid)) {
1242 rv = mTreeBoxObject->InvalidateRow(row);
1243 NS_ENSURE_SUCCESS(rv, rv);
1254 sbLocalDatabaseTreeView::SetMouseState(PRInt32 aRow,
1255 nsITreeColumn* aColumn,
1259 PRInt32 colIndex = -1;
1261 aColumn->GetIndex(&colIndex);
1263 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SetMouseState(%d, %d, %d)",
this,
1264 aRow, colIndex, aState));
1269 if (mMouseState && mMouseStateRow >= 0 && mMouseStateColumn) {
1271 if (mTreeBoxObject) {
1272 rv = mTreeBoxObject->InvalidateCell(mMouseStateRow, mMouseStateColumn);
1273 NS_ENSURE_SUCCESS(rv, rv);
1278 mMouseStateRow = aRow;
1279 mMouseStateColumn = aColumn;
1281 if (mMouseStateRow >= 0 && mMouseStateColumn && mTreeBoxObject) {
1282 rv = mTreeBoxObject->InvalidateCell(mMouseStateRow, mMouseStateColumn);
1283 NS_ENSURE_SUCCESS(rv, rv);
1290 sbLocalDatabaseTreeView::GetSelectionIsAll(PRBool* aSelectionIsAll)
1292 NS_ENSURE_ARG_POINTER(aSelectionIsAll);
1293 NS_ASSERTION(mManageSelection,
1294 "GetSelectionIsAll() called but we're not managing selection");
1296 *aSelectionIsAll = mSelectionIsAll;
1303 NS_ENSURE_ARG_POINTER(aValues);
1304 NS_ASSERTION(mManageSelection,
1305 "GetSelectedValues() called but we're not managing selection");
1308 if (mSelectionIsAll) {
1309 nsTArray<nsString>
empty;
1310 nsCOMPtr<nsIStringEnumerator> enumerator =
1312 NS_ENSURE_TRUE(enumerator, NS_ERROR_OUT_OF_MEMORY);
1314 enumerator.forget(aValues);
1318 nsTArray<nsString> guids;
1319 rv = EnumerateSelection(SelectionListGuidsEnumeratorCallback, &guids);
1320 NS_ENSURE_SUCCESS(rv, rv);
1324 NS_ENSURE_SUCCESS(rv, rv);
1326 PRUint32 length = guids.Length();
1327 nsTArray<nsString> values(length);
1328 for (PRUint32
i = 0;
i < length;
i++) {
1330 nsCOMPtr<sbILocalDatabaseResourcePropertyBag> bag;
1331 rv = GetBag(guids[
i], getter_AddRefs(bag));
1332 NS_ENSURE_SUCCESS(rv, rv);
1335 rv = bag->GetProperty(mCurrentSortProperty, value);
1336 NS_ENSURE_SUCCESS(rv, rv);
1338 nsString* appended = values.AppendElement(value);
1339 NS_ENSURE_TRUE(appended, NS_ERROR_OUT_OF_MEMORY);
1342 nsCOMPtr<nsIStringEnumerator> enumerator =
1344 NS_ENSURE_TRUE(enumerator, NS_ERROR_OUT_OF_MEMORY);
1346 enumerator.forget(aValues);
1352 sbLocalDatabaseTreeView::OnBeforeInvalidate(PRBool aInvalidateLength)
1355 mGuidWorkArray.Reset();
1356 mLastCachedRow = mFirstCachedRow = NOT_SET;
1358 if (mManageSelection) {
1359 nsresult rv = SaveSelectionList();
1360 NS_ENSURE_SUCCESS(rv, rv);
1367 sbLocalDatabaseTreeView::OnAfterInvalidate()
1372 NS_ENSURE_SUCCESS(rv, rv);
1378 sbLocalDatabaseTreeView::GetPropertyForTreeColumn(nsITreeColumn* aTreeColumn,
1379 nsAString& aProperty)
1381 NS_ENSURE_ARG_POINTER(aTreeColumn);
1385 nsCOMPtr<nsIDOMElement>
element;
1386 rv = aTreeColumn->GetElement(getter_AddRefs(element));
1387 NS_ENSURE_SUCCESS(rv, rv);
1389 rv = element->GetAttribute(NS_LITERAL_STRING(
"bind"), aProperty);
1390 NS_ENSURE_SUCCESS(rv, rv);
1396 sbLocalDatabaseTreeView::GetTreeColumnForProperty(
const nsAString& aProperty,
1397 nsITreeColumn** aTreeColumn)
1399 NS_ENSURE_ARG_POINTER(aTreeColumn);
1400 NS_ENSURE_STATE(mTreeBoxObject);
1402 nsCOMPtr<nsITreeColumns>
columns;
1403 nsresult rv = mTreeBoxObject->GetColumns(getter_AddRefs(columns));
1404 NS_ENSURE_SUCCESS(rv, rv);
1407 rv = columns->GetCount(&count);
1408 NS_ENSURE_SUCCESS(rv, rv);
1410 for (PRInt32 i = 0; i <
count; i++) {
1411 nsCOMPtr<nsITreeColumn> column;
1412 rv = columns->GetColumnAt(i, getter_AddRefs(column));
1413 NS_ENSURE_SUCCESS(rv, rv);
1415 nsCOMPtr<nsIDOMElement>
element;
1416 rv = column->GetElement(getter_AddRefs(element));
1417 NS_ENSURE_SUCCESS(rv, rv);
1420 rv = element->GetAttribute(NS_LITERAL_STRING(
"bind"), bind);
1421 NS_ENSURE_SUCCESS(rv, rv);
1423 if (bind.Equals(aProperty)) {
1424 column.forget(aTreeColumn);
1429 return NS_ERROR_NOT_AVAILABLE;
1433 sbLocalDatabaseTreeView::GetColumnPropertyInfo(nsITreeColumn* aColumn,
1436 nsString propertyID;
1437 nsresult rv = GetPropertyForTreeColumn(aColumn, propertyID);
1438 NS_ENSURE_SUCCESS(rv, rv);
1440 rv = mPropMan->GetPropertyInfo(propertyID, aPropertyInfo);
1441 NS_ENSURE_SUCCESS(rv, rv);
1447 sbLocalDatabaseTreeView::GetPropertyInfoAndValue(PRInt32 aRow,
1448 nsITreeColumn* aColumn,
1452 NS_ASSERTION(aColumn,
"aColumn is null");
1453 NS_ASSERTION(aPropertyInfo,
"aPropertyInfo is null");
1456 PRUint32 index = TreeToArray(aRow);
1457 nsCOMPtr<sbILocalDatabaseResourcePropertyBag> bag;
1458 rv = GetBag(index, getter_AddRefs(bag));
1459 NS_ENSURE_SUCCESS(rv, rv);
1461 nsCOMPtr<sbIPropertyInfo> pi;
1462 rv = GetColumnPropertyInfo(aColumn, getter_AddRefs(pi));
1463 NS_ENSURE_SUCCESS(rv, rv);
1465 nsString propertyID;
1466 rv = pi->GetId(propertyID);
1467 NS_ENSURE_SUCCESS(rv, rv);
1470 rv = bag->GetProperty(propertyID, aValue);
1471 NS_ENSURE_SUCCESS(rv, rv);
1473 pi.forget(aPropertyInfo);
1478 sbLocalDatabaseTreeView::GetPlayingProperty(PRUint32 aIndex,
1479 nsISupportsArray* properties)
1481 NS_ASSERTION(properties,
"properties is null");
1491 if (!mPlayingItemUID.IsEmpty()) {
1493 rv = GetUniqueIdForIndex(aIndex, uid);
1494 NS_ENSURE_SUCCESS(rv, rv);
1496 if (mPlayingItemUID.Equals(uid)) {
1498 NS_ENSURE_SUCCESS(rv, rv);
1509 sbLocalDatabaseTreeView::GetOriginNotInMainLibraryProperty
1510 (PRUint32 aIndex, nsISupportsArray* properties)
1512 NS_ASSERTION(properties,
"properties is null");
1522 if (!mViewingDeviceContent) {
1528 nsCOMPtr<sbILocalDatabaseResourcePropertyBag> bag;
1529 rv = GetBag(aIndex, getter_AddRefs(bag));
1530 NS_ENSURE_SUCCESS(rv, rv);
1532 nsString originInMainLibrary;
1533 rv = bag->GetProperty
1535 originInMainLibrary);
1536 NS_ENSURE_SUCCESS(rv, rv);
1539 if (!originInMainLibrary.EqualsLiteral(
"1")) {
1541 NS_ENSURE_SUCCESS(rv, rv);
1548 sbLocalDatabaseTreeView::GetItemDisabledStatus(PRUint32 aIndex,
1549 nsISupportsArray* properties)
1551 NS_ASSERTION(properties,
"properties is null");
1570 rv = mArray->GetGuidByIndex(aIndex, guid);
1571 NS_ENSURE_SUCCESS(rv, rv);
1573 nsCOMPtr<sbIMediaList> mediaList;
1574 rv = mMediaListView->GetMediaList(getter_AddRefs(mediaList));
1575 NS_ENSURE_SUCCESS(rv, rv);
1577 nsCOMPtr<sbILibrary> library;
1578 rv = mediaList->GetLibrary(getter_AddRefs(library));
1579 NS_ENSURE_SUCCESS(rv, rv);
1581 nsCOMPtr<sbIMediaItem> mediaItem;
1582 rv = library->GetMediaItem(guid, getter_AddRefs(mediaItem));
1583 NS_ENSURE_SUCCESS(rv, rv);
1585 nsCOMPtr<sbIMediaItemController> mediaItemController;
1586 rv = mediaItem->GetItemController(getter_AddRefs(mediaItemController));
1587 NS_ENSURE_SUCCESS(rv, rv);
1589 if (!mediaItemController)
1592 PRBool itemDisabled;
1593 rv = mediaItemController->IsItemDisabled(mediaItem, &itemDisabled);
1594 NS_ENSURE_SUCCESS(rv, rv);
1598 NS_ENSURE_SUCCESS(rv, rv);
1605 sbLocalDatabaseTreeView::GetPlayQueueStatus(PRUint32 aIndex,
1606 nsISupportsArray* properties)
1608 NS_ASSERTION(properties,
"properties is null");
1618 if (aIndex < mPlayQueueIndex) {
1620 NS_ENSURE_SUCCESS(rv, rv);
1621 }
else if (aIndex == mPlayQueueIndex) {
1623 NS_ENSURE_SUCCESS(rv, rv);
1630 sbLocalDatabaseTreeView::GetIsListReadOnly(PRBool *aOutIsReadOnly)
1632 NS_ENSURE_ARG_POINTER(aOutIsReadOnly);
1642 nsCOMPtr<sbIMediaList> mediaList;
1643 rv = mMediaListView->GetMediaList(getter_AddRefs(mediaList));
1644 NS_ENSURE_SUCCESS(rv, rv);
1646 nsString isReadOnly;
1649 NS_ENSURE_SUCCESS(rv, rv);
1651 *aOutIsReadOnly = isReadOnly.EqualsLiteral(
"1");
1656 sbLocalDatabaseTreeView::GetBag(PRUint32 aIndex,
1659 NS_ASSERTION(aBag,
"aBag is null!");
1663 rv = mArray->GetGuidByIndex(aIndex, guid);
1664 NS_ENSURE_SUCCESS(rv, rv);
1666 rv = GetBag(guid, aBag);
1667 NS_ENSURE_SUCCESS(rv, rv);
1673 sbLocalDatabaseTreeView::GetBag(
const nsAString& aGuid,
1676 NS_ASSERTION(aBag,
"aBag is null!");
1679 const PRUnichar* guidptr = aGuid.BeginReading();
1683 rv = mPropertyCache->GetProperties(&guidptr, 1, &count, &bags);
1684 NS_ENSURE_SUCCESS(rv, rv);
1686 nsCOMPtr<sbILocalDatabaseResourcePropertyBag> bag;
1687 if (count == 1 && bags[0]) {
1690 NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, bags);
1693 return NS_ERROR_NOT_AVAILABLE;
1701 sbLocalDatabaseTreeView::GetRowCount(PRInt32 *aRowCount)
1703 NS_ENSURE_ARG_POINTER(aRowCount);
1711 *aRowCount = mArrayLength + (mFakeAllRow ? 1 : 0);
1716 sbLocalDatabaseTreeView::GetCellText(PRInt32 row,
1720 NS_ENSURE_ARG_POINTER(col);
1730 if (IsAllRow(row)) {
1731 _retval.Assign(mLocalizedAll);
1735 rv = GetCellPropertyValue(TreeToArray(row), col, _retval);
1736 NS_ENSURE_SUCCESS(rv, rv);
1744 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - GetSelection()",
this));
1747 NS_ENSURE_ARG_POINTER(aSelection);
1748 NS_IF_ADDREF(*aSelection = mSelection);
1753 sbLocalDatabaseTreeView::SetSelection(nsITreeSelection* aSelection)
1755 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SetSelection(0x%.8x)",
this, aSelection));
1757 NS_ENSURE_ARG_POINTER(aSelection);
1761 if (mListType == eDistinct) {
1763 NS_ENSURE_TRUE(mSelection, NS_ERROR_OUT_OF_MEMORY);
1766 NS_ASSERTION(mViewSelection,
"SetSelection called but no mViewSelection");
1768 NS_ENSURE_TRUE(mSelection, NS_ERROR_OUT_OF_MEMORY);
1773 mRealSelection = aSelection;
1776 if (mManageSelection) {
1784 sbLocalDatabaseTreeView::CycleHeader(nsITreeColumn* col)
1786 NS_ENSURE_ARG_POINTER(col);
1789 nsCOMPtr<sbIMediaList> mediaList;
1790 rv = mMediaListView->GetMediaList(getter_AddRefs(mediaList));
1791 NS_ENSURE_SUCCESS(rv, rv);
1794 nsString isSortable;
1797 NS_ENSURE_SUCCESS(rv, rv);
1798 if (isSortable.EqualsLiteral(
"0")) {
1803 rv = GetPropertyForTreeColumn(col, bind);
1804 NS_ENSURE_SUCCESS(rv, rv);
1806 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - CycleHeader %s",
this,
1807 NS_LossyConvertUTF16toASCII(bind).
get()));
1809 PRBool directionIsAscending = PR_TRUE;
1810 if (bind.Equals(mCurrentSortProperty)) {
1811 directionIsAscending = !mCurrentSortDirectionIsAscending;
1814 rv = SetSort(bind, directionIsAscending);
1815 NS_ENSURE_SUCCESS(rv, rv);
1818 nsCOMPtr<sbIMediaListViewTreeViewObserver>
observer =
1819 do_QueryReferent(mObserver);
1821 rv = observer->CycleHeader(col);
1822 NS_ENSURE_SUCCESS(rv, rv);
1830 sbLocalDatabaseTreeView::CycleCell(PRInt32 row,
1833 NS_ENSURE_ARG_POINTER(col);
1835 return NS_ERROR_NOT_IMPLEMENTED;
1839 sbLocalDatabaseTreeView::GetRowProperties(PRInt32 row,
1840 nsISupportsArray* properties)
1842 NS_ENSURE_ARG_MIN(row, 0);
1843 NS_ENSURE_ARG_POINTER(properties);
1847 PRUint32 index = TreeToArray(row);
1856 properties->Count(&count);
1858 for (PRUint32 i = 0; i <
count; i++) {
1859 nsCOMPtr<nsIAtom> atom;
1860 properties->QueryElementAt(i, NS_GET_IID(nsIAtom), getter_AddRefs(atom));
1865 props.AppendLiteral(
" ");
1869 if (IsAllRow(row)) {
1871 NS_ENSURE_SUCCESS(rv, rv);
1875 rv = GetPlayingProperty(index, properties);
1876 NS_ENSURE_SUCCESS(rv, rv);
1878 rv = GetOriginNotInMainLibraryProperty(index, properties);
1879 NS_ENSURE_SUCCESS(rv, rv);
1881 rv = GetItemDisabledStatus(index, properties);
1882 NS_ENSURE_SUCCESS(rv, rv);
1884 if (mPlayQueueService) {
1885 rv = GetPlayQueueStatus(index, properties);
1886 NS_ENSURE_SUCCESS(rv, rv);
1889 nsCOMPtr<sbILocalDatabaseResourcePropertyBag> bag;
1890 rv = GetBag(index, getter_AddRefs(bag));
1891 NS_ENSURE_SUCCESS(rv, rv);
1893 nsCOMPtr<nsIStringEnumerator> propertyEnumerator;
1894 rv = mPropMan->GetPropertyIDs(getter_AddRefs(propertyEnumerator));
1895 NS_ENSURE_SUCCESS(rv, rv);
1897 nsString propertyID;
1898 while (NS_SUCCEEDED(propertyEnumerator->GetNext(propertyID))) {
1901 nsresult rv = bag->GetProperty(propertyID, value);
1902 NS_ENSURE_SUCCESS(rv, rv);
1904 nsCOMPtr<sbIPropertyInfo> propInfo;
1905 rv = mPropMan->GetPropertyInfo(propertyID, getter_AddRefs(propInfo));
1906 NS_ENSURE_SUCCESS(rv, rv);
1908 nsCOMPtr<sbITreeViewPropertyInfo> tvpi = do_QueryInterface(propInfo, &rv);
1909 if (NS_SUCCEEDED(rv)) {
1910 nsString propertiesString;
1911 rv = tvpi->GetRowProperties(value, propertiesString);
1912 NS_ENSURE_SUCCESS(rv, rv);
1914 if (!propertiesString.IsEmpty()) {
1916 NS_ENSURE_SUCCESS(rv, rv);
1925 sbLocalDatabaseTreeView::GetCellProperties(PRInt32 row,
1927 nsISupportsArray* properties)
1929 NS_ENSURE_ARG_MIN(row, 0);
1930 NS_ENSURE_ARG_POINTER(col);
1931 NS_ENSURE_ARG_POINTER(properties);
1940 PRInt32 colIndex = -1;
1941 col->GetIndex(&colIndex);
1943 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - GetCellProperties(%d, %d)",
this,
1947 if (IsAllRow(row)) {
1953 rv = GetColumnProperties(col, properties);
1954 NS_ENSURE_SUCCESS(rv, rv);
1957 if (mMouseStateRow == row && mMouseStateColumn == col) {
1958 switch(mMouseState) {
1961 NS_ENSURE_SUCCESS(rv, rv);
1965 NS_ENSURE_SUCCESS(rv, rv);
1970 PRUint32 index = TreeToArray(row);
1972 rv = GetPlayingProperty(index, properties);
1973 NS_ENSURE_SUCCESS(rv, rv);
1975 rv = GetOriginNotInMainLibraryProperty(index, properties);
1976 NS_ENSURE_SUCCESS(rv, rv);
1978 rv = GetItemDisabledStatus(index, properties);
1979 NS_ENSURE_SUCCESS(rv, rv);
1981 if (mPlayQueueService) {
1982 rv = GetPlayQueueStatus(index, properties);
1983 NS_ENSURE_SUCCESS(rv, rv);
1986 nsCOMPtr<sbIPropertyInfo> pi;
1988 rv = GetPropertyInfoAndValue(row, col, value, getter_AddRefs(pi));
1989 NS_ENSURE_SUCCESS(rv, rv);
1991 nsCOMPtr<sbITreeViewPropertyInfo> tvpi = do_QueryInterface(pi, &rv);
1992 if (NS_SUCCEEDED(rv)) {
1993 nsString propertiesString;
1994 rv = tvpi->GetCellProperties(value, propertiesString);
1995 NS_ENSURE_SUCCESS(rv, rv);
1997 if (!propertiesString.IsEmpty()) {
1999 NS_ENSURE_SUCCESS(rv, rv);
2003 nsCOMPtr<sbIClickablePropertyInfo> cpi = do_QueryInterface(pi, &rv);
2004 if (NS_SUCCEEDED(rv)) {
2006 rv = cpi->IsDisabled(value, &isDisabled);
2007 NS_ENSURE_SUCCESS(rv, rv);
2011 NS_ENSURE_SUCCESS(rv, rv);
2016 PRBool isMediaListReadOnly;
2017 rv = GetIsListReadOnly(&isMediaListReadOnly);
2018 if (NS_SUCCEEDED(rv) && isMediaListReadOnly) {
2020 NS_ENSURE_SUCCESS(rv, rv);
2027 sbLocalDatabaseTreeView::GetColumnProperties(nsITreeColumn* col,
2028 nsISupportsArray* properties)
2030 NS_ENSURE_ARG_POINTER(col);
2031 NS_ENSURE_ARG_POINTER(properties);
2033 nsString propertyID;
2034 nsresult rv = GetPropertyForTreeColumn(col, propertyID);
2035 NS_ENSURE_SUCCESS(rv, rv);
2046 static const PRUnichar kHyphenChar =
'-';
2048 for (PRUint32 index = 0; index < propertyID.Length(); index++) {
2049 PRUnichar testChar = propertyID.CharAt(index);
2052 if ((testChar >= 97 && testChar <= 122) ||
2053 (testChar >= 65 && testChar <= 90) ||
2054 (testChar >= 48 && testChar <= 57)) {
2058 PRInt32 badCharIndex= badChars.FindChar(testChar);
2059 if (badCharIndex > -1) {
2060 if (index > 0 && propertyID.CharAt(index - 1) == kHyphenChar) {
2061 propertyID.Replace(index, 1, nsnull, 0);
2065 propertyID.Replace(index, 1, kHyphenChar);
2071 NS_ENSURE_SUCCESS(rv, rv);
2077 sbLocalDatabaseTreeView::IsContainer(PRInt32 row, PRBool* _retval)
2079 NS_ENSURE_ARG_POINTER(_retval);
2081 *_retval = PR_FALSE;
2087 sbLocalDatabaseTreeView::IsContainerOpen(PRInt32 row, PRBool* _retval)
2089 NS_ENSURE_ARG_POINTER(_retval);
2091 *_retval = PR_FALSE;
2097 sbLocalDatabaseTreeView::IsContainerEmpty(PRInt32 row, PRBool* _retval)
2099 NS_ENSURE_ARG_POINTER(_retval);
2107 sbLocalDatabaseTreeView::IsSeparator(PRInt32 row, PRBool* _retval)
2109 NS_ENSURE_ARG_POINTER(_retval);
2111 *_retval = PR_FALSE;
2117 sbLocalDatabaseTreeView::IsSorted(PRBool* _retval)
2119 NS_ENSURE_ARG_POINTER(_retval);
2127 sbLocalDatabaseTreeView::CanDrop(PRInt32 row,
2128 PRInt32 orientation,
2129 nsIDOMDataTransfer* dataTransfer,
2132 NS_ENSURE_ARG_POINTER(_retval);
2134 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - CanDrop(%d, %d)",
this,
2137 if (!IsAllRow(row) && mObserver) {
2139 nsCOMPtr<sbIMediaListViewTreeViewObserver> observer =
2140 do_QueryReferent(mObserver);
2142 nsresult rv = observer->CanDrop(TreeToArray(row),
2146 NS_ENSURE_SUCCESS(rv, rv);
2150 *_retval = PR_FALSE;
2157 sbLocalDatabaseTreeView::Drop(PRInt32 row,
2158 PRInt32 orientation,
2159 nsIDOMDataTransfer* dataTransfer)
2161 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - Drop(%d, %d)",
this,
2164 if (!IsAllRow(row) && mObserver) {
2166 nsCOMPtr<sbIMediaListViewTreeViewObserver> observer =
2167 do_QueryReferent(mObserver);
2169 nsresult rv = observer->Drop(TreeToArray(row), orientation, dataTransfer);
2170 NS_ENSURE_SUCCESS(rv, rv);
2178 sbLocalDatabaseTreeView::GetParentIndex(PRInt32 rowIndex, PRInt32* _retval)
2180 NS_ENSURE_ARG_POINTER(_retval);
2188 sbLocalDatabaseTreeView::HasNextSibling(PRInt32 rowIndex,
2192 NS_ENSURE_ARG_POINTER(_retval);
2194 return NS_ERROR_NOT_IMPLEMENTED;
2198 sbLocalDatabaseTreeView::GetLevel(PRInt32 row, PRInt32* _retval)
2200 NS_ENSURE_ARG_POINTER(_retval);
2207 sbLocalDatabaseTreeView::GetImageSrc(PRInt32 row,
2211 NS_ENSURE_ARG_POINTER(col);
2213 if (IsAllRow(row)) {
2220 nsCOMPtr<sbIPropertyInfo> pi;
2221 rv = GetPropertyInfoAndValue(row, col, value, getter_AddRefs(pi));
2222 NS_ENSURE_SUCCESS(rv, rv);
2224 nsCOMPtr<sbITreeViewPropertyInfo> tvpi = do_QueryInterface(pi, &rv);
2225 if (NS_SUCCEEDED(rv)) {
2226 rv = tvpi->GetImageSrc(value, _retval);
2227 NS_ENSURE_SUCCESS(rv, rv);
2234 sbLocalDatabaseTreeView::GetProgressMode(PRInt32 row,
2238 NS_ENSURE_ARG_POINTER(col);
2239 NS_ENSURE_ARG_POINTER(_retval);
2241 if (IsAllRow(row)) {
2242 *_retval = nsITreeView::PROGRESS_NONE;
2249 nsCOMPtr<sbIPropertyInfo> pi;
2250 rv = GetPropertyInfoAndValue(row, col, value, getter_AddRefs(pi));
2251 NS_ENSURE_SUCCESS(rv, rv);
2253 nsCOMPtr<sbITreeViewPropertyInfo> tvpi = do_QueryInterface(pi, &rv);
2254 if (NS_SUCCEEDED(rv)) {
2255 rv = tvpi->GetProgressMode(value, _retval);
2256 NS_ENSURE_SUCCESS(rv, rv);
2258 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - GetMode(%d, %d) = %d",
this,
2259 row, col, _retval));
2265 sbLocalDatabaseTreeView::GetCellValue(PRInt32 row,
2270 PRInt32 colIndex = -1;
2271 col->GetIndex(&colIndex);
2273 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - GetCellValue(%d, %d)",
this,
2283 if (IsAllRow(row)) {
2290 nsCOMPtr<sbIPropertyInfo> pi;
2292 rv = GetPropertyInfoAndValue(row, col, value, getter_AddRefs(pi));
2293 NS_ENSURE_SUCCESS(rv, rv);
2295 nsCOMPtr<sbITreeViewPropertyInfo> tvpi = do_QueryInterface(pi, &rv);
2296 if (NS_SUCCEEDED(rv)) {
2297 rv = tvpi->GetCellValue(value, _retval);
2298 NS_ENSURE_SUCCESS(rv, rv);
2301 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - GetCellValue(%d, %d) = %s",
this,
2302 row, colIndex, NS_LossyConvertUTF16toASCII(_retval).
get()));
2308 sbLocalDatabaseTreeView::SetTree(nsITreeBoxObject *tree)
2310 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SetTree(0x%.8x)",
this, tree));
2316 mTreeBoxObject = tree;
2319 nsresult rv = UpdateColumnSortAttributes(mCurrentSortProperty,
2320 mCurrentSortDirectionIsAscending);
2321 NS_ENSURE_SUCCESS(rv, rv);
2325 NS_ENSURE_SUCCESS(rv, rv);
2330 else if (mManageSelection) {
2331 nsresult rv = SaveSelectionList();
2332 NS_ENSURE_SUCCESS(rv, rv);
2340 if (mMediacoreManager) {
2341 nsCOMPtr<sbIMediacoreEventListener> eventListener =
2343 NS_ENSURE_SUCCESS(rv, rv);
2345 nsCOMPtr<sbIMediacoreEventTarget>
target =
2346 do_QueryReferent(mMediacoreManager, &rv);
2347 NS_ENSURE_SUCCESS(rv, rv);
2350 if (!mIsListeningToPlayback) {
2352 rv = target->AddListener(eventListener);
2353 NS_ENSURE_SUCCESS(rv, rv);
2354 mIsListeningToPlayback = PR_TRUE;
2358 NS_ENSURE_SUCCESS(rv, rv);
2361 NS_WARNING(
"Tree set but we're already listening to playback!");
2365 if (mIsListeningToPlayback) {
2366 rv = target->RemoveListener(eventListener);
2367 NS_ENSURE_SUCCESS(rv, rv);
2368 mIsListeningToPlayback = PR_FALSE;
2371 NS_WARNING(
"Tree nulled but we're not listening to playback!");
2380 sbLocalDatabaseTreeView::ToggleOpenState(PRInt32 row)
2382 return NS_ERROR_NOT_IMPLEMENTED;
2386 sbLocalDatabaseTreeView::SelectionChanged()
2388 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SelectionChanged()",
this));
2394 sbLocalDatabaseTreeView::IsEditable(PRInt32 row,
2398 NS_ENSURE_ARG_POINTER(col);
2399 NS_ENSURE_ARG_POINTER(_retval);
2401 if (IsAllRow(row)) {
2402 *_retval = PR_FALSE;
2408 nsCOMPtr<sbIPropertyInfo> propInfo;
2409 rv = GetColumnPropertyInfo(col, getter_AddRefs(propInfo));
2410 NS_ENSURE_SUCCESS(rv, rv);
2412 rv = propInfo->GetUserEditable(_retval);
2413 NS_ENSURE_SUCCESS(rv, rv);
2419 sbLocalDatabaseTreeView::IsSelectable(PRInt32 row,
2423 NS_ENSURE_ARG_POINTER(col);
2424 NS_ENSURE_ARG_POINTER(_retval);
2426 return NS_ERROR_NOT_IMPLEMENTED;
2430 sbLocalDatabaseTreeView::SetCellValue(PRInt32 row,
2432 const nsAString& value)
2434 NS_ENSURE_ARG_POINTER(col);
2439 rv = col->GetIndex(&colIndex);
2440 NS_ENSURE_SUCCESS(rv, rv);
2442 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SetCellValue(%d, %d %s)",
this,
2443 row, colIndex, NS_LossyConvertUTF16toASCII(value).
get()));
2445 rv = SetCellText(row, col, value);
2446 NS_ENSURE_SUCCESS(rv, rv);
2452 sbLocalDatabaseTreeView::SetCellText(PRInt32 row,
2454 const nsAString& value)
2456 NS_ENSURE_ARG_POINTER(col);
2457 NS_ENSURE_STATE(mMediaListView);
2459 if (IsAllRow(row)) {
2466 rv = col->GetIndex(&colIndex);
2467 NS_ENSURE_SUCCESS(rv, rv);
2469 TRACE((
"sbLocalDatabaseTreeView[0x%.8x] - SetCellText(%d, %d %s)",
this,
2470 row, colIndex, NS_LossyConvertUTF16toASCII(value).
get()));
2473 nsCOMPtr<sbIPropertyInfo> info;
2474 rv = GetColumnPropertyInfo(col, getter_AddRefs(info));
2475 NS_ENSURE_SUCCESS(rv, rv);
2478 rv = GetPropertyForTreeColumn(col, bind);
2479 NS_ENSURE_SUCCESS(rv, rv);
2482 rv = mArray->GetGuidByIndex(TreeToArray(row), guid);
2483 NS_ENSURE_SUCCESS(rv, rv);
2485 nsCOMPtr<sbIMediaList> mediaList;
2486 rv = mMediaListView->GetMediaList(getter_AddRefs(mediaList));
2487 NS_ENSURE_SUCCESS(rv, rv);
2489 nsCOMPtr<sbILibrary> library;
2490 rv = mediaList->GetLibrary(getter_AddRefs(library));
2491 NS_ENSURE_SUCCESS(rv, rv);
2493 nsCOMPtr<sbIMediaItem> item;
2494 rv = library->GetMediaItem(guid, getter_AddRefs(item));
2495 NS_ENSURE_SUCCESS(rv, rv);
2498 rv = item->GetProperty(bind, oldValue);
2499 NS_ENSURE_SUCCESS(rv, rv);
2501 if (!value.Equals(oldValue)) {
2502 rv = item->SetProperty(bind, value);
2506 if (rv == NS_ERROR_ILLEGAL_VALUE) {
2511 return NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA;
2513 NS_ENSURE_SUCCESS(rv, rv);
2516 nsCOMPtr<sbIMediaListViewTreeViewObserver> observer =
2517 do_QueryReferent(mObserver);
2519 rv = observer->OnCellEdited(item, bind, oldValue);
2520 NS_ENSURE_SUCCESS(rv, rv);
2529 sbLocalDatabaseTreeView::PerformAction(
const PRUnichar* action)
2531 NS_ENSURE_ARG_POINTER(action);
2533 return NS_ERROR_NOT_IMPLEMENTED;
2537 sbLocalDatabaseTreeView::PerformActionOnRow(
const PRUnichar* action,
2540 NS_ENSURE_ARG_POINTER(action);
2542 return NS_ERROR_NOT_IMPLEMENTED;
2546 sbLocalDatabaseTreeView::PerformActionOnCell(
const PRUnichar* action,
2550 NS_ENSURE_ARG_POINTER(action);
2551 NS_ENSURE_ARG_POINTER(col);
2553 return NS_ERROR_NOT_IMPLEMENTED;
2560 sbLocalDatabaseTreeView::GetNextRowIndexForKeyNavigation(
const nsAString& aKeyString,
2561 PRUint32 aStartFrom,
2564 NS_ASSERTION(NS_IsMainThread(),
"wrong thread");
2565 NS_ENSURE_FALSE(aKeyString.IsEmpty(), NS_ERROR_INVALID_ARG);
2566 NS_ENSURE_ARG_POINTER(_retval);
2568 nsString keyString(aKeyString);
2569 PRUint32 keyStringLength = keyString.Length();
2573 ToLowerCase(keyString);
2577 nsString testString;
2578 nsresult rv = mArray->GetSortPropertyValueByIndex(aStartFrom, testString);
2579 NS_ENSURE_SUCCESS(rv, rv);
2581 if (!keyString.Compare(Substring(testString, 0, keyStringLength))) {
2582 *_retval = aStartFrom;
2587 rv = mArray->GetFirstIndexByPrefix(keyString, &index);
2588 if (NS_FAILED(rv) || (index < aStartFrom)) {
2598 *_retval = (PRInt32)index;
2611 mObserver = do_GetWeakReference(aObserver, &rv);;
2612 NS_ENSURE_SUCCESS(rv, rv);
2627 NS_ENSURE_ARG_POINTER(aObserver);
2629 *aObserver = nsnull;
2631 nsCOMPtr<sbIMediaListViewTreeViewObserver> observer =
2632 do_QueryReferent(mObserver);
2634 observer.forget(aObserver);
2647 NS_ENSURE_ARG_POINTER(aEvent);
2649 PRUint32 eventType = 0;
2650 nsresult rv = aEvent->GetType(&eventType);
2651 NS_ENSURE_SUCCESS(rv, rv);
2658 NS_ENSURE_SUCCESS(rv, rv);
2665 NS_ENSURE_SUCCESS(rv, rv);
2681 mPlayingItemUID = EmptyString();
2683 if (mTreeBoxObject) {
2684 rv = mTreeBoxObject->Invalidate();
2685 NS_ENSURE_SUCCESS(rv, rv);
2694 nsresult rv = NS_ERROR_UNEXPECTED;
2696 nsCOMPtr<sbIMediacoreManager> manager =
2697 do_QueryReferent(mMediacoreManager, &rv);
2698 NS_ENSURE_SUCCESS(rv, rv);
2700 nsCOMPtr<sbIMediacoreSequencer> sequencer;
2701 rv = manager->GetSequencer(getter_AddRefs(sequencer));
2702 NS_ENSURE_SUCCESS(rv, rv);
2704 nsCOMPtr<sbIMediaListView> playingView;
2705 rv = sequencer->GetView(getter_AddRefs(playingView));
2706 NS_ENSURE_SUCCESS(rv, rv);
2708 PRUint32 playingViewIndex = 0;
2709 rv = sequencer->GetViewPosition(&playingViewIndex);
2710 NS_ENSURE_SUCCESS(rv, rv);
2713 NS_ENSURE_SUCCESS(rv, rv);
2724 if (aView && mMediaListView) {
2725 nsCOMPtr<sbIMediaList> viewList;
2726 rv = mMediaListView->GetMediaList(getter_AddRefs(viewList));
2727 NS_ENSURE_SUCCESS(rv, rv);
2729 nsCOMPtr<sbIMediaList> playingList;
2730 rv = aView->GetMediaList(getter_AddRefs(playingList));
2731 NS_ENSURE_SUCCESS(rv, rv);
2734 rv = viewList->Equals(playingList, &equals);
2735 NS_ENSURE_SUCCESS(rv, rv);
2737 nsCOMPtr<sbIMediacoreManager> manager =
2738 do_QueryReferent(mMediacoreManager, &rv);
2739 NS_ENSURE_SUCCESS(rv, rv);
2741 nsCOMPtr<sbIMediacoreStatus> status;
2742 rv = manager->GetStatus(getter_AddRefs(status));
2743 NS_ENSURE_SUCCESS(rv, rv);
2746 rv = status->GetState(&state);
2747 NS_ENSURE_SUCCESS(rv, rv);
2753 if (equals && isPlaying) {
2755 rv = aView->GetViewItemUIDForIndex(aIndex, uid);
2756 NS_ENSURE_SUCCESS(rv, rv);
2759 rv = mMediaListView->GetIndexForViewItemUID(uid, &index);
2760 if (NS_SUCCEEDED(rv)) {
2761 rv = GetUniqueIdForIndex(index, mPlayingItemUID);
2762 NS_ENSURE_SUCCESS(rv, rv);
2765 mPlayingItemUID = EmptyString();
2769 mPlayingItemUID = EmptyString();
2773 mPlayingItemUID = EmptyString();
2776 if (mTreeBoxObject) {
2777 rv = mTreeBoxObject->Invalidate();
2778 NS_ENSURE_SUCCESS(rv, rv);
2787 NS_ENSURE_ARG_POINTER(aEvent);
2797 NS_ENSURE_SUCCESS(rv, rv);
2804 sbLocalDatabaseTreeView::OnSelectionChanged()
2806 LOG((
"sbLocalDatabaseTreeView[0x%.8x] - OnSelectionChanged",
this));
2807 if (mListType != eDistinct && mTreeBoxObject && mRealSelection) {
2809 OnCurrentIndexChanged();
2810 nsresult rv = mTreeBoxObject->Invalidate();
2811 NS_ENSURE_SUCCESS(rv, rv);
2818 sbLocalDatabaseTreeView::OnCurrentIndexChanged()
2821 PRInt32 currentIndex;
2823 if (mRealSelection && mViewSelection) {
2824 rv = mViewSelection->GetCurrentIndex(¤tIndex);
2825 NS_ENSURE_SUCCESS(rv, rv);
2827 PRBool treeIsSelected;
2828 rv = mRealSelection->IsSelected(currentIndex, &treeIsSelected);
2829 NS_ENSURE_SUCCESS(rv, rv);
2833 if (!treeIsSelected) {
2834 rv = mRealSelection->ToggleSelect(currentIndex);
2835 NS_ENSURE_SUCCESS(rv, rv);
2838 rv = mRealSelection->SetCurrentIndex(currentIndex);
2839 NS_ENSURE_SUCCESS(rv, rv);
2848 sbLocalDatabaseTreeView::OnIndexUpdated(PRUint32 aToIndex)
2858 PRUint32 oldIndex = mPlayQueueIndex;
2859 mPlayQueueIndex = aToIndex;
2862 if (mTreeBoxObject) {
2863 if (oldIndex < mPlayQueueIndex) {
2864 rv = mTreeBoxObject->InvalidateRange(oldIndex, mPlayQueueIndex);
2865 NS_ENSURE_SUCCESS(rv, rv);
2867 rv = mTreeBoxObject->InvalidateRange(mPlayQueueIndex, oldIndex);
2868 NS_ENSURE_SUCCESS(rv, rv);
2875 sbLocalDatabaseTreeView::OnQueueOperationStarted()
2881 sbLocalDatabaseTreeView::OnQueueOperationCompleted()
2888 sbLocalDatabaseTreeView::Observe(
nsISupports* aSubject,
2890 const PRUnichar*
aData)
2892 NS_ENSURE_ARG_POINTER(aTopic);
2896 rv = mTreeBoxObject->Invalidate();
2897 NS_ENSURE_SUCCESS(rv, rv);
2905 sbLocalDatabaseTreeView::GetInterfaces(PRUint32* count, nsIID***
array)
2911 sbLocalDatabaseTreeView::GetHelperForLanguage(PRUint32
language,
2919 sbLocalDatabaseTreeView::GetContractID(
char** aContractID)
2921 *aContractID = nsnull;
2926 sbLocalDatabaseTreeView::GetClassDescription(
char** aClassDescription)
2928 *aClassDescription = nsnull;
2933 sbLocalDatabaseTreeView::GetClassID(nsCID** aClassID)
2940 sbLocalDatabaseTreeView::GetImplementationLanguage(PRUint32* aImplementationLanguage)
2942 *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
2947 sbLocalDatabaseTreeView::GetFlags(PRUint32 *aFlags)
2954 sbLocalDatabaseTreeView::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc)
2956 return NS_ERROR_NOT_AVAILABLE;
2963 mSelectionIsAll(PR_FALSE)
2968 sbLocalDatabaseTreeViewState::Read(nsIObjectInputStream* aStream)
2970 NS_ENSURE_ARG_POINTER(aStream);
2974 rv = aStream->ReadObject(PR_TRUE, getter_AddRefs(
mSort));
2975 NS_ENSURE_SUCCESS(rv, rv);
2977 PRUint32 selectionCount;
2978 rv = aStream->Read32(&selectionCount);
2979 NS_ENSURE_SUCCESS(rv, rv);
2981 for (PRUint32 i = 0; i < selectionCount; i++) {
2985 rv = aStream->ReadString(key);
2986 NS_ENSURE_SUCCESS(rv, rv);
2988 rv = aStream->ReadString(entry);
2989 NS_ENSURE_SUCCESS(rv, rv);
2992 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
2995 PRBool selectionIsAll;
2996 rv = aStream->ReadBoolean(&selectionIsAll);
2997 NS_ENSURE_SUCCESS(rv, rv);
3004 sbLocalDatabaseTreeViewState::Write(nsIObjectOutputStream* aStream)
3006 NS_ENSURE_ARG_POINTER(aStream);
3010 rv = aStream->WriteObject(
mSort, PR_TRUE);
3011 NS_ENSURE_SUCCESS(rv, rv);
3014 NS_ENSURE_SUCCESS(rv, rv);
3019 NS_ENSURE_SUCCESS(rv, rv);
3028 NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
3040 rv =
mSort->ToString(temp);
3041 NS_ENSURE_SUCCESS(rv, rv);
3045 buff.AppendLiteral(
" selection ");
3047 buff.AppendLiteral(
"is all");
3051 buff.AppendLiteral(
" items");
nsDataHashtable< nsStringHashKey, nsString > sbSelectionList
NS_IMPL_ISUPPORTS1(sbLocalDatabaseTreeViewState, nsISerializable)
static nsCOMPtr< nsIObserverService > observerService
#define SB_STRING_BUNDLE_CHROME_URL
PLDHashOperator PR_CALLBACK SB_SelectionListGuidsToTArrayCallback(nsStringHashKey::KeyType aKey, nsString aEntry, void *aUserData)
friend class sbPlaylistTreeSelection
sbSelectionList mSelectionList
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
nsresult TokenizeProperties(const nsAString &aProperties, nsISupportsArray *aAtomArray)
Parses a string and separates space-delimited substrings into nsIAtom elements.
#define SB_PROPERTY_ORDINAL
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
#define SONGBIRD_LIBRARYSORT_CONTRACTID
~sbLocalDatabaseTreeView()
void SetShouldPreventRebuild(PRBool aShouldPreventRebuild)
sbAutoSuppressArrayInvalidation(sbILocalDatabaseGUIDArray *aArray)
#define SB_PROPERTY_ISSORTABLE
#define SB_PROPERTYMANAGER_CONTRACTID
NS_IMPL_THREADSAFE_ISUPPORTS10(sbLocalDatabaseTreeView, nsIClassInfo, nsIObserver, nsISupportsWeakReference, nsITreeView, sbILocalDatabaseGUIDArrayListener, sbILocalDatabaseTreeView, sbIMediaListViewTreeView, sbIMediacoreEventListener, sbIMediaListViewSelectionListener, sbIPlayQueueServiceListener) NS_IMPL_CI_INTERFACE_GETTER9(sbLocalDatabaseTreeView
sbLocalDatabaseTreeViewState()
nsCOMPtr< sbILibrarySort > mSort
#define SB_PROPERTY_CREATED
PRBool GetShouldPreventRebuild()
nsresult Init(sbLocalDatabaseMediaListView *aListView, sbILocalDatabaseGUIDArray *aArray, sbIPropertyArray *aCurrentSort, sbLocalDatabaseTreeViewState *aState)
Listener for the Play Queue service.
const unsigned long MOUSE_STATE_NONE
PRBool intersection(PRInt32 start1, PRInt32 end1, PRInt32 start2, PRInt32 end2, PRInt32 &intersectStart, PRInt32 &intersectEnd)
nsresult OnTrackIndexChange(sbIMediacoreEvent *aEvent)
#define SB_PROPERTY_ISREADONLY
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...
const unsigned long MOUSE_STATE_HOVER
#define SB_PROPERTY_ORIGIN_IS_IN_MAIN_LIBRARY
PRPackedBool mSelectionIsAll
sbAutoUpdateBatch(nsITreeBoxObject *aTreeBoxObject)
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
PLDHashOperator PR_CALLBACK SB_CopySelectionListCallback(nsStringHashKey::KeyType aKey, nsString aEntry, void *aUserData)
inst dpDiv empty().append(this._generateHTML(inst)).find('iframe.ui-datepicker-cover').css(
void ClearMediaListView()
nsresult ToString(nsAString &aStr)
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
void ClearWeakReferences()
bind("getData.datepicker", function(event, key){return this._get(inst, key);})
nsresult GetState(sbLocalDatabaseTreeViewState **aState)
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
friend class sbFilterTreeSelection
_getSelectedPageStyle s i
NS_DECL_ISUPPORTS NS_DECL_NSISERIALIZABLE nsresult Init()
_updateTextAndScrollDataForFrame aData
#define SB_INVALIDATE_ALL_TREEVIEWS_TOPIC
virtual ~sbAutoSuppressArrayInvalidation()
const unsigned long MOUSE_STATE_DOWN
PLDHashOperator PR_CALLBACK SB_SerializeSelectionListCallback(nsStringHashKey::KeyType aKey, nsString aEntry, void *aUserData)