nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
nsresult AddressBookParser::ParseFile(){  // Initialize the parser for a run...  mLine.Truncate();  // this is converting 4.x to 6.0  if (mImportingComm4x && mDatabase)   {    return ParseLDIFFile();  } 	/* Get database file name */	char *leafName = nsnull;	nsAutoString fileString;	if (mFileSpec) {		mFileSpec->GetLeafName(&leafName);		fileString.AssignWithConversion(leafName);		// todo:  detect ldif / tab files a better way		if (-1 != fileString.Find(kTabExtension) || -1 != fileString.Find(kTxtExtension))			mFileType = TABFile;		else if (-1 != fileString.Find(kLdifExtension))			mFileType = LDIFFile;		else			return NS_ERROR_FAILURE;		PRInt32 i = 0;		while (leafName[i] != '\0')		{			if (leafName[i] == '.')			{				leafName[i] = '\0';				break;			}			else				i++;		}		if (leafName)			mDbUri = PR_smprintf("%s%s.mab", kMDBDirectoryRoot, leafName);	}	// to do: we should use only one "return rv;" at the very end, instead of this	//  multi return structure	nsresult rv = NS_OK;	nsFileSpec* dbPath = nsnull;	char* fileName = PR_smprintf("%s.mab", leafName);	nsCOMPtr<nsIAddrBookSession> abSession = 	         do_GetService(kAddrBookSessionCID, &rv); 	if(NS_SUCCEEDED(rv))		abSession->GetUserProfileDirectory(&dbPath);		/* create address book database  */	if (dbPath)	{		(*dbPath) += fileName;		nsCOMPtr<nsIAddrDatabase> addrDBFactory = 		         do_GetService(kAddressBookDBCID, &rv);		if (NS_SUCCEEDED(rv) && addrDBFactory)			rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);	}	NS_ENSURE_SUCCESS(rv, rv);    delete dbPath;    nsCOMPtr<nsIRDFService> rdfService = do_GetService (NS_RDF_CONTRACTID "/rdf-service;1", &rv);    NS_ENSURE_SUCCESS(rv, rv);	nsCOMPtr<nsIRDFResource> parentResource;	char *parentUri = PR_smprintf("%s", kAllDirectoryRoot);	rv = rdfService->GetResource(parentUri, getter_AddRefs(parentResource));	nsCOMPtr<nsIAbDirectory> parentDir = do_QueryInterface(parentResource);	if (!parentDir)		return NS_ERROR_NULL_POINTER;	if (parentUri)		PR_smprintf_free(parentUri);	if (PL_strcmp(fileName, kPersonalAddressbook) == 0)	{		// This is the personal address book, get name from prefs		nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv)); 		if (NS_FAILED(rv) || !pPref) 			return nsnull;			        nsXPIDLString dirName;		rv = pPref->GetLocalizedUnicharPref("ldap_2.servers.pab.description", getter_Copies(dirName));		parentDir->CreateDirectoryByURI(dirName, mDbUri, mMigrating);	}	else		parentDir->CreateDirectoryByURI(fileString.get(), mDbUri, mMigrating);				if (mFileType == TABFile)		rv = ParseTabFile();	else if (mFileType == LDIFFile)		rv = ParseLDIFFile();	else 		rv = NS_ERROR_FAILURE;	if (leafName)		nsCRT::free(leafName);	if (fileName)		PR_smprintf_free(fileName);	return rv;}