Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 9036207 Details for
Bug 393302
[patch]
393302-v2.patch
393302-v2.patch (text/plain), 13.79 KB, created by
Kai Engert [:KaiE:]
(
hide
)
Description:
393302-v2.patch
Filename:
MIME Type:
Creator:
Kai Engert [:KaiE:]
Size:
13.79 KB
patch
obsolete
>diff --git a/mailnews/mapi/mapiDll/MapiDll.cpp b/mailnews/mapi/mapiDll/MapiDll.cpp >--- a/mailnews/mapi/mapiDll/MapiDll.cpp >+++ b/mailnews/mapi/mapiDll/MapiDll.cpp >@@ -207,47 +207,85 @@ ULONG FAR PASCAL MAPISendMail (LHANDLE l > if (hr != SUCCESS_SUCCESS) > return MAPI_E_LOGIN_FAILURE ; > bTempSession = TRUE ; > } > > // we need to deal with null data passed in by MAPI clients, specially when MAPI_DIALOG is set. > // The MS COM type lib code generated by MIDL for the MS COM interfaces checks for these parameters > // to be non null, although null is a valid value for them here. >- nsMapiRecipDesc * lpRecips ; >- nsMapiFileDesc * lpFiles ; >+ >+ nsMapiMessage *Message = (nsMapiMessage *)CoTaskMemAlloc(sizeof(nsMapiMessage)); >+ if (!Message) { >+ return MAPI_E_INSUFFICIENT_MEMORY; >+ } > >- nsMapiMessage Message ; >- memset (&Message, 0, sizeof (nsMapiMessage) ) ; >- nsMapiRecipDesc Recipient ; >- memset (&Recipient, 0, sizeof (nsMapiRecipDesc) ); >- nsMapiFileDesc Files ; >- memset (&Files, 0, sizeof (nsMapiFileDesc) ) ; >- >- if(!lpMessage) >- { >- lpMessage = &Message ; >+ memset (Message, 0, sizeof (nsMapiMessage) ) ; >+ if (lpMessage->lpszSubject) { >+ Message->lpszSubject = (LPSTR)CoTaskMemAlloc(1+strlen(lpMessage->lpszSubject)); >+ strcpy(Message->lpszSubject, lpMessage->lpszSubject); >+ } >+ if (lpMessage->lpszNoteText) { >+ Message->lpszNoteText = (LPSTR)CoTaskMemAlloc(1+strlen(lpMessage->lpszNoteText)); >+ strcpy(Message->lpszNoteText, lpMessage->lpszNoteText); >+ } >+ if (lpMessage->lpszMessageType) { >+ Message->lpszMessageType = (LPSTR)CoTaskMemAlloc(1+strlen(lpMessage->lpszMessageType)); >+ strcpy(Message->lpszMessageType, lpMessage->lpszMessageType); >+ } >+ if (lpMessage->lpszDateReceived) { >+ Message->lpszDateReceived = (LPSTR)CoTaskMemAlloc(1+strlen(lpMessage->lpszDateReceived)); >+ strcpy(Message->lpszDateReceived, lpMessage->lpszDateReceived); > } >- if(!lpMessage->lpRecips) >- { >- lpRecips = &Recipient ; >+ >+ nsMapiRecipDesc *Recipients; >+ if (lpMessage->nRecipCount == 0) { >+ Recipients = (nsMapiRecipDesc *)CoTaskMemAlloc(sizeof(nsMapiRecipDesc)); >+ memset (Recipients, 0, sizeof (nsMapiRecipDesc) ); >+ } else { >+ Recipients = (nsMapiRecipDesc *)CoTaskMemAlloc(lpMessage->nRecipCount * sizeof(nsMapiRecipDesc)); >+ memset (Recipients, 0, lpMessage->nRecipCount * sizeof (nsMapiRecipDesc) ); >+ for (int i = 0; i < lpMessage->nRecipCount; ++i) { >+ if (lpMessage->lpRecips[i].lpszName) { >+ size_t len = strlen(lpMessage->lpRecips[i].lpszName); >+ Recipients[i].lpszName = (LPSTR)CoTaskMemAlloc(1 + len); >+ strcpy(Recipients[i].lpszName, lpMessage->lpRecips[i].lpszName); >+ } >+ if (lpMessage->lpRecips[i].lpszAddress) { >+ size_t len = strlen(lpMessage->lpRecips[i].lpszAddress); >+ Recipients[i].lpszAddress = (LPSTR)CoTaskMemAlloc(1 + len); >+ strcpy(Recipients[i].lpszAddress, lpMessage->lpRecips[i].lpszAddress); >+ } >+ } > } >- else >- lpRecips = lpMessage->lpRecips ; >- if(!lpMessage->lpFiles) >- { >- lpFiles = &Files ; >+ nsMapiFileDesc *Files; >+ if (lpMessage->nFileCount == 0) { >+ Files = (nsMapiFileDesc *)CoTaskMemAlloc(sizeof(nsMapiFileDesc)); >+ memset (Files, 0, sizeof (nsMapiFileDesc) ); >+ } else { >+ Files = (nsMapiFileDesc *)CoTaskMemAlloc(lpMessage->nFileCount * sizeof(nsMapiFileDesc)); >+ memset (Files, 0, lpMessage->nFileCount * sizeof (nsMapiFileDesc) ); >+ for (int i = 0; i < lpMessage->nFileCount; ++i) { >+ if (lpMessage->lpFiles[i].lpszPathName) { >+ size_t len = strlen(lpMessage->lpFiles[i].lpszPathName); >+ Files[i].lpszPathName = (LPSTR)CoTaskMemAlloc(1 + len); >+ strcpy(Files[i].lpszPathName, lpMessage->lpFiles[i].lpszPathName); >+ } >+ if (lpMessage->lpFiles[i].lpszFileName) { >+ size_t len = strlen(lpMessage->lpFiles[i].lpszFileName); >+ Files[i].lpszFileName = (LPSTR)CoTaskMemAlloc(1 + len); >+ strcpy(Files[i].lpszFileName, lpMessage->lpFiles[i].lpszFileName); >+ } >+ } > } >- else >- lpFiles = lpMessage->lpFiles ; > >- hr = pNsMapi->SendMail (lhSession, lpMessage, >- (short) lpMessage->nRecipCount, lpRecips, >- (short) lpMessage->nFileCount, lpFiles, >- flFlags, ulReserved); >+ hr = pNsMapi->SendMail(lhSession, Message, >+ (short) lpMessage->nRecipCount, Recipients, >+ (short) lpMessage->nFileCount, Files, >+ flFlags, ulReserved); > > // we are seeing a problem when using Word, although we return success from the MAPI support > // MS COM interface in mozilla, we are getting this error here. This is a temporary hack !! > if (hr == 0x800703e6) > hr = SUCCESS_SUCCESS; > > if (bTempSession) > MAPILogoff (lhSession, ulUIParam, 0,0) ; >diff --git a/mailnews/mapi/mapihook/build/msgMapi.idl b/mailnews/mapi/mapihook/build/msgMapi.idl >--- a/mailnews/mapi/mapihook/build/msgMapi.idl >+++ b/mailnews/mapi/mapihook/build/msgMapi.idl >@@ -9,18 +9,18 @@ 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 */ >- LPTSTR lpszPathName; /* Full path name including file name */ >- LPTSTR lpszFileName; /* Real (original) file name */ >+ LPSTR lpszPathName; /* Full path name including file name */ >+ LPSTR lpszFileName; /* Real (original) file name */ > unsigned char * lpFileType_NotUsed ; > } nsMapiFileDesc, * lpnsMapiFileDesc; > > > typedef struct > { > unsigned long ulReserved; > unsigned long ulRecipClass; /* MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG */ >diff --git a/mailnews/mapi/mapihook/src/msgMapiHook.cpp b/mailnews/mapi/mapihook/src/msgMapiHook.cpp >--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp >+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp >@@ -400,17 +400,17 @@ nsresult nsMapiHook::PopulateCompFields( > aCompFields->SetCc (Cc) ; > aCompFields->SetBcc (Bcc) ; > > // set subject > if (aMessage->lpszSubject) > aCompFields->SetSubject(NS_ConvertASCIItoUTF16(aMessage->lpszSubject)); > > // handle attachments as File URL >- rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, true) ; >+ rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles) ; > if (NS_FAILED(rv)) return rv ; > > // set body > if (aMessage->lpszNoteText) > { > nsString Body; > CopyASCIItoUTF16(mozilla::MakeStringSpan(aMessage->lpszNoteText), Body); > if (Body.IsEmpty() || Body.Last() != '\n') >@@ -422,37 +422,33 @@ nsresult nsMapiHook::PopulateCompFields( > aCompFields->SetForcePlainText(true); > > rv = aCompFields->SetBody(Body) ; > } > return rv ; > } > > nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, int32_t aFileCount, >- lpnsMapiFileDesc aFiles, BOOL aIsUnicode) >+ lpnsMapiFileDesc aFiles) > { > nsresult rv = NS_OK ; > > nsAutoCString Attachments ; > nsAutoCString TempFiles ; > > nsCOMPtr <nsIFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ; > if (NS_FAILED(rv) || (!pFile) ) return rv ; > nsCOMPtr <nsIFile> pTempDir = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ; > if (NS_FAILED(rv) || (!pTempDir) ) return rv ; > > for (int i=0 ; i < aFileCount ; i++) > { > if (aFiles[i].lpszPathName) > { >- // check if attachment exists >- if (aIsUnicode) >- pFile->InitWithPath (nsDependentString(aFiles[i].lpszPathName)); >- else >- pFile->InitWithNativePath (nsDependentCString((const char*)aFiles[i].lpszPathName)); >+ pFile->InitWithNativePath (nsDependentCString(aFiles[i].lpszPathName)); > > bool bExist ; > rv = pFile->Exists(&bExist) ; > MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("nsMapiHook::HandleAttachments: filename: %s path: %s exists = %s \n", (const char*)aFiles[i].lpszFileName, (const char*)aFiles[i].lpszPathName, bExist ? "true" : "false")); > if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ; > > //Temp Directory > nsCOMPtr <nsIFile> pTempDir; >@@ -471,21 +467,19 @@ nsresult nsMapiHook::HandleAttachments ( > > nsAutoString leafName ; > // convert to Unicode using Platform charset > // leafName already contains a unicode leafName from lpszPathName. If we were given > // a value for lpszFileName, use it. Otherwise stick with leafName > if (aFiles[i].lpszFileName) > { > nsAutoString wholeFileName; >- if (aIsUnicode) >- wholeFileName.Assign(aFiles[i].lpszFileName); >- else >- NS_CopyNativeToUnicode(nsDependentCString((char *) aFiles[i].lpszFileName), >- wholeFileName); >+ NS_CopyNativeToUnicode(nsDependentCString(aFiles[i].lpszFileName), >+ wholeFileName); >+ > // need to find the last '\' and find the leafname from that. > int32_t lastSlash = wholeFileName.RFindChar(char16_t('\\')); > if (lastSlash != kNotFound) > leafName.Assign(Substring(wholeFileName, lastSlash + 1)); > else > leafName.Assign(wholeFileName); > } > else >@@ -603,17 +597,17 @@ nsresult nsMapiHook::PopulateCompFieldsW > nsAutoString Subject ; > rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszSubject), > Subject); > if (NS_FAILED(rv)) return rv; > aCompFields->SetSubject(Subject); > } > > // handle attachments as File URL >- rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, false) ; >+ rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles) ; > if (NS_FAILED(rv)) return rv ; > > // set body > if (aMessage->lpszNoteText) > { > nsAutoString Body ; > rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszNoteText), > Body); >diff --git a/mailnews/mapi/mapihook/src/msgMapiHook.h b/mailnews/mapi/mapihook/src/msgMapiHook.h >--- a/mailnews/mapi/mapihook/src/msgMapiHook.h >+++ b/mailnews/mapi/mapihook/src/msgMapiHook.h >@@ -19,15 +19,15 @@ class nsMapiHook > static nsresult BlindSendMail (unsigned long aSession, nsIMsgCompFields * aCompFields) ; > static nsresult ShowComposerWindow (unsigned long aSession, nsIMsgCompFields * aCompFields) ; > static nsresult PopulateCompFields(lpnsMapiMessage aMessage, nsIMsgCompFields * aCompFields) ; > static nsresult PopulateCompFieldsWithConversion(lpnsMapiMessage aMessage, > nsIMsgCompFields * aCompFields) ; > static nsresult PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompFields, > ULONG aFlags, LPTSTR aDelimChar, LPTSTR aFilePaths) ; > static nsresult HandleAttachments (nsIMsgCompFields * aCompFields, int32_t aFileCount, >- lpnsMapiFileDesc aFiles, BOOL aIsUnicode) ; >+ lpnsMapiFileDesc aFiles) ; > static void CleanUp(); > > static bool isMapiService; > }; > > #endif // MSG_MAPI_HOOK_H_ >diff --git a/mailnews/mapi/mapihook/src/msgMapiImp.cpp b/mailnews/mapi/mapihook/src/msgMapiImp.cpp >--- a/mailnews/mapi/mapihook/src/msgMapiImp.cpp >+++ b/mailnews/mapi/mapihook/src/msgMapiImp.cpp >@@ -201,17 +201,19 @@ STDMETHODIMP CMapiImp::SendMail( unsigne > short aRecipCount, lpnsMapiRecipDesc aRecips , short aFileCount, lpnsMapiFileDesc aFiles , > unsigned long aFlags, unsigned long aReserved) > { > nsresult rv = NS_OK ; > > MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::SendMail using flags %d\n", aFlags)); > // Assign the pointers in the aMessage struct to the array of Recips and Files > // received here from MS COM. These are used in BlindSendMail and ShowCompWin fns >+ aMessage->nRecipCount = aRecipCount; > aMessage->lpRecips = aRecips ; >+ aMessage->nFileCount = aFileCount; > aMessage->lpFiles = aFiles ; > > MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("CMapiImp::SendMail flags=%x subject: %s sender: %s\n", > aFlags, (char *) aMessage->lpszSubject, (aMessage->lpOriginator) ? aMessage->lpOriginator->lpszAddress : "")); > > /** 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 ; >@@ -229,16 +231,22 @@ STDMETHODIMP CMapiImp::SendMail( unsigne > rv = nsMapiHook::BlindSendMail(aSession, pCompFields); > } > else > { > rv = nsMapiHook::ShowComposerWindow(aSession, pCompFields); > } > } > >+ // revert back to the original state at the start of this function >+ aMessage->nRecipCount = 0; >+ aMessage->lpRecips = NULL ; >+ aMessage->nFileCount = 0; >+ aMessage->lpFiles = NULL ; >+ > return nsMAPIConfiguration::GetMAPIErrorFromNSError (rv) ; > } > > > STDMETHODIMP CMapiImp::SendDocuments( unsigned long aSession, LPTSTR aDelimChar, > LPTSTR aFilePaths, LPTSTR aFileNames, ULONG aFlags) > { > nsresult rv = NS_OK ;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Flags:
jorgk-bmo
: review+
Actions:
View
|
Diff
|
Review
Attachments on
bug 393302
:
8822226
|
9036164
|
9036206
|
9036207
|
9036358
|
9036387
|
9036440
|
9036603
|
9037162
|
9037169
|
9037227
|
9037303
|
9037311
|
9038021