Bug 459000 - Address book comment cleanup; r=bugzilla
authorGary Kwong <nth10sd@gmail.com>
Thu, 16 Oct 2008 17:18:01 +0200
changeset 623 74eeeb2edbe1bca9dabda2b8edbab36bd1ba5107
parent 622 5d69c7b6e83ce8039e202198ca209f75e326161b
child 624 10f00472446b535994ef7b9fb4aea1c28f27f6b6
push idunknown
push userunknown
push dateunknown
reviewersbugzilla
bugs459000
Bug 459000 - Address book comment cleanup; r=bugzilla
mailnews/addrbook/prefs/resources/content/pref-editdirectories.js
mailnews/addrbook/public/nsAbBaseCID.h
mailnews/addrbook/resources/content/abCommon.js
mailnews/addrbook/resources/content/addressbook.js
mailnews/addrbook/src/nsAbAddressCollecter.cpp
mailnews/addrbook/src/nsAbCardProperty.cpp
mailnews/addrbook/src/nsAbDirProperty.cpp
mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
mailnews/addrbook/src/nsAbLDAPReplicationService.cpp
mailnews/addrbook/src/nsAbMDBCard.cpp
mailnews/addrbook/src/nsAbManager.cpp
mailnews/addrbook/src/nsAbOSXDirectory.h
mailnews/addrbook/src/nsAbOutlookCard.h
mailnews/addrbook/src/nsAbView.cpp
mailnews/addrbook/src/nsAbWinHelper.cpp
mailnews/addrbook/src/nsAddbookProtocolHandler.h
mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp
mailnews/addrbook/test/unit/test_collection.js
mailnews/base/public/nsIMessenger.idl
mailnews/base/public/nsIMessengerOSIntegration.idl
--- a/mailnews/addrbook/prefs/resources/content/pref-editdirectories.js
+++ b/mailnews/addrbook/prefs/resources/content/pref-editdirectories.js
@@ -144,17 +144,17 @@ function selectDirectory()
                           .getService(Components.interfaces.nsIPrefBranch);
     var ab = Components.classes["@mozilla.org/abmanager;1"]
                        .getService(Components.interfaces.nsIAbManager)
                        .getDirectory(abList.value);
     try {
       disable = prefs.getBoolPref(ab.dirPrefId + ".disable_delete");
     }
     catch(ex){
-      // if this preference is not set its ok.
+      // If this preference is not set, it's ok.
     }
     if (disable)
       removeButton.setAttribute("disabled", true);
     else
       removeButton.removeAttribute("disabled");
   }
   else {
     editButton.setAttribute("disabled", true);
--- a/mailnews/addrbook/public/nsAbBaseCID.h
+++ b/mailnews/addrbook/public/nsAbBaseCID.h
@@ -348,17 +348,17 @@
 
 #define NS_ABLDAPDIRFACTORY_CID                                \
 {  /* {8e3701af-8828-426c-84ac-124825c778f8} */			\
         0x8e3701af, 0x8828, 0x426c,                             \
         {0x84, 0xac, 0x12, 0x48, 0x25, 0xc7, 0x78, 0xf8}        \
 }
 
 //
-// LDAP autcomplete directory factory
+// LDAP autocomplete directory factory
 //
 #define NS_ABLDAPACDIRFACTORY_CONTRACTID \
   NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "ldap"
 #define NS_ABLDAPSACDIRFACTORY_CONTRACTID \
   NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "ldaps"
 
 // nsAbLDAPAutoCompFormatter
 
--- a/mailnews/addrbook/resources/content/abCommon.js
+++ b/mailnews/addrbook/resources/content/abCommon.js
@@ -609,17 +609,17 @@ function GetParentDirectoryFromMailingLi
     return abURIArr[0] + "/" + abURIArr[1] + "/" + abURIArr[2];
   }
 
   return null;
 } 
 
 function DirPaneHasFocus()
 {
-  // returns true if diectory pane has the focus. Returns false, otherwise.
+  // Returns true if directory pane has the focus. Returns false, otherwise.
   return (top.document.commandDispatcher.focusedElement == dirTree)
 }
 
 function GetSelectedDirectory()
 {
   if (abList)
     return abList.value;
   else {
--- a/mailnews/addrbook/resources/content/addressbook.js
+++ b/mailnews/addrbook/resources/content/addressbook.js
@@ -96,17 +96,17 @@ var gAddressBookAbListener = {
           // Now get the parent of the row.
           var newRow = dirTree.view.getParentIndex(gPreviousDirTreeIndex);
 
           // if we have no parent (i.e. we are an address book), use the
           // previous index.
           if (newRow == -1)
             newRow = gPreviousDirTreeIndex;
 
-          // Fall back to the first adddress book if we're not in a valid range
+          // Fall back to the first address book if we're not in a valid range
           if (newRow >= dirTree.view.rowCount)
             newRow = 0;
 
           // Now select the new item.
           dirTree.view.selection.select(newRow);
         }
       }
     }
--- a/mailnews/addrbook/src/nsAbAddressCollecter.cpp
+++ b/mailnews/addrbook/src/nsAbAddressCollecter.cpp
@@ -69,17 +69,17 @@ nsAbAddressCollecter::~nsAbAddressCollec
     pPrefBranchInt->RemoveObserver(PREF_MAIL_COLLECT_ADDRESSBOOK, this);
 }
 
 NS_IMETHODIMP nsAbAddressCollecter::GetCardFromAttribute(const nsACString &aName, const nsACString &aValue, nsIAbCard **aCard)
 {
   NS_ENSURE_ARG_POINTER(aCard);
   if (m_database)
     // Please DO NOT change the 3rd param of GetCardFromAttribute() call to 
-    // PR_TRUE (ie, case insensitive) without reading bugs #128535 and #121478.
+    // PR_TRUE (i.e. case insensitive) without reading bugs #128535 and #121478.
     return m_database->GetCardFromAttribute(m_directory.get(),
                                             PromiseFlatCString(aName).get(),
                                             aValue, PR_FALSE /* retain case */,
                                             aCard);
 
   return NS_ERROR_FAILURE;
 }
 
--- a/mailnews/addrbook/src/nsAbCardProperty.cpp
+++ b/mailnews/addrbook/src/nsAbCardProperty.cpp
@@ -395,17 +395,17 @@ NS_IMETHODIMP nsAbCardProperty::HasEmail
   if (rv != NS_ERROR_NOT_AVAILABLE &&
       emailAddress.Equals(aEmailAddress, CaseInsensitiveCompare))
 #endif
     *aResult = PR_TRUE;
 
   return NS_OK;
 }
 
-// This function may be overriden by derived classes for
+// This function may be overridden by derived classes for
 // nsAb*Card specific implementations.
 NS_IMETHODIMP nsAbCardProperty::Copy(nsIAbCard* srcCard)
 {
   NS_ENSURE_ARG_POINTER(srcCard);
 
   nsCOMPtr<nsISimpleEnumerator> properties;
   nsresult rv = srcCard->GetProperties(getter_AddRefs(properties));
   NS_ENSURE_SUCCESS(rv, rv);
--- a/mailnews/addrbook/src/nsAbDirProperty.cpp
+++ b/mailnews/addrbook/src/nsAbDirProperty.cpp
@@ -105,17 +105,17 @@ NS_IMETHODIMP nsAbDirProperty::GetDirNam
 
   CopyUTF8toUTF16(dirName, aDirName);
   return NS_OK;
 }
 
 // XXX Although mailing lists could use the NotifyItemPropertyChanged
 // mechanism here, it requires some rework on how we write/save data
 // relating to mailing lists, so we're just using the old method of a
-// local variable to store tha mailing list name.
+// local variable to store the mailing list name.
 NS_IMETHODIMP nsAbDirProperty::SetDirName(const nsAString &aDirName)
 {
   if (m_DirPrefId.IsEmpty())
   {
     m_ListDirName = aDirName;
     return NS_OK;
   }
 
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
@@ -53,17 +53,17 @@
 #include "nsIAuthPrompt.h"
 #include "nsIStringBundle.h"
 #include "nsIWindowWatcher.h"
 #include "nsUnicharUtils.h"
 #include "plstr.h"
 #include "nsILDAPErrors.h"
 #include "prmem.h"
 
-// defined here since to be used 
+// Defined here since to be used
 // only locally to this file.
 enum UpdateOp {
  NO_OP,
  ENTRY_ADD,
  ENTRY_DELETE,
  ENTRY_MODIFY
 };
 
@@ -80,24 +80,24 @@ nsAbLDAPProcessChangeLogData::~nsAbLDAPP
 {
 
 }
 
 NS_IMETHODIMP nsAbLDAPProcessChangeLogData::Init(nsIAbLDAPReplicationQuery * query, nsIWebProgressListener *progressListener)
 {
    NS_ENSURE_ARG_POINTER(query);
 
-   // here we are assuming that the caller will pass a nsAbLDAPChangeLogQuery object,
+   // Here we are assuming that the caller will pass a nsAbLDAPChangeLogQuery object,
    // an implementation derived from the implementation of nsIAbLDAPReplicationQuery.
    nsresult rv = NS_OK;
    mChangeLogQuery = do_QueryInterface(query, &rv);
    if(NS_FAILED(rv))
        return rv;
    
-   // call the parent's Init now
+   // Call the parent's Init now.
    return nsAbLDAPProcessReplicationData::Init(query, progressListener);
 }
 
 nsresult nsAbLDAPProcessChangeLogData::OnLDAPBind(nsILDAPMessage *aMessage)
 {
     NS_ENSURE_ARG_POINTER(aMessage);
 	if(!mInitialized) 
         return NS_ERROR_NOT_INITIALIZED;
@@ -155,17 +155,17 @@ nsresult nsAbLDAPProcessChangeLogData::O
         }
         break;
     case kSearchingRootDSE:
         rv = ParseRootDSEEntry(aMessage);
         break;
     case kFindingChanges:
         rv = ParseChangeLogEntries(aMessage);
         break;
-    // fall through since we only add (for updates we delete and add)
+    // Fall through since we only add (for updates we delete and add)
     case kReplicatingChanges:
     case kReplicatingAll :
         return nsAbLDAPProcessReplicationData::OnLDAPSearchEntry(aMessage);
     }
 
     if(NS_FAILED(rv))
         Abort();
 
@@ -186,17 +186,17 @@ nsresult nsAbLDAPProcessChangeLogData::O
     {
         if(errorCode == nsILDAPErrors::SUCCESS || errorCode == nsILDAPErrors::SIZELIMIT_EXCEEDED) {
             switch(mState) {
             case kSearchingAuthDN :
                 rv = OnSearchAuthDNDone();
                 break;
             case kSearchingRootDSE:
              {
-                // before starting the changeLog check the DB file, if its not there or bogus
+                // Before starting the changeLog check the DB file, if its not there or bogus
                 // we need to create a new one and set to all.
                 nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
                 if (NS_FAILED(rv)) 
                     break;
                 nsCOMPtr<nsILocalFile> dbPath;
                 rv = abSession->GetUserProfileDirectory(getter_AddRefs(dbPath));
                 if (NS_FAILED(rv)) 
                     break;
@@ -218,44 +218,44 @@ nsresult nsAbLDAPProcessChangeLogData::O
                 PRInt64 fileSize;
                 rv = dbPath->GetFileSize(&fileSize);
                 if(NS_FAILED(rv)) 
                     break;
 
                 if (!fileExists || !fileSize)
                     mUseChangeLog = PR_FALSE;
 
-                // open / create the AB here since it calls Done,
-                // just return from here. 
+                // Open / create the AB here since it calls Done,
+                // just return from here.
                 if (mUseChangeLog)
                    rv = OpenABForReplicatedDir(PR_FALSE);
                 else
                    rv = OpenABForReplicatedDir(PR_TRUE);
                 if (NS_FAILED(rv))
                    return rv;
                 
-                // now start the appropriate query
+                // Now start the appropriate query
                 rv = OnSearchRootDSEDone();
                 break;
              }
             case kFindingChanges:
                 rv = OnFindingChangesDone();
-                // if success we return from here since
+                // If success we return from here since
                 // this changes state to kReplicatingChanges
                 // and it falls thru into the if clause below.
                 if (NS_SUCCEEDED(rv))
                     return rv;
                 break;
             case kReplicatingAll :
                 return nsAbLDAPProcessReplicationData::OnLDAPSearchResult(aMessage);
             } // end of switch
         }
         else
             rv = NS_ERROR_FAILURE;
-        // if one of the changed entry in changelog is not found, 
+        // If one of the changed entry in changelog is not found,
         // continue with replicating the next one.
         if(mState == kReplicatingChanges)
             rv = OnReplicatingChangeDone();
     } // end of outer if
 
     if(NS_FAILED(rv))
         Abort();
 
