Bug 594239 - Fix arguments of Simple MAPI functions that should be LPSTR. r=jorgk
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 19 Jan 2019 06:43:00 +0100
changeset 33396 ba263124fbff
parent 33395 fec3b0d58634
child 33397 751f07fd6874
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs594239
Bug 594239 - Fix arguments of Simple MAPI functions that should be LPSTR. r=jorgk
mailnews/mapi/mapiDll/MapiDll.cpp
mailnews/mapi/mapihook/build/msgMapi.idl
mailnews/mapi/mapihook/src/msgMapiHook.cpp
mailnews/mapi/mapihook/src/msgMapiHook.h
mailnews/mapi/mapihook/src/msgMapiImp.cpp
mailnews/mapi/mapihook/src/msgMapiImp.h
mailnews/mapi/mapihook/src/msgMapiMain.cpp
mailnews/mapi/mapihook/src/msgMapiMain.h
--- a/mailnews/mapi/mapiDll/MapiDll.cpp
+++ b/mailnews/mapi/mapiDll/MapiDll.cpp
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #pragma warning (disable : 4996) // MAPILogoff is deprecated
 
 #include <windows.h>
-#include <tchar.h>
 #include <mapidefs.h>
 #include <mapi.h>
 #include "msgMapi.h"
 
 #define MAX_RECIPS  2000
 #define MAX_FILES   100
 
 
