/* This is where the real work happens! Go through the field map and set the data in a new database row */ nsresult nsTextAddress::ProcessLine(const nsAString &aLine, nsString &errors) { if (!m_fieldMap) { IMPORT_LOG0("*** Error, text import needs a field map\n"); return NS_ERROR_FAILURE; } nsresult rv; // Wait until we get our first non-empty field, then create a new row, // fill in the data, then add the row to the database. nsCOMPtr<nsIMdbRow> newRow; nsAutoString fieldVal; int32_t fieldNum; int32_t numFields = 0; bool active; rv = m_fieldMap->GetMapSize(&numFields); for (int32_t i = 0; (i < numFields) && NS_SUCCEEDED(rv); i++) { active = false; rv = m_fieldMap->GetFieldMap(i, &fieldNum); if (NS_SUCCEEDED(rv)) rv = m_fieldMap->GetFieldActive(i, &active); if (NS_SUCCEEDED(rv) && active) { if (GetField(aLine, i, fieldVal, m_delim)) { if (!fieldVal.IsEmpty()) { if (!newRow) { rv = m_database->GetNewRow(getter_AddRefs(newRow)); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error getting new address database row\n"); } } if (newRow) { rv = m_fieldMap->SetFieldValue(m_database, newRow, fieldNum, fieldVal.get()); } } } else break; } else if (active) { IMPORT_LOG1("*** Error getting field map for index %ld\n", (long)i); } } if (NS_SUCCEEDED(rv) && newRow) rv = m_database->AddCardRowToDB(newRow); return rv; }
nsresult nsTextAddress::ReadRecordNumber(nsIFile *aSrc, nsAString &aLine, int32_t rNum) { nsCOMPtr<nsIInputStream> inputStream; nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error opening address file for reading\n"); return rv; } int32_t rIndex = 0; uint64_t bytesLeft = 0; rv = inputStream->Available(&bytesLeft); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error checking address file for eof\n"); inputStream->Close(); return rv; } nsCOMPtr<nsIUnicharLineInputStream> lineStream; rv = GetUnicharLineStreamForFile(aSrc, inputStream, getter_AddRefs(lineStream)); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error opening converter stream for importer\n"); return rv; } bool more = true; while (more && (rIndex <= rNum)) { rv = ReadRecord(lineStream, aLine, &more); if (NS_FAILED(rv)) { inputStream->Close(); return rv; } if (rIndex == rNum) { inputStream->Close(); return NS_OK; } rIndex++; } return NS_ERROR_FAILURE; }
nsTextImport::nsTextImport() { // Init logging module. if (!TEXTIMPORTLOGMODULE) TEXTIMPORTLOGMODULE = PR_NewLogModule("IMPORT"); IMPORT_LOG0( "nsTextImport Module Created\n"); nsTextStringBundle::GetStringBundle(); }
nsEudoraImport::nsEudoraImport() { // Init logging module. if (!EUDORALOGMODULE) EUDORALOGMODULE = PR_NewLogModule("IMPORT"); IMPORT_LOG0("nsEudoraImport Module Created\n"); nsEudoraStringBundle::GetStringBundle(); }
NS_IMETHODIMP nsEudoraSettings::Import(nsIMsgAccount **localMailAccount, bool *_retval) { NS_PRECONDITION(_retval != nsnull, "null ptr"); *_retval = false; // Get the settings file if it doesn't exist if (!m_pLocation) { #if defined(XP_WIN) || defined(XP_OS2) nsresult rv; m_pLocation = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { if (!nsEudoraWin32::FindSettingsFile(getter_AddRefs(m_pLocation))) { m_pLocation = nsnull; } } #endif #ifdef XP_MACOSX nsEudoraMac::FindSettingsFile(getter_AddRefs(m_pLocation)); #endif } if (!m_pLocation) { IMPORT_LOG0("*** Error, unable to locate settings file for import.\n"); return NS_ERROR_FAILURE; } // do the settings import #if defined(XP_WIN) || defined(XP_OS2) *_retval = nsEudoraWin32::ImportSettings(m_pLocation, localMailAccount); #endif #ifdef XP_MACOSX *_retval = nsEudoraMac::ImportSettings(m_pLocation, localMailAccount); #endif if (*_retval) { IMPORT_LOG0("Successful import of eudora settings\n"); } else { IMPORT_LOG0("*** Error, Unsuccessful import of eudora settings\n"); } return NS_OK; }
nsVCardImport::nsVCardImport() { if (!VCARDLOGMODULE) VCARDLOGMODULE = PR_NewLogModule("IMPORT"); nsImportStringBundle::GetStringBundle( VCARDIMPORT_MSGS_URL, getter_AddRefs(m_stringBundle)); IMPORT_LOG0("nsVCardImport Module Created\n"); }
nsOutlookImport::nsOutlookImport() { // Init logging module. if (!OUTLOOKLOGMODULE) OUTLOOKLOGMODULE = PR_NewLogModule("IMPORT"); IMPORT_LOG0("nsOutlookImport Module Created\n"); nsOutlookStringBundle::GetStringBundle(); }
nsTextImport::nsTextImport() { // Init logging module. if (!TEXTIMPORTLOGMODULE) TEXTIMPORTLOGMODULE = PR_NewLogModule("IMPORT"); IMPORT_LOG0("nsTextImport Module Created\n"); nsImportStringBundle::GetStringBundle(TEXT_MSGS_URL, getter_AddRefs(m_stringBundle)); }
bool OutlookSettings::DoIMAPServer(nsIMsgAccountManager *aMgr, nsIWindowsRegKey *aKey, const nsString &aServerName, nsIMsgAccount **aAccount) { nsAutoString userName; nsresult rv; rv = aKey->ReadStringValue(NS_LITERAL_STRING("IMAP User Name"), userName); if (NS_FAILED(rv)) return false; bool result = false; // I now have a user name/server name pair, find out if it already exists? nsAutoCString nativeUserName; NS_CopyUnicodeToNative(userName, nativeUserName); nsAutoCString nativeServerName; NS_CopyUnicodeToNative(aServerName, nativeServerName); nsCOMPtr<nsIMsgIncomingServer> in; rv = aMgr->FindServer(nativeUserName, nativeServerName, NS_LITERAL_CSTRING("imap"), getter_AddRefs(in)); if (NS_FAILED(rv) || (in == nullptr)) { // Create the incoming server and an account for it? rv = aMgr->CreateIncomingServer(nativeUserName, nativeServerName, NS_LITERAL_CSTRING("imap"), getter_AddRefs(in)); if (NS_SUCCEEDED(rv) && in) { rv = in->SetType(NS_LITERAL_CSTRING("imap")); // TODO SSL, auth method IMPORT_LOG2("Created IMAP server named: %s, userName: %s\n", nativeServerName.get(), nativeUserName.get()); nsAutoString prettyName; if (NS_SUCCEEDED(GetAccountName(aKey, aServerName, prettyName))) rv = in->SetPrettyName(prettyName); // We have a server, create an account. nsCOMPtr<nsIMsgAccount> account; rv = aMgr->CreateAccount(getter_AddRefs(account)); if (NS_SUCCEEDED(rv) && account) { rv = account->SetIncomingServer(in); IMPORT_LOG0( "Created an account and set the IMAP server as the incoming " "server\n"); // Fiddle with the identities SetIdentities(aMgr, account, aKey); result = true; if (aAccount) account.forget(aAccount); } } } else result = true; return result; }
void WMSettings::SetIdentities(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, nsIDOMDocument *xmlDoc, nsAutoString &inUserName, int32_t authMethodIncoming, bool isNNTP) { // Get the relevant information for an identity // BUG 470587. Don't set this: id->SetIdentityName(fullName); nsresult rv; nsAutoString value; nsCOMPtr<nsIMsgIdentity> id; rv = pMgr->CreateIdentity(getter_AddRefs(id)); if (id) { IMPORT_LOG0("Created identity and added to the account\n"); if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Display_Name" : "SMTP_Display_Name", value))) { id->SetFullName(value); IMPORT_LOG1("\tname: %S\n", value.get()); } if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Organization_Name" : "SMTP_Organization_Name", value))) { id->SetOrganization(value); } if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Email_Address" : "SMTP_Email_Address", value))) { id->SetEmail(NS_ConvertUTF16toUTF8(value)); IMPORT_LOG1("\temail: %S\n", value.get()); } if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Reply_To_Email_Address" : "SMTP_Reply_To_Email_Address", value))) { id->SetReplyTo(NS_ConvertUTF16toUTF8(value)); } // Windows users are used to top style quoting. id->SetReplyOnTop(isNNTP ? 0 : 1); pAcc->AddIdentity(id); } if (!isNNTP) // NNTP does not use SMTP in OE or TB SetSmtpServer(xmlDoc, id, inUserName, authMethodIncoming); }
PRBool nsOE5File::ReadIndex( nsIInputStream *pInputStream, PRUint32 **ppIndex, PRUint32 *pSize) { *ppIndex = nsnull; *pSize = 0; char signature[4]; if (!ReadBytes( pInputStream, signature, 0, 4)) return( PR_FALSE); for (int i = 0; i < 4; i++) { if (signature[i] != gSig[i]) { IMPORT_LOG0( "*** Outlook 5.0 dbx file signature doesn't match\n"); return( PR_FALSE); } } PRUint32 offset = 0x00e4; PRUint32 indexStart = 0; if (!ReadBytes( pInputStream, &indexStart, offset, 4)) { IMPORT_LOG0( "*** Unable to read offset to index start\n"); return( PR_FALSE); } PRUint32Array array; array.count = 0; array.alloc = kIndexGrowBy; array.pIndex = new PRUint32[kIndexGrowBy]; PRUint32 next = ReadMsgIndex( pInputStream, indexStart, &array); while (next) { next = ReadMsgIndex( pInputStream, next, &array); } if (array.count) { *pSize = array.count; *ppIndex = array.pIndex; return( PR_TRUE); } delete [] array.pIndex; return( PR_FALSE); }
PRBool nsEudoraWin32::BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount) { char valBuff[kIniValueSize]; nsCString serverName; nsCString userName; GetServerAndUserName( pSection, pIni, serverName, userName, valBuff); if (serverName.IsEmpty() || userName.IsEmpty()) return( PR_FALSE); PRBool result = PR_FALSE; nsCOMPtr<nsIMsgIncomingServer> in; nsresult rv = accMgr->FindServer( userName, serverName, NS_LITERAL_CSTRING("imap"), getter_AddRefs(in)); if (NS_FAILED( rv) || (in == nsnull)) { // Create the incoming server and an account for it? rv = accMgr->CreateIncomingServer( userName, serverName, NS_LITERAL_CSTRING("imap"), getter_AddRefs(in)); if (NS_SUCCEEDED( rv) && in) { rv = in->SetType(NS_LITERAL_CSTRING("imap")); // rv = in->SetHostName( serverName); // rv = in->SetUsername( userName); IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", serverName.get(), userName.get()); nsString prettyName; GetAccountName( pSection, prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", prettyName.get()); rv = in->SetPrettyName(prettyName); // We have a server, create an account. nsCOMPtr<nsIMsgAccount> account; rv = accMgr->CreateAccount( getter_AddRefs( account)); if (NS_SUCCEEDED( rv) && account) { rv = account->SetIncomingServer(in); IMPORT_LOG0( "Created an account and set the IMAP server as the incoming server\n"); // Fiddle with the identities SetIdentities(accMgr, account, pSection, pIni, userName.get(), serverName.get(), valBuff); result = PR_TRUE; if (ppAccount) account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount); } } } else result = PR_TRUE; return( result); }
NS_IMETHODIMP nsEudoraFilters::Import(char16_t **aError, bool *_retval) { NS_ENSURE_ARG_POINTER(aError); NS_ENSURE_ARG_POINTER(_retval); nsresult rv; *_retval = false; *aError = nullptr; // Get the settings file if it doesn't exist if (!m_pLocation) { m_pLocation = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); #if defined(XP_WIN) if (!nsEudoraWin32::FindFiltersFile(getter_AddRefs(m_pLocation))) m_pLocation = nullptr; #endif #ifdef XP_MACOSX if (!nsEudoraMac::FindFiltersFile(getter_AddRefs(m_pLocation))) m_pLocation = nullptr; #endif } if (!m_pLocation) { IMPORT_LOG0("*** Error, unable to locate filters file for import.\n"); return NS_ERROR_FAILURE; } // Now perform actual importing task *_retval = RealImport(); *aError = ToNewUnicode(m_errorLog); if (*_retval) IMPORT_LOG0("Successful import of eudora filters\n"); else IMPORT_LOG0("*** Error, Unsuccessful import of eudora filters\n"); return NS_OK; }
nsImportService::~nsImportService() { NS_IF_RELEASE(m_pDecoder); NS_IF_RELEASE(m_pEncoder); gImportService = nsnull; if (m_pModules != nsnull) delete m_pModules; IMPORT_LOG0("* nsImport Service Deleted\n"); }
PRBool nsOEScanBoxes::GetMailboxList( nsIFile * root, nsISupportsArray **pArray) { nsresult rv = NS_NewISupportsArray( pArray); if (NS_FAILED( rv)) { IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n"); return( PR_FALSE); } BuildMailboxList( nsnull, root, 1, *pArray); return( PR_TRUE); }
nsAppleMailImportModule::nsAppleMailImportModule() { // Init logging module. if (!APPLEMAILLOGMODULE) APPLEMAILLOGMODULE = PR_NewLogModule("APPLEMAILIMPORTLOG"); IMPORT_LOG0("nsAppleMailImportModule Created"); nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID)); if (bundleService) bundleService->CreateBundle(APPLEMAIL_MSGS_URL, getter_AddRefs(mBundle)); }
nsresult nsTextAddress::ReadRecordNumber(nsIFile *aSrc, nsCString &aLine, PRInt32 rNum) { nsCOMPtr<nsIInputStream> inputStream; nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc); if (NS_FAILED(rv)) { IMPORT_LOG0( "*** Error opening address file for reading\n"); return rv; } PRInt32 rIndex = 0; PRUint32 bytesLeft = 0; rv = inputStream->Available(&bytesLeft); if (NS_FAILED(rv)) { IMPORT_LOG0( "*** Error checking address file for eof\n"); inputStream->Close(); return rv; } nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv)); NS_ENSURE_SUCCESS(rv, rv); bool more = true; while (more && (rIndex <= rNum)) { rv = ReadRecord(lineStream, aLine, &more); if (NS_FAILED(rv)) { inputStream->Close(); return rv; } if (rIndex == rNum) { inputStream->Close(); return NS_OK; } rIndex++; } return NS_ERROR_FAILURE; }
void nsImportGenericAddressBooks::GetDefaultBooks(void) { if (!m_pInterface || m_Books) return; if (!m_pLocation && !m_autoFind) return; nsresult rv = m_pInterface->FindAddressBooks(m_pLocation, getter_AddRefs(m_Books)); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error: FindAddressBooks failed\n"); } }
nsAppleMailImportModule::nsAppleMailImportModule() { // Init logging module. if (!APPLEMAILLOGMODULE) APPLEMAILLOGMODULE = PR_NewLogModule("APPLEMAILIMPORTLOG"); IMPORT_LOG0("nsAppleMailImportModule Created"); nsCOMPtr<nsIStringBundleService> bundleService = mozilla::services::GetStringBundleService(); if (bundleService) bundleService->CreateBundle(APPLEMAIL_MSGS_URL, getter_AddRefs(mBundle)); }
nsresult nsWMUtils::GetRootFolder(nsIFile **aRootFolder) { nsCOMPtr<nsIWindowsRegKey> key; if (NS_FAILED(nsWMUtils::FindWMKey(getter_AddRefs(key)))) { IMPORT_LOG0("*** Error finding Windows Live Mail registry account keys\n"); return NS_ERROR_NOT_AVAILABLE; } // This is essential to proceed; it is the location on disk of xml-type account files; // it is in reg_expand_sz so it will need expanding to absolute path. nsString storeRoot; nsresult rv = key->ReadStringValue(NS_LITERAL_STRING("Store Root"), storeRoot); key->Close(); // Finished with windows registry key. We do not want to return before this closing if (NS_FAILED(rv) || storeRoot.IsEmpty()) { IMPORT_LOG0("*** Error finding Windows Live Mail Store Root\n"); return rv; } uint32_t size = ::ExpandEnvironmentStringsW((LPCWSTR)storeRoot.get(), nullptr, 0); nsString expandedStoreRoot; expandedStoreRoot.SetLength(size - 1); if (expandedStoreRoot.Length() != size - 1) return false; ::ExpandEnvironmentStringsW((LPCWSTR)storeRoot.get(), (LPWSTR)expandedStoreRoot.BeginWriting(), size); storeRoot = expandedStoreRoot; nsCOMPtr<nsIFile> rootFolder(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); rv = rootFolder->InitWithPath(storeRoot); NS_ENSURE_SUCCESS(rv, rv); rootFolder.forget(aRootFolder); return NS_OK; }
bool OutlookSettings::DoIMAPServer(nsIMsgAccountManager *pMgr, HKEY hKey, char *pServerName, nsIMsgAccount **ppAccount) { if (ppAccount) *ppAccount = nsnull; BYTE *pBytes; pBytes = nsOutlookRegUtil::GetValueBytes(hKey, "IMAP User Name"); if (!pBytes) return false; bool result = false; // I now have a user name/server name pair, find out if it already exists? nsCOMPtr<nsIMsgIncomingServer> in; nsresult rv = pMgr->FindServer(nsDependentCString((const char *)pBytes), nsDependentCString(pServerName), NS_LITERAL_CSTRING("imap"), getter_AddRefs(in)); if (NS_FAILED(rv) || (in == nsnull)) { // Create the incoming server and an account for it? rv = pMgr->CreateIncomingServer(nsDependentCString((const char *)pBytes), nsDependentCString(pServerName), NS_LITERAL_CSTRING("imap"), getter_AddRefs(in)); if (NS_SUCCEEDED(rv) && in) { rv = in->SetType(NS_LITERAL_CSTRING("imap")); // TODO SSL, auth method IMPORT_LOG2("Created IMAP server named: %s, userName: %s\n", pServerName, (char *)pBytes); nsString prettyName; if (NS_SUCCEEDED(GetAccountName(hKey, pServerName, prettyName))) rv = in->SetPrettyName(prettyName); // We have a server, create an account. nsCOMPtr<nsIMsgAccount> account; rv = pMgr->CreateAccount(getter_AddRefs(account)); if (NS_SUCCEEDED(rv) && account) { rv = account->SetIncomingServer(in); IMPORT_LOG0("Created an account and set the IMAP server as the incoming server\n"); // Fiddle with the identities SetIdentities(pMgr, account, hKey); result = true; if (ppAccount) account->QueryInterface(NS_GET_IID(nsIMsgAccount), (void **)ppAccount); } } } else result = true; nsOutlookRegUtil::FreeValueBytes(pBytes); return result; }
nsresult nsEudoraCompose::ReadHeaders( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header) { // This should be the headers... header.m_writeOffset = 0; nsresult rv; PRInt32 lineLen; PRInt32 endLen = -1; PRInt8 endBuffer = 0; while ((endLen = IsEndHeaders( copy)) == -1) { while ((lineLen = FindNextEndLine( copy)) == -1) { copy.m_writeOffset = copy.m_bytesInBuf; if (!header.Write( copy.m_pBuffer, copy.m_writeOffset)) { IMPORT_LOG0( "*** ERROR, writing headers\n"); return( NS_ERROR_FAILURE); } if (NS_FAILED( rv = FillMailBuffer( pState, copy))) { IMPORT_LOG0( "*** Error reading message headers\n"); return( rv); } if (!copy.m_bytesInBuf) { IMPORT_LOG0( "*** Error, end of file while reading headers\n"); return( NS_ERROR_FAILURE); } } copy.m_writeOffset += lineLen; if ((copy.m_writeOffset + 4) >= copy.m_bytesInBuf) { if (!header.Write( copy.m_pBuffer, copy.m_writeOffset)) { IMPORT_LOG0( "*** ERROR, writing headers 2\n"); return( NS_ERROR_FAILURE); } if (NS_FAILED( rv = FillMailBuffer( pState, copy))) { IMPORT_LOG0( "*** Error reading message headers 2\n"); return( rv); } } } if (!header.Write( copy.m_pBuffer, copy.m_writeOffset)) { IMPORT_LOG0( "*** Error writing final headers\n"); return( NS_ERROR_FAILURE); } if (!header.Write( (const char *)&endBuffer, 1)) { IMPORT_LOG0( "*** Error writing header trailing null\n"); return( NS_ERROR_FAILURE); } copy.m_writeOffset += endLen; return( NS_OK); }
void OESettings::SetIdentities(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, HKEY hKey, char *pIncomgUserName, PRInt32 authMethodIncoming, bool isNNTP) { // Get the relevant information for an identity char *pSmtpServer = (char *)nsOERegUtil::GetValueBytes(hKey, "SMTP Server"); char *pName = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Display Name" : "SMTP Display Name"); char *pEmail = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Email Address" : "SMTP Email Address"); char *pReply = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Reply To Email Address" : "SMTP Reply To Email Address"); char *pOrgName = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Organization Name" : "SMTP Organization Name"); nsresult rv; nsCOMPtr<nsIMsgIdentity> id; rv = pMgr->CreateIdentity(getter_AddRefs(id)); if (id) { nsAutoString fullName, organization; rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), nsCString(pName), fullName); if (NS_SUCCEEDED(rv)) id->SetFullName(fullName); // BUG 470587. Don't set this: id->SetIdentityName(fullName); rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), nsCString(pOrgName), organization); if (NS_SUCCEEDED(rv)) id->SetOrganization(organization); id->SetEmail(nsCString(pEmail)); if (pReply) id->SetReplyTo(nsCString(pReply)); // Outlook Express users are used to top style quoting. id->SetReplyOnTop(isNNTP ? 0 : 1); pAcc->AddIdentity(id); IMPORT_LOG0("Created identity and added to the account\n"); IMPORT_LOG1("\tname: %s\n", pName); IMPORT_LOG1("\temail: %s\n", pEmail); } if (!isNNTP) // NNTP does not use SMTP in OE or TB SetSmtpServer(pSmtpServer, hKey, id, pIncomgUserName, authMethodIncoming); nsOERegUtil::FreeValueBytes((BYTE *)pName); nsOERegUtil::FreeValueBytes((BYTE *)pSmtpServer); nsOERegUtil::FreeValueBytes((BYTE *)pEmail); nsOERegUtil::FreeValueBytes((BYTE *)pReply); }
nsresult MailEwsMsgCompose::CreateComponents(void) { nsresult rv = NS_OK; if (!m_pIOService) { IMPORT_LOG0("Creating nsIOService\n"); m_pIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); } NS_IF_RELEASE(m_pMsgFields); if (NS_SUCCEEDED(rv)) { rv = CallCreateInstance(kMsgCompFieldsCID, &m_pMsgFields); if (NS_SUCCEEDED(rv) && m_pMsgFields) { IMPORT_LOG0("nsOutlookCompose - CreateComponents succeeded\n"); m_pMsgFields->SetForcePlainText(false); return NS_OK; } } return NS_ERROR_FAILURE; }
nsresult nsEudoraWin32::FoundAddressBook( nsIFile *file, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc) { nsCOMPtr<nsIImportABDescriptor> desc; nsISupports * pInterface; nsString name; nsresult rv; if (pName) name = pName; else { nsAutoString leaf; rv = file->GetLeafName(leaf); if (NS_FAILED( rv)) return( rv); if (leaf.IsEmpty()) return( NS_ERROR_FAILURE); nsString tStr; leaf.Right( tStr, 4); if (tStr.LowerCaseEqualsLiteral(".txt") || tStr.LowerCaseEqualsLiteral(".nnt")) { leaf.Left( tStr, leaf.Length() - 4); leaf = tStr; } } nsCOMPtr<nsILocalFile> fileLoc = do_QueryInterface(file, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc)); if (NS_SUCCEEDED( rv)) { PRInt64 sz = 0; file->GetFileSize( &sz); desc->SetPreferredName(name); desc->SetSize((PRUint32) sz); desc->SetAbFile(fileLoc); rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface); pArray->AppendElement( pInterface); pInterface->Release(); } if (NS_FAILED( rv)) { IMPORT_LOG0( "*** Error creating address book descriptor for eudora\n"); return( rv); } return( NS_OK); }
nsresult nsComm4xMail::FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) { nsresult rv = NS_NewISupportsArray(ppArray); if (NS_FAILED(rv)) { IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); return rv; } nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; m_depth = 0; return (ScanMailDir(pRoot, *ppArray, impSvc)); }
/* void OnStopSending (in string aMsgID, in nsresult aStatus, in wstring aMsg, in nsIFile returnFile); */ NS_IMETHODIMP MailEwsSendListener::OnStopSending(const char *aMsgID, nsresult aStatus, const char16_t *aMsg, nsIFile *returnFile) { IMPORT_LOG0("Send end!"); m_done = true; m_location = returnFile; nsString path; returnFile->GetPath(path); NS_LossyConvertUTF16toASCII_external convertString(path); mailews_logger << "msg file:" << convertString.get() << std::endl; return NS_OK; }
nsresult nsEudoraWin32::FindMailboxes( nsIFile *pRoot, nsISupportsArray **ppArray) { nsresult rv = NS_NewISupportsArray( ppArray); if (NS_FAILED( rv)) { IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n"); return( rv); } nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_FAILED( rv)) return( rv); m_depth = 0; m_mailImportLocation = do_QueryInterface(pRoot); return( ScanMailDir( pRoot, *ppArray, impSvc)); }
PRBool nsOEScanBoxes::GetMailboxes( nsIFile *pWhere, nsISupportsArray **pArray) { nsCString path; pWhere->GetNativePath(path); if (!path.IsEmpty()) { IMPORT_LOG1( "Looking for mail in: %s\n", path.get()); } else { pWhere->GetNativeLeafName(path); if (!path.IsEmpty()) IMPORT_LOG1( "Looking for mail in: %s\n", path.get()); else IMPORT_LOG0( "Unable to get info about where to look for mail\n"); } nsCOMPtr <nsIFile> location; pWhere->Clone(getter_AddRefs(location)); // 1. Look for 5.0 folders.dbx // 2. Look for 3.x & 4.x folders.nch // 3. Look for 5.0 *.dbx mailboxes // 4. Look for 3.x & 4.x *.mbx mailboxes PRBool result; location->AppendNative(NS_LITERAL_CSTRING("folders.dbx")); if (Find50MailBoxes(location)) { result = GetMailboxList( location, pArray); } else { // 2. Look for 4.x mailboxes location->AppendNative(NS_LITERAL_CSTRING("folders.nch")); if (FindMailBoxes(location)) { result = GetMailboxList( location, pArray); } else { // 3 & 4, look for the specific mailbox files. pWhere->Clone(getter_AddRefs(location)); ScanMailboxDir( location); result = GetMailboxList( location, pArray); } } return( result); }
void nsImportGenericMail::GetDefaultDestination(void) { if (m_pDestFolder) return; if (!m_pInterface) return; nsIMsgFolder * rootFolder; m_deleteDestFolder = false; m_createdFolder = false; if (CreateFolder(&rootFolder)) { m_pDestFolder = rootFolder; m_deleteDestFolder = true; m_createdFolder = true; return; } IMPORT_LOG0("*** GetDefaultDestination: Failed to create a default import destination folder."); }