@@ -342,20 +342,20 @@ nsresult nsAbLDAPProcessChangeLogData::O
 }
 
 nsresult nsAbLDAPProcessChangeLogData::ParseRootDSEEntry(nsILDAPMessage *aMessage)
 {
     NS_ENSURE_ARG_POINTER(aMessage);
     if (!mInitialized)
         return NS_ERROR_NOT_INITIALIZED;
 
-    // populate the RootDSEChangeLogEntry
+    // Populate the RootDSEChangeLogEntry
     CharPtrArrayGuard attrs;
     nsresult rv = aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());
-    // no attributes !!!
+    // No attributes
     if(NS_FAILED(rv)) 
         return rv;
 
     for(PRInt32 i=attrs.GetSize()-1; i >= 0; i--) {
         PRUnicharPtrArrayGuard vals;
         rv = aMessage->GetValues(attrs.GetArray()[i], vals.GetSizeAddr(), vals.GetArrayAddr());
         if(NS_FAILED(rv))
             continue;
@@ -376,17 +376,17 @@ nsresult nsAbLDAPProcessChangeLogData::P
 
     if ((mRootDSEEntry.lastChangeNumber > 0) &&
         (lastChangeNumber < mRootDSEEntry.lastChangeNumber) &&
         (lastChangeNumber > mRootDSEEntry.firstChangeNumber))
         mUseChangeLog = PR_TRUE;
 
     if (mRootDSEEntry.lastChangeNumber &&
         (lastChangeNumber == mRootDSEEntry.lastChangeNumber)) {
-        Done(PR_TRUE); // we are up to date no need to replicate, db not open yet so call Done
+        Done(PR_TRUE); // We are up to date no need to replicate, db not open yet so call Done
         return NS_OK;
     }
 
     return rv;
 }
 
 nsresult nsAbLDAPProcessChangeLogData::OnSearchRootDSEDone()
 {
@@ -421,20 +421,20 @@ nsresult nsAbLDAPProcessChangeLogData::O
 }
 
 nsresult nsAbLDAPProcessChangeLogData::ParseChangeLogEntries(nsILDAPMessage *aMessage)
 {
     NS_ENSURE_ARG_POINTER(aMessage);
     if(!mInitialized) 
         return NS_ERROR_NOT_INITIALIZED;
 
-    // populate the RootDSEChangeLogEntry
+    // Populate the RootDSEChangeLogEntry
     CharPtrArrayGuard attrs;
     nsresult rv = aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());
-    // no attributes
+    // No attributes
     if(NS_FAILED(rv)) 
         return rv;
 
     nsAutoString targetDN;
     UpdateOp operation = NO_OP;
     for(PRInt32 i = attrs.GetSize()-1; i >= 0; i--) {
         PRUnicharPtrArrayGuard vals;
         rv = aMessage->GetValues(attrs.GetArray()[i], vals.GetSizeAddr(), vals.GetArrayAddr());
@@ -450,93 +450,93 @@ nsresult nsAbLDAPProcessChangeLogData::P
                     operation = ENTRY_MODIFY;
                 if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("delete"), nsCaseInsensitiveStringComparator()))
                     operation = ENTRY_DELETE;
             }
         }
     }
 
     mChangeLogEntriesCount++;
-    if(!(mChangeLogEntriesCount % 10)) { // inform the listener every 10 entries
+    if(!(mChangeLogEntriesCount % 10)) { // Inform the listener every 10 entries
         mListener->OnProgressChange(nsnull,nsnull,mChangeLogEntriesCount, -1, mChangeLogEntriesCount, -1);
-        // in case if the LDAP Connection thread is starved and causes problem
+        // In case if the LDAP Connection thread is starved and causes problem
         // uncomment this one and try.
         // PR_Sleep(PR_INTERVAL_NO_WAIT); // give others a chance
     }
 
 #ifdef DEBUG_rdayal
     printf ("ChangeLog Replication : Updated Entry : %s for OpType : %u\n", 
                                     NS_ConvertUTF16toUTF8(targetDN).get(), operation);
 #endif
 
     switch(operation) {
     case ENTRY_ADD:
-        // add the DN to the add list if not already in the list
+        // Add the DN to the add list if not already in the list
         if(!(mEntriesToAdd.IndexOf(targetDN) >= 0))
             mEntriesToAdd.AppendString(targetDN);
         break;
     case ENTRY_DELETE:
-        // donot check the return here since delete may fail if 
-        // entry deleted in changelog doesnot exist in DB 
+        // Do not check the return here since delete may fail if
+        // entry deleted in changelog does not exist in DB
         // for e.g if the user specifies a filter, so go next entry
         DeleteCard(targetDN);
         break;
     case ENTRY_MODIFY:
-        // for modify, delte the entry from DB and add updated entry
+        // For modify, delete the entry from DB and add updated entry
         // we do this since we cannot access the changes attribs of changelog
         rv = DeleteCard(targetDN);
         if (NS_SUCCEEDED(rv)) 
             if(!(mEntriesToAdd.IndexOf(targetDN) >= 0))
                 mEntriesToAdd.AppendString(targetDN);
         break;
     default:
-        // should not come here, would come here only
+        // Should not come here, would come here only
         // if the entry is not a changeLog entry
         NS_WARNING("nsAbLDAPProcessChangeLogData::ParseChangeLogEntries"
            "Not an changelog entry");
     }
 
-    // go ahead processing the next entry,  a modify or delete DB operation 
-    // can 'correctly' fail if the entry is not present in the DB. 
-    // eg : in case a filter is specified.
+    // Go ahead processing the next entry, a modify or delete DB operation
+    // can 'correctly' fail if the entry is not present in the DB,
+    // e.g. in case a filter is specified.
     return NS_OK;
 }
 
 nsresult nsAbLDAPProcessChangeLogData::OnFindingChangesDone()
 {
     if(!mInitialized) 
         return NS_ERROR_NOT_INITIALIZED;
 
 #ifdef DEBUG_rdayal
     printf ("ChangeLog Replication : Finding Changes Done \n");
 #endif
 
     nsresult rv = NS_OK;
 
-    // no entries to add/update (for updates too we delete and add) entries,
+    // No entries to add/update (for updates too we delete and add) entries,
     // we took care of deletes in ParseChangeLogEntries, all Done!
     mEntriesAddedQueryCount = mEntriesToAdd.Count();
     if(mEntriesAddedQueryCount <= 0) {
         if(mReplicationDB && mDBOpen) {
-            // close the DB, no need to commit since we have not made
+            // Close the DB, no need to commit since we have not made
             // any changes yet to the DB.
             rv = mReplicationDB->Close(PR_FALSE);
             NS_ASSERTION(NS_SUCCEEDED(rv), "Replication DB Close(no commit) on Success failed");
             mDBOpen = PR_FALSE;
-            // once are done with the replication file, delete the backup file
+            // Once are done with the replication file, delete the backup file
             if(mBackupReplicationFile) {
                 rv = mBackupReplicationFile->Remove(PR_FALSE);
                 NS_ASSERTION(NS_SUCCEEDED(rv), "Replication BackupFile Remove on Success failed");
             }
         }
         Done(PR_TRUE);
         return NS_OK;
     }
 
-    // decrement the count first to get the correct array element
+    // Decrement the count first to get the correct array element
     mEntriesAddedQueryCount--;
     rv = mChangeLogQuery->QueryChangedEntries(NS_ConvertUTF16toUTF8(*(mEntriesToAdd[mEntriesAddedQueryCount])));
     if (NS_FAILED(rv))
         return rv;
 
     if(mListener && NS_SUCCEEDED(rv))
         mListener->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_START, PR_TRUE);
 
@@ -549,30 +549,30 @@ nsresult nsAbLDAPProcessChangeLogData::O
     if(!mInitialized) 
         return NS_ERROR_NOT_INITIALIZED;
 
     nsresult rv = NS_OK;
 
     if(!mEntriesAddedQueryCount)
     {
         if(mReplicationDB && mDBOpen) {
-            rv = mReplicationDB->Close(PR_TRUE); // commit and close the DB
+            rv = mReplicationDB->Close(PR_TRUE); // Commit and close the DB
             NS_ASSERTION(NS_SUCCEEDED(rv), "Replication DB Close (commit) on Success failed");
             mDBOpen = PR_FALSE;
         }
-        // once we done with the replication file, delete the backup file
+        // Once we done with the replication file, delete the backup file.
         if(mBackupReplicationFile) {
             rv = mBackupReplicationFile->Remove(PR_FALSE);
             NS_ASSERTION(NS_SUCCEEDED(rv), "Replication BackupFile Remove on Success failed");
         }
-        Done(PR_TRUE);  // all data is received
+        Done(PR_TRUE);  // All data is received
         return NS_OK;
     }
 
-    // remove the entry already added from the list and query the next one
+    // Remove the entry already added from the list and query the next one.
     if(mEntriesAddedQueryCount < mEntriesToAdd.Count() && mEntriesAddedQueryCount >= 0)
         mEntriesToAdd.RemoveStringAt(mEntriesAddedQueryCount);
     mEntriesAddedQueryCount--;
     rv = mChangeLogQuery->QueryChangedEntries(NS_ConvertUTF16toUTF8(*(mEntriesToAdd[mEntriesAddedQueryCount])));
 
     return rv;
 }
 
--- a/mailnews/addrbook/src/nsAbLDAPReplicationService.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationService.cpp
@@ -65,17 +65,17 @@ NS_IMETHODIMP nsAbLDAPReplicationService
 							   nsIWebProgressListener *progressListener)
 {
   NS_ENSURE_ARG_POINTER(aDirectory);
 
 #ifdef DEBUG_rdayal
   printf("Start Replication called");
 #endif
 
-  // makes sure to allow only one replication at a time
+  // Makes sure to allow only one replication at a time.
   if(mReplicating)
     return NS_ERROR_FAILURE;
 
   mDirectory = aDirectory;
 
   nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
 
   switch (DecideProtocol())
@@ -127,42 +127,42 @@ NS_IMETHODIMP nsAbLDAPReplicationService
   nsresult rv = NS_ERROR_FAILURE;
 
   if (aDirectory == mDirectory)
   {
     if (mQuery && mReplicating)
       rv = mQuery->CancelQuery();  
   }
 
-  // if query has been cancelled successfully
+  // If query has been cancelled successfully
   if (NS_SUCCEEDED(rv))
     Done(PR_FALSE);
 
   return rv;
 }
 
 NS_IMETHODIMP nsAbLDAPReplicationService::Done(PRBool aSuccess)
 {
   mReplicating = PR_FALSE;
   if (mQuery)
   {
-    mQuery = nsnull;  // release query obj
-    mDirectory = nsnull; // release directory
+    mQuery = nsnull;  // Release query obj
+    mDirectory = nsnull; // Release directory
   }
 
   return NS_OK;
 }
 
 
-// XXX: This method should query the RootDSE for the changeLog attribute, 
+// XXX: This method should query the RootDSE for the changeLog attribute,
 // if it exists ChangeLog protocol is supported.
 PRInt32 nsAbLDAPReplicationService::DecideProtocol()
 {
-  // do the changeLog, it will decide if there is a need to replicate all
-  // entries or only update existing DB and will do the approprite thing.
+  // Do the changeLog, it will decide if there is a need to replicate all
+  // entries or only update existing DB and will do the appropriate thing.
   //
   // XXX: Bug 231965 changed this from kChangeLogProtocol to
   // kDefaultDownloadAll because of a problem with ldap replication not
   // working correctly. We need to change this back at some stage (bug 311632).
   return nsIAbLDAPProcessReplicationData::kDefaultDownloadAll;
 }
 
 
--- a/mailnews/addrbook/src/nsAbMDBCard.cpp
+++ b/mailnews/addrbook/src/nsAbMDBCard.cpp
@@ -56,17 +56,17 @@ NS_IMETHODIMP nsAbMDBCard::Equals(nsIAbC
   }
 
   // If we have the same directory, we will equal the other card merely given
   // the row IDs. If not, we are never equal. But we are dumb in that we don't
   // know who our directory is, which may change in the future. For now,
   // however, the only known users of this method are for locating us in a list
   // of cards, most commonly mailing lists; a warning on the IDL has also
   // notified consumers that this method is not generally safe to use. In this
-  // respect, it is safe to assume that the directory portion is satisified when
+  // respect, it is safe to assume that the directory portion is satisfied when
   // making this call.
   // However, if we make the wrong assumption, one of two things will happen.
   // If the other directory is a local address book, we could return a spurious
   // true result. If not, then DbRowID should be unset and we can definitively
   // return false.
 
   PRUint32 row;
   nsresult rv = card->GetPropertyAsUint32("DbRowID", &row);
