* Send() now hides the window to hide eventual delays while composing the mail.
* Removed error code from error messages. * Simplified the X-Mailer string and version information (we could eventually add the SVN revision there, though). * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21225 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+49
-53
@@ -3198,6 +3198,10 @@ TMailWindow::Send(bool now)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Hide();
|
||||||
|
// depending on the system (and I/O) load, this could take a while
|
||||||
|
// but the user shouldn't be left waiting
|
||||||
|
|
||||||
if (fHeaderView != NULL)
|
if (fHeaderView != NULL)
|
||||||
characterSetToUse = fHeaderView->fCharacterSetUserSees;
|
characterSetToUse = fHeaderView->fCharacterSetUserSees;
|
||||||
|
|
||||||
@@ -3206,22 +3210,22 @@ TMailWindow::Send(bool now)
|
|||||||
// particularly Japanese stuff, they only understand base64. They also
|
// particularly Japanese stuff, they only understand base64. They also
|
||||||
// prefer it for the smaller size. Later on this will be reduced to 7bit
|
// prefer it for the smaller size. Later on this will be reduced to 7bit
|
||||||
// if the encoded text is just 7bit characters.
|
// if the encoded text is just 7bit characters.
|
||||||
if (characterSetToUse == B_SJIS_CONVERSION ||
|
if (characterSetToUse == B_SJIS_CONVERSION
|
||||||
characterSetToUse == B_EUC_CONVERSION)
|
|| characterSetToUse == B_EUC_CONVERSION)
|
||||||
encodingForBody = base64;
|
encodingForBody = base64;
|
||||||
else if (characterSetToUse == B_JIS_CONVERSION ||
|
else if (characterSetToUse == B_JIS_CONVERSION
|
||||||
characterSetToUse == B_MAIL_US_ASCII_CONVERSION ||
|
|| characterSetToUse == B_MAIL_US_ASCII_CONVERSION
|
||||||
characterSetToUse == B_ISO1_CONVERSION ||
|
|| characterSetToUse == B_ISO1_CONVERSION
|
||||||
characterSetToUse == B_EUC_KR_CONVERSION)
|
|| characterSetToUse == B_EUC_KR_CONVERSION)
|
||||||
encodingForBody = eight_bit;
|
encodingForBody = eight_bit;
|
||||||
|
|
||||||
// Using quoted printable headers on almost completely non-ASCII Japanese
|
// Using quoted printable headers on almost completely non-ASCII Japanese
|
||||||
// is a waste of time. Besides, some stupid cell phone services need
|
// is a waste of time. Besides, some stupid cell phone services need
|
||||||
// base64 in the headers.
|
// base64 in the headers.
|
||||||
if (characterSetToUse == B_SJIS_CONVERSION ||
|
if (characterSetToUse == B_SJIS_CONVERSION
|
||||||
characterSetToUse == B_EUC_CONVERSION ||
|
|| characterSetToUse == B_EUC_CONVERSION
|
||||||
characterSetToUse == B_JIS_CONVERSION ||
|
|| characterSetToUse == B_JIS_CONVERSION
|
||||||
characterSetToUse == B_EUC_KR_CONVERSION)
|
|| characterSetToUse == B_EUC_KR_CONVERSION)
|
||||||
encodingForHeaders = base64;
|
encodingForHeaders = base64;
|
||||||
|
|
||||||
// Count the number of characters in the message body which aren't in the
|
// Count the number of characters in the message body which aren't in the
|
||||||
@@ -3229,25 +3233,22 @@ TMailWindow::Send(bool now)
|
|||||||
// text can safely use 7 bit characters.
|
// text can safely use 7 bit characters.
|
||||||
if (fContentView->fTextView->TextLength() > 0) {
|
if (fContentView->fTextView->TextLength() > 0) {
|
||||||
// First do a trial encoding with the user's character set.
|
// First do a trial encoding with the user's character set.
|
||||||
int32 converterState = 0;
|
int32 converterState = 0;
|
||||||
int32 originalLength;
|
int32 originalLength;
|
||||||
BString tempString;
|
BString tempString;
|
||||||
int32 tempStringLength;
|
int32 tempStringLength;
|
||||||
char *tempStringPntr;
|
char* tempStringPntr;
|
||||||
originalLength = fContentView->fTextView->TextLength();
|
originalLength = fContentView->fTextView->TextLength();
|
||||||
tempStringLength = originalLength *
|
tempStringLength = originalLength *
|
||||||
6 /* Some character sets bloat up on escape codes */;
|
6 /* Some character sets bloat up on escape codes */;
|
||||||
tempStringPntr = tempString.LockBuffer (tempStringLength);
|
tempStringPntr = tempString.LockBuffer (tempStringLength);
|
||||||
if (tempStringPntr != NULL &&
|
if (tempStringPntr != NULL && mail_convert_from_utf8(characterSetToUse,
|
||||||
B_OK == mail_convert_from_utf8 (
|
fContentView->fTextView->Text(), &originalLength,
|
||||||
characterSetToUse,
|
tempStringPntr, &tempStringLength, &converterState,
|
||||||
fContentView->fTextView->Text(), &originalLength,
|
0x1A /* used for unknown characters */) == B_OK) {
|
||||||
tempStringPntr, &tempStringLength, &converterState,
|
|
||||||
0x1A /* The code to substitute for unknown characters */)) {
|
|
||||||
|
|
||||||
// Check for any characters which don't fit in a 7 bit encoding.
|
// Check for any characters which don't fit in a 7 bit encoding.
|
||||||
int i;
|
int i;
|
||||||
bool has8Bit = false;
|
bool has8Bit = false;
|
||||||
for (i = 0; i < tempStringLength; i++)
|
for (i = 0; i < tempStringLength; i++)
|
||||||
if (tempString[i] == 0 || (tempString[i] & 0x80)) {
|
if (tempString[i] == 0 || (tempString[i] & 0x80)) {
|
||||||
has8Bit = true;
|
has8Bit = true;
|
||||||
@@ -3259,8 +3260,8 @@ TMailWindow::Send(bool now)
|
|||||||
|
|
||||||
// Count up the number of unencoded characters and warn the user about them.
|
// Count up the number of unencoded characters and warn the user about them.
|
||||||
if (gWarnAboutUnencodableCharacters) {
|
if (gWarnAboutUnencodableCharacters) {
|
||||||
int32 offset = 0;
|
int32 offset = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (offset >= 0) {
|
while (offset >= 0) {
|
||||||
offset = tempString.FindFirst (0x1A, offset);
|
offset = tempString.FindFirst (0x1A, offset);
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
@@ -3269,7 +3270,7 @@ TMailWindow::Send(bool now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
int32 userAnswer;
|
int32 userAnswer;
|
||||||
BString messageString;
|
BString messageString;
|
||||||
MDR_DIALECT_CHOICE (
|
MDR_DIALECT_CHOICE (
|
||||||
messageString << "Your main text contains " << count <<
|
messageString << "Your main text contains " << count <<
|
||||||
@@ -3303,8 +3304,7 @@ TMailWindow::Send(bool now)
|
|||||||
if (fResending) {
|
if (fResending) {
|
||||||
BFile file(fRef, O_RDONLY);
|
BFile file(fRef, O_RDONLY);
|
||||||
result = file.InitCheck();
|
result = file.InitCheck();
|
||||||
if (result == B_OK)
|
if (result == B_OK) {
|
||||||
{
|
|
||||||
BEmailMessage mail(&file);
|
BEmailMessage mail(&file);
|
||||||
mail.SetTo(fHeaderView->fTo->Text(), characterSetToUse, encodingForHeaders);
|
mail.SetTo(fHeaderView->fTo->Text(), characterSetToUse, encodingForHeaders);
|
||||||
|
|
||||||
@@ -3322,40 +3322,34 @@ TMailWindow::Send(bool now)
|
|||||||
// CC field meant that it got sent out anyway, so pass in empty strings
|
// CC field meant that it got sent out anyway, so pass in empty strings
|
||||||
// when changing the header to force it to remove the header.
|
// when changing the header to force it to remove the header.
|
||||||
|
|
||||||
fMail->SetTo(fHeaderView->fTo->Text(), characterSetToUse, encodingForHeaders);
|
fMail->SetTo(fHeaderView->fTo->Text(), characterSetToUse,
|
||||||
fMail->SetSubject(fHeaderView->fSubject->Text(), characterSetToUse, encodingForHeaders);
|
encodingForHeaders);
|
||||||
fMail->SetCC(fHeaderView->fCc->Text(), characterSetToUse, encodingForHeaders);
|
fMail->SetSubject(fHeaderView->fSubject->Text(), characterSetToUse,
|
||||||
|
encodingForHeaders);
|
||||||
|
fMail->SetCC(fHeaderView->fCc->Text(), characterSetToUse,
|
||||||
|
encodingForHeaders);
|
||||||
fMail->SetBCC(fHeaderView->fBcc->Text());
|
fMail->SetBCC(fHeaderView->fBcc->Text());
|
||||||
|
|
||||||
//--- Add X-Mailer field
|
//--- Add X-Mailer field
|
||||||
{
|
{
|
||||||
// get app version
|
// get app version
|
||||||
version_info versionInfo;
|
version_info info;
|
||||||
memset(&versionInfo, 0, sizeof(version_info));
|
memset(&info, 0, sizeof(version_info));
|
||||||
|
|
||||||
app_info appInfo;
|
app_info appInfo;
|
||||||
if (be_app->GetAppInfo(&appInfo) == B_OK) {
|
if (be_app->GetAppInfo(&appInfo) == B_OK) {
|
||||||
BFile file(&appInfo.ref, B_READ_ONLY);
|
BFile file(&appInfo.ref, B_READ_ONLY);
|
||||||
if (file.InitCheck() == B_OK) {
|
if (file.InitCheck() == B_OK) {
|
||||||
BAppFileInfo info(&file);
|
BAppFileInfo appFileInfo(&file);
|
||||||
if (info.InitCheck() == B_OK)
|
if (appFileInfo.InitCheck() == B_OK)
|
||||||
info.GetVersionInfo(&versionInfo, B_APP_VERSION_KIND);
|
appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// prepare version variety string
|
|
||||||
const char *varietyStrings[] = {
|
|
||||||
"Development", "Alpha", "Beta",
|
|
||||||
"Gamma", "Golden master", "Final"
|
|
||||||
};
|
|
||||||
char varietyString[32];
|
|
||||||
strcpy(varietyString, varietyStrings[versionInfo.variety % 6]);
|
|
||||||
if (versionInfo.variety < 5)
|
|
||||||
sprintf(varietyString + strlen(varietyString), "/%li", versionInfo.internal);
|
|
||||||
|
|
||||||
char versionString[255];
|
char versionString[255];
|
||||||
sprintf(versionString,
|
sprintf(versionString,
|
||||||
"Mail - Mail Daemon Replacement %ld.%ld.%ld %s",
|
"Mail/Haiku %ld.%ld.%ld",
|
||||||
versionInfo.major, versionInfo.middle, versionInfo.minor, varietyString);
|
info.major, info.middle, info.minor);
|
||||||
fMail->SetHeaderField("X-Mailer", versionString);
|
fMail->SetHeaderField("X-Mailer", versionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3432,9 +3426,10 @@ TMailWindow::Send(bool now)
|
|||||||
result = be_roster->Launch("application/x-vnd.Be-POST");
|
result = be_roster->Launch("application/x-vnd.Be-POST");
|
||||||
if (result == B_OK)
|
if (result == B_OK)
|
||||||
BMailDaemon::SendQueuedMail();
|
BMailDaemon::SendQueuedMail();
|
||||||
else
|
else {
|
||||||
sprintf(errorMessage,"The mail_daemon could not be started:\n (0x%.8lx) %s",
|
sprintf(errorMessage,"The mail_daemon could not be started:\n\t%s",
|
||||||
result,strerror(result));
|
strerror(result));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3450,8 +3445,9 @@ TMailWindow::Send(bool now)
|
|||||||
// break;
|
// break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sprintf(errorMessage, "An error occurred trying to send mail (0x%.8lx): %s",
|
sprintf(errorMessage, "An error occurred trying to send mail:\n\t%s",
|
||||||
result,strerror(result));
|
strerror(result));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != B_NO_ERROR && result != B_MAIL_NO_DAEMON) {
|
if (result != B_NO_ERROR && result != B_MAIL_NO_DAEMON) {
|
||||||
|
|||||||
Reference in New Issue
Block a user