* 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/trunk@42245 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
* Copyright 2011, Clemens Zeidler <[email protected]>
|
* Copyright 2011, Clemens Zeidler <[email protected]>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "AutoConfigView.h"
|
#include "AutoConfigView.h"
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
@@ -196,27 +198,27 @@ AutoConfigView::SetupProtocolView(BRect rect)
|
|||||||
status_t
|
status_t
|
||||||
AutoConfigView::GetSMTPAddonRef(entry_ref *ref)
|
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;
|
BPath path;
|
||||||
status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY :
|
status_t status = find_directory(which[i], &path);
|
||||||
B_BEOS_ADDONS_DIRECTORY, &path);
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
{
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
path.Append("mail_daemon");
|
path.Append("mail_daemon");
|
||||||
path.Append("outbound_protocols");
|
path.Append("outbound_protocols");
|
||||||
|
path.Append("SMTP");
|
||||||
|
|
||||||
BDirectory dir(path.Path());
|
BEntry entry(path.Path());
|
||||||
|
if (entry.Exists() && entry.GetRef(ref) == B_OK)
|
||||||
while (dir.GetNextRef(ref) == B_OK)
|
|
||||||
{
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return B_ERROR;
|
return B_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -273,8 +275,12 @@ AutoConfigView::IsValidMailAddress(BString email)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||||
: BView(rect, NULL,B_FOLLOW_ALL,0),
|
:
|
||||||
|
BView(rect, NULL,B_FOLLOW_ALL,0),
|
||||||
fInboundAccount(true),
|
fInboundAccount(true),
|
||||||
fOutboundAccount(true),
|
fOutboundAccount(true),
|
||||||
fInboundAuthMenu(NULL),
|
fInboundAuthMenu(NULL),
|
||||||
@@ -296,7 +302,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
|||||||
boxRect.bottom -= 5;
|
boxRect.bottom -= 5;
|
||||||
|
|
||||||
BBox *box = new BBox(boxRect);
|
BBox *box = new BBox(boxRect);
|
||||||
box->SetLabel(B_TRANSLATE("Inbound"));
|
box->SetLabel(B_TRANSLATE("Incoming"));
|
||||||
AddChild(box);
|
AddChild(box);
|
||||||
|
|
||||||
BString serverName;
|
BString serverName;
|
||||||
@@ -314,7 +320,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
|||||||
|
|
||||||
GetAuthEncrMenu(info.inboundProtocol, &fInboundAuthMenu,
|
GetAuthEncrMenu(info.inboundProtocol, &fInboundAuthMenu,
|
||||||
&fInboundEncryptionMenu);
|
&fInboundEncryptionMenu);
|
||||||
if (fInboundAuthMenu) {
|
if (fInboundAuthMenu != NULL) {
|
||||||
int authID = info.providerInfo.authentification_pop;
|
int authID = info.providerInfo.authentification_pop;
|
||||||
if (info.inboundType == POP)
|
if (info.inboundType == POP)
|
||||||
fInboundAuthMenu->Menu()->ItemAt(authID)->SetMarked(true);
|
fInboundAuthMenu->Menu()->ItemAt(authID)->SetMarked(true);
|
||||||
@@ -326,16 +332,16 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
|||||||
if (fInboundEncryptionMenu) {
|
if (fInboundEncryptionMenu) {
|
||||||
BMenuItem *item = NULL;
|
BMenuItem *item = NULL;
|
||||||
if (info.inboundType == POP) {
|
if (info.inboundType == POP) {
|
||||||
item = fInboundEncryptionMenu->Menu()
|
item = fInboundEncryptionMenu->Menu()->ItemAt(
|
||||||
->ItemAt(info.providerInfo.ssl_pop);
|
info.providerInfo.ssl_pop);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
fInboundEncryptionMenu->MoveTo(10, 80);
|
fInboundEncryptionMenu->MoveTo(10, 80);
|
||||||
}
|
}
|
||||||
if (info.inboundType == IMAP) {
|
if (info.inboundType == IMAP) {
|
||||||
item = fInboundEncryptionMenu->Menu()->ItemAt(
|
item = fInboundEncryptionMenu->Menu()->ItemAt(
|
||||||
info.providerInfo.ssl_imap);
|
info.providerInfo.ssl_imap);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
fInboundEncryptionMenu->MoveTo(10, 50);
|
fInboundEncryptionMenu->MoveTo(10, 50);
|
||||||
}
|
}
|
||||||
@@ -356,7 +362,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
|||||||
boxRect.top += 5;
|
boxRect.top += 5;
|
||||||
|
|
||||||
box = new BBox(boxRect);
|
box = new BBox(boxRect);
|
||||||
box->SetLabel(B_TRANSLATE("Outbound"));
|
box->SetLabel(B_TRANSLATE("Outgoing"));
|
||||||
AddChild(box);
|
AddChild(box);
|
||||||
|
|
||||||
serverName = info.providerInfo.smtp_server;
|
serverName = info.providerInfo.smtp_server;
|
||||||
@@ -369,20 +375,20 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
|||||||
|
|
||||||
GetAuthEncrMenu(info.outboundProtocol, &fOutboundAuthMenu,
|
GetAuthEncrMenu(info.outboundProtocol, &fOutboundAuthMenu,
|
||||||
&fOutboundEncryptionMenu);
|
&fOutboundEncryptionMenu);
|
||||||
if (fOutboundAuthMenu) {
|
if (fOutboundAuthMenu != NULL) {
|
||||||
BMenuItem *item = fOutboundAuthMenu->Menu()->ItemAt(
|
BMenuItem *item = fOutboundAuthMenu->Menu()->ItemAt(
|
||||||
info.providerInfo.authentification_smtp);
|
info.providerInfo.authentification_smtp);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
fOutboundAuthItemStart = item;
|
fOutboundAuthItemStart = item;
|
||||||
box->AddChild(fOutboundAuthMenu);
|
box->AddChild(fOutboundAuthMenu);
|
||||||
fOutboundAuthMenu->SetDivider(divider);
|
fOutboundAuthMenu->SetDivider(divider);
|
||||||
fOutboundAuthMenu->MoveTo(10, 50);
|
fOutboundAuthMenu->MoveTo(10, 50);
|
||||||
}
|
}
|
||||||
if (fOutboundEncryptionMenu) {
|
if (fOutboundEncryptionMenu != NULL) {
|
||||||
BMenuItem *item = fOutboundEncryptionMenu->Menu()->ItemAt(
|
BMenuItem *item = fOutboundEncryptionMenu->Menu()->ItemAt(
|
||||||
info.providerInfo.ssl_smtp);
|
info.providerInfo.ssl_smtp);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
fOutboundEncrItemStart = item;
|
fOutboundEncrItemStart = item;
|
||||||
box->AddChild(fOutboundEncryptionMenu);
|
box->AddChild(fOutboundEncryptionMenu);
|
||||||
@@ -414,43 +420,47 @@ ServerSettingsView::GetServerInfo(account_info &info)
|
|||||||
{
|
{
|
||||||
if (info.inboundType == IMAP) {
|
if (info.inboundType == IMAP) {
|
||||||
info.providerInfo.imap_server = fInboundNameView->Text();
|
info.providerInfo.imap_server = fInboundNameView->Text();
|
||||||
if (fInboundEncryptionMenu) {
|
if (fInboundEncryptionMenu != NULL) {
|
||||||
BMenuItem* item = fInboundEncryptionMenu->Menu()->FindMarked();
|
BMenuItem* item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||||
if (item)
|
if (item != NULL) {
|
||||||
info.providerInfo.ssl_imap = fInboundEncryptionMenu->Menu()
|
info.providerInfo.ssl_imap
|
||||||
->IndexOf(item);
|
= fInboundEncryptionMenu->Menu()->IndexOf(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info.providerInfo.pop_server = fInboundNameView->Text();
|
info.providerInfo.pop_server = fInboundNameView->Text();
|
||||||
BMenuItem* item = NULL;
|
BMenuItem* item = NULL;
|
||||||
if (fInboundAuthMenu) {
|
if (fInboundAuthMenu != NULL) {
|
||||||
item = fInboundAuthMenu->Menu()->FindMarked();
|
item = fInboundAuthMenu->Menu()->FindMarked();
|
||||||
if (item)
|
if (item != NULL) {
|
||||||
info.providerInfo.authentification_pop = fInboundAuthMenu
|
info.providerInfo.authentification_pop
|
||||||
->Menu()
|
= fInboundAuthMenu->Menu()->IndexOf(item);
|
||||||
->IndexOf(item);
|
|
||||||
}
|
}
|
||||||
if (fInboundEncryptionMenu) {
|
}
|
||||||
|
if (fInboundEncryptionMenu != NULL) {
|
||||||
item = fInboundEncryptionMenu->Menu()->FindMarked();
|
item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||||
if (item)
|
if (item != NULL) {
|
||||||
info.providerInfo.ssl_pop = fInboundEncryptionMenu->Menu()
|
info.providerInfo.ssl_pop
|
||||||
->IndexOf(item);
|
= fInboundEncryptionMenu->Menu()->IndexOf(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.providerInfo.smtp_server = fOutboundNameView->Text();
|
info.providerInfo.smtp_server = fOutboundNameView->Text();
|
||||||
BMenuItem* item = NULL;
|
BMenuItem* item = NULL;
|
||||||
if (fOutboundAuthMenu) {
|
if (fOutboundAuthMenu != NULL) {
|
||||||
item = fOutboundAuthMenu->Menu()->FindMarked();
|
item = fOutboundAuthMenu->Menu()->FindMarked();
|
||||||
if (item)
|
if (item != NULL) {
|
||||||
info.providerInfo.authentification_smtp = fOutboundAuthMenu->Menu()
|
info.providerInfo.authentification_smtp
|
||||||
->IndexOf(item);
|
= fOutboundAuthMenu->Menu()->IndexOf(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fOutboundEncryptionMenu) {
|
if (fOutboundEncryptionMenu != NULL) {
|
||||||
item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
||||||
if (item)
|
if (item != NULL) {
|
||||||
info.providerInfo.ssl_smtp = fOutboundEncryptionMenu->Menu()
|
info.providerInfo.ssl_smtp
|
||||||
->IndexOf(item);
|
= fOutboundEncryptionMenu->Menu()->IndexOf(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DetectMenuChanges();
|
DetectMenuChanges();
|
||||||
}
|
}
|
||||||
@@ -460,22 +470,22 @@ void
|
|||||||
ServerSettingsView::DetectMenuChanges()
|
ServerSettingsView::DetectMenuChanges()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (fInboundAuthMenu) {
|
if (fInboundAuthMenu != NULL) {
|
||||||
BMenuItem *item = fInboundAuthMenu->Menu()->FindMarked();
|
BMenuItem *item = fInboundAuthMenu->Menu()->FindMarked();
|
||||||
if (fInboundAuthItemStart != item)
|
if (fInboundAuthItemStart != item)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (fInboundEncryptionMenu) {
|
if (fInboundEncryptionMenu != NULL) {
|
||||||
BMenuItem *item = fInboundEncryptionMenu->Menu()->FindMarked();
|
BMenuItem *item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||||
if (fInboundEncrItemStart != item)
|
if (fInboundEncrItemStart != item)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (fOutboundAuthMenu) {
|
if (fOutboundAuthMenu != NULL) {
|
||||||
BMenuItem *item = fOutboundAuthMenu->Menu()->FindMarked();
|
BMenuItem *item = fOutboundAuthMenu->Menu()->FindMarked();
|
||||||
if (fOutboundAuthItemStart != item)
|
if (fOutboundAuthItemStart != item)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (fOutboundEncryptionMenu) {
|
if (fOutboundEncryptionMenu != NULL) {
|
||||||
BMenuItem *item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
BMenuItem *item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
||||||
if (fOutboundEncrItemStart != item)
|
if (fOutboundEncrItemStart != item)
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -496,8 +506,8 @@ ServerSettingsView::GetAuthEncrMenu(entry_ref protocol,
|
|||||||
BView *view = CreateConfigView(protocol, dummySettings.InboundSettings(),
|
BView *view = CreateConfigView(protocol, dummySettings.InboundSettings(),
|
||||||
dummySettings, &fImageId);
|
dummySettings, &fImageId);
|
||||||
|
|
||||||
*authField = (BMenuField *)(view->FindView("auth_method"));
|
*authField = (BMenuField *)view->FindView("auth_method");
|
||||||
*sslField = (BMenuField *)(view->FindView("flavor"));
|
*sslField = (BMenuField *)view->FindView("flavor");
|
||||||
|
|
||||||
view->RemoveChild(*authField);
|
view->RemoveChild(*authField);
|
||||||
view->RemoveChild(*sslField);
|
view->RemoveChild(*sslField);
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent)
|
|||||||
|
|
||||||
buttonRect.left += 5 + buttonWidth;
|
buttonRect.left += 5 + buttonWidth;
|
||||||
buttonRect.right = buttonRect.left + 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);
|
fNextButton->MakeDefault(true);
|
||||||
fRootView->AddChild(fNextButton);
|
fRootView->AddChild(fNextButton);
|
||||||
|
|
||||||
@@ -85,10 +86,9 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
|||||||
{
|
{
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
BAlert* invalidMailAlert = NULL;
|
BAlert* invalidMailAlert = NULL;
|
||||||
switch (msg->what)
|
|
||||||
{
|
switch (msg->what) {
|
||||||
case kOkMsg:
|
case kOkMsg:
|
||||||
{
|
|
||||||
if (fMainConfigState) {
|
if (fMainConfigState) {
|
||||||
fMainView->GetBasicAccountInfo(fAccountInfo);
|
fMainView->GetBasicAccountInfo(fAccountInfo);
|
||||||
if (!fMainView->IsValidMailAddress(fAccountInfo.email)) {
|
if (!fMainView->IsValidMailAddress(fAccountInfo.email)) {
|
||||||
@@ -100,7 +100,7 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
|||||||
if (fAutoConfigServer) {
|
if (fAutoConfigServer) {
|
||||||
status = fAutoConfig.GetInfoFromMailAddress(
|
status = fAutoConfig.GetInfoFromMailAddress(
|
||||||
fAccountInfo.email.String(),
|
fAccountInfo.email.String(),
|
||||||
&(fAccountInfo.providerInfo));
|
&fAccountInfo.providerInfo);
|
||||||
}
|
}
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
fParentWindow->Lock();
|
fParentWindow->Lock();
|
||||||
@@ -116,8 +116,8 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
|||||||
fRootView->AddChild(fServerView);
|
fRootView->AddChild(fServerView);
|
||||||
|
|
||||||
fBackButton->SetEnabled(true);
|
fBackButton->SetEnabled(true);
|
||||||
}
|
fNextButton->SetLabel(B_TRANSLATE("Finish"));
|
||||||
else{
|
} else {
|
||||||
fServerView->GetServerInfo(fAccountInfo);
|
fServerView->GetServerInfo(fAccountInfo);
|
||||||
fParentWindow->Lock();
|
fParentWindow->Lock();
|
||||||
GenerateBasicAccount();
|
GenerateBasicAccount();
|
||||||
@@ -125,9 +125,8 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
|||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case kBackMsg:
|
case kBackMsg:
|
||||||
{
|
|
||||||
if (fServerConfigState) {
|
if (fServerConfigState) {
|
||||||
fServerView->GetServerInfo(fAccountInfo);
|
fServerView->GetServerInfo(fAccountInfo);
|
||||||
|
|
||||||
@@ -141,12 +140,11 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
|||||||
fBackButton->SetEnabled(false);
|
fBackButton->SetEnabled(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case kServerChangedMsg:
|
case kServerChangedMsg:
|
||||||
{
|
|
||||||
fAutoConfigServer = false;
|
fAutoConfigServer = false;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
@@ -155,7 +153,7 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AutoConfigWindow::QuitRequested(void)
|
AutoConfigWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user