--- a/mailnews/addrbook/src/nsAbManager.cpp
+++ b/mailnews/addrbook/src/nsAbManager.cpp
@@ -166,17 +166,17 @@ NS_IMPL_QUERY_INTERFACE2(nsAbManager,
 // nsIAbManager
 //
 
 NS_IMETHODIMP nsAbManager::GetDirectories(nsISimpleEnumerator **aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   // We cache the top level AB to ensure that nsIAbDirectory items are not
-  // created and dumped every time GetDirectores is called. This was causing
+  // created and dumped every time GetDirectories is called. This was causing
   // performance problems, especially with the content policy on messages
   // with lots of urls.
   if (!mCacheTopLevelAb)
   {
     nsresult rv;
     nsCOMPtr<nsIRDFService> rdfService(do_GetService(NS_RDF_CONTRACTID "/rdf-service;1", &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -498,40 +498,40 @@ NS_IMETHODIMP nsAbManager::ExportAddress
   {
     default:
     case LDIF_EXPORT_TYPE: // ldif
       // If filename does not have the correct ext, add one.
       if ((fileName.Find(LDIF_FILE_EXTENSION, fileName.Length() - strlen(LDIF_FILE_EXTENSION), PR_TRUE) == -1) && 
           (fileName.Find(LDIF_FILE_EXTENSION2, fileName.Length() - strlen(LDIF_FILE_EXTENSION2), PR_TRUE) == -1)) {
 
 
-       // Add the extenstion and build a new localFile.
+       // Add the extension and build a new localFile.
        fileName.AppendLiteral(LDIF_FILE_EXTENSION2);
        localFile->SetLeafName(fileName);
     }
       rv = ExportDirectoryToLDIF(aDirectory, localFile);
       break;
 
     case CSV_EXPORT_TYPE: // csv
       // If filename does not have the correct ext, add one.
       if (fileName.Find(CSV_FILE_EXTENSION, fileName.Length() - strlen(CSV_FILE_EXTENSION), PR_TRUE) == -1) {
 
-       // Add the extenstion and build a new localFile.
+       // Add the extension and build a new localFile.
        fileName.AppendLiteral(CSV_FILE_EXTENSION);
        localFile->SetLeafName(fileName);
     }
       rv = ExportDirectoryToDelimitedText(aDirectory, CSV_DELIM, CSV_DELIM_LEN, localFile);
       break;
 
     case TAB_EXPORT_TYPE: // tab & text
       // If filename does not have the correct ext, add one.
       if ((fileName.Find(TXT_FILE_EXTENSION, fileName.Length() - strlen(TXT_FILE_EXTENSION), PR_TRUE) == -1) && 
           (fileName.Find(TAB_FILE_EXTENSION, fileName.Length() - strlen(TAB_FILE_EXTENSION), PR_TRUE) == -1)) {
 
-       // Add the extenstion and build a new localFile.
+       // Add the extension and build a new localFile.
        fileName.AppendLiteral(TXT_FILE_EXTENSION);
        localFile->SetLeafName(fileName);
   }
       rv = ExportDirectoryToDelimitedText(aDirectory, TAB_DELIM, TAB_DELIM_LEN, localFile);
       break;
   };
 
   return rv;
@@ -828,17 +828,17 @@ nsAbManager::ExportDirectoryToLDIF(nsIAb
                 NS_ENSURE_SUCCESS(rv,rv);
                 if (length != writeCount)
                   return NS_ERROR_FAILURE;
               }
               valueCStr.Truncate();
             }
             else {
               // something we don't support yet
-              // ldif doesn't export mutliple addresses
+              // ldif doesn't export multiple addresses
             }
           }
 
           // write out the linebreak that separates the cards
           rv = outputStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &writeCount);
           NS_ENSURE_SUCCESS(rv,rv);
           if (MSG_LINEBREAK_LEN != writeCount)
             return NS_ERROR_FAILURE;
--- a/mailnews/addrbook/src/nsAbOSXDirectory.h
+++ b/mailnews/addrbook/src/nsAbOSXDirectory.h
@@ -125,13 +125,13 @@ private:
   // - nsIAbDirectory items that are mailing lists, must keep a list of
   //   nsIAbCards in m_AddressList, however
   // - nsIAbDirectory items that are address books, must keep a list of
   //   nsIAbDirectory (i.e. mailing lists) in m_AddressList, AND no nsIAbCards.
   //
   // This wasn't too bad for mork, as that just gets a list from its database,
   // but because we store our own copy of the list, we must store a separate
   // list of nsIAbCards here. nsIMutableArray is used, because then it is
-  // interchangable with m_AddressList.
+  // interchangeable with m_AddressList.
   nsCOMPtr<nsIMutableArray> mCardList;
 };
 
 #endif // nsAbOSXDirectory_h___
--- a/mailnews/addrbook/src/nsAbOutlookCard.h
+++ b/mailnews/addrbook/src/nsAbOutlookCard.h
@@ -115,9 +115,9 @@ public:
 
 protected:
     nsMapiEntry *mMapiData ;
     PRUint32 mAbWinType ;
 
 private:
 };
 
-#endif // nsAbOultlookCard_h___
+#endif // nsAbOutlookCard_h___
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -62,17 +62,17 @@
 
 #define CARD_NOT_FOUND -1
 #define ALL_ROWS -1
 
 #define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
 #define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_AUTOGENERATION "mail.addr_book.displayName.autoGeneration"
 #define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_LASTNAMEFIRST "mail.addr_book.displayName.lastnamefirst"
 
-// also, our default primary sort
+// Also, our default primary sort
 #define GENERATED_NAME_COLUMN_ID "GeneratedName" 
 
 NS_IMPL_ISUPPORTS4(nsAbView, nsIAbView, nsITreeView, nsIAbListener, nsIObserver)
 
 nsAbView::nsAbView() : mInitialized(PR_FALSE),
                        mSuppressSelectionChange(PR_FALSE),
                        mSuppressCountChange(PR_FALSE),
                        mGeneratedNameFormat(0)
