err = row->AliasCellYarn(mEnv, kToken_LastVisitDateColumn, &yarn);
nsMdbPtr<nsIMdbCell> cell(mEnv); err = row->GetCell(mEnv, kToken_LastVisitDateColumn, getter_Acquires(cell));
nsGlobalHistory::GetTarget(nsIRDFResource* aSource,                           nsIRDFResource* aProperty,                           PRBool aTruthValue,                           nsIRDFNode** aTarget){  NS_PRECONDITION(aSource != nsnull, "null ptr");  if (! aSource)    return NS_ERROR_NULL_POINTER;  NS_PRECONDITION(aProperty != nsnull, "null ptr");  if (! aProperty)    return NS_ERROR_NULL_POINTER;  nsresult rv;  // Initialize return value.  *aTarget = nsnull;  // Only "positive" assertions here.  if (! aTruthValue)    return NS_RDF_NO_VALUE;  if ((aSource == kNC_HistoryRoot) && (aProperty == kNC_child)) {    // If they're asking for all the children of the HistoryRoot, call    // through to GetTargets() and return the first one.    nsCOMPtr<nsISimpleEnumerator> targets;    rv = GetTargets(aSource, aProperty, aTruthValue, getter_AddRefs(targets));    if (NS_FAILED(rv)) return rv;    PRBool hasMore;    rv = targets->HasMoreElements(&hasMore);    if (NS_FAILED(rv)) return rv;    if (! hasMore) return NS_RDF_NO_VALUE;    nsCOMPtr<nsISupports> isupports;    rv = targets->GetNext(getter_AddRefs(isupports));    if (NS_FAILED(rv)) return rv;    return CallQueryInterface(isupports, aTarget);  }  else if ((aProperty == kNC_Date) ||           (aProperty == kNC_VisitCount) ||           (aProperty == kNC_Name) ||           (aProperty == kNC_Referrer) ||           (aProperty == kNC_URL)) {    // It's a real property! Okay, first we'll get the row...    mdb_err err;    const char* uri;    rv = aSource->GetValueConst(&uri);    if (NS_FAILED(rv)) return rv;    PRInt32 len = PL_strlen(uri);    mdbYarn yarn = { NS_CONST_CAST(void*, NS_STATIC_CAST(const void*, uri)), len, len, 0, 0, nsnull };    mdbOid rowId;    nsMdbPtr<nsIMdbRow> row(mEnv);    err = mStore->FindRow(mEnv, kToken_HistoryRowScope, kToken_URLColumn, &yarn, &rowId, getter_Acquires(row));    if (err != 0) return NS_ERROR_FAILURE;    if (!row) return NS_RDF_NO_VALUE;    // ...and then depending on the property they want, we'll pull the    // cell they want out of it.    if (aProperty == kNC_Date) {      // Last visit date      err = row->AliasCellYarn(mEnv, kToken_LastVisitDateColumn, &yarn);      if (err != 0) return NS_ERROR_FAILURE;      PRInt64 i;      rv = CharsToPRInt64((const char*) yarn.mYarn_Buf, yarn.mYarn_Fill, &i);      if (NS_FAILED(rv)) return rv;      nsCOMPtr<nsIRDFDate> date;      rv = gRDFService->GetDateLiteral(i, getter_AddRefs(date));      if (NS_FAILED(rv)) return rv;      return CallQueryInterface(date, aTarget);    }    else if (aProperty == kNC_VisitCount) {      // Visit count      NS_NOTYETIMPLEMENTED("sorry");      rv = NS_ERROR_NOT_IMPLEMENTED;    }    else if (aProperty == kNC_Name) {      // Site name (i.e., page title)      err = row->AliasCellYarn(mEnv, kToken_NameColumn, &yarn);      if (err != 0) return NS_ERROR_FAILURE;      // Can't alias, because we don't store the terminating null      // character in the db.      len = yarn.mYarn_Fill / sizeof(PRUnichar);      nsAutoString str((const PRUnichar*) yarn.mYarn_Buf, len);      nsCOMPtr<nsIRDFLiteral> name;      rv = gRDFService->GetLiteral(str.GetUnicode(), getter_AddRefs(name));      if (NS_FAILED(rv)) return rv;      return CallQueryInterface(name, aTarget);    }    else if (aProperty == kNC_Referrer) {      // Referrer field      err = row->AliasCellYarn(mEnv, kToken_ReferrerColumn, &yarn);      if (err != 0) return NS_ERROR_FAILURE;      // XXX Could probably alias the buffer here to avoid copy      nsCAutoString str((const char*) yarn.mYarn_Buf, yarn.mYarn_Fill);      nsCOMPtr<nsIRDFResource> referrer;      rv = gRDFService->GetResource((const char*) str, getter_AddRefs(referrer));      if (NS_FAILED(rv)) return rv;      return CallQueryInterface(referrer, aTarget);    }    else if (aProperty == kNC_URL) {      nsCOMPtr<nsIRDFLiteral> uriLiteral;      rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(uri), getter_AddRefs(uriLiteral));      if (NS_FAILED(rv))    return(rv);      return CallQueryInterface(uriLiteral, aTarget);    }    else {      NS_NOTREACHED("huh, how'd I get here?");    }  }  return NS_RDF_NO_VALUE;}