--- a/mailnews/import/eudora/src/nsEudoraAddress.cpp
+++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp
@@ -64,42 +64,42 @@
}
// If we get a line longer than 16K it's just toooooo bad!
#define kEudoraAddressBufferSz (16 * 1024)
#ifdef IMPORT_DEBUG
-void DumpAliasArray( nsVoidArray& a);
+void DumpAliasArray(nsVoidArray& a);
#endif
class CAliasData {
public:
CAliasData() {}
~CAliasData() {}
- bool Process( const char *pLine, PRInt32 len);
+ bool Process(const char *pLine, PRInt32 len);
public:
nsCString m_fullEntry;
nsCString m_nickName;
nsCString m_realName;
nsCString m_email;
};
class CAliasEntry {
public:
- CAliasEntry( nsCString& name) { m_name = name;}
+ CAliasEntry(nsCString& name) { m_name = name;}
~CAliasEntry() { EmptyList();}
- void EmptyList( void) {
+ void EmptyList(void) {
CAliasData *pData;
for (PRInt32 i = 0; i < m_list.Count(); i++) {
- pData = (CAliasData *)m_list.ElementAt( i);
+ pData = (CAliasData *)m_list.ElementAt(i);
delete pData;
}
m_list.Clear();
}
public:
nsCString m_name;
nsVoidArray m_list;
@@ -111,136 +111,135 @@ nsEudoraAddress::nsEudoraAddress()
}
nsEudoraAddress::~nsEudoraAddress()
{
EmptyAliases();
}
-nsresult nsEudoraAddress::ImportAddresses( PRUint32 *pBytes, bool *pAbort,
+nsresult nsEudoraAddress::ImportAddresses(PRUint32 *pBytes, bool *pAbort,
const PRUnichar *pName, nsIFile *pSrc,
nsIAddrDatabase *pDb, nsString& errors)
{
// Open the source file for reading, read each line and process it!
EmptyAliases();
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), pSrc);
if (NS_FAILED(rv)) {
- IMPORT_LOG0( "*** Error opening address file for reading\n");
+ IMPORT_LOG0("*** Error opening address file for reading\n");
return rv;
}
PRUint32 bytesLeft = 0;
rv = inputStream->Available(&bytesLeft);
if (NS_FAILED(rv)) {
- IMPORT_LOG0( "*** Error checking address file for eof\n");
+ 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 ((!(*pAbort) && more && NS_SUCCEEDED( rv)))
+ while ((!(*pAbort) && more && NS_SUCCEEDED(rv)))
{
nsCString line;
rv = lineStream->ReadLine(line, &more);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
PRInt32 len = line.Length();
- ProcessLine( line.get(), len, errors);
+ ProcessLine(line.get(), len, errors);
if (pBytes)
*pBytes += (len / 2);
}
}
rv = inputStream->Close();
if (more)
{
- IMPORT_LOG0( "*** Error reading the address book, didn't reach the end\n");
- return( NS_ERROR_FAILURE);
+ IMPORT_LOG0("*** Error reading the address book, didn't reach the end\n");
+ return NS_ERROR_FAILURE;
}
// Run through the alias array and make address book entries...
#ifdef IMPORT_DEBUG
- DumpAliasArray( m_alias);
+ DumpAliasArray(m_alias);
#endif
- BuildABCards( pBytes, pDb);
+ BuildABCards(pBytes, pDb);
return pDb->Commit(nsAddrDBCommitType::kLargeCommit);
}
-PRInt32 nsEudoraAddress::CountWhiteSpace( const char *pLine, PRInt32 len)
+PRInt32 nsEudoraAddress::CountWhiteSpace(const char *pLine, PRInt32 len)
{
PRInt32 cnt = 0;
while (len && ((*pLine == ' ') || (*pLine == '\t'))) {
len--;
pLine++;
cnt++;
}
- return( cnt);
+ return cnt;
}
-void nsEudoraAddress::EmptyAliases( void)
+void nsEudoraAddress::EmptyAliases(void)
{
CAliasEntry *pData;
for (PRInt32 i = 0; i < m_alias.Count(); i++) {
- pData = (CAliasEntry *)m_alias.ElementAt( i);
+ pData = (CAliasEntry *)m_alias.ElementAt(i);
delete pData;
}
m_alias.Clear();
}
-void nsEudoraAddress::ProcessLine( const char *pLine, PRInt32 len, nsString& errors)
+void nsEudoraAddress::ProcessLine(const char *pLine, PRInt32 len, nsString& errors)
{
if (len < 6)
return;
PRInt32 cnt;
CAliasEntry *pEntry;
- if (!strncmp( pLine, "alias", 5)) {
+ if (!strncmp(pLine, "alias", 5)) {
pLine += 5;
len -= 5;
- cnt = CountWhiteSpace( pLine, len);
+ cnt = CountWhiteSpace(pLine, len);
if (cnt) {
pLine += cnt;
len -= cnt;
- if ((pEntry = ProcessAlias( pLine, len, errors)) != nsnull) {
- m_alias.AppendElement( pEntry);
- }
+ if ((pEntry = ProcessAlias(pLine, len, errors)) != nsnull)
+ m_alias.AppendElement(pEntry);
}
}
- else if (!strncmp( pLine, "note", 4)) {
+ else if (!strncmp(pLine, "note", 4)) {
pLine += 4;
len -= 4;
- cnt = CountWhiteSpace( pLine, len);
+ cnt = CountWhiteSpace(pLine, len);
if (cnt) {
pLine += cnt;
len -= cnt;
- ProcessNote( pLine, len, errors);
+ ProcessNote(pLine, len, errors);
}
}
// as far as I know everything must be on one line
// if not, then I need to add a state variable.
}
-PRInt32 nsEudoraAddress::GetAliasName( const char *pLine, PRInt32 len, nsCString& name)
+PRInt32 nsEudoraAddress::GetAliasName(const char *pLine, PRInt32 len, nsCString& name)
{
name.Truncate();
if (!len)
- return( 0);
+ return 0;
const char *pStart = pLine;
char end[2] = {' ', '\t'};
if (*pLine == '"') {
pLine++;
pStart++;
len--;
end[0] = '"';
end[1] = 0;
@@ -251,209 +250,208 @@ PRInt32 nsEudoraAddress::GetAliasName( c
if ((*pLine == end[0]) || (*pLine == end[1]))
break;
len--;
pLine++;
cnt++;
}
if (cnt)
- name.Append( pStart, cnt);
+ name.Append(pStart, cnt);
if (end[0] == '"') {
cnt++;
if (len && (*pLine == '"')) {
cnt++;
pLine++;
len--;
}
}
- cnt += CountWhiteSpace( pLine, len);
+ cnt += CountWhiteSpace(pLine, len);
- return( cnt);
+ return cnt;
}
-CAliasEntry *nsEudoraAddress::ProcessAlias( const char *pLine, PRInt32 len, nsString& errors)
+CAliasEntry *nsEudoraAddress::ProcessAlias(const char *pLine, PRInt32 len, nsString& errors)
{
nsCString name;
- PRInt32 cnt = GetAliasName( pLine, len, name);
+ PRInt32 cnt = GetAliasName(pLine, len, name);
pLine += cnt;
len -= cnt;
// we have 3 known forms of addresses in Eudora
// 1) real name <email@address>
// 2) email@address
// 3) <email@address>
// 4) real name email@address
// 5) <email@address> (Real name)
- CAliasEntry *pEntry = new CAliasEntry( name);
+ CAliasEntry *pEntry = new CAliasEntry(name);
if (!cnt || !len)
- return(pEntry);
+ return pEntry;
// Theoretically, an alias is just an RFC822 email adress, but it may contain
// an alias to another alias as the email! I general, it appears close
// but unfortunately not exact so we can't use the nsIMsgHeaderParser to do
// the work for us!
// Very big bummer!
const char *pStart;
PRInt32 tLen;
nsCString alias;
- while ( len) {
+ while (len) {
pStart = pLine;
cnt = 0;
while (len && (*pLine != ',')) {
if (*pLine == '"') {
- tLen = CountQuote( pLine, len);
+ tLen = CountQuote(pLine, len);
pLine += tLen;
len -= tLen;
cnt += tLen;
}
else if (*pLine == '(') {
- tLen = CountComment( pLine, len);
+ tLen = CountComment(pLine, len);
pLine += tLen;
len -= tLen;
cnt += tLen;
}
else if (*pLine == '<') {
- tLen = CountAngle( pLine, len);
+ tLen = CountAngle(pLine, len);
pLine += tLen;
len -= tLen;
cnt += tLen;
}
else {
cnt++;
pLine++;
len--;
}
}
if (cnt) {
CAliasData *pData = new CAliasData();
- if (pData->Process( pStart, cnt)) {
- pEntry->m_list.AppendElement( pData);
- }
+ if (pData->Process(pStart, cnt))
+ pEntry->m_list.AppendElement(pData);
else
delete pData;
}
if (len && (*pLine == ',')) {
pLine++;
len--;
}
}
// Always return the entry even if there's no other attribute associated with the contact.
- return( pEntry);
+ return pEntry;
}
-void nsEudoraAddress::ProcessNote( const char *pLine, PRInt32 len, nsString& errors)
+void nsEudoraAddress::ProcessNote(const char *pLine, PRInt32 len, nsString& errors)
{
nsCString name;
- PRInt32 cnt = GetAliasName( pLine, len, name);
+ PRInt32 cnt = GetAliasName(pLine, len, name);
pLine += cnt;
len -= cnt;
if (!cnt || !len)
return;
// Find the alias for this note and store the note data there!
CAliasEntry *pEntry = nsnull;
- PRInt32 idx = FindAlias( name);
+ PRInt32 idx = FindAlias(name);
if (idx == -1)
return;
- pEntry = (CAliasEntry *) m_alias.ElementAt( idx);
- pEntry->m_notes.Append( pLine, len);
- pEntry->m_notes.Trim( kWhitespace);
+ pEntry = (CAliasEntry *) m_alias.ElementAt(idx);
+ pEntry->m_notes.Append(pLine, len);
+ pEntry->m_notes.Trim(kWhitespace);
}
-PRInt32 nsEudoraAddress::CountQuote( const char *pLine, PRInt32 len)
+PRInt32 nsEudoraAddress::CountQuote(const char *pLine, PRInt32 len)
{
if (!len)
- return( 0);
+ return 0;
PRInt32 cnt = 1;
pLine++;
len--;
while (len && (*pLine != '"')) {
cnt++;
len--;
pLine++;
}
if (len)
cnt++;
- return( cnt);
+ return cnt;
}
-PRInt32 nsEudoraAddress::CountAngle( const char *pLine, PRInt32 len)
+PRInt32 nsEudoraAddress::CountAngle(const char *pLine, PRInt32 len)
{
if (!len)
- return( 0);
+ return 0;
PRInt32 cnt = 1;
pLine++;
len--;
while (len && (*pLine != '>')) {
cnt++;
len--;
pLine++;
}
if (len)
cnt++;
- return( cnt);
+ return cnt;
}
-PRInt32 nsEudoraAddress::CountComment( const char *pLine, PRInt32 len)
+PRInt32 nsEudoraAddress::CountComment(const char *pLine, PRInt32 len)
{
if (!len)
- return( 0);
+ return 0;
PRInt32 cCnt;
PRInt32 cnt = 1;
pLine++;
len--;
while (len && (*pLine != ')')) {
if (*pLine == '(') {
- cCnt = CountComment( pLine, len);
+ cCnt = CountComment(pLine, len);
cnt += cCnt;
pLine += cCnt;
len -= cCnt;
}
else {
cnt++;
len--;
pLine++;
}
}
if (len)
cnt++;
- return( cnt);
+ return cnt;
}
/*
nsCString m_nickName;
nsCString m_realName;
nsCString m_email;
*/
-bool CAliasData::Process( const char *pLine, PRInt32 len)
+bool CAliasData::Process(const char *pLine, PRInt32 len)
{
// Extract any comments first!
nsCString str;
const char *pStart = pLine;
PRInt32 tCnt = 0;
PRInt32 cnt = 0;
PRInt32 max = len;
@@ -467,236 +465,241 @@ bool CAliasData::Process( const char *pL
// ResolveAlias were failing because "Smith" is not the full nickname.
// Now we just stash the full entry for nickname resolution before processing
// the line as a potential entry in its own right.
m_fullEntry.Append(pLine, len);
while (max) {
if (*pLine == '"') {
if (tCnt && !endCollect) {
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
if (!str.IsEmpty())
- str.Append( " ", 1);
- str.Append( pStart, tCnt);
+ str.Append(" ", 1);
+ str.Append(pStart, tCnt);
}
- cnt = nsEudoraAddress::CountQuote( pLine, max);
+ cnt = nsEudoraAddress::CountQuote(pLine, max);
if ((cnt > 2) && m_realName.IsEmpty()) {
- m_realName.Append( pLine + 1, cnt - 2);
+ m_realName.Append(pLine + 1, cnt - 2);
}
pLine += cnt;
max -= cnt;
pStart = pLine;
tCnt = 0;
}
else if (*pLine == '<') {
if (tCnt && !endCollect) {
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
if (!str.IsEmpty())
- str.Append( " ", 1);
- str.Append( pStart, tCnt);
+ str.Append(" ", 1);
+ str.Append(pStart, tCnt);
}
- cnt = nsEudoraAddress::CountAngle( pLine, max);
+ cnt = nsEudoraAddress::CountAngle(pLine, max);
if ((cnt > 2) && m_email.IsEmpty()) {
- m_email.Append( pLine + 1, cnt - 2);
+ m_email.Append(pLine + 1, cnt - 2);
}
pLine += cnt;
max -= cnt;
pStart = pLine;
tCnt = 0;
endCollect = true;
}
else if (*pLine == '(') {
if (tCnt && !endCollect) {
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
if (!str.IsEmpty())
- str.Append( " ", 1);
- str.Append( pStart, tCnt);
+ str.Append(" ", 1);
+ str.Append(pStart, tCnt);
}
- cnt = nsEudoraAddress::CountComment( pLine, max);
+ cnt = nsEudoraAddress::CountComment(pLine, max);
if (cnt > 2) {
if (!m_realName.IsEmpty() && m_nickName.IsEmpty())
m_nickName = m_realName;
m_realName.Truncate();
- m_realName.Append( pLine + 1, cnt - 2);
+ m_realName.Append(pLine + 1, cnt - 2);
}
pLine += cnt;
max -= cnt;
pStart = pLine;
tCnt = 0;
}
else {
tCnt++;
pLine++;
max--;
}
}
if (tCnt) {
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
if (!str.IsEmpty())
- str.Append( " ", 1);
- str.Append( pStart, tCnt);
+ str.Append(" ", 1);
+ str.Append(pStart, tCnt);
}
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
if (!m_realName.IsEmpty() && !m_email.IsEmpty())
- return( true);
+ return true;
// now we should have a string with any remaining non-delimitted text
// we assume that the last token is the email
// anything before that is realName
if (!m_email.IsEmpty()) {
m_realName = str;
- return( true);
+ return true;
}
- tCnt = str.RFindChar( ' ');
+ tCnt = str.RFindChar(' ');
if (tCnt == -1) {
if (!str.IsEmpty()) {
m_email = str;
- return( true);
+ return true;
}
- return( false);
+ return false;
}
m_email = Substring(str, tCnt + 1);
m_realName = StringHead(str, tCnt);
- m_realName.Trim( kWhitespace);
- m_email.Trim( kWhitespace);
+ m_realName.Trim(kWhitespace);
+ m_email.Trim(kWhitespace);
- return( !m_email.IsEmpty());
+ return !m_email.IsEmpty();
}
#ifdef IMPORT_DEBUG
-void DumpAliasArray( nsVoidArray& a)
+void DumpAliasArray(nsVoidArray& a)
{
CAliasEntry *pEntry;
CAliasData *pData;
PRInt32 cnt = a.Count();
- IMPORT_LOG1( "Alias list size: %ld\n", cnt);
+ IMPORT_LOG1("Alias list size: %ld\n", cnt);
for (PRInt32 i = 0; i < cnt; i++) {
- pEntry = (CAliasEntry *)a.ElementAt( i);
- IMPORT_LOG1( "\tAlias: %s\n", pEntry->m_name.get());
+ pEntry = (CAliasEntry *)a.ElementAt(i);
+ IMPORT_LOG1("\tAlias: %s\n", pEntry->m_name.get());
if (pEntry->m_list.Count() > 1) {
- IMPORT_LOG1( "\tList count #%ld\n", pEntry->m_list.Count());
+ IMPORT_LOG1("\tList count #%ld\n", pEntry->m_list.Count());
for (PRInt32 j = 0; j < pEntry->m_list.Count(); j++) {
- pData = (CAliasData *) pEntry->m_list.ElementAt( j);
- IMPORT_LOG0( "\t\t--------\n");
- IMPORT_LOG1( "\t\temail: %s\n", pData->m_email.get());
- IMPORT_LOG1( "\t\trealName: %s\n", pData->m_realName.get());
- IMPORT_LOG1( "\t\tnickName: %s\n", pData->m_nickName.get());
+ pData = (CAliasData *) pEntry->m_list.ElementAt(j);
+ IMPORT_LOG0("\t\t--------\n");
+ IMPORT_LOG1("\t\temail: %s\n", pData->m_email.get());
+ IMPORT_LOG1("\t\trealName: %s\n", pData->m_realName.get());
+ IMPORT_LOG1("\t\tnickName: %s\n", pData->m_nickName.get());
}
}
else if (pEntry->m_list.Count()) {
- pData = (CAliasData *) pEntry->m_list.ElementAt( 0);
- IMPORT_LOG1( "\t\temail: %s\n", pData->m_email.get());
- IMPORT_LOG1( "\t\trealName: %s\n", pData->m_realName.get());
- IMPORT_LOG1( "\t\tnickName: %s\n", pData->m_nickName.get());
+ pData = (CAliasData *) pEntry->m_list.ElementAt(0);
+ IMPORT_LOG1("\t\temail: %s\n", pData->m_email.get());
+ IMPORT_LOG1("\t\trealName: %s\n", pData->m_realName.get());
+ IMPORT_LOG1("\t\tnickName: %s\n", pData->m_nickName.get());
}
}
}
#endif
-CAliasEntry *nsEudoraAddress::ResolveAlias( nsCString& name)
+CAliasEntry *nsEudoraAddress::ResolveAlias(nsCString& name)
{
PRInt32 max = m_alias.Count();
CAliasEntry *pEntry;
for (PRInt32 i = 0; i < max; i++) {
- pEntry = (CAliasEntry *) m_alias.ElementAt( i);
- if (name.Equals( pEntry->m_name, nsCaseInsensitiveCStringComparator()))
- return( pEntry);
+ pEntry = (CAliasEntry *) m_alias.ElementAt(i);
+ if (name.Equals(pEntry->m_name, nsCaseInsensitiveCStringComparator()))
+ return pEntry;
}
- return( nsnull);
+ return nsnull;
}
-void nsEudoraAddress::ResolveEntries( nsCString& name, nsVoidArray& list,
+void nsEudoraAddress::ResolveEntries(nsCString& name, nsVoidArray& list,
nsVoidArray& result, bool addResolvedEntries,
bool wasResolved, PRInt32& numResolved)
{
/* a safe-guard against recursive entries */
if (result.Count() > m_alias.Count())
return;
PRInt32 max = list.Count();
PRInt32 i;
CAliasData * pData;
CAliasEntry * pEntry;
for (i = 0; i < max; i++) {
- pData = (CAliasData *)list.ElementAt( i);
+ pData = (CAliasData *)list.ElementAt(i);
// resolve the email to an existing alias!
- if ( !name.Equals(pData->m_email, nsCaseInsensitiveCStringComparator()) &&
- ((pEntry = ResolveAlias( pData->m_fullEntry)) != nsnull) ) {
+ if (!name.Equals(pData->m_email, nsCaseInsensitiveCStringComparator()) &&
+ ((pEntry = ResolveAlias(pData->m_fullEntry)) != nsnull)) {
// This new entry has all of the entries for this puppie.
// Resolve all of it's entries!
numResolved++; // Track the number of entries resolved
// We pass in true for the 5th parameter so that we know that we're
// calling ourselves recursively.
- ResolveEntries( pEntry->m_name, pEntry->m_list, result, addResolvedEntries, true, numResolved);
+ ResolveEntries(pEntry->m_name,
+ pEntry->m_list,
+ result,
+ addResolvedEntries,
+ true,
+ numResolved);
}
else if (addResolvedEntries || !wasResolved) {
// This is either an ordinary entry (i.e. just contains the info) or we were told
// to add resolved alias entries.
- result.AppendElement( pData);
+ result.AppendElement(pData);
}
}
}
-PRInt32 nsEudoraAddress::FindAlias( nsCString& name)
+PRInt32 nsEudoraAddress::FindAlias(nsCString& name)
{
CAliasEntry * pEntry;
PRInt32 max = m_alias.Count();
PRInt32 i;
for (i = 0; i < max; i++) {
- pEntry = (CAliasEntry *) m_alias.ElementAt( i);
+ pEntry = (CAliasEntry *) m_alias.ElementAt(i);
if (pEntry->m_name == name)
- return( i);
+ return i;
}
- return( -1);
+ return -1;
}
-void nsEudoraAddress::BuildABCards( PRUint32 *pBytes, nsIAddrDatabase *pDb)
+void nsEudoraAddress::BuildABCards(PRUint32 *pBytes, nsIAddrDatabase *pDb)
{
CAliasEntry * pEntry;
PRInt32 max = m_alias.Count();
PRInt32 i;
nsVoidArray emailList;
nsVoidArray membersArray;// Remember group members.
nsVoidArray groupsArray; // Remember groups.
// First off, run through the list and build person cards - groups/lists have to be done later
for (i = 0; i < max; i++) {
PRInt32 numResolved = 0;
- pEntry = (CAliasEntry *) m_alias.ElementAt( i);
+ pEntry = (CAliasEntry *) m_alias.ElementAt(i);
// false for 4th parameter tells ResolveEntries not to add resolved entries (avoids
// duplicates as mailing lists are being resolved to other cards - the other cards that
// are found have already been added and don't need to be added again).
//
// false for 5th parameter tells ResolveEntries that we're calling it - it's not being
// called recursively by itself.
- ResolveEntries( pEntry->m_name, pEntry->m_list, emailList, false, false, numResolved);
+ ResolveEntries(pEntry->m_name, pEntry->m_list, emailList, false, false, numResolved);
// Treat it as a group if there's more than one email address or if we
// needed to resolve one or more aliases. We treat single aliases to
// other aliases as a mailing list because there's no better equivalent.
- if ( (emailList.Count() > 1) || (numResolved > 0) )
+ if ((emailList.Count() > 1) || (numResolved > 0))
{
// Remember group members uniquely and add them to db later.
RememberGroupMembers(membersArray, emailList);
// Remember groups and add them to db later.
groupsArray.AppendElement(pEntry);
}
else
- AddSingleCard( pEntry, emailList, pDb);
+ AddSingleCard(pEntry, emailList, pDb);
emailList.Clear();
if (pBytes) {
// This isn't exact but it will get us close enough
*pBytes += (pEntry->m_name.Length() + pEntry->m_notes.Length() + 10);
}
}
@@ -713,90 +716,90 @@ void nsEudoraAddress::BuildABCards( PRUi
PRInt32 numResolved = 0;
pEntry = (CAliasEntry *) groupsArray.ElementAt(i);
// false for 4th parameter tells ResolveEntries to add resolved entries so that we
// can create the mailing list with references to all entries correctly.
//
// false for 5th parameter tells ResolveEntries that we're calling it - it's not being
// called recursively by itself.
- ResolveEntries( pEntry->m_name, pEntry->m_list, emailList, true, false, numResolved);
+ ResolveEntries(pEntry->m_name, pEntry->m_list, emailList, true, false, numResolved);
AddSingleList(pEntry, emailList, pDb);
emailList.Clear();
}
}
-void nsEudoraAddress::ExtractNoteField( nsCString& note, nsCString& value, const char *pFieldName)
+void nsEudoraAddress::ExtractNoteField(nsCString& note, nsCString& value, const char *pFieldName)
{
value.Truncate();
nsCString field("<");
- field.Append( pFieldName);
- field.Append( ':');
+ field.Append(pFieldName);
+ field.Append(':');
/*
this is a bit of a cheat, but there's no reason it won't work
fine for us, even better than Eudora in some cases!
*/
- PRInt32 idx = note.Find( field);
+ PRInt32 idx = note.Find(field);
if (idx != -1) {
idx += field.Length();
- PRInt32 endIdx = note.FindChar( '>', idx);
+ PRInt32 endIdx = note.FindChar('>', idx);
if (endIdx == -1)
endIdx = note.Length() - 1;
value = Substring(note, idx, endIdx - idx);
idx -= field.Length();
note.Cut(idx, endIdx + 1);
}
}
void nsEudoraAddress::FormatExtraDataInNoteField(PRInt32 labelStringID, nsCString& extraData, nsString& noteUTF16)
{
nsAutoString label;
nsEudoraStringBundle::GetStringByID(labelStringID, label);
noteUTF16.Append(label);
noteUTF16.AppendLiteral("\n");
- noteUTF16.Append( NS_ConvertASCIItoUTF16(extraData) );
+ noteUTF16.Append(NS_ConvertASCIItoUTF16(extraData));
noteUTF16.AppendLiteral("\n\n");
}
-void nsEudoraAddress::SanitizeValue( nsCString& val)
+void nsEudoraAddress::SanitizeValue(nsCString& val)
{
MsgReplaceSubstring(val, "\n", ", ");
MsgReplaceChar(val, '\r', ',');
}
-void nsEudoraAddress::SplitString( nsCString& val1, nsCString& val2)
+void nsEudoraAddress::SplitString(nsCString& val1, nsCString& val2)
{
nsCString temp;
// Find the last line if there is more than one!
- PRInt32 idx = val1.RFind( "\x0D\x0A");
+ PRInt32 idx = val1.RFind("\x0D\x0A");
PRInt32 cnt = 2;
if (idx == -1) {
cnt = 1;
- idx = val1.RFindChar( 13);
+ idx = val1.RFindChar(13);
}
if (idx == -1)
- idx= val1.RFindChar( 10);
+ idx= val1.RFindChar(10);
if (idx != -1) {
val2 = Substring(val1, idx + cnt);
val1.SetLength(idx);
- SanitizeValue( val1);
+ SanitizeValue(val1);
}
}
-void nsEudoraAddress::AddSingleCard( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb)
+void nsEudoraAddress::AddSingleCard(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb)
{
// We always have a nickname and everything else is optional.
// Map both home and work related fields to our address card. Eudora
// fields that can't be mapped will be left in the 'note' field!
nsIMdbRow* newRow = nsnull;
- pDb->GetNewRow( &newRow);
+ pDb->GetNewRow(&newRow);
if (!newRow)
return;
nsCString displayName, name, firstName, lastName;
nsCString fax, secondaryFax, phone, mobile, secondaryMobile, webLink;
nsCString address, address2, city, state, zip, country;
nsCString phoneWK, webLinkWK, title, company;
nsCString addressWK, address2WK, cityWK, stateWK, zipWK, countryWK;
@@ -804,53 +807,53 @@ void nsEudoraAddress::AddSingleCard( CAl
nsCString additionalEmail, stillMoreEmail;
nsCString note(pEntry->m_notes);
nsString noteUTF16;
bool isSecondaryMobileWorkNumber = true;
bool isSecondaryFaxWorkNumber = true;
if (!note.IsEmpty())
{
- ExtractNoteField( note, fax, "fax");
- ExtractNoteField( note, secondaryFax, "fax2");
- ExtractNoteField( note, phone, "phone");
- ExtractNoteField( note, mobile, "mobile");
- ExtractNoteField( note, secondaryMobile, "mobile2");
- ExtractNoteField( note, address, "address");
- ExtractNoteField( note, city, "city");
- ExtractNoteField( note, state, "state");
- ExtractNoteField( note, zip, "zip");
- ExtractNoteField( note, country, "country");
- ExtractNoteField( note, name, "name");
- ExtractNoteField( note, firstName, "first");
- ExtractNoteField( note, lastName, "last");
- ExtractNoteField( note, webLink, "web");
+ ExtractNoteField(note, fax, "fax");
+ ExtractNoteField(note, secondaryFax, "fax2");
+ ExtractNoteField(note, phone, "phone");
+ ExtractNoteField(note, mobile, "mobile");
+ ExtractNoteField(note, secondaryMobile, "mobile2");
+ ExtractNoteField(note, address, "address");
+ ExtractNoteField(note, city, "city");
+ ExtractNoteField(note, state, "state");
+ ExtractNoteField(note, zip, "zip");
+ ExtractNoteField(note, country, "country");
+ ExtractNoteField(note, name, "name");
+ ExtractNoteField(note, firstName, "first");
+ ExtractNoteField(note, lastName, "last");
+ ExtractNoteField(note, webLink, "web");
- ExtractNoteField( note, addressWK, "address2");
- ExtractNoteField( note, cityWK, "city2");
- ExtractNoteField( note, stateWK, "state2");
- ExtractNoteField( note, zipWK, "zip2");
- ExtractNoteField( note, countryWK, "country2");
- ExtractNoteField( note, phoneWK, "phone2");
- ExtractNoteField( note, title, "title");
- ExtractNoteField( note, company, "company");
- ExtractNoteField( note, webLinkWK, "web2");
+ ExtractNoteField(note, addressWK, "address2");
+ ExtractNoteField(note, cityWK, "city2");
+ ExtractNoteField(note, stateWK, "state2");
+ ExtractNoteField(note, zipWK, "zip2");
+ ExtractNoteField(note, countryWK, "country2");
+ ExtractNoteField(note, phoneWK, "phone2");
+ ExtractNoteField(note, title, "title");
+ ExtractNoteField(note, company, "company");
+ ExtractNoteField(note, webLinkWK, "web2");
- ExtractNoteField( note, primaryLocation, "primary");
- ExtractNoteField( note, additionalEmail, "otheremail");
- ExtractNoteField( note, otherPhone, "otherphone");
- ExtractNoteField( note, otherWeb, "otherweb");
+ ExtractNoteField(note, primaryLocation, "primary");
+ ExtractNoteField(note, additionalEmail, "otheremail");
+ ExtractNoteField(note, otherPhone, "otherphone");
+ ExtractNoteField(note, otherWeb, "otherweb");
// Is there any "extra" data that we may want to format nicely and place
// in the notes field?
- if ( !additionalEmail.IsEmpty() || !otherPhone.IsEmpty() || !otherWeb.IsEmpty() )
+ if (!additionalEmail.IsEmpty() || !otherPhone.IsEmpty() || !otherWeb.IsEmpty())
{
nsCString otherNotes(note);
- if ( !additionalEmail.IsEmpty() )
+ if (!additionalEmail.IsEmpty())
{
// Reconstitute line breaks for additional email
MsgReplaceSubstring(additionalEmail, "\x03", "\n");
// Try to figure out if there are multiple email addresses in additionalEmail
PRInt32 idx = MsgFindCharInSet(additionalEmail, "\t\r\n,; ");
if (idx != -1)
@@ -861,65 +864,65 @@ void nsEudoraAddress::AddSingleCard( CAl
stillMoreEmail.Trim(kWhitespace);
// Separate out the first address.
additionalEmail.SetLength(idx);
}
// If there were more than one additional email addresses store all the extra
// ones in the notes field, labeled nicely.
- if ( !stillMoreEmail.IsEmpty() )
+ if (!stillMoreEmail.IsEmpty())
FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHEREMAIL, stillMoreEmail, noteUTF16);
}
- if ( !otherPhone.IsEmpty() )
+ if (!otherPhone.IsEmpty())
{
// Reconstitute line breaks for other phone numbers
MsgReplaceSubstring(otherPhone, "\x03", "\n");
// Store other phone numbers in the notes field, labeled nicely
FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERPHONE, otherPhone, noteUTF16);
}
- if ( !otherWeb.IsEmpty() )
+ if (!otherWeb.IsEmpty())
{
// Reconstitute line breaks for other web sites
MsgReplaceSubstring(otherWeb, "\x03", "\n");
// Store other web sites in the notes field, labeled nicely
FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERWEB, otherWeb, noteUTF16);
}
- noteUTF16.Append( NS_ConvertASCIItoUTF16(note) );
+ noteUTF16.Append(NS_ConvertASCIItoUTF16(note));
}
}
CAliasData *pData = emailList.Count() ? (CAliasData *)emailList.ElementAt(0) : nsnull;
if (pData && !pData->m_realName.IsEmpty())
displayName = pData->m_realName;
else if (!name.IsEmpty())
displayName = name;
else
displayName = pEntry->m_name;
MsgReplaceSubstring(address, "\x03", "\n");
- SplitString( address, address2);
+ SplitString(address, address2);
MsgReplaceSubstring(note, "\x03", "\n");
MsgReplaceSubstring(fax, "\x03", " ");
MsgReplaceSubstring(secondaryFax, "\x03", " ");
MsgReplaceSubstring(phone, "\x03", " ");
MsgReplaceSubstring(name, "\x03", " ");
MsgReplaceSubstring(city, "\x03", " ");
MsgReplaceSubstring(state, "\x03", " ");
MsgReplaceSubstring(zip, "\x03", " ");
MsgReplaceSubstring(country, "\x03", " ");
MsgReplaceSubstring(addressWK, "\x03", "\n");
- SplitString( addressWK, address2WK);
+ SplitString(addressWK, address2WK);
MsgReplaceSubstring(phoneWK, "\x03", " ");
MsgReplaceSubstring(cityWK, "\x03", " ");
MsgReplaceSubstring(stateWK, "\x03", " ");
MsgReplaceSubstring(zipWK, "\x03", " ");
MsgReplaceSubstring(countryWK, "\x03", " ");
MsgReplaceSubstring(title, "\x03", " ");
MsgReplaceSubstring(company, "\x03", " ");
@@ -950,18 +953,18 @@ void nsEudoraAddress::AddSingleCard( CAl
ADD_FIELD_TO_DB_ROW(pDb, AddWorkPhone, newRow, phoneWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkAddress, newRow, addressWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkAddress2, newRow, address2WK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkCity, newRow, cityWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkZipCode, newRow, zipWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkState, newRow, stateWK, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddWorkCountry, newRow, countryWK, uniStr);
- if ( (primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsLiteral("home")) &&
- !mobile.IsEmpty() )
+ if ((primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsLiteral("home")) &&
+ !mobile.IsEmpty())
{
// Primary location field is either specified to be "home" or is not
// specified and there is a home mobile number, so use that as the mobile number.
ADD_FIELD_TO_DB_ROW(pDb, AddCellularNumber, newRow, mobile, uniStr);
isSecondaryMobileWorkNumber = true;
}
else
@@ -970,18 +973,18 @@ void nsEudoraAddress::AddSingleCard( CAl
// home mobile number, so use work mobile number.
ADD_FIELD_TO_DB_ROW(pDb, AddCellularNumber, newRow, secondaryMobile, uniStr);
// Home mobile number (if any) is the secondary mobile number
secondaryMobile = mobile;
isSecondaryMobileWorkNumber = false;
}
- if ( (primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsLiteral("home")) &&
- !fax.IsEmpty() )
+ if ((primaryLocation.IsEmpty() || primaryLocation.LowerCaseEqualsLiteral("home")) &&
+ !fax.IsEmpty())
{
// Primary location field is either specified to be "home" or is not
// specified and there is a home fax number, so use that as the fax number.
ADD_FIELD_TO_DB_ROW(pDb, AddFaxNumber, newRow, fax, uniStr);
isSecondaryFaxWorkNumber = true;
}
else
@@ -998,41 +1001,41 @@ void nsEudoraAddress::AddSingleCard( CAl
ADD_FIELD_TO_DB_ROW(pDb, Add2ndEmail, newRow, additionalEmail, uniStr);
// Extra info fields
PRInt32 stringID;
nsString pFormat;
nsString pCustomData;
// Add second mobile number, if any, to the Custom 1 field
- if ( !secondaryMobile.IsEmpty() )
+ if (!secondaryMobile.IsEmpty())
{
stringID = isSecondaryMobileWorkNumber ?
EUDORAIMPORT_ADDRESS_LABEL_WORKMOBILE : EUDORAIMPORT_ADDRESS_LABEL_HOMEMOBILE;
pFormat.Adopt(nsEudoraStringBundle::GetStringByID(stringID));
- pCustomData.Adopt( nsTextFormatter::smprintf(pFormat.get(), NS_ConvertASCIItoUTF16(secondaryMobile).get()) );
- pDb->AddCustom1( newRow, NS_ConvertUTF16toUTF8(pCustomData).get() );
+ pCustomData.Adopt(nsTextFormatter::smprintf(pFormat.get(), NS_ConvertASCIItoUTF16(secondaryMobile).get()));
+ pDb->AddCustom1(newRow, NS_ConvertUTF16toUTF8(pCustomData).get());
}
// Add second fax number, if any, to the Custom 2 field
- if ( !secondaryFax.IsEmpty() )
+ if (!secondaryFax.IsEmpty())
{
stringID = isSecondaryFaxWorkNumber ?
EUDORAIMPORT_ADDRESS_LABEL_WORKFAX : EUDORAIMPORT_ADDRESS_LABEL_HOMEFAX;
pFormat.Adopt(nsEudoraStringBundle::GetStringByID(stringID));
- pCustomData.Adopt( nsTextFormatter::smprintf(pFormat.get(), NS_ConvertASCIItoUTF16(secondaryFax).get()) );
- pDb->AddCustom2( newRow, NS_ConvertUTF16toUTF8(pCustomData).get() );
+ pCustomData.Adopt(nsTextFormatter::smprintf(pFormat.get(), NS_ConvertASCIItoUTF16(secondaryFax).get()));
+ pDb->AddCustom2(newRow, NS_ConvertUTF16toUTF8(pCustomData).get());
}
// Lastly, note field.
- pDb->AddNotes( newRow, NS_ConvertUTF16toUTF8(noteUTF16).get() );
+ pDb->AddNotes(newRow, NS_ConvertUTF16toUTF8(noteUTF16).get());
- pDb->AddCardRowToDB( newRow);
+ pDb->AddCardRowToDB(newRow);
- IMPORT_LOG1( "Added card to db: %s\n", displayName.get());
+ IMPORT_LOG1("Added card to db: %s\n", displayName.get());
}
}
//
// Since there is no way to check if a card for a given email address already exists,
// elements in 'membersArray' are make unique. So for each email address in 'emailList'
// we check it in 'membersArray' and if it's not there then we add it to 'membersArray'.
//
@@ -1083,34 +1086,34 @@ nsresult nsEudoraAddress::AddGroupMember
displayName = pData->m_realName;
else if (!pData->m_nickName.IsEmpty())
displayName = pData->m_nickName;
else
displayName.Truncate();
ADD_FIELD_TO_DB_ROW(pDb, AddDisplayName, newRow, displayName, uniStr);
ADD_FIELD_TO_DB_ROW(pDb, AddPrimaryEmail, newRow, pData->m_email, uniStr);
- rv = pDb->AddCardRowToDB( newRow);
+ rv = pDb->AddCardRowToDB(newRow);
NS_ENSURE_SUCCESS(rv, rv);
}
return rv;
}
nsresult nsEudoraAddress::AddSingleList(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb)
{
// Create a list.
nsCOMPtr <nsIMdbRow> newRow;
nsresult rv = pDb->GetNewListRow(getter_AddRefs(newRow));
if (NS_FAILED(rv) || !newRow)
return rv;
// Extract name from notes, if any
nsCString name;
- if ( !pEntry->m_notes.IsEmpty() )
+ if (!pEntry->m_notes.IsEmpty())
{
nsCString note(pEntry->m_notes);
ExtractNoteField(note, name, "name");
}
// If we got a name from the notes, use that for the name otherwise use the
// name in pEntry (which is the Eudora nickname).
rv = pDb->AddListName(newRow, name.IsEmpty() ? pEntry->m_name.get() : name.get());
--- a/mailnews/import/eudora/src/nsEudoraAddress.h
+++ b/mailnews/import/eudora/src/nsEudoraAddress.h
@@ -59,49 +59,49 @@ class nsIStringBundle;
class nsEudoraAddress {
public:
nsEudoraAddress();
virtual ~nsEudoraAddress();
// Things that must be overridden because they are platform specific.
// retrieve the mail folder
- virtual bool FindAddressFolder( nsIFile **pFolder) { return( false);}
+ virtual bool FindAddressFolder(nsIFile **pFolder) { return false;}
// get the list of mailboxes
- virtual nsresult FindAddressBooks( nsIFile *pRoot, nsISupportsArray **ppArray) { return( NS_ERROR_FAILURE);}
+ virtual nsresult FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray) { return NS_ERROR_FAILURE;}
// Non-platform specific common stuff
// import a mailbox
- nsresult ImportAddresses( PRUint32 *pBytes, bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIAddrDatabase *pDb, nsString& errors);
+ nsresult ImportAddresses(PRUint32 *pBytes, bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIAddrDatabase *pDb, nsString& errors);
private:
- void EmptyAliases( void);
- void ProcessLine( const char *pLine, PRInt32 len, nsString& errors);
- PRInt32 CountWhiteSpace( const char *pLine, PRInt32 len);
- CAliasEntry * ProcessAlias( const char *pLine, PRInt32 len, nsString& errors);
- void ProcessNote( const char *pLine, PRInt32 len, nsString& errors);
- PRInt32 GetAliasName( const char *pLine, PRInt32 len, nsCString& name);
- CAliasEntry * ResolveAlias( nsCString& name);
- void ResolveEntries( nsCString& name, nsVoidArray& list, nsVoidArray& result, bool addResolvedEntries, bool wasResolved, PRInt32& numResolved);
- void BuildABCards( PRUint32 *pBytes, nsIAddrDatabase *pDb);
- void AddSingleCard( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
- nsresult AddSingleList( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
+ void EmptyAliases(void);
+ void ProcessLine(const char *pLine, PRInt32 len, nsString& errors);
+ PRInt32 CountWhiteSpace(const char *pLine, PRInt32 len);
+ CAliasEntry * ProcessAlias(const char *pLine, PRInt32 len, nsString& errors);
+ void ProcessNote(const char *pLine, PRInt32 len, nsString& errors);
+ PRInt32 GetAliasName(const char *pLine, PRInt32 len, nsCString& name);
+ CAliasEntry * ResolveAlias(nsCString& name);
+ void ResolveEntries(nsCString& name, nsVoidArray& list, nsVoidArray& result, bool addResolvedEntries, bool wasResolved, PRInt32& numResolved);
+ void BuildABCards(PRUint32 *pBytes, nsIAddrDatabase *pDb);
+ void AddSingleCard(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
+ nsresult AddSingleList(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
nsresult AddGroupMembersAsCards(nsVoidArray &membersArray, nsIAddrDatabase *pDb);
void RememberGroupMembers(nsVoidArray &membersArray, nsVoidArray &emailList);
- PRInt32 FindAlias( nsCString& name);
- void ExtractNoteField( nsCString& note, nsCString& field, const char *pFieldName);
+ PRInt32 FindAlias(nsCString& name);
+ void ExtractNoteField(nsCString& note, nsCString& field, const char *pFieldName);
void FormatExtraDataInNoteField(PRInt32 labelStringID, nsCString& extraData, nsString& noteUTF16);
- void SanitizeValue( nsCString& val);
- void SplitString( nsCString& val1, nsCString& val2);
+ void SanitizeValue(nsCString& val);
+ void SplitString(nsCString& val1, nsCString& val2);
public:
- static PRInt32 CountQuote( const char *pLine, PRInt32 len);
- static PRInt32 CountComment( const char *pLine, PRInt32 len);
- static PRInt32 CountAngle( const char *pLine, PRInt32 len);
+ static PRInt32 CountQuote(const char *pLine, PRInt32 len);
+ static PRInt32 CountComment(const char *pLine, PRInt32 len);
+ static PRInt32 CountAngle(const char *pLine, PRInt32 len);
private:
nsVoidArray m_alias;
};
#endif /* nsEudoraAddress_h__ */
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -67,18 +67,18 @@
#include "EudoraDebugLog.h"
#include "nsMimeTypes.h"
#include "nsCRT.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsIMutableArray.h"
-static NS_DEFINE_CID( kMsgSendCID, NS_MSGSEND_CID);
-static NS_DEFINE_CID( kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
+static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID);
+static NS_DEFINE_CID(kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
// We need to do some calculations to set these numbers to something reasonable!
// Unless of course, CreateAndSendMessage will NEVER EVER leave us in the lurch
#define kHungCount 100000
#define kHungAbortCount 1000
// Define maximum possible length for content type sanity check
#define kContentTypeLengthSanityCheck 32
@@ -154,29 +154,29 @@ public:
}
/* void OnSendNotPerformed */
NS_IMETHOD OnSendNotPerformed(const char *aMsgID, nsresult aStatus) {return NS_OK;}
/* void OnGetDraftFolderURI (); */
NS_IMETHOD OnGetDraftFolderURI(const char *aFolderURI) {return NS_OK;}
- static nsresult CreateSendListener( nsIMsgSendListener **ppListener);
+ static nsresult CreateSendListener(nsIMsgSendListener **ppListener);
void Reset() { m_done = false; m_location = nsnull;}
public:
bool m_done;
nsCOMPtr <nsIFile> m_location;
};
NS_IMPL_THREADSAFE_ISUPPORTS1(EudoraSendListener, nsIMsgSendListener)
-nsresult EudoraSendListener::CreateSendListener( nsIMsgSendListener **ppListener)
+nsresult EudoraSendListener::CreateSendListener(nsIMsgSendListener **ppListener)
{
NS_ENSURE_ARG_POINTER(ppListener);
*ppListener = new EudoraSendListener();
NS_ENSURE_TRUE(*ppListener, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*ppListener);
return NS_OK;
}
@@ -190,104 +190,109 @@ nsresult EudoraSendListener::CreateSendL
nsEudoraCompose::nsEudoraCompose()
{
m_pAttachments = nsnull;
m_pListener = nsnull;
m_pMsgFields = nsnull;
m_pHeaders = p_test_headers;
if (m_pHeaders)
- m_headerLen = strlen( m_pHeaders);
+ m_headerLen = strlen(m_pHeaders);
else
m_headerLen = 0;
m_pBody = p_test_body;
if (m_pBody)
- m_bodyLen = strlen( m_pBody);
+ m_bodyLen = strlen(m_pBody);
else
m_bodyLen = 0;
m_readHeaders.m_convertCRs = true;
}
nsEudoraCompose::~nsEudoraCompose()
{
- NS_IF_RELEASE( m_pListener);
- NS_IF_RELEASE( m_pMsgFields);
+ NS_IF_RELEASE(m_pListener);
+ NS_IF_RELEASE(m_pMsgFields);
}
-nsresult nsEudoraCompose::CreateIdentity( void)
+nsresult nsEudoraCompose::CreateIdentity(void)
{
if (s_pIdentity)
- return( NS_OK);
+ return NS_OK;
// Should only create identity from main thread
NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_FAILURE);
nsresult rv;
nsCOMPtr<nsIMsgAccountManager> accMgr(do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
- rv = accMgr->CreateIdentity( &s_pIdentity);
+ rv = accMgr->CreateIdentity(&s_pIdentity);
nsString name(NS_LITERAL_STRING("Import Identity"));
if (s_pIdentity) {
s_pIdentity->SetFullName(name);
s_pIdentity->SetIdentityName(name);
s_pIdentity->SetEmail(NS_LITERAL_CSTRING("import@import.service"));
// SetDoFcc to false to save time when CreateAndSendMessage operates.
// Profiling revealed that GetFolderURIFromUserPrefs was taking up a significant chunk
// of time during the operation of CreateAndSendMessage. By calling SetDoFcc(false),
// we skip Fcc handling code inside of InitCompositionFields (called indirectly during
// CreateAndSendMessage operation). There's no point in any Fcc code firing since the
// message will never actually be sent anyway.
s_pIdentity->SetDoFcc(false);
}
- return( rv);
+ return rv;
}
-void nsEudoraCompose::ReleaseIdentity( void)
+void nsEudoraCompose::ReleaseIdentity(void)
{
if (s_pIdentity) {
nsresult rv = s_pIdentity->ClearAllValues();
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to clear values");
if (NS_FAILED(rv)) return;
NS_RELEASE(s_pIdentity);
}
}
-nsresult nsEudoraCompose::CreateComponents( void)
+nsresult nsEudoraCompose::CreateComponents(void)
{
nsresult rv = NS_OK;
if (!m_pIOService) {
- IMPORT_LOG0( "Creating nsIOService\n");
+ IMPORT_LOG0("Creating nsIOService\n");
m_pIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
}
- NS_IF_RELEASE( m_pMsgFields);
- if (!m_pListener && NS_SUCCEEDED( rv))
- rv = EudoraSendListener::CreateSendListener( &m_pListener);
+ NS_IF_RELEASE(m_pMsgFields);
+ if (!m_pListener && NS_SUCCEEDED(rv))
+ rv = EudoraSendListener::CreateSendListener(&m_pListener);
if (NS_SUCCEEDED(rv)) {
- rv = CallCreateInstance( kMsgCompFieldsCID, &m_pMsgFields);
+ rv = CallCreateInstance(kMsgCompFieldsCID, &m_pMsgFields);
if (NS_SUCCEEDED(rv) && m_pMsgFields) {
- // IMPORT_LOG0( "nsOutlookCompose - CreateComponents succeeded\n");
- m_pMsgFields->SetForcePlainText( false);
- return( NS_OK);
+ // IMPORT_LOG0("nsOutlookCompose - CreateComponents succeeded\n");
+ m_pMsgFields->SetForcePlainText(false);
+ return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
-void nsEudoraCompose::GetNthHeader( const char *pData, PRInt32 dataLen, PRInt32 n, nsCString& header, nsCString& val, bool unwrap)
+void nsEudoraCompose::GetNthHeader(const char *pData,
+ PRInt32 dataLen,
+ PRInt32 n,
+ nsCString& header,
+ nsCString& val,
+ bool unwrap)
{
header.Truncate();
val.Truncate();
if (!pData)
return;
PRInt32 index = 0;
PRInt32 len;
@@ -297,34 +302,34 @@ void nsEudoraCompose::GetNthHeader( cons
if (n == 0) {
pStart = pChar;
len = 0;
while ((start < dataLen) && (*pChar != ':')) {
start++;
len++;
pChar++;
}
- header.Append( pStart, len);
- header.Trim( kWhitespace);
+ header.Append(pStart, len);
+ header.Trim(kWhitespace);
start++;
pChar++;
}
else {
while (start < dataLen) {
if ((*pChar != ' ') && (*pChar != '\t')) {
if (n == index) {
pStart = pChar;
len = 0;
while ((start < dataLen) && (*pChar != ':')) {
start++;
len++;
pChar++;
}
- header.Append( pStart, len);
- header.Trim( kWhitespace);
+ header.Append(pStart, len);
+ header.Trim(kWhitespace);
start++;
pChar++;
break;
}
else
index++;
}
@@ -351,17 +356,17 @@ void nsEudoraCompose::GetNthHeader( cons
while (end < dataLen) {
// Skip to next end of line.
while ((end < dataLen) && (*pChar != nsCRT::CR) && (*pChar != nsCRT::LF)) {
end++;
pChar++;
}
if (end > start) {
- val.Append( pData + start, end - start);
+ val.Append(pData + start, end - start);
}
lineEnd = end;
pStart = pChar;
// Skip over end of line(s).
while ((end < dataLen) &&
((*pChar == nsCRT::CR) || (*pChar == nsCRT::LF))) {
@@ -376,38 +381,42 @@ void nsEudoraCompose::GetNthHeader( cons
end++;
pChar++;
}
if (start == end)
break;
if (unwrap)
- val.Append( ' ');
+ val.Append(' ');
else {
- val.Append( pStart, end - lineEnd);
+ val.Append(pStart, end - lineEnd);
}
start = end;
}
- val.Trim( kWhitespace);
+ val.Trim(kWhitespace);
}
-void nsEudoraCompose::GetHeaderValue( const char *pData, PRInt32 dataLen, const char *pHeader, nsCString& val, bool unwrap)
+void nsEudoraCompose::GetHeaderValue(const char *pData,
+ PRInt32 dataLen,
+ const char *pHeader,
+ nsCString& val,
+ bool unwrap)
{
val.Truncate();
if (!pData)
return;
PRInt32 start = 0;
- PRInt32 len = strlen( pHeader);
+ PRInt32 len = strlen(pHeader);
const char *pChar = pData;
- if (!PL_strncasecmp( pHeader, pData, len)) {
+ if (!PL_strncasecmp(pHeader, pData, len)) {
start = len;
}
else {
while (start < dataLen) {
// Skip to next end of line.
while ((start < dataLen) &&
(*pChar != nsCRT::CR) && (*pChar != nsCRT::LF)) {
start++;
@@ -415,17 +424,17 @@ void nsEudoraCompose::GetHeaderValue( co
}
// Skip over end of line(s).
while ((start < dataLen) &&
((*pChar == nsCRT::CR) || (*pChar == nsCRT::LF))) {
start++;
pChar++;
}
- if ((start < dataLen) && !PL_strncasecmp( pChar, pHeader, len))
+ if ((start < dataLen) && !PL_strncasecmp(pChar, pHeader, len))
break;
}
if (start < dataLen)
start += len;
}
if (start >= dataLen)
return;
@@ -438,19 +447,18 @@ void nsEudoraCompose::GetHeaderValue( co
while (end < dataLen) {
// Skip to next end of line.
while ((end < dataLen) && (*pChar != nsCRT::CR) && (*pChar != nsCRT::LF)) {
end++;
pChar++;
}
- if (end > start) {
- val.Append( pData + start, end - start);
- }
+ if (end > start)
+ val.Append(pData + start, end - start);
lineEnd = end;
pStart = pChar;
// Skip over the end of line(s).
while ((end < dataLen) &&
((*pChar == nsCRT::CR) || (*pChar == nsCRT::LF))) {
end++;
@@ -464,60 +472,60 @@ void nsEudoraCompose::GetHeaderValue( co
end++;
pChar++;
}
if (start == end)
break;
if (unwrap)
- val.Append( ' ');
+ val.Append(' ');
else {
- val.Append( pStart, end - lineEnd);
+ val.Append(pStart, end - lineEnd);
}
start = end;
}
- val.Trim( kWhitespace);
+ val.Trim(kWhitespace);
}
-void nsEudoraCompose::ExtractCharset( nsString& str)
+void nsEudoraCompose::ExtractCharset(nsString& str)
{
PRInt32 idx = MsgFind(str, "charset=", true, 0);
if (idx != -1) {
str.Cut(0, idx + 8);
- idx = str.FindChar( ';');
+ idx = str.FindChar(';');
if (idx != -1)
str.SetLength(idx);
- str.Trim( kWhitespace);
- if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
+ str.Trim(kWhitespace);
+ if ((str.CharAt(0) == '"') && (str.Length() > 2)) {
str.SetLength(str.Length() - 1);
str.Cut(0, 1);
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
}
}
else
str.Truncate();
}
-void nsEudoraCompose::ExtractType( nsString& str)
+void nsEudoraCompose::ExtractType(nsString& str)
{
nsString tStr;
- PRInt32 idx = str.FindChar( ';');
+ PRInt32 idx = str.FindChar(';');
if (idx != -1)
str.SetLength(idx);
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
- if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
+ if ((str.CharAt(0) == '"') && (str.Length() > 2)) {
str.SetLength(str.Length() - 1);
str.Cut(0, 1);
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
}
// if multipart then ignore it since no outlook message body is ever
// valid multipart!
if (StringBeginsWith(str, NS_LITERAL_STRING("multipart/"), nsCaseInsensitiveStringComparator()))
str.Truncate();
}
@@ -540,99 +548,97 @@ nsresult nsEudoraCompose::GetLocalAttach
ImportAttachment * pAttach;
for (PRInt32 i = 0; i < count; i++) {
nsCOMPtr<nsIMsgAttachedFile> a(do_CreateInstance(NS_MSGATTACHEDFILE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
// nsMsgNewURL(&url, "file://C:/boxster.jpg");
// a[i].orig_url = url;
- // NS_PRECONDITION( false, "Forced Break");
-
- pAttach = (ImportAttachment *) m_pAttachments->ElementAt( i);
+ pAttach = (ImportAttachment *) m_pAttachments->ElementAt(i);
nsCOMPtr<nsILocalFile> tmpFile = do_QueryInterface(pAttach->pAttachment);
a->SetTmpFile(tmpFile);
urlStr.Adopt(0);
nsCOMPtr <nsIURI> uri;
nsresult rv = NS_NewFileURI(getter_AddRefs(uri), pAttach->pAttachment);
NS_ENSURE_SUCCESS(rv, nsnull);
uri->GetSpec(urlStr);
if (urlStr.IsEmpty())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> origUrl;
- rv = m_pIOService->NewURI( urlStr, nsnull, nsnull, getter_AddRefs(origUrl));
+ rv = m_pIOService->NewURI(urlStr, nsnull, nsnull, getter_AddRefs(origUrl));
NS_ENSURE_SUCCESS(rv, rv);
a->SetOrigUrl(origUrl);
a->SetType(nsDependentCString(pAttach->mimeType));
a->SetRealName(nsDependentCString(pAttach->description));
a->SetEncoding(NS_LITERAL_CSTRING(ENCODING_BINARY));
attachments->AppendElement(a, false);
}
return NS_OK;
}
// Test a message send????
nsresult nsEudoraCompose::SendTheMessage(nsIFile *pMailImportLocation, nsIFile **pMsg)
{
nsresult rv = CreateComponents();
- if (NS_FAILED( rv))
- return( rv);
+ if (NS_FAILED(rv))
+ return rv;
- // IMPORT_LOG0( "Outlook Compose created necessary components\n");
+ // IMPORT_LOG0("Outlook Compose created necessary components\n");
nsString bodyType;
nsString charSet;
nsString headerVal;
- GetHeaderValue( m_pHeaders, m_headerLen, "From:", headerVal);
+ GetHeaderValue(m_pHeaders, m_headerLen, "From:", headerVal);
if (!headerVal.IsEmpty())
- m_pMsgFields->SetFrom( headerVal);
- GetHeaderValue( m_pHeaders, m_headerLen, "To:", headerVal);
+ m_pMsgFields->SetFrom(headerVal);
+ GetHeaderValue(m_pHeaders, m_headerLen, "To:", headerVal);
if (!headerVal.IsEmpty())
- m_pMsgFields->SetTo( headerVal);
- GetHeaderValue( m_pHeaders, m_headerLen, "Subject:", headerVal);
+ m_pMsgFields->SetTo(headerVal);
+ GetHeaderValue(m_pHeaders, m_headerLen, "Subject:", headerVal);
if (!headerVal.IsEmpty())
- m_pMsgFields->SetSubject( headerVal);
- GetHeaderValue( m_pHeaders, m_headerLen, "Content-type:", headerVal);
+ m_pMsgFields->SetSubject(headerVal);
+ GetHeaderValue(m_pHeaders, m_headerLen, "Content-type:", headerVal);
bodyType = headerVal;
- ExtractType( bodyType);
- ExtractCharset( headerVal);
+ ExtractType(bodyType);
+ ExtractCharset(headerVal);
// Use platform charset as default if the msg doesn't specify one
// (ie, no 'charset' param in the Content-Type: header). As the last
// resort we'll use the mail default charset.
// (ie, no 'charset' param in the Content-Type: header) or if the
// charset parameter fails a length sanity check.
// As the last resort we'll use the mail default charset.
- if ( headerVal.IsEmpty() || (headerVal.Length() > kContentTypeLengthSanityCheck) )
+ if (headerVal.IsEmpty() || (headerVal.Length() > kContentTypeLengthSanityCheck))
{
headerVal.AssignASCII(nsMsgI18NFileSystemCharset());
if (headerVal.IsEmpty())
{ // last resort
if (m_defCharset.IsEmpty())
{
nsString defaultCharset;
NS_GetLocalizedUnicharPreferenceWithDefault(nsnull, "mailnews.view_default_charset",
NS_LITERAL_STRING("ISO-8859-1"), defaultCharset);
m_defCharset = defaultCharset;
}
headerVal = m_defCharset;
}
}
- m_pMsgFields->SetCharacterSet( NS_LossyConvertUTF16toASCII(headerVal).get() );
+ m_pMsgFields->SetCharacterSet(NS_LossyConvertUTF16toASCII(headerVal).get());
charSet = headerVal;
- GetHeaderValue( m_pHeaders, m_headerLen, "CC:", headerVal);
+ GetHeaderValue(m_pHeaders, m_headerLen, "CC:", headerVal);
if (!headerVal.IsEmpty())
- m_pMsgFields->SetCc( headerVal);
- GetHeaderValue( m_pHeaders, m_headerLen, "Message-ID:", headerVal);
+ m_pMsgFields->SetCc(headerVal);
+ GetHeaderValue(m_pHeaders, m_headerLen, "Message-ID:", headerVal);
if (!headerVal.IsEmpty())
- m_pMsgFields->SetMessageId( NS_LossyConvertUTF16toASCII(headerVal).get() );
- GetHeaderValue( m_pHeaders, m_headerLen, "Reply-To:", headerVal);
+ m_pMsgFields->SetMessageId(NS_LossyConvertUTF16toASCII(headerVal).get());
+ GetHeaderValue(m_pHeaders, m_headerLen, "Reply-To:", headerVal);
if (!headerVal.IsEmpty())
- m_pMsgFields->SetReplyTo( headerVal);
+ m_pMsgFields->SetReplyTo(headerVal);
// what about all of the other headers?!?!?!?!?!?!
char *pMimeType;
if (!bodyType.IsEmpty())
pMimeType = ToNewCString(NS_LossyConvertUTF16toASCII(bodyType));
else
pMimeType = ToNewCString(m_bodyType);
@@ -652,26 +658,24 @@ nsresult nsEudoraCompose::SendTheMessage
*UNLESS* of course, I don't know what the charset of the message
should be? How do I determine what the charset should
be if it doesn't exist?
*/
nsCString body;
- rv = nsMsgI18NConvertFromUnicode( NS_LossyConvertUTF16toASCII(charSet).get(),
+ rv = nsMsgI18NConvertFromUnicode(NS_LossyConvertUTF16toASCII(charSet).get(),
uniBody, body);
- if (NS_FAILED( rv)) {
+ if (NS_FAILED(rv) && !charSet.Equals(m_defCharset)) {
// in this case, if we did not use the default compose
// charset, then try that.
- if (!charSet.Equals( m_defCharset)) {
- body.Truncate();
- rv = nsMsgI18NConvertFromUnicode( NS_LossyConvertUTF16toASCII(charSet).get(),
- uniBody, body);
- }
+ body.Truncate();
+ rv = nsMsgI18NConvertFromUnicode(NS_LossyConvertUTF16toASCII(charSet).get(),
+ uniBody, body);
}
uniBody.Truncate();
// See if it's a draft msg (ie, no From: or no To: AND no Cc: AND no Bcc:).
// Eudora saves sent and draft msgs in Out folder (ie, mixed) and it does
// store Bcc: header in the msg itself.
nsAutoString from, to, cc, bcc;
@@ -691,294 +695,298 @@ nsresult nsEudoraCompose::SendTheMessage
body.get(), // body pointer
body.Length(), // body length
createAsDraft,
pAttach, // local attachments
embeddedObjects,
m_pListener); // listener
EudoraSendListener *pListen = (EudoraSendListener *)m_pListener;
- if (NS_FAILED( rv)) {
- IMPORT_LOG1( "*** Error, CreateAndSendMessage FAILED: 0x%lx\n", rv);
- // IMPORT_LOG1( "Headers: %80s\n", m_pHeaders);
+ if (NS_FAILED(rv)) {
+ IMPORT_LOG1("*** Error, CreateAndSendMessage FAILED: 0x%lx\n", rv);
+ // IMPORT_LOG1("Headers: %80s\n", m_pHeaders);
}
else {
// wait for the listener to get done!
PRInt32 abortCnt = 0;
PRInt32 cnt = 0;
PRInt32 sleepCnt = 1;
while (!pListen->m_done && (abortCnt < kHungAbortCount)) {
- PR_Sleep( sleepCnt);
+ PR_Sleep(sleepCnt);
cnt++;
if (cnt > kHungCount) {
abortCnt++;
sleepCnt *= 2;
cnt = 0;
}
}
if (abortCnt >= kHungAbortCount) {
- IMPORT_LOG0( "**** Create and send message hung\n");
- IMPORT_LOG1( "Headers: %s\n", m_pHeaders);
- IMPORT_LOG1( "Body: %s\n", m_pBody);
+ IMPORT_LOG0("**** Create and send message hung\n");
+ IMPORT_LOG1("Headers: %s\n", m_pHeaders);
+ IMPORT_LOG1("Body: %s\n", m_pBody);
rv = NS_ERROR_FAILURE;
}
}
if (pMimeType)
- NS_Free( pMimeType);
+ NS_Free(pMimeType);
if (pListen->m_location) {
pListen->m_location->Clone(pMsg);
rv = NS_OK;
}
else {
rv = NS_ERROR_FAILURE;
- IMPORT_LOG0( "*** Error, Outlook compose unsuccessful\n");
+ IMPORT_LOG0("*** Error, Outlook compose unsuccessful\n");
}
pListen->Reset();
- return( rv);
+ return rv;
}
-bool SimpleBufferTonyRCopiedOnce::SpecialMemCpy( PRInt32 offset, const char *pData, PRInt32 len, PRInt32 *pWritten)
+bool SimpleBufferTonyRCopiedOnce::SpecialMemCpy(PRInt32 offset, const char *pData, PRInt32 len, PRInt32 *pWritten)
{
// Arg!!!!! Mozilla can't handle plain CRs in any mail messages. Particularly a
// problem with Eudora since it doesn't give a rats a**
*pWritten = len;
PRInt32 sz = offset + len;
if (offset) {
if ((m_pBuffer[offset - 1] == nsCRT::CR) && (*pData != nsCRT::LF)) {
sz++;
- if (!Grow( sz)) return( false);
+ if (!Grow(sz))
+ return false;
m_pBuffer[offset] = nsCRT::LF;
offset++;
(*pWritten)++;
}
}
while (len > 0) {
if ((*pData == nsCRT::CR) && (*(pData + 1) != nsCRT::LF)) {
sz++;
- if (!Grow( sz)) return( false);
+ if (!Grow(sz))
+ return false;
m_pBuffer[offset] = nsCRT::CR;
offset++;
m_pBuffer[offset] = nsCRT::LF;
(*pWritten)++;
}
else {
m_pBuffer[offset] = *pData;
}
offset++;
pData++;
len--;
}
- return( true);
+ return true;
}
-nsresult nsEudoraCompose::ReadHeaders( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header)
+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) {
+ 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 (!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 (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);
+ 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 (!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 (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(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);
+ 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);
+ return NS_OK;
}
-PRInt32 nsEudoraCompose::FindNextEndLine( SimpleBufferTonyRCopiedOnce& data)
+PRInt32 nsEudoraCompose::FindNextEndLine(SimpleBufferTonyRCopiedOnce& data)
{
PRInt32 len = data.m_bytesInBuf - data.m_writeOffset;
if (!len)
- return( -1);
+ return -1;
PRInt32 count = 0;
const char *pData = data.m_pBuffer + data.m_writeOffset;
// Skip over end of line(s).
while ((count < len) && ((*pData == nsCRT::CR) || (*pData == nsCRT::LF))) {
pData++;
count++;
}
// Skip to next end of line.
while ((count < len) && (*pData != nsCRT::CR) && (*pData != nsCRT::LF)) {
pData++;
count++;
}
- if (count < len)
- return( count);
- return( -1);
+ return (count < len) ? count : -1;
}
-PRInt32 nsEudoraCompose::IsEndHeaders( SimpleBufferTonyRCopiedOnce& data)
+PRInt32 nsEudoraCompose::IsEndHeaders(SimpleBufferTonyRCopiedOnce& data)
{
PRInt32 len = data.m_bytesInBuf - data.m_writeOffset;
if (len < 2)
- return( -1);
+ return -1;
const char *pChar = data.m_pBuffer + data.m_writeOffset;
// Double nsCRT::CR.
if ((*pChar == nsCRT::CR) && (*(pChar + 1) == nsCRT::CR))
- return( 2);
+ return 2;
if (len < 4)
- return( -1);
+ return -1;
// Double (nsCRT::CR + nsCRT::LF).
if ((*pChar == nsCRT::CR) && (*(pChar + 1) == nsCRT::LF) &&
(*(pChar + 2) == nsCRT::CR) && (*(pChar + 3) == nsCRT::LF))
- return( 4);
+ return 4;
- return( -1);
+ return -1;
}
-nsresult nsEudoraCompose::CopyComposedMessage( nsCString& fromLine, nsIFile *pSrc, nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& copy)
+nsresult nsEudoraCompose::CopyComposedMessage(nsCString& fromLine,
+ nsIFile *pSrc,
+ nsIOutputStream *pDst,
+ SimpleBufferTonyRCopiedOnce& copy)
{
copy.m_bytesInBuf = 0;
copy.m_writeOffset = 0;
ReadFileState state;
state.pFile = pSrc;
state.offset = 0;
state.size = 0;
- pSrc->GetFileSize( &state.size);
+ pSrc->GetFileSize(&state.size);
if (!state.size) {
- IMPORT_LOG0( "*** Error, unexpected zero file size for composed message\n");
- return( NS_ERROR_FAILURE);
+ IMPORT_LOG0("*** Error, unexpected zero file size for composed message\n");
+ return NS_ERROR_FAILURE;
}
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(state.pInputStream), pSrc);
- if (NS_FAILED( rv)) {
- IMPORT_LOG0( "*** Error, unable to open composed message file\n");
- return( NS_ERROR_FAILURE);
+ if (NS_FAILED(rv)) {
+ IMPORT_LOG0("*** Error, unable to open composed message file\n");
+ return NS_ERROR_FAILURE;
}
PRUint32 written;
- rv = pDst->Write( fromLine.get(), fromLine.Length(), &written);
+ rv = pDst->Write(fromLine.get(), fromLine.Length(), &written);
// well, isn't this a hoot!
// Read the headers from the new message, get the ones we like
// and write out only the headers we want from the new message,
// along with all of the other headers from the "old" message!
- if (NS_SUCCEEDED( rv))
- rv = FillMailBuffer( &state, copy);
- if (NS_SUCCEEDED( rv))
- rv = ReadHeaders( &state, copy, m_readHeaders);
+ if (NS_SUCCEEDED(rv))
+ rv = FillMailBuffer(&state, copy);
+ if (NS_SUCCEEDED(rv))
+ rv = ReadHeaders(&state, copy, m_readHeaders);
- if (NS_SUCCEEDED( rv)) {
- rv = WriteHeaders( pDst, m_readHeaders);
- }
+ if (NS_SUCCEEDED(rv))
+ rv = WriteHeaders(pDst, m_readHeaders);
// We need to go ahead and write out the rest of the copy buffer
// so that the following will properly copy the rest of the body
char lastChar = 0;
rv = EscapeFromSpaceLine(pDst, copy.m_pBuffer + copy.m_writeOffset, copy.m_pBuffer+copy.m_bytesInBuf);
if (copy.m_bytesInBuf)
lastChar = copy.m_pBuffer[copy.m_bytesInBuf - 1];
if (NS_SUCCEEDED(rv))
copy.m_writeOffset = copy.m_bytesInBuf;
- while ((state.offset < state.size) && NS_SUCCEEDED( rv)) {
- rv = FillMailBuffer( &state, copy);
- if (NS_SUCCEEDED( rv)) {
+ while ((state.offset < state.size) && NS_SUCCEEDED(rv)) {
+ rv = FillMailBuffer(&state, copy);
+ if (NS_SUCCEEDED(rv)) {
rv = EscapeFromSpaceLine(pDst, copy.m_pBuffer + copy.m_writeOffset, copy.m_pBuffer+copy.m_bytesInBuf);
lastChar = copy.m_pBuffer[copy.m_bytesInBuf - 1];
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
copy.m_writeOffset = copy.m_bytesInBuf;
else
- IMPORT_LOG0( "*** Error writing to destination mailbox\n");
+ IMPORT_LOG0("*** Error writing to destination mailbox\n");
}
}
state.pInputStream->Close();
if ((lastChar != nsCRT::LF) && NS_SUCCEEDED(rv)) {
- rv = pDst->Write( "\x0D\x0A", 2, &written);
+ rv = pDst->Write("\x0D\x0A", 2, &written);
if (written != 2)
rv = NS_ERROR_FAILURE;
}
- return( rv);
+ return rv;
}
-nsresult nsEudoraCompose::FillMailBuffer( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read)
+nsresult nsEudoraCompose::FillMailBuffer(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read)
{
if (read.m_writeOffset >= read.m_bytesInBuf) {
read.m_writeOffset = 0;
read.m_bytesInBuf = 0;
}
else if (read.m_writeOffset) {
- memcpy( read.m_pBuffer, read.m_pBuffer + read.m_writeOffset, read.m_bytesInBuf - read.m_writeOffset);
+ memcpy(read.m_pBuffer, read.m_pBuffer + read.m_writeOffset, read.m_bytesInBuf - read.m_writeOffset);
read.m_bytesInBuf -= read.m_writeOffset;
read.m_writeOffset = 0;
}
PRUint32 count = read.m_size - read.m_bytesInBuf;
if ((count + pState->offset) > pState->size)
count = pState->size - pState->offset;
if (count) {
PRUint32 bytesRead = 0;
char * pBuffer = read.m_pBuffer + read.m_bytesInBuf;
nsresult rv = pState->pInputStream->Read(pBuffer, count, &bytesRead);
- if (NS_FAILED( rv)) return( rv);
- if (bytesRead != count) return( NS_ERROR_FAILURE);
+ if (NS_FAILED(rv))
+ return rv;
+ if (bytesRead != count)
+ return NS_ERROR_FAILURE;
read.m_bytesInBuf += bytesRead;
pState->offset += bytesRead;
}
- return( NS_OK);
+ return NS_OK;
}
#define kMaxSpecialHeaders 3
static const char *gSpecialHeaders[kMaxSpecialHeaders] = {
"Content-type",
"MIME-Version",
"Content-transfer-encoding"
@@ -989,34 +997,34 @@ static const char *gSpecialHeaders[kMaxS
static const char *gReplaceHeaders[kMaxReplaceHeaders] = {
"From",
"To",
"Subject",
"Reply-to",
"cc"
};
-bool nsEudoraCompose::IsReplaceHeader( const char *pHeader)
+bool nsEudoraCompose::IsReplaceHeader(const char *pHeader)
{
for (int i = 0; i < kMaxReplaceHeaders; i++) {
- if (!PL_strcasecmp( pHeader, gReplaceHeaders[i]))
- return( true);
+ if (!PL_strcasecmp(pHeader, gReplaceHeaders[i]))
+ return true;
}
- return( false);
+ return false;
}
-PRInt32 nsEudoraCompose::IsSpecialHeader( const char *pHeader)
+PRInt32 nsEudoraCompose::IsSpecialHeader(const char *pHeader)
{
for (int i = 0; i < kMaxSpecialHeaders; i++) {
- if (!PL_strcasecmp( pHeader, gSpecialHeaders[i]))
- return( (PRInt32) i);
+ if (!PL_strcasecmp(pHeader, gSpecialHeaders[i]))
+ return (PRInt32) i;
}
- return( -1);
+ return -1;
}
nsresult nsEudoraCompose::WriteHeaders(nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& newHeaders)
{
// Well, ain't this a peach?
// This is rather disgusting but there really isn't much to be done about it....
@@ -1037,74 +1045,77 @@ nsresult nsEudoraCompose::WriteHeaders(n
int i;
for (i = 0; i < kMaxSpecialHeaders; i++)
specials[i] = false;
// m_pHeaders - contains headers from a Eudora msg.
// newHeaders - contains headers from a mozilla msg (more headers here).
do {
- GetNthHeader( m_pHeaders, m_headerLen, n, header, val, false);
- // GetNthHeader( newHeaders.m_pBuffer, newHeaders.m_writeOffset, n, header, val, false);
+ GetNthHeader(m_pHeaders, m_headerLen, n, header, val, false);
+ // GetNthHeader(newHeaders.m_pBuffer, newHeaders.m_writeOffset, n, header, val, false);
if (!header.IsEmpty()) {
- if ((specialHeader = IsSpecialHeader( header.get())) != -1) {
- header.Append( ':');
- GetHeaderValue( newHeaders.m_pBuffer, newHeaders.m_writeOffset - 1, header.get(), val, false);
- header.SetLength( header.Length() - 1);
+ if ((specialHeader = IsSpecialHeader(header.get())) != -1) {
+ header.Append(':');
+ GetHeaderValue(newHeaders.m_pBuffer, newHeaders.m_writeOffset - 1,
+ header.get(), val, false);
+ header.SetLength(header.Length() - 1);
specials[specialHeader] = true;
}
- else if (IsReplaceHeader( header.get())) {
+ else if (IsReplaceHeader(header.get())) {
replaceVal.Truncate();
- header.Append( ':');
- GetHeaderValue( newHeaders.m_pBuffer, newHeaders.m_writeOffset - 1, header.get(), replaceVal, false);
- header.SetLength( header.Length() - 1);
+ header.Append(':');
+ GetHeaderValue(newHeaders.m_pBuffer, newHeaders.m_writeOffset - 1,
+ header.get(), replaceVal, false);
+ header.SetLength(header.Length() - 1);
if (!replaceVal.IsEmpty())
val = replaceVal;
}
if (!val.IsEmpty()) {
// See if we're writing out a Date: header.
if (header.LowerCaseEqualsLiteral("date"))
hasDateHeader = true;
- rv = pDst->Write( header.get(), header.Length(), &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( ": ", 2, &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( val.get(), val.Length(), &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( "\x0D\x0A", 2, &written);
+ rv = pDst->Write(header.get(), header.Length(), &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write(": ", 2, &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write(val.get(), val.Length(), &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write("\x0D\x0A", 2, &written);
}
}
n++;
- } while (NS_SUCCEEDED( rv) && !header.IsEmpty());
+ } while (NS_SUCCEEDED(rv) && !header.IsEmpty());
// If we don't have Date: header so far then use the default one (taken from Eudora "From " line).
if (!hasDateHeader)
{
rv = pDst->Write(m_defaultDate.get(), m_defaultDate.Length(), &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( "\x0D\x0A", 2, &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write("\x0D\x0A", 2, &written);
}
- for (i = 0; (i < kMaxSpecialHeaders) && NS_SUCCEEDED( rv); i++) {
+ for (i = 0; (i < kMaxSpecialHeaders) && NS_SUCCEEDED(rv); i++) {
if (!specials[i]) {
header = gSpecialHeaders[i];
- header.Append( ':');
- GetHeaderValue( newHeaders.m_pBuffer, newHeaders.m_writeOffset - 1, header.get(), val, false);
- header.SetLength( header.Length() - 1);
+ header.Append(':');
+ GetHeaderValue(newHeaders.m_pBuffer, newHeaders.m_writeOffset - 1,
+ header.get(), val, false);
+ header.SetLength(header.Length() - 1);
if (!val.IsEmpty()) {
- rv = pDst->Write( header.get(), header.Length(), &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( ": ", 2, &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( val.get(), val.Length(), &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( "\x0D\x0A", 2, &written);
+ rv = pDst->Write(header.get(), header.Length(), &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write(": ", 2, &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write(val.get(), val.Length(), &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write("\x0D\x0A", 2, &written);
}
}
}
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( "\x0D\x0A", 2, &written);
- return( rv);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write("\x0D\x0A", 2, &written);
+ return rv;
}
--- a/mailnews/import/eudora/src/nsEudoraCompose.h
+++ b/mailnews/import/eudora/src/nsEudoraCompose.h
@@ -81,54 +81,59 @@ public:
} ReadFileState;
class SimpleBufferTonyRCopiedOnce {
public:
SimpleBufferTonyRCopiedOnce() {m_pBuffer = nsnull; m_size = 0; m_growBy = 4096; m_writeOffset = 0;
m_bytesInBuf = 0; m_convertCRs = false;}
~SimpleBufferTonyRCopiedOnce() { if (m_pBuffer) delete [] m_pBuffer;}
- bool Allocate( PRInt32 sz) {
- if (m_pBuffer) delete [] m_pBuffer;
+ bool Allocate(PRInt32 sz) {
+ if (m_pBuffer)
+ delete [] m_pBuffer;
m_pBuffer = new char[sz];
- if (m_pBuffer) { m_size = sz; return( true); }
- else { m_size = 0; return( false);}
+ if (m_pBuffer) {
+ m_size = sz;
+ return true;
+ }
+ m_size = 0;
+ return false;
}
- bool Grow( PRInt32 newSize) { if (newSize > m_size) return( ReAllocate( newSize)); else return( true);}
- bool ReAllocate( PRInt32 newSize) {
- if (newSize <= m_size) return( true);
+ bool Grow(PRInt32 newSize) { if (newSize > m_size) return ReAllocate(newSize); else return true;}
+ bool ReAllocate(PRInt32 newSize) {
+ if (newSize <= m_size) return true;
char *pOldBuffer = m_pBuffer;
PRInt32 oldSize = m_size;
m_pBuffer = nsnull;
while (m_size < newSize) m_size += m_growBy;
- if (Allocate( m_size)) {
- if (pOldBuffer) { memcpy( m_pBuffer, pOldBuffer, oldSize); delete [] pOldBuffer;}
- return( true);
+ if (Allocate(m_size)) {
+ if (pOldBuffer) { memcpy(m_pBuffer, pOldBuffer, oldSize); delete [] pOldBuffer;}
+ return true;
}
- else { m_pBuffer = pOldBuffer; m_size = oldSize; return( false);}
+ else { m_pBuffer = pOldBuffer; m_size = oldSize; return false;}
}
- bool Write( PRInt32 offset, const char *pData, PRInt32 len, PRInt32 *pWritten) {
+ bool Write(PRInt32 offset, const char *pData, PRInt32 len, PRInt32 *pWritten) {
*pWritten = len;
- if (!len) return( true);
- if (!Grow( offset + len)) return( false);
+ if (!len) return true;
+ if (!Grow(offset + len)) return false;
if (m_convertCRs)
- return( SpecialMemCpy( offset, pData, len, pWritten));
- memcpy( m_pBuffer + offset, pData, len);
- return( true);
+ return SpecialMemCpy(offset, pData, len, pWritten);
+ memcpy(m_pBuffer + offset, pData, len);
+ return true;
}
- bool Write( const char *pData, PRInt32 len) {
+ bool Write(const char *pData, PRInt32 len) {
PRInt32 written;
- if (Write( m_writeOffset, pData, len, &written)) { m_writeOffset += written; return( true);}
- else return( false);
+ if (Write(m_writeOffset, pData, len, &written)) { m_writeOffset += written; return true;}
+ else return false;
}
- bool SpecialMemCpy( PRInt32 offset, const char *pData, PRInt32 len, PRInt32 *pWritten);
+ bool SpecialMemCpy(PRInt32 offset, const char *pData, PRInt32 len, PRInt32 *pWritten);
bool m_convertCRs;
char * m_pBuffer;
PRUint32 m_bytesInBuf; // used when reading into this buffer
PRInt32 m_size; // allocated size of buffer
PRInt32 m_growBy; // duh
PRUint32 m_writeOffset; // used when writing into and reading from the buffer
};
@@ -137,49 +142,49 @@ public:
class nsEudoraCompose {
public:
nsEudoraCompose();
~nsEudoraCompose();
nsresult SendTheMessage(nsIFile *pMailImportLocation, nsIFile **pMsg);
- void SetBody( const char *pBody, PRInt32 len, nsCString &bodyType) { m_pBody = pBody; m_bodyLen = len; m_bodyType = bodyType;}
- void SetHeaders( const char *pHeaders, PRInt32 len) { m_pHeaders = pHeaders; m_headerLen = len;}
- void SetAttachments( nsVoidArray *pAttachments) { m_pAttachments = pAttachments;}
- void SetDefaultDate( nsCString date) { m_defaultDate = date;}
+ void SetBody(const char *pBody, PRInt32 len, nsCString &bodyType) { m_pBody = pBody; m_bodyLen = len; m_bodyType = bodyType;}
+ void SetHeaders(const char *pHeaders, PRInt32 len) { m_pHeaders = pHeaders; m_headerLen = len;}
+ void SetAttachments(nsVoidArray *pAttachments) { m_pAttachments = pAttachments;}
+ void SetDefaultDate(nsCString date) { m_defaultDate = date;}
- nsresult CopyComposedMessage( nsCString& fromLine, nsIFile *pSrc, nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& copy);
+ nsresult CopyComposedMessage(nsCString& fromLine, nsIFile *pSrc, nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& copy);
- static nsresult FillMailBuffer( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
+ static nsresult FillMailBuffer(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
static nsresult CreateIdentity(void);
static void ReleaseIdentity(void);
private:
- nsresult CreateComponents( void);
+ nsresult CreateComponents(void);
- void GetNthHeader( const char *pData, PRInt32 dataLen, PRInt32 n, nsCString& header, nsCString& val, bool unwrap);
- void GetHeaderValue( const char *pData, PRInt32 dataLen, const char *pHeader, nsCString& val, bool unwrap = true);
- void GetHeaderValue( const char *pData, PRInt32 dataLen, const char *pHeader, nsString& val) {
+ void GetNthHeader(const char *pData, PRInt32 dataLen, PRInt32 n, nsCString& header, nsCString& val, bool unwrap);
+ void GetHeaderValue(const char *pData, PRInt32 dataLen, const char *pHeader, nsCString& val, bool unwrap = true);
+ void GetHeaderValue(const char *pData, PRInt32 dataLen, const char *pHeader, nsString& val) {
val.Truncate();
nsCString hVal;
- GetHeaderValue( pData, dataLen, pHeader, hVal, true);
- NS_CopyNativeToUnicode( hVal, val);
+ GetHeaderValue(pData, dataLen, pHeader, hVal, true);
+ NS_CopyNativeToUnicode(hVal, val);
}
- void ExtractCharset( nsString& str);
- void ExtractType( nsString& str);
+ void ExtractCharset(nsString& str);
+ void ExtractType(nsString& str);
nsresult GetLocalAttachments(nsIArray **aArray);
- nsresult ReadHeaders( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header);
- PRInt32 FindNextEndLine( SimpleBufferTonyRCopiedOnce& data);
- PRInt32 IsEndHeaders( SimpleBufferTonyRCopiedOnce& data);
- PRInt32 IsSpecialHeader( const char *pHeader);
- nsresult WriteHeaders( nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& newHeaders);
- bool IsReplaceHeader( const char *pHeader);
+ nsresult ReadHeaders(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header);
+ PRInt32 FindNextEndLine(SimpleBufferTonyRCopiedOnce& data);
+ PRInt32 IsEndHeaders(SimpleBufferTonyRCopiedOnce& data);
+ PRInt32 IsSpecialHeader(const char *pHeader);
+ nsresult WriteHeaders(nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& newHeaders);
+ bool IsReplaceHeader(const char *pHeader);
private:
static nsIMsgIdentity * s_pIdentity;
nsVoidArray * m_pAttachments;
nsIMsgSendListener * m_pListener;
nsIMsgCompFields * m_pMsgFields;
nsCOMPtr<nsIIOService> m_pIOService;
--- a/mailnews/import/eudora/src/nsEudoraEditor.cpp
+++ b/mailnews/import/eudora/src/nsEudoraEditor.cpp
@@ -73,17 +73,17 @@ static PRUint32 EudoraHashString(const c
ulSum -= kKRHashPrime;
if ((*pszStr) & nBit)
++ulSum;
if (ulSum>= kKRHashPrime)
ulSum -= kKRHashPrime;
}
}
- return (ulSum + 1);
+ return ulSum + 1;
}
nsEudoraEditor::nsEudoraEditor(const char * pBody, nsIFile * pMailImportLocation)
: m_body(pBody)
{
m_pMailImportLocation = pMailImportLocation;
}
@@ -100,17 +100,17 @@ nsresult nsEudoraEditor::GetEmbeddedObje
// Check to see if we were already called
if (m_EmbeddedObjectList != nsnull)
{
*aNodeList = m_EmbeddedObjectList;
return NS_OK;
}
// Create array in m_EmbeddedObjectList
- nsresult rv = NS_NewISupportsArray( getter_AddRefs(m_EmbeddedObjectList) );
+ nsresult rv = NS_NewISupportsArray(getter_AddRefs(m_EmbeddedObjectList));
NS_ENSURE_SUCCESS(rv, rv);
// Return m_EmbeddedObjectList in aNodeList and increment ref count - caller
// assumes that we incremented the ref count.
NS_IF_ADDREF(*aNodeList = m_EmbeddedObjectList);
// Create the embedded folder spec
nsCOMPtr<nsIFile> embeddedFolderSpec;
@@ -140,34 +140,36 @@ nsresult nsEudoraEditor::GetEmbeddedObje
// one that I know of, but then again I didn't realize that Eudora translators had
// ever translated "Attachment Converted" as suggested by other Eudora importing code.
for (PRInt32 i = 0; *sEudoraEmbeddedContentLines[i] != '\0'; i++)
{
// Search for "Embedded Content: " lines starting after last closing tag (if any)
PRInt32 startEmbeddedContentLine = startLastClosingTag;
PRInt32 lenEmbeddedContentTag = strlen(sEudoraEmbeddedContentLines[i]);
- while ( (startEmbeddedContentLine = m_body.Find(sEudoraEmbeddedContentLines[i], true, startEmbeddedContentLine+1)) != kNotFound )
+ while ((startEmbeddedContentLine = m_body.Find(sEudoraEmbeddedContentLines[i],
+ true,
+ startEmbeddedContentLine+1)) != kNotFound)
{
// Found this translation of "Embedded Content" - remember that so that we don't
// bother looking for any other translations.
foundEmbeddedContentLines = true;
// Extract the file name from the embedded content line
PRInt32 startFileName = startEmbeddedContentLine + lenEmbeddedContentTag;
PRInt32 endFileName = m_body.Find(":", false, startFileName);
// Create the file spec for the embedded image
embeddedFolderSpec->Clone(getter_AddRefs(embeddedImageSpec));
embeddedImageSpec->Append(Substring(m_body, startFileName, endFileName - startFileName));
// Verify that the embedded image spec exists and is a file
bool isFile = false;
bool exists = false;
- if ( NS_FAILED(embeddedImageSpec->Exists( &exists)) || NS_FAILED(embeddedImageSpec->IsFile(&isFile)) )
+ if (NS_FAILED(embeddedImageSpec->Exists(&exists)) || NS_FAILED(embeddedImageSpec->IsFile(&isFile)))
continue;
if (!exists || !isFile)
continue;
// Extract CID hash from the embedded content line
PRInt32 cidHashValue;
PRInt32 startCIDHash = m_body.Find(",", false, endFileName);
if (startCIDHash != kNotFound)
@@ -175,17 +177,17 @@ nsresult nsEudoraEditor::GetEmbeddedObje
startCIDHash++;
PRInt32 endCIDHash = m_body.Find(",", false, startCIDHash);
if (endCIDHash != kNotFound)
{
nsString cidHash;
cidHash.Assign(Substring(m_body, startCIDHash, endCIDHash - startCIDHash));
- if ( !cidHash.IsEmpty() )
+ if (!cidHash.IsEmpty())
{
// Convert CID hash string to numeric value
nsresult aErrorCode;
cidHashValue = cidHash.ToInteger(&aErrorCode, 16);
}
}
}
@@ -198,18 +200,17 @@ nsresult nsEudoraEditor::GetEmbeddedObje
nsString cid;
// We're going to remember the original cid in the image element,
// which the send code will retrieve as the kMozCIDAttrName property.
GetEmbeddedImageCID(cidHashValue, srcUrl, cid);
// Create the embedded image node
nsEudoraHTMLImageElement *image =
new nsEudoraHTMLImageElement(srcUrl, cid);
- nsCOMPtr<nsIDOMHTMLImageElement> imageNode;
- image->QueryInterface( NS_GET_IID(nsIDOMHTMLImageElement), getter_AddRefs(imageNode) );
+ nsCOMPtr<nsIDOMHTMLImageElement> imageNode(do_QueryInterface(image));
// Append the embedded image node to the list
(*aNodeList)->AppendElement(imageNode);
PRInt32 endEmbeddedContentLine = m_body.Find("\r\n", true, startEmbeddedContentLine+1);
if (endEmbeddedContentLine != kNotFound)
{
// We recognized the "Embedded Content" line correctly and found the associated image.
@@ -230,50 +231,50 @@ nsresult nsEudoraEditor::GetEmbeddedObje
}
bool nsEudoraEditor::GetEmbeddedImageCID(PRUint32 aCIDHash, const nsAString & aOldRef, nsString &aCID)
{
bool foundMatch = false;
PRInt32 startImageTag = 0;
PRInt32 closeImageTag = 0;
- while ( (startImageTag = m_body.Find("<img", true, closeImageTag)) != kNotFound )
+ while ((startImageTag = m_body.Find("<img", true, closeImageTag)) != kNotFound)
{
closeImageTag = m_body.Find(">", false, startImageTag);
// We should always find a close tag, bail if we don't
if (closeImageTag == kNotFound)
break;
// Find the source attribute and make sure it's for our image tag
PRInt32 startSrcValue = m_body.Find("src", true, startImageTag);
- if ( (startSrcValue == kNotFound) || (startSrcValue > closeImageTag) )
+ if ((startSrcValue == kNotFound) || (startSrcValue > closeImageTag))
continue;
// Move past the src
startSrcValue += 3;
// Move past any whitespace
- while ( isspace(m_body.CharAt(startSrcValue)) )
+ while (isspace(m_body.CharAt(startSrcValue)))
++startSrcValue;
// We should find an = now
if (m_body.CharAt(startSrcValue) != '=')
continue;
// Move past =
++startSrcValue;
// Move past any whitespace
- while ( isspace(m_body.CharAt(startSrcValue)) )
+ while (isspace(m_body.CharAt(startSrcValue)))
++startSrcValue;
// Get the quote char and verify that it's valid
char quoteChar = static_cast <char> (m_body.CharAt(startSrcValue));
- if ( (quoteChar != '"') && (quoteChar != '\'') )
+ if ((quoteChar != '"') && (quoteChar != '\''))
continue;
// Move past the quote
++startSrcValue;
PRInt32 endSrcValue = m_body.FindChar(quoteChar, startSrcValue);
PRInt32 srcLength = endSrcValue - startSrcValue;
@@ -284,17 +285,17 @@ bool nsEudoraEditor::GetEmbeddedImageCID
{
// Verify source value starts with "cid:"
if (!StringBeginsWith(aCID, NS_LITERAL_STRING("cid:"), nsCaseInsensitiveStringComparator()))
continue;
// Remove "cid:" from the start
aCID.Cut(0, 4);
- PRUint32 hashValue = EudoraHashString( NS_LossyConvertUTF16toASCII(aCID).get() );
+ PRUint32 hashValue = EudoraHashString(NS_LossyConvertUTF16toASCII(aCID).get());
foundMatch = (hashValue == aCIDHash);
}
else
{
foundMatch = aCID.Equals(aOldRef);
}
}
--- a/mailnews/import/eudora/src/nsEudoraFilters.cpp
+++ b/mailnews/import/eudora/src/nsEudoraFilters.cpp
@@ -98,34 +98,34 @@ NS_IMETHODIMP nsEudoraFilters::AutoLocat
*aDescription = nsnull;
*_retval = false;
nsresult rv;
m_pLocation = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- *aDescription = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME);
+ *aDescription = nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NAME);
#if defined(XP_WIN) || defined(XP_OS2)
- *_retval = nsEudoraWin32::FindFiltersFile( getter_AddRefs(m_pLocation) );
+ *_retval = nsEudoraWin32::FindFiltersFile(getter_AddRefs(m_pLocation));
#endif
#ifdef XP_MACOSX
- *_retval = nsEudoraMac::FindFiltersFile( getter_AddRefs(m_pLocation) );
+ *_retval = nsEudoraMac::FindFiltersFile(getter_AddRefs(m_pLocation));
#endif
NS_IF_ADDREF(*aLocation = m_pLocation);
return NS_OK;
}
NS_IMETHODIMP nsEudoraFilters::SetLocation(nsIFile *aLocation)
{
m_pLocation = aLocation;
- return( NS_OK);
+ return NS_OK;
}
NS_IMETHODIMP nsEudoraFilters::Import(PRUnichar **aError, bool *_retval)
{
NS_ENSURE_ARG_POINTER(aError);
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
@@ -144,56 +144,56 @@ NS_IMETHODIMP nsEudoraFilters::Import(PR
#ifdef XP_MACOSX
if (!nsEudoraMac::FindFiltersFile(getter_AddRefs(m_pLocation)))
m_pLocation = nsnull;
#endif
}
if (!m_pLocation)
{
- IMPORT_LOG0( "*** Error, unable to locate filters file for import.\n");
- return( NS_ERROR_FAILURE);
+ 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");
+ IMPORT_LOG0("Successful import of eudora filters\n");
else
- IMPORT_LOG0( "*** Error, Unsuccessful import of eudora filters\n");
+ IMPORT_LOG0("*** Error, Unsuccessful import of eudora filters\n");
- return( NS_OK);
+ return NS_OK;
}
bool nsEudoraFilters::RealImport()
{
nsresult rv;
rv = Init();
if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error initializing filter import process\n");
+ IMPORT_LOG0("*** Error initializing filter import process\n");
return false;
}
nsCOMPtr <nsIInputStream> inputStream;
rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), m_pLocation);
if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error opening filters file for reading\n");
+ IMPORT_LOG0("*** Error opening filters file for reading\n");
return false;
}
rv = LoadServers();
if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error loading servers with filters\n");
+ IMPORT_LOG0("*** Error loading servers with filters\n");
return false;
}
nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCString line;
bool more = true;
@@ -353,17 +353,17 @@ bool nsEudoraFilters::RealImport()
// Process the last filter
if (!more && NS_SUCCEEDED(rv))
rv = FinalizeFilter();
inputStream->Close();
if (more)
{
- IMPORT_LOG0( "*** Error reading the filters, didn't reach the end\n");
+ IMPORT_LOG0("*** Error reading the filters, didn't reach the end\n");
return false;
}
rv = SaveFilters();
return NS_SUCCEEDED(rv);
}
--- a/mailnews/import/eudora/src/nsEudoraImport.cpp
+++ b/mailnews/import/eudora/src/nsEudoraImport.cpp
@@ -117,23 +117,23 @@ public:
PRUnichar **pErrorLog, PRUnichar **pSuccessLog, bool *fatalError);
/* unsigned long GetImportProgress (); */
NS_IMETHOD GetImportProgress(PRUint32 *_retval);
NS_IMETHOD TranslateFolderName(const nsAString & aFolderName, nsAString & _retval);
public:
- static void AddLinebreak( nsString *pStream);
- static void SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess);
- static void ReportError( PRInt32 errorNum, nsString& name, nsString *pStream);
+ static void AddLinebreak(nsString *pStream);
+ static void SetLogs(nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess);
+ static void ReportError(PRInt32 errorNum, nsString& name, nsString *pStream);
private:
- static void ReportSuccess( nsString& name, PRInt32 count, nsString *pStream);
+ static void ReportSuccess(nsString& name, PRInt32 count, nsString *pStream);
private:
#if defined(XP_WIN) || defined(XP_OS2)
nsEudoraWin32 m_eudora;
#endif
#ifdef XP_MACOSX
nsEudoraMac m_eudora;
#endif
@@ -149,46 +149,46 @@ public:
static nsresult Create(nsIImportAddressBooks** aImport);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIImportAddressBooks interface
- NS_IMETHOD GetSupportsMultiple(bool *_retval) { *_retval = true; return( NS_OK);}
+ NS_IMETHOD GetSupportsMultiple(bool *_retval) { *_retval = true; return NS_OK;}
NS_IMETHOD GetAutoFind(PRUnichar **description, bool *_retval);
- NS_IMETHOD GetNeedsFieldMap(nsIFile *location, bool *_retval) { *_retval = false; return( NS_OK);}
+ NS_IMETHOD GetNeedsFieldMap(nsIFile *location, bool *_retval) { *_retval = false; return NS_OK;}
NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify);
NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval);
NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap)
- { return( NS_ERROR_FAILURE); }
+ { return NS_ERROR_FAILURE; }
NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
nsIAddrDatabase *destination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRUnichar **errorLog,
PRUnichar **successLog,
bool *fatalError);
NS_IMETHOD GetImportProgress(PRUint32 *_retval);
- NS_IMETHOD GetSampleData( PRInt32 index, bool *pFound, PRUnichar **pStr)
- { return( NS_ERROR_FAILURE);}
+ NS_IMETHOD GetSampleData(PRInt32 index, bool *pFound, PRUnichar **pStr)
+ { return NS_ERROR_FAILURE;}
- NS_IMETHOD SetSampleLocation( nsIFile *) { return( NS_OK); }
+ NS_IMETHOD SetSampleLocation(nsIFile *) { return NS_OK; }
private:
- static void ReportSuccess( nsString& name, nsString *pStream);
+ static void ReportSuccess(nsString& name, nsString *pStream);
private:
#if defined(XP_WIN) || defined(XP_OS2)
nsEudoraWin32 m_eudora;
#endif
#ifdef XP_MACOSX
nsEudoraMac m_eudora;
#endif
@@ -199,162 +199,162 @@ private:
////////////////////////////////////////////////////////////////////////
nsEudoraImport::nsEudoraImport()
{
// Init logging module.
if (!EUDORALOGMODULE)
EUDORALOGMODULE = PR_NewLogModule("IMPORT");
- IMPORT_LOG0( "nsEudoraImport Module Created\n");
+ IMPORT_LOG0("nsEudoraImport Module Created\n");
nsEudoraStringBundle::GetStringBundle();
}
nsEudoraImport::~nsEudoraImport()
{
- IMPORT_LOG0( "nsEudoraImport Module Deleted\n");
+ IMPORT_LOG0("nsEudoraImport Module Deleted\n");
}
NS_IMPL_ISUPPORTS1(nsEudoraImport, nsIImportModule)
-NS_IMETHODIMP nsEudoraImport::GetName( PRUnichar **name)
+NS_IMETHODIMP nsEudoraImport::GetName(PRUnichar **name)
{
NS_PRECONDITION(name != nsnull, "null ptr");
if (! name)
return NS_ERROR_NULL_POINTER;
- *name = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME);
+ *name = nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NAME);
return NS_OK;
}
-NS_IMETHODIMP nsEudoraImport::GetDescription( PRUnichar **name)
+NS_IMETHODIMP nsEudoraImport::GetDescription(PRUnichar **name)
{
NS_PRECONDITION(name != nsnull, "null ptr");
if (! name)
return NS_ERROR_NULL_POINTER;
- *name = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_DESCRIPTION);
+ *name = nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_DESCRIPTION);
return NS_OK;
}
-NS_IMETHODIMP nsEudoraImport::GetSupports( char **supports)
+NS_IMETHODIMP nsEudoraImport::GetSupports(char **supports)
{
NS_PRECONDITION(supports != nsnull, "null ptr");
if (! supports)
return NS_ERROR_NULL_POINTER;
- *supports = strdup( kEudoraSupportsString);
- return( NS_OK);
+ *supports = strdup(kEudoraSupportsString);
+ return NS_OK;
}
-NS_IMETHODIMP nsEudoraImport::GetSupportsUpgrade( bool *pUpgrade)
+NS_IMETHODIMP nsEudoraImport::GetSupportsUpgrade(bool *pUpgrade)
{
NS_PRECONDITION(pUpgrade != nsnull, "null ptr");
if (! pUpgrade)
return NS_ERROR_NULL_POINTER;
*pUpgrade = true;
- return( NS_OK);
+ return NS_OK;
}
-NS_IMETHODIMP nsEudoraImport::GetImportInterface( const char *pImportType, nsISupports **ppInterface)
+NS_IMETHODIMP nsEudoraImport::GetImportInterface(const char *pImportType, nsISupports **ppInterface)
{
NS_PRECONDITION(pImportType != nsnull, "null ptr");
if (! pImportType)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(ppInterface != nsnull, "null ptr");
if (! ppInterface)
return NS_ERROR_NULL_POINTER;
*ppInterface = nsnull;
nsresult rv;
- if (!strcmp( pImportType, "mail"))
+ if (!strcmp(pImportType, "mail"))
{
// create the nsIImportMail interface and return it!
nsIImportMail * pMail = nsnull;
nsIImportGeneric *pGeneric = nsnull;
- rv = ImportEudoraMailImpl::Create( &pMail);
- if (NS_SUCCEEDED( rv)) {
+ rv = ImportEudoraMailImpl::Create(&pMail);
+ if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
- rv = impSvc->CreateNewGenericMail( &pGeneric);
- if (NS_SUCCEEDED( rv))
+ rv = impSvc->CreateNewGenericMail(&pGeneric);
+ if (NS_SUCCEEDED(rv))
{
- pGeneric->SetData( "mailInterface", pMail);
+ pGeneric->SetData("mailInterface", pMail);
nsString name;
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME, name);
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NAME, name);
nsCOMPtr<nsISupportsString> nameString (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
nameString->SetData(name);
- pGeneric->SetData( "name", nameString);
- rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface);
+ pGeneric->SetData("name", nameString);
+ rv = pGeneric->QueryInterface(kISupportsIID, (void **)ppInterface);
}
}
}
}
- NS_IF_RELEASE( pMail);
- NS_IF_RELEASE( pGeneric);
- return( rv);
+ NS_IF_RELEASE(pMail);
+ NS_IF_RELEASE(pGeneric);
+ return rv;
}
- if (!strcmp( pImportType, "addressbook"))
+ if (!strcmp(pImportType, "addressbook"))
{
// create the nsIImportMail interface and return it!
nsIImportAddressBooks * pAddress = nsnull;
nsIImportGeneric * pGeneric = nsnull;
- rv = ImportEudoraAddressImpl::Create( &pAddress);
- if (NS_SUCCEEDED( rv))
+ rv = ImportEudoraAddressImpl::Create(&pAddress);
+ if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
- rv = impSvc->CreateNewGenericAddressBooks( &pGeneric);
- if (NS_SUCCEEDED( rv))
+ rv = impSvc->CreateNewGenericAddressBooks(&pGeneric);
+ if (NS_SUCCEEDED(rv))
{
- pGeneric->SetData( "addressInterface", pAddress);
- rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface);
+ pGeneric->SetData("addressInterface", pAddress);
+ rv = pGeneric->QueryInterface(kISupportsIID, (void **)ppInterface);
}
}
}
- NS_IF_RELEASE( pAddress);
- NS_IF_RELEASE( pGeneric);
- return( rv);
+ NS_IF_RELEASE(pAddress);
+ NS_IF_RELEASE(pGeneric);
+ return rv;
}
- if (!strcmp( pImportType, "settings"))
+ if (!strcmp(pImportType, "settings"))
{
nsIImportSettings *pSettings = nsnull;
- rv = nsEudoraSettings::Create( &pSettings);
- if (NS_SUCCEEDED( rv))
- pSettings->QueryInterface( kISupportsIID, (void **)ppInterface);
- NS_IF_RELEASE( pSettings);
- return( rv);
+ rv = nsEudoraSettings::Create(&pSettings);
+ if (NS_SUCCEEDED(rv))
+ pSettings->QueryInterface(kISupportsIID, (void **)ppInterface);
+ NS_IF_RELEASE(pSettings);
+ return rv;
}
- if (!strcmp( pImportType, "filters"))
+ if (!strcmp(pImportType, "filters"))
{
nsIImportFilters *pFilters = nsnull;
- rv = nsEudoraFilters::Create( &pFilters);
- if (NS_SUCCEEDED( rv))
- pFilters->QueryInterface( kISupportsIID, (void **)ppInterface);
- NS_IF_RELEASE( pFilters);
- return( rv);
+ rv = nsEudoraFilters::Create(&pFilters);
+ if (NS_SUCCEEDED(rv))
+ pFilters->QueryInterface(kISupportsIID, (void **)ppInterface);
+ NS_IF_RELEASE(pFilters);
+ return rv;
}
- return( NS_ERROR_NOT_AVAILABLE);
+ return NS_ERROR_NOT_AVAILABLE;
}
/////////////////////////////////////////////////////////////////////////////////
nsresult ImportEudoraMailImpl::Create(nsIImportMail** aImport)
{
NS_PRECONDITION(aImport != nsnull, "null ptr");
if (! aImport)
return NS_ERROR_NULL_POINTER;
@@ -374,17 +374,17 @@ ImportEudoraMailImpl::ImportEudoraMailIm
// Ideally importing the settings will have already created these,
// in which case we won't bother (we'll detect that each key already
// exists). But to be sure we need to create the keys here, at
// least until the infrastructure is improved in some fashion so
// that we can rely on settings *always* being imported before mail.
nsresult rv;
nsCOMPtr<nsIMsgTagService> pTagService = do_GetService(NS_MSGTAGSERVICE_CONTRACTID, &rv);
- if ( NS_SUCCEEDED(rv) )
+ if (NS_SUCCEEDED(rv))
{
struct EudoraDefaultLabels
{
char * key;
nsString tag;
char * color;
};
@@ -414,20 +414,20 @@ ImportEudoraMailImpl::ImportEudoraMailIm
nsCString eudoraKey;
nsString eudoraTag;
nsCString eudoraColor;
for (PRInt16 i = 0; i < kNumEudoraLabels; i++)
{
eudoraKey = defaultEudoraLabels[i].key;
rv = pTagService->GetTagForKey(eudoraKey, eudoraTag);
- if ( NS_FAILED(rv) || eudoraTag.IsEmpty() )
+ if (NS_FAILED(rv) || eudoraTag.IsEmpty())
{
eudoraColor = defaultEudoraLabels[i].color;
- rv = pTagService->AddTagForKey( eudoraKey, defaultEudoraLabels[i].tag, eudoraColor, EmptyCString() );
+ rv = pTagService->AddTagForKey(eudoraKey, defaultEudoraLabels[i].tag, eudoraColor, EmptyCString());
}
}
}
}
ImportEudoraMailImpl::~ImportEudoraMailImpl()
{
@@ -435,88 +435,85 @@ ImportEudoraMailImpl::~ImportEudoraMailI
// that it creates when we import any mail.
nsEudoraCompose::ReleaseIdentity();
}
NS_IMPL_THREADSAFE_ISUPPORTS1(ImportEudoraMailImpl, nsIImportMail)
-NS_IMETHODIMP ImportEudoraMailImpl::GetDefaultLocation( nsIFile **ppLoc, bool *found, bool *userVerify)
+NS_IMETHODIMP ImportEudoraMailImpl::GetDefaultLocation(nsIFile **ppLoc, bool *found, bool *userVerify)
{
NS_PRECONDITION(ppLoc != nsnull, "null ptr");
NS_PRECONDITION(found != nsnull, "null ptr");
NS_PRECONDITION(userVerify != nsnull, "null ptr");
if (!ppLoc || !found || !userVerify)
return NS_ERROR_NULL_POINTER;
*ppLoc = nsnull;
*found = m_eudora.FindMailFolder(ppLoc);
*userVerify = true;
- return( NS_OK);
+ return NS_OK;
}
-NS_IMETHODIMP ImportEudoraMailImpl::FindMailboxes( nsIFile *pLoc, nsISupportsArray **ppArray)
+NS_IMETHODIMP ImportEudoraMailImpl::FindMailboxes(nsIFile *pLoc, nsISupportsArray **ppArray)
{
NS_PRECONDITION(pLoc != nsnull, "null ptr");
NS_PRECONDITION(ppArray != nsnull, "null ptr");
if (!pLoc || !ppArray)
return NS_ERROR_NULL_POINTER;
bool exists = false;
- nsresult rv = pLoc->Exists( &exists);
- if (NS_FAILED( rv) || !exists)
- return( NS_ERROR_FAILURE);
+ nsresult rv = pLoc->Exists(&exists);
+ if (NS_FAILED(rv) || !exists)
+ return NS_ERROR_FAILURE;
- rv = m_eudora.FindMailboxes( pLoc, ppArray);
- if (NS_FAILED( rv) && *ppArray)
- {
- NS_RELEASE( *ppArray);
- *ppArray = nsnull;
- }
+ rv = m_eudora.FindMailboxes(pLoc, ppArray);
+ if (NS_FAILED(rv) && *ppArray)
+ NS_RELEASE(*ppArray);
- return( rv);
+ return rv;
}
-void ImportEudoraMailImpl::AddLinebreak( nsString *pStream)
+void ImportEudoraMailImpl::AddLinebreak(nsString *pStream)
{
if (pStream)
- pStream->Append( PRUnichar('\n'));
+ pStream->Append(PRUnichar('\n'));
}
-void ImportEudoraMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)
+void ImportEudoraMailImpl::ReportSuccess(nsString& name, PRInt32 count, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_SUCCESS);
- PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get(), count);
- pStream->Append( pText);
- nsTextFormatter::smprintf_free( pText);
- nsEudoraStringBundle::FreeString( pFmt);
- AddLinebreak( pStream);
+ PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_MAILBOX_SUCCESS);
+ PRUnichar *pText = nsTextFormatter::smprintf(pFmt, name.get(), count);
+ pStream->Append(pText);
+ nsTextFormatter::smprintf_free(pText);
+ nsEudoraStringBundle::FreeString(pFmt);
+ AddLinebreak(pStream);
}
-void ImportEudoraMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString *pStream)
+void ImportEudoraMailImpl::ReportError(PRInt32 errorNum, nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the error string
PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID(errorNum);
PRUnichar *pText = nsTextFormatter::smprintf(pFmt, name.get());
- pStream->Append( pText);
- nsTextFormatter::smprintf_free( pText);
- nsEudoraStringBundle::FreeString( pFmt);
- AddLinebreak( pStream);
+ pStream->Append(pText);
+ nsTextFormatter::smprintf_free(pText);
+ nsEudoraStringBundle::FreeString(pFmt);
+ AddLinebreak(pStream);
}
-void ImportEudoraMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
+void ImportEudoraMailImpl::SetLogs(nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess)
{
if (pError)
*pError = ToNewUnicode(error);
if (pSuccess)
*pSuccess = ToNewUnicode(success);
}
NS_IMETHODIMP ImportEudoraMailImpl::ImportMailbox(nsIImportMailboxDescriptor *pSource,
@@ -528,85 +525,85 @@ NS_IMETHODIMP ImportEudoraMailImpl::Impo
NS_PRECONDITION(pSource != nsnull, "null ptr");
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError)
{
- IMPORT_LOG0( "*** Bad param passed to eudora mailbox import\n");
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_BADPARAM, error);
+ IMPORT_LOG0("*** Bad param passed to eudora mailbox import\n");
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_MAILBOX_BADPARAM, error);
if (fatalError)
*fatalError = true;
- SetLogs( success, error, pErrorLog, pSuccessLog);
+ SetLogs(success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
bool abort = false;
nsString name;
PRUnichar * pName;
- if (NS_SUCCEEDED( pSource->GetDisplayName( &pName)))
+ if (NS_SUCCEEDED(pSource->GetDisplayName(&pName)))
{
name = pName;
- NS_Free( pName);
+ NS_Free(pName);
}
PRUint32 mailSize = 0;
- pSource->GetSize( &mailSize);
+ pSource->GetSize(&mailSize);
if (mailSize == 0)
{
- IMPORT_LOG0( "Mailbox size is 0, skipping mailbox.\n");
- ReportSuccess( name, 0, &success);
- SetLogs( success, error, pErrorLog, pSuccessLog);
- return( NS_OK);
+ IMPORT_LOG0("Mailbox size is 0, skipping mailbox.\n");
+ ReportSuccess(name, 0, &success);
+ SetLogs(success, error, pErrorLog, pSuccessLog);
+ return NS_OK;
}
nsCOMPtr <nsILocalFile> inFile;
- if (NS_FAILED(pSource->GetFile( getter_AddRefs(inFile))))
+ if (NS_FAILED(pSource->GetFile(getter_AddRefs(inFile))))
{
- ReportError( EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error);
- SetLogs( success, error, pErrorLog, pSuccessLog);
- return( NS_ERROR_FAILURE);
+ ReportError(EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error);
+ SetLogs(success, error, pErrorLog, pSuccessLog);
+ return NS_ERROR_FAILURE;
}
#ifdef IMPORT_DEBUG
nsCString pPath;
inFile->GetNativePath(pPath);
- IMPORT_LOG1( "Import mailbox: %s\n", pPath.get());
+ IMPORT_LOG1("Import mailbox: %s\n", pPath.get());
#endif
PRInt32 msgCount = 0;
nsresult rv = NS_OK;
m_bytes = 0;
- rv = m_eudora.ImportMailbox( &m_bytes, &abort, name.get(), inFile, pDestination, &msgCount);
- if (NS_SUCCEEDED( rv))
- ReportSuccess( name, msgCount, &success);
+ rv = m_eudora.ImportMailbox(&m_bytes, &abort, name.get(), inFile, pDestination, &msgCount);
+ if (NS_SUCCEEDED(rv))
+ ReportSuccess(name, msgCount, &success);
else
- ReportError( EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error);
+ ReportError(EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error);
- SetLogs( success, error, pErrorLog, pSuccessLog);
+ SetLogs(success, error, pErrorLog, pSuccessLog);
- IMPORT_LOG0( "*** Returning from eudora mailbox import\n");
+ IMPORT_LOG0("*** Returning from eudora mailbox import\n");
- return( rv);
+ return rv;
}
-NS_IMETHODIMP ImportEudoraMailImpl::GetImportProgress( PRUint32 *pDoneSoFar)
+NS_IMETHODIMP ImportEudoraMailImpl::GetImportProgress(PRUint32 *pDoneSoFar)
{
NS_PRECONDITION(pDoneSoFar != nsnull, "null ptr");
if (! pDoneSoFar)
return NS_ERROR_NULL_POINTER;
*pDoneSoFar = m_bytes;
- return( NS_OK);
+ return NS_OK;
}
NS_IMETHODIMP ImportEudoraMailImpl::TranslateFolderName(const nsAString & aFolderName, nsAString & _retval)
{
if (aFolderName.LowerCaseEqualsLiteral("out"))
_retval = NS_LITERAL_STRING(kDestSentFolderName);
else if (aFolderName.LowerCaseEqualsLiteral("in"))
@@ -648,155 +645,151 @@ NS_IMETHODIMP ImportEudoraAddressImpl::G
{
NS_PRECONDITION(description != nsnull, "null ptr");
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (! description || !_retval)
return NS_ERROR_NULL_POINTER;
nsString str;
*_retval = false;
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NICKNAMES_NAME, str);
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NICKNAMES_NAME, str);
*description = ToNewUnicode(str);
- return( NS_OK);
+ return NS_OK;
}
NS_IMETHODIMP ImportEudoraAddressImpl::GetDefaultLocation(nsIFile **ppLoc, bool *found, bool *userVerify)
{
NS_PRECONDITION(found != nsnull, "null ptr");
NS_PRECONDITION(ppLoc != nsnull, "null ptr");
NS_PRECONDITION(userVerify != nsnull, "null ptr");
if (! found || !userVerify || !ppLoc)
return NS_ERROR_NULL_POINTER;
*ppLoc = nsnull;
*found = m_eudora.FindAddressFolder(ppLoc);
*userVerify = true;
- return( NS_OK);
+ return NS_OK;
}
NS_IMETHODIMP ImportEudoraAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArray **ppArray)
{
NS_PRECONDITION(pLoc != nsnull, "null ptr");
NS_PRECONDITION(ppArray != nsnull, "null ptr");
if (!pLoc || !ppArray)
return NS_ERROR_NULL_POINTER;
bool exists = false;
- nsresult rv = pLoc->Exists( &exists);
- if (NS_FAILED( rv) || !exists)
- return( NS_ERROR_FAILURE);
+ nsresult rv = pLoc->Exists(&exists);
+ if (NS_FAILED(rv) || !exists)
+ return NS_ERROR_FAILURE;
- rv = m_eudora.FindAddressBooks( pLoc, ppArray);
- if (NS_FAILED( rv) && *ppArray) {
- NS_RELEASE( *ppArray);
- *ppArray = nsnull;
- }
+ rv = m_eudora.FindAddressBooks(pLoc, ppArray);
+ if (NS_FAILED(rv) && *ppArray)
+ NS_RELEASE(*ppArray);
- return( rv);
+ return rv;
}
-void ImportEudoraAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
+void ImportEudoraAddressImpl::ReportSuccess(nsString& name, nsString *pStream)
{
if (!pStream)
return;
// load the success string
- PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_ADDRESS_SUCCESS);
- PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
- pStream->Append( pText);
- nsTextFormatter::smprintf_free( pText);
- nsEudoraStringBundle::FreeString( pFmt);
- ImportEudoraMailImpl::AddLinebreak( pStream);
+ PRUnichar *pFmt = nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_ADDRESS_SUCCESS);
+ PRUnichar *pText = nsTextFormatter::smprintf(pFmt, name.get());
+ pStream->Append(pText);
+ nsTextFormatter::smprintf_free(pText);
+ nsEudoraStringBundle::FreeString(pFmt);
+ ImportEudoraMailImpl::AddLinebreak(pStream);
}
NS_IMETHODIMP
ImportEudoraAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
nsIAddrDatabase *pDestination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,
bool *fatalError)
{
- NS_PRECONDITION(pSource != nsnull, "null ptr");
- NS_PRECONDITION(pDestination != nsnull, "null ptr");
- NS_PRECONDITION(fatalError != nsnull, "null ptr");
+ NS_PRECONDITION(pSource != nsnull, "null ptr");
+ NS_PRECONDITION(pDestination != nsnull, "null ptr");
+ NS_PRECONDITION(fatalError != nsnull, "null ptr");
- nsString success;
- nsString error;
- if (!pSource || !pDestination || !fatalError) {
- IMPORT_LOG0( "*** Bad param passed to eudora address import\n");
+ nsString success;
+ nsString error;
+ if (!pSource || !pDestination || !fatalError) {
+ IMPORT_LOG0("*** Bad param passed to eudora address import\n");
nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_ADDRESS_BADPARAM, error);
if (fatalError)
*fatalError = true;
- ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
- return NS_ERROR_NULL_POINTER;
+ ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
+ return NS_ERROR_NULL_POINTER;
}
- bool abort = false;
- nsString name;
- pSource->GetPreferredName(name);
+ bool abort = false;
+ nsString name;
+ pSource->GetPreferredName(name);
PRUint32 addressSize = 0;
- pSource->GetSize( &addressSize);
+ pSource->GetSize(&addressSize);
if (addressSize == 0) {
- IMPORT_LOG0( "Address book size is 0, skipping mailbox.\n");
- ReportSuccess( name, &success);
- ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
- return( NS_OK);
+ IMPORT_LOG0("Address book size is 0, skipping mailbox.\n");
+ ReportSuccess(name, &success);
+ ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
+ return NS_OK;
}
- nsCOMPtr<nsIFile> inFile;
- if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) {
- ImportEudoraMailImpl::ReportError( EUDORAIMPORT_ADDRESS_BADSOURCEFILE, name, &error);
- ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
- return( NS_ERROR_FAILURE);
- }
+ nsCOMPtr<nsIFile> inFile;
+ if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) {
+ ImportEudoraMailImpl::ReportError(EUDORAIMPORT_ADDRESS_BADSOURCEFILE, name, &error);
+ ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
+ return NS_ERROR_FAILURE;
+ }
#ifdef IMPORT_DEBUG
nsCString path;
inFile->GetNativePath(path);
- IMPORT_LOG1( "Import address book: %s\n", path.get());
+ IMPORT_LOG1("Import address book: %s\n", path.get());
#endif
- nsresult rv = NS_OK;
+ nsresult rv = NS_OK;
m_bytes = 0;
- rv = m_eudora.ImportAddresses( &m_bytes, &abort, name.get(), inFile, pDestination, error);
+ rv = m_eudora.ImportAddresses(&m_bytes, &abort, name.get(), inFile, pDestination, error);
- if (NS_SUCCEEDED( rv) && error.IsEmpty()) {
- ReportSuccess( name, &success);
- }
- else {
- ImportEudoraMailImpl::ReportError( EUDORAIMPORT_ADDRESS_CONVERTERROR, name, &error);
- }
+ if (NS_SUCCEEDED(rv) && error.IsEmpty())
+ ReportSuccess(name, &success);
+ else
+ ImportEudoraMailImpl::ReportError(EUDORAIMPORT_ADDRESS_CONVERTERROR, name, &error);
- ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
+ ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
- IMPORT_LOG0( "*** Returning from eudora address import\n");
+ IMPORT_LOG0("*** Returning from eudora address import\n");
- return( rv);
+ return rv;
}
NS_IMETHODIMP ImportEudoraAddressImpl::GetImportProgress(PRUint32 *_retval)
{
- NS_PRECONDITION(_retval != nsnull, "null ptr");
+ NS_PRECONDITION(_retval != nsnull, "null ptr");
if (!_retval)
- return( NS_ERROR_NULL_POINTER);
+ return NS_ERROR_NULL_POINTER;
*_retval = m_bytes;
- return( NS_OK);
+ return NS_OK;
}
--- a/mailnews/import/eudora/src/nsEudoraMac.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMac.cpp
@@ -70,101 +70,101 @@ static const char * kWhitespace = "\b\t
nsEudoraMac::nsEudoraMac()
{
}
nsEudoraMac::~nsEudoraMac()
{
}
-bool nsEudoraMac::FindMailFolder( nsIFile **pFolder)
+bool nsEudoraMac::FindMailFolder(nsIFile **pFolder)
{
- return( FindEudoraLocation( pFolder));
+ return FindEudoraLocation(pFolder);
}
-bool nsEudoraMac::FindEudoraLocation( nsIFile **pFolder, bool findIni, nsIFile *pLookIn)
+bool nsEudoraMac::FindEudoraLocation(nsIFile **pFolder, bool findIni, nsIFile *pLookIn)
{
bool result = false;
// Modern versions of Eudora make the Eudora Folder in ~/Documents
// The last versions that ran MacOS Classic made the Eudora folder in the user's documents folder
// Early versions made the Eudora Folder in the System Folder
// Eudora searches those three locations, earliest first (System Folder:Eudora Folder), and uses the first Eudora Folder
// it finds. However, it's not clear that any version of OSX can actually *find* the Classic "Documents" folder,
// even if there was one before the machine was updated to OSX.
// The name "Eudora Folder" should not be localized. Early localized versions of Eudora did localize the name; later
// localized versions looked for the localized name and changed it back. We will therefore not
// worry about the folder name being localized. Japan may be an issue, though.
// SD 11/2006
if (!pLookIn)
{
- result = FindEudoraLocation( pFolder, findIni, NS_OS_SYSTEM_DIR );
- if ( !result )
+ result = FindEudoraLocation(pFolder, findIni, NS_OS_SYSTEM_DIR);
+ if (!result)
{
- result = FindEudoraLocation( pFolder, findIni, NS_MAC_DOCUMENTS_DIR );
- if ( !result )
- result = FindEudoraLocation( pFolder, findIni, NS_OSX_USER_DOCUMENTS_DIR );
+ result = FindEudoraLocation(pFolder, findIni, NS_MAC_DOCUMENTS_DIR);
+ if (!result)
+ result = FindEudoraLocation(pFolder, findIni, NS_OSX_USER_DOCUMENTS_DIR);
}
}
else
{
*pFolder = pLookIn;
- result = VerifyEudoraLocation( pFolder, findIni );
+ result = VerifyEudoraLocation(pFolder, findIni);
}
return result;
}
-bool nsEudoraMac::FindEudoraLocation( nsIFile **pFolder, bool findIni, const char *specialDirName )
+bool nsEudoraMac::FindEudoraLocation(nsIFile **pFolder, bool findIni, const char *specialDirName)
{
nsCOMPtr <nsIFile> searchDir;
- nsresult rv = NS_GetSpecialDirectory( specialDirName, getter_AddRefs(searchDir) );
+ nsresult rv = NS_GetSpecialDirectory(specialDirName, getter_AddRefs(searchDir));
if (NS_FAILED(rv))
- return (false);
+ return false;
// Turn it into a mac file, so we can resolve aliases
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(searchDir);
if (!macFile)
- return (false);
+ return false;
macFile->SetFollowLinks(true);
// It's always called "Eudora Folder", so add that to the path
- macFile->AppendNative( NS_LITERAL_CSTRING( "Eudora Folder" ) );
+ macFile->AppendNative(NS_LITERAL_CSTRING("Eudora Folder" ));
// If it's an alias, the "target" will be the real file. Fetch this as a string
// and set is back as the file
nsCString path;
macFile->GetNativeTarget(path);
macFile->InitWithNativePath(path);
// Resolve any unix-style symlinks (this won't do MacOS aliases, hence the machinations above)
bool link = false;
- rv = searchDir->IsSymlink( &link);
- if (NS_SUCCEEDED( rv) && link)
+ rv = searchDir->IsSymlink(&link);
+ if (NS_SUCCEEDED(rv) && link)
{
rv = macFile->SetFollowLinks(true);
- if (NS_FAILED( rv))
- return( false);
+ if (NS_FAILED(rv))
+ return false;
}
// Check for existence and directoriness
bool exists = false;
- rv = searchDir->Exists( &exists);
+ rv = searchDir->Exists(&exists);
bool isFolder = false;
- if (NS_SUCCEEDED( rv) && exists)
- rv = searchDir->IsDirectory( &isFolder);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = searchDir->IsDirectory(&isFolder);
if (!exists || !isFolder)
- return( false);
+ return false;
NS_IF_ADDREF(*pFolder = searchDir);
return true;
}
-bool nsEudoraMac::VerifyEudoraLocation( nsIFile **pFolder, bool findIni )
+bool nsEudoraMac::VerifyEudoraLocation(nsIFile **pFolder, bool findIni)
{
bool result = false;
bool foundPref = false;
bool hasMore;
nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
nsresult rv = (*pFolder)->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
@@ -188,17 +188,17 @@ bool nsEudoraMac::VerifyEudoraLocation(
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(entry, &rv);
if (NS_SUCCEEDED(rv))
{
macFile->GetFileCreator(&creator);
macFile->GetFileType(&type);
}
}
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
if ((type == 'TEXT') && (creator == 'CSOm'))
count++;
else if ((type == 'PREF') && (creator == 'CSOm'))
{
if (!foundPref)
{
prefFile = entry;
@@ -232,63 +232,63 @@ bool nsEudoraMac::VerifyEudoraLocation(
}
}
}
}
if (count >= 2)
result = true;
if (!findIni)
- return( result);
+ return result;
if (!foundPref)
- return( false);
+ return false;
NS_IF_ADDREF(*pFolder = prefFile);
- return( true);
+ return true;
}
-nsresult nsEudoraMac::FindMailboxes( nsIFile *pRoot, nsISupportsArray **ppArray)
+nsresult nsEudoraMac::FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray)
{
- nsresult rv = NS_NewISupportsArray( ppArray);
- if (NS_FAILED( rv))
+ nsresult rv = NS_NewISupportsArray(ppArray);
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
- return( 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);
+ if (NS_FAILED(rv))
+ return rv;
m_depth = 0;
m_mailImportLocation = do_QueryInterface(pRoot);
- return( ScanMailDir( pRoot, *ppArray, impSvc));
+ return ScanMailDir(pRoot, *ppArray, impSvc);
}
-nsresult nsEudoraMac::ScanMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraMac::ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
{
// On Windows, we look for a descmap file but on Mac we just iterate
// the directory
m_depth++;
- nsresult rv = IterateMailDir( pFolder, pArray, pImport);
+ nsresult rv = IterateMailDir(pFolder, pArray, pImport);
m_depth--;
- return( rv);
+ return rv;
}
-nsresult nsEudoraMac::IterateMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraMac::IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
{
bool hasMore;
nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
nsresult rv = pFolder->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
NS_ENSURE_SUCCESS(rv, rv);
directoryEnumerator->HasMoreElements(&hasMore);
@@ -304,241 +304,241 @@ nsresult nsEudoraMac::IterateMailDir( ns
nsCString fName;
nsCString ext;
nsCString name;
OSType type;
OSType creator;
isFolder = false;
isFile = false;
- rv = entry->IsDirectory( &isFolder);
- rv = entry->IsFile( &isFile);
+ rv = entry->IsDirectory(&isFolder);
+ rv = entry->IsFile(&isFile);
rv = entry->GetNativeLeafName(fName);
- if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
+ if (NS_SUCCEEDED(rv) && !fName.IsEmpty())
{
if (isFolder)
{
- if (IsValidMailFolderName( fName))
+ if (IsValidMailFolderName(fName))
{
- rv = FoundMailFolder( entry, fName.get(), pArray, pImport);
- if (NS_SUCCEEDED( rv))
+ rv = FoundMailFolder(entry, fName.get(), pArray, pImport);
+ if (NS_SUCCEEDED(rv))
{
- rv = ScanMailDir( entry, pArray, pImport);
- if (NS_FAILED( rv))
- IMPORT_LOG0( "*** Error scanning mail directory\n");
+ rv = ScanMailDir(entry, pArray, pImport);
+ if (NS_FAILED(rv))
+ IMPORT_LOG0("*** Error scanning mail directory\n");
}
}
}
else if (isFile)
{
type = 0;
creator = 0;
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(entry, &rv);
if (NS_SUCCEEDED(rv))
{
macFile->GetFileCreator(&creator);
macFile->GetFileType(&type);
}
}
- if ((type == 'TEXT') && IsValidMailboxName( fName) && IsValidMailboxFile( entry))
- rv = FoundMailbox( entry, fName.get(), pArray, pImport);
+ if ((type == 'TEXT') && IsValidMailboxName(fName) && IsValidMailboxFile(entry))
+ rv = FoundMailbox(entry, fName.get(), pArray, pImport);
}
}
}
- return( rv);
+ return rv;
}
-nsresult nsEudoraMac::FoundMailbox( nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraMac::FoundMailbox(nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
{
nsAutoString displayName;
nsCOMPtr<nsIImportMailboxDescriptor> desc;
nsISupports * pInterface;
NS_CopyNativeToUnicode(nsDependentCString(pName), displayName);
#ifdef IMPORT_DEBUG
nsCString path;
mailFile->GetNativePath(path);
if (!path.IsEmpty())
- IMPORT_LOG2( "Found eudora mailbox, %s: %s\n", path.get(), pName);
+ IMPORT_LOG2("Found eudora mailbox, %s: %s\n", path.get(), pName);
else
- IMPORT_LOG1( "Found eudora mailbox, %s\n", pName);
- IMPORT_LOG1( "\tm_depth = %d\n", (int)m_depth);
+ IMPORT_LOG1("Found eudora mailbox, %s\n", pName);
+ IMPORT_LOG1("\tm_depth = %d\n", (int)m_depth);
#endif
- nsresult rv = pImport->CreateNewMailboxDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ nsresult rv = pImport->CreateNewMailboxDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
PRInt64 sz = 0;
- mailFile->GetFileSize( &sz);
- desc->SetDisplayName( displayName.get());
- desc->SetDepth( m_depth);
+ mailFile->GetFileSize(&sz);
+ desc->SetDisplayName(displayName.get());
+ desc->SetDepth(m_depth);
nsCOMPtr <nsILocalFile> pLocalFile;
desc->GetFile(getter_AddRefs(pLocalFile));
if (pLocalFile)
{
nsCOMPtr <nsILocalFile> localMailFile = do_QueryInterface(mailFile);
pLocalFile->InitWithFile(localMailFile);
}
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- pArray->AppendElement( pInterface);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ pArray->AppendElement(pInterface);
pInterface->Release();
}
- return( NS_OK);
+ return NS_OK;
}
-nsresult nsEudoraMac::FoundMailFolder( nsILocalFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraMac::FoundMailFolder(nsILocalFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
{
nsAutoString displayName;
nsCOMPtr<nsIImportMailboxDescriptor> desc;
nsISupports * pInterface;
NS_CopyNativeToUnicode(nsDependentCString(pName), displayName);
#ifdef IMPORT_DEBUG
nsCString path;
mailFolder->GetNativePath(path);
if (!path.IsEmpty())
- IMPORT_LOG2( "Found eudora folder, %s: %s\n",path.get(), pName);
+ IMPORT_LOG2("Found eudora folder, %s: %s\n",path.get(), pName);
else
- IMPORT_LOG1( "Found eudora folder, %s\n", pName);
- IMPORT_LOG1( "\tm_depth = %d\n", (int)m_depth);
+ IMPORT_LOG1("Found eudora folder, %s\n", pName);
+ IMPORT_LOG1("\tm_depth = %d\n", (int)m_depth);
#endif
- nsresult rv = pImport->CreateNewMailboxDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ nsresult rv = pImport->CreateNewMailboxDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
PRInt64 sz = 0;
- desc->SetDisplayName( displayName.get());
- desc->SetDepth( m_depth);
- desc->SetSize( sz);
+ desc->SetDisplayName(displayName.get());
+ desc->SetDepth(m_depth);
+ desc->SetSize(sz);
nsCOMPtr <nsILocalFile> pFile;
desc->GetFile(getter_AddRefs(pFile));
if (pFile)
- pFile->InitWithFile( mailFolder);
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- pArray->AppendElement( pInterface);
+ pFile->InitWithFile(mailFolder);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ pArray->AppendElement(pInterface);
pInterface->Release();
}
- return( NS_OK);
+ return NS_OK;
}
-bool nsEudoraMac::CreateTocFromResource( nsIFile *pMail, nsIFile **pToc)
+bool nsEudoraMac::CreateTocFromResource(nsIFile *pMail, nsIFile **pToc)
{
ResFileRefNum resFile = -1;
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(pMail);
FSRef fsRef;
nsresult rv = macFile->GetFSRef(&fsRef);
if (NS_FAILED(rv))
return false;
- resFile = FSOpenResFile( &fsRef, fsRdPerm);
+ resFile = FSOpenResFile(&fsRef, fsRdPerm);
}
if (resFile == -1)
- return( false);
+ return false;
Handle resH = nil;
- short max = Count1Resources( 'TOCF');
+ short max = Count1Resources('TOCF');
if (max)
- resH = Get1IndResource( 'TOCF', 1);
+ resH = Get1IndResource('TOCF', 1);
bool result = false;
if (resH)
{
- PRInt32 sz = (PRInt32) GetHandleSize( resH);
+ PRInt32 sz = (PRInt32) GetHandleSize(resH);
if (sz)
{
// Create the new TOC file
nsCOMPtr<nsIFile> tempDir;
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir));
if (NS_FAILED(rv))
- return (false);
+ return false;
nsCOMPtr <nsIOutputStream> outputStream;
rv = tempDir->Clone(pToc);
- if (NS_SUCCEEDED( rv))
- rv = (*pToc)->AppendNative( NS_LITERAL_CSTRING("temp.toc"));
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
+ rv = (*pToc)->AppendNative(NS_LITERAL_CSTRING("temp.toc"));
+ if (NS_SUCCEEDED(rv))
rv = (*pToc)->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), (*pToc));
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
- HLock( resH);
+ HLock(resH);
PRUint32 written = 0;
- rv = outputStream->Write( *resH, sz, &written);
- HUnlock( resH);
+ rv = outputStream->Write(*resH, sz, &written);
+ HUnlock(resH);
outputStream->Close();
- if (NS_FAILED( rv) || (written != sz))
- (*pToc)->Remove( false);
+ if (NS_FAILED(rv) || (written != sz))
+ (*pToc)->Remove(false);
else
result = true;
}
}
- ReleaseResource( resH);
+ ReleaseResource(resH);
}
- CloseResFile( resFile);
+ CloseResFile(resFile);
- return( result);
+ return result;
}
-nsresult nsEudoraMac::FindTOCFile( nsIFile *pMailFile, nsIFile **ppTOCFile, bool *pDeleteToc)
+nsresult nsEudoraMac::FindTOCFile(nsIFile *pMailFile, nsIFile **ppTOCFile, bool *pDeleteToc)
{
nsresult rv;
*pDeleteToc = false;
*ppTOCFile = nsnull;
nsCString leaf;
rv = pMailFile->GetNativeLeafName(leaf);
- if (NS_FAILED( rv))
- return( rv);
- rv = pMailFile->GetParent( ppTOCFile);
- if (NS_FAILED( rv))
- return( rv);
+ if (NS_FAILED(rv))
+ return rv;
+ rv = pMailFile->GetParent(ppTOCFile);
+ if (NS_FAILED(rv))
+ return rv;
- leaf.Append( ".toc");
+ leaf.Append(".toc");
OSType type = 0;
OSType creator = 0;
bool exists = false;
bool isFile = false;
rv = (*ppTOCFile)->AppendNative(leaf);
- if (NS_SUCCEEDED( rv))
- rv = (*ppTOCFile)->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = (*ppTOCFile)->IsFile( &isFile);
+ if (NS_SUCCEEDED(rv))
+ rv = (*ppTOCFile)->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = (*ppTOCFile)->IsFile(&isFile);
if (isFile)
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(*ppTOCFile);
if (macFile)
{
macFile->GetFileCreator(&creator);
macFile->GetFileType(&type);
}
}
if (exists && isFile && (type == 'TOCF') && (creator == 'CSOm'))
- return( NS_OK);
+ return NS_OK;
// try and create the file from a resource.
- if (CreateTocFromResource( pMailFile, ppTOCFile))
+ if (CreateTocFromResource(pMailFile, ppTOCFile))
{
*pDeleteToc = true;
- return( NS_OK);
+ return NS_OK;
}
- return( NS_ERROR_FAILURE);
+ return NS_ERROR_FAILURE;
}
// GetIndString isn't supported on 64-bit Mac OS X
// This code is emulation for GetIndString.
static StringPtr GetStringFromHandle(Handle aResource,
ResourceIndex aId)
{
if (!aResource)
@@ -582,181 +582,175 @@ static StringPtr GetStringFromHandle(Han
// resource IDs
#define kSmtpServerID 4
#define kEmailAddressID 3
#define kReturnAddressID 5
#define kFullNameID 77
#define kLeaveMailOnServerID 18
-bool nsEudoraMac::GetSettingsFromResource( nsIFile *pSettings, short resId, nsCString **pStrs, bool *pIMAP)
+bool nsEudoraMac::GetSettingsFromResource(nsIFile *pSettings, short resId, nsCString **pStrs, bool *pIMAP)
{
nsresult rv;
*pIMAP = false;
// Get settings from the resources...
ResFileRefNum resFile = -1;
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(pSettings, &rv);
if (NS_FAILED(rv))
return false;
FSRef fsRef;
rv = macFile->GetFSRef(&fsRef);
if (NS_FAILED(rv))
return false;
- resFile = FSOpenResFile( &fsRef, fsRdPerm);
+ resFile = FSOpenResFile(&fsRef, fsRdPerm);
}
if (resFile == -1)
- return( false);
+ return false;
UseResFile(resFile);
// smtp server, STR# 1000, 4
- Handle resH = Get1Resource( 'STR#', resId /* 1000 */);
+ Handle resH = Get1Resource('STR#', resId /* 1000 */);
int idx;
if (resH)
{
StringPtr pStr[5];
StringPtr theStr;
// Cannot use GetIndString due to 64-bit support
pStr[0] = GetStringFromHandle(resH, kSmtpServerID);
pStr[1] = GetStringFromHandle(resH, kEmailAddressID);
pStr[2] = GetStringFromHandle(resH, kReturnAddressID);
pStr[3] = GetStringFromHandle(resH, kFullNameID);
pStr[4] = GetStringFromHandle(resH, kLeaveMailOnServerID);
theStr = pStr[0];
if (theStr && *theStr)
- pStrs[0]->Append( (const char *) (theStr + 1), *theStr);
+ pStrs[0]->Append((const char *) (theStr + 1), *theStr);
theStr = pStr[1];
if (theStr && *theStr)
{
idx = 1;
while (idx <= *theStr)
{
if (theStr[idx] == '@')
break;
else
idx++;
}
if (idx <= *theStr)
{
PRUint8 save = *theStr;
*theStr = idx - 1;
if (*theStr)
- pStrs[1]->Append( (const char *) (theStr + 1), *theStr);
+ pStrs[1]->Append((const char *) (theStr + 1), *theStr);
*theStr = save;
}
else
idx = 0;
theStr[idx] = theStr[0] - idx;
if (theStr[idx])
- pStrs[2]->Append( (const char *) (theStr + idx + 1), *(theStr + idx));
+ pStrs[2]->Append((const char *) (theStr + idx + 1), *(theStr + idx));
}
theStr = pStr[2];
if (theStr && *theStr)
- pStrs[3]->Append( (const char *) (theStr + 1), *theStr);
+ pStrs[3]->Append((const char *) (theStr + 1), *theStr);
theStr = pStr[3];
if (theStr && *theStr)
- pStrs[4]->Append( (const char *) (theStr + 1), *theStr);
+ pStrs[4]->Append((const char *) (theStr + 1), *theStr);
theStr = pStr[4];
if (theStr && *theStr)
{
if (theStr[1] == 'y')
*(pStrs[5]) = "Y";
else
*(pStrs[5]) = "N";
}
ReleaseResource(resH);
- CloseResFile( resFile);
+ CloseResFile(resFile);
- return( true);
+ return true;
}
else
{
- CloseResFile( resFile);
- return( false);
+ CloseResFile(resFile);
+ return false;
}
}
-bool nsEudoraMac::ImportSettings( nsIFile *pIniFile, nsIMsgAccount **localMailAccount)
+bool nsEudoraMac::ImportSettings(nsIFile *pIniFile, nsIMsgAccount **localMailAccount)
{
nsresult rv;
nsCOMPtr<nsIMsgAccountManager> accMgr =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Failed to create a account manager!\n");
- return( false);
+ IMPORT_LOG0("*** Failed to create a account manager!\n");
+ return false;
}
short baseResId = 1000;
nsCString **pStrs = new nsCString *[kNumSettingStrs];
int i;
for (i = 0; i < kNumSettingStrs; i++)
pStrs[i] = new nsCString;
nsString accName(NS_LITERAL_STRING("Eudora Settings"));
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_ACCOUNTNAME, accName);
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_ACCOUNTNAME, accName);
// This is a little overkill but we're not sure yet how multiple accounts
// are stored in the Mac preferences, hopefully similar to existing prefs
// which means the following is a good start!
bool isIMAP = false;
int popCount = 0;
int accounts = 0;
nsIMsgAccount * pAccount;
while (baseResId)
{
isIMAP = false;
- if (GetSettingsFromResource( pIniFile, baseResId, pStrs, &isIMAP))
+ if (GetSettingsFromResource(pIniFile, baseResId, pStrs, &isIMAP))
{
pAccount = nsnull;
if (!isIMAP)
{
// This is a POP account
- if (BuildPOPAccount( accMgr, pStrs, &pAccount, accName))
+ if (BuildPOPAccount(accMgr, pStrs, &pAccount, accName))
{
accounts++;
popCount++;
if (popCount > 1)
{
if (localMailAccount && *localMailAccount)
- {
- NS_RELEASE( *localMailAccount);
- *localMailAccount = nsnull;
- }
+ NS_RELEASE(*localMailAccount);
}
- else
+ else if (localMailAccount)
{
- if (localMailAccount)
- {
- *localMailAccount = pAccount;
- NS_IF_ADDREF( pAccount);
- }
+ *localMailAccount = pAccount;
+ NS_IF_ADDREF(pAccount);
}
}
}
else
{
// This is an IMAP account
- if (BuildIMAPAccount( accMgr, pStrs, &pAccount, accName))
+ if (BuildIMAPAccount(accMgr, pStrs, &pAccount, accName))
accounts++;
}
if (pAccount && (baseResId == 1000))
- accMgr->SetDefaultAccount( pAccount);
+ accMgr->SetDefaultAccount(pAccount);
- NS_IF_RELEASE( pAccount);
+ NS_IF_RELEASE(pAccount);
}
baseResId = 0;
// Set the next account name???
if (baseResId)
{
for (i = 0; i < kNumSettingStrs; i++)
@@ -767,143 +761,143 @@ bool nsEudoraMac::ImportSettings( nsIFil
// Now save the new acct info to pref file.
rv = accMgr->SaveAccountInfo();
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't save account info to pref file");
for (i = 0; i < kNumSettingStrs; i++)
delete pStrs[i];
delete pStrs;
- return( accounts != 0);
+ return accounts != 0;
}
-bool nsEudoraMac::FindFiltersFile( nsIFile **pFiltersFile)
+bool nsEudoraMac::FindFiltersFile(nsIFile **pFiltersFile)
{
- bool result = FindEudoraLocation( pFiltersFile, false);
+ bool result = FindEudoraLocation(pFiltersFile, false);
if (result)
{
- (*pFiltersFile)->AppendNative( NS_LITERAL_CSTRING("Eudora Filters") );
+ (*pFiltersFile)->AppendNative(NS_LITERAL_CSTRING("Eudora Filters"));
(*pFiltersFile)->IsFile(&result);
}
return result;
}
-bool nsEudoraMac::BuildPOPAccount( nsIMsgAccountManager *accMgr, nsCString **pStrs, nsIMsgAccount **ppAccount, nsString& accName)
+bool nsEudoraMac::BuildPOPAccount(nsIMsgAccountManager *accMgr, nsCString **pStrs, nsIMsgAccount **ppAccount, nsString& accName)
{
if (ppAccount)
*ppAccount = nsnull;
if (!pStrs[kPopServerStr]->Length() || !pStrs[kPopAccountNameStr]->Length())
- return( false);
+ 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 = accMgr->FindServer( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("pop3"), getter_AddRefs( in));
- if (NS_FAILED( rv) || (in == nsnull))
+ nsresult rv = accMgr->FindServer(*(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("pop3"), getter_AddRefs(in));
+ if (NS_FAILED(rv) || (in == nsnull))
{
// Create the incoming server and an account for it?
- rv = accMgr->CreateIncomingServer( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("pop3"), getter_AddRefs( in));
- if (NS_SUCCEEDED( rv) && in)
+ rv = accMgr->CreateIncomingServer(*(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("pop3"), getter_AddRefs(in));
+ if (NS_SUCCEEDED(rv) && in)
{
rv = in->SetType(NS_LITERAL_CSTRING("pop3"));
- // rv = in->SetHostName( pStrs[kPopServerStr]->get());
- // rv = in->SetUsername( pStrs[kPopAccountNameStr]->get());
+ // rv = in->SetHostName(pStrs[kPopServerStr]->get());
+ // rv = in->SetUsername(pStrs[kPopAccountNameStr]->get());
- IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", pStrs[kPopServerStr]->get(), pStrs[kPopAccountNameStr]->get());
- IMPORT_LOG1( "\tSet pretty name to: %S\n", accName.get());
- rv = in->SetPrettyName( accName);
+ IMPORT_LOG2("Created POP3 server named: %s, userName: %s\n", pStrs[kPopServerStr]->get(), pStrs[kPopAccountNameStr]->get());
+ IMPORT_LOG1("\tSet pretty name to: %S\n", accName.get());
+ rv = in->SetPrettyName(accName);
// We have a server, create an account.
nsCOMPtr<nsIMsgAccount> account;
- rv = accMgr->CreateAccount( getter_AddRefs( account));
- if (NS_SUCCEEDED( rv) && account)
+ rv = accMgr->CreateAccount(getter_AddRefs(account));
+ if (NS_SUCCEEDED(rv) && account)
{
- rv = account->SetIncomingServer( in);
+ rv = account->SetIncomingServer(in);
- IMPORT_LOG0( "Created a new account and set the incoming server to the POP3 server.\n");
+ IMPORT_LOG0("Created a new account and set the incoming server to the POP3 server.\n");
nsCOMPtr<nsIPop3IncomingServer> pop3Server = do_QueryInterface(in, &rv);
NS_ENSURE_SUCCESS(rv,rv);
pop3Server->SetLeaveMessagesOnServer(pStrs[kLeaveOnServerStr]->First() == 'Y' ? true : false);
// Fiddle with the identities
SetIdentities(accMgr, account, pStrs[kPopAccountNameStr]->get(), pStrs[kPopServerStr]->get(), pStrs);
result = true;
if (ppAccount)
- account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
+ account->QueryInterface(NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
}
}
}
else
result = true;
- return( result);
+ return result;
}
-bool nsEudoraMac::BuildIMAPAccount( nsIMsgAccountManager *accMgr, nsCString **pStrs, nsIMsgAccount **ppAccount, nsString& accName)
+bool nsEudoraMac::BuildIMAPAccount(nsIMsgAccountManager *accMgr, nsCString **pStrs, nsIMsgAccount **ppAccount, nsString& accName)
{
if (!pStrs[kPopServerStr]->Length() || !pStrs[kPopAccountNameStr]->Length())
- return( false);
+ return false;
bool result = false;
nsCOMPtr<nsIMsgIncomingServer> in;
- nsresult rv = accMgr->FindServer(*(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("imap"), getter_AddRefs( in));
- if (NS_FAILED( rv) || (in == nsnull))
+ nsresult rv = accMgr->FindServer(*(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), 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( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("imap"), getter_AddRefs( in));
- if (NS_SUCCEEDED( rv) && in)
+ rv = accMgr->CreateIncomingServer(*(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), NS_LITERAL_CSTRING("imap"), getter_AddRefs(in));
+ if (NS_SUCCEEDED(rv) && in)
{
rv = in->SetType(NS_LITERAL_CSTRING("imap"));
- // rv = in->SetHostName( pStrs[kPopServerStr]->get());
- // rv = in->SetUsername( pStrs[kPopAccountNameStr]->get());
+ // rv = in->SetHostName(pStrs[kPopServerStr]->get());
+ // rv = in->SetUsername(pStrs[kPopAccountNameStr]->get());
- IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", pStrs[kPopServerStr]->get(), pStrs[kPopAccountNameStr]->get());
- IMPORT_LOG1( "\tSet pretty name to: %S\n", accName.get());
- rv = in->SetPrettyName( accName);
+ IMPORT_LOG2("Created IMAP server named: %s, userName: %s\n", pStrs[kPopServerStr]->get(), pStrs[kPopAccountNameStr]->get());
+ IMPORT_LOG1("\tSet pretty name to: %S\n", accName.get());
+ rv = in->SetPrettyName(accName);
// We have a server, create an account.
nsCOMPtr<nsIMsgAccount> account;
- rv = accMgr->CreateAccount( getter_AddRefs( account));
- if (NS_SUCCEEDED( rv) && account)
+ rv = accMgr->CreateAccount(getter_AddRefs(account));
+ if (NS_SUCCEEDED(rv) && account)
{
- rv = account->SetIncomingServer( in);
+ rv = account->SetIncomingServer(in);
- IMPORT_LOG0( "Created an account and set the IMAP server as the incoming server\n");
+ IMPORT_LOG0("Created an account and set the IMAP server as the incoming server\n");
// Fiddle with the identities
SetIdentities(accMgr, account, pStrs[kPopAccountNameStr]->get(), pStrs[kPopServerStr]->get(), pStrs);
result = true;
if (ppAccount)
- account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
+ account->QueryInterface(NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
}
}
}
else
result = true;
- return( result);
+ return result;
}
void nsEudoraMac::SetIdentities(nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *userName, const char *serverName, nsCString **pStrs)
{
nsresult rv;
nsCOMPtr<nsIMsgIdentity> id;
- rv = accMgr->CreateIdentity( getter_AddRefs( id));
+ rv = accMgr->CreateIdentity(getter_AddRefs(id));
if (id)
{
nsAutoString fullName;
if (pStrs[kFullNameStr]->Length())
CopyASCIItoUTF16(pStrs[kFullNameStr]->get(), fullName);
id->SetFullName(fullName);
id->SetIdentityName(fullName);
if (pStrs[kReturnAddressStr]->Length())
@@ -911,57 +905,57 @@ void nsEudoraMac::SetIdentities(nsIMsgAc
else
{
nsCAutoString emailAddress;
emailAddress = userName;
emailAddress += "@";
emailAddress += serverName;
id->SetEmail(emailAddress);
}
- acc->AddIdentity( id);
- IMPORT_LOG0( "Created identity and added to the account\n");
- IMPORT_LOG1( "\tname: %s\n", pStrs[kFullNameStr]->get());
- IMPORT_LOG1( "\temail: %s\n", pStrs[kReturnAddressStr]->get());
+ acc->AddIdentity(id);
+ IMPORT_LOG0("Created identity and added to the account\n");
+ IMPORT_LOG1("\tname: %s\n", pStrs[kFullNameStr]->get());
+ IMPORT_LOG1("\temail: %s\n", pStrs[kReturnAddressStr]->get());
}
- SetSmtpServer( accMgr, acc, pStrs[kSmtpServerStr]->get(), userName);
+ SetSmtpServer(accMgr, acc, pStrs[kSmtpServerStr]->get(), userName);
}
-void nsEudoraMac::SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser)
+void nsEudoraMac::SetSmtpServer(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser)
{
nsresult rv;
nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && smtpService)
{
nsCOMPtr<nsISmtpServer> foundServer;
- rv = smtpService->FindServer( pUser, pServer, getter_AddRefs( foundServer));
- if (NS_SUCCEEDED( rv) && foundServer)
+ rv = smtpService->FindServer(pUser, pServer, getter_AddRefs(foundServer));
+ if (NS_SUCCEEDED(rv) && foundServer)
{
- IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
+ IMPORT_LOG1("SMTP server already exists: %s\n", pServer);
return;
}
nsCOMPtr<nsISmtpServer> smtpServer;
- rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
- if (NS_SUCCEEDED( rv) && smtpServer)
+ rv = smtpService->CreateSmtpServer(getter_AddRefs(smtpServer));
+ if (NS_SUCCEEDED(rv) && smtpServer)
{
smtpServer->SetHostname(nsDependentCString(pServer));
if (pUser)
smtpServer->SetUsername(nsDependentCString(pUser));
- IMPORT_LOG1( "Created new SMTP server: %s\n", pServer);
+ IMPORT_LOG1("Created new SMTP server: %s\n", pServer);
}
}
}
-nsresult nsEudoraMac::GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment)
+nsresult nsEudoraMac::GetAttachmentInfo(const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment)
{
mimeType.Truncate();
// Sample attachment line
// Internet:sandh.jpg (JPEG/JVWR) (0003C2E8)
OSType type = '????';
OSType creator = '????';
@@ -971,81 +965,81 @@ nsresult nsEudoraMac::GetAttachmentInfo(
nsCString str(pFileName);
if (str.Length() > 22)
{
// try and extract the mac file info from the attachment line
nsCString fileNum;
nsCString types;
- str.Right( fileNum, 10);
- if ((fileNum.CharAt( 0) == '(') && (fileNum.CharAt( 9) == ')'))
+ str.Right(fileNum, 10);
+ if ((fileNum.CharAt(0) == '(') && (fileNum.CharAt(9) == ')'))
{
for (i = 1; i < 9; i++)
{
fNum *= 16;
- c = fileNum.CharAt( i);
+ c = fileNum.CharAt(i);
if ((c >= '0') && (c <= '9'))
fNum += (c - '0');
else if ((c >= 'a') && (c <= 'f'))
fNum += (c - 'a' + 10);
else if ((c >= 'A') && (c <= 'F'))
fNum += (c - 'A' + 10);
else
break;
}
if (i == 9)
{
- str.Left( fileNum, str.Length() - 10);
+ str.Left(fileNum, str.Length() - 10);
str = fileNum;
- str.Trim( kWhitespace);
- str.Right( types, 11);
- if ((types.CharAt( 0) == '(') && (types.CharAt( 5) == '/') && (types.CharAt( 10) == ')'))
+ str.Trim(kWhitespace);
+ str.Right(types, 11);
+ if ((types.CharAt(0) == '(') && (types.CharAt(5) == '/') && (types.CharAt(10) == ')'))
{
- type = ((PRUint32)types.CharAt( 1)) << 24;
- type |= ((PRUint32)types.CharAt( 2)) << 16;
- type |= types.CharAt( 3) << 8;
- type |= types.CharAt( 4);
- creator = ((PRUint32)types.CharAt( 6)) << 24;
- creator |= ((PRUint32)types.CharAt( 7)) << 16;
- creator |= types.CharAt( 8) << 8;
- creator |= types.CharAt( 9);
- str.Left( types, str.Length() - 11);
+ type = ((PRUint32)types.CharAt(1)) << 24;
+ type |= ((PRUint32)types.CharAt(2)) << 16;
+ type |= types.CharAt(3) << 8;
+ type |= types.CharAt(4);
+ creator = ((PRUint32)types.CharAt(6)) << 24;
+ creator |= ((PRUint32)types.CharAt(7)) << 16;
+ creator |= types.CharAt(8) << 8;
+ creator |= types.CharAt(9);
+ str.Left(types, str.Length() - 11);
str = types;
- str.Trim( kWhitespace);
+ str.Trim(kWhitespace);
}
}
else
fNum = 0;
}
}
#ifdef IMPORT_DEBUG
nsCString typeStr;
nsCString creatStr;
- creatStr.Append( (const char *)&creator, 4);
- typeStr.Append( (const char *)&type, 4);
- IMPORT_LOG3( "\tAttachment type: %s, creator: %s, fileNum: %ld\n", typeStr.get(), creatStr.get(), fNum);
- IMPORT_LOG1( "\tAttachment file name: %s\n", str.get());
+ creatStr.Append((const char *)&creator, 4);
+ typeStr.Append((const char *)&type, 4);
+ IMPORT_LOG3("\tAttachment type: %s, creator: %s, fileNum: %ld\n", typeStr.get(), creatStr.get(), fNum);
+ IMPORT_LOG1("\tAttachment file name: %s\n", str.get());
#endif
FSRef fsRef;
- memset( &fsRef, 0, sizeof( fsRef));
+ memset(&fsRef, 0, sizeof(fsRef));
{
nsresult rv;
nsCOMPtr <nsILocalFile> pLocalFile = do_QueryInterface(pFile, &rv);
NS_ENSURE_SUCCESS(rv, rv);
pLocalFile->InitWithNativePath(str);
if (NS_FAILED(rv))
{
IMPORT_LOG0("\tfailed to set native path\n");
return rv;
}
- pFile->GetNativeLeafName( aAttachment);
+ pFile->GetNativeLeafName(aAttachment);
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(pFile, &rv);
if (NS_FAILED(rv))
{
IMPORT_LOG0("\tfailed to get local mac file\n");
return rv;
}
@@ -1057,19 +1051,19 @@ nsresult nsEudoraMac::GetAttachmentInfo(
}
}
if (HasResourceFork(&fsRef))
mimeType = "application/applefile";
else
mimeType = "application/octet-stream";
- IMPORT_LOG1( "\tMimeType: %s\n", mimeType.get());
+ IMPORT_LOG1("\tMimeType: %s\n", mimeType.get());
- return( NS_OK);
+ return NS_OK;
}
bool nsEudoraMac::HasResourceFork(FSRef *fsRef)
{
FSCatalogInfo catalogInfo;
OSErr err = FSGetCatalogInfo(fsRef,
kFSCatInfoDataSizes + kFSCatInfoRsrcSizes,
&catalogInfo, nsnull, nsnull, nsnull);
@@ -1084,151 +1078,149 @@ const char *cBadFolderNames[kNumBadFolde
"Eudora Items",
"Nicknames Folder",
"Parts Folder",
"Signature Folder",
"Spool Folder",
"Stationery Folder"
};
-bool nsEudoraMac::IsValidMailFolderName( nsCString& name)
+bool nsEudoraMac::IsValidMailFolderName(nsCString& name)
{
if (m_depth > 1)
- return( true);
+ return true;
for (int i = 0; i < kNumBadFolderNames; i++)
{
- if (name.Equals( cBadFolderNames[i], nsCaseInsensitiveCStringComparator()))
- return( false);
+ if (name.Equals(cBadFolderNames[i], nsCaseInsensitiveCStringComparator()))
+ return false;
}
- return( true);
+ return true;
}
-bool nsEudoraMac::IsValidMailboxName( nsCString& fName)
+bool nsEudoraMac::IsValidMailboxName(nsCString& fName)
{
if (m_depth > 1)
- return( true);
- if (fName.LowerCaseEqualsLiteral("eudora nicknames"))
- return( false);
- return( true);
+ return true;
+ return !fName.LowerCaseEqualsLiteral("eudora nicknames");
}
-bool nsEudoraMac::IsValidMailboxFile( nsIFile *pFile)
+bool nsEudoraMac::IsValidMailboxFile(nsIFile *pFile)
{
PRInt64 size = 0;
- nsresult rv = pFile->GetFileSize( &size);
+ nsresult rv = pFile->GetFileSize(&size);
if (size)
{
if (size < 10)
- return( false);
+ return false;
nsCOMPtr <nsIInputStream> inputStream;
rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), pFile);
- if (NS_FAILED( rv))
- return( false);
+ if (NS_FAILED(rv))
+ return false;
PRUint32 read = 0;
char buffer[6];
char * pBuf = buffer;
- rv = inputStream->Read( pBuf, 5, &read);
+ rv = inputStream->Read(pBuf, 5, &read);
inputStream->Close();
- if (NS_FAILED( rv) || (read != 5))
- return( false);
+ if (NS_FAILED(rv) || (read != 5))
+ return false;
buffer[5] = 0;
- if (strcmp( buffer, "From "))
- return( false);
+ if (strcmp(buffer, "From "))
+ return false;
}
- return( true);
+ return true;
}
-bool nsEudoraMac::FindAddressFolder( nsIFile **pFolder)
+bool nsEudoraMac::FindAddressFolder(nsIFile **pFolder)
{
- return( FindEudoraLocation( pFolder));
+ return FindEudoraLocation(pFolder);
}
-nsresult nsEudoraMac::FindAddressBooks( nsIFile *pRoot, nsISupportsArray **ppArray)
+nsresult nsEudoraMac::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray)
{
// Look for the nicknames file in this folder and then
// additional files in the Nicknames folder
// Try and find the nickNames file
nsresult rv;
nsCOMPtr<nsILocalFile> file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILocalFile> localRoot = do_QueryInterface(pRoot);
rv = file->InitWithFile(localRoot);
- if (NS_FAILED( rv))
- return( rv);
- rv = NS_NewISupportsArray( ppArray);
- if (NS_FAILED( rv))
+ if (NS_FAILED(rv))
+ return rv;
+ rv = NS_NewISupportsArray(ppArray);
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
- return( 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);
+ if (NS_FAILED(rv))
+ return rv;
nsString displayName;
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NICKNAMES_NAME, displayName);
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NICKNAMES_NAME, displayName);
PRInt64 sz = 0;
// First find the Nicknames file itself
- rv = file->AppendNative( NS_LITERAL_CSTRING("Eudora Nicknames"));
+ rv = file->AppendNative(NS_LITERAL_CSTRING("Eudora Nicknames"));
bool exists = false;
bool isFile = false;
- if (NS_SUCCEEDED( rv))
- rv = file->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = file->IsFile( &isFile);
+ if (NS_SUCCEEDED(rv))
+ rv = file->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = file->IsFile(&isFile);
nsCOMPtr<nsIImportABDescriptor> desc;
nsISupports *pInterface;
if (exists && isFile)
{
- rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ rv = impSvc->CreateNewABDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
sz = 0;
- file->GetFileSize( &sz);
+ file->GetFileSize(&sz);
desc->SetPreferredName(displayName);
- desc->SetSize( sz);
+ desc->SetSize(sz);
// SetAbFile will clone the file we pass to it.
desc->SetAbFile(file);
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- (*ppArray)->AppendElement( pInterface);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ (*ppArray)->AppendElement(pInterface);
pInterface->Release();
}
- if (NS_FAILED( rv))
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error creating address book descriptor for eudora nicknames\n");
- return( rv);
+ IMPORT_LOG0("*** Error creating address book descriptor for eudora nicknames\n");
+ return rv;
}
}
// Now try the directory of address books!
rv = file->InitWithFile(localRoot);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
rv = file->AppendNative(NS_LITERAL_CSTRING("Nicknames Folder"));
exists = false;
bool isDir = false;
- if (NS_SUCCEEDED( rv))
- rv = file->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = file->IsDirectory( &isDir);
+ if (NS_SUCCEEDED(rv))
+ rv = file->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = file->IsDirectory(&isDir);
if (!isDir)
- return( NS_OK);
+ return NS_OK;
bool hasMore;
nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
rv = file->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
NS_ENSURE_SUCCESS(rv, rv);
directoryEnumerator->HasMoreElements(&hasMore);
@@ -1238,56 +1230,56 @@ nsresult nsEudoraMac::FindAddressBooks(
while (hasMore && NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> aSupport;
rv = directoryEnumerator->GetNext(getter_AddRefs(aSupport));
nsCOMPtr<nsILocalFile> entry(do_QueryInterface(aSupport, &rv));
directoryEnumerator->HasMoreElements(&hasMore);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
isFile = false;
- rv = entry->IsFile( &isFile);
+ rv = entry->IsFile(&isFile);
rv = entry->GetLeafName(displayName);
- if (NS_SUCCEEDED( rv) && !displayName.IsEmpty() && isFile)
+ if (NS_SUCCEEDED(rv) && !displayName.IsEmpty() && isFile)
{
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
type = 0;
creator = 0;
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(entry, &rv);
if (NS_SUCCEEDED(rv))
{
macFile->GetFileCreator(&creator);
macFile->GetFileType(&type);
}
}
if (type == 'TEXT')
{
- rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ rv = impSvc->CreateNewABDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
sz = 0;
- entry->GetFileSize( &sz);
+ entry->GetFileSize(&sz);
desc->SetPreferredName(displayName);
- desc->SetSize( sz);
+ desc->SetSize(sz);
// SetAbFile will clone the file we pass to it.
desc->SetAbFile(entry);
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- (*ppArray)->AppendElement( pInterface);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ (*ppArray)->AppendElement(pInterface);
pInterface->Release();
}
- if (NS_FAILED( rv))
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error creating address book descriptor for eudora address book\n");
- return( rv);
+ IMPORT_LOG0("*** Error creating address book descriptor for eudora address book\n");
+ return rv;
}
}
}
}
}
}
- return( rv);
+ return rv;
}
--- a/mailnews/import/eudora/src/nsEudoraMac.h
+++ b/mailnews/import/eudora/src/nsEudoraMac.h
@@ -55,60 +55,98 @@ class nsIMsgAccount;
class nsEudoraMac : public nsEudoraMailbox, public nsEudoraAddress {
public:
nsEudoraMac();
~nsEudoraMac();
// retrieve the mail folder
- virtual bool FindMailFolder( nsIFile **pFolder);
+ virtual bool FindMailFolder(nsIFile **pFolder);
// get the list of mailboxes
- virtual nsresult FindMailboxes( nsIFile *pRoot, nsISupportsArray **ppArray);
+ virtual nsresult FindMailboxes(nsIFile *pRoot,
+ nsISupportsArray **ppArray);
// get a TOC file from a mailbox file
- virtual nsresult FindTOCFile( nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc);
+ virtual nsresult FindTOCFile(nsIFile *pMailFile,
+ nsIFile **pTOCFile,
+ bool *pDeleteToc);
- virtual nsresult GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment);
+ virtual nsresult GetAttachmentInfo(const char *pFileName,
+ nsIFile *pFile,
+ nsCString& mimeType,
+ nsCString& aAttachment);
// Address book stuff
- virtual bool FindAddressFolder( nsIFile **pFolder);
+ virtual bool FindAddressFolder(nsIFile **pFolder);
// get the list of mailboxes
- virtual nsresult FindAddressBooks( nsIFile *pRoot, nsISupportsArray **ppArray);
+ virtual nsresult FindAddressBooks(nsIFile *pRoot,
+ nsISupportsArray **ppArray);
// import settings
- static bool ImportSettings( nsIFile *pIniFile, nsIMsgAccount **localMailAccount);
- static bool FindSettingsFile( nsIFile **pIniFile) { return( FindEudoraLocation( pIniFile, true));}
+ static bool ImportSettings(nsIFile *pIniFile,
+ nsIMsgAccount **localMailAccount);
+ static bool FindSettingsFile(nsIFile **pIniFile) { return FindEudoraLocation(pIniFile, true);}
- static bool FindFiltersFile( nsIFile **pFiltersFile);
+ static bool FindFiltersFile(nsIFile **pFiltersFile);
private:
- static bool FindEudoraLocation( nsIFile **pFolder, bool findIni = false, nsIFile *pLookIn = nsnull);
- static bool FindEudoraLocation( nsIFile **pFolder, bool findIni, const char *specialDirName );
- static bool VerifyEudoraLocation( nsIFile **pFolder, bool findIni );
+ static bool FindEudoraLocation(nsIFile **pFolder,
+ bool findIni = false,
+ nsIFile *pLookIn = nsnull);
+ static bool FindEudoraLocation(nsIFile **pFolder,
+ bool findIni,
+ const char *specialDirName);
+ static bool VerifyEudoraLocation(nsIFile **pFolder, bool findIni);
- nsresult ScanMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
- nsresult IterateMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
- nsresult FoundMailFolder( nsILocalFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
- nsresult FoundMailbox( nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
+ nsresult ScanMailDir(nsIFile *pFolder,
+ nsISupportsArray *pArray,
+ nsIImportService *pImport);
+ nsresult IterateMailDir(nsIFile *pFolder,
+ nsISupportsArray *pArray,
+ nsIImportService *pImport);
+ nsresult FoundMailFolder(nsILocalFile *mailFolder,
+ const char *pName,
+ nsISupportsArray *pArray,
+ nsIImportService *pImport);
+ nsresult FoundMailbox(nsIFile *mailFile,
+ const char *pName,
+ nsISupportsArray *pArray,
+ nsIImportService *pImport);
- bool IsValidMailFolderName( nsCString& name);
- bool IsValidMailboxName( nsCString& fName);
- bool IsValidMailboxFile( nsIFile *pFile);
+ bool IsValidMailFolderName(nsCString& name);
+ bool IsValidMailboxName(nsCString& fName);
+ bool IsValidMailboxFile(nsIFile *pFile);
- bool CreateTocFromResource( nsIFile *pMail, nsIFile **pToc);
+ bool CreateTocFromResource(nsIFile *pMail, nsIFile **pToc);
// Settings support
- static bool BuildPOPAccount( nsIMsgAccountManager *accMgr, nsCString **pStrs, nsIMsgAccount **ppAccount, nsString& accName);
- static bool BuildIMAPAccount( nsIMsgAccountManager *accMgr, nsCString **pStrs, nsIMsgAccount **ppAccount, nsString& accName);
- static void SetIdentities( nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *userName, const char *serverName, nsCString **pStrs);
- static void SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser);
- static bool GetSettingsFromResource( nsIFile *pSettings, short resId, nsCString **pStrs, bool *pIMAP);
+ static bool BuildPOPAccount(nsIMsgAccountManager *accMgr,
+ nsCString **pStrs,
+ nsIMsgAccount **ppAccount,
+ nsString& accName);
+ static bool BuildIMAPAccount(nsIMsgAccountManager *accMgr,
+ nsCString **pStrs,
+ nsIMsgAccount **ppAccount,
+ nsString& accName);
+ static void SetIdentities(nsIMsgAccountManager *accMgr,
+ nsIMsgAccount *acc,
+ const char *userName,
+ const char *serverName,
+ nsCString **pStrs);
+ static void SetSmtpServer(nsIMsgAccountManager *pMgr,
+ nsIMsgAccount *pAcc,
+ const char *pServer,
+ const char *pUser);
+ static bool GetSettingsFromResource(nsIFile *pSettings,
+ short resId,
+ nsCString **pStrs,
+ bool *pIMAP);
private:
PRUint32 m_depth;
nsCOMPtr <nsILocalFile> m_mailImportLocation;
bool HasResourceFork(FSRef *fsRef);
};
--- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp
@@ -57,38 +57,35 @@
#define kMailReadBufferSize 16384
#define DATE_STR_LEN 64 // 64 bytes is plenty to hold the date header.
#define kWhitespace " \t\b\r\n"
const char *eudoraFromLine = "From - Mon Jan 1 00:00:00 1965\x0D\x0A";
#ifdef IMPORT_DEBUG
-void DUMP_FILENAME( nsIFile *pFile, bool endLine);
+void DUMP_FILENAME(nsIFile *pFile, bool endLine);
-void DUMP_FILENAME( nsIFile *pFile, bool endLine)
+void DUMP_FILENAME(nsIFile *pFile, bool endLine)
{
nsCString pPath;
if (pFile)
pFile->GetNativePath(pPath);
- if (!pPath.IsEmpty()) {
- IMPORT_LOG1( "%s", pPath.get());
- }
- else {
- IMPORT_LOG0( "Unknown");
- }
- if (endLine) {
- IMPORT_LOG0( "\n");
- }
+ if (!pPath.IsEmpty())
+ IMPORT_LOG1("%s", pPath.get());
+ else
+ IMPORT_LOG0("Unknown");
+ if (endLine)
+ IMPORT_LOG0("\n");
}
// #define DONT_DELETE_EUDORA_TEMP_FILES 1
#else
-#define DUMP_FILENAME( x, y)
+#define DUMP_FILENAME(x, y)
#endif
static const char *eudoraWeekDays[7] = {
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
@@ -195,154 +192,154 @@ nsEudoraMailbox::nsEudoraMailbox()
{
}
nsEudoraMailbox::~nsEudoraMailbox()
{
EmptyAttachments();
}
-nsresult nsEudoraMailbox::CreateTempFile( nsIFile **ppFile)
+nsresult nsEudoraMailbox::CreateTempFile(nsIFile **ppFile)
{
nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
"impmail.txt",
ppFile);
NS_ENSURE_SUCCESS(rv, rv);
return (*ppFile)->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
}
-nsresult nsEudoraMailbox::DeleteFile( nsIFile *pFile)
+nsresult nsEudoraMailbox::DeleteFile(nsIFile *pFile)
{
bool result;
nsresult rv = NS_OK;
result = false;
- pFile->Exists( &result);
+ pFile->Exists(&result);
if (result) {
result = false;
- pFile->IsFile( &result);
+ pFile->IsFile(&result);
if (result) {
#ifndef DONT_DELETE_EUDORA_TEMP_FILES
rv = pFile->Remove(false);
#endif
}
}
- return( rv);
+ return rv;
}
#define kComposeErrorStr "X-Eudora-Compose-Error: *****" "\x0D\x0A"
#define kHTMLTag "<html>"
-nsresult nsEudoraMailbox::ImportMailbox( PRUint32 *pBytes, bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIFile *pDst, PRInt32 *pMsgCount)
+nsresult nsEudoraMailbox::ImportMailbox(PRUint32 *pBytes, bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIFile *pDst, PRInt32 *pMsgCount)
{
nsCOMPtr<nsIFile> tocFile;
- nsCOMPtr <nsIInputStream> srcInputStream;
- nsCOMPtr <nsIInputStream> tocInputStream;
- nsCOMPtr <nsIOutputStream> mailOutputStream;
- bool importWithoutToc = true;
+ nsCOMPtr<nsIInputStream> srcInputStream;
+ nsCOMPtr<nsIInputStream> tocInputStream;
+ nsCOMPtr<nsIOutputStream> mailOutputStream;
+ bool importWithoutToc = true;
bool deleteToc = false;
nsresult rv;
nsCOMPtr<nsIFile> mailFile;
if (pMsgCount)
*pMsgCount = 0;
- rv = pSrc->GetFileSize( &m_mailSize);
+ rv = pSrc->GetFileSize(&m_mailSize);
- rv = NS_NewLocalFileInputStream(getter_AddRefs(srcInputStream), pSrc);
- if (NS_FAILED( rv))
- return( rv);
+ rv = NS_NewLocalFileInputStream(getter_AddRefs(srcInputStream), pSrc);
+ if (NS_FAILED(rv))
+ return rv;
- NS_ADDREF( pSrc);
+ NS_ADDREF(pSrc);
// First, get the index file for this mailbox
- rv = FindTOCFile( pSrc, getter_AddRefs( tocFile), &deleteToc);
- if (NS_SUCCEEDED( rv) && tocFile)
- {
- IMPORT_LOG0( "Reading euroda toc file: ");
- DUMP_FILENAME( tocFile, true);
+ rv = FindTOCFile(pSrc, getter_AddRefs(tocFile), &deleteToc);
+ if (NS_SUCCEEDED(rv) && tocFile)
+ {
+ IMPORT_LOG0("Reading euroda toc file: ");
+ DUMP_FILENAME(tocFile, true);
- rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mailOutputStream), pDst);
- NS_ENSURE_SUCCESS(rv, rv);
+ rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mailOutputStream), pDst);
+ NS_ENSURE_SUCCESS(rv, rv);
// Read the toc and import the messages
- rv = ImportMailboxUsingTOC( pBytes, pAbort, srcInputStream, tocFile, mailOutputStream, pMsgCount);
+ rv = ImportMailboxUsingTOC(pBytes, pAbort, srcInputStream, tocFile, mailOutputStream, pMsgCount);
// clean up
if (deleteToc)
- DeleteFile( tocFile);
+ DeleteFile(tocFile);
// If we were able to import with the TOC, then we don't need to bother
// importing without the TOC.
- if ( NS_SUCCEEDED(rv) ) {
+ if (NS_SUCCEEDED(rv)) {
importWithoutToc = false;
- IMPORT_LOG0( "Imported mailbox: "); DUMP_FILENAME( pSrc, false);
- IMPORT_LOG0( " Using TOC: "); DUMP_FILENAME(tocFile, true);
+ IMPORT_LOG0("Imported mailbox: "); DUMP_FILENAME(pSrc, false);
+ IMPORT_LOG0(" Using TOC: "); DUMP_FILENAME(tocFile, true);
}
else {
- IMPORT_LOG0( "*** Error importing with TOC - will import without TOC.\n");
+ IMPORT_LOG0("*** Error importing with TOC - will import without TOC.\n");
}
}
// pSrc must be Released before returning
if (importWithoutToc) {
// The source file contains partially constructed mail messages,
// and attachments. We should first investigate if we can use the mailnews msgCompose
// stuff to do the work for us. If not we have to scan the mailboxes and do TONS
// of work to properly reconstruct the message - Eudora is so nice that it strips things
// like MIME headers, character encoding, and attachments - beautiful!
- rv = pSrc->GetFileSize( &m_mailSize);
+ rv = pSrc->GetFileSize(&m_mailSize);
SimpleBufferTonyRCopiedOnce readBuffer;
SimpleBufferTonyRCopiedOnce headers;
SimpleBufferTonyRCopiedOnce body;
SimpleBufferTonyRCopiedOnce copy;
headers.m_convertCRs = true;
body.m_convertCRs = true;
- copy.Allocate( kCopyBufferSize);
- readBuffer.Allocate( kMailReadBufferSize);
+ copy.Allocate(kCopyBufferSize);
+ readBuffer.Allocate(kMailReadBufferSize);
ReadFileState state;
state.offset = 0;
state.size = m_mailSize;
state.pFile = pSrc;
- IMPORT_LOG0( "Reading mailbox\n");
+ IMPORT_LOG0("Reading mailbox\n");
- if (NS_SUCCEEDED( rv ))
+ if (NS_SUCCEEDED(rv))
{
nsCString defaultDate;
nsCAutoString bodyType;
- IMPORT_LOG0( "Reading first message\n");
+ IMPORT_LOG0("Reading first message\n");
- while (!*pAbort && NS_SUCCEEDED( rv = ReadNextMessage( &state, readBuffer, headers, body, defaultDate, bodyType, NULL))) {
+ while (!*pAbort && NS_SUCCEEDED(rv = ReadNextMessage(&state, readBuffer, headers, body, defaultDate, bodyType, NULL))) {
if (pBytes) {
*pBytes += body.m_writeOffset - 1 + headers.m_writeOffset - 1;
}
rv = ImportMessage(headers, body, defaultDate, bodyType, mailOutputStream, pMsgCount);
if (!readBuffer.m_bytesInBuf && (state.offset >= state.size))
break;
}
}
else {
- IMPORT_LOG0( "*** Error creating file spec for composition\n");
+ IMPORT_LOG0("*** Error creating file spec for composition\n");
}
}
pSrc->Release();
- return( rv);
+ return rv;
}
#ifdef XP_MACOSX
#define kMsgHeaderSize 220
#define kMsgFirstOffset 278
#else
#define kMsgHeaderSize 218
#define kMsgFirstOffset 104
@@ -358,45 +355,45 @@ nsresult nsEudoraMailbox::ImportMailboxU
{
nsresult rv = NS_OK;
PRInt64 mailSize = m_mailSize;
PRInt64 tocSize = 0;
PRUint32 saveBytes = pBytes ? *pBytes : 0;
nsCOMPtr <nsIInputStream> tocInputStream;
- rv = tocFile->GetFileSize( &tocSize);
+ rv = tocFile->GetFileSize(&tocSize);
// if the index or the mail file is empty then just
// use the original mail file.
if (!mailSize || !tocSize)
return NS_ERROR_FAILURE;
rv = NS_NewLocalFileInputStream(getter_AddRefs(tocInputStream), tocFile);
NS_ENSURE_SUCCESS(rv, rv);
SimpleBufferTonyRCopiedOnce readBuffer;
SimpleBufferTonyRCopiedOnce headers;
SimpleBufferTonyRCopiedOnce body;
SimpleBufferTonyRCopiedOnce copy;
PRInt32 tocOffset = kMsgFirstOffset;
EudoraTOCEntry tocEntry;
- copy.Allocate( kCopyBufferSize);
+ copy.Allocate(kCopyBufferSize);
readBuffer.Allocate(kMailReadBufferSize);
- IMPORT_LOG0( "Importing mailbox using TOC: ");
- DUMP_FILENAME( tocFile, true);
+ IMPORT_LOG0("Importing mailbox using TOC: ");
+ DUMP_FILENAME(tocFile, true);
nsCOMPtr <nsISeekableStream> tocSeekableStream = do_QueryInterface(tocInputStream);
nsCOMPtr <nsISeekableStream> mailboxSeekableStream = do_QueryInterface(pInputStream);
while (!*pAbort && (tocOffset < (PRInt32)tocSize)) {
- if ( NS_FAILED(rv = tocSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, tocOffset)) )
+ if (NS_FAILED(rv = tocSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, tocOffset)))
break;
- if ( NS_FAILED(rv = ReadTOCEntry(tocInputStream, tocEntry)) )
+ if (NS_FAILED(rv = ReadTOCEntry(tocInputStream, tocEntry)))
break;
// Quick and dirty way to read in and parse the message the way the rest
// of the code expects.
nsCString defaultDate;
nsCAutoString bodyType;
ReadFileState state;
@@ -407,39 +404,39 @@ nsresult nsEudoraMailbox::ImportMailboxU
// state.size is meant to be the size of the entire file, because it's
// assumed that ReadNextMessage will actually have to parse. We know
// exactly how big the message is, so we simply set the "size" to be
// immediately where the message ends.
state.offset = tocEntry.m_Offset;
state.pInputStream = pInputStream;
state.size = state.offset + tocEntry.m_Length;
- if ( NS_SUCCEEDED(rv = ReadNextMessage(&state, readBuffer, headers, body, defaultDate, bodyType, &tocEntry) ) )
+ if (NS_SUCCEEDED(rv = ReadNextMessage(&state, readBuffer, headers, body, defaultDate, bodyType, &tocEntry)))
{
rv = ImportMessage(headers, body, defaultDate, bodyType, pDst, pMsgCount);
if (pBytes)
*pBytes += tocEntry.m_Length;
}
// We currently don't consider an error from ReadNextMessage or ImportMessage to be fatal.
// Reset the error back to no error in case this is the last time through the loop.
rv = NS_OK;
tocOffset += kMsgHeaderSize;
}
- if ( NS_SUCCEEDED(rv) ) {
- IMPORT_LOG0( " finished\n");
+ if (NS_SUCCEEDED(rv)) {
+ IMPORT_LOG0(" finished\n");
}
else {
// We failed somewhere important enough that we kept the error.
// Bail on all that we imported since we'll be importing everything
// again using just the mailbox.
- IMPORT_LOG0( "*** Error importing mailbox using TOC: ");
+ IMPORT_LOG0("*** Error importing mailbox using TOC: ");
// DUMP_FILENAME(pMail, true);
// Reset pBytes back to where it was before we imported this mailbox.
// This will likely result in a funky progress bar which will move
// backwards, but that's probably the best we can do to keep the
// progress accurate since we'll be re-importing the same mailbox.
if (pBytes)
*pBytes = saveBytes;
@@ -450,17 +447,17 @@ nsresult nsEudoraMailbox::ImportMailboxU
}
return rv;
}
nsresult nsEudoraMailbox::ReadTOCEntry(nsIInputStream *pToc, EudoraTOCEntry& tocEntry)
{
#define READ_TOC_FIELD(entry) pBuffer = (char *)&entry;\
- if ( NS_FAILED(pToc->Read(pBuffer, sizeof(entry), &bytesRead)) || (bytesRead != sizeof(entry)) )\
+ if (NS_FAILED(pToc->Read(pBuffer, sizeof(entry), &bytesRead)) || (bytesRead != sizeof(entry)))\
return NS_ERROR_FAILURE
PRUint32 bytesRead = 0;
char * pBuffer;
// Here we'll read any initial data that's in the same format on both Mac and Windows
READ_TOC_FIELD(tocEntry.m_Offset);
READ_TOC_FIELD(tocEntry.m_Length);
@@ -538,359 +535,355 @@ nsresult nsEudoraMailbox::ImportMessage(
{
nsresult rv = NS_OK;
PRUint32 written = 0;
nsEudoraCompose compose;
// Unfortunately Eudora stores HTML messages in the sent folder
// without any content type header at all. If the first line of the message body is <html>
// then mark the message as html internally...See Bug #258489
- if (body.m_pBuffer && (body.m_writeOffset > (PRInt32)strlen(kHTMLTag)) && (strncmp(body.m_pBuffer, kHTMLTag, strlen(kHTMLTag)) == 0 ))
+ if (body.m_pBuffer && (body.m_writeOffset > (PRInt32)strlen(kHTMLTag)) && (strncmp(body.m_pBuffer, kHTMLTag, strlen(kHTMLTag)) == 0))
bodyType = "text/html"; // ignore whatever body type we were given...force html
- compose.SetBody( body.m_pBuffer, body.m_writeOffset - 1, bodyType);
- compose.SetHeaders( headers.m_pBuffer, headers.m_writeOffset - 1);
- compose.SetAttachments( &m_attachments);
+ compose.SetBody(body.m_pBuffer, body.m_writeOffset - 1, bodyType);
+ compose.SetHeaders(headers.m_pBuffer, headers.m_writeOffset - 1);
+ compose.SetAttachments(&m_attachments);
compose.SetDefaultDate(defaultDate);
nsCOMPtr <nsIFile> compositionFile;
rv = compose.SendTheMessage(m_mailImportLocation, getter_AddRefs(compositionFile));
- if (NS_SUCCEEDED( rv)) {
+ if (NS_SUCCEEDED(rv)) {
nsCString fromLine(eudoraFromLine);
SimpleBufferTonyRCopiedOnce copy;
- copy.Allocate( kCopyBufferSize);
+ copy.Allocate(kCopyBufferSize);
- /* IMPORT_LOG0( "Composed message in file: "); DUMP_FILENAME( compositionFile, true); */
+ /* IMPORT_LOG0("Composed message in file: "); DUMP_FILENAME(compositionFile, true); */
// copy the resulting file into the destination file!
- rv = compose.CopyComposedMessage( fromLine, compositionFile, pDst, copy);
+ rv = compose.CopyComposedMessage(fromLine, compositionFile, pDst, copy);
DeleteFile(compositionFile);
- if (NS_FAILED( rv)) {
- IMPORT_LOG0( "*** Error copying composed message to destination mailbox\n");
- }
+ if (NS_FAILED(rv))
+ IMPORT_LOG0("*** Error copying composed message to destination mailbox\n");
if (pMsgCount)
(*pMsgCount)++;
}
else {
- IMPORT_LOG0( "*** Error composing message, writing raw message\n");
- rv = WriteFromSep( pDst);
+ IMPORT_LOG0("*** Error composing message, writing raw message\n");
+ rv = WriteFromSep(pDst);
- rv = pDst->Write( kComposeErrorStr,
- strlen( kComposeErrorStr),
- &written );
+ rv = pDst->Write(kComposeErrorStr, strlen(kComposeErrorStr), &written);
- if (NS_SUCCEEDED( rv))
- rv = pDst->Write( headers.m_pBuffer, headers.m_writeOffset - 1, &written);
- if (NS_SUCCEEDED( rv) && (written == (headers.m_writeOffset - 1)))
- rv = pDst->Write( "\x0D\x0A" "\x0D\x0A", 4, &written);
- if (NS_SUCCEEDED( rv) && (written == 4))
- rv = pDst->Write( body.m_pBuffer, body.m_writeOffset - 1, &written);
- if (NS_SUCCEEDED( rv) && (written == (body.m_writeOffset - 1))) {
- rv = pDst->Write( "\x0D\x0A", 2, &written);
+ if (NS_SUCCEEDED(rv))
+ rv = pDst->Write(headers.m_pBuffer, headers.m_writeOffset - 1, &written);
+ if (NS_SUCCEEDED(rv) && (written == (headers.m_writeOffset - 1)))
+ rv = pDst->Write("\x0D\x0A" "\x0D\x0A", 4, &written);
+ if (NS_SUCCEEDED(rv) && (written == 4))
+ rv = pDst->Write(body.m_pBuffer, body.m_writeOffset - 1, &written);
+ if (NS_SUCCEEDED(rv) && (written == (body.m_writeOffset - 1))) {
+ rv = pDst->Write("\x0D\x0A", 2, &written);
if (written != 2)
rv = NS_ERROR_FAILURE;
}
- if (NS_FAILED( rv)) {
- IMPORT_LOG0( "*** Error writing to destination mailbox\n");
- }
+ if (NS_FAILED(rv))
+ IMPORT_LOG0("*** Error writing to destination mailbox\n");
}
return rv;
}
-nsresult nsEudoraMailbox::ReadNextMessage( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy,
+nsresult nsEudoraMailbox::ReadNextMessage(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy,
SimpleBufferTonyRCopiedOnce& header, SimpleBufferTonyRCopiedOnce& body,
nsCString& defaultDate, nsCString& bodyType, EudoraTOCEntry *pTocEntry)
{
header.m_writeOffset = 0;
body.m_writeOffset = 0;
nsresult rv;
PRInt32 lineLen;
char endBuffer = 0;
lineLen = -1;
// Find the from separator - we should actually be positioned at the
// from separator, but for now, we'll verify this.
while (lineLen == -1) {
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error, FillMailBuffer FAILED in ReadNextMessage\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error, FillMailBuffer FAILED in ReadNextMessage\n");
+ return rv;
}
- lineLen = IsEudoraFromSeparator( copy.m_pBuffer + copy.m_writeOffset, copy.m_bytesInBuf - copy.m_writeOffset, defaultDate);
+ lineLen = IsEudoraFromSeparator(copy.m_pBuffer + copy.m_writeOffset, copy.m_bytesInBuf - copy.m_writeOffset, defaultDate);
if (lineLen == -1) {
- while ((lineLen = FindStartLine( copy)) == -1) {
+ while ((lineLen = FindStartLine(copy)) == -1) {
copy.m_writeOffset = copy.m_bytesInBuf;
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error, FillMailBuffer FAILED in ReadNextMessage, looking for next start line\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error, FillMailBuffer FAILED in ReadNextMessage, looking for next start line\n");
+ return rv;
}
if (!copy.m_bytesInBuf) {
- IMPORT_LOG0( "*** Error, ReadNextMessage, looking for start of next line, got end of file.\n");
- return( NS_ERROR_FAILURE);
+ IMPORT_LOG0("*** Error, ReadNextMessage, looking for start of next line, got end of file.\n");
+ return NS_ERROR_FAILURE;
}
}
copy.m_writeOffset += lineLen;
lineLen = -1;
}
}
// Skip past the from line separator
- while ((lineLen = FindStartLine( copy)) == -1) {
+ while ((lineLen = FindStartLine(copy)) == -1) {
copy.m_writeOffset = copy.m_bytesInBuf;
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error, ReadNextMessage, FillMailBuffer failed looking for from sep\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error, ReadNextMessage, FillMailBuffer failed looking for from sep\n");
+ return rv;
}
if (!copy.m_bytesInBuf) {
- IMPORT_LOG0( "*** Error, ReadNextMessage, end of file looking for from sep\n");
- return( NS_ERROR_FAILURE);
+ IMPORT_LOG0("*** Error, ReadNextMessage, end of file looking for from sep\n");
+ return NS_ERROR_FAILURE;
}
}
copy.m_writeOffset += lineLen;
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error, Unable to fill mail buffer after from sep.\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error, Unable to fill mail buffer after from sep.\n");
+ return rv;
}
// This should be the headers...
PRInt32 endLen = -1;
- while ((endLen = IsEndHeaders( copy)) == -1) {
- while ((lineLen = FindNextEndLine( copy)) == -1) {
+ 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 (!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 (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);
+ 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 (!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 (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(copy.m_pBuffer, copy.m_writeOffset)) {
+ IMPORT_LOG0("*** Error writing final headers\n");
+ return NS_ERROR_FAILURE;
}
if (pTocEntry) {
// This is not the prettiest spot to stick this code, but it works and it was convenient.
char header_str[128];
// Write X-Mozilla-Status header
- PR_snprintf( header_str, 128, MSG_LINEBREAK X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, pTocEntry->GetMozillaStatusFlags() );
- header.Write( header_str, strlen(header_str) );
+ PR_snprintf(header_str, 128, MSG_LINEBREAK X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, pTocEntry->GetMozillaStatusFlags());
+ header.Write(header_str, strlen(header_str));
// Write X-Mozilla-Status2 header
- PR_snprintf( header_str, 128, X_MOZILLA_STATUS2_FORMAT MSG_LINEBREAK, pTocEntry->GetMozillaStatus2Flags() );
- header.Write( header_str, strlen(header_str) );
+ PR_snprintf(header_str, 128, X_MOZILLA_STATUS2_FORMAT MSG_LINEBREAK, pTocEntry->GetMozillaStatus2Flags());
+ header.Write(header_str, strlen(header_str));
// Format and write X-Mozilla-Keys header
nsCString keywordHdr(X_MOZILLA_KEYWORDS);
- if ( pTocEntry->HasEudoraLabel() ) {
- PR_snprintf( header_str, 128, "eudoralabel%d", pTocEntry->GetLabelNumber() );
+ if (pTocEntry->HasEudoraLabel()) {
+ PR_snprintf(header_str, 128, "eudoralabel%d", pTocEntry->GetLabelNumber());
keywordHdr.Replace(sizeof(HEADER_X_MOZILLA_KEYWORDS) + 1, strlen(header_str), header_str);
}
- header.Write( keywordHdr.get(), keywordHdr.Length() );
+ header.Write(keywordHdr.get(), keywordHdr.Length());
}
- if (!header.Write( &endBuffer, 1)) {
- IMPORT_LOG0( "*** Error writing header trailing null\n");
- return( NS_ERROR_FAILURE);
+ if (!header.Write(&endBuffer, 1)) {
+ IMPORT_LOG0("*** Error writing header trailing null\n");
+ return NS_ERROR_FAILURE;
}
copy.m_writeOffset += endLen;
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error reading beginning of message body\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error reading beginning of message body\n");
+ return rv;
}
EmptyAttachments();
// Get the body!
// Read one line at a time here and look for the next separator
nsCString tmp;
bool insideEudoraTags = false;
// by default we consider the body text to be plain text
bodyType = "text/plain";
- while ((lineLen = IsEudoraFromSeparator( copy.m_pBuffer + copy.m_writeOffset, copy.m_bytesInBuf - copy.m_writeOffset, tmp)) == -1) {
+ while ((lineLen = IsEudoraFromSeparator(copy.m_pBuffer + copy.m_writeOffset, copy.m_bytesInBuf - copy.m_writeOffset, tmp)) == -1) {
PRInt32 tagLength = 0;
- if (IsEudoraTag ( copy.m_pBuffer + copy.m_writeOffset, copy.m_bytesInBuf - copy.m_writeOffset, insideEudoraTags, bodyType, tagLength)) {
+ if (IsEudoraTag (copy.m_pBuffer + copy.m_writeOffset, copy.m_bytesInBuf - copy.m_writeOffset, insideEudoraTags, bodyType, tagLength)) {
// We don't want to keep eudora tags so skip over them.
// let's write the previous text
- if (!body.Write( copy.m_pBuffer, copy.m_writeOffset)) {
- IMPORT_LOG0( "*** Error writing to message body\n");
- return( NS_ERROR_FAILURE);
+ if (!body.Write(copy.m_pBuffer, copy.m_writeOffset)) {
+ IMPORT_LOG0("*** Error writing to message body\n");
+ return NS_ERROR_FAILURE;
}
// we want to skip over the tag...for now we are assuming the tag is always at the start of line.
copy.m_writeOffset += tagLength;
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error reading message body\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error reading message body\n");
+ return rv;
}
if (!copy.m_bytesInBuf)
break;
continue;
}
// Eudora Attachment lines are always outside Eudora Tags
// so we shouldn't try to find one here
if (!insideEudoraTags) {
// Debatable is whether or not to exclude these lines from the
// text of the message, I prefer not to in case the original
// attachment is actually missing.
- rv = ExamineAttachment( copy);
- if (NS_FAILED( rv)) {
- IMPORT_LOG0( "*** Error examining attachment line\n");
- return( rv);
+ rv = ExamineAttachment(copy);
+ if (NS_FAILED(rv)) {
+ IMPORT_LOG0("*** Error examining attachment line\n");
+ return rv;
}
}
- while (((lineLen = FindStartLine( copy)) == -1) && copy.m_bytesInBuf) {
+ while (((lineLen = FindStartLine(copy)) == -1) && copy.m_bytesInBuf) {
copy.m_writeOffset = copy.m_bytesInBuf;
- if (!body.Write( copy.m_pBuffer, copy.m_writeOffset)) {
- IMPORT_LOG0( "*** Error writing to message body\n");
- return( NS_ERROR_FAILURE);
+ if (!body.Write(copy.m_pBuffer, copy.m_writeOffset)) {
+ IMPORT_LOG0("*** Error writing to message body\n");
+ return NS_ERROR_FAILURE;
}
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error reading message body\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error reading message body\n");
+ return rv;
}
}
if (!copy.m_bytesInBuf)
break;
copy.m_writeOffset += lineLen;
// found the start of the next line
// make sure it's long enough to check for the from line
if ((copy.m_writeOffset + 2048) >= copy.m_bytesInBuf) {
- if (!body.Write( copy.m_pBuffer, copy.m_writeOffset)) {
- IMPORT_LOG0( "*** Error writing to message body 2\n");
- return( NS_ERROR_FAILURE);
+ if (!body.Write(copy.m_pBuffer, copy.m_writeOffset)) {
+ IMPORT_LOG0("*** Error writing to message body 2\n");
+ return NS_ERROR_FAILURE;
}
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error reading message body 2\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error reading message body 2\n");
+ return rv;
}
}
}
// the start of the current line is a from, we-re done
- if (!body.Write( copy.m_pBuffer, copy.m_writeOffset)) {
- IMPORT_LOG0( "*** Error writing final message body\n");
- return( NS_ERROR_FAILURE);
+ if (!body.Write(copy.m_pBuffer, copy.m_writeOffset)) {
+ IMPORT_LOG0("*** Error writing final message body\n");
+ return NS_ERROR_FAILURE;
}
- if (!body.Write( &endBuffer, 1)) {
- IMPORT_LOG0( "*** Error writing body trailing null\n");
- IMPORT_LOG2( "\tbody.m_size: %ld, body.m_writeOffset: %ld\n", body.m_size, body.m_writeOffset);
- return( NS_ERROR_FAILURE);
+ if (!body.Write(&endBuffer, 1)) {
+ IMPORT_LOG0("*** Error writing body trailing null\n");
+ IMPORT_LOG2("\tbody.m_size: %ld, body.m_writeOffset: %ld\n", body.m_size, body.m_writeOffset);
+ return NS_ERROR_FAILURE;
}
- if (NS_FAILED( rv = FillMailBuffer( pState, copy))) {
- IMPORT_LOG0( "*** Error filling mail buffer for next read message\n");
- return( rv);
+ if (NS_FAILED(rv = FillMailBuffer(pState, copy))) {
+ IMPORT_LOG0("*** Error filling mail buffer for next read message\n");
+ return rv;
}
- return( NS_OK);
+ return NS_OK;
}
-PRInt32 nsEudoraMailbox::FindStartLine( SimpleBufferTonyRCopiedOnce& data)
+PRInt32 nsEudoraMailbox::FindStartLine(SimpleBufferTonyRCopiedOnce& data)
{
PRInt32 len = data.m_bytesInBuf - data.m_writeOffset;
if (!len)
- return( -1);
+ return -1;
PRInt32 count = 0;
const char *pData = data.m_pBuffer + data.m_writeOffset;
// Skip to next end of line.
while ((count < len) && (*pData != nsCRT::CR) && (*pData != nsCRT::LF)) {
pData++;
count++;
}
if (count == len)
- return( -1);
+ return -1;
// Skip over end of line(s).
while ((count < len) && ((*pData == nsCRT::CR) || (*pData == nsCRT::LF))) {
pData++;
count++;
}
if (count < len)
- return( count);
+ return count;
- return( -1);
+ return -1;
}
-PRInt32 nsEudoraMailbox::FindNextEndLine( SimpleBufferTonyRCopiedOnce& data)
+PRInt32 nsEudoraMailbox::FindNextEndLine(SimpleBufferTonyRCopiedOnce& data)
{
PRInt32 len = data.m_bytesInBuf - data.m_writeOffset;
if (!len)
- return( -1);
+ return -1;
PRInt32 count = 0;
const char *pData = data.m_pBuffer + data.m_writeOffset;
// Skip over end of line(s).
while ((count < len) && ((*pData == nsCRT::CR) || (*pData == nsCRT::LF))) {
pData++;
count++;
}
// Skip to next end of line.
while ((count < len) && (*pData != nsCRT::CR) && (*pData != nsCRT::LF)) {
pData++;
count++;
}
if (count < len)
- return( count);
+ return count;
- return( -1);
+ return -1;
}
-PRInt32 nsEudoraMailbox::IsEndHeaders( SimpleBufferTonyRCopiedOnce& data)
+PRInt32 nsEudoraMailbox::IsEndHeaders(SimpleBufferTonyRCopiedOnce& data)
{
PRInt32 len = data.m_bytesInBuf - data.m_writeOffset;
if (len < 2)
- return( -1);
+ return -1;
const char *pChar = data.m_pBuffer + data.m_writeOffset;
// Double nsCRT::CR.
if ((*pChar == nsCRT::CR) && (*(pChar + 1) == nsCRT::CR))
- return( 2);
+ return 2;
if (len < 4)
- return( -1);
+ return -1;
// Double (nsCRT::CR + nsCRT::LF).
if ((*pChar == nsCRT::CR) && (*(pChar + 1) == nsCRT::LF) &&
(*(pChar + 2) == nsCRT::CR) && (*(pChar + 3) == nsCRT::LF))
- return( 4);
+ return 4;
- return( -1);
+ return -1;
}
static const char *eudoraTag[] = {
"<x-html>",
"</x-html>",
"<x-rich>",
"</x-rich>",
"<x-flowed>",
@@ -912,97 +905,97 @@ static const char *TagContentType[] = {
"text/html",
"text/enriched",
"text/enriched",
"text/plain",
"text/plain",
};
// Determine if this line contains an eudora special tag
-bool nsEudoraMailbox::IsEudoraTag( const char *pChar, PRInt32 maxLen, bool &insideEudoraTags, nsCString &bodyType, PRInt32 &tagLength)
+bool nsEudoraMailbox::IsEudoraTag(const char *pChar, PRInt32 maxLen, bool &insideEudoraTags, nsCString &bodyType, PRInt32 &tagLength)
{
PRInt32 idx = 0;
while ((tagLength = eudoraTagLen[idx]) != 0) {
- if (maxLen >= tagLength && !strncmp( eudoraTag[idx], pChar, tagLength)) {
+ if (maxLen >= tagLength && !strncmp(eudoraTag[idx], pChar, tagLength)) {
insideEudoraTags = (pChar[1] != '/');
bodyType = TagContentType[idx];
return true;
}
idx++;
}
return false;
}
// Determine if this line meets Eudora standards for a separator line
// This logic is based on Eudora 1.3.1's strict requirements for what
// makes a valid separator line. This may need to be relaxed for newer
// versions of Eudora.
// A sample from line:
// From john@uxc.cso.uiuc.edu Wed Jan 14 12:36:18 1989
-PRInt32 nsEudoraMailbox::IsEudoraFromSeparator( const char *pChar, PRInt32 maxLen, nsCString& defaultDate)
+PRInt32 nsEudoraMailbox::IsEudoraFromSeparator(const char *pChar, PRInt32 maxLen, nsCString& defaultDate)
{
if (maxLen < 12)
- return( -1);
+ return -1;
PRInt32 len = 0;
if ((*pChar != 'F') || (*(pChar + 1) != 'r') || (*(pChar + 2) != 'o') || (*(pChar + 3) != 'm'))
- return( -1);
+ return -1;
pChar += 4;
len += 4;
// According to Eudora the next char MUST be a space, and there can only be 1 space
// before the return mail address.
// I'll be nicer and allow any amount of whitespace
while (((*pChar == ' ') || (*pChar == '\t')) && (len < maxLen)) {
pChar++;
len++;
}
if (len == maxLen)
- return( -1);
+ return -1;
// Determine the length of the line
PRInt32 lineLen = len;
const char * pTok = pChar;
// Skip to next end of line.
while ((lineLen < maxLen) && (*pTok != nsCRT::CR) && (*pTok != nsCRT::LF)) {
lineLen++;
pTok++;
}
if (len >= lineLen)
- return( -1);
+ return -1;
// Eudora allows the return address to be double quoted or not at all..
// I'll allow single or double quote, but other than that, just skip
// the return address until you hit a space char (I allow tab as well)
char quote = *pChar;
if ((quote == '"') || (quote == '\'')) {
pChar++;
len++;
while ((len < lineLen) && (*pChar != quote)) {
pChar++;
len++;
}
if (len == lineLen)
- return( -1);
+ return -1;
len++;
pChar++;
}
else {
while ((len < lineLen) && (*pChar != ' ') && (*pChar != '\t')) {
pChar++;
len++;
}
}
while (((*pChar == ' ') || (*pChar == '\t')) && (len < lineLen)) {
pChar++;
len++;
}
if (len == lineLen)
- return( -1);
+ return -1;
// we've passed the address, now check for the remaining data
// Now it gets really funky!
// In no particular order, with token separators space, tab, comma, newline
// a - the phrase "remote from", remote must be first, from is optional. 2 froms or 2 remotes fails
// b - one and only one time value xx:xx or xx:xx:xx
// c - one and only one day, 1 to 31
// d - one and only one year, 2 digit anything or 4 digit > 1900
@@ -1029,40 +1022,40 @@ PRInt32 nsEudoraMailbox::IsEudoraFromSe
pTok = pChar;
tokStart = len;
while ((len < lineLen) && (*pChar != ' ') && (*pChar != '\t') && (*pChar != ',')) {
pChar++;
len++;
}
tokLen = len - tokStart;
if (tokLen) {
- num = AsciiToLong( pTok, tokLen);
- if ((tokLen == 3) && ((result = IsWeekDayStr( pTok)) != 0)) {
+ num = AsciiToLong(pTok, tokLen);
+ if ((tokLen == 3) && ((result = IsWeekDayStr(pTok)) != 0)) {
if (weekDay)
- return( -1);
+ return -1;
weekDay = result;
}
- else if ((tokLen == 3) && ((result = IsMonthStr( pTok)) != 0)) {
+ else if ((tokLen == 3) && ((result = IsMonthStr(pTok)) != 0)) {
if (month)
- return( -1);
+ return -1;
month = result;
}
- else if ((tokLen == 6) && !PL_strncasecmp( pTok, "remote", 6)) {
+ else if ((tokLen == 6) && !PL_strncasecmp(pTok, "remote", 6)) {
if (remote || from)
- return( -1);
+ return -1;
remote = true;
}
- else if ((tokLen == 4) && !PL_strncasecmp( pTok, "from", 4)) {
+ else if ((tokLen == 4) && !PL_strncasecmp(pTok, "from", 4)) {
if (!remote || from)
- return( -1);
+ return -1;
from = true;
}
- else if ((tokLen == 4) && ((num > 1900) || !strncmp( pTok, "0000", 4))) {
+ else if ((tokLen == 4) && ((num > 1900) || !strncmp(pTok, "0000", 4))) {
if (year)
- return( -1);
+ return -1;
year = (int)num;
if (!year)
year = 1900;
}
else if (!year && day && (tokLen == 2) && (*(pTok + 1) >= '0') && (*(pTok + 1) <= '9')) {
if (num < 65)
num += 1900;
else
@@ -1080,20 +1073,20 @@ PRInt32 nsEudoraMailbox::IsEudoraFromSe
if ((result != 2) && (result != 5)) {
if ((pTok[result] < '0') || (pTok[result] > '9')) {
break;
}
}
}
if (result == tokLen) {
if (tym)
- return( -1);
+ return -1;
tym = true;
// for future use, get the time value
- memcpy( tymStr, pTok, tokLen);
+ memcpy(tymStr, pTok, tokLen);
if (tokLen == 5) {
tymStr[5] = ':';
tymStr[6] = '0';
tymStr[7] = '0';
}
tymStr[8] = 0;
}
else {
@@ -1114,112 +1107,112 @@ PRInt32 nsEudoraMailbox::IsEudoraFromSe
if (day && year && month && tym && (other < 3)) {
// Now we need to make sure the next line
// isn't blank!
while (len < lineLen) {
len++;
pChar++;
}
if (len == maxLen)
- return( -1);
+ return -1;
if (*pChar == nsCRT::CR) {
len++;
pChar++;
if (*pChar == nsCRT::LF) {
len++;
pChar++;
}
}
else if (*pChar == nsCRT::LF) {
len++;
pChar++;
}
else
- return( -1);
+ return -1;
if (len >= maxLen)
- return( -1);
+ return -1;
while (len < maxLen) {
if ((*pChar == nsCRT::CR) || (*pChar == nsCRT::LF))
- return( -1);
+ return -1;
if ((*pChar != ' ') && (*pChar != '\t'))
break;
pChar++;
len++;
}
// Whew!, the next line isn't blank.
// Generate the default date header in case the date header is missing when we
// write out headers later. The header looks like "Date: Tue, 5 Feb 2002 23:05:04"
char date_header_str[DATE_STR_LEN];
PR_snprintf(date_header_str, DATE_STR_LEN, "Date: %s, %2d %s %4d %s", eudoraWeekDays[weekDay-1], day, eudoraMonths[month-1], year, tymStr);
defaultDate.Assign(date_header_str);
- return( lineLen);
+ return lineLen;
}
- return( -1);
+ return -1;
}
-PRInt32 nsEudoraMailbox::AsciiToLong( const char *pChar, PRInt32 len)
+PRInt32 nsEudoraMailbox::AsciiToLong(const char *pChar, PRInt32 len)
{
PRInt32 num = 0;
while (len) {
if ((*pChar < '0') || (*pChar > '9'))
- return( num);
+ return num;
num *= 10;
num += (*pChar - '0');
len--;
pChar++;
}
- return( num);
+ return num;
}
-int nsEudoraMailbox::IsWeekDayStr( const char *pStr)
+int nsEudoraMailbox::IsWeekDayStr(const char *pStr)
{
for (int i = 0; i < 7; i++) {
- if (!PL_strncasecmp( pStr, eudoraWeekDays[i], 3))
- return( i + 1);
+ if (!PL_strncasecmp(pStr, eudoraWeekDays[i], 3))
+ return i + 1;
}
- return( 0);
+ return 0;
}
-int nsEudoraMailbox::IsMonthStr( const char *pStr)
+int nsEudoraMailbox::IsMonthStr(const char *pStr)
{
for (int i = 0; i < 12; i++) {
- if (!PL_strncasecmp( pStr, eudoraMonths[i], 3))
- return( i + 1);
+ if (!PL_strncasecmp(pStr, eudoraMonths[i], 3))
+ return i + 1;
}
- return( 0);
+ return 0;
}
-nsresult nsEudoraMailbox::WriteFromSep( nsIOutputStream *pDst)
+nsresult nsEudoraMailbox::WriteFromSep(nsIOutputStream *pDst)
{
if (!m_fromLen)
- m_fromLen = strlen( eudoraFromLine);
+ m_fromLen = strlen(eudoraFromLine);
PRUint32 written = 0;
- nsresult rv = pDst->Write( eudoraFromLine, m_fromLen, &written);
- if (NS_SUCCEEDED( rv) && (written != m_fromLen))
- return( NS_ERROR_FAILURE);
- return( rv);
+ nsresult rv = pDst->Write(eudoraFromLine, m_fromLen, &written);
+ if (NS_SUCCEEDED(rv) && (written != m_fromLen))
+ return NS_ERROR_FAILURE;
+ return rv;
}
-void nsEudoraMailbox::EmptyAttachments( void)
+void nsEudoraMailbox::EmptyAttachments(void)
{
PRInt32 max = m_attachments.Count();
ImportAttachment * pAttach;
for (PRInt32 i = 0; i < max; i++) {
- pAttach = (ImportAttachment *) m_attachments.ElementAt( i);
+ pAttach = (ImportAttachment *) m_attachments.ElementAt(i);
if (pAttach) {
- NS_Free( pAttach->description);
- NS_Free( pAttach->mimeType);
+ NS_Free(pAttach->description);
+ NS_Free(pAttach->mimeType);
delete pAttach;
}
}
m_attachments.Clear();
}
static const char *eudoraAttachLines[] = {
@@ -1234,30 +1227,30 @@ static const char *eudoraAttachLines[] =
static PRInt32 eudoraAttachLen[] = {
21,
21,
24,
24,
0
};
-nsresult nsEudoraMailbox::ExamineAttachment( SimpleBufferTonyRCopiedOnce& data)
+nsresult nsEudoraMailbox::ExamineAttachment(SimpleBufferTonyRCopiedOnce& data)
{
// get the file, then get the mime type, and add it to the array
// of attachments.
PRInt32 len = data.m_bytesInBuf - data.m_writeOffset;
const char *pChar = data.m_pBuffer + data.m_writeOffset;
const char *pData;
const char *pStart;
PRInt32 nameLen;
char quote;
PRInt32 cnt;
PRInt32 idx = 0;
while ((cnt = eudoraAttachLen[idx]) != 0) {
- if (!strncmp( eudoraAttachLines[idx], pChar, cnt)) {
+ if (!strncmp(eudoraAttachLines[idx], pChar, cnt)) {
pData = pChar + cnt;
while (((*pData == ' ') || (*pData == '\t')) && (cnt < len)) {
cnt++;
pData++;
}
if (pData != pChar) {
quote = *pData;
nameLen = 0;
@@ -1277,77 +1270,79 @@ nsresult nsEudoraMailbox::ExamineAttachm
while ((cnt < len) &&
(*pData != nsCRT::CR) && (*pData != nsCRT::LF)) {
pData++;
cnt++;
nameLen++;
}
}
nsCString fileName;
- fileName.Append( pStart, nameLen);
- fileName.Trim( kWhitespace);
+ fileName.Append(pStart, nameLen);
+ fileName.Trim(kWhitespace);
if (fileName.Length()) {
#ifdef XP_MACOSX
return NS_OK;
#else
- if( AddAttachment( fileName))
- return( NS_OK);
+ if(AddAttachment(fileName))
+ return NS_OK;
#endif
}
}
}
idx++;
}
- return( NS_OK);
+ return NS_OK;
}
-bool nsEudoraMailbox::AddAttachment( nsCString& fileName)
+bool nsEudoraMailbox::AddAttachment(nsCString& fileName)
{
- IMPORT_LOG1( "Found attachment: %s\n", fileName.get());
+ IMPORT_LOG1("Found attachment: %s\n", fileName.get());
nsresult rv;
nsCOMPtr <nsILocalFile> pFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
- if (NS_FAILED( rv))
- return( false);
+ if (NS_FAILED(rv))
+ return false;
nsCString mimeType;
nsCString attachmentName;
- if (NS_FAILED( GetAttachmentInfo( fileName.get(), pFile, mimeType, attachmentName)))
- return( false);
+ if (NS_FAILED(GetAttachmentInfo(fileName.get(), pFile, mimeType, attachmentName)))
+ return false;
ImportAttachment *a = new ImportAttachment;
a->mimeType = ToNewCString(mimeType);
- a->description = !attachmentName.IsEmpty() ? ToNewCString(attachmentName) : strdup( "Attached File");
+ a->description = !attachmentName.IsEmpty() ? ToNewCString(attachmentName) : strdup("Attached File");
a->pAttachment = pFile;
- m_attachments.AppendElement( a);
+ m_attachments.AppendElement(a);
- return( true);
+ return true;
}
-nsresult nsEudoraMailbox::FillMailBuffer( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read)
+nsresult nsEudoraMailbox::FillMailBuffer(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read)
{
if (read.m_writeOffset >= read.m_bytesInBuf) {
read.m_writeOffset = 0;
read.m_bytesInBuf = 0;
}
else if (read.m_writeOffset) {
- memcpy( read.m_pBuffer, read.m_pBuffer + read.m_writeOffset, read.m_bytesInBuf - read.m_writeOffset);
+ memcpy(read.m_pBuffer, read.m_pBuffer + read.m_writeOffset, read.m_bytesInBuf - read.m_writeOffset);
read.m_bytesInBuf -= read.m_writeOffset;
read.m_writeOffset = 0;
}
PRUint32 count = read.m_size - read.m_bytesInBuf;
if ((count + pState->offset) > pState->size)
count = pState->size - pState->offset;
if (count) {
PRUint32 bytesRead = 0;
char * pBuffer = read.m_pBuffer + read.m_bytesInBuf;
nsresult rv = pState->pInputStream->Read(pBuffer, count, &bytesRead);
- if (NS_FAILED( rv)) return( rv);
- if (bytesRead != PRUint32(count)) return( NS_ERROR_FAILURE);
+ if (NS_FAILED(rv))
+ return rv;
+ if (bytesRead != PRUint32(count))
+ return NS_ERROR_FAILURE;
read.m_bytesInBuf += bytesRead;
pState->offset += bytesRead;
}
- return( NS_OK);
+ return NS_OK;
}
--- a/mailnews/import/eudora/src/nsEudoraMailbox.h
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.h
@@ -166,56 +166,56 @@ public:
class nsEudoraMailbox {
public:
nsEudoraMailbox();
virtual ~nsEudoraMailbox();
// Things that must be overridden because they are platform specific.
// retrieve the mail folder
- virtual bool FindMailFolder( nsIFile **pFolder) { return( false);}
+ virtual bool FindMailFolder(nsIFile **pFolder) { return false;}
// get the list of mailboxes
- virtual nsresult FindMailboxes( nsIFile *pRoot, nsISupportsArray **ppArray) { return( NS_ERROR_FAILURE);}
+ virtual nsresult FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) { return NS_ERROR_FAILURE;}
// get the toc file corresponding to this mailbox
- virtual nsresult FindTOCFile( nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc) { return( NS_ERROR_FAILURE);}
+ virtual nsresult FindTOCFile(nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc) { return NS_ERROR_FAILURE;}
// interpret the attachment line and return the attached file
- virtual nsresult GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment) { return( NS_ERROR_FAILURE);}
+ virtual nsresult GetAttachmentInfo(const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment) { return NS_ERROR_FAILURE;}
// Non-platform specific common stuff
// import a mailbox
- nsresult ImportMailbox( PRUint32 *pBytes, bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIFile *pDst, PRInt32 *pMsgCount);
+ nsresult ImportMailbox(PRUint32 *pBytes, bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIFile *pDst, PRInt32 *pMsgCount);
- static PRInt32 IsEudoraFromSeparator( const char *pData, PRInt32 maxLen, nsCString& defaultDate);
- static bool IsEudoraTag( const char *pChar, PRInt32 maxLen, bool &insideEudoraTags, nsCString &bodyType, PRInt32& tagLength);
+ static PRInt32 IsEudoraFromSeparator(const char *pData, PRInt32 maxLen, nsCString& defaultDate);
+ static bool IsEudoraTag(const char *pChar, PRInt32 maxLen, bool &insideEudoraTags, nsCString &bodyType, PRInt32& tagLength);
protected:
- nsresult CreateTempFile( nsIFile **ppFile);
- nsresult DeleteFile( nsIFile *pFile);
+ nsresult CreateTempFile(nsIFile **ppFile);
+ nsresult DeleteFile(nsIFile *pFile);
private:
- nsresult ImportMailboxUsingTOC( PRUint32 *pBytes, bool *pAbort, nsIInputStream *pInputStream, nsIFile *tocFile, nsIOutputStream *pDst, PRInt32 *pMsgCount);
+ nsresult ImportMailboxUsingTOC(PRUint32 *pBytes, bool *pAbort, nsIInputStream *pInputStream, nsIFile *tocFile, nsIOutputStream *pDst, PRInt32 *pMsgCount);
nsresult ReadTOCEntry(nsIInputStream *pToc, EudoraTOCEntry& tocEntry);
nsresult ImportMessage(SimpleBufferTonyRCopiedOnce& headers, SimpleBufferTonyRCopiedOnce& body, nsCString& defaultDate, nsCAutoString& bodyType, nsIOutputStream *pDst, PRInt32 *pMsgCount);
- nsresult ReadNextMessage( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header,
+ nsresult ReadNextMessage(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header,
SimpleBufferTonyRCopiedOnce& body, nsCString& defaultDate,
nsCString &defBodyType, EudoraTOCEntry *pTocEntry);
- PRInt32 FindStartLine( SimpleBufferTonyRCopiedOnce& data);
- PRInt32 FindNextEndLine( SimpleBufferTonyRCopiedOnce& data);
- PRInt32 IsEndHeaders( SimpleBufferTonyRCopiedOnce& data);
- nsresult WriteFromSep( nsIOutputStream *pDst);
- nsresult FillMailBuffer( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
+ PRInt32 FindStartLine(SimpleBufferTonyRCopiedOnce& data);
+ PRInt32 FindNextEndLine(SimpleBufferTonyRCopiedOnce& data);
+ PRInt32 IsEndHeaders(SimpleBufferTonyRCopiedOnce& data);
+ nsresult WriteFromSep(nsIOutputStream *pDst);
+ nsresult FillMailBuffer(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
- void EmptyAttachments( void);
- nsresult ExamineAttachment( SimpleBufferTonyRCopiedOnce& data);
- bool AddAttachment( nsCString& fileName);
+ void EmptyAttachments(void);
+ nsresult ExamineAttachment(SimpleBufferTonyRCopiedOnce& data);
+ bool AddAttachment(nsCString& fileName);
- static PRInt32 AsciiToLong( const char *pChar, PRInt32 len);
- static int IsWeekDayStr( const char *pStr);
- static int IsMonthStr( const char *pStr);
+ static PRInt32 AsciiToLong(const char *pChar, PRInt32 len);
+ static int IsWeekDayStr(const char *pStr);
+ static int IsMonthStr(const char *pStr);
protected:
nsCOMPtr <nsILocalFile> m_mailImportLocation;
private:
PRInt64 m_mailSize;
PRUint32 m_fromLen;
nsVoidArray m_attachments;
--- a/mailnews/import/eudora/src/nsEudoraSettings.cpp
+++ b/mailnews/import/eudora/src/nsEudoraSettings.cpp
@@ -82,76 +82,76 @@ nsEudoraSettings::~nsEudoraSettings()
NS_IMPL_ISUPPORTS1(nsEudoraSettings, nsIImportSettings)
NS_IMETHODIMP nsEudoraSettings::AutoLocate(PRUnichar **description, nsIFile **location, bool *_retval)
{
NS_PRECONDITION(description != nsnull, "null ptr");
NS_PRECONDITION(_retval != nsnull, "null ptr");
NS_PRECONDITION(location != nsnull, "null ptr");
if (!description || !_retval || !location)
- return( NS_ERROR_NULL_POINTER);
+ return NS_ERROR_NULL_POINTER;
*description = nsnull;
*_retval = false;
nsresult rv;
m_pLocation = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- *description = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME);
+ *description = nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NAME);
#if defined(XP_WIN) || defined(XP_OS2)
- *_retval = nsEudoraWin32::FindSettingsFile( getter_AddRefs(m_pLocation));
+ *_retval = nsEudoraWin32::FindSettingsFile(getter_AddRefs(m_pLocation));
#endif
NS_IF_ADDREF(*location = m_pLocation);
return NS_OK;
}
NS_IMETHODIMP nsEudoraSettings::SetLocation(nsIFile *location)
{
m_pLocation = location;
- return( NS_OK);
+ return NS_OK;
}
NS_IMETHODIMP nsEudoraSettings::Import(nsIMsgAccount **localMailAccount, bool *_retval)
{
- NS_PRECONDITION( _retval != nsnull, "null ptr");
+ 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));
+ 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);
+ 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);
+ *_retval = nsEudoraWin32::ImportSettings(m_pLocation, localMailAccount);
#endif
#ifdef XP_MACOSX
- *_retval = nsEudoraMac::ImportSettings( m_pLocation, localMailAccount);
+ *_retval = nsEudoraMac::ImportSettings(m_pLocation, localMailAccount);
#endif
if (*_retval) {
- IMPORT_LOG0( "Successful import of eudora settings\n");
+ IMPORT_LOG0("Successful import of eudora settings\n");
}
else {
- IMPORT_LOG0( "*** Error, Unsuccessful import of eudora settings\n");
+ IMPORT_LOG0("*** Error, Unsuccessful import of eudora settings\n");
}
- return( NS_OK);
+ return NS_OK;
}
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
@@ -46,53 +46,53 @@
#include "nsIURI.h"
#include "nsTextFormatter.h"
#include "mozilla/Services.h"
#define EUDORA_MSGS_URL "chrome://messenger/locale/eudoraImportMsgs.properties"
nsIStringBundle * nsEudoraStringBundle::m_pBundle = nsnull;
-nsIStringBundle *nsEudoraStringBundle::GetStringBundle( void)
+nsIStringBundle *nsEudoraStringBundle::GetStringBundle(void)
{
if (m_pBundle)
return m_pBundle;
const char* propertyURL = EUDORA_MSGS_URL;
nsIStringBundle* sBundle = nsnull;
nsCOMPtr<nsIStringBundleService> sBundleService =
mozilla::services::GetStringBundleService();
if (sBundleService)
sBundleService->CreateBundle(propertyURL, &sBundle);
m_pBundle = sBundle;
- return( sBundle);
+ return sBundle;
}
-void nsEudoraStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
+void nsEudoraStringBundle::GetStringByID(PRInt32 stringID, nsString& result)
{
PRUnichar *ptrv = GetStringByID(stringID);
result = ptrv;
- FreeString( ptrv);
+ FreeString(ptrv);
}
PRUnichar *nsEudoraStringBundle::GetStringByID(PRInt32 stringID)
{
if (!m_pBundle)
m_pBundle = GetStringBundle();
if (m_pBundle)
{
PRUnichar *ptrv = nsnull;
nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv);
- if (NS_SUCCEEDED( rv) && ptrv)
- return( ptrv);
+ if (NS_SUCCEEDED(rv) && ptrv)
+ return ptrv;
}
nsString resultString(NS_LITERAL_STRING("[StringID "));
resultString.AppendInt(stringID);
resultString.AppendLiteral("?]");
return ToNewUnicode(resultString);
}
@@ -110,14 +110,14 @@ nsString nsEudoraStringBundle::FormatStr
PRUnichar *pText = nsTextFormatter::vsmprintf(format.get(), args);
va_end(args);
nsString result(pText);
nsTextFormatter::smprintf_free(pText);
return result;
}
-void nsEudoraStringBundle::Cleanup( void)
+void nsEudoraStringBundle::Cleanup(void)
{
if (m_pBundle)
m_pBundle->Release();
m_pBundle = nsnull;
}
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.h
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.h
@@ -43,19 +43,19 @@
class nsIStringBundle;
class nsEudoraStringBundle {
public:
static PRUnichar * GetStringByID(PRInt32 stringID);
static void GetStringByID(PRInt32 stringID, nsString& result);
static nsString FormatString(PRInt32 stringID, ...);
- static nsIStringBundle * GetStringBundle( void); // don't release
- static void FreeString( PRUnichar *pStr) { NS_Free( pStr);}
- static void Cleanup( void);
+ static nsIStringBundle * GetStringBundle(void); // don't release
+ static void FreeString(PRUnichar *pStr) { NS_Free(pStr);}
+ static void Cleanup(void);
private:
static nsIStringBundle * m_pBundle;
};
#define EUDORAIMPORT_NAME 2000
--- a/mailnews/import/eudora/src/nsEudoraWin32.cpp
+++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp
@@ -62,216 +62,214 @@
#include "EudoraDebugLog.h"
#include "prmem.h"
#include "plstr.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static const char * kWhitespace = "\b\t\r\n ";
-// ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Accounts", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &sKey) == ERROR_SUCCESS)
-
-BYTE * nsEudoraWin32::GetValueBytes( HKEY hKey, const char *pValueName)
+BYTE * nsEudoraWin32::GetValueBytes(HKEY hKey, const char *pValueName)
{
LONG err;
DWORD bufSz;
LPBYTE pBytes = NULL;
- err = ::RegQueryValueEx( hKey, pValueName, NULL, NULL, NULL, &bufSz);
+ err = ::RegQueryValueEx(hKey, pValueName, NULL, NULL, NULL, &bufSz);
if (err == ERROR_SUCCESS)
{
pBytes = new BYTE[bufSz];
- err = ::RegQueryValueEx( hKey, pValueName, NULL, NULL, pBytes, &bufSz);
+ err = ::RegQueryValueEx(hKey, pValueName, NULL, NULL, pBytes, &bufSz);
if (err != ERROR_SUCCESS)
{
delete [] pBytes;
pBytes = NULL;
}
}
- return( pBytes);
+ return pBytes;
}
nsEudoraWin32::nsEudoraWin32()
{
m_pMimeSection = nsnull;
}
nsEudoraWin32::~nsEudoraWin32()
{
delete [] m_pMimeSection;
}
-bool nsEudoraWin32::FindMailFolder( nsIFile **pFolder)
+bool nsEudoraWin32::FindMailFolder(nsIFile **pFolder)
{
- return( FindEudoraLocation( pFolder));
+ return FindEudoraLocation(pFolder);
}
-bool nsEudoraWin32::FindEudoraLocation( nsIFile **pFolder, bool findIni)
+bool nsEudoraWin32::FindEudoraLocation(nsIFile **pFolder, bool findIni)
{
bool result = false;
bool exists = false;
nsCOMPtr <nsILocalFile> eudoraPath = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
// look in the registry to see where eudora is installed?
HKEY sKey;
- if (::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Qualcomm\\Eudora\\CommandLine", 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS)
+ if (::RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Qualcomm\\Eudora\\CommandLine", 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS)
{
// get the value of "Current"
- BYTE *pBytes = GetValueBytes( sKey, "Current");
+ BYTE *pBytes = GetValueBytes(sKey, "Current");
if (pBytes)
{
nsCString str((const char *)pBytes);
delete [] pBytes;
MsgCompressWhitespace(str);
// Command line is Eudora mailfolder eudora.ini
if (findIni)
{
// find the string coming after the last space
PRInt32 index = str.RFind(" ");
if (index != -1)
{
index++; // skip the space
eudoraPath->InitWithNativePath(Substring(str, index));
- eudoraPath->IsFile( &exists);
+ eudoraPath->IsFile(&exists);
if (exists)
result = exists;
else // it may just be the mailbox location....guess that there will be a eudora.ini file there
{
eudoraPath->AppendNative(NS_LITERAL_CSTRING("eudora.ini"));
- eudoraPath->IsFile( &exists);
+ eudoraPath->IsFile(&exists);
result = exists;
}
}
} // if findIni
else
{
int idx = -1;
- if (str.CharAt( 0) == '"')
+ if (str.CharAt(0) == '"')
{
- idx = str.FindChar( '"', 1);
+ idx = str.FindChar('"', 1);
if (idx != -1)
idx++;
}
else
- idx = str.FindChar( ' ');
+ idx = str.FindChar(' ');
if (idx != -1)
{
idx++;
- while (str.CharAt( idx) == ' ') idx++;
+ while (str.CharAt(idx) == ' ') idx++;
int endIdx = -1;
- if (str.CharAt( idx) == '"')
- endIdx = str.FindChar( '"', idx);
+ if (str.CharAt(idx) == '"')
+ endIdx = str.FindChar('"', idx);
else {
- endIdx = str.FindChar( ' ', idx);
+ endIdx = str.FindChar(' ', idx);
if (endIdx == -1)
endIdx = str.Length();
}
if (endIdx != -1)
{
eudoraPath->InitWithNativePath(Substring(str, idx, endIdx - idx));
- if (NS_SUCCEEDED( eudoraPath->IsDirectory( &exists)))
+ if (NS_SUCCEEDED(eudoraPath->IsDirectory(&exists)))
result = exists;
}
}
}
} // if pBytes
- ::RegCloseKey( sKey);
+ ::RegCloseKey(sKey);
}
NS_IF_ADDREF(*pFolder = eudoraPath);
- return( result);
+ return result;
}
-nsresult nsEudoraWin32::FindMailboxes( nsIFile *pRoot, nsISupportsArray **ppArray)
+nsresult nsEudoraWin32::FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray)
{
- nsresult rv = NS_NewISupportsArray( ppArray);
- if (NS_FAILED( rv))
+ nsresult rv = NS_NewISupportsArray(ppArray);
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
- return( 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);
+ if (NS_FAILED(rv))
+ return rv;
m_depth = 0;
m_mailImportLocation = do_QueryInterface(pRoot);
- return( ScanMailDir( pRoot, *ppArray, impSvc));
+ return ScanMailDir(pRoot, *ppArray, impSvc);
}
-nsresult nsEudoraWin32::ScanMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraWin32::ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
{
bool exists = false;
bool isFile = false;
char * pContents = nsnull;
PRInt32 len = 0;
nsCOMPtr<nsIFile> descMap;
nsresult rv;
- if (NS_FAILED( rv = pFolder->Clone(getter_AddRefs(descMap))))
- return( rv);
+ if (NS_FAILED(rv = pFolder->Clone(getter_AddRefs(descMap))))
+ return rv;
m_depth++;
rv = descMap->AppendNative(NS_LITERAL_CSTRING("descmap.pce"));
- if (NS_SUCCEEDED( rv))
- rv = descMap->IsFile( &isFile);
- if (NS_SUCCEEDED( rv))
- rv = descMap->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists && isFile)
+ if (NS_SUCCEEDED(rv))
+ rv = descMap->IsFile(&isFile);
+ if (NS_SUCCEEDED(rv))
+ rv = descMap->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists && isFile)
{
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), descMap);
if (NS_FAILED(rv))
return rv;
PRUint32 bytesLeft = 0;
rv = inputStream->Available(&bytesLeft);
if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error checking address file for eof\n");
+ IMPORT_LOG0("*** Error checking address file for eof\n");
inputStream->Close();
return rv;
}
pContents = (char *) PR_Malloc(bytesLeft + 1);
if (!pContents)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 bytesRead;
rv = inputStream->Read(pContents, bytesLeft, &bytesRead);
if (bytesRead != bytesLeft)
return NS_ERROR_FAILURE;
pContents[bytesRead] = '\0';
- if (NS_SUCCEEDED( rv) && pContents)
+ if (NS_SUCCEEDED(rv) && pContents)
{
len = bytesRead;
- if (NS_SUCCEEDED( rv))
- rv = ScanDescmap( pFolder, pArray, pImport, pContents, len);
- PR_Free( pContents);
+ if (NS_SUCCEEDED(rv))
+ rv = ScanDescmap(pFolder, pArray, pImport, pContents, len);
+ PR_Free(pContents);
}
else
rv = NS_ERROR_FAILURE;
}
- if (NS_FAILED( rv) || !isFile || !exists)
- rv = IterateMailDir( pFolder, pArray, pImport);
+ if (NS_FAILED(rv) || !isFile || !exists)
+ rv = IterateMailDir(pFolder, pArray, pImport);
m_depth--;
- return( rv);
+ return rv;
}
-nsresult nsEudoraWin32::IterateMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraWin32::IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
{
bool hasMore;
nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
nsresult rv = pFolder->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
NS_ENSURE_SUCCESS(rv, rv);
directoryEnumerator->HasMoreElements(&hasMore);
bool isFolder;
@@ -283,70 +281,70 @@ nsresult nsEudoraWin32::IterateMailDir(
while (hasMore && NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> aSupport;
rv = directoryEnumerator->GetNext(getter_AddRefs(aSupport));
nsCOMPtr<nsILocalFile> entry(do_QueryInterface(aSupport, &rv));
directoryEnumerator->HasMoreElements(&hasMore);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
rv = entry->GetNativeLeafName(fName);
- if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
+ if (NS_SUCCEEDED(rv) && !fName.IsEmpty())
{
if (fName.Length() > 4)
{
ext = StringTail(fName, 4);
name = StringHead(fName, fName.Length() - 4);
}
else
{
ext.Truncate();
name = fName;
}
ToLowerCase(ext);
if (ext.EqualsLiteral(".fol"))
{
isFolder = false;
- entry->IsDirectory( &isFolder);
+ entry->IsDirectory(&isFolder);
if (isFolder)
{
// add the folder
- rv = FoundMailFolder( entry, name.get(), pArray, pImport);
- if (NS_SUCCEEDED( rv))
+ rv = FoundMailFolder(entry, name.get(), pArray, pImport);
+ if (NS_SUCCEEDED(rv))
{
- rv = ScanMailDir( entry, pArray, pImport);
- if (NS_FAILED( rv))
- IMPORT_LOG0( "*** Error scanning mail directory\n");
+ rv = ScanMailDir(entry, pArray, pImport);
+ if (NS_FAILED(rv))
+ IMPORT_LOG0("*** Error scanning mail directory\n");
}
}
}
else if (ext.EqualsLiteral(".mbx"))
{
isFile = false;
- entry->IsFile( &isFile);
+ entry->IsFile(&isFile);
if (isFile)
- rv = FoundMailbox( entry, name.get(), pArray, pImport);
+ rv = FoundMailbox(entry, name.get(), pArray, pImport);
}
}
}
}
- return( rv);
+ return rv;
}
-nsresult nsEudoraWin32::ScanDescmap( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len)
+nsresult nsEudoraWin32::ScanDescmap(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len)
{
// use this to find stuff in the directory.
nsCOMPtr<nsIFile> entry;
nsresult rv;
- if (NS_FAILED( rv = pFolder->Clone(getter_AddRefs(entry))))
- return( rv);
+ if (NS_FAILED(rv = pFolder->Clone(getter_AddRefs(entry))))
+ return rv;
entry->AppendNative(NS_LITERAL_CSTRING("dummy"));
// format is Name,FileName,Type,Flag?
// Type = M or S for mailbox
// = F for folder
PRInt32 fieldLen;
PRInt32 pos = 0;
const char * pStart;
@@ -363,353 +361,347 @@ nsresult nsEudoraWin32::ScanDescmap( nsI
while ((pos < len) && (*pData != ','))
{
pos++;
pData++;
fieldLen++;
}
name.Truncate();
if (fieldLen)
- name.Append( pStart, fieldLen);
- name.Trim( kWhitespace);
+ name.Append(pStart, fieldLen);
+ name.Trim(kWhitespace);
pos++;
pData++;
pStart = pData;
fieldLen = 0;
while ((pos < len) && (*pData != ','))
{
pos++;
pData++;
fieldLen++;
}
fName.Truncate();
if (fieldLen)
- fName.Append( pStart, fieldLen);
+ fName.Append(pStart, fieldLen);
// Descmap file name is written without any extraneous white space - i.e.
// if there's whitespace present it's intentional and important. Don't
// strip whitespace from the fName.
pos++;
pData++;
pStart = pData;
fieldLen = 0;
while ((pos < len) && (*pData != ','))
{
pos++;
pData++;
fieldLen++;
}
type.Truncate();
if (fieldLen)
- type.Append( pStart, fieldLen);
- type.Trim( kWhitespace);
+ type.Append(pStart, fieldLen);
+ type.Trim(kWhitespace);
pos++;
pData++;
pStart = pData;
fieldLen = 0;
// Skip to next end of line, or ',' separator.
while ((pos < len) &&
(*pData != nsCRT::CR) && (*pData != nsCRT::LF) && (*pData != ','))
{
pos++;
pData++;
fieldLen++;
}
flag.Truncate();
if (fieldLen)
- flag.Append( pStart, fieldLen);
- flag.Trim( kWhitespace);
+ flag.Append(pStart, fieldLen);
+ flag.Trim(kWhitespace);
// Skip over end of line(s).
while ((pos < len) && ((*pData == nsCRT::CR) || (*pData == nsCRT::LF)))
{
pos++;
pData++;
}
- IMPORT_LOG2( "name: %s, fName: %s\n", name.get(), fName.get());
+ IMPORT_LOG2("name: %s, fName: %s\n", name.get(), fName.get());
if (!fName.IsEmpty() && !name.IsEmpty() && (type.Length() == 1))
{
rv = entry->SetNativeLeafName(fName);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
- if (type.CharAt( 0) == 'F')
+ if (type.CharAt(0) == 'F')
{
isFolder = false;
- entry->IsDirectory( &isFolder);
+ entry->IsDirectory(&isFolder);
if (isFolder)
{
- rv = FoundMailFolder( entry, name.get(), pArray, pImport);
- if (NS_SUCCEEDED( rv))
+ rv = FoundMailFolder(entry, name.get(), pArray, pImport);
+ if (NS_SUCCEEDED(rv))
{
- rv = ScanMailDir( entry, pArray, pImport);
- if (NS_FAILED( rv))
- IMPORT_LOG0( "*** Error scanning mail directory\n");
+ rv = ScanMailDir(entry, pArray, pImport);
+ if (NS_FAILED(rv))
+ IMPORT_LOG0("*** Error scanning mail directory\n");
}
}
}
- else if ((type.CharAt( 0) == 'M') || (type.CharAt( 0) == 'S'))
+ else if ((type.CharAt(0) == 'M') || (type.CharAt(0) == 'S'))
{
isFile = false;
- entry->IsFile( &isFile);
+ entry->IsFile(&isFile);
if (isFile)
- FoundMailbox( entry, name.get(), pArray, pImport);
+ FoundMailbox(entry, name.get(), pArray, pImport);
}
}
}
}
- return( NS_OK);
+ return NS_OK;
}
-nsresult nsEudoraWin32::FoundMailbox( nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraWin32::FoundMailbox(nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
{
nsString displayName;
nsCOMPtr<nsIImportMailboxDescriptor> desc;
nsISupports * pInterface;
NS_CopyNativeToUnicode(nsDependentCString(pName), displayName);
#ifdef IMPORT_DEBUG
nsCAutoString path;
mailFile->GetNativePath(path);
if (!path.IsEmpty())
- IMPORT_LOG2( "Found eudora mailbox, %s: %s\n", path.get(), pName);
+ IMPORT_LOG2("Found eudora mailbox, %s: %s\n", path.get(), pName);
else
- IMPORT_LOG1( "Found eudora mailbox, %s\n", pName);
- IMPORT_LOG1( "\tm_depth = %d\n", (int)m_depth);
+ IMPORT_LOG1("Found eudora mailbox, %s\n", pName);
+ IMPORT_LOG1("\tm_depth = %d\n", (int)m_depth);
#endif
- nsresult rv = pImport->CreateNewMailboxDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ nsresult rv = pImport->CreateNewMailboxDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
PRInt64 sz = 0;
- mailFile->GetFileSize( &sz);
- desc->SetDisplayName( displayName.get());
- desc->SetDepth( m_depth);
- desc->SetSize( sz);
+ mailFile->GetFileSize(&sz);
+ desc->SetDisplayName(displayName.get());
+ desc->SetDepth(m_depth);
+ desc->SetSize(sz);
nsCOMPtr <nsILocalFile> pFile = nsnull;
desc->GetFile(getter_AddRefs(pFile));
if (pFile)
{
nsCOMPtr <nsILocalFile> localMailFile = do_QueryInterface(mailFile);
- pFile->InitWithFile( localMailFile);
+ pFile->InitWithFile(localMailFile);
}
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- pArray->AppendElement( pInterface);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ pArray->AppendElement(pInterface);
pInterface->Release();
}
- return( NS_OK);
+ return NS_OK;
}
-nsresult nsEudoraWin32::FoundMailFolder( nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
+nsresult nsEudoraWin32::FoundMailFolder(nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
{
nsString displayName;
nsCOMPtr<nsIImportMailboxDescriptor> desc;
nsISupports * pInterface;
NS_CopyNativeToUnicode(nsDependentCString(pName), displayName);
#ifdef IMPORT_DEBUG
nsCAutoString path;
mailFolder->GetNativePath(path);
if (!path.IsEmpty())
- IMPORT_LOG2( "Found eudora folder, %s: %s\n", path.get(), pName);
+ IMPORT_LOG2("Found eudora folder, %s: %s\n", path.get(), pName);
else
- IMPORT_LOG1( "Found eudora folder, %s\n", pName);
- IMPORT_LOG1( "\tm_depth = %d\n", (int)m_depth);
+ IMPORT_LOG1("Found eudora folder, %s\n", pName);
+ IMPORT_LOG1("\tm_depth = %d\n", (int)m_depth);
#endif
- nsresult rv = pImport->CreateNewMailboxDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ nsresult rv = pImport->CreateNewMailboxDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
PRUint32 sz = 0;
- desc->SetDisplayName( displayName.get());
- desc->SetDepth( m_depth);
- desc->SetSize( sz);
+ desc->SetDisplayName(displayName.get());
+ desc->SetDepth(m_depth);
+ desc->SetSize(sz);
nsCOMPtr <nsILocalFile> pFile = nsnull;
desc->GetFile(getter_AddRefs(pFile));
if (pFile)
{
nsCOMPtr <nsILocalFile> localMailFile = do_QueryInterface(mailFolder);
- pFile->InitWithFile( localMailFile);
+ pFile->InitWithFile(localMailFile);
}
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- pArray->AppendElement( pInterface);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ pArray->AppendElement(pInterface);
pInterface->Release();
}
- return( NS_OK);
+ return NS_OK;
}
-nsresult nsEudoraWin32::FindTOCFile( nsIFile *pMailFile, nsIFile **ppTOCFile, bool *pDeleteToc)
+nsresult nsEudoraWin32::FindTOCFile(nsIFile *pMailFile, nsIFile **ppTOCFile, bool *pDeleteToc)
{
nsresult rv;
nsCAutoString leaf;
*pDeleteToc = false;
*ppTOCFile = nsnull;
rv = pMailFile->GetNativeLeafName(leaf);
- if (NS_FAILED( rv))
- return( rv);
- rv = pMailFile->GetParent( ppTOCFile);
- if (NS_FAILED( rv))
- return( rv);
+ if (NS_FAILED(rv))
+ return rv;
+ rv = pMailFile->GetParent(ppTOCFile);
+ if (NS_FAILED(rv))
+ return rv;
nsCString name;
- if ((leaf.Length() > 4) && (leaf.CharAt( leaf.Length() - 4) == '.'))
+ if ((leaf.Length() > 4) && (leaf.CharAt(leaf.Length() - 4) == '.'))
name = StringHead(leaf, leaf.Length() - 4);
else
name = leaf;
- name.Append( ".toc");
+ name.Append(".toc");
rv = (*ppTOCFile)->AppendNative(name);
- if (NS_FAILED( rv))
- return( rv);
+ if (NS_FAILED(rv))
+ return rv;
bool exists = false;
- rv = (*ppTOCFile)->Exists( &exists);
- if (NS_FAILED( rv))
- return( rv);
+ rv = (*ppTOCFile)->Exists(&exists);
+ if (NS_FAILED(rv))
+ return rv;
bool isFile = false;
- rv = (*ppTOCFile)->IsFile( &isFile);
- if (NS_FAILED( rv))
- return( rv);
+ rv = (*ppTOCFile)->IsFile(&isFile);
+ if (NS_FAILED(rv))
+ return rv;
if (exists && isFile)
- return( NS_OK);
+ return NS_OK;
- return( NS_ERROR_FAILURE);
+ return NS_ERROR_FAILURE;
}
-bool nsEudoraWin32::ImportSettings( nsIFile *pIniFile, nsIMsgAccount **localMailAccount)
+bool nsEudoraWin32::ImportSettings(nsIFile *pIniFile, nsIMsgAccount **localMailAccount)
{
bool result = false;
nsresult rv;
nsCOMPtr<nsIMsgAccountManager> accMgr =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Failed to create a account manager!\n");
- return( false);
+ IMPORT_LOG0("*** Failed to create a account manager!\n");
+ return false;
}
// Eudora info is arranged by key, 1 for the default, then persona's for additional
// accounts.
// Start with the first one, then do each persona
nsCString iniPath;
pIniFile->GetNativePath(iniPath);
if (iniPath.IsEmpty())
- return( false);
+ return false;
UINT valInt;
SimpleBufferTonyRCopiedOnce section;
DWORD sSize;
DWORD sOffset = 0;
DWORD start;
nsCString sectionName("Settings");
int popCount = 0;
int accounts = 0;
DWORD allocSize = 0;
do
{
allocSize += 2048;
- section.Allocate( allocSize);
- sSize = ::GetPrivateProfileSection( "Personalities", section.m_pBuffer, allocSize, iniPath.get());
+ section.Allocate(allocSize);
+ sSize = ::GetPrivateProfileSection("Personalities", section.m_pBuffer, allocSize, iniPath.get());
} while (sSize == (allocSize - 2));
nsIMsgAccount * pAccount;
do
{
if (!sectionName.IsEmpty())
{
pAccount = nsnull;
- valInt = ::GetPrivateProfileInt( sectionName.get(), "UsesPOP", 1, iniPath.get());
+ valInt = ::GetPrivateProfileInt(sectionName.get(), "UsesPOP", 1, iniPath.get());
if (valInt)
{
// This is a POP account
- if (BuildPOPAccount( accMgr, sectionName.get(), iniPath.get(), &pAccount))
+ if (BuildPOPAccount(accMgr, sectionName.get(), iniPath.get(), &pAccount))
{
accounts++;
popCount++;
if (popCount > 1)
{
if (localMailAccount && *localMailAccount)
- {
- NS_RELEASE( *localMailAccount);
- *localMailAccount = nsnull;
- }
+ NS_RELEASE(*localMailAccount);
}
- else
+ else if (localMailAccount)
{
- if (localMailAccount)
- {
- *localMailAccount = pAccount;
- NS_IF_ADDREF( pAccount);
- }
+ *localMailAccount = pAccount;
+ NS_IF_ADDREF(pAccount);
}
}
}
else
{
- valInt = ::GetPrivateProfileInt( sectionName.get(), "UsesIMAP", 0, iniPath.get());
+ valInt = ::GetPrivateProfileInt(sectionName.get(), "UsesIMAP", 0, iniPath.get());
if (valInt)
{
// This is an IMAP account
- if (BuildIMAPAccount( accMgr, sectionName.get(), iniPath.get(), &pAccount))
+ if (BuildIMAPAccount(accMgr, sectionName.get(), iniPath.get(), &pAccount))
accounts++;
}
}
if (pAccount && (sOffset == 0))
- accMgr->SetDefaultAccount( pAccount);
+ accMgr->SetDefaultAccount(pAccount);
- NS_IF_RELEASE( pAccount);
+ NS_IF_RELEASE(pAccount);
}
sectionName.Truncate();
while ((sOffset < sSize) && (section.m_pBuffer[sOffset] != '='))
sOffset++;
sOffset++;
start = sOffset;
while ((sOffset < sSize) && (section.m_pBuffer[sOffset] != 0))
sOffset++;
if (sOffset > start)
{
- sectionName.Append( section.m_pBuffer + start, sOffset - start);
- sectionName.Trim( kWhitespace);
+ sectionName.Append(section.m_pBuffer + start, sOffset - start);
+ sectionName.Trim(kWhitespace);
}
} while (sOffset < sSize);
// Now save the new acct info to pref file.
rv = accMgr->SaveAccountInfo();
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't save account info to pref file");
- return( accounts != 0);
+ return accounts != 0;
}
-bool nsEudoraWin32::FindFiltersFile( nsIFile **pFiltersFile)
+bool nsEudoraWin32::FindFiltersFile(nsIFile **pFiltersFile)
{
- bool result = FindEudoraLocation( pFiltersFile, false);
+ bool result = FindEudoraLocation(pFiltersFile, false);
if (result)
{
- (*pFiltersFile)->AppendNative( NS_LITERAL_CSTRING("Filters.pce") );
+ (*pFiltersFile)->AppendNative(NS_LITERAL_CSTRING("Filters.pce"));
(*pFiltersFile)->IsFile(&result);
}
return result;
}
-bool nsEudoraWin32::GetMailboxNameHierarchy( const nsACString& pEudoraLocation, const char* pEudoraFilePath, nsCString& nameHierarchy)
+bool nsEudoraWin32::GetMailboxNameHierarchy(const nsACString& pEudoraLocation, const char* pEudoraFilePath, nsCString& nameHierarchy)
{
if (pEudoraLocation.IsEmpty() || !pEudoraFilePath || !*pEudoraFilePath)
return false;
nsresult rv;
nsCOMPtr <nsILocalFile> descMap = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
rv = descMap->InitWithNativePath(pEudoraLocation);
@@ -769,56 +761,56 @@ bool nsEudoraWin32::GetMailboxNameHierar
return false;
}
// maximium size of settings strings
#define kIniValueSize 384
-void nsEudoraWin32::GetServerAndUserName( const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff)
+void nsEudoraWin32::GetServerAndUserName(const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff)
{
DWORD valSize;
int idx;
nsCString tStr;
serverName.Truncate();
userName.Truncate();
- valSize = ::GetPrivateProfileString( pSection, "PopServer", "", pBuff, kIniValueSize, pIni);
+ valSize = ::GetPrivateProfileString(pSection, "PopServer", "", pBuff, kIniValueSize, pIni);
if (valSize)
serverName = pBuff;
else
{
- valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
+ valSize = ::GetPrivateProfileString(pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
if (valSize)
{
serverName = pBuff;
- idx = serverName.FindChar( '@');
+ idx = serverName.FindChar('@');
if (idx != -1)
serverName = Substring(serverName, idx + 1);
}
}
- valSize = ::GetPrivateProfileString( pSection, "LoginName", "", pBuff, kIniValueSize, pIni);
+ valSize = ::GetPrivateProfileString(pSection, "LoginName", "", pBuff, kIniValueSize, pIni);
if (valSize)
userName = pBuff;
else
{
- valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
+ valSize = ::GetPrivateProfileString(pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
if (valSize)
{
userName = pBuff;
- idx = userName.FindChar( '@');
+ idx = userName.FindChar('@');
if (idx != -1)
userName.SetLength(idx);
}
}
}
-void nsEudoraWin32::GetAccountName( const char *pSection, nsString& str)
+void nsEudoraWin32::GetAccountName(const char *pSection, nsString& str)
{
str.Truncate();
nsCString s(pSection);
if (s.LowerCaseEqualsLiteral("settings"))
{
str.AssignLiteral("Eudora ");
@@ -828,236 +820,236 @@ void nsEudoraWin32::GetAccountName( cons
{
str.AssignASCII(pSection);
if (StringBeginsWith(s, NS_LITERAL_CSTRING("persona-"), nsCaseInsensitiveCStringComparator()))
CopyASCIItoUTF16(Substring(s, 8), str);
}
}
-bool nsEudoraWin32::BuildPOPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount)
+bool nsEudoraWin32::BuildPOPAccount(nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount)
{
if (ppAccount)
*ppAccount = nsnull;
char valBuff[kIniValueSize];
nsCString serverName;
nsCString userName;
- GetServerAndUserName( pSection, pIni, serverName, userName, valBuff);
+ GetServerAndUserName(pSection, pIni, serverName, userName, valBuff);
if (serverName.IsEmpty() || userName.IsEmpty())
- return( false);
+ 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 = accMgr->FindServer( userName, serverName, NS_LITERAL_CSTRING("pop3"), getter_AddRefs(in));
+ nsresult rv = accMgr->FindServer(userName, serverName, NS_LITERAL_CSTRING("pop3"), getter_AddRefs(in));
if (NS_FAILED(rv) || !in)
{
// Create the incoming server and an account for it?
- rv = accMgr->CreateIncomingServer( userName, serverName, NS_LITERAL_CSTRING("pop3"), getter_AddRefs(in));
- if (NS_SUCCEEDED( rv) && in)
+ rv = accMgr->CreateIncomingServer(userName, serverName, NS_LITERAL_CSTRING("pop3"), getter_AddRefs(in));
+ if (NS_SUCCEEDED(rv) && in)
{
rv = in->SetType(NS_LITERAL_CSTRING("pop3"));
- // rv = in->SetHostName( serverName);
- // rv = in->SetUsername( userName);
+ // rv = in->SetHostName(serverName);
+ // rv = in->SetUsername(userName);
- IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", serverName.get(), userName.get());
+ IMPORT_LOG2("Created POP3 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);
+ 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 = accMgr->CreateAccount(getter_AddRefs(account));
+ if (NS_SUCCEEDED(rv) && account)
{
- rv = account->SetIncomingServer( in);
+ rv = account->SetIncomingServer(in);
- IMPORT_LOG0( "Created a new account and set the incoming server to the POP3 server.\n");
+ IMPORT_LOG0("Created a new account and set the incoming server to the POP3 server.\n");
nsCOMPtr<nsIPop3IncomingServer> pop3Server = do_QueryInterface(in, &rv);
NS_ENSURE_SUCCESS(rv,rv);
UINT valInt = ::GetPrivateProfileInt(pSection, "LeaveMailOnServer", 0, pIni);
pop3Server->SetLeaveMessagesOnServer(valInt ? true : false);
// Fiddle with the identities
SetIdentities(accMgr, account, pSection, pIni, userName.get(), serverName.get(), valBuff);
result = true;
if (ppAccount)
- account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
+ account->QueryInterface(NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
}
}
}
else
result = true;
- return( result);
+ return result;
}
-bool nsEudoraWin32::BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount)
+bool 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);
+ GetServerAndUserName(pSection, pIni, serverName, userName, valBuff);
if (serverName.IsEmpty() || userName.IsEmpty())
- return( false);
+ return false;
bool result = false;
nsCOMPtr<nsIMsgIncomingServer> in;
- nsresult rv = accMgr->FindServer( userName, serverName, NS_LITERAL_CSTRING("imap"), getter_AddRefs(in));
- if (NS_FAILED( rv) || (in == nsnull))
+ 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 = 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);
+ // rv = in->SetHostName(serverName);
+ // rv = in->SetUsername(userName);
- IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", serverName.get(), userName.get());
+ 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());
+ 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 = 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");
+ 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 = true;
if (ppAccount)
- account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
+ account->QueryInterface(NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
}
}
}
else
result = true;
- return( result);
+ return result;
}
void nsEudoraWin32::SetIdentities(nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff)
{
nsCAutoString realName;
nsCAutoString email;
nsCAutoString server;
DWORD valSize;
nsresult rv;
- valSize = ::GetPrivateProfileString( pSection, "RealName", "", pBuff, kIniValueSize, pIniFile);
+ valSize = ::GetPrivateProfileString(pSection, "RealName", "", pBuff, kIniValueSize, pIniFile);
if (valSize)
realName = pBuff;
- valSize = ::GetPrivateProfileString( pSection, "SMTPServer", "", pBuff, kIniValueSize, pIniFile);
+ valSize = ::GetPrivateProfileString(pSection, "SMTPServer", "", pBuff, kIniValueSize, pIniFile);
if (valSize)
server = pBuff;
- valSize = ::GetPrivateProfileString( pSection, "ReturnAddress", "", pBuff, kIniValueSize, pIniFile);
+ valSize = ::GetPrivateProfileString(pSection, "ReturnAddress", "", pBuff, kIniValueSize, pIniFile);
if (valSize)
email = pBuff;
nsCOMPtr<nsIMsgIdentity> id;
- rv = accMgr->CreateIdentity( getter_AddRefs( id));
+ rv = accMgr->CreateIdentity(getter_AddRefs(id));
if (id)
{
nsAutoString fullName;
fullName.Assign(NS_ConvertASCIItoUTF16(realName));
id->SetFullName(fullName);
id->SetIdentityName(fullName);
if (email.IsEmpty())
{
email = userName;
email += "@";
email += serverName;
}
id->SetEmail(email);
- acc->AddIdentity( id);
+ acc->AddIdentity(id);
- IMPORT_LOG0( "Created identity and added to the account\n");
- IMPORT_LOG1( "\tname: %s\n", realName.get());
- IMPORT_LOG1( "\temail: %s\n", email.get());
+ IMPORT_LOG0("Created identity and added to the account\n");
+ IMPORT_LOG1("\tname: %s\n", realName.get());
+ IMPORT_LOG1("\temail: %s\n", email.get());
}
- SetSmtpServer( accMgr, acc, server.get(), userName);
+ SetSmtpServer(accMgr, acc, server.get(), userName);
}
-void nsEudoraWin32::SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser)
+void nsEudoraWin32::SetSmtpServer(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser)
{
nsresult rv;
nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && smtpService)
{
nsCOMPtr<nsISmtpServer> foundServer;
- rv = smtpService->FindServer( pUser, pServer, getter_AddRefs( foundServer));
- if (NS_SUCCEEDED( rv) && foundServer)
+ rv = smtpService->FindServer(pUser, pServer, getter_AddRefs(foundServer));
+ if (NS_SUCCEEDED(rv) && foundServer)
{
- IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
+ IMPORT_LOG1("SMTP server already exists: %s\n", pServer);
return;
}
nsCOMPtr<nsISmtpServer> smtpServer;
- rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
- if (NS_SUCCEEDED( rv) && smtpServer)
+ rv = smtpService->CreateSmtpServer(getter_AddRefs(smtpServer));
+ if (NS_SUCCEEDED(rv) && smtpServer)
{
smtpServer->SetHostname(nsDependentCString(pServer));
if (pUser)
smtpServer->SetUsername(nsDependentCString(pUser));
- IMPORT_LOG1( "Created new SMTP server: %s\n", pServer);
+ IMPORT_LOG1("Created new SMTP server: %s\n", pServer);
}
}
}
-nsresult nsEudoraWin32::GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachmentName)
+nsresult nsEudoraWin32::GetAttachmentInfo(const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachmentName)
{
nsresult rv;
mimeType.Truncate();
nsCOMPtr <nsILocalFile> pLocalFile = do_QueryInterface(pFile, &rv);
NS_ENSURE_SUCCESS(rv, rv);
pLocalFile->InitWithNativePath(nsDependentCString(pFileName));
bool isFile = false;
bool exists = false;
- if (NS_FAILED( rv = pFile->Exists( &exists)))
- return( rv);
- if ( exists && NS_FAILED( rv = pFile->IsFile(&isFile) ) )
- return( rv);
+ if (NS_FAILED(rv = pFile->Exists(&exists)))
+ return rv;
+ if (exists && NS_FAILED(rv = pFile->IsFile(&isFile)))
+ return rv;
if (!exists || !isFile)
{
// Windows Eudora writes the full path to the attachment when the message
// is received, but doesn't update that path if the attachment directory
// changes (e.g. if email directory is moved). When operating on an
// attachment (opening, etc.) Eudora will first check the full path
// and then if the file doesn't exist there Eudora will check the
// current attachment directory for a file with the same name.
//
// Check to see if we have any better luck looking for the attachment
// in the current attachment directory.
nsCAutoString name;
pFile->GetNativeLeafName(name);
if (name.IsEmpty())
- return( NS_ERROR_FAILURE);
+ return NS_ERROR_FAILURE;
nsCOMPtr <nsIFile> altFile;
rv = m_mailImportLocation->Clone(getter_AddRefs(altFile));
NS_ENSURE_SUCCESS(rv, rv);
// For now, we'll do that using a hard coded name and location for the
// attachment directory on Windows (the default location) "attach" inside
// of the Eudora mail directory. Once settings from Eudora are imported
// better, we'll want to check where the settings say attachments are stored.
@@ -1067,41 +1059,41 @@ nsresult nsEudoraWin32::GetAttachmentInf
// Did we come up with a different path or was the original path already
// in the current attachment directory?
bool isSamePath = true;
rv = altFile->Equals(pFile, &isSamePath);
if (NS_SUCCEEDED(rv) && !isSamePath)
{
// We came up with a different path - check the new path.
- if (NS_FAILED( rv = altFile->Exists( &exists)))
- return( rv);
- if ( exists && NS_FAILED( rv = altFile->IsFile( &isFile) ) )
- return( rv);
+ if (NS_FAILED(rv = altFile->Exists(&exists)))
+ return rv;
+ if (exists && NS_FAILED(rv = altFile->IsFile(&isFile)))
+ return rv;
// Keep the new path if it helped us.
if (exists && isFile)
{
nsCString nativePath;
altFile->GetNativePath(nativePath);
pLocalFile->InitWithNativePath(nativePath);
}
}
}
if (exists && isFile)
{
nsCAutoString name;
pFile->GetNativeLeafName(name);
if (name.IsEmpty())
- return( NS_ERROR_FAILURE);
+ return NS_ERROR_FAILURE;
if (name.Length() > 4)
{
nsCString ext;
- PRInt32 idx = name.RFindChar( '.');
+ PRInt32 idx = name.RFindChar('.');
if (idx != -1)
{
ext = Substring(name, idx);
GetMimeTypeFromExtension(ext, mimeType);
}
}
if (mimeType.IsEmpty())
mimeType = "application/octet-stream";
@@ -1109,23 +1101,23 @@ nsresult nsEudoraWin32::GetAttachmentInf
nsAutoString description;
rv = NS_CopyNativeToUnicode(name, description);
if (NS_SUCCEEDED(rv))
aAttachmentName = NS_ConvertUTF16toUTF8(description);
else
aAttachmentName = name;
- return( NS_OK);
+ return NS_OK;
}
- return( NS_ERROR_FAILURE);
+ return NS_ERROR_FAILURE;
}
-bool nsEudoraWin32::FindMimeIniFile( nsIFile *pFile)
+bool nsEudoraWin32::FindMimeIniFile(nsIFile *pFile)
{
bool hasMore;
nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
nsresult rv = pFile->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsILocalFile> pLocalFile = do_QueryInterface(pFile, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@@ -1142,74 +1134,74 @@ bool nsEudoraWin32::FindMimeIniFile( nsI
while (hasMore && NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> aSupport;
rv = directoryEnumerator->GetNext(getter_AddRefs(aSupport));
nsCOMPtr<nsILocalFile> entry(do_QueryInterface(aSupport, &rv));
directoryEnumerator->HasMoreElements(&hasMore);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
rv = entry->GetNativeLeafName(fName);
- if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
+ if (NS_SUCCEEDED(rv) && !fName.IsEmpty())
{
if (fName.Length() > 4)
{
ext = StringTail(fName, 4);
name = StringHead(fName, fName.Length() - 4);
}
else
{
ext.Truncate();
name = fName;
}
ToLowerCase(ext);
if (ext.EqualsLiteral(".ini"))
{
isFile = false;
- entry->IsFile( &isFile);
+ entry->IsFile(&isFile);
if (isFile)
{
if (found)
{
// which one of these files is newer?
PRInt64 modDate1, modDate2;
- entry->GetLastModifiedTime( &modDate2);
- pFile->GetLastModifiedTime( &modDate1);
+ entry->GetLastModifiedTime(&modDate2);
+ pFile->GetLastModifiedTime(&modDate1);
if (modDate2 > modDate1)
- pLocalFile->InitWithFile( entry);
+ pLocalFile->InitWithFile(entry);
}
else
{
- pLocalFile->InitWithFile( entry);
+ pLocalFile->InitWithFile(entry);
found = true;
}
}
}
}
}
}
return found;
}
-void nsEudoraWin32::GetMimeTypeFromExtension( nsCString& ext, nsCString& mimeType)
+void nsEudoraWin32::GetMimeTypeFromExtension(nsCString& ext, nsCString& mimeType)
{
HKEY sKey;
- if (::RegOpenKeyEx( HKEY_CLASSES_ROOT, ext.get(), 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS)
+ if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, ext.get(), 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS)
{
// get the value of "Current"
- BYTE *pBytes = GetValueBytes( sKey, "Content Type");
+ BYTE *pBytes = GetValueBytes(sKey, "Content Type");
if (pBytes)
{
mimeType = (const char *)pBytes;
delete [] pBytes;
}
- ::RegCloseKey( sKey);
+ ::RegCloseKey(sKey);
}
if (!mimeType.IsEmpty() || !m_mailImportLocation || (ext.Length() > 10))
return;
// TLR: FIXME: We should/could cache the extension to mime type maps we find
// and check the cache first before scanning all of eudora's mappings?
@@ -1221,49 +1213,49 @@ void nsEudoraWin32::GetMimeTypeFromExten
if (!pFile)
return;
pFile->InitWithFile(m_mailImportLocation);
pFile->AppendNative(NS_LITERAL_CSTRING("eudora.ini"));
bool exists = false;
bool isFile = false;
- nsresult rv = pFile->Exists( &exists);
- if (NS_SUCCEEDED( rv))
- rv = pFile->IsFile( &isFile);
+ nsresult rv = pFile->Exists(&exists);
+ if (NS_SUCCEEDED(rv))
+ rv = pFile->IsFile(&isFile);
if (!isFile || !exists)
{
- rv = pFile->InitWithFile( m_mailImportLocation);
- if (NS_FAILED( rv))
+ rv = pFile->InitWithFile(m_mailImportLocation);
+ if (NS_FAILED(rv))
return;
- if (!FindMimeIniFile( pFile))
+ if (!FindMimeIniFile(pFile))
return;
}
nsCAutoString fileName;
pFile->GetNativePath(fileName);
if (fileName.IsEmpty())
return;
// Read the mime map section
DWORD size = 1024;
DWORD dSize = size - 2;
while (dSize == (size - 2))
{
if (m_pMimeSection)
delete [] m_pMimeSection;
size += 1024;
m_pMimeSection = new char[size];
- dSize = ::GetPrivateProfileSection( "Mappings", m_pMimeSection, size, fileName.get());
+ dSize = ::GetPrivateProfileSection("Mappings", m_pMimeSection, size, fileName.get());
}
}
if (!m_pMimeSection)
return;
- IMPORT_LOG1( "Looking for mime type for extension: %s\n", ext.get());
+ IMPORT_LOG1("Looking for mime type for extension: %s\n", ext.get());
// out/in/both=extension,mac creator,mac type,mime type1,mime type2
const char *pExt = ext.get();
pExt++;
char * pChar = m_pMimeSection;
char * pStart;
int len;
@@ -1284,19 +1276,19 @@ void nsEudoraWin32::GetMimeTypeFromExten
{
pChar++;
len++;
}
if (!*pChar)
return;
tStr.Truncate();
- tStr.Append( pStart, len);
- tStr.Trim( kWhitespace);
- if (!PL_strcasecmp( tStr.get(), pExt))
+ tStr.Append(pStart, len);
+ tStr.Trim(kWhitespace);
+ if (!PL_strcasecmp(tStr.get(), pExt))
{
// skip the mac creator and type
pChar++;
while (*pChar && (*pChar != ','))
pChar++;
if (!*pChar)
return;
@@ -1318,79 +1310,79 @@ void nsEudoraWin32::GetMimeTypeFromExten
if (!*pChar)
return;
pChar++;
if (!len)
continue;
tStr.Truncate();
- tStr.Append( pStart, len);
- tStr.Trim( kWhitespace);
+ tStr.Append(pStart, len);
+ tStr.Trim(kWhitespace);
if (tStr.IsEmpty())
continue;
mimeType.Truncate();
- mimeType.Append( tStr.get());
- mimeType.Append( "/");
+ mimeType.Append(tStr.get());
+ mimeType.Append("/");
pStart = pChar;
len = 0;
// Skip to next end of line.
while (*pChar && (*pChar != nsCRT::CR) && (*pChar != nsCRT::LF))
{
pChar++;
len++;
}
if (!len)
continue;
tStr.Truncate();
- tStr.Append( pStart, len);
- tStr.Trim( kWhitespace);
+ tStr.Append(pStart, len);
+ tStr.Trim(kWhitespace);
if (tStr.IsEmpty())
continue;
- mimeType.Append( tStr.get());
+ mimeType.Append(tStr.get());
- IMPORT_LOG1( "Found Mime Type: %s\n", mimeType.get());
+ IMPORT_LOG1("Found Mime Type: %s\n", mimeType.get());
return;
}
}
}
-bool nsEudoraWin32::FindAddressFolder( nsIFile **pFolder)
+bool nsEudoraWin32::FindAddressFolder(nsIFile **pFolder)
{
- IMPORT_LOG0( "*** Looking for Eudora address folder\n");
+ IMPORT_LOG0("*** Looking for Eudora address folder\n");
- return( FindEudoraLocation( pFolder));
+ return FindEudoraLocation(pFolder);
}
-nsresult nsEudoraWin32::FindAddressBooks( nsIFile *pRoot, nsISupportsArray **ppArray)
+nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray)
{
nsresult rv;
nsCOMPtr<nsILocalFile> file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILocalFile> localRoot = do_QueryInterface(pRoot);
- rv = file->InitWithFile( localRoot);
+ rv = file->InitWithFile(localRoot);
NS_ENSURE_SUCCESS(rv, rv);
- rv = NS_NewISupportsArray( ppArray);
- if (NS_FAILED( rv))
+ rv = NS_NewISupportsArray(ppArray);
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
- return( 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);
+ if (NS_FAILED(rv))
+ return rv;
m_addressImportFolder = pRoot;
nsString displayName;
- nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NICKNAMES_NAME, displayName);
+ nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_NICKNAMES_NAME, displayName);
// First off, get the default nndbase.txt, then scan the default nicknames subdir,
// then look in the .ini file for additional directories to scan for address books!
bool exists = false;
bool isFile = false;
rv = file->AppendNative(NS_LITERAL_CSTRING("nndbase.txt"));
bool checkedBoth = false;
@@ -1409,119 +1401,119 @@ nsresult nsEudoraWin32::FindAddressBooks
// Check for alternate file extension ".nnt" which Windows Eudora uses as an option
// to hide from simple minded viruses that scan ".txt" files for addresses.
rv = file->SetNativeLeafName(NS_LITERAL_CSTRING("nndbase.nnt"));
checkedBoth = true;
} while (NS_SUCCEEDED(rv));
if (exists && isFile)
{
- if (NS_FAILED( rv = FoundAddressBook( file, displayName.get(), *ppArray, impSvc)))
- return( rv);
+ if (NS_FAILED(rv = FoundAddressBook(file, displayName.get(), *ppArray, impSvc)))
+ return rv;
}
// Try the default directory
- rv = rv = file->InitWithFile( localRoot);
- if (NS_FAILED( rv))
- return( rv);
+ rv = rv = file->InitWithFile(localRoot);
+ if (NS_FAILED(rv))
+ return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING("Nickname"));
bool isDir = false;
exists = false;
- if (NS_SUCCEEDED( rv))
- rv = file->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = file->IsDirectory( &isDir);
+ if (NS_SUCCEEDED(rv))
+ rv = file->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = file->IsDirectory(&isDir);
if (exists && isDir)
{
- if (NS_FAILED( rv = ScanAddressDir(file, *ppArray, impSvc)))
- return( rv);
+ if (NS_FAILED(rv = ScanAddressDir(file, *ppArray, impSvc)))
+ return rv;
}
// Try the ini file to find other directories!
- rv = rv = file->InitWithFile( localRoot);
- if (NS_FAILED( rv))
- return( rv);
+ rv = rv = file->InitWithFile(localRoot);
+ if (NS_FAILED(rv))
+ return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING("eudora.ini"));
exists = false;
isFile = false;
- if (NS_SUCCEEDED( rv))
- rv = file->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = file->IsFile( &isFile);
+ if (NS_SUCCEEDED(rv))
+ rv = file->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = file->IsFile(&isFile);
if (!isFile || !exists)
{
- rv = file->InitWithFile( localRoot);
- if (NS_FAILED( rv))
- return( NS_OK);
+ rv = file->InitWithFile(localRoot);
+ if (NS_FAILED(rv))
+ return NS_OK;
if (!FindMimeIniFile(file))
- return( NS_OK);
+ return NS_OK;
}
nsCString fileName;
file->GetNativePath(fileName);
// This is the supposed ini file name!
// Get the extra directories for nicknames and parse it for valid nickname directories
// to look into...
char *pBuffer = new char[2048];
- DWORD len = ::GetPrivateProfileString( "Settings", "ExtraNicknameDirs", "", pBuffer, 2048, fileName.get());
+ DWORD len = ::GetPrivateProfileString("Settings", "ExtraNicknameDirs", "", pBuffer, 2048, fileName.get());
if (len == 2047)
{
// If the value is really that large then don't bother!
delete [] pBuffer;
- return( NS_OK);
+ return NS_OK;
}
nsCString dirs(pBuffer);
delete [] pBuffer;
- dirs.Trim( kWhitespace);
+ dirs.Trim(kWhitespace);
PRInt32 idx = 0;
nsCString currentDir;
- while ((idx = dirs.FindChar( ';')) != -1)
+ while ((idx = dirs.FindChar(';')) != -1)
{
currentDir = StringHead(dirs, idx);
- currentDir.Trim( kWhitespace);
+ currentDir.Trim(kWhitespace);
if (!currentDir.IsEmpty())
{
rv = file->InitWithNativePath(currentDir);
exists = false;
isDir = false;
- if (NS_SUCCEEDED( rv))
- rv = file->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = file->IsDirectory( &isDir);
+ if (NS_SUCCEEDED(rv))
+ rv = file->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = file->IsDirectory(&isDir);
if (exists && isDir)
{
- if (NS_FAILED( rv = ScanAddressDir(file, *ppArray, impSvc)))
- return( rv);
+ if (NS_FAILED(rv = ScanAddressDir(file, *ppArray, impSvc)))
+ return rv;
}
}
dirs = Substring(dirs, idx + 1);
- dirs.Trim( kWhitespace);
+ dirs.Trim(kWhitespace);
}
if (!dirs.IsEmpty())
{
rv = file->InitWithNativePath(dirs);
exists = false;
isDir = false;
- if (NS_SUCCEEDED( rv))
- rv = file->Exists( &exists);
- if (NS_SUCCEEDED( rv) && exists)
- rv = file->IsDirectory( &isDir);
+ if (NS_SUCCEEDED(rv))
+ rv = file->Exists(&exists);
+ if (NS_SUCCEEDED(rv) && exists)
+ rv = file->IsDirectory(&isDir);
if (exists && isDir)
{
- if (NS_FAILED( rv = ScanAddressDir(file, *ppArray, impSvc)))
- return( rv);
+ if (NS_FAILED(rv = ScanAddressDir(file, *ppArray, impSvc)))
+ return rv;
}
}
- return( NS_OK);
+ return NS_OK;
}
-nsresult nsEudoraWin32::ScanAddressDir( nsIFile *pDir, nsISupportsArray *pArray, nsIImportService *impSvc)
+nsresult nsEudoraWin32::ScanAddressDir(nsIFile *pDir, nsISupportsArray *pArray, nsIImportService *impSvc)
{
bool hasMore;
nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
nsresult rv = pDir->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsILocalFile> pLocalFile = do_QueryInterface(pDir, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@@ -1537,134 +1529,134 @@ nsresult nsEudoraWin32::ScanAddressDir(
while (hasMore && NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> aSupport;
rv = directoryEnumerator->GetNext(getter_AddRefs(aSupport));
nsCOMPtr<nsILocalFile> entry(do_QueryInterface(aSupport, &rv));
directoryEnumerator->HasMoreElements(&hasMore);
- if (NS_SUCCEEDED( rv))
+ if (NS_SUCCEEDED(rv))
{
rv = entry->GetNativeLeafName(fName);
- if (NS_SUCCEEDED( rv) && !fName.IsEmpty())
+ if (NS_SUCCEEDED(rv) && !fName.IsEmpty())
{
if (fName.Length() > 4)
{
ext = StringTail(fName, 4);
name = StringHead(fName, fName.Length() - 4);
}
else
{
ext.Truncate();
name = fName;
}
ToLowerCase(ext);
if (ext.EqualsLiteral(".txt"))
{
isFile = false;
- entry->IsFile( &isFile);
+ entry->IsFile(&isFile);
if (isFile)
{
- rv = FoundAddressBook( entry, nsnull, pArray, impSvc);
- if (NS_FAILED( rv))
- return( rv);
+ rv = FoundAddressBook(entry, nsnull, pArray, impSvc);
+ if (NS_FAILED(rv))
+ return rv;
}
}
}
}
}
- return( rv);
+ return rv;
}
-nsresult nsEudoraWin32::FoundAddressBook( nsIFile *file, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc)
+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 (NS_FAILED(rv))
+ return rv;
if (leaf.IsEmpty())
- return( NS_ERROR_FAILURE);
+ return NS_ERROR_FAILURE;
nsString tStr;
tStr = StringTail(leaf, 4);
if (tStr.LowerCaseEqualsLiteral(".txt") || tStr.LowerCaseEqualsLiteral(".nnt"))
leaf.SetLength(leaf.Length() - 4);
}
nsCOMPtr<nsILocalFile> fileLoc = do_QueryInterface(file, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc));
- if (NS_SUCCEEDED( rv))
+ rv = impSvc->CreateNewABDescriptor(getter_AddRefs(desc));
+ if (NS_SUCCEEDED(rv))
{
PRInt64 sz = 0;
- file->GetFileSize( &sz);
+ file->GetFileSize(&sz);
desc->SetPreferredName(name);
desc->SetSize((PRUint32) sz);
desc->SetAbFile(fileLoc);
- rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
- pArray->AppendElement( pInterface);
+ rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface);
+ pArray->AppendElement(pInterface);
pInterface->Release();
}
- if (NS_FAILED( rv))
+ if (NS_FAILED(rv))
{
- IMPORT_LOG0( "*** Error creating address book descriptor for eudora\n");
- return( rv);
+ IMPORT_LOG0("*** Error creating address book descriptor for eudora\n");
+ return rv;
}
- return( NS_OK);
+ return NS_OK;
}
-void nsEudoraWin32::ConvertPath( nsCString& str)
+void nsEudoraWin32::ConvertPath(nsCString& str)
{
nsCString temp;
nsCString path;
PRInt32 idx = 0;
PRInt32 start = 0;
nsCString search;
- idx = str.FindChar( '\\', idx);
- if ((idx == 2) && (str.CharAt( 1) == ':'))
+ idx = str.FindChar('\\', idx);
+ if ((idx == 2) && (str.CharAt(1) == ':'))
{
path = StringHead(str, 3);
idx++;
- idx = str.FindChar( '\\', idx);
+ idx = str.FindChar('\\', idx);
start = 3;
if ((idx == -1) && (str.Length() > 3))
path.Append(Substring(str, start));
}
WIN32_FIND_DATA findFileData;
while (idx != -1)
{
search = path;
search.Append(Substring(str, start, idx - start));
- HANDLE h = FindFirstFile( search.get(), &findFileData);
+ HANDLE h = FindFirstFile(search.get(), &findFileData);
if (h == INVALID_HANDLE_VALUE)
return;
- path.Append( findFileData.cFileName);
+ path.Append(findFileData.cFileName);
idx++;
start = idx;
- idx = str.FindChar( '\\', idx);
- FindClose( h);
+ idx = str.FindChar('\\', idx);
+ FindClose(h);
if (idx != -1)
- path.Append( '\\');
+ path.Append('\\');
else
{
- path.Append( '\\');
+ path.Append('\\');
path.Append(Substring(str, start));
}
}
str = path;
}
--- a/mailnews/import/eudora/src/nsEudoraWin32.h
+++ b/mailnews/import/eudora/src/nsEudoraWin32.h
@@ -55,64 +55,64 @@ class nsIMsgAccount;
class nsEudoraWin32 : public nsEudoraMailbox, public nsEudoraAddress {
public:
nsEudoraWin32();
~nsEudoraWin32();
// retrieve the mail folder
- virtual bool FindMailFolder( nsIFile **pFolder);
+ virtual bool FindMailFolder(nsIFile **pFolder);
// get the list of mailboxes
- virtual nsresult FindMailboxes( nsIFile *pRoot, nsISupportsArray **ppArray);
+ virtual nsresult FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray);
// get a TOC file from a mailbox file
- virtual nsresult FindTOCFile( nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc);
+ virtual nsresult FindTOCFile(nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc);
- virtual nsresult GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment);
+ virtual nsresult GetAttachmentInfo(const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment);
// Things that must be overridden because they are platform specific.
// retrieve the address book folder
- virtual bool FindAddressFolder( nsIFile **pFolder);
+ virtual bool FindAddressFolder(nsIFile **pFolder);
// get the list of address books
- virtual nsresult FindAddressBooks( nsIFile *pRoot, nsISupportsArray **ppArray);
+ virtual nsresult FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray);
// import settings from Win32 ini file
- static bool ImportSettings( nsIFile *pIniFile, nsIMsgAccount **localMailAccount);
- static bool FindSettingsFile( nsIFile **pIniFile) { return( FindEudoraLocation( pIniFile, true));}
+ static bool ImportSettings(nsIFile *pIniFile, nsIMsgAccount **localMailAccount);
+ static bool FindSettingsFile(nsIFile **pIniFile) { return FindEudoraLocation(pIniFile, true);}
- static bool FindFiltersFile( nsIFile **pFiltersFile);
+ static bool FindFiltersFile(nsIFile **pFiltersFile);
- static bool GetMailboxNameHierarchy( const nsACString& pEudoraLocation, const char* pEudoraFilePath, nsCString& nameHierarchy);
+ static bool GetMailboxNameHierarchy(const nsACString& pEudoraLocation, const char* pEudoraFilePath, nsCString& nameHierarchy);
private:
- nsresult ScanMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
- nsresult IterateMailDir( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
- nsresult ScanDescmap( nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len);
- nsresult FoundMailFolder( nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
- nsresult FoundMailbox( nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
- bool FindMimeIniFile( nsIFile *pFile);
- void GetMimeTypeFromExtension( nsCString& ext, nsCString& mimeType);
- nsresult FoundAddressBook( nsIFile *file, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc);
- nsresult ScanAddressDir( nsIFile *pDir, nsISupportsArray *pArray, nsIImportService *impSvc);
+ nsresult ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
+ nsresult IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
+ nsresult ScanDescmap(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len);
+ nsresult FoundMailFolder(nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
+ nsresult FoundMailbox(nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
+ bool FindMimeIniFile(nsIFile *pFile);
+ void GetMimeTypeFromExtension(nsCString& ext, nsCString& mimeType);
+ nsresult FoundAddressBook(nsIFile *file, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc);
+ nsresult ScanAddressDir(nsIFile *pDir, nsISupportsArray *pArray, nsIImportService *impSvc);
- static bool FindEudoraLocation( nsIFile **pFolder, bool findIni = false);
+ static bool FindEudoraLocation(nsIFile **pFolder, bool findIni = false);
// Settings support
- static bool BuildPOPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
- static bool BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
- static void GetServerAndUserName( const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff);
- static void GetAccountName( const char *pSection, nsString& str);
- static void SetIdentities( nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff);
- static void SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser);
+ static bool BuildPOPAccount(nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
+ static bool BuildIMAPAccount(nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
+ static void GetServerAndUserName(const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff);
+ static void GetAccountName(const char *pSection, nsString& str);
+ static void SetIdentities(nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff);
+ static void SetSmtpServer(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser);
- static BYTE * GetValueBytes( HKEY hKey, const char *pValueName);
- static void ConvertPath( nsCString& str);
+ static BYTE * GetValueBytes(HKEY hKey, const char *pValueName);
+ static void ConvertPath(nsCString& str);
private:
PRUint32 m_depth;
nsCOMPtr <nsIFile> m_addressImportFolder;
char * m_pMimeSection;
};
--- a/mailnews/import/oexpress/WabObject.cpp
+++ b/mailnews/import/oexpress/WabObject.cpp
@@ -130,17 +130,17 @@ CWAB::CWAB(nsILocalFile *file)
*szWABDllPath = '\0';
// First we look under the default WAB DLL path location in the
// Registry.
// WAB_DLL_PATH_KEY is defined in wabapi.h
//
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, WAB_DLL_PATH_KEY, 0, KEY_READ, &hKey)) {
- RegQueryValueEx( hKey, "", NULL, &dwType, (LPBYTE) szWABDllPath, &cbData);
+ RegQueryValueEx(hKey, "", NULL, &dwType, (LPBYTE) szWABDllPath, &cbData);
if (dwType == REG_EXPAND_SZ) {
// Expand the environment variables
DWORD bufferSize = ExpandEnvironmentStrings(szWABDllPath, NULL, 0);
if (bufferSize && bufferSize < MAX_PATH) {
TCHAR tmp[MAX_PATH];
ExpandEnvironmentStrings(szWABDllPath, tmp, bufferSize);
_tcscpy(szWABDllPath, tmp);
}
@@ -162,17 +162,17 @@ CWAB::CWAB(nsILocalFile *file)
}
}
if(hKey) RegCloseKey(hKey);
// if the Registry came up blank, we do a loadlibrary on the wab32.dll
// WAB_DLL_NAME is defined in wabapi.h
//
- m_hinstWAB = LoadLibrary( (lstrlen(szWABDllPath)) ? szWABDllPath : WAB_DLL_NAME );
+ m_hinstWAB = LoadLibrary((lstrlen(szWABDllPath)) ? szWABDllPath : WAB_DLL_NAME);
}
if(m_hinstWAB)
{
// if we loaded the dll, get the entry point
//
m_lpfnWABOpen = (LPWABOPEN) GetProcAddress(m_hinstWAB, "WABOpen");
@@ -223,17 +223,17 @@ CWAB::~CWAB()
FreeLibrary(m_hinstWAB);
}
}
HRESULT CWAB::IterateWABContents(CWabIterator *pIter, int *pDone)
{
if (!m_bInitialized || !m_lpAdrBook)
- return( E_FAIL);
+ return E_FAIL;
ULONG ulObjType = 0;
LPMAPITABLE lpAB = NULL;
ULONG cRows = 0;
LPSRowSet lpRowAB = NULL;
LPABCONT lpContainer = NULL;
int cNumRows = 0;
nsresult keepGoing;
@@ -244,19 +244,19 @@ HRESULT CWAB::IterateWABContents(CWabIte
LPENTRYID lpEID = NULL;
ULONG rowCount = 0;
ULONG curCount = 0;
nsString uniStr;
// Get the entryid of the root PAB container
//
- hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID);
+ hr = m_lpAdrBook->GetPAB(&lpcbEID, &lpEID);
- if (HR_FAILED( hr))
+ if (HR_FAILED(hr))
goto exit;
ulObjType = 0;
// Open the root PAB container
// This is where all the WAB contents reside
//
hr = m_lpAdrBook->OpenEntry(lpcbEID,
@@ -271,43 +271,42 @@ HRESULT CWAB::IterateWABContents(CWabIte
lpEID = NULL;
if(HR_FAILED(hr))
goto exit;
// Get a contents table of all the contents in the
// WABs root container
//
- hr = lpContainer->GetContentsTable( 0,
- &lpAB);
+ hr = lpContainer->GetContentsTable(0, &lpAB);
if(HR_FAILED(hr))
goto exit;
- hr = lpAB->GetRowCount( 0, &rowCount);
+ hr = lpAB->GetRowCount(0, &rowCount);
if (HR_FAILED(hr))
rowCount = 100;
if (rowCount == 0)
rowCount = 1;
// Order the columns in the ContentsTable to conform to the
// ones we want - which are mainly DisplayName, EntryID and
// ObjectType
// The table is gauranteed to set the columns in the order
// requested
//
- hr =lpAB->SetColumns( (LPSPropTagArray)&ptaEid, 0 );
+ hr =lpAB->SetColumns((LPSPropTagArray)&ptaEid, 0);
if(HR_FAILED(hr))
goto exit;
// Reset to the beginning of the table
//
- hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL );
+ hr = lpAB->SeekRow(BOOKMARK_BEGINNING, 0, NULL);
if(HR_FAILED(hr))
goto exit;
// Read all the rows of the table one by one
//
do {
@@ -333,33 +332,33 @@ HRESULT CWAB::IterateWABContents(CWabIte
// objects
//
if(lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER)
{
// We will now take the entry-id of each object and cache it
// on the listview item representing that object. This enables
// us to uniquely identify the object later if we need to
//
- CStrToUnicode( lpsz, uniStr);
- keepGoing = pIter->EnumUser( uniStr.get(), lpEID, cbEID);
+ CStrToUnicode(lpsz, uniStr);
+ keepGoing = pIter->EnumUser(uniStr.get(), lpEID, cbEID);
curCount++;
if (pDone) {
*pDone = (curCount * 100) / rowCount;
if (*pDone > 100)
*pDone = 100;
}
}
}
- FreeProws(lpRowAB );
+ FreeProws(lpRowAB);
}
- } while ( SUCCEEDED(hr) && cNumRows && lpRowAB && NS_SUCCEEDED(keepGoing) ) ;
+ } while (SUCCEEDED(hr) && cNumRows && lpRowAB && NS_SUCCEEDED(keepGoing)) ;
- hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL );
+ hr = lpAB->SeekRow(BOOKMARK_BEGINNING, 0, NULL);
if(HR_FAILED(hr))
goto exit;
// Read all the rows of the table one by one
//
keepGoing = TRUE;
do {
@@ -394,59 +393,59 @@ HRESULT CWAB::IterateWABContents(CWabIte
hr = m_lpAdrBook->OpenEntry(cbEID, lpEID, NULL,
0,&ulObjType,(LPUNKNOWN *)&distListContainer);
LPMAPITABLE distListTable = NULL;
// Get a contents table of the dist list
//
- hr = distListContainer->GetContentsTable( 0, &distListTable);
+ hr = distListContainer->GetContentsTable(0, &distListTable);
if (lpAB)
{
- hr = distListTable->GetRowCount( 0, &rowCount);
+ hr = distListTable->GetRowCount(0, &rowCount);
if (HR_FAILED(hr))
rowCount = 100;
if (rowCount == 0)
rowCount = 1;
// Order the columns in the ContentsTable to conform to the
// ones we want - which are mainly DisplayName, EntryID and
// ObjectType
// The table is gauranteed to set the columns in the order
// requested
//
- hr = distListTable->SetColumns( (LPSPropTagArray)&ptaEid, 0 );
- CStrToUnicode( lpsz, uniStr);
- keepGoing = pIter->EnumList( uniStr.get(), lpEID, cbEID, distListTable);
+ hr = distListTable->SetColumns((LPSPropTagArray)&ptaEid, 0);
+ CStrToUnicode(lpsz, uniStr);
+ keepGoing = pIter->EnumList(uniStr.get(), lpEID, cbEID, distListTable);
curCount++;
if (pDone) {
*pDone = (curCount * 100) / rowCount;
if (*pDone > 100)
*pDone = 100;
}
}
if (distListContainer)
distListContainer->Release();
if (distListTable)
distListTable->Release();
}
}
- FreeProws(lpRowAB );
+ FreeProws(lpRowAB);
}
- } while ( SUCCEEDED(hr) && cNumRows && lpRowAB && NS_SUCCEEDED(keepGoing) ) ;
+ } while (SUCCEEDED(hr) && cNumRows && lpRowAB && NS_SUCCEEDED(keepGoing)) ;
exit:
- if ( lpContainer )
+ if (lpContainer)
lpContainer->Release();
- if ( lpAB )
+ if (lpAB)
lpAB->Release();
return hr;
}
@@ -458,176 +457,174 @@ void CWAB::FreeProws(LPSRowSet prows)
if (!prows)
return;
for (irow = 0; irow < prows->cRows; ++irow)
m_lpWABObject->FreeBuffer(prows->aRow[irow].lpProps);
m_lpWABObject->FreeBuffer(prows);
}
-LPDISTLIST CWAB::GetDistList( ULONG cbEid, LPENTRYID pEid)
+LPDISTLIST CWAB::GetDistList(ULONG cbEid, LPENTRYID pEid)
{
if (!m_bInitialized || !m_lpAdrBook)
- return( NULL);
+ return NULL;
LPDISTLIST lpDistList = NULL;
ULONG ulObjType;
- m_lpAdrBook->OpenEntry( cbEid, pEid, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpDistList);
- return( lpDistList);
+ m_lpAdrBook->OpenEntry(cbEid, pEid, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpDistList);
+ return lpDistList;
}
-LPSPropValue CWAB::GetListProperty( LPDISTLIST pUser, ULONG tag)
+LPSPropValue CWAB::GetListProperty(LPDISTLIST pUser, ULONG tag)
{
if (!pUser)
- return( NULL);
+ return NULL;
- int sz = CbNewSPropTagArray( 1);
+ int sz = CbNewSPropTagArray(1);
SPropTagArray *pTag = (SPropTagArray *) new char[sz];
pTag->cValues = 1;
pTag->aulPropTag[0] = tag;
LPSPropValue lpProp = NULL;
ULONG cValues = 0;
- HRESULT hr = pUser->GetProps( pTag, 0, &cValues, &lpProp);
+ HRESULT hr = pUser->GetProps(pTag, 0, &cValues, &lpProp);
delete [] pTag;
- if (HR_FAILED( hr) || (cValues != 1)) {
+ if (HR_FAILED(hr) || (cValues != 1)) {
if (lpProp)
- m_lpWABObject->FreeBuffer( lpProp);
- return( NULL);
+ m_lpWABObject->FreeBuffer(lpProp);
+ return NULL;
}
- return( lpProp);
+ return lpProp;
}
-LPMAILUSER CWAB::GetUser( ULONG cbEid, LPENTRYID pEid)
+LPMAILUSER CWAB::GetUser(ULONG cbEid, LPENTRYID pEid)
{
if (!m_bInitialized || !m_lpAdrBook)
- return( NULL);
+ return NULL;
LPMAILUSER lpMailUser = NULL;
ULONG ulObjType;
- m_lpAdrBook->OpenEntry( cbEid, pEid, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpMailUser);
- return( lpMailUser);
+ m_lpAdrBook->OpenEntry(cbEid, pEid, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpMailUser);
+ return lpMailUser;
}
-LPSPropValue CWAB::GetUserProperty( LPMAILUSER pUser, ULONG tag)
+LPSPropValue CWAB::GetUserProperty(LPMAILUSER pUser, ULONG tag)
{
if (!pUser)
- return( NULL);
+ return NULL;
ULONG uTag = tag;
/*
Getting Unicode does not help with getting the right
international charset. Windoze bloze.
*/
/*
- if (PROP_TYPE( uTag) == PT_STRING8) {
- uTag = CHANGE_PROP_TYPE( tag, PT_UNICODE);
+ if (PROP_TYPE(uTag) == PT_STRING8) {
+ uTag = CHANGE_PROP_TYPE(tag, PT_UNICODE);
}
*/
- int sz = CbNewSPropTagArray( 1);
+ int sz = CbNewSPropTagArray(1);
SPropTagArray *pTag = (SPropTagArray *) new char[sz];
pTag->cValues = 1;
pTag->aulPropTag[0] = uTag;
LPSPropValue lpProp = NULL;
ULONG cValues = 0;
- HRESULT hr = pUser->GetProps( pTag, 0, &cValues, &lpProp);
- if (HR_FAILED( hr) || (cValues != 1)) {
+ HRESULT hr = pUser->GetProps(pTag, 0, &cValues, &lpProp);
+ if (HR_FAILED(hr) || (cValues != 1)) {
if (lpProp)
- m_lpWABObject->FreeBuffer( lpProp);
+ m_lpWABObject->FreeBuffer(lpProp);
lpProp = NULL;
if (uTag != tag) {
pTag->cValues = 1;
pTag->aulPropTag[0] = tag;
cValues = 0;
- hr = pUser->GetProps( pTag, 0, &cValues, &lpProp);
- if (HR_FAILED( hr) || (cValues != 1)) {
+ hr = pUser->GetProps(pTag, 0, &cValues, &lpProp);
+ if (HR_FAILED(hr) || (cValues != 1)) {
if (lpProp)
- m_lpWABObject->FreeBuffer( lpProp);
+ m_lpWABObject->FreeBuffer(lpProp);
lpProp = NULL;
}
}
}
delete [] pTag;
- return( lpProp);
+ return lpProp;
}
-void CWAB::CStrToUnicode( const char *pStr, nsString& result)
+void CWAB::CStrToUnicode(const char *pStr, nsString& result)
{
result.Truncate();
- int wLen = MultiByteToWideChar( CP_ACP, 0, pStr, -1, m_pUniBuff, 0);
+ int wLen = MultiByteToWideChar(CP_ACP, 0, pStr, -1, m_pUniBuff, 0);
if (wLen >= m_uniBuffLen) {
if (m_pUniBuff)
delete [] m_pUniBuff;
m_pUniBuff = new PRUnichar[wLen + 64];
m_uniBuffLen = wLen + 64;
}
if (wLen) {
- MultiByteToWideChar( CP_ACP, 0, pStr, -1, m_pUniBuff, m_uniBuffLen);
+ MultiByteToWideChar(CP_ACP, 0, pStr, -1, m_pUniBuff, m_uniBuffLen);
result = m_pUniBuff;
}
}
// If the value is a string, get it...
-void CWAB::GetValueString( LPSPropValue pVal, nsString& val)
+void CWAB::GetValueString(LPSPropValue pVal, nsString& val)
{
val.Truncate();
if (!pVal)
return;
- switch( PROP_TYPE( pVal->ulPropTag)) {
- case PT_STRING8: {
- CStrToUnicode( (const char *) (pVal->Value.lpszA), val);
- }
- break;
+ switch(PROP_TYPE(pVal->ulPropTag)) {
+ case PT_STRING8:
+ CStrToUnicode((const char *) (pVal->Value.lpszA), val);
+ break;
case PT_UNICODE:
val = (PRUnichar *) (pVal->Value.lpszW);
- break;
+ break;
case PT_MV_STRING8: {
nsString tmp;
- ULONG j;
- for(j = 0; j < pVal->Value.MVszA.cValues; j++) {
- CStrToUnicode( (const char *) (pVal->Value.MVszA.lppszA[j]), tmp);
- val += tmp;
- val.Append(NS_ConvertASCIItoUTF16(TR_OUTPUT_EOL));
- }
- }
- break;
+ ULONG j;
+ for(j = 0; j < pVal->Value.MVszA.cValues; j++) {
+ CStrToUnicode((const char *) (pVal->Value.MVszA.lppszA[j]), tmp);
+ val += tmp;
+ val.Append(NS_ConvertASCIItoUTF16(TR_OUTPUT_EOL));
+ }
+ break;
+ }
case PT_MV_UNICODE: {
- ULONG j;
- for(j = 0; j < pVal->Value.MVszW.cValues; j++) {
- val += (PRUnichar *) (pVal->Value.MVszW.lppszW[j]);
- val.Append(NS_ConvertASCIItoUTF16(TR_OUTPUT_EOL));
- }
- }
- break;
-
+ ULONG j;
+ for(j = 0; j < pVal->Value.MVszW.cValues; j++) {
+ val += (PRUnichar *) (pVal->Value.MVszW.lppszW[j]);
+ val.Append(NS_ConvertASCIItoUTF16(TR_OUTPUT_EOL));
+ }
+ break;
+ }
case PT_I2:
case PT_LONG:
case PT_R4:
case PT_DOUBLE:
case PT_BOOLEAN: {
/*
TCHAR sz[256];
wsprintf(sz,"%d", pVal->Value.l);
val = sz;
*/
- }
- break;
+ break;
+ }
case PT_BINARY:
- break;
+ break;
default:
- break;
- }
+ break;
+ }
- val.Trim( kWhitespace, true, true);
+ val.Trim(kWhitespace, true, true);
}
void CWAB::GetValueTime(LPSPropValue pVal, PRTime& val)
{
if (!pVal)
return;
@@ -635,81 +632,81 @@ void CWAB::GetValueTime(LPSPropValue pVa
return;
nsOE5File::FileTimeToPRTime(&pVal->Value.ft, &val);
}
/*
-BOOL CWabIterateProcess::SanitizeMultiLine( CString& val)
+BOOL CWabIterateProcess::SanitizeMultiLine(CString& val)
{
val.TrimLeft();
val.TrimRight();
- int idx = val.FindOneOf( "\x0D\x0A");
+ int idx = val.FindOneOf("\x0D\x0A");
if (idx == -1)
- return( FALSE);
+ return FALSE;
// needs encoding
- U32 bufSz = UMimeEncode::GetBufferSize( val.GetLength());
+ U32 bufSz = UMimeEncode::GetBufferSize(val.GetLength());
P_U8 pBuf = new U8[bufSz];
- U32 len = UMimeEncode::ConvertBuffer( (PC_U8)((PC_S8)val), val.GetLength(), pBuf, 66, 52, "\x0D\x0A ");
+ U32 len = UMimeEncode::ConvertBuffer((PC_U8)((PC_S8)val), val.GetLength(), pBuf, 66, 52, "\x0D\x0A ");
pBuf[len] = 0;
val = pBuf;
delete pBuf;
- return( TRUE);
+ return TRUE;
}
-BOOL CWabIterateProcess::EnumUser( LPCTSTR pName, LPENTRYID pEid, ULONG cbEid)
+BOOL CWabIterateProcess::EnumUser(LPCTSTR pName, LPENTRYID pEid, ULONG cbEid)
{
- TRACE1( "User: %s\n", pName);
+ TRACE1("User: %s\n", pName);
- LPMAILUSER pUser = m_pWab->GetUser( cbEid, pEid);
+ LPMAILUSER pUser = m_pWab->GetUser(cbEid, pEid);
// Get the "required" strings first
CString lastName;
CString firstName;
CString eMail;
CString nickName;
CString middleName;
if (!pUser) {
- UDialogs::ErrMessage1( IDS_ENTRY_ERROR, pName);
- return( FALSE);
+ UDialogs::ErrMessage1(IDS_ENTRY_ERROR, pName);
+ return FALSE;
}
- LPSPropValue pProp = m_pWab->GetUserProperty( pUser, PR_EMAIL_ADDRESS);
+ LPSPropValue pProp = m_pWab->GetUserProperty(pUser, PR_EMAIL_ADDRESS);
if (pProp) {
- m_pWab->GetValueString( pProp, eMail);
- SanitizeValue( eMail);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, eMail);
+ SanitizeValue(eMail);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_GIVEN_NAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_GIVEN_NAME);
if (pProp) {
- m_pWab->GetValueString( pProp, firstName);
- SanitizeValue( firstName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, firstName);
+ SanitizeValue(firstName);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_SURNAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_SURNAME);
if (pProp) {
- m_pWab->GetValueString( pProp, lastName);
- SanitizeValue( lastName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, lastName);
+ SanitizeValue(lastName);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_MIDDLE_NAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_MIDDLE_NAME);
if (pProp) {
- m_pWab->GetValueString( pProp, middleName);
- SanitizeValue( middleName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, middleName);
+ SanitizeValue(middleName);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_NICKNAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_NICKNAME);
if (pProp) {
- m_pWab->GetValueString( pProp, nickName);
- SanitizeValue( nickName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, nickName);
+ SanitizeValue(nickName);
+ m_pWab->FreeProperty(pProp);
}
if (nickName.IsEmpty())
nickName = pName;
if (firstName.IsEmpty()) {
firstName = nickName;
middleName.Empty();
lastName.Empty();
}
@@ -724,410 +721,410 @@ BOOL CWabIterateProcess::EnumUser( LPCTS
// write them out followed by any optional fields!
BOOL result = TRUE;
if (m_recordsDone)
result = m_out.WriteEol();
CString line;
CString header;
- line.LoadString( IDS_LDIF_DN_START);
+ line.LoadString(IDS_LDIF_DN_START);
line += firstName;
if (!middleName.IsEmpty()) {
line += ' ';
line += middleName;
}
if (!lastName.IsEmpty()) {
line += ' ';
line += lastName;
}
- header.LoadString( IDS_LDIF_DN_MIDDLE);
+ header.LoadString(IDS_LDIF_DN_MIDDLE);
line += header;
line += eMail;
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
- line.LoadString( IDS_FIELD_LDIF_FULLNAME);
+ line.LoadString(IDS_FIELD_LDIF_FULLNAME);
line += ' ';
line += firstName;
if (!middleName.IsEmpty()) {
line += ' ';
line += middleName;
}
if (!lastName.IsEmpty()) {
line += ' ';
line += lastName;
}
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
- line.LoadString( IDS_FIELD_LDIF_GIVENNAME);
+ line.LoadString(IDS_FIELD_LDIF_GIVENNAME);
line += ' ';
line += firstName;
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
if (!lastName.IsEmpty()) {
- line.LoadString( IDS_FIELD_LDIF_LASTNAME);
+ line.LoadString(IDS_FIELD_LDIF_LASTNAME);
if (!middleName.IsEmpty()) {
line += ' ';
line += middleName;
}
line += ' ';
line += lastName;
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
}
- result = result && m_out.WriteStr( kLDIFPerson);
+ result = result && m_out.WriteStr(kLDIFPerson);
- line.LoadString( IDS_FIELD_LDIF_EMAIL);
+ line.LoadString(IDS_FIELD_LDIF_EMAIL);
line += ' ';
line += eMail;
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
- line.LoadString( IDS_FIELD_LDIF_NICKNAME);
+ line.LoadString(IDS_FIELD_LDIF_NICKNAME);
line += ' ';
line += nickName;
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
// Do all of the extra fields!
CString value;
BOOL encoded = FALSE;
for (int i = 0; i < kExtraUserFields; i++) {
value.Empty();
- pProp = m_pWab->GetUserProperty( pUser, extraUserFields[i].tag);
+ pProp = m_pWab->GetUserProperty(pUser, extraUserFields[i].tag);
if (pProp) {
- m_pWab->GetValueString( pProp, value);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, value);
+ m_pWab->FreeProperty(pProp);
}
if (extraUserFields[i].multiLine) {
- encoded = SanitizeMultiLine( value);
+ encoded = SanitizeMultiLine(value);
}
else
- SanitizeValue( value);
+ SanitizeValue(value);
if (!value.IsEmpty()) {
line = extraUserFields[i].pLDIF;
if (encoded) {
line += ": ";
encoded = FALSE;
}
else
line += ' ';
line += value;
- result = result && m_out.WriteStr( line);
+ result = result && m_out.WriteStr(line);
result = result && m_out.WriteEol();
}
}
- m_pWab->ReleaseUser( pUser);
+ m_pWab->ReleaseUser(pUser);
if (!result) {
- UDialogs::ErrMessage0( IDS_ADDRESS_SAVE_ERROR);
+ UDialogs::ErrMessage0(IDS_ADDRESS_SAVE_ERROR);
}
m_totalDone += kValuePerUser;
m_recordsDone++;
- return( result);
+ return result;
}
*/
/*
-BOOL CWabIterateProcess::EnumList( LPCTSTR pName, LPENTRYID pEid, ULONG cbEid)
+BOOL CWabIterateProcess::EnumList(LPCTSTR pName, LPENTRYID pEid, ULONG cbEid)
{
- TRACE1( "List: %s\n", pName);
+ TRACE1("List: %s\n", pName);
- LPDISTLIST pList = m_pWab->GetDistList( cbEid, pEid);
+ LPDISTLIST pList = m_pWab->GetDistList(cbEid, pEid);
if (!pList) {
- UDialogs::ErrMessage1( IDS_ENTRY_ERROR, pName);
- return( FALSE);
+ UDialogs::ErrMessage1(IDS_ENTRY_ERROR, pName);
+ return FALSE;
}
// Find out if this is just a regular entry or a true list...
CString eMail;
- LPSPropValue pProp = m_pWab->GetListProperty( pList, PR_EMAIL_ADDRESS);
+ LPSPropValue pProp = m_pWab->GetListProperty(pList, PR_EMAIL_ADDRESS);
if (pProp) {
- m_pWab->GetValueString( pProp, eMail);
- SanitizeValue( eMail);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, eMail);
+ SanitizeValue(eMail);
+ m_pWab->FreeProperty(pProp);
// Treat this like a regular entry...
if (!eMail.IsEmpty()) {
- m_pWab->ReleaseDistList( pList);
- return( WriteListUserEntry( pName, eMail));
+ m_pWab->ReleaseDistList(pList);
+ return WriteListUserEntry(pName, eMail);
}
}
// This may very well be a list, find the entries...
- m_pListTable = OpenDistList( pList);
+ m_pListTable = OpenDistList(pList);
if (m_pListTable) {
m_pList = pList;
m_listName = pName;
m_listDone = 0;
m_listHeaderDone = FALSE;
m_state = kEnumListState;
}
else {
- m_pWab->ReleaseDistList( pList);
+ m_pWab->ReleaseDistList(pList);
m_recordsDone++;
m_totalDone += kValuePerUser;
}
- return( TRUE);
+ return TRUE;
}
-BOOL CWabIterateProcess::EnumNextListUser( BOOL *pDone)
+BOOL CWabIterateProcess::EnumNextListUser(BOOL *pDone)
{
HRESULT hr;
int cNumRows = 0;
LPSRowSet lpRowAB = NULL;
BOOL keepGoing = TRUE;
if (!m_pListTable)
- return( FALSE);
+ return FALSE;
- hr = m_pListTable->QueryRows( 1, 0, &lpRowAB);
+ hr = m_pListTable->QueryRows(1, 0, &lpRowAB);
if(HR_FAILED(hr)) {
- UDialogs::ErrMessage0( IDS_ERROR_READING_WAB);
- return( FALSE);
+ UDialogs::ErrMessage0(IDS_ERROR_READING_WAB);
+ return FALSE;
}
if(lpRowAB) {
cNumRows = lpRowAB->cRows;
if (cNumRows) {
LPTSTR lpsz = lpRowAB->aRow[0].lpProps[ieidPR_DISPLAY_NAME].Value.lpszA;
LPENTRYID lpEID = (LPENTRYID) lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
ULONG cbEID = lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
if(lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_DISTLIST) {
- keepGoing = HandleListList( lpsz, lpEID, cbEID);
+ keepGoing = HandleListList(lpsz, lpEID, cbEID);
}
else if (lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER) {
- keepGoing = HandleListUser( lpsz, lpEID, cbEID);
+ keepGoing = HandleListUser(lpsz, lpEID, cbEID);
}
}
- m_pWab->FreeProws( lpRowAB);
+ m_pWab->FreeProws(lpRowAB);
}
if (!cNumRows || !lpRowAB) {
*pDone = TRUE;
m_pListTable->Release();
m_pListTable = NULL;
if (m_pList)
- m_pWab->ReleaseDistList( m_pList);
+ m_pWab->ReleaseDistList(m_pList);
m_pList = NULL;
if (m_listDone < kValuePerUser)
m_totalDone += (kValuePerUser - m_listDone);
m_recordsDone++;
- return( keepGoing);
+ return keepGoing;
}
if (!keepGoing)
- return( FALSE);
+ return FALSE;
if (m_listDone < kValuePerUser) {
m_listDone++;
m_totalDone++;
}
- return( TRUE);
+ return TRUE;
}
-BOOL CWabIterateProcess::HandleListList( LPCTSTR pName, LPENTRYID lpEid, ULONG cbEid)
+BOOL CWabIterateProcess::HandleListList(LPCTSTR pName, LPENTRYID lpEid, ULONG cbEid)
{
BOOL result;
- LPDISTLIST pList = m_pWab->GetDistList( cbEid, lpEid);
+ LPDISTLIST pList = m_pWab->GetDistList(cbEid, lpEid);
if (!pList) {
- UDialogs::ErrMessage1( IDS_ENTRY_ERROR, pName);
- return( FALSE);
+ UDialogs::ErrMessage1(IDS_ENTRY_ERROR, pName);
+ return FALSE;
}
CString eMail;
- LPSPropValue pProp = m_pWab->GetListProperty( pList, PR_EMAIL_ADDRESS);
+ LPSPropValue pProp = m_pWab->GetListProperty(pList, PR_EMAIL_ADDRESS);
if (pProp) {
- m_pWab->GetValueString( pProp, eMail);
- SanitizeValue( eMail);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, eMail);
+ SanitizeValue(eMail);
+ m_pWab->FreeProperty(pProp);
// Treat this like a regular entry...
if (!eMail.IsEmpty()) {
// write out a member based on pName and eMail
- result = WriteGroupMember( pName, eMail);
- m_pWab->ReleaseDistList( pList);
- return( result);
+ result = WriteGroupMember(pName, eMail);
+ m_pWab->ReleaseDistList(pList);
+ return result;
}
}
// iterate the list and add each member to the top level list
- LPMAPITABLE pTable = OpenDistList( pList);
+ LPMAPITABLE pTable = OpenDistList(pList);
if (!pTable) {
- TRACE0( "Error opening table for list\n");
- m_pWab->ReleaseDistList( pList);
- UDialogs::ErrMessage1( IDS_ENTRY_ERROR, pName);
- return( FALSE);
+ TRACE0("Error opening table for list\n");
+ m_pWab->ReleaseDistList(pList);
+ UDialogs::ErrMessage1(IDS_ENTRY_ERROR, pName);
+ return FALSE;
}
int cNumRows = 0;
LPSRowSet lpRowAB = NULL;
HRESULT hr;
BOOL keepGoing = TRUE;
do {
- hr = pTable->QueryRows( 1, 0, &lpRowAB);
+ hr = pTable->QueryRows(1, 0, &lpRowAB);
if(HR_FAILED(hr)) {
- UDialogs::ErrMessage0( IDS_ERROR_READING_WAB);
+ UDialogs::ErrMessage0(IDS_ERROR_READING_WAB);
pTable->Release();
- m_pWab->ReleaseDistList( pList);
- return( FALSE);
+ m_pWab->ReleaseDistList(pList);
+ return FALSE;
}
if(lpRowAB) {
cNumRows = lpRowAB->cRows;
if (cNumRows) {
LPTSTR lpsz = lpRowAB->aRow[0].lpProps[ieidPR_DISPLAY_NAME].Value.lpszA;
LPENTRYID lpEID = (LPENTRYID) lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
ULONG cbEID = lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
if(lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_DISTLIST) {
- keepGoing = HandleListList( lpsz, lpEID, cbEID);
+ keepGoing = HandleListList(lpsz, lpEID, cbEID);
}
else if (lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER) {
- keepGoing = HandleListUser( lpsz, lpEID, cbEID);
+ keepGoing = HandleListUser(lpsz, lpEID, cbEID);
}
}
- m_pWab->FreeProws( lpRowAB);
+ m_pWab->FreeProws(lpRowAB);
}
}
while (keepGoing && cNumRows && lpRowAB);
pTable->Release();
- m_pWab->ReleaseDistList( pList);
- return( keepGoing);
+ m_pWab->ReleaseDistList(pList);
+ return keepGoing;
}
-BOOL CWabIterateProcess::HandleListUser( LPCTSTR pName, LPENTRYID lpEid, ULONG cbEid)
+BOOL CWabIterateProcess::HandleListUser(LPCTSTR pName, LPENTRYID lpEid, ULONG cbEid)
{
// Get the basic properties for building the member line
- LPMAILUSER pUser = m_pWab->GetUser( cbEid, lpEid);
+ LPMAILUSER pUser = m_pWab->GetUser(cbEid, lpEid);
// Get the "required" strings first
CString lastName;
CString firstName;
CString eMail;
CString nickName;
CString middleName;
if (!pUser) {
- UDialogs::ErrMessage1( IDS_ENTRY_ERROR, pName);
- return( FALSE);
+ UDialogs::ErrMessage1(IDS_ENTRY_ERROR, pName);
+ return FALSE;
}
- LPSPropValue pProp = m_pWab->GetUserProperty( pUser, PR_EMAIL_ADDRESS);
+ LPSPropValue pProp = m_pWab->GetUserProperty(pUser, PR_EMAIL_ADDRESS);
if (pProp) {
- m_pWab->GetValueString( pProp, eMail);
- SanitizeValue( eMail);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, eMail);
+ SanitizeValue(eMail);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_GIVEN_NAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_GIVEN_NAME);
if (pProp) {
- m_pWab->GetValueString( pProp, firstName);
- SanitizeValue( firstName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, firstName);
+ SanitizeValue(firstName);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_SURNAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_SURNAME);
if (pProp) {
- m_pWab->GetValueString( pProp, lastName);
- SanitizeValue( lastName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, lastName);
+ SanitizeValue(lastName);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_MIDDLE_NAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_MIDDLE_NAME);
if (pProp) {
- m_pWab->GetValueString( pProp, middleName);
- SanitizeValue( middleName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, middleName);
+ SanitizeValue(middleName);
+ m_pWab->FreeProperty(pProp);
}
- pProp = m_pWab->GetUserProperty( pUser, PR_NICKNAME);
+ pProp = m_pWab->GetUserProperty(pUser, PR_NICKNAME);
if (pProp) {
- m_pWab->GetValueString( pProp, nickName);
- SanitizeValue( nickName);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, nickName);
+ SanitizeValue(nickName);
+ m_pWab->FreeProperty(pProp);
}
if (nickName.IsEmpty())
nickName = pName;
if (firstName.IsEmpty()) {
firstName = nickName;
middleName.Empty();
lastName.Empty();
}
if (lastName.IsEmpty())
middleName.Empty();
if (eMail.IsEmpty())
eMail = nickName;
- m_pWab->ReleaseUser( pUser);
+ m_pWab->ReleaseUser(pUser);
CString name = firstName;
if (!middleName.IsEmpty()) {
name += ' ';
name += middleName;
}
if (!lastName.IsEmpty()) {
name += ' ';
name += lastName;
}
- return( WriteGroupMember( name, eMail));
+ return WriteGroupMember(name, eMail);
}
-BOOL CWabIterateProcess::WriteGroupMember( const char *pName, const char *pEmail)
+BOOL CWabIterateProcess::WriteGroupMember(const char *pName, const char *pEmail)
{
CString middle;
CString line;
BOOL result;
// Check for the header first
if (!m_listHeaderDone) {
if (m_recordsDone)
result = m_out.WriteEol();
else
result = TRUE;
- line.LoadString( IDS_LDIF_DN_START);
+ line.LoadString(IDS_LDIF_DN_START);
line += m_listName;
line += TR_OUTPUT_EOL;
- middle.LoadString( IDS_FIELD_LDIF_FULLNAME);
+ middle.LoadString(IDS_FIELD_LDIF_FULLNAME);
line += middle;
line += m_listName;
line += TR_OUTPUT_EOL;
- if (!result || !m_out.WriteStr( line) || !m_out.WriteStr( kLDIFGroup)) {
- UDialogs::ErrMessage0( IDS_ADDRESS_SAVE_ERROR);
- return( FALSE);
+ if (!result || !m_out.WriteStr(line) || !m_out.WriteStr(kLDIFGroup)) {
+ UDialogs::ErrMessage0(IDS_ADDRESS_SAVE_ERROR);
+ return FALSE;
}
m_listHeaderDone = TRUE;
}
- line.LoadString( IDS_FIELD_LDIF_MEMBER_START);
+ line.LoadString(IDS_FIELD_LDIF_MEMBER_START);
line += pName;
- middle.LoadString( IDS_LDIF_DN_MIDDLE);
+ middle.LoadString(IDS_LDIF_DN_MIDDLE);
line += middle;
line += pEmail;
line += TR_OUTPUT_EOL;
- if (!m_out.WriteStr( line)) {
- UDialogs::ErrMessage0( IDS_ADDRESS_SAVE_ERROR);
- return( FALSE);
+ if (!m_out.WriteStr(line)) {
+ UDialogs::ErrMessage0(IDS_ADDRESS_SAVE_ERROR);
+ return FALSE;
}
if (m_listDone < kValuePerUser) {
m_listDone++;
m_totalDone++;
}
- return( TRUE);
+ return TRUE;
}
*/
--- a/mailnews/import/oexpress/WabObject.h
+++ b/mailnews/import/oexpress/WabObject.h
@@ -44,43 +44,43 @@
#include "nsILocalFile.h"
#include <windows.h>
#include <wab.h>
class CWabIterator {
public:
- virtual nsresult EnumUser( const PRUnichar *pName, LPENTRYID pEid, ULONG cbEid) = 0;
- virtual nsresult EnumList( const PRUnichar *pName, LPENTRYID pEid, ULONG cbEid, LPMAPITABLE lpTable) = 0;
+ virtual nsresult EnumUser(const PRUnichar *pName, LPENTRYID pEid, ULONG cbEid) = 0;
+ virtual nsresult EnumList(const PRUnichar *pName, LPENTRYID pEid, ULONG cbEid, LPMAPITABLE lpTable) = 0;
};
class CWAB
{
public:
- CWAB( nsILocalFile *fileName);
+ CWAB(nsILocalFile *fileName);
~CWAB();
- bool Loaded( void) { return( m_bInitialized);}
+ bool Loaded(void) { return m_bInitialized;}
HRESULT IterateWABContents(CWabIterator *pIter, int *pDone);
// Methods for User entries
- LPDISTLIST GetDistList( ULONG cbEid, LPENTRYID pEid);
- void ReleaseDistList( LPDISTLIST pList) { if (pList) pList->Release();}
- LPMAILUSER GetUser( ULONG cbEid, LPENTRYID pEid);
- void ReleaseUser( LPMAILUSER pUser) { if (pUser) pUser->Release();}
- LPSPropValue GetUserProperty( LPMAILUSER pUser, ULONG tag);
- LPSPropValue GetListProperty( LPDISTLIST pList, ULONG tag);
- void FreeProperty( LPSPropValue pVal) { if (pVal) m_lpWABObject->FreeBuffer( pVal);}
- void GetValueString( LPSPropValue pVal, nsString& val);
+ LPDISTLIST GetDistList(ULONG cbEid, LPENTRYID pEid);
+ void ReleaseDistList(LPDISTLIST pList) { if (pList) pList->Release();}
+ LPMAILUSER GetUser(ULONG cbEid, LPENTRYID pEid);
+ void ReleaseUser(LPMAILUSER pUser) { if (pUser) pUser->Release();}
+ LPSPropValue GetUserProperty(LPMAILUSER pUser, ULONG tag);
+ LPSPropValue GetListProperty(LPDISTLIST pList, ULONG tag);
+ void FreeProperty(LPSPropValue pVal) { if (pVal) m_lpWABObject->FreeBuffer(pVal);}
+ void GetValueString(LPSPropValue pVal, nsString& val);
void GetValueTime(LPSPropValue pVal, PRTime& val);
- void CStrToUnicode( const char *pStr, nsString& result);
+ void CStrToUnicode(const char *pStr, nsString& result);
// Utility stuff used by iterate
void FreeProws(LPSRowSet prows);
private:
PRUnichar * m_pUniBuff;
int m_uniBuffLen;
--- a/mailnews/import/oexpress/nsOE5File.cpp
+++ b/mailnews/import/oexpress/nsOE5File.cpp
@@ -59,17 +59,17 @@
#define ISWATCHED 0x400000 // 256
#define ISIGNORED 0x800000 // 262144
#define XLATFLAGS(s) (((MARKED & s) ? nsMsgMessageFlags::Marked : 0) | \
((READ & s) ? nsMsgMessageFlags::Read : 0) | \
((HASATTACHMENT & s) ? nsMsgMessageFlags::Attachment : 0) | \
((ISANSWERED & s) ? nsMsgMessageFlags::Replied : 0) | \
((ISFORWARDED & s) ? nsMsgMessageFlags::Forwarded : 0) | \
((ISWATCHED & s) ? nsMsgMessageFlags::Watched : 0) | \
- ((ISIGNORED & s) ? nsMsgMessageFlags::Ignored : 0) )
+ ((ISIGNORED & s) ? nsMsgMessageFlags::Ignored : 0))
static char *gSig =
"\xCF\xAD\x12\xFE\xC5\xFD\x74\x6F\x66\xE3\xD1\x11";
// copied from nsprpub/pr/src/{io/prfile.c | md/windows/w95io.c} :
// PR_FileTimeToPRTime and _PR_FileTimeToPRTime
void nsOE5File::FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm)
{
@@ -83,106 +83,106 @@ void nsOE5File::FileTimeToPRTime(const F
::CopyMemory(prtm, filetime, sizeof(PRTime));
#ifdef __GNUC__
*prtm = (*prtm - _pr_filetime_offset) / 10LL;
#else
*prtm = (*prtm - _pr_filetime_offset) / 10i64;
#endif
}
-bool nsOE5File::VerifyLocalMailFile( nsIFile *pFile)
+bool nsOE5File::VerifyLocalMailFile(nsIFile *pFile)
{
char sig[kSignatureSize];
nsCOMPtr <nsIInputStream> inputStream;
if (NS_FAILED(NS_NewLocalFileInputStream(getter_AddRefs(inputStream), pFile)))
return false;
- if (!ReadBytes( inputStream, sig, 0, kSignatureSize))
+ if (!ReadBytes(inputStream, sig, 0, kSignatureSize))
return false;
bool result = true;
for (int i = 0; (i < kSignatureSize) && result; i++) {
if (sig[i] != gSig[i])
result = false;
}
char storeName[14];
- if (!ReadBytes( inputStream, storeName, 0x24C1, 12))
+ if (!ReadBytes(inputStream, storeName, 0x24C1, 12))
result = false;
storeName[12] = 0;
- if (PL_strcasecmp( "LocalStore", storeName))
+ if (PL_strcasecmp("LocalStore", storeName))
result = false;
return result;
}
-bool nsOE5File::IsLocalMailFile( nsIFile *pFile)
+bool nsOE5File::IsLocalMailFile(nsIFile *pFile)
{
nsresult rv;
bool isFile = false;
- rv = pFile->IsFile( &isFile);
- if (NS_FAILED( rv) || !isFile)
- return( false);
+ rv = pFile->IsFile(&isFile);
+ if (NS_FAILED(rv) || !isFile)
+ return false;
- bool result = VerifyLocalMailFile( pFile);
+ bool result = VerifyLocalMailFile(pFile);
- return( result);
+ return result;
}
-bool nsOE5File::ReadIndex( nsIInputStream *pInputStream, PRUint32 **ppIndex, PRUint32 *pSize)
+bool nsOE5File::ReadIndex(nsIInputStream *pInputStream, PRUint32 **ppIndex, PRUint32 *pSize)
{
*ppIndex = nsnull;
*pSize = 0;
char signature[4];
- if (!ReadBytes( pInputStream, signature, 0, 4))
- return( false);
+ if (!ReadBytes(pInputStream, signature, 0, 4))
+ return 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( false);
+ IMPORT_LOG0("*** Outlook 5.0 dbx file signature doesn't match\n");
+ return false;
}
}
PRUint32 offset = 0x00e4;
PRUint32 indexStart = 0;
- if (!ReadBytes( pInputStream, &indexStart, offset, 4)) {
- IMPORT_LOG0( "*** Unable to read offset to index start\n");
- return( false);
+ if (!ReadBytes(pInputStream, &indexStart, offset, 4)) {
+ IMPORT_LOG0("*** Unable to read offset to index start\n");
+ return false;
}
PRUint32Array array;
array.count = 0;
array.alloc = kIndexGrowBy;
array.pIndex = new PRUint32[kIndexGrowBy];
- PRUint32 next = ReadMsgIndex( pInputStream, indexStart, &array);
+ PRUint32 next = ReadMsgIndex(pInputStream, indexStart, &array);
while (next) {
- next = ReadMsgIndex( pInputStream, next, &array);
+ next = ReadMsgIndex(pInputStream, next, &array);
}
if (array.count) {
*pSize = array.count;
*ppIndex = array.pIndex;
- return( true);
+ return true;
}
delete [] array.pIndex;
- return( false);
+ return false;
}
-PRUint32 nsOE5File::ReadMsgIndex( nsIInputStream *pInputStream, PRUint32 offset, PRUint32Array *pArray)
+PRUint32 nsOE5File::ReadMsgIndex(nsIInputStream *pInputStream, PRUint32 offset, PRUint32Array *pArray)
{
// Record is:
// 4 byte marker
// 4 byte unknown
// 4 byte nextSubIndex
// 4 byte (parentIndex?)
// 2 bytes unknown
// 1 byte length - # of entries in this record
@@ -190,55 +190,55 @@ PRUint32 nsOE5File::ReadMsgIndex( nsIInp
// 4 byte unknown
// length records consisting of 3 longs
// 1 - pointer to record
// 2 - child index pointer
// 3 - number of records in child
PRUint32 marker;
- if (!ReadBytes( pInputStream, &marker, offset, 4))
- return( 0);
+ if (!ReadBytes(pInputStream, &marker, offset, 4))
+ return 0;
if (marker != offset)
- return( 0);
+ return 0;
PRUint32 vals[3];
- if (!ReadBytes( pInputStream, vals, offset + 4, 12))
- return( 0);
+ if (!ReadBytes(pInputStream, vals, offset + 4, 12))
+ return 0;
PRUint8 len[4];
- if (!ReadBytes( pInputStream, len, offset + 16, 4))
- return( 0);
+ if (!ReadBytes(pInputStream, len, offset + 16, 4))
+ return 0;
PRUint32 cnt = (PRUint32) len[1];
cnt *= 3;
PRUint32 *pData = new PRUint32[cnt];
- if (!ReadBytes( pInputStream, pData, offset + 24, cnt * 4)) {
+ if (!ReadBytes(pInputStream, pData, offset + 24, cnt * 4)) {
delete [] pData;
- return( 0);
+ return 0;
}
PRUint32 next;
PRUint32 indexOffset;
PRUint32 * pRecord = pData;
PRUint32 * pNewIndex;
for (PRUint8 i = 0; i < (PRUint8)len[1]; i++, pRecord += 3) {
indexOffset = pRecord[0];
if (pArray->count >= pArray->alloc) {
pNewIndex = new PRUint32[ pArray->alloc + kIndexGrowBy];
- memcpy( pNewIndex, pArray->pIndex, (pArray->alloc * 4));
+ memcpy(pNewIndex, pArray->pIndex, (pArray->alloc * 4));
(pArray->alloc) += kIndexGrowBy;
delete [] pArray->pIndex;
pArray->pIndex = pNewIndex;
}
/*
We could do some checking here if we wanted -
make sure the index is within the file,
@@ -247,67 +247,68 @@ PRUint32 nsOE5File::ReadMsgIndex( nsIInp
pArray->pIndex[pArray->count] = indexOffset;
(pArray->count)++;
next = pRecord[1];
if (next)
- while ((next = ReadMsgIndex( pInputStream, next, pArray)) != 0);
+ while ((next = ReadMsgIndex(pInputStream, next, pArray)) != 0);
}
delete [] pData;
// return the pointer to the next subIndex
- return( vals[1]);
+ return vals[1];
}
-bool nsOE5File::IsFromLine( char *pLine, PRUint32 len)
+bool nsOE5File::IsFromLine(char *pLine, PRUint32 len)
{
return (len > 5 && (pLine[0] == 'F') && (pLine[1] == 'r') && (pLine[2] == 'o') && (pLine[3] == 'm') && (pLine[4] == ' '));
}
// Anything over 16K will be assumed BAD, BAD, BAD!
#define kMailboxBufferSize 0x4000
#define kMaxAttrCount 0x0030
const char *nsOE5File::m_pFromLineSep = "From - Mon Jan 1 00:00:00 1965\x0D\x0A";
-nsresult nsOE5File::ImportMailbox( PRUint32 *pBytesDone, bool *pAbort, nsString& name, nsIFile *inFile, nsIFile *pDestination, PRUint32 *pCount)
+nsresult nsOE5File::ImportMailbox(PRUint32 *pBytesDone, bool *pAbort, nsString& name, nsIFile *inFile, nsIFile *pDestination, PRUint32 *pCount)
{
nsresult rv;
PRInt32 msgCount = 0;
if (pCount)
*pCount = 0;
nsCOMPtr <nsIInputStream> inputStream;
rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), inFile);
- if (NS_FAILED( rv)) return( rv);
+ if (NS_FAILED(rv))
+ return rv;
nsCOMPtr <nsIOutputStream> outputStream;
rv = MsgNewBufferedFileOutputStream(getter_AddRefs(outputStream), pDestination, -1, 0600);
- if (NS_FAILED( rv))
- return( rv);
+ if (NS_FAILED(rv))
+ return rv;
PRUint32 * pIndex;
PRUint32 indexSize;
PRUint32 * pFlags;
PRUint64 * pTime;
- if (!ReadIndex( inputStream, &pIndex, &indexSize)) {
- IMPORT_LOG1( "No messages found in mailbox: %s\n", NS_LossyConvertUTF16toASCII(name.get()));
- return( NS_OK);
+ if (!ReadIndex(inputStream, &pIndex, &indexSize)) {
+ IMPORT_LOG1("No messages found in mailbox: %s\n", NS_LossyConvertUTF16toASCII(name.get()));
+ return NS_OK;
}
pTime = new PRUint64[ indexSize];
pFlags = new PRUint32[ indexSize];
char * pBuffer = new char[kMailboxBufferSize];
if (!(*pAbort))
- ConvertIndex( inputStream, pBuffer, pIndex, indexSize, pFlags, pTime);
+ ConvertIndex(inputStream, pBuffer, pIndex, indexSize, pFlags, pTime);
PRUint32 block[4];
- PRInt32 sepLen = (PRInt32) strlen( m_pFromLineSep);
+ PRInt32 sepLen = (PRInt32) strlen(m_pFromLineSep);
PRUint32 written;
/*
Each block is:
marker - matches file offset
block length
text length in block
pointer to next block. (0 if end)
@@ -332,38 +333,38 @@ nsresult nsOE5File::ImportMailbox( PRUin
nsCAutoString partialLine, tempLine;
rv = NS_OK;
for (PRUint32 i = 0; (i < indexSize) && !(*pAbort); i++)
{
if (! pIndex[i])
continue;
- if (ReadBytes( inputStream, block, pIndex[i], 16) && (block[0] == pIndex[i]) &&
- (block[2] < kMailboxBufferSize) && (ReadBytes( inputStream, pBuffer, kDontSeek, block[2])))
+ if (ReadBytes(inputStream, block, pIndex[i], 16) && (block[0] == pIndex[i]) &&
+ (block[2] < kMailboxBufferSize) && (ReadBytes(inputStream, pBuffer, kDontSeek, block[2])))
{
// block[2] contains the chars in the buffer (ie, buf content size).
// block[3] contains offset to the next block of data (0 means no more data).
size = block[2];
pStart = pBuffer;
pEnd = pStart + size;
// write out the from separator.
rv = NS_ERROR_FAILURE;
- if (IsFromLine( pBuffer, size))
+ if (IsFromLine(pBuffer, size))
{
char *pChar = pStart;
while ((pChar < pEnd) && (*pChar != '\r') && (*(pChar+1) != '\n'))
pChar++;
if (pChar < pEnd)
{
// Get the "From " line so write it out.
rv = outputStream->Write(pStart, pChar-pStart+2, &written);
- if ( rv)
+ if (rv)
// Now buffer starts from the 2nd line.
pStart = pChar + 2;
}
}
else if (pTime[i])
{
char result[156] = "";
PRExplodedTime xpldTime;
@@ -375,24 +376,24 @@ nsresult nsOE5File::ImportMailbox( PRUin
PR_ExplodeTime(prt, PR_LocalTimeParameters, &xpldTime);
PR_FormatTimeUSEnglish(buffer, sizeof(buffer),
"%a %b %d %H:%M:%S %Y",
&xpldTime);
PL_strcpy(result, "From - ");
PL_strcpy(result + 7, buffer);
PL_strcpy(result + 7 + 24, CRLF);
- rv = outputStream->Write(result, (PRInt32) strlen( result), &written);
+ rv = outputStream->Write(result, (PRInt32) strlen(result), &written);
}
- if (NS_FAILED( rv))
+ if (NS_FAILED(rv))
{
// Write out the default from line since there is none in the msg.
rv = outputStream->Write(m_pFromLineSep, sepLen, &written);
// FIXME: Do I need to check the return value of written???
- if (NS_FAILED( rv))
+ if (NS_FAILED(rv))
break;
}
char statusLine[50];
PRUint32 msgFlags = XLATFLAGS(pFlags[i]);
PR_snprintf(statusLine, sizeof(statusLine), X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, msgFlags & 0xFFFF);
rv = outputStream->Write(statusLine, strlen(statusLine), &written);
NS_ENSURE_SUCCESS(rv,rv);
@@ -402,17 +403,17 @@ nsresult nsOE5File::ImportMailbox( PRUin
do
{
partialLine.Truncate();
partialLineStart = pEnd;
// If the buffer doesn't end with CRLF then a line is broken into two blocks,
// so save the incomplete line for later process when we read the next block.
- if ( (size > 1) && !(*(pEnd - 2) == '\r' && *(pEnd - 1) == '\n') )
+ if ((size > 1) && !(*(pEnd - 2) == '\r' && *(pEnd - 1) == '\n'))
{
partialLineStart -= 2;
while ((partialLineStart >= pStart) && (*partialLineStart != '\r') && (*(partialLineStart+1) != '\n'))
partialLineStart--;
if (partialLineStart != (pEnd - 2))
partialLineStart += 2; // skip over CRLF if we find them.
partialLine.Assign(partialLineStart, pEnd - partialLineStart);
}
@@ -454,18 +455,18 @@ nsresult nsOE5File::ImportMailbox( PRUin
break;
// Adjust where data start and size (since some of the data has been processed).
size -= (pStart - pBuffer);
}
}
else
{
- IMPORT_LOG2( "Error reading message from %s at 0x%lx\n", NS_LossyConvertUTF16toASCII(name.get()), pIndex[i]);
- rv = outputStream->Write( "\x0D\x0A", 2, &written);
+ IMPORT_LOG2("Error reading message from %s at 0x%lx\n", NS_LossyConvertUTF16toASCII(name.get()), pIndex[i]);
+ rv = outputStream->Write("\x0D\x0A", 2, &written);
next = 0;
}
} while (next);
// Always end a msg with CRLF. This will make sure that OE msgs without body is
// correctly recognized as msgs. Otherwise, we'll end up with the following in
// the msg folder where the 2nd msg starts right after the headers of the 1st msg:
//
@@ -474,42 +475,42 @@ nsresult nsOE5File::ImportMailbox( PRUin
// . . . (more headers)
// To: <someone@netscape.com>
// From - Jan 1965 00:00:00 <<<--- 2nd msg starts here
// Subject: How are you
// . . .(more headers)
//
// In this case, the 1st msg is not recognized as a msg (it's skipped)
// when you open the folder.
- rv = outputStream->Write( "\x0D\x0A", 2, &written);
+ rv = outputStream->Write("\x0D\x0A", 2, &written);
if (NS_FAILED(rv))
break;
msgCount++;
if (pCount)
*pCount = msgCount;
if (pBytesDone)
*pBytesDone = didBytes;
}
else {
// Error reading message, should this be logged???
- IMPORT_LOG2( "Error reading message from %s at 0x%lx\n", NS_LossyConvertUTF16toASCII(name.get()), pIndex[i]);
+ IMPORT_LOG2("Error reading message from %s at 0x%lx\n", NS_LossyConvertUTF16toASCII(name.get()), pIndex[i]);
*pAbort = true;
}
}
delete [] pBuffer;
delete [] pFlags;
delete [] pTime;
if (NS_FAILED(rv))
*pAbort = true;
- return( rv);
+ return rv;
}
/*
A message index record consists of:
4 byte marker - matches record offset
4 bytes size - size of data after this header
2 bytes header length - not dependable
@@ -540,17 +541,17 @@ nsresult nsOE5File::ImportMailbox( PRUin
0x0D - offset to from
0x0E - offset to from addresses
0x13 - offset to to name
0x45 - offset to to address <----correct --> 0x14
0x80 - msgId <-correction-> 0x07 addr to msg id
0x84 - direct text offset, direct pointer to message text
*/
-void nsOE5File::ConvertIndex( nsIInputStream *pFile, char *pBuffer,
+void nsOE5File::ConvertIndex(nsIInputStream *pFile, char *pBuffer,
PRUint32 *pIndex, PRUint32 size,
PRUint32 *pFlags, PRUint64 *pTime)
{
// for each index record, get the actual message offset! If there is a
// problem just record the message offset as 0 and the message reading code
// can log that error information.
// XXXTODO- above error reporting is not done
@@ -566,75 +567,75 @@ void nsOE5File::ConvertIndex( nsIInputSt
PRUint32 flags;
PRUint64 time;
PRUint32 dataStart;
for (PRUint32 i = 0; i < size; i++) {
offset = 0;
flags = 0;
time = 0;
- if (ReadBytes( pFile, recordHead, pIndex[i], 12)) {
- memcpy( &marker, recordHead, 4);
- memcpy( &recordSize, recordHead + 4, 4);
+ if (ReadBytes(pFile, recordHead, pIndex[i], 12)) {
+ memcpy(&marker, recordHead, 4);
+ memcpy(&recordSize, recordHead + 4, 4);
numAttrs = (PRUint32) recordHead[10];
if (marker == pIndex[i] && numAttrs <= kMaxAttrCount) {
dataStart = pIndex[i] + 12 + (numAttrs * 4);
- if (ReadBytes( pFile, pBuffer, kDontSeek, numAttrs * 4)) {
+ if (ReadBytes(pFile, pBuffer, kDontSeek, numAttrs * 4)) {
attrOffset = 0;
for (attrIndex = 0; attrIndex < numAttrs; attrIndex++, attrOffset += 4) {
tag = (PRUint8) pBuffer[attrOffset];
if (tag == (PRUint8) 0x84) {
tagData = 0;
- memcpy( &tagData, pBuffer + attrOffset + 1, 3);
+ memcpy(&tagData, pBuffer + attrOffset + 1, 3);
offset = tagData;
}
else if (tag == (PRUint8) 0x04) {
tagData = 0;
- memcpy( &tagData, pBuffer + attrOffset + 1, 3);
+ memcpy(&tagData, pBuffer + attrOffset + 1, 3);
ReadBytes(pFile, &offset, dataStart + tagData, 4);
}
else if (tag == (PRUint8) 0x81) {
tagData = 0;
- memcpy( &tagData, pBuffer + attrOffset +1, 3);
+ memcpy(&tagData, pBuffer + attrOffset +1, 3);
flags = tagData;
}
else if (tag == (PRUint8) 0x01) {
tagData = 0;
- memcpy( &tagData, pBuffer + attrOffset +1, 3);
+ memcpy(&tagData, pBuffer + attrOffset +1, 3);
ReadBytes(pFile, &flags, dataStart + tagData, 4);
}
else if (tag == (PRUint8) 0x02) {
tagData = 0;
- memcpy( &tagData, pBuffer + attrOffset +1, 3);
+ memcpy(&tagData, pBuffer + attrOffset +1, 3);
ReadBytes(pFile, &time, dataStart + tagData, 4);
}
}
}
}
}
pIndex[i] = offset;
pFlags[i] = flags;
pTime[i] = time;
}
}
-bool nsOE5File::ReadBytes( nsIInputStream *stream, void *pBuffer, PRUint32 offset, PRUint32 bytes)
+bool nsOE5File::ReadBytes(nsIInputStream *stream, void *pBuffer, PRUint32 offset, PRUint32 bytes)
{
nsresult rv;
nsCOMPtr <nsISeekableStream> seekableStream = do_QueryInterface(stream);
if (offset != kDontSeek) {
rv = seekableStream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
- if (NS_FAILED( rv))
- return( false);
+ if (NS_FAILED(rv))
+ return false;
}
if (!bytes)
- return( true);
+ return true;
PRUint32 cntRead;
char * pReadTo = (char *)pBuffer;
rv = stream->Read(pReadTo, bytes, &cntRead);
return NS_SUCCEEDED(rv) && cntRead == bytes;
}
--- a/mailnews/import/oexpress/nsOE5File.h
+++ b/mailnews/import/oexpress/nsOE5File.h
@@ -43,23 +43,23 @@
#include <windows.h>
class nsIInputStream;
class nsOE5File
{
public:
/* pFile must already be open for reading. */
- static bool VerifyLocalMailFile( nsIFile *pFile);
+ static bool VerifyLocalMailFile(nsIFile *pFile);
/* pFile must NOT be open for reading */
- static bool IsLocalMailFile( nsIFile *pFile);
+ static bool IsLocalMailFile(nsIFile *pFile);
- static bool ReadIndex( nsIInputStream *pFile, PRUint32 **ppIndex, PRUint32 *pSize);
+ static bool ReadIndex(nsIInputStream *pFile, PRUint32 **ppIndex, PRUint32 *pSize);
- static nsresult ImportMailbox( PRUint32 *pBytesDone, bool *pAbort, nsString& name, nsIFile *inFile, nsIFile *pDestination, PRUint32 *pCount);
+ static nsresult ImportMailbox(PRUint32 *pBytesDone, bool *pAbort, nsString& name, nsIFile *inFile, nsIFile *pDestination, PRUint32 *pCount);
static void FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);
private:
typedef struct {
PRUint32 * pIndex;
PRUint32 count;
PRUint32 alloc;
--- a/mailnews/import/oexpress/nsOEAddressIterator.cpp
+++ b/mailnews/import/oexpress/nsOEAddressIterator.cpp
@@ -105,68 +105,68 @@ static MAPIFields gMapiFields[] = {
{ 13, kNoMultiLine, PR_HOME_ADDRESS_CITY},
{ 16, kNoMultiLine, PR_HOME_ADDRESS_COUNTRY},
{ 15, kNoMultiLine, PR_HOME_ADDRESS_POSTAL_CODE},
{ 14, kNoMultiLine, PR_HOME_ADDRESS_STATE_OR_PROVINCE},
{ 11, 12, PR_HOME_ADDRESS_STREET},
{ 24, kNoMultiLine, PR_DEPARTMENT_NAME}
};
-nsOEAddressIterator::nsOEAddressIterator( CWAB *pWab, nsIAddrDatabase *database)
+nsOEAddressIterator::nsOEAddressIterator(CWAB *pWab, nsIAddrDatabase *database)
{
m_pWab = pWab;
m_database = database;
m_listRows.Init();
}
nsOEAddressIterator::~nsOEAddressIterator()
{
}
-nsresult nsOEAddressIterator::EnumUser( const PRUnichar * pName, LPENTRYID pEid, ULONG cbEid)
+nsresult nsOEAddressIterator::EnumUser(const PRUnichar * pName, LPENTRYID pEid, ULONG cbEid)
{
- IMPORT_LOG1( "User: %S\n", pName);
+ IMPORT_LOG1("User: %S\n", pName);
nsresult rv = NS_OK;
if (m_database) {
- LPMAILUSER pUser = m_pWab->GetUser( cbEid, pEid);
+ LPMAILUSER pUser = m_pWab->GetUser(cbEid, pEid);
if (pUser) {
// Get a new row from the database!
nsCOMPtr <nsIMdbRow> newRow;
rv = m_database->GetNewRow(getter_AddRefs(newRow));
NS_ENSURE_SUCCESS(rv, rv);
- if (newRow && BuildCard( pName, newRow, pUser))
+ if (newRow && BuildCard(pName, newRow, pUser))
{
rv = m_database->AddCardRowToDB(newRow);
NS_ENSURE_SUCCESS(rv, rv);
- IMPORT_LOG0( "* Added entry to address book database\n");
+ IMPORT_LOG0("* Added entry to address book database\n");
nsString eMail;
- LPSPropValue pProp = m_pWab->GetUserProperty( pUser, PR_EMAIL_ADDRESS);
+ LPSPropValue pProp = m_pWab->GetUserProperty(pUser, PR_EMAIL_ADDRESS);
if (pProp)
{
- m_pWab->GetValueString( pProp, eMail);
- SanitizeValue( eMail);
- m_pWab->FreeProperty( pProp);
+ m_pWab->GetValueString(pProp, eMail);
+ SanitizeValue(eMail);
+ m_pWab->FreeProperty(pProp);
m_listRows.Put(eMail, newRow);
}
}
- m_pWab->ReleaseUser( pUser);
+ m_pWab->ReleaseUser(pUser);
}
}
- return(rv);
+ return rv;
}
void nsOEAddressIterator::FindListRow(nsString &eMail, nsIMdbRow **cardRow)
{
m_listRows.Get(eMail,cardRow);
}
-nsresult nsOEAddressIterator::EnumList( const PRUnichar * pName, LPENTRYID pEid, ULONG cbEid, LPMAPITABLE lpTable)
+nsresult nsOEAddressIterator::EnumList(const PRUnichar * pName, LPENTRYID pEid, ULONG cbEid, LPMAPITABLE lpTable)
{
// If no name provided then we're done.
if (!pName || !(*pName))
return NS_OK;
nsresult rv = NS_ERROR_FAILURE;
HRESULT hr = E_FAIL;
// Make sure we have db to work with.
@@ -187,19 +187,19 @@ nsresult nsOEAddressIterator::EnumList(
LPSRowSet lpRowAB = NULL;
ULONG lpcbEID = 0;
LPENTRYID lpEID = NULL;
ULONG rowCount = 0;
int cNumRows = 0;
int numListElems = 0;
nsAutoString uniStr;
- hr = lpTable->GetRowCount( 0, &rowCount);
+ hr = lpTable->GetRowCount(0, &rowCount);
//
- hr = lpTable->SeekRow( BOOKMARK_BEGINNING, 0, NULL );
+ hr = lpTable->SeekRow(BOOKMARK_BEGINNING, 0, NULL);
if(HR_FAILED(hr))
return NS_ERROR_FAILURE;
// Read all the rows of the table one by one
do
{
hr = lpTable->QueryRows(1, 0, &lpRowAB);
@@ -217,70 +217,70 @@ nsresult nsOEAddressIterator::EnumList(
ULONG cbEID = lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
// There are 2 kinds of objects - the MAPI_MAILUSER contact object
// and the MAPI_DISTLIST contact object
// For distribution lists, we will only consider MAILUSER
// objects since we can't nest lists yet.
if(lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER)
{
- LPMAILUSER pUser = m_pWab->GetUser( cbEID, lpEID);
- LPSPropValue pProp = m_pWab->GetUserProperty( pUser, PR_EMAIL_ADDRESS);
- nsString eMail;
+ LPMAILUSER pUser = m_pWab->GetUser(cbEID, lpEID);
+ LPSPropValue pProp = m_pWab->GetUserProperty(pUser, PR_EMAIL_ADDRESS);
+ nsString eMail;
nsCOMPtr <nsIMdbRow> cardRow;
- m_pWab->GetValueString( pProp, eMail);
- SanitizeValue( eMail);
+ m_pWab->GetValueString(pProp, eMail);
+ SanitizeValue(eMail);
FindListRow(eMail, getter_AddRefs(cardRow));
if (cardRow)
{
nsCOMPtr <nsIAbCard> userCard;
nsCOMPtr <nsIAbCard> newCard;
userCard = do_CreateInstance(NS_ABMDBCARD_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
m_database->InitCardFromRow(userCard,cardRow);
m_database->AddListCardColumnsToRow(userCard, listRow, ++numListElems,
getter_AddRefs(newCard),
true, nsnull, nsnull);
}
- m_pWab->FreeProperty( pProp);
- m_pWab->ReleaseUser( pUser);
+ m_pWab->FreeProperty(pProp);
+ m_pWab->ReleaseUser(pUser);
}
}
- m_pWab->FreeProws(lpRowAB );
+ m_pWab->FreeProws(lpRowAB);
}
} while (SUCCEEDED(hr) && cNumRows && lpRowAB);
m_database->SetListAddressTotal(listRow, numListElems);
return rv;
}
-void nsOEAddressIterator::SanitizeValue( nsString& val)
+void nsOEAddressIterator::SanitizeValue(nsString& val)
{
MsgReplaceSubstring(val, NS_LITERAL_STRING("\r\n"), NS_LITERAL_STRING(", &