mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
* Reverted accidental commit to the wrong branch.
git-svn-id: file:///srv/svn/repos/haiku/haiku/branches/releases/r1alpha3@42244 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c521b159e6
commit
b031258f27
@ -3,8 +3,6 @@
|
||||
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "AutoConfigView.h"
|
||||
|
||||
#include <Catalog.h>
|
||||
@ -198,27 +196,27 @@ AutoConfigView::SetupProtocolView(BRect rect)
|
||||
status_t
|
||||
AutoConfigView::GetSMTPAddonRef(entry_ref *ref)
|
||||
{
|
||||
directory_which which[] = {
|
||||
B_USER_ADDONS_DIRECTORY,
|
||||
B_BEOS_ADDONS_DIRECTORY
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
BPath path;
|
||||
status_t status = find_directory(which[i], &path);
|
||||
status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY :
|
||||
B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
if (status != B_OK)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
path.Append("mail_daemon");
|
||||
path.Append("outbound_protocols");
|
||||
path.Append("SMTP");
|
||||
|
||||
BEntry entry(path.Path());
|
||||
if (entry.Exists() && entry.GetRef(ref) == B_OK)
|
||||
BDirectory dir(path.Path());
|
||||
|
||||
while (dir.GetNextRef(ref) == B_OK)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return B_FILE_NOT_FOUND;
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@ -275,12 +273,8 @@ AutoConfigView::IsValidMailAddress(BString email)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
:
|
||||
BView(rect, NULL,B_FOLLOW_ALL,0),
|
||||
: BView(rect, NULL,B_FOLLOW_ALL,0),
|
||||
fInboundAccount(true),
|
||||
fOutboundAccount(true),
|
||||
fInboundAuthMenu(NULL),
|
||||
@ -302,7 +296,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
boxRect.bottom -= 5;
|
||||
|
||||
BBox *box = new BBox(boxRect);
|
||||
box->SetLabel(B_TRANSLATE("Incoming"));
|
||||
box->SetLabel(B_TRANSLATE("Inbound"));
|
||||
AddChild(box);
|
||||
|
||||
BString serverName;
|
||||
@ -320,7 +314,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
|
||||
GetAuthEncrMenu(info.inboundProtocol, &fInboundAuthMenu,
|
||||
&fInboundEncryptionMenu);
|
||||
if (fInboundAuthMenu != NULL) {
|
||||
if (fInboundAuthMenu) {
|
||||
int authID = info.providerInfo.authentification_pop;
|
||||
if (info.inboundType == POP)
|
||||
fInboundAuthMenu->Menu()->ItemAt(authID)->SetMarked(true);
|
||||
@ -332,16 +326,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 != NULL)
|
||||
item = fInboundEncryptionMenu->Menu()
|
||||
->ItemAt(info.providerInfo.ssl_pop);
|
||||
if (item)
|
||||
item->SetMarked(true);
|
||||
fInboundEncryptionMenu->MoveTo(10, 80);
|
||||
}
|
||||
if (info.inboundType == IMAP) {
|
||||
item = fInboundEncryptionMenu->Menu()->ItemAt(
|
||||
info.providerInfo.ssl_imap);
|
||||
if (item != NULL)
|
||||
if (item)
|
||||
item->SetMarked(true);
|
||||
fInboundEncryptionMenu->MoveTo(10, 50);
|
||||
}
|
||||
@ -362,7 +356,7 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
boxRect.top += 5;
|
||||
|
||||
box = new BBox(boxRect);
|
||||
box->SetLabel(B_TRANSLATE("Outgoing"));
|
||||
box->SetLabel(B_TRANSLATE("Outbound"));
|
||||
AddChild(box);
|
||||
|
||||
serverName = info.providerInfo.smtp_server;
|
||||
@ -375,20 +369,20 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
|
||||
GetAuthEncrMenu(info.outboundProtocol, &fOutboundAuthMenu,
|
||||
&fOutboundEncryptionMenu);
|
||||
if (fOutboundAuthMenu != NULL) {
|
||||
if (fOutboundAuthMenu) {
|
||||
BMenuItem *item = fOutboundAuthMenu->Menu()->ItemAt(
|
||||
info.providerInfo.authentification_smtp);
|
||||
if (item != NULL)
|
||||
if (item)
|
||||
item->SetMarked(true);
|
||||
fOutboundAuthItemStart = item;
|
||||
box->AddChild(fOutboundAuthMenu);
|
||||
fOutboundAuthMenu->SetDivider(divider);
|
||||
fOutboundAuthMenu->MoveTo(10, 50);
|
||||
}
|
||||
if (fOutboundEncryptionMenu != NULL) {
|
||||
if (fOutboundEncryptionMenu) {
|
||||
BMenuItem *item = fOutboundEncryptionMenu->Menu()->ItemAt(
|
||||
info.providerInfo.ssl_smtp);
|
||||
if (item != NULL)
|
||||
if (item)
|
||||
item->SetMarked(true);
|
||||
fOutboundEncrItemStart = item;
|
||||
box->AddChild(fOutboundEncryptionMenu);
|
||||
@ -420,47 +414,43 @@ ServerSettingsView::GetServerInfo(account_info &info)
|
||||
{
|
||||
if (info.inboundType == IMAP) {
|
||||
info.providerInfo.imap_server = fInboundNameView->Text();
|
||||
if (fInboundEncryptionMenu != NULL) {
|
||||
if (fInboundEncryptionMenu) {
|
||||
BMenuItem* item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (item != NULL) {
|
||||
info.providerInfo.ssl_imap
|
||||
= fInboundEncryptionMenu->Menu()->IndexOf(item);
|
||||
}
|
||||
if (item)
|
||||
info.providerInfo.ssl_imap = fInboundEncryptionMenu->Menu()
|
||||
->IndexOf(item);
|
||||
}
|
||||
} else {
|
||||
info.providerInfo.pop_server = fInboundNameView->Text();
|
||||
BMenuItem* item = NULL;
|
||||
if (fInboundAuthMenu != NULL) {
|
||||
if (fInboundAuthMenu) {
|
||||
item = fInboundAuthMenu->Menu()->FindMarked();
|
||||
if (item != NULL) {
|
||||
info.providerInfo.authentification_pop
|
||||
= fInboundAuthMenu->Menu()->IndexOf(item);
|
||||
if (item)
|
||||
info.providerInfo.authentification_pop = fInboundAuthMenu
|
||||
->Menu()
|
||||
->IndexOf(item);
|
||||
}
|
||||
}
|
||||
if (fInboundEncryptionMenu != NULL) {
|
||||
if (fInboundEncryptionMenu) {
|
||||
item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (item != NULL) {
|
||||
info.providerInfo.ssl_pop
|
||||
= fInboundEncryptionMenu->Menu()->IndexOf(item);
|
||||
}
|
||||
if (item)
|
||||
info.providerInfo.ssl_pop = fInboundEncryptionMenu->Menu()
|
||||
->IndexOf(item);
|
||||
}
|
||||
}
|
||||
info.providerInfo.smtp_server = fOutboundNameView->Text();
|
||||
BMenuItem* item = NULL;
|
||||
if (fOutboundAuthMenu != NULL) {
|
||||
if (fOutboundAuthMenu) {
|
||||
item = fOutboundAuthMenu->Menu()->FindMarked();
|
||||
if (item != NULL) {
|
||||
info.providerInfo.authentification_smtp
|
||||
= fOutboundAuthMenu->Menu()->IndexOf(item);
|
||||
}
|
||||
if (item)
|
||||
info.providerInfo.authentification_smtp = fOutboundAuthMenu->Menu()
|
||||
->IndexOf(item);
|
||||
}
|
||||
|
||||
if (fOutboundEncryptionMenu != NULL) {
|
||||
if (fOutboundEncryptionMenu) {
|
||||
item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (item != NULL) {
|
||||
info.providerInfo.ssl_smtp
|
||||
= fOutboundEncryptionMenu->Menu()->IndexOf(item);
|
||||
}
|
||||
if (item)
|
||||
info.providerInfo.ssl_smtp = fOutboundEncryptionMenu->Menu()
|
||||
->IndexOf(item);
|
||||
}
|
||||
DetectMenuChanges();
|
||||
}
|
||||
@ -470,22 +460,22 @@ void
|
||||
ServerSettingsView::DetectMenuChanges()
|
||||
{
|
||||
bool changed = false;
|
||||
if (fInboundAuthMenu != NULL) {
|
||||
if (fInboundAuthMenu) {
|
||||
BMenuItem *item = fInboundAuthMenu->Menu()->FindMarked();
|
||||
if (fInboundAuthItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
if (fInboundEncryptionMenu != NULL) {
|
||||
if (fInboundEncryptionMenu) {
|
||||
BMenuItem *item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (fInboundEncrItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
if (fOutboundAuthMenu != NULL) {
|
||||
if (fOutboundAuthMenu) {
|
||||
BMenuItem *item = fOutboundAuthMenu->Menu()->FindMarked();
|
||||
if (fOutboundAuthItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
if (fOutboundEncryptionMenu != NULL) {
|
||||
if (fOutboundEncryptionMenu) {
|
||||
BMenuItem *item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (fOutboundEncrItemStart != item)
|
||||
changed = true;
|
||||
@ -506,8 +496,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);
|
||||
|
@ -55,10 +55,9 @@ 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, "next", B_TRANSLATE("Next"),
|
||||
new BMessage(kOkMsg));
|
||||
fNextButton = new BButton(buttonRect, "ok", B_TRANSLATE("OK"), new BMessage(kOkMsg));
|
||||
fNextButton->MakeDefault(true);
|
||||
fRootView->AddChild(fNextButton);
|
||||
|
||||
@ -86,9 +85,10 @@ 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();
|
||||
@ -116,8 +116,8 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
fRootView->AddChild(fServerView);
|
||||
|
||||
fBackButton->SetEnabled(true);
|
||||
fNextButton->SetLabel(B_TRANSLATE("Finish"));
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
fServerView->GetServerInfo(fAccountInfo);
|
||||
fParentWindow->Lock();
|
||||
GenerateBasicAccount();
|
||||
@ -125,9 +125,10 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
Quit();
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
case kBackMsg:
|
||||
if (fServerConfigState) {
|
||||
{
|
||||
if(fServerConfigState){
|
||||
fServerView->GetServerInfo(fAccountInfo);
|
||||
|
||||
fMainConfigState = true;
|
||||
@ -140,11 +141,12 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
fBackButton->SetEnabled(false);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
case kServerChangedMsg:
|
||||
{
|
||||
fAutoConfigServer = false;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
@ -153,7 +155,7 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
|
||||
|
||||
bool
|
||||
AutoConfigWindow::QuitRequested()
|
||||
AutoConfigWindow::QuitRequested(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -162,7 +164,7 @@ AutoConfigWindow::QuitRequested()
|
||||
BMailAccountSettings*
|
||||
AutoConfigWindow::GenerateBasicAccount()
|
||||
{
|
||||
if (!fAccount) {
|
||||
if(!fAccount) {
|
||||
fParentWindow->Lock();
|
||||
fAccount = fParentWindow->AddAccount();
|
||||
fParentWindow->Unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user