@@ -129,17 +129,17 @@ nsresult nsAbView::RemoveCardAt(PRInt32 
   AbCard *abcard = (AbCard*) (mCards.ElementAt(row));
   NS_IF_RELEASE(abcard->card);
   mCards.RemoveElementAt(row);
   PR_FREEIF(abcard->primaryCollationKey);
   PR_FREEIF(abcard->secondaryCollationKey);
   PR_FREEIF(abcard);
 
   
-  // this needs to happen after we remove the card, as RowCountChanged() will call GetRowCount()
+  // This needs to happen after we remove the card, as RowCountChanged() will call GetRowCount()
   if (mTree) {
     rv = mTree->RowCountChanged(row, -1);
     NS_ENSURE_SUCCESS(rv,rv);
   }
 
   if (mAbViewListener && !mSuppressCountChange) {
     rv = mAbViewListener->OnCountChanged(mCards.Count());
     NS_ENSURE_SUCCESS(rv,rv);
@@ -196,47 +196,47 @@ NS_IMETHODIMP nsAbView::SetView(nsIAbDir
                                 nsAString &aResult)
 {
   // Ensure we are initialized
   nsresult rv = Initialize();
 
   mAbViewListener = nsnull;
   if (mTree)
   {
-    // try and speed deletion of old cards by disconnecting the tree from us
+    // Try and speed deletion of old cards by disconnecting the tree from us.
     mTreeSelection->ClearSelection();
     mTree->SetView(nsnull);
   }
 
-  // clear out old cards
+  // Clear out old cards
   PRInt32 i = mCards.Count();
   while(i-- > 0)
   {
     rv = RemoveCardAt(i);
     NS_ASSERTION(NS_SUCCEEDED(rv), "remove card failed\n");
   }
 
   mDirectory = aAddressBook;
 
   rv = EnumerateCards();
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_NAMED_LITERAL_STRING(generatedNameColumnId, GENERATED_NAME_COLUMN_ID);
 
-  // see if the persisted sortColumn is valid.
-  // it may not be, if you migrated from older versions, or switched between
+  // See if the persisted sortColumn is valid.
+  // It may not be, if you migrated from older versions, or switched between
   // a mozilla build and a commercial build, which have different columns.
   nsAutoString actualSortColumn;
   if (!generatedNameColumnId.Equals(aSortColumn) && mCards.Count()) {
     nsIAbCard *card = ((AbCard *)(mCards.ElementAt(0)))->card;
     nsString value;
     // XXX todo
-    // need to check if _Generic is valid.  GetCardValue() will always return NS_OK for _Generic
-    // we're going to have to ask mDirectory if it is.
-    // it might not be.  example:  _ScreenName is valid in Netscape, but not Mozilla.
+    // Need to check if _Generic is valid.  GetCardValue() will always return NS_OK for _Generic
+    // We're going to have to ask mDirectory if it is.
+    // It might not be.  example:  _ScreenName is valid in Netscape, but not Mozilla.
     rv = GetCardValue(card, PromiseFlatString(aSortColumn).get(), value);
     if (NS_FAILED(rv))
       actualSortColumn = generatedNameColumnId;
     else
       actualSortColumn = aSortColumn;
   }
   else
     actualSortColumn = aSortColumn;
@@ -276,30 +276,30 @@ nsresult nsAbView::EnumerateCards()
     nsCOMPtr<nsISupports> item;
     PRBool more;
     while (NS_SUCCEEDED(cardsEnumerator->HasMoreElements(&more)) && more)
     {
       rv = cardsEnumerator->GetNext(getter_AddRefs(item));
       if (NS_SUCCEEDED(rv))
       {
         nsCOMPtr <nsIAbCard> card = do_QueryInterface(item);
-        // malloc these from an arena
+        // Malloc these from an arena
         AbCard *abcard = (AbCard *) PR_Calloc(1, sizeof(struct AbCard));
         if (!abcard) 
           return NS_ERROR_OUT_OF_MEMORY;
 
         abcard->card = card;
         NS_IF_ADDREF(abcard->card);
 
         // XXX todo
-        // would it be better to do an insertion sort, than append and sort?
+        // Would it be better to do an insertion sort, than append and sort?
         // XXX todo
-        // if we knew how many cards there was going to be
-        // we could allocate an array of the size, 
-        // instead of growing and copying as we append
+        // If we knew how many cards there was going to be
+        // we could allocate an array of the size,
+        // instead of growing and copying as we append.
         rv = mCards.AppendElement((void *)abcard);
         NS_ASSERTION(NS_SUCCEEDED(rv), "failed to append card");
       }
     }
   }
 
   return NS_OK;
 }
@@ -432,46 +432,46 @@ nsresult nsAbView::GetCardValue(nsIAbCar
                                 nsAString &_retval)
 {
   // "G" == "GeneratedName", "_P" == "_PhoneticName"
   // else, standard column (like PrimaryEmail and _AimScreenName)
   if (colID[0] == PRUnichar('G'))
     return card->GenerateName(mGeneratedNameFormat, mABBundle, _retval);
 
   if (colID[0] == PRUnichar('_') && colID[1] == PRUnichar('P'))
-    // use LN/FN order for the phonetic name
+    // Use LN/FN order for the phonetic name
     return card->GeneratePhoneticName(PR_TRUE, _retval);
 
   nsresult rv = card->GetPropertyAsAString(NS_ConvertUTF16toUTF8(colID).get(), _retval);
   if (rv == NS_ERROR_NOT_AVAILABLE) {
     rv = NS_OK;
     _retval.Truncate();
   }
   return rv;
 }
 
 nsresult nsAbView::RefreshTree()
 {
   nsresult rv;
 
-  // the PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST pref affects how the GeneratedName column looks.
+  // The PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST pref affects how the GeneratedName column looks.
   // so if the GeneratedName is our primary or secondary sort,
   // we need to resort.
-  // the same applies for kPhoneticNameColumn 
+  // the same applies for kPhoneticNameColumn
   //
   // XXX optimize me
   // PrimaryEmail is always the secondary sort, unless it is currently the
-  // primary sort.  So, if PrimaryEmail is the primary sort, 
+  // primary sort.  So, if PrimaryEmail is the primary sort,
   // GeneratedName might be the secondary sort.
   //
-  // one day, we can get fancy and remember what the secondary sort is.
-  // we do that, we can fix this code.  at best, it will turn a sort into a invalidate.
+  // One day, we can get fancy and remember what the secondary sort is.
+  // We do that, we can fix this code. At best, it will turn a sort into a invalidate.
   // 
-  // if neither the primary nor the secondary sorts are GeneratedName (or kPhoneticNameColumn), 
-  // all we have to do is invalidate (to show the new GeneratedNames), 
+  // If neither the primary nor the secondary sorts are GeneratedName (or kPhoneticNameColumn),
+  // all we have to do is invalidate (to show the new GeneratedNames),
   // but the sort will not change.
   if (mSortColumn.EqualsLiteral(GENERATED_NAME_COLUMN_ID) ||
       mSortColumn.EqualsLiteral(kPriEmailProperty) ||
       mSortColumn.EqualsLiteral(kPhoneticNameColumn)) {
     rv = SortBy(mSortColumn.get(), mSortDirection.get());
   }
   else {
     rv = InvalidateTree(ALL_ROWS);
@@ -603,18 +603,18 @@ inplaceSortCallback(const void *data1, c
 {
   AbCard *card1 = (AbCard *)data1;
   AbCard *card2 = (AbCard *)data2;
   
   SortClosure *closure = (SortClosure *) privateData;
   
   PRInt32 sortValue;
   
-  // if we are sorting the "PrimaryEmail", swap the collation keys, as the secondary is always the 
-  // PrimaryEmail.  use the last primary key as the secondary key.
+  // If we are sorting the "PrimaryEmail", swap the collation keys, as the secondary is always the
+  // PrimaryEmail. Use the last primary key as the secondary key.
   //
   // "Pr" to distinguish "PrimaryEmail" from "PagerNumber"
   if (closure->colID[0] == PRUnichar('P') && closure->colID[1] == PRUnichar('r')) {
     sortValue = closure->abView->CompareCollationKeys(card1->secondaryCollationKey,card1->secondaryCollationKeyLen,card2->secondaryCollationKey,card2->secondaryCollationKeyLen);
     if (sortValue)
       return sortValue * closure->factor;
     else
       return closure->abView->CompareCollationKeys(card1->primaryCollationKey,card1->primaryCollationKeyLen,card2->primaryCollationKey,card2->primaryCollationKeyLen) * (closure->factor);
@@ -649,40 +649,40 @@ NS_IMETHODIMP nsAbView::SortBy(const PRU
 
   nsAutoString sortColumn;
   if (!colID) 
     sortColumn = NS_LITERAL_STRING(GENERATED_NAME_COLUMN_ID).get();  // default sort
   else
     sortColumn = colID;
 
   PRInt32 i;
-  // this function does not optimize for the case when sortColumn and sortDirection
+  // This function does not optimize for the case when sortColumn and sortDirection
   // are identical since the last call, the caller is responsible optimizing
   // for that case
 
-  // if we are sorting by how we are already sorted, 
+  // If we are sorting by how we are already sorted,
   // and just the sort direction changes, just reverse
   //
-  // note, we'll call SortBy() with the existing sort column and the
+  // Note, we'll call SortBy() with the existing sort column and the
   // existing sort direction, and that needs to do a complete resort.
-  // for example, we do that when the PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST changes
+  // For example, we do that when the PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST changes
   if (!NS_strcmp(mSortColumn.get(),sortColumn.get()) && NS_strcmp(mSortDirection.get(), sortDir)) {
     PRInt32 halfPoint = count / 2;
     for (i=0; i < halfPoint; i++) {
-      // swap the elements.
+      // Swap the elements.
       void *ptr1 = mCards.ElementAt(i);
       void *ptr2 = mCards.ElementAt(count - i - 1);
       mCards.ReplaceElementAt(ptr2, i);
       mCards.ReplaceElementAt(ptr1, count - i - 1);
     }
 
     mSortDirection = sortDir;
   }
   else {
-    // generate collation keys
+    // Generate collation keys
     for (i=0; i < count; i++) {
       AbCard *abcard = (AbCard *)(mCards.ElementAt(i));
 
       rv = GenerateCollationKeysForCard(sortColumn.get(), abcard);
       NS_ENSURE_SUCCESS(rv,rv);
     }
 
     nsAutoString sortDirection;
@@ -787,17 +787,17 @@ NS_IMETHODIMP nsAbView::OnItemAdded(nsIS
 {
   nsresult rv;
   nsCOMPtr <nsIAbDirectory> directory = do_QueryInterface(parentDir,&rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (directory.get() == mDirectory.get()) {
     nsCOMPtr <nsIAbCard> addedCard = do_QueryInterface(item);
     if (addedCard) {
-      // malloc these from an arena
+      // Malloc these from an arena
       AbCard *abcard = (AbCard *) PR_Calloc(1, sizeof(struct AbCard));
       if (!abcard) 
         return NS_ERROR_OUT_OF_MEMORY;
 
       abcard->card = addedCard;
       NS_IF_ADDREF(abcard->card);
     
       rv = GenerateCollationKeysForCard(mSortColumn.get(), abcard);
@@ -829,17 +829,17 @@ nsresult nsAbView::AddCard(AbCard *abcar
 {
   nsresult rv = NS_OK;
   NS_ENSURE_ARG_POINTER(abcard);
   
   *index = FindIndexForInsert(abcard);
   rv = mCards.InsertElementAt((void *)abcard, *index);
   NS_ENSURE_SUCCESS(rv,rv);
     
-  // this needs to happen after we insert the card, as RowCountChanged() will call GetRowCount()
+  // This needs to happen after we insert the card, as RowCountChanged() will call GetRowCount()
   if (mTree)
     rv = mTree->RowCountChanged(*index, 1);
 
   if (selectCardAfterAdding && mTreeSelection) {
     mTreeSelection->SetCurrentIndex(*index);
     mTreeSelection->RangedSelect(*index, *index, PR_FALSE /* augment */);
   }
 
@@ -857,21 +857,21 @@ PRInt32 nsAbView::FindIndexForInsert(AbC
   PRInt32 i;
 
   void *item = (void *)abcard;
   
   SortClosure closure;
   SetSortClosure(mSortColumn.get(), mSortDirection.get(), this, &closure);
   
   // XXX todo
-  // make this a binary search
+  // Make this a binary search
   for (i=0; i < count; i++) {
     void *current = mCards.ElementAt(i);
     PRInt32 value = inplaceSortCallback(item, current, (void *)(&closure));
-    // XXX fix me, this is not right for both ascending and descending
+    // XXX Fix me, this is not right for both ascending and descending
     if (value <= 0) 
       break;
   }
   return i;
 }
 
 NS_IMETHODIMP nsAbView::OnItemRemoved(nsISupports *parentDir, nsISupports *item)
 {
@@ -893,29 +893,29 @@ nsresult nsAbView::RemoveCardAndSelectNe
   nsCOMPtr <nsIAbCard> card = do_QueryInterface(item);
   if (card) {
     PRInt32 index = FindIndexForCard(card);
     if (index != CARD_NOT_FOUND) {
       PRBool selectNextCard = PR_FALSE;
       if (mTreeSelection) {
         PRInt32 selectedIndex;
         // XXX todo
-        // make sure it works if nothing selected
+        // Make sure it works if nothing selected
         mTreeSelection->GetCurrentIndex(&selectedIndex);
         if (index == selectedIndex)
           selectNextCard = PR_TRUE;
       }
 
       rv = RemoveCardAt(index);
       NS_ENSURE_SUCCESS(rv,rv);
 
       if (selectNextCard) {
       PRInt32 count = mCards.Count();
       if (count && mTreeSelection) {
-        // if we deleted the last card, adjust so we select the new "last" card
+        // If we deleted the last card, adjust so we select the new "last" card
         if (index >= (count - 1)) {
           index = count -1;
         }
         mTreeSelection->SetCurrentIndex(index);
         mTreeSelection->RangedSelect(index, index, PR_FALSE /* augment */);
       }
     }
   }
@@ -923,17 +923,17 @@ nsresult nsAbView::RemoveCardAndSelectNe
   return rv;
 }
 
 PRInt32 nsAbView::FindIndexForCard(nsIAbCard *card)
 {
   PRInt32 count = mCards.Count();
   PRInt32 i;
  
-  // you can't implement the binary search here, as all you have is the nsIAbCard
+  // You can't implement the binary search here, as all you have is the nsIAbCard
   // you might be here because one of the card properties has changed, and that property
   // could be the collation key.
   for (i=0; i < count; i++) {
     AbCard *abcard = (AbCard*) (mCards.ElementAt(i));
     PRBool equals;
     nsresult rv = card->Equals(abcard->card, &equals);
     if (NS_SUCCEEDED(rv) && equals) {
       return i;
@@ -951,17 +951,17 @@ NS_IMETHODIMP nsAbView::OnItemPropertyCh
     return NS_OK;
 
   PRInt32 index = FindIndexForCard(card);
   if (index == -1)
     return NS_OK;
 
   AbCard *oldCard = (AbCard*) (mCards.ElementAt(index));
 
-  // malloc these from an arena
+  // Malloc these from an arena
   AbCard *newCard = (AbCard *) PR_Calloc(1, sizeof(struct AbCard));
   if (!newCard)
     return NS_ERROR_OUT_OF_MEMORY;
 
   newCard->card = card;
   NS_IF_ADDREF(newCard->card);
     
   rv = GenerateCollationKeysForCard(mSortColumn.get(), newCard);
@@ -971,46 +971,46 @@ NS_IMETHODIMP nsAbView::OnItemPropertyCh
 
   if (mTreeSelection) {
     rv = mTreeSelection->IsSelected(index, &cardWasSelected);
     NS_ENSURE_SUCCESS(rv,rv);
   }
   
   if (!CompareCollationKeys(newCard->primaryCollationKey,newCard->primaryCollationKeyLen,oldCard->primaryCollationKey,oldCard->primaryCollationKeyLen)
     && CompareCollationKeys(newCard->secondaryCollationKey,newCard->secondaryCollationKeyLen,oldCard->secondaryCollationKey,oldCard->secondaryCollationKeyLen)) {
-    // no need to remove and add, since the collation keys haven't change.
-    // since they haven't chagned, the card will sort to the same place.
-    // we just need to clean up what we allocated.
+    // No need to remove and add, since the collation keys haven't changed.
+    // Since they haven't changed, the card will sort to the same place.
+    // We just need to clean up what we allocated.
     NS_IF_RELEASE(newCard->card);
     if (newCard->primaryCollationKey)
       nsMemory::Free(newCard->primaryCollationKey);
     if (newCard->secondaryCollationKey)
       nsMemory::Free(newCard->secondaryCollationKey);
     PR_FREEIF(newCard);
 
-    // still need to invalidate, as the other columns may have changed
+    // Still need to invalidate, as the other columns may have changed.
     rv = InvalidateTree(index);
     NS_ENSURE_SUCCESS(rv,rv);
   }
   else {
     mSuppressSelectionChange = PR_TRUE;
     mSuppressCountChange = PR_TRUE;
 
-    // remove the old card
+    // Remove the old card.
     rv = RemoveCardAt(index);
     NS_ASSERTION(NS_SUCCEEDED(rv), "remove card failed\n");
 
-    // add the card we created, and select it (to restore selection) if it was selected
+    // Add the card we created, and select it (to restore selection) if it was selected.
     rv = AddCard(newCard, cardWasSelected /* select card */, &index);
     NS_ASSERTION(NS_SUCCEEDED(rv), "add card failed\n");
 
     mSuppressSelectionChange = PR_FALSE;
     mSuppressCountChange = PR_FALSE;
 
-    // ensure restored selection is visible
+    // Ensure restored selection is visible
     if (cardWasSelected && mTree) 
       mTree->EnsureRowIsVisible(index);
   }
 
   // Although the selection hasn't changed, the card that is selected may need
   // to be displayed differently, therefore pretend that the selection has
   // changed to force that update.
   if (cardWasSelected)
@@ -1059,17 +1059,17 @@ nsresult nsAbView::ReselectCards(nsIArra
     if (card) {
       PRInt32 index = FindIndexForCard(card);
       if (index != CARD_NOT_FOUND) {
         mTreeSelection->RangedSelect(index, index, PR_TRUE /* augment */);
       }
     }
   }
 
-  // reset the index card, and ensure it is visible
+  // Reset the index card, and ensure it is visible.
   if (aIndexCard) {
     PRInt32 currentIndex = FindIndexForCard(aIndexCard);
     rv = mTreeSelection->SetCurrentIndex(currentIndex);
     NS_ENSURE_SUCCESS(rv, rv);
   
     if (mTree) {
       rv = mTree->EnsureRowIsVisible(currentIndex);
       NS_ENSURE_SUCCESS(rv, rv);
@@ -1082,17 +1082,17 @@ nsresult nsAbView::ReselectCards(nsIArra
 NS_IMETHODIMP nsAbView::DeleteSelectedCards()
 {
   nsCOMPtr<nsIArray> cardsToDelete;
   
   nsresult rv = GetSelectedCards(getter_AddRefs(cardsToDelete));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // mDirectory should not be null
-  // bullet proof (and assert) to help figure out bug #127748
+  // Bullet proof (and assert) to help figure out bug #127748
   NS_ENSURE_TRUE(mDirectory, NS_ERROR_UNEXPECTED);
 
   rv = mDirectory->DeleteCards(cardsToDelete);
   NS_ENSURE_SUCCESS(rv, rv);
   return rv;
 }
 
 nsresult nsAbView::GetSelectedCards(nsIArray **aSelectedCards)
@@ -1143,18 +1143,18 @@ NS_IMETHODIMP nsAbView::SwapFirstNameLas
   
   PRInt32 selectionCount; 
   nsresult rv = mTreeSelection->GetRangeCount(&selectionCount);
   NS_ENSURE_SUCCESS(rv, rv);
   
   if (!selectionCount)
     return NS_OK;
   
-  // prepare for displayname generation
-  // no cache for pref and bundle since the swap operation is not executed frequently
+  // Prepare for displayname generation
+  // No cache for pref and bundle since the swap operation is not executed frequently
   PRBool displayNameAutoGeneration;
   PRBool displayNameLastnamefirst = PR_FALSE;
 
   nsCOMPtr<nsIPrefBranch2> pPrefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = pPrefBranchInt->GetBoolPref(PREF_MAIL_ADDR_BOOK_DISPLAYNAME_AUTOGENERATION, &displayNameAutoGeneration);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1187,87 +1187,87 @@ NS_IMETHODIMP nsAbView::SwapFirstNameLas
     PRInt32 totalCards = mCards.Count();
     if (startRange >= 0 && startRange < totalCards)
     {
       for (PRInt32 rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < totalCards; rangeIndex++) {
         nsCOMPtr<nsIAbCard> abCard;
         rv = GetCardFromRow(rangeIndex, getter_AddRefs(abCard));
         NS_ENSURE_SUCCESS(rv, rv);
 
-        // swap FN/LN
+        // Swap FN/LN
         nsAutoString fn, ln;
         abCard->GetFirstName(fn);
         abCard->GetLastName(ln);
         if (!fn.IsEmpty() || !ln.IsEmpty())
         {
           abCard->SetFirstName(ln);
           abCard->SetLastName(fn);
 
-          // generate display name using the new order
+          // Generate display name using the new order
           if (displayNameAutoGeneration &&
               !fn.IsEmpty() && !ln.IsEmpty())
           {
             nsString dnLnFn;
             nsString dnFnLn;
             const PRUnichar *nameString[2];
             const PRUnichar *formatString;
 
-            // the format should stays the same before/after we swap the names
+            // The format should stays the same before/after we swap the names
             formatString = displayNameLastnamefirst ?
                               NS_LITERAL_STRING("lastFirstFormat").get() :
                               NS_LITERAL_STRING("firstLastFormat").get();
 
-            // generate both ln/fn and fn/ln combination since we need both later
+            // Generate both ln/fn and fn/ln combination since we need both later
             // to check to see if the current display name was edited
             // note that fn/ln still hold the values before the swap
             nameString[0] = ln.get();
             nameString[1] = fn.get();
             rv = bundle->FormatStringFromName(formatString,
                                               nameString, 2, getter_Copies(dnLnFn));
             NS_ENSURE_SUCCESS(rv, rv);
             nameString[0] = fn.get();
             nameString[1] = ln.get();
             rv = bundle->FormatStringFromName(formatString,
                                               nameString, 2, getter_Copies(dnFnLn));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            // get the current display name
+            // Get the current display name
             nsAutoString dn;
             rv = abCard->GetDisplayName(dn);
             NS_ENSURE_SUCCESS(rv, rv);
 
-            // swap the display name if not edited
+            // Swap the display name if not edited
             if (displayNameLastnamefirst)
             {
               if (dn.Equals(dnLnFn))
                 abCard->SetDisplayName(dnFnLn);
             }
             else
             {
               if (dn.Equals(dnFnLn))
                 abCard->SetDisplayName(dnLnFn);
             }
           }
 
-          // swap phonetic names
+          // Swap phonetic names
           rv = abCard->GetPropertyAsAString(kPhoneticFirstNameProperty, fn);
           NS_ENSURE_SUCCESS(rv, rv);
           rv = abCard->GetPropertyAsAString(kPhoneticLastNameProperty, ln);
           NS_ENSURE_SUCCESS(rv, rv);
           if (!fn.IsEmpty() || !ln.IsEmpty())
           {
             abCard->SetPropertyAsAString(kPhoneticFirstNameProperty, ln);
             abCard->SetPropertyAsAString(kPhoneticLastNameProperty, fn);
           }
         }
       }
     }
   }
-  // update the tree
-  // re-sort if either generated or phonetic name is primary or secondary sort,
+  // Update the tree
+  // Re-sort if either generated or phonetic name is primary or secondary sort,
   // otherwise invalidate to reflect the change
   rv = RefreshTree();
 
   return rv;
 }
 
 NS_IMETHODIMP nsAbView::GetSelectedAddresses(nsIArray **_retval)
 {
--- a/mailnews/addrbook/src/nsAbWinHelper.cpp
+++ b/mailnews/addrbook/src/nsAbWinHelper.cpp
@@ -491,17 +491,17 @@ BOOL nsAbWinHelper::GetPropertyBin(const
                       reinterpret_cast<LPENTRYID>(values->Value.bin.lpb)) ;
     }
     FreeBuffer(values) ;
     return TRUE ;
 }
 
 // This function, supposedly indicating whether a particular entry was
 // in a particular container, doesn't seem to work very well (has
-// a tendancy to return TRUE even if we're talking to different containers...).
+// a tendency to return TRUE even if we're talking to different containers...).
 BOOL nsAbWinHelper::TestOpenEntry(const nsMapiEntry& aContainer, const nsMapiEntry& aEntry)
 {
     nsMapiInterfaceWrapper<LPMAPICONTAINER> container ;
     nsMapiInterfaceWrapper<LPMAPIPROP> subObject ;
     ULONG objType = 0 ;
     
     mLastError = mAddressBook->OpenEntry(aContainer.mByteCount, aContainer.mEntryId,
                                          &IID_IMAPIContainer, 0, &objType, 
--- a/mailnews/addrbook/src/nsAddbookProtocolHandler.h
+++ b/mailnews/addrbook/src/nsAddbookProtocolHandler.h
@@ -48,19 +48,19 @@
 class nsAddbookProtocolHandler : public nsIProtocolHandler
 {
 public:
 	nsAddbookProtocolHandler();
 	virtual ~nsAddbookProtocolHandler();
 
   NS_DECL_ISUPPORTS
 
-	//////////////////////////////////////////////////////////////////////////
-	// we suppport the nsIProtocolHandler interface 
-	//////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////
+  // We support the nsIProtocolHandler interface.
+  //////////////////////////////////////////////////////////////////////////
   NS_DECL_NSIPROTOCOLHANDLER
 
 private:
   nsresult    GenerateXMLOutputChannel(nsString &aOutput,
                                          nsIAddbookUrl *addbookUrl,
                                          nsIURI *aURI, 
                                          nsIChannel **_retval);
 
--- a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp
+++ b/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp
@@ -88,210 +88,199 @@ nsLDAPAutoCompleteSession::~nsLDAPAutoCo
 #define IS_CJK_CHAR_FOR_LDAP(u)  (0x2e80 <= (u) && (u) <= 0xd7ff)
 
 /* void onStartLookup (in wstring searchString, in nsIAutoCompleteResults previousSearchResult, in nsIAutoCompleteListener listener); */
 NS_IMETHODIMP 
 nsLDAPAutoCompleteSession::OnStartLookup(const PRUnichar *searchString, 
                                          nsIAutoCompleteResults *previousSearchResult,
                                          nsIAutoCompleteListener *listener)
 {
-    nsresult rv; // hold return values from XPCOM calls
+    nsresult rv; // Hold return values from XPCOM calls
 
 #ifdef PR_LOGGING
-    // initialize logging, if it hasn't been already
-    //
+    // Initialize logging, if it hasn't been already.
     if (!sLDAPAutoCompleteLogModule) {
         sLDAPAutoCompleteLogModule = PR_NewLogModule("ldapautocomplete");
 
         NS_ABORT_IF_FALSE(sLDAPAutoCompleteLogModule, 
                           "failed to initialize ldapautocomplete log module");
     }
 #endif
 
     PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
            ("nsLDAPAutoCompleteSession::OnStartLookup entered\n"));
     
     if (!listener) {
         NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): NULL listener"
                  "passed in");
         return NS_ERROR_NULL_POINTER;
     } else {
-        mListener = listener;   // save it for later callbacks
+        mListener = listener;   // Save it for later callbacks
     }
 
-    // ignore the empty string, strings with @ in them, and strings
-    // that are too short
-    //
+    // Ignore the empty string, strings with @ in them, and strings
+    // that are too short.
     if (searchString[0] == 0 ||
         nsDependentString(searchString).FindChar(PRUnichar('@'), 0) != -1 || 
         nsDependentString(searchString).FindChar(PRUnichar(','), 0) != -1 || 
         ( !IS_CJK_CHAR_FOR_LDAP(searchString[0]) ?
           mMinStringLength && NS_strlen(searchString) < mMinStringLength :
           mCjkMinStringLength && NS_strlen(searchString) < 
           mCjkMinStringLength ) ) {
 
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::ignored, 0, mState);
         return NS_OK;
     } else {
         mSearchString = searchString;        // save it for later use
     }
 
-    // make sure this was called appropriately.
-    //
+    // Make sure this was called appropriately.
     if (mState == SEARCHING || mState == BINDING) {
         NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): called while "
                  "search already in progress; no lookup started.");
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems,
                                  NS_ERROR_FAILURE, mState);
         return NS_ERROR_FAILURE;
     }
 
     NS_ASSERTION(mFormatter, "nsLDAPAutoCompleteSession::OnStartLookup(): "
                  "formatter attribute has not been set");
 
-    // see if this is a narrow search that we could potentially do locally
-    //
+    // See if this is a narrow search that we could potentially do locally.
     if (previousSearchResult) {
 
-        // get the string representing previous search results
-        //
+        // Get the string representing previous search results.
         nsString prevSearchStr;
 
         rv = previousSearchResult->GetSearchString(
             getter_Copies(prevSearchStr));
         if ( NS_FAILED(rv) ) {
             NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): couldn't "
                      "get search string from previousSearchResult");
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, 
                                      NS_ERROR_FAILURE, mState);
             return NS_ERROR_FAILURE;
         }
 
-        // does the string actually contain anything?
-        //
+        // Does the string actually contain anything?
         if ( prevSearchStr.get() && prevSearchStr.get()[0]) {
 
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                    ("nsLDAPAutoCompleteSession::OnStartLookup(): starting "
                     "narrowing search\n"));
 
-            // XXXdmose for performance, we should really do a local, 
-            // synchronous search against the existing dataset instead of 
+            // XXXdmose for performance, we should really do a local,
+            // synchronous search against the existing dataset instead of
             // just kicking off a new LDAP search here.  When implementing
             // this, need to be sure that only previous results which did not
             // hit the size limit and were successfully completed are used.
             //
             mState = SEARCHING;
             return DoTask();
         }
     }
 
-    // init connection if necesary
+    // Init connection if necessary
     //
     switch (mState) {
     case UNBOUND:
 
-        // initialize the connection.  
+        // Initialize the connection.  
         //
         rv = InitConnection();
         if (NS_FAILED(rv)) {
 
-            // InitConnection() will have already called 
+            // InitConnection() will have already called
             // FinishAutoCompleteLookup for us as necessary
             //
             return rv;
         }
 
         return NS_OK;
 
     case BOUND:
 
         PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                ("nsLDAPAutoComplete::OnStartLookup(): subsequent search "
                 "starting"));
 
-        // kick off an LDAP search
+        // Kick off an LDAP search
         mState = SEARCHING;
         return DoTask();
 
     case INITIALIZING:
         // We don't need to do anything here (for now at least), because
         // we can't really abandon the initialization. If we allowed the
         // initialization to be aborted, we could potentially lock the
         // UI thread again, since the DNS service might be stalled.
         //
         return NS_OK;
 
     case BINDING:
     case SEARCHING:
-        // we should never get here
+        // We should never get here
         NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): unexpected "
                  "value of mStatus");
         return NS_ERROR_UNEXPECTED;
     }
     
     return NS_ERROR_UNEXPECTED;     /*NOTREACHED*/
 }
 
 /* void onStopLookup (); */
 NS_IMETHODIMP 
 nsLDAPAutoCompleteSession::OnStopLookup()
 {
 #ifdef PR_LOGGING
-    // initialize logging, if it hasn't been already
-    //
+    // Initialize logging, if it hasn't been already.
     if (!sLDAPAutoCompleteLogModule) {
         sLDAPAutoCompleteLogModule = PR_NewLogModule("ldapautocomplete");
 
         NS_ABORT_IF_FALSE(sLDAPAutoCompleteLogModule, 
                           "failed to initialize ldapautocomplete log module");
     }
 #endif
 
     PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
            ("nsLDAPAutoCompleteSession::OnStopLookup entered\n"));
 
     switch (mState) {
     case UNBOUND:
-        // nothing to stop
+        // Nothing to stop
         return NS_OK;
 
     case BOUND:
-        // nothing to stop
+        // Nothing to stop
         return NS_OK;
 
     case INITIALIZING:
-        // We can't or shouldn't abor the initialization, because then the
+        // We can't or shouldn't abort the initialization, because then the
         // DNS service can hang again...
         //
         return NS_OK;
 
     case BINDING:
     case SEARCHING:
         // Abandon the operation, if there is one
-        //
         if (mOperation) {
             nsresult rv = mOperation->AbandonExt();
 
             if (NS_FAILED(rv)) {
-                // since there's nothing interesting that can or should be
+                // Since there's nothing interesting that can or should be
                 // done if this abandon failed, warn about it and move on
-                //
                 NS_WARNING("nsLDAPAutoCompleteSession::OnStopLookup(): "
                            "error calling mOperation->AbandonExt()");
             }
 
-            // force nsCOMPtr to release mOperation
-            //
+            // Force nsCOMPtr to release mOperation
             mOperation = 0;
         }
 
         // Set the status properly, set to UNBOUND of we were binding, or
         // to BOUND if we were searching.
-        //
         mState = (mState == BINDING ? UNBOUND : BOUND);
         if (mState == UNBOUND)
           NS_IF_RELEASE(mConnection);
     }
 
     mResultsArray = 0;
     mResults = 0;
     mListener = 0;
@@ -301,20 +290,20 @@ nsLDAPAutoCompleteSession::OnStopLookup(
 
 /* void onAutoComplete (in wstring searchString, in nsIAutoCompleteResults previousSearchResult, in nsIAutoCompleteListener listener); */
 NS_IMETHODIMP 
 nsLDAPAutoCompleteSession::OnAutoComplete(const PRUnichar *searchString, 
                                  nsIAutoCompleteResults *previousSearchResult, 
                                           nsIAutoCompleteListener *listener)
 {
     // OnStopLookup should have already been called, so there's nothing to
-    // free here.  Additionally, as of this writing, noone is hanging around 
-    // waiting for mListener->OnAutoComplete() to be called either, and if 
-    // they were, it's unclear what we'd return, since we're not guaranteed 
-    // to be in any particular state.  My suspicion is that this method 
+    // free here.  Additionally, as of this writing, no one is hanging around
+    // waiting for mListener->OnAutoComplete() to be called either, and if
+    // they were, it's unclear what we'd return, since we're not guaranteed
+    // to be in any particular state.  My suspicion is that this method
     // (nsIAutoCompleteSession::OnAutoComplete) should probably be removed
     // from the interface.
 
     return NS_OK;
 }
 
 /**
  * Messages received are passed back via this function.
@@ -323,78 +312,72 @@ nsLDAPAutoCompleteSession::OnAutoComplet
  *
  * void OnLDAPMessage (in nsILDAPMessage aMessage)
  */
 NS_IMETHODIMP 
 nsLDAPAutoCompleteSession::OnLDAPMessage(nsILDAPMessage *aMessage)
 {
     PRInt32 messageType;
 
-    // just in case.
+    // Just in case.
     // XXXdmose the semantics of NULL are currently undefined, but are likely
     // to be defined once we insert timeout handling code into the XPCOM SDK
     // At that time we should figure out if this still the right thing to do.
-    // 
     if (!aMessage) {
         return NS_OK;
     }
 
-    // figure out what sort of message was returned
-    //
+    // Figure out what sort of message was returned.
     nsresult rv = aMessage->GetType(&messageType);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPMessage(): unexpected "
                  "error in aMessage->GetType()");
        
-        // don't call FinishAutoCompleteLookup(), as this could conceivably 
-        // be an anomaly, and perhaps the next message will be ok.  if this
+        // Don't call FinishAutoCompleteLookup(), as this could conceivably 
+        // be an anomaly, and perhaps the next message will be ok. If this
         // really was a problem, this search should eventually get
         // reaped by a timeout (once that code gets implemented).
-        //
         return NS_ERROR_UNEXPECTED;
     }
 
-    // if this message is not associated with the current operation, 
-    // discard it, since it is probably from a previous (aborted) 
-    // operation
-    //
+    // If this message is not associated with the current operation,
+    // discard it, since it is probably from a previous (aborted)
+    // operation.
     PRBool isCurrent;
     rv = IsMessageCurrent(aMessage, &isCurrent);
     if (NS_FAILED(rv)) {
         // IsMessageCurrent will have logged any necessary errors
         return rv;
     }
     if ( ! isCurrent ) {
         PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG,
                ("nsLDAPAutoCompleteSession::OnLDAPMessage(): received message "
                 "from operation other than current one; discarded"));
         return NS_OK;
     }
 
     // XXXdmose - we may want a small state machine either here or
-    // or in the nsLDAPConnection object, to make sure that things are 
-    // happening in the right order and timing out appropriately.  this will
+    // or in the nsLDAPConnection object, to make sure that things are
+    // happening in the right order and timing out appropriately. This will
     // certainly depend on how timeouts are implemented, and how binding
-    // gets is dealt with by nsILDAPService.  also need to deal with the case
+    // gets is dealt with by nsILDAPService. Also need to deal with the case
     // where a bind callback happens after onStopLookup was called.
-    // 
     switch (messageType) {
 
     case nsILDAPMessage::RES_BIND:
 
-        // a bind has completed
-        //
+        // A bind has completed
         if (mState != BINDING) {
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                    ("nsLDAPAutoCompleteSession::OnLDAPMessage(): LDAP bind "
                     "entry returned after OnStopLookup() called; ignoring"));
 
-            // XXXdmose when nsLDAPService integration happens, need to make 
-            // sure that the possibility of having an already bound 
-            // connection, due to a previously unaborted bind, doesn't cause 
+            // XXXdmose when nsLDAPService integration happens, need to make
+            // sure that the possibility of having an already bound
+            // connection, due to a previously unaborted bind, doesn't cause
             // any problems.
 
             return NS_OK;
         }
 
         rv = OnLDAPMessageBind(aMessage);
         if (NS_FAILED(rv)) {
           mState = UNBOUND;
@@ -403,67 +386,62 @@ nsLDAPAutoCompleteSession::OnLDAPMessage
         }
         else
           mState = SEARCHING;
 
         return rv;
 
     case nsILDAPMessage::RES_SEARCH_ENTRY:
         
-        // ignore this if OnStopLookup was already called
-        //
+        // Ignore this if OnStopLookup was already called.
         if (mState != SEARCHING) {
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                    ("nsLDAPAutoCompleteSession::OnLDAPMessage(): LDAP search "
                     "entry returned after OnStopLoookup() called; ignoring"));
             return NS_OK;
         }
 
-        // a search entry has been returned
-        //
+        // A search entry has been returned.
         return OnLDAPSearchEntry(aMessage);
 
     case nsILDAPMessage::RES_SEARCH_RESULT:
 
-        // ignore this if OnStopLookup was already called
-        //
+        // Ignore this if OnStopLookup was already called.
         if (mState != SEARCHING) {
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG,
                    ("nsLDAPAutoCompleteSession::OnLDAPMessage(): LDAP search "
                     "result returned after OnStopLookup called; ignoring"));
             return NS_OK;
         }
 
-        // the search is finished; we're all done
-        //  
+        // The search is finished; we're all done.
         return OnLDAPSearchResult(aMessage);
 
     default:
         
         // Given the LDAP operations nsLDAPAutoCompleteSession uses, we should
-        // never get here.  If we do get here in a release build, it's
+        // never get here. If we do get here in a release build, it's
         // probably a bug, but maybe it's the LDAP server doing something
-        // weird.  Might as well try and continue anyway.  The session should
+        // weird. Might as well try and continue anyway. The session should
         // eventually get reaped by the timeout code, if necessary.
         //
         NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPMessage(): unexpected "
                  "LDAP message received");
         return NS_OK;
     }
 }
 
 void
 nsLDAPAutoCompleteSession::InitFailed(PRBool aCancelled)
 {
   FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, 0,
                            UNBOUND);
 }
 
 // void onLDAPInit (in nsresult aStatus);
-//
 NS_IMETHODIMP
 nsLDAPAutoCompleteSession::OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus)
 {
   nsresult rv = nsAbLDAPListenerBase::OnLDAPInit(aConn, aStatus);
 
   if (NS_SUCCEEDED(rv))
     mState = BINDING;
 
@@ -471,147 +449,138 @@ nsLDAPAutoCompleteSession::OnLDAPInit(ns
 }
 
 nsresult
 nsLDAPAutoCompleteSession::OnLDAPSearchEntry(nsILDAPMessage *aMessage)
 {
     PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
            ("nsLDAPAutoCompleteSession::OnLDAPSearchEntry entered\n"));
 
-    // make sure this is only getting called after DoTask has 
-    // initialized the result set
-    //
+    // Make sure this is only getting called after DoTask has
+    // initialized the result set.
     NS_ASSERTION(mResultsArray,
                  "nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
                  "mResultsArrayItems is uninitialized");
 
     // Errors in this method return an error (which ultimately gets
     // ignored, since this is being called through an async proxy).
     // But the important thing is that we're bailing out here rather
-    // than trying to generate a bogus nsIAutoCompleteItem.  Also note
+    // than trying to generate a bogus nsIAutoCompleteItem. Also note
     // that FinishAutoCompleteLookup is _NOT_ being called here, because
     // this error may just have to do with this particular item.
 
-    // generate an autocomplete item from this message by calling the
-    // formatter
-    //
+    // Generate an autocomplete item from this message by calling the
+    // formatter.
     nsCOMPtr<nsIAutoCompleteItem> item;
     nsresult rv = mFormatter->Format(aMessage, getter_AddRefs(item));
     if (NS_FAILED(rv)) {
         PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG,
                ("nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
                 "mFormatter->Format() failed"));
         return NS_ERROR_FAILURE;
     }
 
     rv = mResultsArray->AppendElement(item);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
                  "mItems->AppendElement() failed");
         return NS_ERROR_FAILURE;
     }
 
