Bug 1372943 - Port
bug 1353593 to mailnews: replace wwc. rs=bustage-fix
--- a/mailnews/addrbook/src/nsAbWinHelper.cpp
+++ b/mailnews/addrbook/src/nsAbWinHelper.cpp
@@ -509,17 +509,17 @@ BOOL nsAbWinHelper::DeleteEntry(const ns
BOOL nsAbWinHelper::SetPropertyUString(const nsMapiEntry& aObject, ULONG aPropertyTag,
const char16_t *aValue)
{
SPropValue value ;
nsAutoCString alternativeValue ;
value.ulPropTag = aPropertyTag ;
if (PROP_TYPE(aPropertyTag) == PT_UNICODE) {
- value.Value.lpszW = wwc(const_cast<char16_t *>(aValue)) ;
+ value.Value.lpszW = reinterpret_cast<wchar_t*>(const_cast<char16_t *>(aValue));
}
else if (PROP_TYPE(aPropertyTag) == PT_STRING8) {
alternativeValue = NS_LossyConvertUTF16toASCII(aValue);
value.Value.lpszA = const_cast<char *>(alternativeValue.get()) ;
}
else {
PRINTF(("Property %08x is not a string.\n", aPropertyTag)) ;
return TRUE ;
--- a/mailnews/import/outlook/src/MapiApi.cpp
+++ b/mailnews/import/outlook/src/MapiApi.cpp
@@ -8,25 +8,24 @@
#include <sstream>
#include "rtfMailDecoder.h"
#include "prprf.h"
#include "nsMemory.h"
#include "nsMsgUtils.h"
#include "nsUnicharUtils.h"
+#include "nsNativeCharsetUtils.h"
int CMapiApi::m_clients = 0;
BOOL CMapiApi::m_initialized = false;
nsTArray<CMsgStore*> *CMapiApi::m_pStores = NULL;
LPMAPISESSION CMapiApi::m_lpSession = NULL;
LPMDB CMapiApi::m_lpMdb = NULL;
HRESULT CMapiApi::m_lastError;
-char16_t * CMapiApi::m_pUniBuff = NULL;
-int CMapiApi::m_uniBuffLen = 0;
/*
Type: 1, name: Calendar, class: IPF.Appointment
Type: 1, name: Contacts, class: IPF.Contact
Type: 1, name: Journal, class: IPF.Journal
Type: 1, name: Notes, class: IPF.StickyNote
Type: 1, name: Tasks, class: IPF.Task
Type: 1, name: Drafts, class: IPF.Note
*/
@@ -280,38 +279,22 @@ CMapiApi::~CMapiApi()
}
if (m_initialized) {
MAPIUninitialize();
m_initialized = FALSE;
}
UnloadMapi();
-
- if (m_pUniBuff)
- delete [] m_pUniBuff;
- m_pUniBuff = NULL;
- m_uniBuffLen = 0;
}
}
void CMapiApi::CStrToUnicode(const char *pStr, nsString& result)
{
- result.Truncate();
- int wLen = MultiByteToWideChar(CP_ACP, 0, pStr, -1, wwc(m_pUniBuff), 0);
- if (wLen >= m_uniBuffLen) {
- if (m_pUniBuff)
- delete [] m_pUniBuff;
- m_pUniBuff = new char16_t[wLen + 64];
- m_uniBuffLen = wLen + 64;
- }
- if (wLen) {
- MultiByteToWideChar(CP_ACP, 0, pStr, -1, wwc(m_pUniBuff), m_uniBuffLen);
- result = m_pUniBuff;
- }
+ NS_CopyNativeToUnicode(nsDependentCString(pStr), result);
}
BOOL CMapiApi::Initialize(void)
{
if (m_initialized)
return TRUE;
HRESULT hr;
@@ -989,17 +972,18 @@ BOOL CMapiApi::IterateStores(CMapiFolder
int strLen = strlen(lpStr);
char16_t * pwszStr = (char16_t *) moz_xmalloc((strLen + 1) * sizeof(WCHAR));
if (!pwszStr) {
// out of memory
FreeProws(lpRow);
lpTable->Release();
return FALSE;
}
- ::MultiByteToWideChar(CP_ACP, 0, lpStr, strlen(lpStr) + 1, wwc(pwszStr), (strLen + 1) * sizeof(WCHAR));
+ ::MultiByteToWideChar(CP_ACP, 0, lpStr, strlen(lpStr) + 1,
+ reinterpret_cast<wchar_t*>(pwszStr), (strLen + 1) * sizeof(WCHAR));
CMapiFolder *pFolder = new CMapiFolder(pwszStr, cbEID, lpEID, 0, MAPI_STORE);
free(pwszStr);
long szContents = 1;
GetStoreInfo(pFolder, &szContents);
MAPI_TRACE1(" DisplayName: %s\n", lpStr);
if (szContents)
--- a/mailnews/import/outlook/src/MapiMessage.cpp
+++ b/mailnews/import/outlook/src/MapiMessage.cpp
@@ -628,18 +628,18 @@ void ExtractMetaCharset(const wchar_t* b
// <META content="text/html; charset=utf-8" http-equiv=Content-Type>
// <META content="text/html; charset=utf-8;" http-equiv=Content-Type>
// <META content="text/html; charset=utf-8 ;" http-equiv=Content-Type>
// <META content="text/html; charset=utf-8 " http-equiv=Content-Type>
const wchar_t term[] = L";\" ", *term_end= term+sizeof(term)/sizeof(term[0])-1;
const wchar_t* chset_end = std::find_first_of(chset_pos, eohd_pos, term,
term_end);
if (chset_end != eohd_pos)
- LossyCopyUTF16toASCII(Substring(wwc(const_cast<wchar_t *>(chset_pos)),
- wwc(const_cast<wchar_t *>(chset_end))),
+ LossyCopyUTF16toASCII(Substring(char16ptr_t(chset_pos),
+ char16ptr_t(chset_end)),
charset);
}
bool CMapiMessage::FetchBody(void)
{
m_bodyIsHtml = false;
m_body.Truncate();
--- a/mailnews/mapi/mapihook/src/msgMapiImp.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiImp.cpp
@@ -162,17 +162,17 @@ 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, wwc(aLogin), wwc(aPassWord),
+ nResult = pConfig->RegisterSession(aUIArg, char16ptr_t(aLogin), char16ptr_t(aPassWord),
(aFlags & MAPI_FORCE_DOWNLOAD), bNewSession,
&nSession_Id, id_key.get());
switch (nResult)
{
case -1 :
{
*aSessionId = MAPI_E_TOO_MANY_SESSIONS;
return hr;