@@ -104,57 +103,28 @@ BOOL InitMozillaReference(nsIMapi **aRet
     return FALSE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
 // The MAPILogon function begins a Simple MAPI session, loading the default message ////
 // store and address book providers                            ////
 ////////////////////////////////////////////////////////////////////////////////////////
 
-ULONG FAR PASCAL MAPILogon(ULONG aUIParam, LPTSTR aProfileName,
-                            LPTSTR aPassword, FLAGS aFlags,
-                            ULONG aReserved, LPLHANDLE aSession)
+ULONG FAR PASCAL MAPILogon(ULONG aUIParam, LPSTR aProfileName,
+                           LPSTR aPassword, FLAGS aFlags,
+                           ULONG aReserved, LPLHANDLE aSession)
 {
     HRESULT hr = 0;
     ULONG nSessionId = 0;
     nsIMapi *pNsMapi = NULL;
 
     if (!InitMozillaReference(&pNsMapi))
         return MAPI_E_FAILURE;
 
-    if (!(aFlags & MAPI_UNICODE))
-    {
-        // Need to convert the parameters to Unicode.
-
-        char *pUserName = (char *) aProfileName;
-        char *pPassWord = (char *) aPassword;
-
-        TCHAR ProfileName[MAX_NAME_LEN] = {0};
-        TCHAR PassWord[MAX_PW_LEN] = {0};
-
-        if (pUserName != NULL)
-        {
-            if (!MultiByteToWideChar(CP_ACP, 0, pUserName, -1, ProfileName,
-                                                            MAX_NAME_LEN))
-                return MAPI_E_FAILURE;
-        }
-
-        if (pPassWord != NULL)
-        {
-            if (!MultiByteToWideChar(CP_ACP, 0, pPassWord, -1, PassWord,
-                                                            MAX_NAME_LEN))
-                return MAPI_E_FAILURE;
-        }
-
-        hr = pNsMapi->Login(aUIParam, ProfileName, PassWord, aFlags,
-                                                        &nSessionId);
-    }
-    else
-        hr = pNsMapi->Login(aUIParam, aProfileName, aPassword,
-                                                aFlags, &nSessionId);
+    hr = pNsMapi->Login(aUIParam, aProfileName, aPassword, aFlags, &nSessionId);
     if (hr == S_OK)
         (*aSession) = (LHANDLE) nSessionId;
     else
         return nSessionId;
 
     return SUCCESS_SUCCESS;
 }
 
@@ -198,17 +168,17 @@ ULONG FAR PASCAL MAPISendMail (LHANDLE l
     if (!lhSession || pNsMapi->IsValidSession(lhSession) != S_OK)
     {
         FLAGS LoginFlag = 0;
         if ( (flFlags & MAPI_LOGON_UI) && (flFlags & MAPI_NEW_SESSION) )
             LoginFlag = MAPI_LOGON_UI | MAPI_NEW_SESSION ;
         else if (flFlags & MAPI_LOGON_UI)
             LoginFlag = MAPI_LOGON_UI ;
 
-        hr = MAPILogon (ulUIParam, (LPTSTR) NULL, (LPTSTR) NULL, LoginFlag, 0, &lhSession) ;
+        hr = MAPILogon(ulUIParam, nullptr, nullptr, LoginFlag, 0, &lhSession);
         if (hr != SUCCESS_SUCCESS)
             return MAPI_E_LOGIN_FAILURE ;
         bTempSession = TRUE ;
     }
 
     hr = pNsMapi->SendMail(lhSession, lpMessage, flFlags, ulReserved);
 
     // we are seeing a problem when using Word, although we return success from the MAPI support
@@ -244,17 +214,17 @@ ULONG FAR PASCAL MAPISendMailW(LHANDLE l
     if (!lhSession || pNsMapi->IsValidSession(lhSession) != S_OK)
     {
       FLAGS LoginFlag = 0;
       if ((flFlags & MAPI_LOGON_UI) && (flFlags & MAPI_NEW_SESSION))
         LoginFlag = MAPI_LOGON_UI | MAPI_NEW_SESSION;
       else if (flFlags & MAPI_LOGON_UI)
         LoginFlag = MAPI_LOGON_UI;
 
-      hr = MAPILogon(ulUIParam, (LPTSTR)NULL, (LPTSTR)NULL, LoginFlag, 0, &lhSession);
+      hr = MAPILogon(ulUIParam, nullptr, nullptr, LoginFlag, 0, &lhSession);
       if (hr != SUCCESS_SUCCESS)
         return MAPI_E_LOGIN_FAILURE;
       bTempSession = TRUE;
     }
 
     hr = pNsMapi->SendMailW(lhSession, lpMessage, flFlags, ulReserved);
 
     // we are seeing a problem when using Word, although we return success from the MAPI support
@@ -263,59 +233,56 @@ ULONG FAR PASCAL MAPISendMailW(LHANDLE l
       hr = SUCCESS_SUCCESS;
 
     if (bTempSession)
       MAPILogoff(lhSession, ulUIParam, 0, 0);
 
     return hr;
 }
 
-ULONG FAR PASCAL MAPISendDocuments(ULONG ulUIParam, LPTSTR lpszDelimChar, LPTSTR lpszFilePaths,
-                                LPTSTR lpszFileNames, ULONG ulReserved)
+ULONG FAR PASCAL MAPISendDocuments(ULONG ulUIParam, LPSTR lpszDelimChar, LPSTR lpszFilePaths,
+                                   LPSTR lpszFileNames, ULONG ulReserved)
 {
     LHANDLE lhSession ;
     nsIMapi *pNsMapi = NULL;
 
     if (!InitMozillaReference(&pNsMapi))
         return MAPI_E_FAILURE;
 
-    unsigned long result = MAPILogon (ulUIParam, (LPTSTR) NULL, (LPTSTR) NULL, MAPI_LOGON_UI, 0, &lhSession) ;
+    unsigned long result = MAPILogon(ulUIParam, nullptr, nullptr, MAPI_LOGON_UI, 0, &lhSession);
     if (result != SUCCESS_SUCCESS)
         return MAPI_E_LOGIN_FAILURE ;
 
     HRESULT hr;
 
-    hr = pNsMapi->SendDocuments(lhSession, (LPTSTR) lpszDelimChar, (LPTSTR) lpszFilePaths,
-                                    (LPTSTR) lpszFileNames, ulReserved) ;
+    hr = pNsMapi->SendDocuments(lhSession, lpszDelimChar, lpszFilePaths, lpszFileNames, ulReserved);
 
     MAPILogoff (lhSession, ulUIParam, 0,0) ;
 
     return hr ;
 }
 
-ULONG FAR PASCAL MAPIFindNext(LHANDLE lhSession, ULONG ulUIParam, const LPTSTR lpszMessageType,
-                              const LPTSTR lpszSeedMessageID, FLAGS flFlags, ULONG ulReserved,
+ULONG FAR PASCAL MAPIFindNext(LHANDLE lhSession, ULONG ulUIParam, const LPSTR lpszMessageType,
+                              const LPSTR lpszSeedMessageID, FLAGS flFlags, ULONG ulReserved,
                               unsigned char lpszMessageID[64])
 {
   nsIMapi *pNsMapi = NULL;
 
   if (!InitMozillaReference(&pNsMapi))
     return MAPI_E_FAILURE;
 
   if (lhSession == 0)
     return MAPI_E_INVALID_SESSION;
 
-  const LPTSTR type = lpszMessageType ? lpszMessageType : (const LPTSTR)(L"");
-  const LPTSTR id = lpszSeedMessageID ? lpszSeedMessageID : (const LPTSTR)(L"");
-  return pNsMapi->FindNext(lhSession, ulUIParam, type, id,
+  return pNsMapi->FindNext(lhSession, ulUIParam, lpszMessageType, lpszSeedMessageID,
                            flFlags, ulReserved, lpszMessageID);
 }
 
 
-ULONG FAR PASCAL MAPIReadMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
+ULONG FAR PASCAL MAPIReadMail(LHANDLE lhSession, ULONG ulUIParam, LPSTR lpszMessageID,
                               FLAGS flFlags, ULONG ulReserved, nsMapiMessage **lppMessage)
 {
   nsIMapi *pNsMapi = NULL;
 
   if (!InitMozillaReference(&pNsMapi))
     return MAPI_E_FAILURE;
 
   if (lhSession == 0)
@@ -323,60 +290,60 @@ ULONG FAR PASCAL MAPIReadMail(LHANDLE lh
 
   return pNsMapi->ReadMail(lhSession, ulUIParam,
                               lpszMessageID, flFlags, ulReserved,
                               lppMessage) ;
 
 }
 
 ULONG FAR PASCAL MAPISaveMail(LHANDLE lhSession, ULONG ulUIParam, lpnsMapiMessage lpMessage,
-                              FLAGS flFlags, ULONG ulReserved, LPTSTR lpszMessageID)
+                              FLAGS flFlags, ULONG ulReserved, LPSTR lpszMessageID)
 {
   nsIMapi *pNsMapi = NULL;
 
   if (lhSession == 0)
     return MAPI_E_INVALID_SESSION;
 
   if (!InitMozillaReference(&pNsMapi))
     return MAPI_E_FAILURE;
 
   return MAPI_E_FAILURE;
 }
 
-ULONG FAR PASCAL MAPIDeleteMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
+ULONG FAR PASCAL MAPIDeleteMail(LHANDLE lhSession, ULONG ulUIParam, LPSTR lpszMessageID,
                                 FLAGS flFlags, ULONG ulReserved)
 {
   nsIMapi *pNsMapi = NULL;
 
   if (lhSession == 0)
     return MAPI_E_INVALID_SESSION;
 
   if (!InitMozillaReference(&pNsMapi))
     return MAPI_E_FAILURE;
 
   return pNsMapi->DeleteMail(lhSession, ulUIParam,
                               lpszMessageID, flFlags, ulReserved) ;
 }
 
-ULONG FAR PASCAL MAPIAddress(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszCaption,
-                             ULONG nEditFields, LPTSTR lpszLabels, ULONG nRecips,
+ULONG FAR PASCAL MAPIAddress(LHANDLE lhSession, ULONG ulUIParam, LPSTR lpszCaption,
+                             ULONG nEditFields, LPSTR lpszLabels, ULONG nRecips,
                              lpMapiRecipDesc lpRecips, FLAGS flFlags,
                              ULONG ulReserved, LPULONG lpnNewRecips,
                              lpMapiRecipDesc FAR *lppNewRecips)
 {
     return MAPI_E_NOT_SUPPORTED;
 }
 
 ULONG FAR PASCAL MAPIDetails(LHANDLE lhSession, ULONG ulUIParam, lpMapiRecipDesc lpRecip,
                              FLAGS flFlags, ULONG ulReserved)
 {
     return MAPI_E_NOT_SUPPORTED;
 }
 
-ULONG FAR PASCAL MAPIResolveName(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszName,
+ULONG FAR PASCAL MAPIResolveName(LHANDLE lhSession, ULONG ulUIParam, LPSTR lpszName,
                                  FLAGS flFlags, ULONG ulReserved, lpMapiRecipDesc FAR *lppRecip)
 {
   char* lpszRecipName = new char[(strlen((const char*)lpszName) + 1)];
   if (lpszRecipName == NULL)
     return MAPI_E_INSUFFICIENT_MEMORY;
   char* lpszRecipAddress = new char[(strlen((const char*)lpszName) + 6)];
   if (!lpszRecipAddress) {
     delete[] lpszRecipName;
--- a/mailnews/mapi/mapihook/build/msgMapi.idl
+++ b/mailnews/mapi/mapihook/build/msgMapi.idl
@@ -2,18 +2,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This idl will be compiled by MIDL.  MS-COM is used
 // as bridge between MAPI clients and the Mozilla.
 
 import "unknwn.idl";
 
-typedef wchar_t LOGIN_PW_TYPE[256];
-
 typedef struct
 {
     unsigned long   ulReserved;
     unsigned long   flFlags;           /* Flags */
     unsigned long   nPosition_NotUsed; /* character in text to be replaced by attachment */
     LPSTR           lpszPathName;      /* Full path name including file name */
     LPSTR           lpszFileName;      /* Real (original) file name */
     unsigned char * lpFileType_NotUsed ;
@@ -86,43 +84,43 @@ typedef struct
     object,
     uuid(6EDCD38E-8861-11d5-A3DD-00B0D0F3BAA7),
     helpstring("nsIMapi Interface"),
     pointer_default(unique)
 ]
 
 interface nsIMapi : IUnknown
 {
-    HRESULT Login([in] unsigned long aUIArg, [in, unique] LOGIN_PW_TYPE aLogin,
-                  [in, unique] LOGIN_PW_TYPE aPassWord, [in] unsigned long aFlags,
+    HRESULT Login([in] unsigned long aUIArg, [in, unique, max_is(256)] LPSTR aLogin,
+                  [in, unique, max_is(256)] LPSTR aPassWord, [in] unsigned long aFlags,
                   [out] unsigned long *aSessionId);
 
     HRESULT Initialize();
     HRESULT IsValid();
     HRESULT IsValidSession([in] unsigned long aSession);
 
     HRESULT SendMail([in] unsigned long aSession, [in, unique] lpnsMapiMessage aMessage,
                      [in] unsigned long aFlags, [in] unsigned long aReserved) ;
 
     HRESULT SendDocuments([in] unsigned long aSession,
-                          [in, unique] LPTSTR aDelimChar, [in, unique] LPTSTR aFilePaths,
-                          [in, unique] LPTSTR aFileNames, [in] ULONG aFlags ) ;
+                          [in, unique] LPSTR aDelimChar, [in, unique] LPSTR aFilePaths,
+                          [in, unique] LPSTR aFileNames, [in] ULONG aFlags);
 
-    HRESULT FindNext([in] unsigned long aSession, [in] ULONG ulUIParam, [in, unique] const LPTSTR lpszMessageType,
-                     [in, unique] const LPTSTR lpszSeedMessageID, [in] ULONG flFlags, [in] ULONG ulReserved,
+    HRESULT FindNext([in] unsigned long aSession, [in] ULONG ulUIParam, [in, unique] const LPSTR lpszMessageType,
+                     [in, unique] const LPSTR lpszSeedMessageID, [in] ULONG flFlags, [in] ULONG ulReserved,
                      [in] [out] char lpszMessageID[64] ) ;
 
-    HRESULT ReadMail([in] unsigned long lhSession, [in] ULONG ulUIParam, [in, unique] LPTSTR lpszMessageID,
+    HRESULT ReadMail([in] unsigned long lhSession, [in] ULONG ulUIParam, [in, unique] LPSTR lpszMessageID,
                      [in] ULONG flFlags, [in] ULONG ulReserved, [out] lpnsMapiMessage *lppMessage);
 
-    HRESULT DeleteMail([in] unsigned long lhSession, [in] ULONG ulUIParam, [in, unique] LPTSTR lpszMessageID,
+    HRESULT DeleteMail([in] unsigned long lhSession, [in] ULONG ulUIParam, [in, unique] LPSTR lpszMessageID,
                        [in] ULONG flFlags, [in] ULONG ulReserved);
 
     HRESULT SaveMail([in] unsigned long lhSession, [in] ULONG ulUIParam, [in, unique] lpnsMapiMessage lppMessage,
-                     [in] ULONG flFlags, [in] ULONG ulReserved, [in, unique] LPTSTR lpszMessageID);
+                     [in] ULONG flFlags, [in] ULONG ulReserved, [in, unique] LPSTR lpszMessageID);
 
     HRESULT SendMailW([in] unsigned long aSession, [in, unique] lpnsMapiMessageW aMessage,
                       [in] unsigned long aFlags, [in] unsigned long aReserved);
 
     HRESULT Logoff(unsigned long aSession);
     HRESULT CleanUp();
 };
 
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -1,17 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #define MAPI_STARTUP_ARG       "/MAPIStartUp"
 
 #include <mapidefs.h>
 #include <mapi.h>
-#include <tchar.h>
 #include <direct.h>
 #include "nsCOMPtr.h"
 #include "nsISupports.h"
 #include "nsIPromptService.h"
 #include "nsIAppShellService.h"
 #include "mozIDOMWindow.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
@@ -170,17 +169,17 @@ bool nsMapiHook::DisplayLoginDialog(bool
       rv = dlgService->PromptPassword(nullptr, loginTitle.get(), loginText.get(),
                                       aPassword, nullptr, &dummyValue, &btnResult);
     }
   }
 
   return btnResult;
 }
 
-bool nsMapiHook::VerifyUserName(const nsString& aUsername, nsCString& aIdKey)
+bool nsMapiHook::VerifyUserName(const nsCString& aUsername, nsCString& aIdKey)
 {
   nsresult rv;
 
   if (aUsername.IsEmpty())
     return false;
 
   nsCOMPtr<nsIMsgAccountManager> accountManager(do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv));
   if (NS_FAILED(rv)) return false;
@@ -200,17 +199,17 @@ bool nsMapiHook::VerifyUserName(const ns
       rv = thisIdentity->GetEmail(email);
       if (NS_FAILED(rv)) continue;
 
       // get the username from the email and compare with the username
       int32_t index = email.FindChar('@');
       if (index != -1)
         email.SetLength(index);
 
-      if (aUsername.Equals(NS_ConvertASCIItoUTF16(email)))
+      if (aUsername.Equals(email))
         return NS_SUCCEEDED(thisIdentity->GetKey(aIdKey));
     }
   }
 
   return false;
 }
 
 bool
@@ -773,20 +772,20 @@ nsresult nsMapiHook::PopulateCompFieldsW
 
     rv = aCompFields->SetBody(Body);
   }
   return rv;
 }
 
 // this is used to populate the docs as attachments in the Comp fields for Send Documents
 nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompFields, ULONG aFlags,
-                                                   LPTSTR aDelimChar, LPTSTR aFilePaths)
+                                                   LPSTR aDelimChar, LPSTR aFilePaths)
 {
-  nsAutoString strDelimChars ;
-  nsString strFilePaths;
+  nsAutoCString strDelimChars;
+  nsAutoCString strFilePaths;
   nsresult rv = NS_OK ;
   bool bExist ;
 
   if (aDelimChar)
     strDelimChars.Assign(aDelimChar);
   if (aFilePaths)
     strFilePaths.Assign(aFilePaths);
 
@@ -808,34 +807,34 @@ nsresult nsMapiHook::PopulateCompFieldsF
   if (FilePathsLen)
   {
     nsAutoString Subject ;
 
     // multiple files to be sent, delim specified
     nsCOMPtr <nsIFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
     if (NS_FAILED(rv) || (!pFile) ) return rv ;
 
-    char16_t * newFilePaths = (char16_t *) strFilePaths.get() ;
+    char *newFilePaths = (char *)strFilePaths.get();
     while (offset != kNotFound)
     {
       //Temp Directory
       nsCOMPtr <nsIFile> pTempDir;
       NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(pTempDir));
 
       // if not already existing, create another temp dir for mapi within Win temp dir
       // this is windows only so we can do "\\"
       pTempDir->AppendRelativePath (NS_LITERAL_STRING("moz_mapi"));
       pTempDir->Exists(&bExist) ;
       if (!bExist)
       {
         rv = pTempDir->Create(nsIFile::DIRECTORY_TYPE, 777) ;
         if (NS_FAILED(rv)) return rv ;
       }
 
-      nsString RemainingPaths ;
+      nsAutoCString RemainingPaths;
       RemainingPaths.Assign(newFilePaths) ;
       offset = RemainingPaths.Find (strDelimChars) ;
       if (offset != kNotFound)
       {
         RemainingPaths.SetLength (offset) ;
         if ((offset + (int32_t)strDelimChars.Length()) < FilePathsLen)
           newFilePaths += offset + strDelimChars.Length() ;
         else
@@ -843,24 +842,24 @@ nsresult nsMapiHook::PopulateCompFieldsF
         FilePathsLen -= offset + strDelimChars.Length();
       }
 
       if (RemainingPaths[1] != ':' && RemainingPaths[1] != '\\')
       {
         char cwd[MAX_PATH];
         if (_getdcwd(_getdrive(), cwd, MAX_PATH))
         {
-          nsAutoString cwdStr;
-          CopyASCIItoUTF16(mozilla::MakeStringSpan(cwd), cwdStr);
+          nsAutoCString cwdStr;
+          cwdStr.Assign(cwd);
           cwdStr.Append('\\');
           RemainingPaths.Insert(cwdStr, 0);
         }
       }
 
-      pFile->InitWithPath (RemainingPaths) ;
+      pFile->InitWithNativePath(RemainingPaths) ;
 
       rv = pFile->Exists(&bExist) ;
       if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ;
 
       // filename of the file attachment
       nsAutoString leafName ;
       pFile->GetLeafName (leafName) ;
       if(NS_FAILED(rv) || leafName.IsEmpty()) return rv ;
--- a/mailnews/mapi/mapihook/src/msgMapiHook.h
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.h
@@ -8,26 +8,26 @@
 #include "prtypes.h"
 
 class nsMapiHook
 {
     public :
 
         static bool DisplayLoginDialog(bool aLogin, char16_t **aUsername,
                         char16_t **aPassword);
-        static bool VerifyUserName(const nsString& aUsername, nsCString& aIdKey);
+        static bool VerifyUserName(const nsCString& aUsername, nsCString& aIdKey);
 
         static bool IsBlindSendAllowed () ;
         static nsresult BlindSendMail (unsigned long aSession, nsIMsgCompFields * aCompFields) ;
         static nsresult ShowComposerWindow (unsigned long aSession, nsIMsgCompFields * aCompFields) ;
         static nsresult PopulateCompFieldsWithConversion(lpnsMapiMessage aMessage,
                                         nsIMsgCompFields * aCompFields) ;
         static nsresult PopulateCompFieldsW(lpnsMapiMessageW aMessage, nsIMsgCompFields *aCompFields);
         static nsresult PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompFields,
-                                        ULONG aFlags, LPTSTR aDelimChar, LPTSTR aFilePaths) ;
+                                        ULONG aFlags, LPSTR aDelimChar, LPSTR aFilePaths);
         static nsresult HandleAttachments(nsIMsgCompFields *aCompFields, int32_t aFileCount,
                                           lpnsMapiFileDesc aFiles, bool aIsUTF8);
         static nsresult HandleAttachmentsW(nsIMsgCompFields *aCompFields, int32_t aFileCount,
                                            lpnsMapiFileDescW aFiles);
         static void CleanUp();
 
         static bool isMapiService;
 };
--- a/mailnews/mapi/mapihook/src/msgMapiImp.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiImp.cpp
@@ -116,31 +116,31 @@ STDMETHODIMP CMapiImp::Initialize()
     if (pConfig != nullptr)
       hr = S_OK;
 
     PR_Unlock(m_Lock);
 
     return hr;
 }
 
-STDMETHODIMP CMapiImp::Login(unsigned long aUIArg, LOGIN_PW_TYPE aLogin, LOGIN_PW_TYPE aPassWord,
-                unsigned long aFlags, unsigned long *aSessionId)
+STDMETHODIMP CMapiImp::Login(unsigned long aUIArg, LPSTR aLogin, LPSTR aPassWord,
+                             unsigned long aFlags, unsigned long *aSessionId)
 {
     HRESULT hr = E_FAIL;
      bool bNewSession = false;
     nsCString id_key;
 
     MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::Login using flags %d\n", aFlags));
     if (aFlags & MAPI_NEW_SESSION)
         bNewSession = true;
 
     // Check For Profile Name
     if (aLogin != nullptr && aLogin[0] != '\0')
     {
-        if (!nsMapiHook::VerifyUserName(nsString(aLogin), id_key))
+        if (!nsMapiHook::VerifyUserName(nsDependentCString(aLogin), id_key))
         {
             *aSessionId = MAPI_E_LOGIN_FAILURE;
             MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::Login failed for username %s\n", aLogin));
             NS_ASSERTION(false, "failed verifying user name");
             return hr;
         }
     }
     else
@@ -166,17 +166,18 @@ STDMETHODIMP CMapiImp::Login(unsigned lo
     }
 
     // finally register(create) the session.
     uint32_t nSession_Id;
     int16_t nResult = 0;
 
     nsMAPIConfiguration *pConfig = nsMAPIConfiguration::GetMAPIConfiguration();
     if (pConfig != nullptr)
-        nResult = pConfig->RegisterSession(aUIArg, char16ptr_t(aLogin), char16ptr_t(aPassWord),
+        nResult = pConfig->RegisterSession(aUIArg, nsDependentCString(aLogin),
+                                           nsDependentCString(aPassWord),
                                            (aFlags & MAPI_FORCE_DOWNLOAD), bNewSession,
                                            &nSession_Id, id_key.get());
     switch (nResult)
     {
         case -1 :
         {
             *aSessionId = MAPI_E_TOO_MANY_SESSIONS;
             return hr;
@@ -272,18 +273,18 @@ STDMETHODIMP CMapiImp::SendMailW(unsigne
       {
         rv = nsMapiHook::ShowComposerWindow(aSession, pCompFields);
       }
     }
 
     return nsMAPIConfiguration::GetMAPIErrorFromNSError(rv);
 }
 
-STDMETHODIMP CMapiImp::SendDocuments( unsigned long aSession, LPTSTR aDelimChar,
-                            LPTSTR aFilePaths, LPTSTR aFileNames, ULONG aFlags)
+STDMETHODIMP CMapiImp::SendDocuments(unsigned long aSession, LPSTR aDelimChar,
+                                     LPSTR aFilePaths, LPSTR aFileNames, ULONG aFlags)
 {
     nsresult rv = NS_OK ;
 
     MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::SendDocument using flags %d\n", aFlags));
     /** create nsIMsgCompFields obj and populate it **/
     nsCOMPtr<nsIMsgCompFields> pCompFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv) ;
     if (NS_FAILED(rv) || (!pCompFields) ) return MAPI_E_INSUFFICIENT_MEMORY ;
 
@@ -404,19 +405,19 @@ LONG CMapiImp::InitContext(unsigned long
       return MAPI_E_NO_MESSAGES;
     }
     else
       pMapiConfig->SetMapiListContext(session, *listContext);
   }
   return SUCCESS_SUCCESS;
 }
 
-STDMETHODIMP CMapiImp::FindNext(unsigned long aSession, unsigned long ulUIParam, LPTSTR lpszMessageType,
-                              LPTSTR lpszSeedMessageID, unsigned long flFlags, unsigned long ulReserved,
-                              unsigned char lpszMessageID[64])
+STDMETHODIMP CMapiImp::FindNext(unsigned long aSession, unsigned long ulUIParam, LPSTR lpszMessageType,
+                                LPSTR lpszSeedMessageID, unsigned long flFlags, unsigned long ulReserved,
+                                unsigned char lpszMessageID[64])
 
 {
   //
   // If this is true, then this is the first call to this FindNext function
   // and we should start the enumeration operation.
   //
 
   *lpszMessageID = '\0';
@@ -449,18 +450,18 @@ STDMETHODIMP CMapiImp::FindNext(unsigned
 
     sprintf((char *) lpszMessageID, "%d", nextKey);
   }
 
   MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::FindNext returning key %s\n", (char *) lpszMessageID));
   return(SUCCESS_SUCCESS);
 }
 
-STDMETHODIMP CMapiImp::ReadMail(unsigned long aSession, unsigned long ulUIParam, LPTSTR lpszMessageID,
-                              unsigned long flFlags, unsigned long ulReserved, lpnsMapiMessage *lppMessage)
+STDMETHODIMP CMapiImp::ReadMail(unsigned long aSession, unsigned long ulUIParam, LPSTR lpszMessageID,
+                                unsigned long flFlags, unsigned long ulReserved, lpnsMapiMessage *lppMessage)
 {
   nsresult irv;
   nsAutoCString keyString((char *) lpszMessageID);
   MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::ReadMail asking for key %s\n", (char *) lpszMessageID));
   nsMsgKey msgKey = keyString.ToInteger(&irv);
   if (NS_FAILED(irv))
   {
     NS_ASSERTION(false, "invalid lpszMessageID");
@@ -475,34 +476,34 @@ STDMETHODIMP CMapiImp::ReadMail(unsigned
   }
   *lppMessage = listContext->GetMessage (msgKey, flFlags);
   NS_ASSERTION(*lppMessage, "get message failed");
 
   return (*lppMessage) ? SUCCESS_SUCCESS : E_FAIL;
 }
 
 
-STDMETHODIMP CMapiImp::DeleteMail(unsigned long aSession, unsigned long ulUIParam, LPTSTR lpszMessageID,
-                              unsigned long flFlags, unsigned long ulReserved)
+STDMETHODIMP CMapiImp::DeleteMail(unsigned long aSession, unsigned long ulUIParam, LPSTR lpszMessageID,
+                                  unsigned long flFlags, unsigned long ulReserved)
 {
   nsresult irv;
   nsAutoCString keyString((char *) lpszMessageID);
   nsMsgKey msgKey = keyString.ToInteger(&irv);
   // XXX Why do we return success on failure?
   if (NS_FAILED(irv))
     return SUCCESS_SUCCESS;
   MsgMapiListContext *listContext;
   LONG ret = InitContext(aSession, &listContext);
   if (ret != SUCCESS_SUCCESS)
     return ret;
   return (listContext->DeleteMessage(msgKey)) ? SUCCESS_SUCCESS : MAPI_E_INVALID_MESSAGE;
 }
 
-STDMETHODIMP CMapiImp::SaveMail(unsigned long aSession, unsigned long ulUIParam,  lpnsMapiMessage lppMessage,
-                              unsigned long flFlags, unsigned long ulReserved, LPTSTR lpszMessageID)
+STDMETHODIMP CMapiImp::SaveMail(unsigned long aSession, unsigned long ulUIParam, lpnsMapiMessage lppMessage,
+                                unsigned long flFlags, unsigned long ulReserved, LPSTR lpszMessageID)
 {
   MsgMapiListContext *listContext;
   LONG ret = InitContext(aSession, &listContext);
   if (ret != SUCCESS_SUCCESS)
     return ret;
   return S_OK;
 }
 
--- a/mailnews/mapi/mapihook/src/msgMapiImp.h
+++ b/mailnews/mapi/mapihook/src/msgMapiImp.h
@@ -26,36 +26,36 @@ public :
   // IUnknown
 
   STDMETHODIMP            QueryInterface(const IID& aIid, void** aPpv);
   STDMETHODIMP_(ULONG)    AddRef();
   STDMETHODIMP_(ULONG)    Release();
 
   // Interface INsMapi
 
-  STDMETHODIMP Login(unsigned long aUIArg, LOGIN_PW_TYPE aLogin,
-                     LOGIN_PW_TYPE aPassWord, unsigned long aFlags,
+  STDMETHODIMP Login(unsigned long aUIArg, LPSTR aLogin,
+                     LPSTR aPassWord, unsigned long aFlags,
                      unsigned long *aSessionId);
 
-  STDMETHODIMP SendMail( unsigned long aSession, lpnsMapiMessage aMessage,
-       unsigned long aFlags, unsigned long aReserved) ;
+  STDMETHODIMP SendMail(unsigned long aSession, lpnsMapiMessage aMessage,
+                        unsigned long aFlags, unsigned long aReserved);
 
-  STDMETHODIMP SendDocuments( unsigned long aSession, LPTSTR aDelimChar,
-                              LPTSTR aFilePaths, LPTSTR aFileNames, ULONG aFlags);
+  STDMETHODIMP SendDocuments(unsigned long aSession, LPSTR aDelimChar,
+                             LPSTR aFilePaths, LPSTR aFileNames, ULONG aFlags);
 
-  STDMETHODIMP FindNext(  unsigned long aSession, unsigned long ulUIParam, LPTSTR lpszMessageType,
-                            LPTSTR lpszSeedMessageID, unsigned long flFlags, unsigned long ulReserved,
-                            unsigned char lpszMessageID[64] );
+  STDMETHODIMP FindNext(unsigned long aSession, unsigned long ulUIParam, LPSTR lpszMessageType,
+                        LPSTR lpszSeedMessageID, unsigned long flFlags, unsigned long ulReserved,
+                        unsigned char lpszMessageID[64]);
 
-  STDMETHODIMP ReadMail(unsigned long lhSession, unsigned long ulUIParam, LPTSTR lpszMessageID,
-                            unsigned long flFlags, unsigned long ulReserved, lpnsMapiMessage *lppMessage);
-  STDMETHODIMP DeleteMail(unsigned long lhSession, unsigned long ulUIParam, LPTSTR lpszMessageID,
-                            unsigned long flFlags, unsigned long ulReserved);
+  STDMETHODIMP ReadMail(unsigned long lhSession, unsigned long ulUIParam, LPSTR lpszMessageID,
+                        unsigned long flFlags, unsigned long ulReserved, lpnsMapiMessage *lppMessage);
+  STDMETHODIMP DeleteMail(unsigned long lhSession, unsigned long ulUIParam, LPSTR lpszMessageID,
+                          unsigned long flFlags, unsigned long ulReserved);
   STDMETHODIMP SaveMail(unsigned long lhSession, unsigned long ulUIParam, lpnsMapiMessage lppMessage,
-                            unsigned long flFlags, unsigned long ulReserved, LPTSTR lpszMessageID);
+                        unsigned long flFlags, unsigned long ulReserved, LPSTR lpszMessageID);
 
   STDMETHODIMP Initialize();
   STDMETHODIMP IsValid();
   STDMETHODIMP IsValidSession(unsigned long aSession);
 
   STDMETHODIMP SendMailW(unsigned long aSession, lpnsMapiMessageW aMessage,
                          unsigned long aFlags, unsigned long aReserved);
 
--- a/mailnews/mapi/mapihook/src/msgMapiMain.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiMain.cpp
@@ -40,35 +40,35 @@ void nsMAPIConfiguration::OpenConfigurat
   // if it is decided to have configuration (registry)
   // parameter, this function can be used to set the
   // max sessions;
 
   return;
 }
 
 int16_t nsMAPIConfiguration::RegisterSession(uint32_t aHwnd,
-                const char16_t *aUserName, const char16_t *aPassword,
+                const nsCString& aUserName, const nsCString& aPassword,
                 bool aForceDownLoad, bool aNewSession,
                 uint32_t *aSession, const char *aIdKey)
 {
   int16_t nResult = 0;
   uint32_t n_SessionId = 0;
 
   PR_Lock(m_Lock);
 
   // Check whether max sessions is exceeded
 
   if (sessionCount >= m_nMaxSessions)
   {
     PR_Unlock(m_Lock);
     return -1;
   }
 
-  if (aUserName != nullptr && aUserName[0] != '\0')
-    m_ProfileMap.Get(nsDependentString(aUserName), &n_SessionId);
+  if (!aUserName.IsEmpty())
+    m_ProfileMap.Get(aUserName, &n_SessionId);
 
   // try to share a session; if not create a session
   if (n_SessionId > 0)
   {
     nsMAPISession *pTemp = nullptr;
     m_SessionMap.Get(n_SessionId, &pTemp);
     if (pTemp != nullptr)
     {
@@ -76,31 +76,30 @@ int16_t nsMAPIConfiguration::RegisterSes
       *aSession = n_SessionId;
       nResult = 1;
     }
   }
   else if (aNewSession || n_SessionId == 0) // checking for n_SessionId is a concession
   {
     // create a new session; if new session is specified OR there is no session
     nsMAPISession *pTemp = nullptr;
-    pTemp = new nsMAPISession(aHwnd, aUserName,
-                           aPassword, aForceDownLoad, aIdKey);
+    pTemp = new nsMAPISession(aHwnd, aUserName, aPassword, aForceDownLoad, aIdKey);
 
     if (pTemp != nullptr)
     {
       session_generator++;
 
       // I don't think there will be (2 power 32) sessions alive
       // in a cycle.  This is an assumption
 
       if (session_generator == 0)
           session_generator++;
       m_SessionMap.Put(session_generator, pTemp);
-      if (aUserName != nullptr && aUserName[0] != '\0')
-        m_ProfileMap.Put(nsDependentString(aUserName), session_generator);
+      if (!aUserName.IsEmpty())
+        m_ProfileMap.Put(aUserName, session_generator);
       *aSession = session_generator;
       sessionCount++;
       nResult = 1;
     }
   }
 
   PR_Unlock(m_Lock);
   return nResult;
@@ -256,25 +255,24 @@ HRESULT nsMAPIConfiguration::GetMAPIErro
       hr = MAPI_E_FAILURE;
       break;
   }
 
   return hr;
 }
 
 
-nsMAPISession::nsMAPISession(uint32_t aHwnd, const char16_t *aUserName,
-                             const char16_t *aPassword,
+nsMAPISession::nsMAPISession(uint32_t aHwnd, const nsCString& aUserName, const nsCString& aPassword,
                              bool aForceDownLoad, const char *aKey)
 : m_nShared(1),
   m_pIdKey(aKey)
 {
   m_listContext = NULL;
-  m_pProfileName.Assign(aUserName);
-  m_pPassword.Assign(aPassword);
+  m_pProfileName = aUserName;
+  m_pPassword = aPassword;
 }
 
 nsMAPISession::~nsMAPISession()
 {
 }
 
 uint32_t nsMAPISession::IncrementSession()
 {
--- a/mailnews/mapi/mapihook/src/msgMapiMain.h
+++ b/mailnews/mapi/mapihook/src/msgMapiMain.h
@@ -26,26 +26,26 @@ class nsMAPIConfiguration
 private :
 
   static uint32_t session_generator;
   static uint32_t sessionCount;
   static nsMAPIConfiguration *m_pSelfRef;
   PRLock *m_Lock;
   uint32_t  m_nMaxSessions;
 
-  nsDataHashtable<nsStringHashKey, uint32_t> m_ProfileMap;
+  nsDataHashtable<nsCStringHashKey, uint32_t> m_ProfileMap;
   nsClassHashtable<nsUint32HashKey, nsMAPISession> m_SessionMap;
   nsMAPIConfiguration();
   ~nsMAPIConfiguration();
 
 public :
   static nsMAPIConfiguration *GetMAPIConfiguration();
   void OpenConfiguration();
-  int16_t RegisterSession(uint32_t aHwnd, const char16_t *aUserName, \
-                          const char16_t *aPassword, bool aForceDownLoad, \
+  int16_t RegisterSession(uint32_t aHwnd, const nsCString& aUserName,
+                          const nsCString& aPassword, bool aForceDownLoad,
                           bool aNewSession, uint32_t *aSession, const char *aIdKey);
   bool IsSessionValid(uint32_t aSessionID);
   bool UnRegisterSession(uint32_t aSessionID);
   char16_t *GetPassword(uint32_t aSessionID);
   void GetIdKey(uint32_t aSessionID, nsCString& aKey);
   void *GetMapiListContext(uint32_t aSessionID);
   void SetMapiListContext(uint32_t aSessionID, void *mapiListContext);
 
@@ -55,23 +55,22 @@ public :
 
 class nsMAPISession
 {
   friend class nsMAPIConfiguration;
 
   private :
     uint32_t m_nShared;
     nsCString m_pIdKey;
-    nsString m_pProfileName;
-    nsString m_pPassword;
+    nsCString m_pProfileName;
+    nsCString m_pPassword;
     void   *m_listContext; // used by findNext
 
   public :
-    nsMAPISession(uint32_t aHwnd, const char16_t *aUserName, \
-                  const char16_t *aPassword, \
+    nsMAPISession(uint32_t aHwnd, const nsCString& aUserName, const nsCString& aPassword,
                   bool aForceDownLoad, const char *aKey);
     uint32_t IncrementSession();
     uint32_t DecrementSession();
     uint32_t GetSessionCount();
     char16_t *GetPassword();
     void GetIdKey(nsCString& aKey);
     ~nsMAPISession();
     // For enumerating Messages...