-    // remember that something has been returned
-    //
+    // Remember that something has been returned.
     mEntriesReturned++;
 
     return NS_OK;
 }
 
 nsresult
 nsLDAPAutoCompleteSession::OnLDAPSearchResult(nsILDAPMessage *aMessage)
 {
-    nsresult rv;        // temp for return vals
+    nsresult rv;        // Temp for return vals
 
     PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
            ("nsLDAPAutoCompleteSession::OnLDAPSearchResult entered\n"));
 
-    // figure out if we succeeded or failed, and set the status 
-    // and default index appropriately
-    //
+    // Figure out if we succeeded or failed, and set the status
+    // and default index appropriately.
     AutoCompleteStatus status;
     PRInt32 lderrno;
 
     if (mEntriesReturned) {
 
         status = nsIAutoCompleteStatus::matchFound;
 
-        // there's at least one match, so the default index should
+        // There's at least one match, so the default index should
         // point to the first thing here.  This ensures that if the local
-        // addressbook autocomplete session only found foo@local.domain, 
-        // this will be given preference
-        //
+        // addressbook autocomplete session only found foo@local.domain,
+        // this will be given preference.
         rv = mResults->SetDefaultItemIndex(0);
         if (NS_FAILED(rv)) {
             NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchResult(): "
                      "mResults->SetDefaultItemIndex(0) failed");
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      BOUND);
         }
     } else {
-        // note that we only look at the error code if there are no results for
+        // Note that we only look at the error code if there are no results for
         // this session; if we got results and then an error happened, this
         // is ignored, in part because it seems likely to be confusing to the
-        // user, and in part because it is likely to be scrolled out of view 
-        // anyway
-        //
+        // user, and in part because it is likely to be scrolled out of view
+        // anyway.
         aMessage->GetErrorCode(&lderrno);
         if (lderrno != nsILDAPErrors::SUCCESS) {
 
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                    ("nsLDAPAutoCompleteSession::OnLDAPSearchResult(): "
                     "lderrno=%d\n", lderrno));
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, 
                                      NS_ERROR_GENERATE_FAILURE(
                                          NS_ERROR_MODULE_LDAP, lderrno), 
                                      BOUND);
             return NS_OK;
         }
 
