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:
parent
0e76cf0b69
commit
6f4b593285
@ -122,8 +122,7 @@ TMailApp::TMailApp()
|
||||
fAutoMarkRead = true;
|
||||
fSignature = (char*)malloc(strlen(B_TRANSLATE("None")) + 1);
|
||||
strcpy(fSignature, B_TRANSLATE("None"));
|
||||
fReplyPreamble = (char*)malloc(1);
|
||||
fReplyPreamble[0] = '\0';
|
||||
fReplyPreamble = strdup(B_TRANSLATE("%e wrote:%b"));
|
||||
|
||||
fMailWindowFrame.Set(0, 0, 0, 0);
|
||||
fSignatureWindowFrame.Set(6, TITLE_BAR_HEIGHT, 6 + kSigWidth,
|
||||
|
@ -2053,8 +2053,6 @@ TMailWindow::CopyMessage(entry_ref *ref, TMailWindow *src)
|
||||
void
|
||||
TMailWindow::Reply(entry_ref *ref, TMailWindow *window, uint32 type)
|
||||
{
|
||||
const char *notImplementedString = "<Not Yet Implemented>";
|
||||
|
||||
fRepliedMail = *ref;
|
||||
SetOriginatingWindow(window);
|
||||
|
||||
@ -2105,79 +2103,27 @@ TMailWindow::Reply(entry_ref *ref, TMailWindow *window, uint32 type)
|
||||
|
||||
// create preamble string
|
||||
|
||||
BString replyPreamble = fApp->ReplyPreamble();
|
||||
BString preamble = fApp->ReplyPreamble();
|
||||
|
||||
char preamble[1024];
|
||||
const char* from = replyPreamble.String();
|
||||
char* to = preamble;
|
||||
BString name;
|
||||
mail->GetName(&name);
|
||||
if (name.Length() <= 0)
|
||||
name = B_TRANSLATE("(Name unavailable)");
|
||||
|
||||
while (*from) {
|
||||
if (*from == '%') {
|
||||
// insert special content
|
||||
int32 length;
|
||||
BString address(mail->From());
|
||||
if (address.Length() <= 0)
|
||||
address = B_TRANSLATE("(Address unavailable)");
|
||||
|
||||
switch (*++from) {
|
||||
case 'n': // full name
|
||||
{
|
||||
BString fullName(mail->From());
|
||||
if (fullName.Length() <= 0)
|
||||
fullName = "No-From-Address-Available";
|
||||
|
||||
extract_address_name(fullName);
|
||||
length = fullName.Length();
|
||||
memcpy(to, fullName.String(), length);
|
||||
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';
|
||||
BString date(mail->Date());
|
||||
if (date.Length() <= 0)
|
||||
date = B_TRANSLATE("(Date unavailable)");
|
||||
|
||||
preamble.ReplaceAll("%n", name);
|
||||
preamble.ReplaceAll("%e", address);
|
||||
preamble.ReplaceAll("%d", date);
|
||||
preamble.ReplaceAll("%b", "\n");
|
||||
preamble.ReplaceAll("\\n", "\n");
|
||||
// backwards compatability with older settings
|
||||
|
||||
// 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);
|
||||
if (strlen(preamble) > 0)
|
||||
if (preamble.Length() > 0)
|
||||
fContentView->fTextView->Insert(preamble);
|
||||
} else {
|
||||
fContentView->fTextView->LoadMessage(mail, true, preamble);
|
||||
|
@ -484,8 +484,12 @@ TPrefsWindow::MessageReceived(BMessage* msg)
|
||||
}
|
||||
|
||||
BTextView *text = fReplyPreamble->TextView();
|
||||
// To do: insert at selection point rather than at the end.
|
||||
text->Insert(text->TextLength(), item->Label(), 2);
|
||||
int32 selectionStart;
|
||||
int32 selectionEnd;
|
||||
text->GetSelection(&selectionStart, &selectionEnd);
|
||||
if (selectionStart != selectionEnd)
|
||||
text->Delete(selectionStart, selectionEnd);
|
||||
text->Insert(item->Label(), 2);
|
||||
}
|
||||
case P_SIG:
|
||||
free(*fNewSignature);
|
||||
@ -677,29 +681,21 @@ TPrefsWindow::_BuildReplyToMenu(int32 account)
|
||||
BMenu*
|
||||
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);
|
||||
|
||||
for (int32 i = 0; substitutes[i]; i++) {
|
||||
if (*substitutes[i] == '\0') {
|
||||
menu->AddSeparatorItem();
|
||||
} else {
|
||||
menu->AddItem(new BMenuItem(substitutes[i],
|
||||
new BMessage(P_REPLY_PREAMBLE)));
|
||||
}
|
||||
}
|
||||
menu->AddItem(new BMenuItem(B_TRANSLATE("%n - Full name"),
|
||||
new BMessage(P_REPLY_PREAMBLE)));
|
||||
|
||||
menu->AddItem(new BMenuItem(B_TRANSLATE("%e - E-mail address"),
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user