|
|
|
Lines 400-416
nsresult nsMapiHook::PopulateCompFields(
|
Link Here
|
|---|
|
| 400 |
aCompFields->SetCc (Cc) ; |
400 |
aCompFields->SetCc (Cc) ; |
| 401 |
aCompFields->SetBcc (Bcc) ; |
401 |
aCompFields->SetBcc (Bcc) ; |
| 402 |
|
402 |
|
| 403 |
// set subject |
403 |
// set subject |
| 404 |
if (aMessage->lpszSubject) |
404 |
if (aMessage->lpszSubject) |
| 405 |
aCompFields->SetSubject(NS_ConvertASCIItoUTF16(aMessage->lpszSubject)); |
405 |
aCompFields->SetSubject(NS_ConvertASCIItoUTF16(aMessage->lpszSubject)); |
| 406 |
|
406 |
|
| 407 |
// handle attachments as File URL |
407 |
// handle attachments as File URL |
| 408 |
rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, true) ; |
408 |
rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles) ; |
| 409 |
if (NS_FAILED(rv)) return rv ; |
409 |
if (NS_FAILED(rv)) return rv ; |
| 410 |
|
410 |
|
| 411 |
// set body |
411 |
// set body |
| 412 |
if (aMessage->lpszNoteText) |
412 |
if (aMessage->lpszNoteText) |
| 413 |
{ |
413 |
{ |
| 414 |
nsString Body; |
414 |
nsString Body; |
| 415 |
CopyASCIItoUTF16(mozilla::MakeStringSpan(aMessage->lpszNoteText), Body); |
415 |
CopyASCIItoUTF16(mozilla::MakeStringSpan(aMessage->lpszNoteText), Body); |
| 416 |
if (Body.IsEmpty() || Body.Last() != '\n') |
416 |
if (Body.IsEmpty() || Body.Last() != '\n') |
|
Lines 422-458
nsresult nsMapiHook::PopulateCompFields(
|
Link Here
|
|---|
|
| 422 |
aCompFields->SetForcePlainText(true); |
422 |
aCompFields->SetForcePlainText(true); |
| 423 |
|
423 |
|
| 424 |
rv = aCompFields->SetBody(Body) ; |
424 |
rv = aCompFields->SetBody(Body) ; |
| 425 |
} |
425 |
} |
| 426 |
return rv ; |
426 |
return rv ; |
| 427 |
} |
427 |
} |
| 428 |
|
428 |
|
| 429 |
nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, int32_t aFileCount, |
429 |
nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, int32_t aFileCount, |
| 430 |
lpnsMapiFileDesc aFiles, BOOL aIsUnicode) |
430 |
lpnsMapiFileDesc aFiles) |
| 431 |
{ |
431 |
{ |
| 432 |
nsresult rv = NS_OK ; |
432 |
nsresult rv = NS_OK ; |
| 433 |
|
433 |
|
| 434 |
nsAutoCString Attachments ; |
434 |
nsAutoCString Attachments ; |
| 435 |
nsAutoCString TempFiles ; |
435 |
nsAutoCString TempFiles ; |
| 436 |
|
436 |
|
| 437 |
nsCOMPtr <nsIFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ; |
437 |
nsCOMPtr <nsIFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ; |
| 438 |
if (NS_FAILED(rv) || (!pFile) ) return rv ; |
438 |
if (NS_FAILED(rv) || (!pFile) ) return rv ; |
| 439 |
nsCOMPtr <nsIFile> pTempDir = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ; |
439 |
nsCOMPtr <nsIFile> pTempDir = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ; |
| 440 |
if (NS_FAILED(rv) || (!pTempDir) ) return rv ; |
440 |
if (NS_FAILED(rv) || (!pTempDir) ) return rv ; |
| 441 |
|
441 |
|
| 442 |
for (int i=0 ; i < aFileCount ; i++) |
442 |
for (int i=0 ; i < aFileCount ; i++) |
| 443 |
{ |
443 |
{ |
| 444 |
if (aFiles[i].lpszPathName) |
444 |
if (aFiles[i].lpszPathName) |
| 445 |
{ |
445 |
{ |
| 446 |
// check if attachment exists |
446 |
pFile->InitWithNativePath (nsDependentCString(aFiles[i].lpszPathName)); |
| 447 |
if (aIsUnicode) |
|
|
| 448 |
pFile->InitWithPath (nsDependentString(aFiles[i].lpszPathName)); |
| 449 |
else |
| 450 |
pFile->InitWithNativePath (nsDependentCString((const char*)aFiles[i].lpszPathName)); |
| 451 |
|
447 |
|
| 452 |
bool bExist ; |
448 |
bool bExist ; |
| 453 |
rv = pFile->Exists(&bExist) ; |
449 |
rv = pFile->Exists(&bExist) ; |
| 454 |
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")); |
450 |
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")); |
| 455 |
if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ; |
451 |
if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ; |
| 456 |
|
452 |
|
| 457 |
//Temp Directory |
453 |
//Temp Directory |
| 458 |
nsCOMPtr <nsIFile> pTempDir; |
454 |
nsCOMPtr <nsIFile> pTempDir; |
|
Lines 471-491
nsresult nsMapiHook::HandleAttachments (
|
Link Here
|
|---|
|
| 471 |
|
467 |
|
| 472 |
nsAutoString leafName ; |
468 |
nsAutoString leafName ; |
| 473 |
// convert to Unicode using Platform charset |
469 |
// convert to Unicode using Platform charset |
| 474 |
// leafName already contains a unicode leafName from lpszPathName. If we were given |
470 |
// leafName already contains a unicode leafName from lpszPathName. If we were given |
| 475 |
// a value for lpszFileName, use it. Otherwise stick with leafName |
471 |
// a value for lpszFileName, use it. Otherwise stick with leafName |
| 476 |
if (aFiles[i].lpszFileName) |
472 |
if (aFiles[i].lpszFileName) |
| 477 |
{ |
473 |
{ |
| 478 |
nsAutoString wholeFileName; |
474 |
nsAutoString wholeFileName; |
| 479 |
if (aIsUnicode) |
475 |
NS_CopyNativeToUnicode(nsDependentCString(aFiles[i].lpszFileName), |
| 480 |
wholeFileName.Assign(aFiles[i].lpszFileName); |
476 |
wholeFileName); |
| 481 |
else |
477 |
|
| 482 |
NS_CopyNativeToUnicode(nsDependentCString((char *) aFiles[i].lpszFileName), |
|
|
| 483 |
wholeFileName); |
| 484 |
// need to find the last '\' and find the leafname from that. |
478 |
// need to find the last '\' and find the leafname from that. |
| 485 |
int32_t lastSlash = wholeFileName.RFindChar(char16_t('\\')); |
479 |
int32_t lastSlash = wholeFileName.RFindChar(char16_t('\\')); |
| 486 |
if (lastSlash != kNotFound) |
480 |
if (lastSlash != kNotFound) |
| 487 |
leafName.Assign(Substring(wholeFileName, lastSlash + 1)); |
481 |
leafName.Assign(Substring(wholeFileName, lastSlash + 1)); |
| 488 |
else |
482 |
else |
| 489 |
leafName.Assign(wholeFileName); |
483 |
leafName.Assign(wholeFileName); |
| 490 |
} |
484 |
} |
| 491 |
else |
485 |
else |
|
Lines 603-619
nsresult nsMapiHook::PopulateCompFieldsW
|
Link Here
|
|---|
|
| 603 |
nsAutoString Subject ; |
597 |
nsAutoString Subject ; |
| 604 |
rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszSubject), |
598 |
rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszSubject), |
| 605 |
Subject); |
599 |
Subject); |
| 606 |
if (NS_FAILED(rv)) return rv; |
600 |
if (NS_FAILED(rv)) return rv; |
| 607 |
aCompFields->SetSubject(Subject); |
601 |
aCompFields->SetSubject(Subject); |
| 608 |
} |
602 |
} |
| 609 |
|
603 |
|
| 610 |
// handle attachments as File URL |
604 |
// handle attachments as File URL |
| 611 |
rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, false) ; |
605 |
rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles) ; |
| 612 |
if (NS_FAILED(rv)) return rv ; |
606 |
if (NS_FAILED(rv)) return rv ; |
| 613 |
|
607 |
|
| 614 |
// set body |
608 |
// set body |
| 615 |
if (aMessage->lpszNoteText) |
609 |
if (aMessage->lpszNoteText) |
| 616 |
{ |
610 |
{ |
| 617 |
nsAutoString Body ; |
611 |
nsAutoString Body ; |
| 618 |
rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszNoteText), |
612 |
rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszNoteText), |
| 619 |
Body); |
613 |
Body); |