-        // we could potentially keep track of non-fatal errors to the 
+        // We could potentially keep track of non-fatal errors to the
         // search, and if there has been more than 1, and there are no entries,
-        // we could return |failed| instead of |noMatch|.  It's unclear to me
+        // we could return |failed| instead of |noMatch|. It's unclear to me
         // that this actually buys us anything though.
-        //
         status = nsIAutoCompleteStatus::noMatch;
     }
 
-    // call the mListener's OnAutoComplete and clean up
+    // Call the mListener's OnAutoComplete and clean up
     //
     // XXXdmose should we really leave the connection BOUND here?
     FinishAutoCompleteLookup(status, NS_OK, BOUND);
 
     return NS_OK;
 }
 
 nsresult
 nsLDAPAutoCompleteSession::DoTask()
 {
     nsresult rv; // temp for xpcom return values
     nsCOMPtr<nsILDAPMessageListener> selfProxy; // for callback
 
     PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
            ("nsLDAPAutoCompleteSession::DoTask entered\n"));
 
-    // create and initialize an LDAP operation (to be used for the search
-    //  
+    // Create and initialize an LDAP operation (to be used for the search).
     mOperation = 
         do_CreateInstance("@mozilla.org/network/ldap-operation;1", &rv);
 
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
                  "create @mozilla.org/network/ldap-operation;1");
 
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  BOUND);
         return NS_ERROR_FAILURE;
     }
 
