Ejemplo n.º 1
0
/* Populate document list with records */
static void UpdateDocList( void )
    /* THROWS */
{
    /* no automatic update if user has selected to handle it manually
       or if we have a low power situation */
    if ( Prefs()->syncPolicy == SYNC_MANUAL || ! HasEnoughPower() )
        return;

    SpeedFaster();

    /* create list for documents that have been deleted since the last
       session */
    CreateRemoveList();

    ErrTry {
        /* find all Plucker documents in RAM */

        EnumerateRAM();

        /* ... and on mounted external cards */
        if ( Prefs()->syncPolicy != SYNC_IGNORE_CARD ) {
#ifdef SUPPORT_VFS_FONTS
            if ( ! ScannedVFSFonts() ) {
                EnumerateCards( ENUMERATECARD_DOCS | ENUMERATECARD_FONTS );
                PostprocessVFSFonts();
            }
            else
#endif
            {
                EnumerateCards( ENUMERATECARD_DOCS );
            }
        }

        /* clean up */
        DeactivateDocuments();

        DmInsertionSort( plkrDocList, CompareDocumentNames, 0 );
    }
    ErrCatch( err ) {
        ReleaseDeactivateList();
        ErrThrow( err );
    } ErrEndCatch

    SpeedRestore();
}
Ejemplo n.º 2
0
/* Scan VFS for fonts */
void ScanVFSFonts( void )
{
#ifdef SUPPORT_VFS_FONTS
    if ( ! scannedVFS ) {
        ErrTry {
            EnumerateCards( ENUMERATECARD_FONTS );
            PostprocessVFSFonts();
        }
        ErrCatch( UNUSED_PARAM( err ) ) {
        } ErrEndCatch
    }
Ejemplo n.º 3
0
NS_IMETHODIMP nsAbView::SetView(nsIAbDirectory *aAddressBook,
                                nsIAbViewListener *aAbViewListener,
                                const nsAString &aSortColumn,
                                const nsAString &aSortDirection,
                                nsAString &aResult)
{
  // Ensure we are initialized
  nsresult rv = Initialize();

  mAbViewListener = nsnull;
  if (mTree)
  {
    // Try and speed deletion of old cards by disconnecting the tree from us.
    mTreeSelection->ClearSelection();
    mTree->SetView(nsnull);
  }

  // Clear out old cards
  PRInt32 i = mCards.Count();
  while(i-- > 0)
  {
    rv = RemoveCardAt(i);
    NS_ASSERTION(NS_SUCCEEDED(rv), "remove card failed\n");
  }

  mDirectory = aAddressBook;

  rv = EnumerateCards();
  NS_ENSURE_SUCCESS(rv, rv);

  NS_NAMED_LITERAL_STRING(generatedNameColumnId, GENERATED_NAME_COLUMN_ID);

  // See if the persisted sortColumn is valid.
  // It may not be, if you migrated from older versions, or switched between
  // a mozilla build and a commercial build, which have different columns.
  nsAutoString actualSortColumn;
  if (!generatedNameColumnId.Equals(aSortColumn) && mCards.Count()) {
    nsIAbCard *card = ((AbCard *)(mCards.ElementAt(0)))->card;
    nsString value;
    // XXX todo
    // Need to check if _Generic is valid.  GetCardValue() will always return NS_OK for _Generic
    // We're going to have to ask mDirectory if it is.
    // It might not be.  example:  _ScreenName is valid in Netscape, but not Mozilla.
    rv = GetCardValue(card, PromiseFlatString(aSortColumn).get(), value);
    if (NS_FAILED(rv))
      actualSortColumn = generatedNameColumnId;
    else
      actualSortColumn = aSortColumn;
  }
  else
    actualSortColumn = aSortColumn;

  rv = SortBy(actualSortColumn.get(), PromiseFlatString(aSortDirection).get());
  NS_ENSURE_SUCCESS(rv, rv);

  mAbViewListener = aAbViewListener;
  if (mAbViewListener && !mSuppressCountChange) {
    rv = mAbViewListener->OnCountChanged(mCards.Count());
    NS_ENSURE_SUCCESS(rv, rv);
  }

  aResult = actualSortColumn;
  return NS_OK;
}