use textencodings
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9912 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+50
-19
@@ -56,6 +56,12 @@ All rights reserved.
|
|||||||
#include <MailSettings.h>
|
#include <MailSettings.h>
|
||||||
#include <MailMessage.h>
|
#include <MailMessage.h>
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
|
#include <CharacterSet.h>
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
#include "Mail.h"
|
#include "Mail.h"
|
||||||
#include "Header.h"
|
#include "Header.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
@@ -154,27 +160,52 @@ THeaderView::THeaderView (
|
|||||||
// (because the adjacent pop-up menu can't resize dynamically due to a BeOS
|
// (because the adjacent pop-up menu can't resize dynamically due to a BeOS
|
||||||
// bug).
|
// bug).
|
||||||
|
|
||||||
bool marked;
|
float widestCharacterSet = 0;
|
||||||
float widestCharacterSet;
|
bool marked_charset = false;
|
||||||
|
BMenuItem * item;
|
||||||
|
|
||||||
fEncodingMenu = new BPopUpMenu (B_EMPTY_STRING);
|
fEncodingMenu = new BPopUpMenu (B_EMPTY_STRING);
|
||||||
marked = false;
|
|
||||||
widestCharacterSet = 0;
|
BCharacterSetRoster roster;
|
||||||
for (int32 i = 0; true; i++) {
|
BCharacterSet charset;
|
||||||
if (kEncodings[i].flavor == B_MAIL_NULL_CONVERSION && (resending || !fIncoming))
|
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
|
||||||
break; // Composing a new message, don't display last "Automatic" item.
|
BString name(charset.GetPrintName());
|
||||||
msg = new BMessage(kMsgEncoding);
|
const char * mime = charset.GetMIMEName();
|
||||||
msg->AddInt32 ("charset", kEncodings[i].flavor);
|
if (mime) {
|
||||||
BMenuItem *item = new BMenuItem (kEncodings[i].name, msg);
|
name.Append(" (");
|
||||||
if (kEncodings[i].flavor == fCharacterSetUserSees && !marked) {
|
name.Append(mime);
|
||||||
item->SetMarked (true);
|
name.Append(")");
|
||||||
marked = true;
|
|
||||||
}
|
}
|
||||||
fEncodingMenu->AddItem (item);
|
msg = new BMessage(kMsgEncoding);
|
||||||
if (font.StringWidth (kEncodings[i].name) > widestCharacterSet)
|
if ((mime == 0) || (strcmp(mime, "UTF-8") != 0)) {
|
||||||
widestCharacterSet = font.StringWidth (kEncodings[i].name);
|
msg->AddInt32("charset", charset.GetConversionID());
|
||||||
if (kEncodings[i].flavor == B_MAIL_NULL_CONVERSION)
|
} else {
|
||||||
break; // No more character set choices after this one, stop.
|
msg->AddInt32("charset", B_MAIL_UTF8_CONVERSION);
|
||||||
|
}
|
||||||
|
fEncodingMenu->AddItem(item = new BMenuItem(name.String(), msg));
|
||||||
|
if (charset.GetConversionID() == fCharacterSetUserSees && !marked_charset) {
|
||||||
|
item->SetMarked(true);
|
||||||
|
marked_charset = true;
|
||||||
|
}
|
||||||
|
if (font.StringWidth(name.String()) > widestCharacterSet)
|
||||||
|
widestCharacterSet = font.StringWidth(name.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = new BMessage(kMsgEncoding);
|
||||||
|
msg->AddInt32("charset", B_MAIL_US_ASCII_CONVERSION);
|
||||||
|
fEncodingMenu->AddItem(item = new BMenuItem("US-ASCII", msg));
|
||||||
|
if (fCharacterSetUserSees == B_MAIL_US_ASCII_CONVERSION && !marked_charset) {
|
||||||
|
item->SetMarked(true);
|
||||||
|
marked_charset = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!resending && fIncoming) {
|
||||||
|
// reading a message, display the Automatic item
|
||||||
|
fEncodingMenu->AddSeparatorItem();
|
||||||
|
msg = new BMessage(kMsgEncoding);
|
||||||
|
msg->AddInt32("charset", B_MAIL_NULL_CONVERSION);
|
||||||
|
fEncodingMenu->AddItem(item = new BMenuItem("Automatic", msg));
|
||||||
|
item->SetMarked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// First line of the header, From for reading e-mails (includes the
|
// First line of the header, From for reading e-mails (includes the
|
||||||
@@ -254,7 +285,7 @@ THeaderView::THeaderView (
|
|||||||
BList chains;
|
BList chains;
|
||||||
if (GetOutboundMailChains(&chains) >= B_OK)
|
if (GetOutboundMailChains(&chains) >= B_OK)
|
||||||
{
|
{
|
||||||
marked = false;
|
bool marked = false;
|
||||||
for (int32 i = 0;i < chains.CountItems();i++)
|
for (int32 i = 0;i < chains.CountItems();i++)
|
||||||
{
|
{
|
||||||
BMailChain *chain = (BMailChain *)chains.ItemAt(i);
|
BMailChain *chain = (BMailChain *)chains.ItemAt(i);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
SubDir OBOS_TOP src apps bemail ;
|
SubDir OBOS_TOP src apps bemail ;
|
||||||
|
|
||||||
UsePrivateHeaders mail ;
|
UsePrivateHeaders mail ;
|
||||||
|
UsePrivateHeaders textencoding ;
|
||||||
|
|
||||||
AddResources BeMail : versioning.rdef pictures.rdef ;
|
AddResources BeMail : versioning.rdef pictures.rdef ;
|
||||||
App BeMail :
|
App BeMail :
|
||||||
@@ -21,7 +22,7 @@ App BeMail :
|
|||||||
Words.cpp
|
Words.cpp
|
||||||
KUndoBuffer.cpp ;
|
KUndoBuffer.cpp ;
|
||||||
|
|
||||||
LinkSharedOSLibs BeMail : be tracker stdc++.r4 libmail.so ;
|
LinkSharedOSLibs BeMail : be tracker stdc++.r4 libmail.so libtextencoding.so ;
|
||||||
|
|
||||||
Package haiku-maildaemon-cvs :
|
Package haiku-maildaemon-cvs :
|
||||||
BeMail :
|
BeMail :
|
||||||
|
|||||||
+13
-15
@@ -66,6 +66,10 @@ All rights reserved.
|
|||||||
#include <mail_util.h>
|
#include <mail_util.h>
|
||||||
#include <MDRLanguage.h>
|
#include <MDRLanguage.h>
|
||||||
|
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
|
|
||||||
|
using namespace BPrivate ;
|
||||||
|
|
||||||
#ifndef BONE
|
#ifndef BONE
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -241,7 +245,7 @@ TMailApp::AboutRequested()
|
|||||||
(new BAlert("",
|
(new BAlert("",
|
||||||
"BeMail\nBy Robert Polic\n\n"
|
"BeMail\nBy Robert Polic\n\n"
|
||||||
"Enhanced by Axel Dörfler and the Dr. Zoidberg crew\n\n"
|
"Enhanced by Axel Dörfler and the Dr. Zoidberg crew\n\n"
|
||||||
"Mail.cpp $Revision: 1.3 $\n"
|
"Mail.cpp $Revision: 1.4 $\n"
|
||||||
"Compiled on " __DATE__ " at " __TIME__ ".",
|
"Compiled on " __DATE__ " at " __TIME__ ".",
|
||||||
"Close"))->Go();
|
"Close"))->Go();
|
||||||
}
|
}
|
||||||
@@ -927,13 +931,10 @@ TMailApp::LoadSavePrefs(bool loadThem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
prefsFile.Read(&gMailCharacterSet, sizeof(int32));
|
prefsFile.Read(&gMailCharacterSet, sizeof(int32));
|
||||||
for (uint32 index = 0; true; index++) {
|
if ((gMailCharacterSet != B_MAIL_UTF8_CONVERSION) &&
|
||||||
if (kEncodings[index].flavor == B_MAIL_NULL_CONVERSION) {
|
(gMailCharacterSet != B_MAIL_US_ASCII_CONVERSION) &&
|
||||||
gMailCharacterSet = B_MS_WINDOWS_CONVERSION;
|
(BCharacterSetRoster::GetCharacterSetByConversionID(gMailCharacterSet) == NULL)) {
|
||||||
break;
|
gMailCharacterSet = B_MS_WINDOWS_CONVERSION;
|
||||||
}
|
|
||||||
if (kEncodings[index].flavor == gMailCharacterSet)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefsFile.Read(&len, sizeof(int32)) > 0)
|
if (prefsFile.Read(&len, sizeof(int32)) > 0)
|
||||||
@@ -1072,13 +1073,10 @@ TMailApp::LoadSavePrefs(bool loadThem)
|
|||||||
if (loadThem) {
|
if (loadThem) {
|
||||||
if (settingsMsg.FindInt32(fieldName, &tempInt32) == B_OK)
|
if (settingsMsg.FindInt32(fieldName, &tempInt32) == B_OK)
|
||||||
gMailCharacterSet = tempInt32;
|
gMailCharacterSet = tempInt32;
|
||||||
for (uint32 index = 0; true; index++) {
|
if ((gMailCharacterSet != B_MAIL_UTF8_CONVERSION) &&
|
||||||
if (kEncodings[index].flavor == B_MAIL_NULL_CONVERSION) {
|
(gMailCharacterSet != B_MAIL_US_ASCII_CONVERSION) &&
|
||||||
gMailCharacterSet = B_MS_WINDOWS_CONVERSION;
|
(BCharacterSetRoster::GetCharacterSetByConversionID(gMailCharacterSet) == NULL)) {
|
||||||
break; // Don't use unknown character sets.
|
gMailCharacterSet = B_MS_WINDOWS_CONVERSION;
|
||||||
}
|
|
||||||
if (kEncodings[index].flavor == gMailCharacterSet)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else if (errorCode == B_OK)
|
} else if (errorCode == B_OK)
|
||||||
errorCode = settingsMsg.AddInt32(fieldName, gMailCharacterSet);
|
errorCode = settingsMsg.AddInt32(fieldName, gMailCharacterSet);
|
||||||
|
|||||||
+43
-47
@@ -50,6 +50,12 @@ All rights reserved.
|
|||||||
#include <mail_encoding.h>
|
#include <mail_encoding.h>
|
||||||
#include <MDRLanguage.h>
|
#include <MDRLanguage.h>
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
|
#include <CharacterSet.h>
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
#include "Mail.h"
|
#include "Mail.h"
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
|
|
||||||
@@ -98,41 +104,6 @@ enum P_MESSAGES {P_OK = 128, P_CANCEL, P_REVERT, P_FONT,
|
|||||||
|
|
||||||
extern BPoint prefs_window;
|
extern BPoint prefs_window;
|
||||||
|
|
||||||
const EncodingItem kEncodings[] =
|
|
||||||
{
|
|
||||||
// B_MS_WINDOWS is a superset of B_ISO1, MS mailers lie and send Windows
|
|
||||||
// chars as ISO-1 we still don't want to pretend we would use the Windows
|
|
||||||
// 1252 codetable; this should only be done at decoding stage, axeld.
|
|
||||||
// {"ISO-8859-1", B_MS_WINDOWS_CONVERSION},
|
|
||||||
{"ISO-8859-1 (Latin-1)", B_ISO1_CONVERSION},
|
|
||||||
{"ISO-8859-2", B_ISO2_CONVERSION},
|
|
||||||
{"ISO-8859-3", B_ISO3_CONVERSION},
|
|
||||||
{"ISO-8859-4", B_ISO4_CONVERSION},
|
|
||||||
{"ISO-8859-5", B_ISO5_CONVERSION},
|
|
||||||
{"ISO-8859-6", B_ISO6_CONVERSION},
|
|
||||||
{"ISO-8859-7", B_ISO7_CONVERSION},
|
|
||||||
{"ISO-8859-8", B_ISO8_CONVERSION},
|
|
||||||
{"ISO-8859-9", B_ISO9_CONVERSION},
|
|
||||||
{"ISO-8859-10", B_ISO10_CONVERSION},
|
|
||||||
{"ISO-8859-13", B_ISO13_CONVERSION},
|
|
||||||
{"ISO-8859-14", B_ISO14_CONVERSION},
|
|
||||||
{"ISO-8859-15", B_ISO15_CONVERSION},
|
|
||||||
{"SHIFT-JIS (obsolete)", B_SJIS_CONVERSION},
|
|
||||||
{"ISO-2022-JP", B_JIS_CONVERSION},
|
|
||||||
{"EUC-JP (obsolete)", B_EUC_CONVERSION},
|
|
||||||
{"EUC-KR", B_EUC_KR_CONVERSION},
|
|
||||||
{"KOI8-R", B_KOI8R_CONVERSION},
|
|
||||||
{"Windows-1251",B_MS_WINDOWS_1251_CONVERSION},
|
|
||||||
{"Windows-1252 (\"ANSI\")",B_MS_WINDOWS_CONVERSION},
|
|
||||||
{"DOS-437 (common)", B_MS_DOS_CONVERSION},
|
|
||||||
{"DOS-866 (rarer)", B_MS_DOS_866_CONVERSION},
|
|
||||||
{"Macintosh Roman", B_MAC_ROMAN_CONVERSION},
|
|
||||||
{"US-ASCII", B_MAIL_US_ASCII_CONVERSION},
|
|
||||||
{"UTF-8 (BeOS)", B_MAIL_UTF8_CONVERSION},
|
|
||||||
|
|
||||||
{"Automatic", B_MAIL_NULL_CONVERSION /* marks end of list, only visible when decoding */}
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ATTRIBUTE_ON_TEXT MDR_DIALECT_CHOICE ("Include BeOS Attributes in Attachments", "BeOSの属性を付ける")
|
#define ATTRIBUTE_ON_TEXT MDR_DIALECT_CHOICE ("Include BeOS Attributes in Attachments", "BeOSの属性を付ける")
|
||||||
#define ATTRIBUTE_OFF_TEXT MDR_DIALECT_CHOICE ("No BeOS Attributes, just Plain Data", "BeOSの属性を付けない(データのみ)")
|
#define ATTRIBUTE_OFF_TEXT MDR_DIALECT_CHOICE ("No BeOS Attributes, just Plain Data", "BeOSの属性を付けない(データのみ)")
|
||||||
|
|
||||||
@@ -470,13 +441,16 @@ TPrefsWindow::MessageReceived(BMessage *msg)
|
|||||||
if (item)
|
if (item)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
for (uint32 index = 0; kEncodings[index].flavor != B_MAIL_NULL_CONVERSION; index++)
|
uint32 index = 0;
|
||||||
{
|
while ((item = fEncodingMenu->ItemAt(index++)) != NULL) {
|
||||||
if (kEncodings[index].flavor == *fNewEncoding)
|
BMessage * message = item->Message();
|
||||||
{
|
if (message == NULL) {
|
||||||
item = fEncodingMenu->FindItem(kEncodings[index].name);
|
continue;
|
||||||
if (item)
|
}
|
||||||
item->SetMarked(true);
|
int32 encoding;
|
||||||
|
if ((message->FindInt32("encoding", &encoding) == B_OK) &&
|
||||||
|
((uint32)encoding == *fNewEncoding)) {
|
||||||
|
item->SetMarked(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -905,19 +879,41 @@ TPrefsWindow::BuildColoredQuotesMenu(bool quote)
|
|||||||
BPopUpMenu *
|
BPopUpMenu *
|
||||||
TPrefsWindow::BuildEncodingMenu(uint32 encoding)
|
TPrefsWindow::BuildEncodingMenu(uint32 encoding)
|
||||||
{
|
{
|
||||||
uint32 loop;
|
|
||||||
BMenuItem *item;
|
BMenuItem *item;
|
||||||
BMessage *msg;
|
BMessage *msg;
|
||||||
BPopUpMenu *menu;
|
BPopUpMenu *menu;
|
||||||
|
|
||||||
menu = new BPopUpMenu("");
|
menu = new BPopUpMenu("");
|
||||||
for (loop = 0; kEncodings[loop].flavor != B_MAIL_NULL_CONVERSION; loop++) {
|
|
||||||
|
BCharacterSetRoster roster;
|
||||||
|
BCharacterSet charset;
|
||||||
|
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
|
||||||
|
BString name(charset.GetPrintName());
|
||||||
|
const char * mime = charset.GetMIMEName();
|
||||||
|
if (mime) {
|
||||||
|
name.Append(" (");
|
||||||
|
name.Append(mime);
|
||||||
|
name.Append(")");
|
||||||
|
}
|
||||||
msg = new BMessage(P_ENC);
|
msg = new BMessage(P_ENC);
|
||||||
msg->AddInt32("encoding", kEncodings[loop].flavor);
|
if ((mime == 0) || (strcmp(mime, "UTF-8") != 0)) {
|
||||||
menu->AddItem(item = new BMenuItem(kEncodings[loop].name, msg));
|
msg->AddInt32("encoding", charset.GetConversionID());
|
||||||
if (encoding == kEncodings[loop].flavor)
|
} else {
|
||||||
|
msg->AddInt32("encoding", B_MAIL_UTF8_CONVERSION);
|
||||||
|
}
|
||||||
|
menu->AddItem(item = new BMenuItem(name.String(), msg));
|
||||||
|
if (charset.GetConversionID() == encoding) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg = new BMessage(P_ENC);
|
||||||
|
msg->AddInt32("encoding", B_MAIL_US_ASCII_CONVERSION);
|
||||||
|
menu->AddItem(item = new BMenuItem("US-ASCII", msg));
|
||||||
|
if (encoding == B_MAIL_US_ASCII_CONVERSION) {
|
||||||
|
item->SetMarked(true);
|
||||||
|
}
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user