-    // get a proxy object so the callback happens on the main thread
-    //
+    // Get a proxy object so the callback happens on the main thread.
     nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
     if (NS_FAILED(rv)) {
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, UNBOUND);
         return NS_ERROR_FAILURE;
     }
     rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
                               NS_GET_IID(nsILDAPMessageListener), 
                               static_cast<nsILDAPMessageListener *>(this), 
@@ -620,28 +589,27 @@ nsLDAPAutoCompleteSession::DoTask()
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
                  "create proxy to this object for callback");
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  BOUND);
         return NS_ERROR_FAILURE;
     }
 
-    // initialize the LDAP operation object
-    //
+    // Initialize the LDAP operation object.
     rv = mOperation->Init(mConnection, selfProxy, nsnull);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
                  "initialize LDAP operation");
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  BOUND);
         return NS_ERROR_UNEXPECTED;
     }
 
-    // set the server and client controls on the operation
+    // Set the server and client controls on the operation.
     if (mSearchServerControls) {
         rv = mOperation->SetServerControls(mSearchServerControls);
         if (NS_FAILED(rv)) {
             NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
                      "initialize LDAP search operation server controls");
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      BOUND);
             return NS_ERROR_UNEXPECTED;
@@ -653,63 +621,58 @@ nsLDAPAutoCompleteSession::DoTask()
             NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
                      "initialize LDAP search operation client controls");
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      BOUND);
             return NS_ERROR_UNEXPECTED;
         }
     }
 
-    // get the search filter associated with the directory server url; 
+    // Get the search filter associated with the directory server url;
     // it will be ANDed with the rest of the search filter that we're using.
-    //
     nsCAutoString urlFilter;
     rv = mDirectoryUrl->GetFilter(urlFilter);
     if ( NS_FAILED(rv) ){
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
                                  BOUND);
         return NS_ERROR_UNEXPECTED;
     }
 
-    // get the LDAP service, since createFilter is called through it.
-    //
+    // Get the LDAP service, since createFilter is called through it.
     nsCOMPtr<nsILDAPService> ldapSvc = do_GetService(
         "@mozilla.org/network/ldap-service;1", &rv);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
                  "get @mozilla.org/network/ldap-service;1");
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
                                  BOUND);
         return NS_ERROR_FAILURE;
     }
 
-    // if urlFilter is unset (or set to the default "objectclass=*"), there's
-    // no need to AND in an empty search term, so leave prefix and suffix empty
-    //
+    // If urlFilter is unset (or set to the default "objectclass=*"), there's
+    // no need to AND in an empty search term, so leave prefix and suffix empty.
     nsCAutoString prefix, suffix;
     if (urlFilter.Length() && !urlFilter.Equals(NS_LITERAL_CSTRING("(objectclass=*)"))) {
 
-        // if urlFilter isn't parenthesized, we need to add in parens so that
+        // If urlFilter isn't parenthesized, we need to add in parens so that
         // the filter works as a term to &
-        //
         if (urlFilter[0] != '(') {
             prefix.AssignLiteral("(&(");
             prefix.Append(urlFilter);
             prefix.AppendLiteral(")");
         } else {
             prefix.AssignLiteral("(&");
             prefix.Append(urlFilter);
         }
         
         suffix = ')';
     }
 
-    // generate an LDAP search filter from mFilterTemplate.  If it's unset,
+    // Generate an LDAP search filter from mFilterTemplate. If it's unset,
     // use the default.
-    //
 #define MAX_AUTOCOMPLETE_FILTER_SIZE 1024
     nsCAutoString searchFilter;
     rv = ldapSvc->CreateFilter(MAX_AUTOCOMPLETE_FILTER_SIZE,
                                mFilterTemplate,
                                prefix, suffix, EmptyCString(), 
                                NS_ConvertUTF16toUTF8(mSearchString),
                                searchFilter);
     if (NS_FAILED(rv)) {
@@ -728,62 +691,57 @@ nsLDAPAutoCompleteSession::DoTask()
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
                                      BOUND);
             return rv;
 
         case NS_ERROR_INVALID_ARG:
         case NS_ERROR_UNEXPECTED:
         default:
 
-            // all this stuff indicates code bugs
-            //
+            // All this stuff indicates code bugs.
             NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): "
                      "createFilter returned unexpected value");
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      BOUND);
             return NS_ERROR_UNEXPECTED;
         }
 
     }
 
     // If the results array for this search hasn't already been created, do
-    // so now.  Note that we don't return ::failureItems here, because if
+    // so now. Note that we don't return ::failureItems here, because if
     // there's no array, there's nowhere to put the items.
-    //
     rv = CreateResultsArray();
     if (NS_FAILED(rv)) {
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failed, rv, BOUND);
     }
 
-    // nothing returned yet!
-    //
+    // Nothing returned yet!
     mEntriesReturned = 0;
     
-    // get the base dn to search
-    //
+    // Get the base dn to search
     nsCAutoString dn;
     rv = mDirectoryUrl->GetDn(dn);
     if ( NS_FAILED(rv) ){
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
                                  BOUND);
         return NS_ERROR_UNEXPECTED;
     }
 
-    // and the scope
-    //
+    // And the scope
     PRInt32 scope;
     rv = mDirectoryUrl->GetScope(&scope);
     if ( NS_FAILED(rv) ){
         mState = BOUND;
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  BOUND);
         return NS_ERROR_UNEXPECTED;
     }
 
-    // take the relevant controls on this object and set them
+    // Take the relevant controls on this object and set them
     // on the operation
     rv = mOperation->SetServerControls(mSearchServerControls.get());
     if ( NS_FAILED(rv) ){
         mState = BOUND;
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  BOUND);
         return NS_ERROR_UNEXPECTED;
     }
@@ -791,17 +749,17 @@ nsLDAPAutoCompleteSession::DoTask()
     rv = mOperation->SetClientControls(mSearchClientControls.get());
     if ( NS_FAILED(rv) ){
         mState = BOUND;
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  BOUND);
         return NS_ERROR_UNEXPECTED;
     }
 
-    // time to kick off the search.
+    // Time to kick off the search.
     //
     // XXXdmose what about timeouts? 
     //
     rv = mOperation->SearchExt(dn, scope, searchFilter, mSearchAttrsSize,
                                const_cast<const char **>(mSearchAttrs),
                                0, mMaxHits);
     if (NS_FAILED(rv)) {
         switch(rv) {
@@ -818,18 +776,18 @@ nsLDAPAutoCompleteSession::DoTask()
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                    ("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
                     "returned NS_ERROR_LDAP_FILTER_ERROR"));
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      BOUND);
             return NS_OK;
 
         case NS_ERROR_LDAP_SERVER_DOWN:
-            // XXXdmose discuss with leif how to handle this in general in the 
-            // LDAP XPCOM SDK.  
+            // XXXdmose discuss with leif how to handle this in general in the
+            // LDAP XPCOM SDK.
 
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                    ("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
                     "returned NS_ERROR_LDAP_SERVER_DOWN"));
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
                                      UNBOUND);
             return NS_OK;
 
@@ -838,18 +796,17 @@ nsLDAPAutoCompleteSession::DoTask()
                                      BOUND);
             return NS_ERROR_OUT_OF_MEMORY;
 
         case NS_ERROR_LDAP_NOT_SUPPORTED:
         case NS_ERROR_NOT_INITIALIZED:        
         case NS_ERROR_INVALID_ARG:
         default:
 
-            // all this stuff indicates code bugs
-            //
+            // All this stuff indicates code bugs.
             NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
                      "returned unexpected value");
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      BOUND);
             return NS_ERROR_UNEXPECTED;
         }
     }
 
@@ -861,42 +818,39 @@ nsLDAPAutoCompleteSession::DoTask()
 nsresult
 nsLDAPAutoCompleteSession::InitConnection()
 {
     nsresult rv;        // temp for xpcom return values
     nsCOMPtr<nsILDAPMessageListener> selfProxy;
     
     NS_ASSERTION(!mConnection, "in InitConnection w/ existing connection");
 
-    // create an LDAP connection
-    //
+    // Create an LDAP connection
     nsCOMPtr<nsILDAPConnection> connection =
       do_CreateInstance("@mozilla.org/network/ldap-connection;1", &rv);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::InitConnection(): could "
                  "not create @mozilla.org/network/ldap-connection;1");
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  UNBOUND);
         return NS_ERROR_FAILURE;
     }
 
     NS_ADDREF(mConnection = connection);
 
-    // have we been properly initialized?
-    //
+    // Have we been properly initialized?
     if (!mDirectoryUrl) {
         NS_ERROR("nsLDAPAutoCompleteSession::InitConnection(): mDirectoryUrl "
                  "is NULL");
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  UNBOUND);
         return NS_ERROR_NOT_INITIALIZED;
     }
 
-    // get a proxy object so the callback happens on the main thread
-    //
+    // Get a proxy object so the callback happens on the main thread.
     nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
     if (NS_FAILED(rv)) {
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, UNBOUND);
         return NS_ERROR_FAILURE;
     }
     rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, 
                               NS_GET_IID(nsILDAPMessageListener), 
                               static_cast<nsILDAPMessageListener *>(this), 
@@ -908,17 +862,16 @@ nsLDAPAutoCompleteSession::InitConnectio
         FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                  UNBOUND);
         return NS_ERROR_FAILURE;
     }
 
     // Initialize the connection. This will cause an asynchronous DNS
     // lookup to occur, and we'll finish the binding of the connection
     // in the OnLDAPInit() listener function.
-    //
     rv = mConnection->Init(mDirectoryUrl, mLogin, selfProxy, nsnull, mVersion);
     if (NS_FAILED(rv)) {
         switch (rv) {
 
         case NS_ERROR_OUT_OF_MEMORY:
         case NS_ERROR_NOT_AVAILABLE:
         case NS_ERROR_FAILURE:
             PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
@@ -931,51 +884,47 @@ nsLDAPAutoCompleteSession::InitConnectio
         case NS_ERROR_ILLEGAL_VALUE:
         default:
             FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
                                      UNBOUND);
             return NS_ERROR_UNEXPECTED;
         }
     }
 
-    // set our state
-    //
+    // Set our state
     mState = INITIALIZING;
 
     return NS_OK;
 }
 
 nsresult
 nsLDAPAutoCompleteSession::CreateResultsArray(void)
 {
     nsresult rv;
 
-    // create a result set
-    //
+    // Create a result set
     mResults = do_CreateInstance(NS_AUTOCOMPLETERESULTS_CONTRACTID, &rv);
 
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::DoTask() couldn't"
                  " create " NS_AUTOCOMPLETERESULTS_CONTRACTID);
         return NS_ERROR_FAILURE;
     }
 
     // This seems to be necessary for things to work, though I'm not sure
     // why that's true.
-    //
     rv = mResults->SetSearchString(mSearchString.get());
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchResult(): couldn't "
                  "set search string in results object");
         return NS_ERROR_FAILURE;
     }
 
