Bug 1500047 - Port bug 1486554: Make conversion CTORs explicit in Windows-only code and fix other minor issues. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Thu, 18 Oct 2018 20:34:41 +0200
changeset 33404 4e6b66d1a7e326d1764ef1f5b2d061e910a3c917
parent 33403 1c5d8e0a6c27debe071f9bb7cd2e5b8a2084dce5
child 33405 c818d0a484d571351c9e21fb67a06bff37d4cb85
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersbustage-fix
bugs1500047, 1486554
Bug 1500047 - Port bug 1486554: Make conversion CTORs explicit in Windows-only code and fix other minor issues. rs=bustage-fix
mailnews/addrbook/src/nsAbWinHelper.h
mailnews/addrbook/src/nsWabAddressBook.cpp
mailnews/import/outlook/src/MapiApi.h
mailnews/import/outlook/src/MapiMessage.h
mailnews/import/outlook/src/nsOutlookCompose.cpp
mailnews/mapi/mapihook/src/Registry.cpp
--- a/mailnews/addrbook/src/nsAbWinHelper.h
+++ b/mailnews/addrbook/src/nsAbWinHelper.h
@@ -126,17 +126,17 @@ enum nsAbWinType
     nsAbWinType_Unknown,
     nsAbWinType_Outlook,
     nsAbWinType_OutlookExp
 } ;
 
 class nsAbWinHelperGuard
 {
 public :
-    nsAbWinHelperGuard(uint32_t aType) ;
+    explicit nsAbWinHelperGuard(uint32_t aType) ;
     ~nsAbWinHelperGuard(void) ;
 
     nsAbWinHelper *operator ->(void) { return mHelper ; }
 
 private:
     nsAbWinHelper *mHelper ;
 } ;
 
--- a/mailnews/addrbook/src/nsWabAddressBook.cpp
+++ b/mailnews/addrbook/src/nsWabAddressBook.cpp
@@ -49,17 +49,19 @@ BOOL nsWabAddressBook::LoadWabLibrary(vo
             _tcsncat(wabDLLPath, WAB_DLL_NAME,
                      std::min(_tcslen(WAB_DLL_NAME), MAX_PATH - _tcslen(wabDLLPath) - 1));
         }
         else {
             return FALSE;
         }
     }
     if (keyHandle) { RegCloseKey(keyHandle) ; }
-    mLibrary = LoadLibrary( (lstrlen(wabDLLPath)) ? wabDLLPath : WAB_DLL_NAME );
+    mLibrary = LoadLibraryW((lstrlen(wabDLLPath))
+      ? NS_ConvertASCIItoUTF16(wabDLLPath).get()
+      : NS_ConvertASCIItoUTF16(WAB_DLL_NAME).get());
     if (!mLibrary) { return FALSE ; }
     ++ mLibUsage ;
     mWABOpen = reinterpret_cast<LPWABOPEN>(GetProcAddress(mLibrary, "WABOpen")) ;
     if (!mWABOpen) { return FALSE ; }
     HRESULT retCode = mWABOpen(&mRootBook, &mRootSession, NULL, 0) ;
 
     if (HR_FAILED(retCode)) {
         PRINTF(("Cannot initialize WAB %08x.\n", retCode)) ; return FALSE ;
--- a/mailnews/import/outlook/src/MapiApi.h
+++ b/mailnews/import/outlook/src/MapiApi.h
@@ -154,17 +154,17 @@ private:
   static int        m_uniBuffLen;
 
   static BOOL      GetLargeProperty(LPMAPIPROP pProp, ULONG tag, void** result);
 };
 
 class CMapiFolder {
 public:
   CMapiFolder();
-  CMapiFolder(const CMapiFolder *pCopyFrom);
+  explicit CMapiFolder(const CMapiFolder *pCopyFrom);
   CMapiFolder(const char16_t *pDisplayName, ULONG cbEid, LPENTRYID lpEid, int depth, LONG oType = MAPI_FOLDER);
   ~CMapiFolder();
 
   void  SetDoImport(BOOL doIt) { m_doImport = doIt;}
   void  SetObjectType(long oType) { m_objectType = oType;}
   void  SetDisplayName(const char16_t *pDisplayName) { m_displayName = pDisplayName;}
   void  SetEntryID(ULONG cbEid, LPENTRYID lpEid);
   void  SetDepth(int depth) { m_depth = depth;}
@@ -214,17 +214,17 @@ protected:
 
 private:
   nsTArray<CMapiFolder*>    m_array;
 };
 
 
 class CMsgStore {
 public:
-  CMsgStore(ULONG cbEid = 0, LPENTRYID lpEid = NULL);
+  explicit CMsgStore(ULONG cbEid = 0, LPENTRYID lpEid = NULL);
   ~CMsgStore();
 
   void    SetEntryID(ULONG cbEid, LPENTRYID lpEid);
   BOOL    Open(LPMAPISESSION pSession, LPMDB *ppMdb);
 
   ULONG    GetCBEntryID(void) { return m_cbEid;}
   LPENTRYID  GetLPEntryID(void) { return (LPENTRYID) m_lpEid;}
 
--- a/mailnews/import/outlook/src/MapiMessage.h
+++ b/mailnews/import/outlook/src/MapiMessage.h
@@ -60,17 +60,17 @@ public:
                        hdrMessageID,
                        hdrSubject,
                        hdrMimeVersion,
                        hdrContentType,
                        hdrContentTransferEncoding,
                        hdrMax // utility value
                      };
 
