Apply a nice patch from Taos, just some smaller fixes by myself.

Localize the mail add-ons.
The Japanese translation is attached to #7689. Please give a notice when it is in the translation system and the ticket can be closed.
Does the B_UTF8_ELLIPSIS comes into the B_TRANSLATE macro?



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42265 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2011-06-20 21:09:11 +00:00
parent c57f433713
commit b2a55ebf98
16 changed files with 244 additions and 136 deletions
@@ -4,6 +4,9 @@
*/ */
#include <stdio.h>
#include <Catalog.h>
#include <MenuField.h> #include <MenuField.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <Message.h> #include <Message.h>
@@ -14,7 +17,10 @@
#include <FileConfigView.h> #include <FileConfigView.h>
#include <MailSettings.h> #include <MailSettings.h>
#include <MDRLanguage.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
const uint32 kMsgActionMoveTo = 'argm'; const uint32 kMsgActionMoveTo = 'argm';
const uint32 kMsgActionDelete = 'argd'; const uint32 kMsgActionDelete = 'argd';
@@ -40,7 +46,6 @@ class RuleFilterConfig : public BView {
int32 chain; int32 chain;
}; };
#include <stdio.h>
RuleFilterConfig::RuleFilterConfig(const BMessage *settings) RuleFilterConfig::RuleFilterConfig(const BMessage *settings)
: :
@@ -48,25 +53,29 @@ RuleFilterConfig::RuleFilterConfig(const BMessage *settings)
0), menu(NULL) 0), menu(NULL)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
attr = new BTextControl(BRect(5,5,100,20),"attr",MDR_DIALECT_CHOICE ("If","条件:"),MDR_DIALECT_CHOICE ("header (e.g. Subject)","ヘッダ(例えばSubject)"),NULL); attr = new BTextControl(BRect(5,5,100,20),"attr", B_TRANSLATE("If"),
attr->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE ("If ","条件: "))+ 4); B_TRANSLATE("header (e.g. Subject)"),NULL);
attr->SetDivider(be_plain_font->StringWidth(B_TRANSLATE("If "))+ 4);
if (settings->HasString("attribute")) if (settings->HasString("attribute"))
attr->SetText(settings->FindString("attribute")); attr->SetText(settings->FindString("attribute"));
AddChild(attr); AddChild(attr);
regex = new BTextControl(BRect(104,5,255,20),"attr",MDR_DIALECT_CHOICE (" has ",""),MDR_DIALECT_CHOICE ("value (use REGEX: in from of regular expressions like *spam*)","値(正規表現対応)"),NULL); regex = new BTextControl(BRect(104,5,255,20),"attr", B_TRANSLATE(" has "),
regex->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE (" has ","")) + 4); B_TRANSLATE("value (use REGEX: in from of regular expressions like "
"*spam*)"), NULL);
regex->SetDivider(be_plain_font->StringWidth(B_TRANSLATE(" has ")) + 4);
if (settings->HasString("regex")) if (settings->HasString("regex"))
regex->SetText(settings->FindString("regex")); regex->SetText(settings->FindString("regex"));
AddChild(regex); AddChild(regex);
arg = new BFileControl(BRect(5,55,255,80),"arg",NULL,MDR_DIALECT_CHOICE ("this field is based on the action","ここは動作によって意味が変わります")); arg = new BFileControl(BRect(5,55,255,80),"arg", NULL,
B_TRANSLATE("this field is based on the action"));
if (BControl *control = (BControl *)arg->FindView("select_file")) if (BControl *control = (BControl *)arg->FindView("select_file"))
control->SetEnabled(false); control->SetEnabled(false);
if (settings->HasString("argument")) if (settings->HasString("argument"))
arg->SetText(settings->FindString("argument")); arg->SetText(settings->FindString("argument"));
outbound = new BPopUpMenu(MDR_DIALECT_CHOICE ("<Choose account>","<アカウントを選択>")); outbound = new BPopUpMenu(B_TRANSLATE("<Choose account>"));
if (settings->HasInt32("do_what")) if (settings->HasInt32("do_what"))
staging = settings->FindInt32("do_what"); staging = settings->FindInt32("do_what");
@@ -96,17 +105,23 @@ void RuleFilterConfig::AttachedToWindow() {
if (menu != NULL) if (menu != NULL)
return; // We switched back from another tab return; // We switched back from another tab
menu = new BPopUpMenu(MDR_DIALECT_CHOICE ("<Choose action>","<動作を選択>")); menu = new BPopUpMenu(B_TRANSLATE("<Choose action>"));
menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Move to","移動する"), new BMessage(kMsgActionMoveTo))); menu->AddItem(new BMenuItem(B_TRANSLATE("Move to"),
menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Set flags to","フラグを指定する"), new BMessage(kMsgActionSetTo))); new BMessage(kMsgActionMoveTo)));
menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Delete message","削除する"), new BMessage(kMsgActionDelete))); menu->AddItem(new BMenuItem(B_TRANSLATE("Set flags to"),
menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Reply with","返事を書く"), new BMessage(kMsgActionReplyWith))); new BMessage(kMsgActionSetTo)));
menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Set as read","既読にする"), new BMessage(kMsgActionSetRead))); menu->AddItem(new BMenuItem(B_TRANSLATE("Delete message"),
new BMessage(kMsgActionDelete)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Reply with"),
new BMessage(kMsgActionReplyWith)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Set as read"),
new BMessage(kMsgActionSetRead)));
menu->SetTargetForItems(this); menu->SetTargetForItems(this);
BMenuField *field = new BMenuField(BRect(5,30,210,50),"do_what",MDR_DIALECT_CHOICE ("Then","ならば"),menu); BMenuField *field = new BMenuField(BRect(5,30,210,50),"do_what",
B_TRANSLATE("Then"), menu);
field->ResizeToPreferred(); field->ResizeToPreferred();
field->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE ("Then","ならば")) + 8); field->SetDivider(be_plain_font->StringWidth(B_TRANSLATE("Then")) + 8);
AddChild(field); AddChild(field);
outbound_field = new BMenuField(BRect(5,55,255,80),"reply","Foo",outbound); outbound_field = new BMenuField(BRect(5,55,255,80),"reply","Foo",outbound);
@@ -5,10 +5,21 @@ UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ; SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
Addon MatchHeader : Addon MatchHeader
:
ConfigView.cpp ConfigView.cpp
RuleFilter.cpp RuleFilter.cpp
StringMatcher.cpp ; StringMatcher.cpp
;
LinkAgainst MatchHeader : LinkAgainst MatchHeader
be libmail.so $(TARGET_LIBSUPC++) ; :
be libmail.so $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
;
DoCatalogs MatchHeader
:
x-vnd.Haiku-MatchHeader
:
ConfigView.cpp
;
@@ -6,6 +6,7 @@
#include "ConfigView.h" #include "ConfigView.h"
#include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <MenuItem.h> #include <MenuItem.h>
@@ -13,11 +14,14 @@
#include <String.h> #include <String.h>
#include <Message.h> #include <Message.h>
#include <MDRLanguage.h>
#include <MailAddon.h> #include <MailAddon.h>
#include <MailSettings.h> #include <MailSettings.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
const uint32 kMsgNotifyMethod = 'nomt'; const uint32 kMsgNotifyMethod = 'nomt';
@@ -35,19 +39,22 @@ ConfigView::ConfigView()
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false); BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false);
const char *notifyMethods[] = { const char *notifyMethods[] = {
MDR_DIALECT_CHOICE ("Beep",""), B_TRANSLATE("Beep"),
MDR_DIALECT_CHOICE ("Alert","窓(メール毎)"), B_TRANSLATE("Alert"),
MDR_DIALECT_CHOICE ("Keyboard LEDs","キーボードLED"), B_TRANSLATE("Keyboard LEDs"),
MDR_DIALECT_CHOICE ("Central alert","窓(一括)"), B_TRANSLATE("Central alert"),
"Central beep","Log window"}; B_TRANSLATE("Central beep"),
for (int32 i = 0,j = 1;i < 6;i++,j *= 2) B_TRANSLATE("Log window")
menu->AddItem(new BMenuItem(notifyMethods[i],new BMessage(kMsgNotifyMethod))); };
for (int32 i = 0,j = 1;i < 6;i++,j *= 2) {
menu->AddItem(new BMenuItem(notifyMethods[i],
new BMessage(kMsgNotifyMethod)));
}
BMenuField *field = new BMenuField(frame,"notify", BMenuField *field = new BMenuField(frame,"notify", B_TRANSLATE("Method:"),
MDR_DIALECT_CHOICE ("Method:","方法:"),menu); menu);
field->ResizeToPreferred(); field->ResizeToPreferred();
field->SetDivider(field->StringWidth( field->SetDivider(field->StringWidth(B_TRANSLATE("Method:")) + 6);
MDR_DIALECT_CHOICE ("Method:","方法:")) + 6);
AddChild(field); AddChild(field);
ResizeToPreferred(); ResizeToPreferred();
@@ -9,5 +9,12 @@ Addon NewMailNotification :
filter.cpp filter.cpp
ConfigView.cpp ConfigView.cpp
: :
be libmail.so $(TARGET_LIBSUPC++) be libmail.so $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
; ;
DoCatalogs NewMailNotification :
x-vnd.Haiku-NewMailNotification
:
ConfigView.cpp
filter.cpp
;
@@ -5,19 +5,23 @@
*/ */
#include <Message.h>
#include <String.h>
#include <Alert.h> #include <Alert.h>
#include <Beep.h>
#include <Path.h>
#include <Application.h> #include <Application.h>
#include <Beep.h>
#include <Catalog.h>
#include <Message.h>
#include <Path.h>
#include <String.h>
#include <MailAddon.h> #include <MailAddon.h>
#include <MDRLanguage.h>
#include "ConfigView.h" #include "ConfigView.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "filter"
class NotifyFilter : public MailFilter class NotifyFilter : public MailFilter
{ {
public: public:
@@ -64,13 +68,17 @@ NotifyFilter::MailboxSynced(status_t status)
if (fStrategy & alert) { if (fStrategy & alert) {
BString text; BString text;
MDR_DIALECT_CHOICE ( if (fNNewMessages != 1)
text << "You have " << fNNewMessages << " new message" << ((fNNewMessages != 1) ? "s" : "") text << B_TRANSLATE("You have ") << fNNewMessages << B_TRANSLATE(
<< " for " << fMailProtocol.AccountSettings().Name() << ".", " new messages") << B_TRANSLATE(" for ")
<< fMailProtocol.AccountSettings().Name() << ".";
else
text << B_TRANSLATE("You have ") << fNNewMessages << B_TRANSLATE(
" new message") << B_TRANSLATE(" for ")
<< fMailProtocol.AccountSettings().Name() << ".";
text << fMailProtocol.AccountSettings().Name() << "より\n" << fNNewMessages << " 通のメッセージが届きました"); BAlert *alert = new BAlert(B_TRANSLATE("New messages"), text.String(),
"OK", NULL, NULL, B_WIDTH_AS_USUAL);
BAlert *alert = new BAlert(MDR_DIALECT_CHOICE ("New messages","新着メッセージ"), text.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL);
alert->SetFeel(B_NORMAL_WINDOW_FEEL); alert->SetFeel(B_NORMAL_WINDOW_FEEL);
alert->Go(NULL); alert->Go(NULL);
} }
@@ -91,7 +99,10 @@ NotifyFilter::MailboxSynced(status_t status)
if (fStrategy & log_window) { if (fStrategy & log_window) {
BString message; BString message;
message << fNNewMessages << " new message" << ((fNNewMessages != 1) ? "s" : ""); if (fNNewMessages != 1)
message << fNNewMessages << B_TRANSLATE(" new messages");
else
message << fNNewMessages << B_TRANSLATE(" new message");
fMailProtocol.ShowMessage(message.String()); fMailProtocol.ShowMessage(message.String());
} }
@@ -7,6 +7,7 @@
#include "IMAPFolderConfig.h" #include "IMAPFolderConfig.h"
#include <Catalog.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <ListItem.h> #include <ListItem.h>
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
@@ -18,6 +19,10 @@
#include <crypt.h> #include <crypt.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "IMAPFolderConfig"
class EditableListItem { class EditableListItem {
public: public:
EditableListItem(); EditableListItem();
@@ -90,7 +95,6 @@ CheckBoxItem::DrawItem(BView* owner, BRect itemRect, bool drawEverything)
BRect boxRect(0.0f, 2.0f, ceilf(3.0f + fontHeight.ascent), BRect boxRect(0.0f, 2.0f, ceilf(3.0f + fontHeight.ascent),
ceilf(5.0f + fontHeight.ascent)); ceilf(5.0f + fontHeight.ascent));
fBoxRect.left = itemRect.right - boxRect.Width(); fBoxRect.left = itemRect.right - boxRect.Width();
fBoxRect.top = itemRect.top + (itemRect.Height() - boxRect.Height()) / 2; fBoxRect.top = itemRect.top + (itemRect.Height() - boxRect.Height()) / 2;
fBoxRect.right = itemRect.right; fBoxRect.right = itemRect.right;
@@ -201,7 +205,7 @@ class StatusWindow : public BWindow {
public: public:
StatusWindow(const char* text) StatusWindow(const char* text)
: :
BWindow(BRect(0, 0, 10, 10), "status", B_MODAL_WINDOW_LOOK, BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE
| B_AVOID_FRONT | B_NOT_RESIZABLE) | B_AVOID_FRONT | B_NOT_RESIZABLE)
{ {
@@ -230,9 +234,9 @@ const uint32 kMsgInit = '&Ini';
FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings) FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings)
: :
BWindow(BRect(0, 0, 300, 300), "IMAP Folders", B_TITLED_WINDOW_LOOK, BWindow(BRect(0, 0, 300, 300), B_TRANSLATE("IMAP Folders"),
B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION
| B_AVOID_FRONT), | B_NOT_ZOOMABLE | B_AVOID_FRONT),
fSettings(settings) fSettings(settings)
{ {
BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, B_WILL_DRAW); BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, B_WILL_DRAW);
@@ -244,13 +248,14 @@ FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings)
rootView->SetLayout(layout); rootView->SetLayout(layout);
layout->SetInset(spacing); layout->SetInset(spacing);
fFolderListView = new EditListView("IMAP Folders"); fFolderListView = new EditListView(B_TRANSLATE("IMAP Folders"));
fFolderListView->SetExplicitPreferredSize(BSize(B_SIZE_UNLIMITED, fFolderListView->SetExplicitPreferredSize(BSize(B_SIZE_UNLIMITED,
B_SIZE_UNLIMITED)); B_SIZE_UNLIMITED));
fApplyButton = new BButton("Apply", "Apply", new BMessage(kMsgApplyButton)); fApplyButton = new BButton("Apply", B_TRANSLATE("Apply"),
new BMessage(kMsgApplyButton));
fQuotaView = new BStringView("quota view", fQuotaView = new BStringView("quota view",
"Failed to fetch available storage."); B_TRANSLATE("Failed to fetch available storage."));
fQuotaView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, fQuotaView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
B_ALIGN_VERTICAL_CENTER)); B_ALIGN_VERTICAL_CENTER));
@@ -294,8 +299,8 @@ FolderConfigWindow::MessageReceived(BMessage* message)
void void
FolderConfigWindow::_LoadFolders() FolderConfigWindow::_LoadFolders()
{ {
StatusWindow* status = new StatusWindow("Fetching IMAP folders, have " StatusWindow* status = new StatusWindow(
"patience..."); B_TRANSLATE("Fetching IMAP folders, have patience..."));
status->Show(); status->Show();
BString server; BString server;
@@ -356,8 +361,8 @@ FolderConfigWindow::_ApplyChanges()
if (!haveChanges) if (!haveChanges)
return; return;
StatusWindow* status = new StatusWindow("Subcribe / Unsuscribe IMAP " StatusWindow* status = new StatusWindow(B_TRANSLATE("Subcribe / Unsuscribe "
"folders, have patience..."); "IMAP folders, have patience..."));
status->Show(); status->Show();
for (unsigned int i = 0; i < fFolderList.size(); i++) { for (unsigned int i = 0; i < fFolderList.size(); i++) {
@@ -33,7 +33,7 @@ Addon IMAP
: :
$(sources) $(sources)
: :
be libmail.so $(TARGET_NETWORK_LIBS) libalm.so be libmail.so $(HAIKU_LOCALE_LIBS) $(TARGET_NETWORK_LIBS) libalm.so
libshared.a $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++) libshared.a $(TARGET_LIBSUPC++) $(TARGET_LIBSTDC++)
; ;
@@ -46,3 +46,10 @@ Package haiku-maildaemon-cvs :
IMAP : IMAP :
boot home config add-ons mail_daemon inbound_protocols boot home config add-ons mail_daemon inbound_protocols
; ;
DoCatalogs IMAP :
x-vnd.Haiku-IMAP
:
imap_config.cpp
IMAPFolderConfig.cpp
;
@@ -8,6 +8,7 @@
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <TextControl.h> #include <TextControl.h>
#include <MailAddon.h> #include <MailAddon.h>
@@ -16,11 +17,14 @@
#include <FileConfigView.h> #include <FileConfigView.h>
#include <ProtocolConfigView.h> #include <ProtocolConfigView.h>
#include <MailPrivate.h> #include <MailPrivate.h>
#include <MDRLanguage.h>
#include "IMAPFolderConfig.h" #include "IMAPFolderConfig.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "imap_config"
const uint32 kMsgOpenIMAPFolder = '&OIF'; const uint32 kMsgOpenIMAPFolder = '&OIF';
@@ -70,8 +74,8 @@ IMAPConfig::IMAPConfig(MailAddonSettings& settings,
((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true); ((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true);
((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0, -25); ((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0, -25);
fIMAPFolderButton = new BButton(frame, "IMAP Folders", "IMAP Folders", fIMAPFolderButton = new BButton(frame, "IMAP Folders", B_TRANSLATE(
new BMessage(kMsgOpenIMAPFolder)); "IMAP Folders"), new BMessage(kMsgOpenIMAPFolder));
AddChild(fIMAPFolderButton); AddChild(fIMAPFolderButton);
frame.right -= 10; frame.right -= 10;
@@ -79,8 +83,8 @@ IMAPConfig::IMAPConfig(MailAddonSettings& settings,
BPath defaultFolder = BPrivate::default_mail_directory(); BPath defaultFolder = BPrivate::default_mail_directory();
defaultFolder.Append(accountSettings.Name()); defaultFolder.Append(accountSettings.Name());
fFileView = new BMailFileConfigView("Destination:", "destination", fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"),
false, defaultFolder.Path()); "destination", false, defaultFolder.Path());
fFileView->SetTo(&settings.Settings(), NULL); fFileView->SetTo(&settings.Settings(), NULL);
AddChild(fFileView); AddChild(fFileView);
fFileView->MoveBy(0, frame.bottom + 5); fFileView->MoveBy(0, frame.bottom + 5);
@@ -7,12 +7,17 @@
*/ */
#include <Catalog.h>
#include <FileConfigView.h> #include <FileConfigView.h>
#include <MailAddon.h> #include <MailAddon.h>
#include <MailPrivate.h> #include <MailPrivate.h>
#include <ProtocolConfigView.h> #include <ProtocolConfigView.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
class POP3ConfigView : public BMailProtocolConfigView { class POP3ConfigView : public BMailProtocolConfigView {
public: public:
POP3ConfigView(MailAddonSettings& settings, POP3ConfigView(MailAddonSettings& settings,
@@ -47,8 +52,8 @@ POP3ConfigView::POP3ConfigView(MailAddonSettings& settings,
SetTo(settings); SetTo(settings);
fFileView = new BMailFileConfigView("Destination:", "destination", fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"),
false, BPrivate::default_mail_in_directory().Path()); "destination", false, BPrivate::default_mail_in_directory().Path());
fFileView->SetTo(&settings.Settings(), NULL); fFileView->SetTo(&settings.Settings(), NULL);
AddChild(fFileView); AddChild(fFileView);
float w, h; float w, h;
@@ -30,11 +30,18 @@ if $(HAIKU_OPENSSL_ENABLED) {
Addon POP3 Addon POP3
: $(sources) : $(sources)
: be libmail.so $(TARGET_NETWORK_LIBS) $(HAIKU_OPENSSL_LIBS) : be libmail.so $(HAIKU_LOCALE_LIBS) $(HAIKU_OPENSSL_LIBS)
$(TARGET_LIBSUPC++) $(TARGET_LIBSUPC++) $(TARGET_NETWORK_LIBS)
; ;
Package haiku-maildaemon-cvs : Package haiku-maildaemon-cvs :
POP3 : POP3 :
boot home config add-ons mail_daemon inbound_protocols boot home config add-ons mail_daemon inbound_protocols
; ;
DoCatalogs POP3 :
x-vnd.Haiku-POP3
:
ConfigView.cpp
pop3.cpp
;
@@ -30,9 +30,10 @@
#endif #endif
#include <Alert.h> #include <Alert.h>
#include <fs_attr.h> #include <Catalog.h>
#include <Debug.h> #include <Debug.h>
#include <Directory.h> #include <Directory.h>
#include <fs_attr.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
@@ -42,7 +43,10 @@
#include "MailSettings.h" #include "MailSettings.h"
#include "MessageIO.h" #include "MessageIO.h"
#include <MDRLanguage.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "pop3"
#define POP3_RETRIEVAL_TIMEOUT 60000000 #define POP3_RETRIEVAL_TIMEOUT 60000000
#define CRLF "\r\n" #define CRLF "\r\n"
@@ -140,15 +144,14 @@ POP3Protocol::SyncMessages()
_ReadManifest(); _ReadManifest();
SetTotalItems(2); SetTotalItems(2);
ReportProgress(0, 1, "Connect to server..."); ReportProgress(0, 1, B_TRANSLATE("Connect to server" B_UTF8_ELLIPSIS));
status_t error = Connect(); status_t error = Connect();
if (error < B_OK) { if (error < B_OK) {
ResetProgress(); ResetProgress();
return error; return error;
} }
ReportProgress(0, 1, MDR_DIALECT_CHOICE("Getting UniqueIDs...", ReportProgress(0, 1, B_TRANSLATE("Getting UniqueIDs" B_UTF8_ELLIPSIS));
"固有のIDを取得中..."));
error = _UniqueIDs(); error = _UniqueIDs();
if (error < B_OK) { if (error < B_OK) {
ResetProgress(); ResetProgress();
@@ -326,8 +329,8 @@ POP3Protocol::DeleteMessage(const entry_ref& ref)
status_t status_t
POP3Protocol::Open(const char *server, int port, int) POP3Protocol::Open(const char *server, int port, int)
{ {
ReportProgress(0, 0, MDR_DIALECT_CHOICE("Connecting to POP3 server...", ReportProgress(0, 0, B_TRANSLATE("Connecting to POP3 server"
"POP3サーバに接続しています...")); B_UTF8_ELLIPSIS));
if (port <= 0) { if (port <= 0) {
#ifdef USE_SSL #ifdef USE_SSL
@@ -341,8 +344,7 @@ POP3Protocol::Open(const char *server, int port, int)
// Prime the error message // Prime the error message
BString error_msg; BString error_msg;
error_msg << MDR_DIALECT_CHOICE("Error while connecting to server ", error_msg << B_TRANSLATE("Error while connecting to server ") << server;
"サーバに接続中にエラーが発生しました ") << server;
if (port != 110) if (port != 110)
error_msg << ":" << port; error_msg << ":" << port;
@@ -354,8 +356,7 @@ POP3Protocol::Open(const char *server, int port, int)
} }
if (hostIP == 0) { if (hostIP == 0) {
error_msg << MDR_DIALECT_CHOICE(": Connection refused or host not found", error_msg << B_TRANSLATE(": Connection refused or host not found");
": :接続が拒否されたかサーバーが見つかりません");
ShowError(error_msg.String()); ShowError(error_msg.String());
return B_NAME_NOT_FOUND; return B_NAME_NOT_FOUND;
@@ -368,7 +369,8 @@ POP3Protocol::Open(const char *server, int port, int)
saAddr.sin_family = AF_INET; saAddr.sin_family = AF_INET;
saAddr.sin_port = htons(port); saAddr.sin_port = htons(port);
saAddr.sin_addr.s_addr = hostIP; saAddr.sin_addr.s_addr = hostIP;
int result = connect(fSocket, (struct sockaddr *) &saAddr, sizeof(saAddr)); int result = connect(fSocket, (struct sockaddr *) &saAddr,
sizeof(saAddr));
if (result < 0) { if (result < 0) {
close(fSocket); close(fSocket);
fSocket = -1; fSocket = -1;
@@ -377,7 +379,7 @@ POP3Protocol::Open(const char *server, int port, int)
return errno; return errno;
} }
} else { } else {
error_msg << ": Could not allocate socket."; error_msg << B_TRANSLATE(": Could not allocate socket.");
ShowError(error_msg.String()); ShowError(error_msg.String());
return B_ERROR; return B_ERROR;
} }
@@ -424,10 +426,10 @@ POP3Protocol::Open(const char *server, int port, int)
if (strncmp(line.String(), "+OK", 3) != 0) { if (strncmp(line.String(), "+OK", 3) != 0) {
if (line.Length() > 0) { if (line.Length() > 0) {
error_msg << MDR_DIALECT_CHOICE(". The server said:\n", error_msg << B_TRANSLATE(". The server said:\n")
"サーバのメッセージです\n") << line.String(); << line.String();
} else } else
error_msg << ": No reply.\n"; error_msg << B_TRANSLATE(": No reply.\n");
ShowError(error_msg.String()); ShowError(error_msg.String());
return B_ERROR; return B_ERROR;
@@ -444,14 +446,13 @@ POP3Protocol::Login(const char *uid, const char *password, int method)
status_t err; status_t err;
BString error_msg; BString error_msg;
error_msg << MDR_DIALECT_CHOICE("Error while authenticating user ", error_msg << B_TRANSLATE("Error while authenticating user ") << uid;
"ユーザー認証中にエラーが発生しました ") << uid;
if (method == 1) { //APOP if (method == 1) { //APOP
int32 index = fLog.FindFirst("<"); int32 index = fLog.FindFirst("<");
if(index != B_ERROR) { if(index != B_ERROR) {
ReportProgress(0, 0, MDR_DIALECT_CHOICE( ReportProgress(0, 0, B_TRANSLATE("Sending APOP authentication"
"Sending APOP authentication...", "APOP認証情報を送信中...")); B_UTF8_ELLIPSIS));
int32 end = fLog.FindFirst(">",index); int32 end = fLog.FindFirst(">",index);
BString timestamp(""); BString timestamp("");
fLog.CopyInto(timestamp, index, end - index + 1); fLog.CopyInto(timestamp, index, end - index + 1);
@@ -466,22 +467,19 @@ POP3Protocol::Login(const char *uid, const char *password, int method)
err = SendCommand(cmd.String()); err = SendCommand(cmd.String());
if (err != B_OK) { if (err != B_OK) {
error_msg << MDR_DIALECT_CHOICE(". The server said:\n", error_msg << B_TRANSLATE(". The server said:\n") << fLog;
"サーバのメッセージです\n") << fLog;
ShowError(error_msg.String()); ShowError(error_msg.String());
return err; return err;
} }
return B_OK; return B_OK;
} else { } else {
error_msg << MDR_DIALECT_CHOICE(": The server does not support APOP.", error_msg << B_TRANSLATE(": The server does not support APOP.");
"サーバはAPOPをサポートしていません");
ShowError(error_msg.String()); ShowError(error_msg.String());
return B_NOT_ALLOWED; return B_NOT_ALLOWED;
} }
} }
ReportProgress(0, 0, MDR_DIALECT_CHOICE("Sending username...", ReportProgress(0, 0, B_TRANSLATE("Sending username" B_UTF8_ELLIPSIS));
"ユーザーID送信中..."));
BString cmd = "USER "; BString cmd = "USER ";
cmd += uid; cmd += uid;
@@ -489,22 +487,19 @@ POP3Protocol::Login(const char *uid, const char *password, int method)
err = SendCommand(cmd.String()); err = SendCommand(cmd.String());
if (err != B_OK) { if (err != B_OK) {
error_msg << MDR_DIALECT_CHOICE(". The server said:\n", error_msg << B_TRANSLATE(". The server said:\n") << fLog;
"サーバのメッセージです\n") << fLog;
ShowError(error_msg.String()); ShowError(error_msg.String());
return err; return err;
} }
ReportProgress(0, 0, MDR_DIALECT_CHOICE("Sending password...", ReportProgress(0, 0, B_TRANSLATE("Sending password" B_UTF8_ELLIPSIS));
"パスワード送信中..."));
cmd = "PASS "; cmd = "PASS ";
cmd += password; cmd += password;
cmd += CRLF; cmd += CRLF;
err = SendCommand(cmd.String()); err = SendCommand(cmd.String());
if (err != B_OK) { if (err != B_OK) {
error_msg << MDR_DIALECT_CHOICE(". The server said:\n", error_msg << B_TRANSLATE(". The server said:\n") << fLog;
"サーバのメッセージです\n") << fLog;
ShowError(error_msg.String()); ShowError(error_msg.String());
return err; return err;
} }
@@ -516,8 +511,7 @@ POP3Protocol::Login(const char *uid, const char *password, int method)
status_t status_t
POP3Protocol::Stat() POP3Protocol::Stat()
{ {
ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting mailbox size...", ReportProgress(0, 0, B_TRANSLATE("Getting mailbox size" B_UTF8_ELLIPSIS));
"メールボックスのサイズを取得しています..."));
if (SendCommand("STAT" CRLF) < B_OK) if (SendCommand("STAT" CRLF) < B_OK)
return B_ERROR; return B_ERROR;
@@ -746,10 +740,10 @@ POP3Protocol::RetrieveInternal(const char *command, int32 message,
// since that will get mistakenly evaluated again in the // since that will get mistakenly evaluated again in the
// next loop and delete a character by mistake. // next loop and delete a character by mistake.
if (testIndex >= amountInBuffer - 4 && testStr[2] == '.') { if (testIndex >= amountInBuffer - 4 && testStr[2] == '.') {
printf ("POP3Protocol::RetrieveInternal: Jackpot! You have " printf ("POP3Protocol::RetrieveInternal: Jackpot! "
"hit the rare situation with an escaped period at the " "You have hit the rare situation with an escaped "
"end of the buffer. Aren't you happy it decodes it " "period at the end of the buffer. Aren't you happy"
"correctly?\n"); "it decodes it correctly?\n");
flushWholeBuffer = true; flushWholeBuffer = true;
} }
} }
@@ -6,33 +6,41 @@
#include "ConfigView.h" #include "ConfigView.h"
#include <Catalog.h>
#include <TextControl.h> #include <TextControl.h>
#include <String.h> #include <String.h>
#include <Message.h> #include <Message.h>
#include <FileConfigView.h> #include <FileConfigView.h>
#include <MDRLanguage.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
ConfigView::ConfigView() ConfigView::ConfigView()
: BView(BRect(0,0,20,20),"fortune_filter",B_FOLLOW_LEFT | B_FOLLOW_TOP,0) :
BView(BRect(0, 0, 20, 20), "fortune_filter", B_FOLLOW_LEFT | B_FOLLOW_TOP,
0)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// determine font height // determine font height
font_height fontHeight; font_height fontHeight;
GetFontHeight(&fontHeight); GetFontHeight(&fontHeight);
float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13; float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading) + 13;
BRect rect(5,4,250,25); BRect rect(5,4,250,25);
rect.bottom = rect.top - 2 + itemHeight; rect.bottom = rect.top - 2 + itemHeight;
BMailFileConfigView *fview = new BMailFileConfigView(MDR_DIALECT_CHOICE ("Fortune file:","予言ファイル:"),"fortune_file",false,"",B_FILE_NODE); BMailFileConfigView *fview = new BMailFileConfigView(
B_TRANSLATE("Fortune file:"), "fortune_file", false, "", B_FILE_NODE);
AddChild(fview); AddChild(fview);
rect.top = rect.bottom + 8; rect.top = rect.bottom + 8;
rect.bottom = rect.top - 2 + itemHeight; rect.bottom = rect.top - 2 + itemHeight;
BTextControl * control = new BTextControl(rect,"tag_line",MDR_DIALECT_CHOICE ("Tag line:","見出し:"),NULL,NULL); BTextControl * control = new BTextControl(rect, "tag_line",
B_TRANSLATE("Tag line:"), NULL, NULL);
control->SetDivider(control->StringWidth(control->Label()) + 6); control->SetDivider(control->StringWidth(control->Label()) + 6);
AddChild(control); AddChild(control);
@@ -42,8 +50,10 @@ ConfigView::ConfigView()
void ConfigView::SetTo(const BMessage *archive) void ConfigView::SetTo(const BMessage *archive)
{ {
if (BMailFileConfigView *control = (BMailFileConfigView *)FindView("fortune_file")) BMailFileConfigView* control = (BMailFileConfigView*)FindView(
control->SetTo(archive,NULL); "fortune_file")
if (control != NULL)
control->SetTo(archive, NULL);
BString path = archive->FindString("tag_line"); BString path = archive->FindString("tag_line");
if (!archive->HasString("tag_line")) if (!archive->HasString("tag_line"))
@@ -57,7 +67,8 @@ void ConfigView::SetTo(const BMessage *archive)
status_t ConfigView::Archive(BMessage *into,bool) const status_t ConfigView::Archive(BMessage *into,bool) const
{ {
if (BMailFileConfigView *control = (BMailFileConfigView *)FindView("fortune_file")) if (BMailFileConfigView *control = (BMailFileConfigView
*)FindView("fortune_file"))
{ {
control->Archive(into); control->Archive(into);
} }
@@ -67,8 +78,8 @@ status_t ConfigView::Archive(BMessage *into,bool) const
BString line = control->Text(); BString line = control->Text();
if (line != B_EMPTY_STRING) if (line != B_EMPTY_STRING)
line << "\n\n"; line << "\n\n";
if (into->ReplaceString("tag_line",line.String()) != B_OK) if (into->ReplaceString("tag_line", line.String()) != B_OK)
into->AddString("tag_line",line.String()); into->AddString("tag_line", line.String());
} }
return B_OK; return B_OK;
} }
@@ -8,7 +8,13 @@ SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
Addon Fortune : Addon Fortune :
ConfigView.cpp ConfigView.cpp
filter.cpp ; filter.cpp
:
be libmail.so $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
;
LinkAgainst Fortune : DoCatalogs Fortune :
be libmail.so $(TARGET_LIBSUPC++) ; x-vnd.Haiku-Fortune
:
ConfigView.cpp
;
@@ -9,14 +9,18 @@
#include <TextControl.h> #include <TextControl.h>
#include <Catalog.h>
#include <FileConfigView.h> #include <FileConfigView.h>
#include <MailAddon.h> #include <MailAddon.h>
#include <MDRLanguage.h>
#include <MenuField.h> #include <MenuField.h>
#include <MailPrivate.h> #include <MailPrivate.h>
#include <ProtocolConfigView.h> #include <ProtocolConfigView.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
class SMTPConfigView : public BMailProtocolConfigView { class SMTPConfigView : public BMailProtocolConfigView {
public: public:
SMTPConfigView(MailAddonSettings& settings, SMTPConfigView(MailAddonSettings& settings,
@@ -45,12 +49,12 @@ SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
AddFlavor("STARTTLS"); AddFlavor("STARTTLS");
#endif #endif
AddAuthMethod(MDR_DIALECT_CHOICE("None","無し"), false); AddAuthMethod(B_TRANSLATE("None"), false);
AddAuthMethod(MDR_DIALECT_CHOICE("ESMTP","ESMTP")); AddAuthMethod(B_TRANSLATE("ESMTP"));
AddAuthMethod(MDR_DIALECT_CHOICE("POP3 before SMTP","送信前に受信する"), false); AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);
BTextControl *control = (BTextControl *)(FindView("host")); BTextControl *control = (BTextControl *)(FindView("host"));
control->SetLabel(MDR_DIALECT_CHOICE("SMTP server: ","SMTPサーバ: ")); control->SetLabel(B_TRANSLATE("SMTP server: "));
// Reset the dividers after changing one // Reset the dividers after changing one
float widestLabel = 0; float widestLabel = 0;
@@ -68,8 +72,8 @@ SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
SetTo(settings); SetTo(settings);
fFileView = new BMailFileConfigView("Destination:", "path", false, fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path",
BPrivate::default_mail_out_directory().Path()); false, BPrivate::default_mail_out_directory().Path());
fFileView->SetTo(&settings.Settings(), NULL); fFileView->SetTo(&settings.Settings(), NULL);
AddChild(fFileView); AddChild(fFileView);
float w, h; float w, h;
@@ -27,5 +27,12 @@ if $(HAIKU_OPENSSL_ENABLED) {
Addon SMTP Addon SMTP
: $(sources) : $(sources)
: be libmail.so $(TARGET_NETWORK_LIBS) $(TARGET_LIBSTDC++) : be libmail.so $(TARGET_NETWORK_LIBS) $(TARGET_LIBSTDC++)
$(HAIKU_OPENSSL_LIBS) $(HAIKU_LOCALE_LIBS) $(HAIKU_OPENSSL_LIBS)
;
DoCatalogs SMTP :
x-vnd.Haiku-SMTP
:
ConfigView.cpp
smtp.cpp
; ;
@@ -26,6 +26,7 @@
#include <unistd.h> #include <unistd.h>
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <DataIO.h> #include <DataIO.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
@@ -46,7 +47,9 @@
# include "md5.h" # include "md5.h"
#endif #endif
#include <MDRLanguage.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "smtp"
#define CRLF "\r\n" #define CRLF "\r\n"
@@ -268,7 +271,8 @@ SMTPProtocol::Connect()
// to the SMTP server first... // to the SMTP server first...
status_t status = _POP3Authentication(); status_t status = _POP3Authentication();
if (status < B_OK) { if (status < B_OK) {
error_msg << MDR_DIALECT_CHOICE ("POP3 authentication failed. The server said:\n","POP3認証に失敗しました\n") << fLog; error_msg << B_TRANSLATE("POP3 authentication failed. The server "
"said:\n") << fLog;
ShowError(error_msg.String()); ShowError(error_msg.String());
return status; return status;
} }
@@ -277,16 +281,17 @@ SMTPProtocol::Connect()
status = Open(fSettingsMessage.FindString("server"), status = Open(fSettingsMessage.FindString("server"),
fSettingsMessage.FindInt32("port"), authMethod == 1); fSettingsMessage.FindInt32("port"), authMethod == 1);
if (status < B_OK) { if (status < B_OK) {
error_msg << MDR_DIALECT_CHOICE ("Error while opening connection to ","接続中にエラーが発生しました") << fSettingsMessage.FindString("server"); error_msg << B_TRANSLATE("Error while opening connection to ")
<< fSettingsMessage.FindString("server");
if (fSettingsMessage.FindInt32("port") > 0) if (fSettingsMessage.FindInt32("port") > 0)
error_msg << ":" << fSettingsMessage.FindInt32("port"); error_msg << ":" << fSettingsMessage.FindInt32("port");
// << strerror(err) - BNetEndpoint sucks, we can't use this; // << strerror(err) - BNetEndpoint sucks, we can't use this;
if (fLog.Length() > 0) if (fLog.Length() > 0)
error_msg << ". The server says:\n" << fLog; error_msg << B_TRANSLATE(". The server says:\n") << fLog;
else else
error_msg << MDR_DIALECT_CHOICE (": Connection refused or host not found.",";接続が拒否されたかサーバーが見つかりません"); error_msg << B_TRANSLATE(": Connection refused or host not found.");
ShowError(error_msg.String()); ShowError(error_msg.String());
@@ -299,8 +304,9 @@ SMTPProtocol::Connect()
if (status != B_OK) { if (status != B_OK) {
//-----This is a really cool kind of error message. How can we make it work for POP3? //-----This is a really cool kind of error message. How can we make it work for POP3?
error_msg << MDR_DIALECT_CHOICE ("Error while logging in to ","ログイン中にエラーが発生しました\n") << fSettingsMessage.FindString("server") error_msg << B_TRANSLATE("Error while logging in to ")
<< MDR_DIALECT_CHOICE (". The server said:\n","サーバーエラー\n") << fLog; << fSettingsMessage.FindString("server")
<< B_TRANSLATE(". The server said:\n") << fLog;
ShowError(error_msg.String()); ShowError(error_msg.String());
} }
return B_OK; return B_OK;
@@ -350,7 +356,7 @@ SMTPProtocol::SendMessages(const std::vector<entry_ref>& mails,
status_t status_t
SMTPProtocol::Open(const char *address, int port, bool esmtp) SMTPProtocol::Open(const char *address, int port, bool esmtp)
{ {
ReportProgress(0, 0, MDR_DIALECT_CHOICE ("Connecting to server...","接続中...")); ReportProgress(0, 0, B_TRANSLATE("Connecting to server" B_UTF8_ELLIPSIS));
#ifdef USE_SSL #ifdef USE_SSL
use_ssl = (fSettingsMessage.FindInt32("flavor") == 1); use_ssl = (fSettingsMessage.FindInt32("flavor") == 1);
@@ -408,7 +414,8 @@ SMTPProtocol::Open(const char *address, int port, bool esmtp)
if (SSL_connect(ssl) <= 0) { if (SSL_connect(ssl) <= 0) {
BString error; BString error;
error << "Could not connect to SMTP server " << fSettingsMessage.FindString("server"); error << "Could not connect to SMTP server "
<< fSettingsMessage.FindString("server");
if (port != 465) if (port != 465)
error << ":" << port; error << ":" << port;
error << ". (SSL connection error)"; error << ". (SSL connection error)";