-    // get a pointer to the array in question now, so that we don't have to
-    // keep re-fetching it every time an entry callback happens
-    //
+    // Get a pointer to the array in question now, so that we don't have to
+    // keep re-fetching it every time an entry callback happens.
     rv = mResults->GetItems(getter_AddRefs(mResultsArray));
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::DoTask() couldn't "
                  "get results array.");
         return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
@@ -984,115 +933,107 @@ nsLDAPAutoCompleteSession::CreateResults
 void
 nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(
     AutoCompleteStatus aACStatus, const nsresult aResult,
     enum SessionState aEndState)
 {
     nsCOMPtr<nsIAutoCompleteItem> errorItem; // pointer to item we may create
     nsresult rv; // temp for return value 
 
-    // if there's a listener, inform the listener that the search is over
-    //
+    // If there's a listener, inform the listener that the search is over.
     rv = NS_OK;
     if (mListener) {
         
         switch (aACStatus) {
 
         case nsIAutoCompleteStatus::matchFound:
             rv = mListener->OnAutoComplete(mResults, aACStatus);
             break;
 
         case nsIAutoCompleteStatus::failureItems:
-            // if the results array hasn't already been created, make one
+            // If the results array hasn't already been created, make one
             // to return the error message.  If there's an error, fallback
             // to ::failed
-            //
             if (!mResults) {
                 rv = CreateResultsArray();
                 if (NS_FAILED(rv)) {
                     NS_ERROR("nsLDAPAutoCompleteSession::"
                              "FinishAutoCompleteLookup():"
                              " CreateResultsArray() failed");
                     rv = mListener->OnAutoComplete(0, 
                                                 nsIAutoCompleteStatus::failed);
                     break;
                 }
             }
 
-            // create the error item
-            //
+            // Create the error item.
             rv = mFormatter->FormatException(mState, aResult,
                                              getter_AddRefs(errorItem));
             if (NS_SUCCEEDED(rv)) {
 
-                // try and append the error item; falling back to ::failed
-                // if there's a problem 
+                // Try and append the error item; falling back to ::failed
+                // if there's a problem.
                 //
                 rv = mResultsArray->AppendElement(errorItem);
                 if (NS_FAILED(rv)) {
                     NS_ERROR("nsLDAPAutoCompleteSession::"
                              "FinishAutoCompleteLookup():"
                              " mItems->AppendElement() failed");
                     rv = mListener->OnAutoComplete(0, 
                                                 nsIAutoCompleteStatus::failed);
                     break;
                 } 
 
-                // we don't want the autocomplete widget trying to 
-                // automagically use the error item for anything.  If 
+                // We don't want the autocomplete widget trying to
+                // automagically use the error item for anything. If
                 // something goes wrong here, continue on anyway.
                 //
                 (void)mResults->SetDefaultItemIndex(-1);
 
                 rv = mListener->OnAutoComplete(mResults, 
                                           nsIAutoCompleteStatus::failureItems);
                 break;
             } 
 
-            // fallback to ::failed
+            // Fallback to ::failed
             NS_ERROR("nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(): "
                      "error calling FormatException()");
 
             rv = mListener->OnAutoComplete(0, nsIAutoCompleteStatus::failed);
             break;
         
         case nsIAutoCompleteStatus::failed:
         default:
             rv = mListener->OnAutoComplete(0, aACStatus);
             break;
         }
 
     } else {
-        // if there's no listener, something's wrong 
-        // 
+        // If there's no listener, something's wrong.
         NS_ERROR("nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(): "
                  "called with mListener unset!");
     }
 
     if (NS_FAILED(rv)) {
 
-        // there's nothing we can actually do here other than warn
-        //
+        // There's nothing we can actually do here other than warn.
         NS_WARNING("nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(): "
                    "error calling mListener->OnAutoComplete()");
     }
 
-    // set the state appropriately
-    //
+    // Set the state appropriately.
     mState = aEndState;
 
-    // we're done with various things; cause nsCOMPtr to release them
-    //
+    // We're done with various things; cause nsCOMPtr to release them.
     mResultsArray = 0;
     mResults = 0;
     mListener = 0;
     mOperation = 0;
 
-    // If we are unbound, drop the connection (if any)
-    //
+    // If we are unbound, drop the connection (if any).
     if (mState == UNBOUND) {
         NS_IF_RELEASE(mConnection);
     }
 }
 
 // methods for nsILDAPAutoCompleteSession
 
 // attribute AUTF8String searchFilter;
@@ -1150,23 +1091,22 @@ NS_IMETHODIMP
 nsLDAPAutoCompleteSession::SetServerURL(nsILDAPURL * aServerURL)
 {
     if (! aServerURL ) {
         return NS_ERROR_NULL_POINTER;
     }
 
     mDirectoryUrl = aServerURL;
 
-    // the following line will cause the next call to OnStartLookup to 
-    // call InitConnection again.  This will reinitialize all the relevant
-    // member variables and kick off an LDAP bind.  By virtue of the magic of 
+    // The following line will cause the next call to OnStartLookup to
+    // call InitConnection again. This will reinitialize all the relevant
+    // member variables and kick off an LDAP bind. By virtue of the magic of
     // nsCOMPtrs, doing this will cause all the nsISupports-based stuff to
     // be Released, which will eventually result in the old connection being
     // destroyed, and the destructor for that calls ldap_unbind()
-    //
     mState = UNBOUND;
 
     return NS_OK;
 }
 
 // attribute unsigned long minStringLength
 NS_IMETHODIMP
 nsLDAPAutoCompleteSession::GetMinStringLength(PRUint32 *aMinStringLength)
@@ -1200,54 +1140,49 @@ nsLDAPAutoCompleteSession::GetCjkMinStri
 NS_IMETHODIMP
 nsLDAPAutoCompleteSession::SetCjkMinStringLength(PRUint32 aCjkMinStringLength)
 {
     mCjkMinStringLength = aCjkMinStringLength;
 
     return NS_OK;
 }
 
-// check to see if the message returned is related to our current operation
-// if there is no current operation, it's not.  :-)
-//
+// Check to see if the message returned is related to our current operation
+// if there is no current operation, it's not. :-)
 nsresult 
 nsLDAPAutoCompleteSession::IsMessageCurrent(nsILDAPMessage *aMessage, 
                                             PRBool *aIsCurrent)
 {
-    // if there's no operation, this message must be stale (ie non-current)
-    //
+    // If there's no operation, this message must be stale (ie non-current).
     if ( !mOperation ) {
         *aIsCurrent = PR_FALSE;
         return NS_OK;
     }
 
-    // get the message id from the current operation
-    //
+    // Get the message id from the current operation.
     PRInt32 currentId;
     nsresult rv = mOperation->GetMessageID(&currentId);
     if (NS_FAILED(rv)) {
         PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                ("nsLDAPAutoCompleteSession::IsMessageCurrent(): unexpected "
                 "error 0x%lx calling mOperation->GetMessageId()", rv));
         return NS_ERROR_UNEXPECTED;
     }
 
-    // get the message operation from the message
-    //
+    // Get the message operation from the message.
     nsCOMPtr<nsILDAPOperation> msgOp;
     rv = aMessage->GetOperation(getter_AddRefs(msgOp));
     if (NS_FAILED(rv)) {
         PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                ("nsLDAPAutoCompleteSession::IsMessageCurrent(): unexpected "
                 "error 0x%lx calling aMessage->GetOperation()", rv));
         return NS_ERROR_UNEXPECTED;
     }
 
-    // get the message operation id from the message operation
-    //
+    // Get the message operation id from the message operation.
     PRInt32 msgOpId;
     rv = msgOp->GetMessageID(&msgOpId);
     if (NS_FAILED(rv)) {
         PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
                ("nsLDAPAutoCompleteSession::IsMessageCurrent(): unexpected "
                 "error 0x%lx calling msgOp->GetMessageId()", rv));
         return NS_ERROR_UNEXPECTED;
     }
@@ -1283,18 +1218,17 @@ nsLDAPAutoCompleteSession::SetFormatter(
     mFormatter = aFormatter;
 
     // Ensure any old data is freed if necessary.
     if (mSearchAttrs) {
         NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mSearchAttrsSize, mSearchAttrs);
         mSearchAttrs = nsnull;
     }
 
-    // get and cache the attributes that will be used to do lookups
-    //
+    // Get and cache the attributes that will be used to do lookups.
     nsresult rv = mFormatter->GetAttributes(&mSearchAttrsSize, &mSearchAttrs);
     if (NS_FAILED(rv)) {
         NS_ERROR("nsLDAPAutoCompleteSession::SetFormatter(): "
                  " mFormatter->GetAttributes failed");
         return NS_ERROR_FAILURE;
     }
     
     return NS_OK;
--- a/mailnews/addrbook/test/unit/test_collection.js
+++ b/mailnews/addrbook/test/unit/test_collection.js
@@ -6,17 +6,17 @@
  * nsIAbAddressCollecter::getCardFromAttribute if its kept.
  */
 
 const nsIAbPMF = Components.interfaces.nsIAbPreferMailFormat;
 
 // Source fields (emailHeader/mailFormat) and expected results for use for
 // testing the addition of new addresses to the database.
 //
-// Note: these email addressess should be different to allow collecting an
+// Note: these email addresses should be different to allow collecting an
 // address to add a different card each time.
 var addEmailChecks =
   // First 3 items aimed at basic collection and mail format.
   [ { emailHeader: "test0@invalid.com",
       primaryEmail: "test0@invalid.com",
       mailFormat: nsIAbPMF.unknown,
       displayName: "",
       firstName: "",
--- a/mailnews/base/public/nsIMessenger.idl
+++ b/mailnews/base/public/nsIMessenger.idl
@@ -89,34 +89,34 @@ interface nsIMessenger : nsISupports {
     void saveAttachmentToFile(in nsIFile aFile, in ACString aUrl, in ACString aMessageUri, 
                               in ACString aContentType, in nsIUrlListener aListener);
     
     void detachAttachment(in string contentTpe, in string url, in string displayName, in string messageUri, in boolean saveFirst, [optional] in boolean withoutWarning);
     void detachAllAttachments(in unsigned long count, [array, size_is(count)] in string contentTypeArray,
                              [array, size_is(count)] in string urlArray, [array, size_is(count)] in string displayNameArray,
                              [array, size_is(count)] in string messageUriArray, in boolean saveFirst, [optional] in boolean withoutWarning);
     // saveAttachmentToFolder is used by the drag and drop code to drop an attachment to a destination folder
-    // we need to return the actual file path (including the filename).
+    // We need to return the actual file path (including the filename).
     nsILocalFile saveAttachmentToFolder(in ACString contentType, in ACString url, in ACString displayName, in ACString messageUri, in nsILocalFile aDestFolder);
 
     attribute boolean sendingUnsentMsgs;
 
     readonly attribute ACString lastDisplayedMessageUri;
 
     nsIMsgMessageService messageServiceFromURI(in ACString aUri);
     nsIMsgDBHdr msgHdrFromURI(in ACString aUri);
-    // for back forward history, we need a list of visited messages,
+    // For back forward history, we need a list of visited messages,
     // and where we are in the list.
     
     // aPos is relative to the current history cursor - 1 is forward, -1 is back.
     // Unfortunately, you must call this before navigating to this position,
     // because calling this has the side effect of making us adjust our current
     // history pos, and *not* adding the loaded message to the history queue.
     ACString getMsgUriAtNavigatePos(in long aPos);
     ACString getFolderUriAtNavigatePos(in long aPos);
     attribute long navigatePos;
-    // if caller just wants the count and cur pos, they can pass in a null history pointer, which will be more efficent
+    // If caller just wants the count and cur pos, they can pass in a null history pointer, which will be more efficient
     // if they want a list suitable for display in a back/forward menu drop down, they should pass in a aHistory pointer,
     // and they'll get returned an array with strings containing something like subject and sender of the message - 
     // other possible info is the folder containing the message, and the preview text, if available.
     void getNavigateHistory(out unsigned long aCurPos, out unsigned long aCount, [array, size_is(aCount)] out string aHistory);
 };
 
--- a/mailnews/base/public/nsIMessengerOSIntegration.idl
+++ b/mailnews/base/public/nsIMessengerOSIntegration.idl
@@ -36,12 +36,12 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 [scriptable, uuid(d9e45fee-1dd1-11b2-938c-9147855ed837)]
 interface nsIMessengerOSIntegration : nsISupports {
   // for now, nothing.  it's up to the implementation to 
-  // do all the work of registering itsself as listeners
+  // do all the work of registering itself as listeners
   // all we guarantee is your service will be created
   // when accounts are loaded by the account manager
 };