-  CMapiMessageHeaders(const char* headers = 0) { Assign(headers); }
+  explicit CMapiMessageHeaders(const char* headers = 0) { Assign(headers); }
   ~CMapiMessageHeaders();
   void Assign(const char* headers);
 
   inline bool IsEmpty() const { return m_headerFields.empty(); }
   // if no such header exists then 0 is returned, else the first value returned
   const char* Value(const char* name) const;
   // if no such header exists then 0 is returned
   const char* Value(SpecialHeader special) const;
@@ -107,28 +107,28 @@ private:
   private:
     char* m_fname;
     char* m_fbody;
     bool m_fbody_utf8;
   }; //class HeaderField
 
   class write_to_stream {
   public:
-    write_to_stream(nsIOutputStream *pDst) : m_pDst(pDst), m_rv(NS_OK) {}
+    explicit write_to_stream(nsIOutputStream *pDst) : m_pDst(pDst), m_rv(NS_OK) {}
     void operator () (const CHeaderField* f);
     inline operator nsresult() const { return m_rv; }
   private:
     nsIOutputStream *m_pDst;
     nsresult m_rv;
   };
 
   // Search helper
   class fname_equals {
   public:
-    fname_equals(const char* search) : m_search(search) {}
+    explicit fname_equals(const char* search) : m_search(search) {}
     inline bool operator () (const CHeaderField* f) const { return stricmp(f->fname(), m_search) == 0; }
   private:
     const char* m_search;
   }; // class fname_equals
 
   // The common array of special headers' names
   static const char* Specials[hdrMax];
 
