Workaround for ticket #6721 by using %b (line break) instead of \n for newline. (I looked into the string escaping issue in the locale kit and it appears to work as expected, so I don't know.) Simplification of some code. Addition of a default reply preamble. The name variable now results in just the name. Removal of commented out First/Last name variables, as the order of these is culture-dependent. Insert at point of selection.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41158 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -122,8 +122,7 @@ TMailApp::TMailApp()
|
|||||||
fAutoMarkRead = true;
|
fAutoMarkRead = true;
|
||||||
fSignature = (char*)malloc(strlen(B_TRANSLATE("None")) + 1);
|
fSignature = (char*)malloc(strlen(B_TRANSLATE("None")) + 1);
|
||||||
strcpy(fSignature, B_TRANSLATE("None"));
|
strcpy(fSignature, B_TRANSLATE("None"));
|
||||||
fReplyPreamble = (char*)malloc(1);
|
fReplyPreamble = strdup(B_TRANSLATE("%e wrote:%b"));
|
||||||
fReplyPreamble[0] = '\0';
|
|
||||||
|
|
||||||
fMailWindowFrame.Set(0, 0, 0, 0);
|
fMailWindowFrame.Set(0, 0, 0, 0);
|
||||||
fSignatureWindowFrame.Set(6, TITLE_BAR_HEIGHT, 6 + kSigWidth,
|
fSignatureWindowFrame.Set(6, TITLE_BAR_HEIGHT, 6 + kSigWidth,
|
||||||
|
|||||||
@@ -2053,8 +2053,6 @@ TMailWindow::CopyMessage(entry_ref *ref, TMailWindow *src)
|
|||||||
void
|
void
|
||||||
TMailWindow::Reply(entry_ref *ref, TMailWindow *window, uint32 type)
|
TMailWindow::Reply(entry_ref *ref, TMailWindow *window, uint32 type)
|
||||||
{
|
{
|
||||||
const char *notImplementedString = "<Not Yet Implemented>";
|
|
||||||
|
|
||||||
fRepliedMail = *ref;
|
fRepliedMail = *ref;
|
||||||
SetOriginatingWindow(window);
|
SetOriginatingWindow(window);
|
||||||
|
|
||||||
@@ -2105,79 +2103,27 @@ TMailWindow::Reply(entry_ref *ref, TMailWindow *window, uint32 type)
|
|||||||
|
|
||||||
// create preamble string
|
// create preamble string
|
||||||
|
|
||||||
BString replyPreamble = fApp->ReplyPreamble();
|
BString preamble = fApp->ReplyPreamble();
|
||||||
|
|
||||||
char preamble[1024];
|
BString name;
|
||||||
const char* from = replyPreamble.String();
|
mail->GetName(&name);
|
||||||
char* to = preamble;
|
if (name.Length() <= 0)
|
||||||
|
name = B_TRANSLATE("(Name unavailable)");
|
||||||
|
|
||||||
while (*from) {
|
BString address(mail->From());
|
||||||
if (*from == '%') {
|
if (address.Length() <= 0)
|
||||||
// insert special content
|
address = B_TRANSLATE("(Address unavailable)");
|
||||||
int32 length;
|
|
||||||
|
|
||||||
switch (*++from) {
|
BString date(mail->Date());
|
||||||
case 'n': // full name
|
if (date.Length() <= 0)
|
||||||
{
|
date = B_TRANSLATE("(Date unavailable)");
|
||||||
BString fullName(mail->From());
|
|
||||||
if (fullName.Length() <= 0)
|
preamble.ReplaceAll("%n", name);
|
||||||
fullName = "No-From-Address-Available";
|
preamble.ReplaceAll("%e", address);
|
||||||
|
preamble.ReplaceAll("%d", date);
|
||||||
extract_address_name(fullName);
|
preamble.ReplaceAll("%b", "\n");
|
||||||
length = fullName.Length();
|
preamble.ReplaceAll("\\n", "\n");
|
||||||
memcpy(to, fullName.String(), length);
|
// backwards compatability with older settings
|
||||||
to += length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'e': // eMail address
|
|
||||||
{
|
|
||||||
const char *address = mail->From();
|
|
||||||
if (address == NULL)
|
|
||||||
address = "<unknown>";
|
|
||||||
length = strlen(address);
|
|
||||||
memcpy(to, address, length);
|
|
||||||
to += length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'd': // date
|
|
||||||
{
|
|
||||||
const char *date = mail->Date();
|
|
||||||
if (date == NULL)
|
|
||||||
date = "No-Date-Available";
|
|
||||||
length = strlen(date);
|
|
||||||
memcpy(to, date, length);
|
|
||||||
to += length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ToDo: parse stuff!
|
|
||||||
case 'f': // first name
|
|
||||||
case 'l': // last name
|
|
||||||
length = strlen(notImplementedString);
|
|
||||||
memcpy(to, notImplementedString, length);
|
|
||||||
to += length;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: // Sometimes a % is just a %.
|
|
||||||
*to++ = *from;
|
|
||||||
}
|
|
||||||
} else if (*from == '\\') {
|
|
||||||
switch (*++from) {
|
|
||||||
case 'n':
|
|
||||||
*to++ = '\n';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
*to++ = *from;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
*to++ = *from;
|
|
||||||
|
|
||||||
from++;
|
|
||||||
}
|
|
||||||
*to = '\0';
|
|
||||||
|
|
||||||
// insert (if selection) or load (if whole mail) message text into text view
|
// insert (if selection) or load (if whole mail) message text into text view
|
||||||
|
|
||||||
@@ -2216,7 +2162,7 @@ TMailWindow::Reply(entry_ref *ref, TMailWindow *window, uint32 type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fContentView->fTextView->GoToLine(0);
|
fContentView->fTextView->GoToLine(0);
|
||||||
if (strlen(preamble) > 0)
|
if (preamble.Length() > 0)
|
||||||
fContentView->fTextView->Insert(preamble);
|
fContentView->fTextView->Insert(preamble);
|
||||||
} else {
|
} else {
|
||||||
fContentView->fTextView->LoadMessage(mail, true, preamble);
|
fContentView->fTextView->LoadMessage(mail, true, preamble);
|
||||||
|
|||||||
+19
-23
@@ -484,8 +484,12 @@ TPrefsWindow::MessageReceived(BMessage* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BTextView *text = fReplyPreamble->TextView();
|
BTextView *text = fReplyPreamble->TextView();
|
||||||
// To do: insert at selection point rather than at the end.
|
int32 selectionStart;
|
||||||
text->Insert(text->TextLength(), item->Label(), 2);
|
int32 selectionEnd;
|
||||||
|
text->GetSelection(&selectionStart, &selectionEnd);
|
||||||
|
if (selectionStart != selectionEnd)
|
||||||
|
text->Delete(selectionStart, selectionEnd);
|
||||||
|
text->Insert(item->Label(), 2);
|
||||||
}
|
}
|
||||||
case P_SIG:
|
case P_SIG:
|
||||||
free(*fNewSignature);
|
free(*fNewSignature);
|
||||||
@@ -677,29 +681,21 @@ TPrefsWindow::_BuildReplyToMenu(int32 account)
|
|||||||
BMenu*
|
BMenu*
|
||||||
TPrefsWindow::_BuildReplyPreambleMenu()
|
TPrefsWindow::_BuildReplyPreambleMenu()
|
||||||
{
|
{
|
||||||
const char *substitutes[] = {
|
|
||||||
/* To do: Not yet working, leave out for 2.0.0 beta 4:
|
|
||||||
"%f - First name",
|
|
||||||
"%l - Last name",
|
|
||||||
*/
|
|
||||||
B_TRANSLATE("%n - Full name"),
|
|
||||||
B_TRANSLATE("%e - E-mail address"),
|
|
||||||
B_TRANSLATE("%d - Date"),
|
|
||||||
"",
|
|
||||||
B_TRANSLATE("\\n - Newline"),
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
BMenu *menu = new BMenu(B_EMPTY_STRING);
|
BMenu *menu = new BMenu(B_EMPTY_STRING);
|
||||||
|
|
||||||
for (int32 i = 0; substitutes[i]; i++) {
|
menu->AddItem(new BMenuItem(B_TRANSLATE("%n - Full name"),
|
||||||
if (*substitutes[i] == '\0') {
|
new BMessage(P_REPLY_PREAMBLE)));
|
||||||
menu->AddSeparatorItem();
|
|
||||||
} else {
|
menu->AddItem(new BMenuItem(B_TRANSLATE("%e - E-mail address"),
|
||||||
menu->AddItem(new BMenuItem(substitutes[i],
|
new BMessage(P_REPLY_PREAMBLE)));
|
||||||
new BMessage(P_REPLY_PREAMBLE)));
|
|
||||||
}
|
menu->AddItem(new BMenuItem(B_TRANSLATE("%d - Date"),
|
||||||
}
|
new BMessage(P_REPLY_PREAMBLE)));
|
||||||
|
|
||||||
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
|
menu->AddItem(new BMenuItem(B_TRANSLATE("%b - Line break"),
|
||||||
|
new BMessage(P_REPLY_PREAMBLE)));
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user