* Renamed "Outbound"/"Inbound" to Outgoing and Incoming, which is not just

more common language, but also consistent with the rest of the preferences
  app.
* Fixed broken "get SMTP add-on" method.
* Renamed OK button to "Next", and "Finish" on the last page.
* Style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/branches/releases/r1alpha3@42243 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2011-06-19 14:22:33 +00:00
parent a490cd91dc
commit c521b159e6
2 changed files with 97 additions and 89 deletions

View File

@ -3,6 +3,8 @@
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
* Distributed under the terms of the MIT License.
*/
#include "AutoConfigView.h"
#include <Catalog.h>
@ -138,7 +140,7 @@ AutoConfigView::GetBasicAccountInfo(account_info &info)
info.inboundType = IMAP;
else
info.inboundType = POP;
info.outboundProtocol = fSMTPAddonRef;
info.name = fNameView->Text();
info.accountName = fAccountNameView->Text();
@ -164,7 +166,7 @@ AutoConfigView::SetupProtocolView(BRect rect)
path.Append("mail_daemon");
path.Append("inbound_protocols");
BDirectory dir(path.Path());
entry_ref protocolRef;
while (dir.GetNextRef(&protocolRef) == B_OK)
@ -196,27 +198,27 @@ AutoConfigView::SetupProtocolView(BRect rect)
status_t
AutoConfigView::GetSMTPAddonRef(entry_ref *ref)
{
for (int i = 0; i < 2; i++) {
directory_which which[] = {
B_USER_ADDONS_DIRECTORY,
B_BEOS_ADDONS_DIRECTORY
};
for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
BPath path;
status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY :
B_BEOS_ADDONS_DIRECTORY, &path);
status_t status = find_directory(which[i], &path);
if (status != B_OK)
{
return B_ERROR;
}
path.Append("mail_daemon");
path.Append("outbound_protocols");
BDirectory dir(path.Path());
while (dir.GetNextRef(ref) == B_OK)
{
path.Append("SMTP");
BEntry entry(path.Path());
if (entry.Exists() && entry.GetRef(ref) == B_OK)
return B_OK;
}
}
return B_ERROR;
return B_FILE_NOT_FOUND;
}
@ -269,19 +271,23 @@ AutoConfigView::IsValidMailAddress(BString email)
email.CopyInto(provider, atPos + 1, email.Length() - atPos);
if (provider.FindLast(".") < 0)
return false;
return true;
return true;
}
// #pragma mark -
ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
: BView(rect, NULL,B_FOLLOW_ALL,0),
fInboundAccount(true),
fOutboundAccount(true),
fInboundAuthMenu(NULL),
fOutboundAuthMenu(NULL),
fInboundEncrItemStart(NULL),
fOutboundEncrItemStart(NULL),
fImageId(-1)
:
BView(rect, NULL,B_FOLLOW_ALL,0),
fInboundAccount(true),
fOutboundAccount(true),
fInboundAuthMenu(NULL),
fOutboundAuthMenu(NULL),
fInboundEncrItemStart(NULL),
fOutboundEncrItemStart(NULL),
fImageId(-1)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@ -296,7 +302,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
boxRect.bottom -= 5;
BBox *box = new BBox(boxRect);
box->SetLabel(B_TRANSLATE("Inbound"));
box->SetLabel(B_TRANSLATE("Incoming"));
AddChild(box);
BString serverName;
@ -311,10 +317,10 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
fInboundNameView->SetDivider(divider);
box->AddChild(fInboundNameView);
GetAuthEncrMenu(info.inboundProtocol, &fInboundAuthMenu,
&fInboundEncryptionMenu);
if (fInboundAuthMenu) {
&fInboundEncryptionMenu);
if (fInboundAuthMenu != NULL) {
int authID = info.providerInfo.authentification_pop;
if (info.inboundType == POP)
fInboundAuthMenu->Menu()->ItemAt(authID)->SetMarked(true);
@ -326,16 +332,16 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
if (fInboundEncryptionMenu) {
BMenuItem *item = NULL;
if (info.inboundType == POP) {
item = fInboundEncryptionMenu->Menu()
->ItemAt(info.providerInfo.ssl_pop);
if (item)
item = fInboundEncryptionMenu->Menu()->ItemAt(
info.providerInfo.ssl_pop);
if (item != NULL)
item->SetMarked(true);
fInboundEncryptionMenu->MoveTo(10, 80);
}
if (info.inboundType == IMAP) {
item = fInboundEncryptionMenu->Menu()->ItemAt(
info.providerInfo.ssl_imap);
if (item)
if (item != NULL)
item->SetMarked(true);
fInboundEncryptionMenu->MoveTo(10, 50);
}
@ -343,7 +349,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
box->AddChild(fInboundEncryptionMenu);
fInboundEncryptionMenu->SetDivider(divider);
}
if (!fInboundAccount) {
fInboundNameView->SetEnabled(false);
if (fInboundAuthMenu)
@ -356,7 +362,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
boxRect.top += 5;
box = new BBox(boxRect);
box->SetLabel(B_TRANSLATE("Outbound"));
box->SetLabel(B_TRANSLATE("Outgoing"));
AddChild(box);
serverName = info.providerInfo.smtp_server;
@ -366,23 +372,23 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
fOutboundNameView->SetDivider(divider);
box->AddChild(fOutboundNameView);
GetAuthEncrMenu(info.outboundProtocol, &fOutboundAuthMenu,
&fOutboundEncryptionMenu);
if (fOutboundAuthMenu) {
&fOutboundEncryptionMenu);
if (fOutboundAuthMenu != NULL) {
BMenuItem *item = fOutboundAuthMenu->Menu()->ItemAt(
info.providerInfo.authentification_smtp);
if (item)
if (item != NULL)
item->SetMarked(true);
fOutboundAuthItemStart = item;
box->AddChild(fOutboundAuthMenu);
fOutboundAuthMenu->SetDivider(divider);
fOutboundAuthMenu->MoveTo(10, 50);
}
if (fOutboundEncryptionMenu) {
if (fOutboundEncryptionMenu != NULL) {
BMenuItem *item = fOutboundEncryptionMenu->Menu()->ItemAt(
info.providerInfo.ssl_smtp);
if (item)
if (item != NULL)
item->SetMarked(true);
fOutboundEncrItemStart = item;
box->AddChild(fOutboundEncryptionMenu);
@ -395,7 +401,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
if (fOutboundAuthMenu)
fOutboundAuthMenu->SetEnabled(false);
}
}
@ -414,43 +420,47 @@ ServerSettingsView::GetServerInfo(account_info &info)
{
if (info.inboundType == IMAP) {
info.providerInfo.imap_server = fInboundNameView->Text();
if (fInboundEncryptionMenu) {
if (fInboundEncryptionMenu != NULL) {
BMenuItem* item = fInboundEncryptionMenu->Menu()->FindMarked();
if (item)
info.providerInfo.ssl_imap = fInboundEncryptionMenu->Menu()
->IndexOf(item);
if (item != NULL) {
info.providerInfo.ssl_imap
= fInboundEncryptionMenu->Menu()->IndexOf(item);
}
}
} else {
info.providerInfo.pop_server = fInboundNameView->Text();
BMenuItem* item = NULL;
if (fInboundAuthMenu) {
if (fInboundAuthMenu != NULL) {
item = fInboundAuthMenu->Menu()->FindMarked();
if (item)
info.providerInfo.authentification_pop = fInboundAuthMenu
->Menu()
->IndexOf(item);
if (item != NULL) {
info.providerInfo.authentification_pop
= fInboundAuthMenu->Menu()->IndexOf(item);
}
}
if (fInboundEncryptionMenu) {
if (fInboundEncryptionMenu != NULL) {
item = fInboundEncryptionMenu->Menu()->FindMarked();
if (item)
info.providerInfo.ssl_pop = fInboundEncryptionMenu->Menu()
->IndexOf(item);
if (item != NULL) {
info.providerInfo.ssl_pop
= fInboundEncryptionMenu->Menu()->IndexOf(item);
}
}
}
info.providerInfo.smtp_server = fOutboundNameView->Text();
BMenuItem* item = NULL;
if (fOutboundAuthMenu) {
if (fOutboundAuthMenu != NULL) {
item = fOutboundAuthMenu->Menu()->FindMarked();
if (item)
info.providerInfo.authentification_smtp = fOutboundAuthMenu->Menu()
->IndexOf(item);
if (item != NULL) {
info.providerInfo.authentification_smtp
= fOutboundAuthMenu->Menu()->IndexOf(item);
}
}
if (fOutboundEncryptionMenu) {
if (fOutboundEncryptionMenu != NULL) {
item = fOutboundEncryptionMenu->Menu()->FindMarked();
if (item)
info.providerInfo.ssl_smtp = fOutboundEncryptionMenu->Menu()
->IndexOf(item);
if (item != NULL) {
info.providerInfo.ssl_smtp
= fOutboundEncryptionMenu->Menu()->IndexOf(item);
}
}
DetectMenuChanges();
}
@ -460,22 +470,22 @@ void
ServerSettingsView::DetectMenuChanges()
{
bool changed = false;
if (fInboundAuthMenu) {
if (fInboundAuthMenu != NULL) {
BMenuItem *item = fInboundAuthMenu->Menu()->FindMarked();
if (fInboundAuthItemStart != item)
changed = true;
}
if (fInboundEncryptionMenu) {
if (fInboundEncryptionMenu != NULL) {
BMenuItem *item = fInboundEncryptionMenu->Menu()->FindMarked();
if (fInboundEncrItemStart != item)
changed = true;
}
if (fOutboundAuthMenu) {
if (fOutboundAuthMenu != NULL) {
BMenuItem *item = fOutboundAuthMenu->Menu()->FindMarked();
if (fOutboundAuthItemStart != item)
changed = true;
}
if (fOutboundEncryptionMenu) {
if (fOutboundEncryptionMenu != NULL) {
BMenuItem *item = fOutboundEncryptionMenu->Menu()->FindMarked();
if (fOutboundEncrItemStart != item)
changed = true;
@ -496,8 +506,8 @@ ServerSettingsView::GetAuthEncrMenu(entry_ref protocol,
BView *view = CreateConfigView(protocol, dummySettings.InboundSettings(),
dummySettings, &fImageId);
*authField = (BMenuField *)(view->FindView("auth_method"));
*sslField = (BMenuField *)(view->FindView("flavor"));
*authField = (BMenuField *)view->FindView("auth_method");
*sslField = (BMenuField *)view->FindView("flavor");
view->RemoveChild(*authField);
view->RemoveChild(*sslField);

View File

@ -55,9 +55,10 @@ AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent)
fBackButton->SetEnabled(false);
fRootView->AddChild(fBackButton);
buttonRect.left+= 5 + buttonWidth;
buttonRect.left += 5 + buttonWidth;
buttonRect.right = buttonRect.left + buttonWidth;
fNextButton = new BButton(buttonRect, "ok", B_TRANSLATE("OK"), new BMessage(kOkMsg));
fNextButton = new BButton(buttonRect, "next", B_TRANSLATE("Next"),
new BMessage(kOkMsg));
fNextButton->MakeDefault(true);
fRootView->AddChild(fNextButton);
@ -85,10 +86,9 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
{
status_t status = B_ERROR;
BAlert* invalidMailAlert = NULL;
switch (msg->what)
{
switch (msg->what) {
case kOkMsg:
{
if (fMainConfigState) {
fMainView->GetBasicAccountInfo(fAccountInfo);
if (!fMainView->IsValidMailAddress(fAccountInfo.email)) {
@ -100,9 +100,9 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
if (fAutoConfigServer) {
status = fAutoConfig.GetInfoFromMailAddress(
fAccountInfo.email.String(),
&(fAccountInfo.providerInfo));
&fAccountInfo.providerInfo);
}
if(status == B_OK){
if (status == B_OK) {
fParentWindow->Lock();
GenerateBasicAccount();
fParentWindow->Unlock();
@ -111,13 +111,13 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
fMainConfigState = false;
fServerConfigState = true;
fMainView->Hide();
fServerView = new ServerSettingsView(fBoxRect, fAccountInfo);
fRootView->AddChild(fServerView);
fBackButton->SetEnabled(true);
}
else{
fNextButton->SetLabel(B_TRANSLATE("Finish"));
} else {
fServerView->GetServerInfo(fAccountInfo);
fParentWindow->Lock();
GenerateBasicAccount();
@ -125,28 +125,26 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
Quit();
}
break;
}
case kBackMsg:
{
if(fServerConfigState){
if (fServerConfigState) {
fServerView->GetServerInfo(fAccountInfo);
fMainConfigState = true;
fServerConfigState = false;
fRootView->RemoveChild(fServerView);
delete fServerView;
fMainView->Show();
fBackButton->SetEnabled(false);
}
break;
}
case kServerChangedMsg:
{
fAutoConfigServer = false;
break;
}
default:
BWindow::MessageReceived(msg);
break;
@ -154,8 +152,8 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
}
bool
AutoConfigWindow::QuitRequested(void)
bool
AutoConfigWindow::QuitRequested()
{
return true;
}
@ -164,7 +162,7 @@ AutoConfigWindow::QuitRequested(void)
BMailAccountSettings*
AutoConfigWindow::GenerateBasicAccount()
{
if(!fAccount) {
if (!fAccount) {
fParentWindow->Lock();
fAccount = fParentWindow->AddAccount();
fParentWindow->Unlock();