@@ -143,17 +143,17 @@ private:
   inline CHeaderField* Find(const char* name) { return const_cast<CHeaderField*>(CFind(name)); }
 
 }; // class CMapiMessageHeaders
 
 //////////////////////////////////////////////////////
 
 class CMapiMessage {
 public:
-  CMapiMessage(LPMESSAGE  lpMsg);
+  explicit CMapiMessage(LPMESSAGE lpMsg);
   ~CMapiMessage();
 
   // Attachments
   // Ordinary (not embedded) attachments.
   nsresult GetAttachments(nsIArray **aArray);
   // Embedded attachments
   size_t EmbeddedAttachmentsCount() const { return m_embattachments.size(); }
   bool GetEmbeddedAttachmentInfo(unsigned int i, nsIURI **uri, const char **cid,
--- a/mailnews/import/outlook/src/nsOutlookCompose.cpp
+++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp
@@ -71,17 +71,17 @@ static const char *p_test_body =
 
 // A replacement for SimpleBufferTonyRCopiedTwice round-robin buffer and ReadFileState classes
 class CCompositionFile {
 public:
   // fifoBuffer is used for memory allocation optimization
   // convertCRs controls if we want to convert standalone CRs to CRLFs
   CCompositionFile(nsIFile* aFile, void* fifoBuffer, uint32_t fifoBufferSize, bool convertCRs=false);
 
-  operator bool() const { return m_fileSize && m_pInputStream; }
+  explicit operator bool() const { return m_fileSize && m_pInputStream; }
 
   // Reads up to and including the term sequence, or entire file if term isn't found
   // termSize may be used to include NULLs in the terminator sequences.
   // termSize value of -1 means "zero-terminated string" -> size is calculated with strlen
   nsresult ToString(nsCString& dest, const char* term=0, int termSize=-1);
   nsresult ToStream(nsIOutputStream *dest, const char* term=0, int termSize=-1);
   char LastChar() { return m_lastChar; }
 private:
@@ -121,17 +121,17 @@ public:
 
   /* void OnStatus (in string aMsgID, in wstring aMsg); */
   NS_IMETHOD OnStatus(const char *aMsgID, const char16_t *aMsg) {return NS_OK;}
 
   /* void OnStopSending (in string aMsgID, in nsresult aStatus, in wstring aMsg, in nsIFile returnFile); */
   NS_IMETHOD OnStopSending(const char *aMsgID, nsresult aStatus, const char16_t *aMsg,
                nsIFile *returnFile) {
     m_done = true;
-    NS_IF_ADDREF(m_location = returnFile);
+    m_location = returnFile;
     return NS_OK;
   }
 
    /* void OnSendNotPerformed */
    NS_IMETHOD OnSendNotPerformed(const char *aMsgID, nsresult aStatus) {return NS_OK;}
 
   /* void OnGetDraftFolderURI (); */
   NS_IMETHOD OnGetDraftFolderURI(const char *aFolderURI) {return NS_OK;}
@@ -363,17 +363,17 @@ nsresult nsOutlookCompose::CopyComposedM
   // well, isn't this a hoot!
   // Read the headers from the new message, get the ones we like
   // and write out only the headers we want from the new message,
   // along with all of the other headers from the "old" message!
 
   nsCString newHeadersStr;
   rv = f.ToString(newHeadersStr, MSG_LINEBREAK MSG_LINEBREAK); // Read all the headers
   NS_ENSURE_SUCCESS(rv, rv);
-  UpdateHeaders(*origMsg.GetHeaders(), newHeadersStr.get());
+  UpdateHeaders(*origMsg.GetHeaders(), CMapiMessageHeaders(newHeadersStr.get()));
   rv = origMsg.GetHeaders()->ToStream(pDst);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // I use the terminating sequence here to avoid a possible situation when a "From " line
   // gets split over two sequential reads and thus will not be escaped.
   // This is done by reading up to CRLF (one line every time), though it may be slower
 
   // Here I revert the changes that were made when the multipart/related message
@@ -607,27 +607,27 @@ nsresult CCompositionFile::ToDest(_OutFn
   NS_ENSURE_SUCCESS(rv, rv);
 
   m_lastChar = c;
   return NS_OK;
 }
 
 class dest_nsCString {
 public:
-  dest_nsCString(nsCString& str) : m_str(str) { m_str.Truncate(); }
+  explicit dest_nsCString(nsCString& str) : m_str(str) { m_str.Truncate(); }
   void SetCapacity(int32_t sz) { m_str.SetCapacity(sz); }
   nsresult Append(const char* buf, uint32_t count) {
     m_str.Append(buf, count); return NS_OK; }
 private:
   nsCString& m_str;
 };
 
 class dest_Stream {
 public:
-  dest_Stream(nsIOutputStream *dest) : m_stream(dest) {}
+  explicit dest_Stream(nsIOutputStream *dest) : m_stream(dest) {}
   void SetCapacity(int32_t) { /*do nothing*/ }
   // const_cast here is due to the poor design of the EscapeFromSpaceLine()
   // that requires a non-constant pointer while doesn't modify its data
   nsresult Append(const char* buf, uint32_t count) {
     return EscapeFromSpaceLine(m_stream, const_cast<char*>(buf), buf+count); }
 private:
   nsIOutputStream *m_stream;
 };
--- a/mailnews/mapi/mapihook/src/Registry.cpp
+++ b/mailnews/mapi/mapihook/src/Registry.cpp
@@ -135,17 +135,17 @@ void RegisterProxy()
         return;
 
     *pTemp = '\0';
     nsAutoCString proxyPath(szModule);
 
     proxyPath += "\\";
     proxyPath += MAPI_PROXY_DLL_NAME;
 
-    h = LoadLibrary(proxyPath.get());
+    h = LoadLibraryW(NS_ConvertASCIItoUTF16(proxyPath).get());
     if (h == NULL)
         return;
 
     RegisterFunc = (ProxyServer *) GetProcAddress(h, "DllRegisterServer");
     if (RegisterFunc)
         RegisterFunc();
 
     FreeLibrary(h);
@@ -170,17 +170,17 @@ void UnRegisterProxy()
         return;
 
     *pTemp = '\0';
     nsAutoCString proxyPath(szModule);
 
     proxyPath += "\\";
     proxyPath += MAPI_PROXY_DLL_NAME;
 
-    h = LoadLibrary(proxyPath.get());
+    h = LoadLibraryW(NS_ConvertASCIItoUTF16(proxyPath).get());
     if (h == NULL)
         return;
 
     UnRegisterFunc = (ProxyServer *) GetProcAddress(h, "DllUnregisterServer");
     if (UnRegisterFunc)
         UnRegisterFunc();
 
     FreeLibrary(h);