E-mail: Converted auto config window to layout API.
* It still doesn't work correctly yet again, though; the servers cannot be configured there. * I'm leaning towards removing the server configuration there, as they can easily changed in the add-on preferences from the same preferences application; the way it was done was pretty much a hack. Any hard feelings about this?
This commit is contained in:
parent
69a973e2f7
commit
9b9e7ec808
@ -13,6 +13,7 @@
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Message.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Path.h>
|
||||
@ -27,70 +28,57 @@
|
||||
#define B_TRANSLATION_CONTEXT "E-Mail"
|
||||
|
||||
|
||||
AutoConfigView::AutoConfigView(BRect rect, AutoConfig &config)
|
||||
AutoConfigView::AutoConfigView(AutoConfig &config)
|
||||
:
|
||||
BBox(rect),
|
||||
BBox("auto config"),
|
||||
fAutoConfig(config)
|
||||
{
|
||||
int32 stepSize = 30;
|
||||
int32 divider = 100;
|
||||
BPoint topLeft(20, 20);
|
||||
BPoint rightDown(rect.Width() - 20, 20 + stepSize);
|
||||
// Search for SMTP entry_ref
|
||||
_GetSMTPAddOnRef(&fSMTPAddOnRef);
|
||||
|
||||
// protocol view
|
||||
topLeft.y += stepSize;
|
||||
rightDown.y += stepSize;
|
||||
fInProtocolsField = _SetupProtocolView(BRect(topLeft, rightDown));
|
||||
if (fInProtocolsField)
|
||||
AddChild(fInProtocolsField);
|
||||
fInProtocolsField = new BMenuField(NULL, NULL, _SetupProtocolMenu());
|
||||
|
||||
// search for smtp ref
|
||||
_GetSMTPAddonRef(&fSMTPAddonRef);
|
||||
fEmailView = new BTextControl("email", B_TRANSLATE("E-mail address:"),
|
||||
"", new BMessage(kEMailChangedMsg));
|
||||
|
||||
// email view
|
||||
topLeft.y += stepSize;
|
||||
rightDown.y += stepSize;
|
||||
fEmailView = new BTextControl(BRect(topLeft, rightDown), "email",
|
||||
B_TRANSLATE("E-mail address:"), "", new BMessage(kEMailChangedMsg));
|
||||
fEmailView->SetDivider(divider);
|
||||
AddChild(fEmailView);
|
||||
fLoginNameView = new BTextControl("login", B_TRANSLATE("Login name:"),
|
||||
"", NULL);
|
||||
|
||||
// login name view
|
||||
topLeft.y += stepSize;
|
||||
rightDown.y += stepSize;
|
||||
fLoginNameView = new BTextControl(BRect(topLeft, rightDown),
|
||||
"login", B_TRANSLATE("Login name:"), "", NULL);
|
||||
fLoginNameView->SetDivider(divider);
|
||||
AddChild(fLoginNameView);
|
||||
|
||||
// password view
|
||||
topLeft.y += stepSize;
|
||||
rightDown.y += stepSize;
|
||||
fPasswordView = new BTextControl(BRect(topLeft, rightDown), "password",
|
||||
B_TRANSLATE("Password:"), "", NULL);
|
||||
fPasswordView->SetDivider(divider);
|
||||
fPasswordView = new BTextControl("password", B_TRANSLATE("Password:"),
|
||||
"", NULL);
|
||||
fPasswordView->TextView()->HideTyping(true);
|
||||
AddChild(fPasswordView);
|
||||
|
||||
// account view
|
||||
topLeft.y += stepSize;
|
||||
rightDown.y += stepSize;
|
||||
fAccountNameView = new BTextControl(BRect(topLeft, rightDown), "account",
|
||||
B_TRANSLATE("Account name:"), "", NULL);
|
||||
fAccountNameView->SetDivider(divider);
|
||||
AddChild(fAccountNameView);
|
||||
fAccountNameView = new BTextControl("account", B_TRANSLATE("Account name:"),
|
||||
"", NULL);
|
||||
|
||||
// name view
|
||||
topLeft.y += stepSize;
|
||||
rightDown.y += stepSize;
|
||||
fNameView = new BTextControl(BRect(topLeft, rightDown), "name",
|
||||
B_TRANSLATE("Real name:"), "", NULL);
|
||||
AddChild(fNameView);
|
||||
fNameView->SetDivider(divider);
|
||||
fNameView = new BTextControl("name", B_TRANSLATE("Real name:"), "", NULL);
|
||||
|
||||
struct passwd* passwd = getpwent();
|
||||
if (passwd != NULL)
|
||||
fNameView->SetText(passwd->pw_gecos);
|
||||
|
||||
AddChild(BLayoutBuilder::Grid<>()
|
||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||
.SetSpacing(B_USE_HALF_ITEM_SPACING, B_USE_HALF_ITEM_SPACING)
|
||||
|
||||
.Add(fInProtocolsField->CreateLabelLayoutItem(), 0, 0)
|
||||
.Add(fInProtocolsField->CreateMenuBarLayoutItem(), 1, 0)
|
||||
|
||||
.Add(fEmailView->CreateLabelLayoutItem(), 0, 1)
|
||||
.Add(fEmailView->CreateTextViewLayoutItem(), 1, 1)
|
||||
|
||||
.Add(fLoginNameView->CreateLabelLayoutItem(), 0, 2)
|
||||
.Add(fLoginNameView->CreateTextViewLayoutItem(), 1, 2)
|
||||
|
||||
.Add(fPasswordView->CreateLabelLayoutItem(), 0, 3)
|
||||
.Add(fPasswordView->CreateTextViewLayoutItem(), 1, 3)
|
||||
|
||||
.Add(fAccountNameView->CreateLabelLayoutItem(), 0, 4)
|
||||
.Add(fAccountNameView->CreateTextViewLayoutItem(), 1, 4)
|
||||
|
||||
.Add(fNameView->CreateLabelLayoutItem(), 0, 5)
|
||||
.Add(fNameView->CreateTextViewLayoutItem(), 1, 5)
|
||||
.View());
|
||||
}
|
||||
|
||||
|
||||
@ -145,7 +133,7 @@ AutoConfigView::GetBasicAccountInfo(account_info &info)
|
||||
else
|
||||
info.inboundType = POP;
|
||||
|
||||
info.outboundProtocol = fSMTPAddonRef;
|
||||
info.outboundProtocol = fSMTPAddOnRef;
|
||||
info.name = fNameView->Text();
|
||||
info.accountName = fAccountNameView->Text();
|
||||
info.email = fEmailView->Text();
|
||||
@ -156,17 +144,18 @@ AutoConfigView::GetBasicAccountInfo(account_info &info)
|
||||
}
|
||||
|
||||
|
||||
BMenuField*
|
||||
AutoConfigView::_SetupProtocolView(BRect rect)
|
||||
BPopUpMenu*
|
||||
AutoConfigView::_SetupProtocolMenu()
|
||||
{
|
||||
BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE("Choose Protocol"));
|
||||
|
||||
// TODO: use path finder!
|
||||
for (int i = 0; i < 2; i++) {
|
||||
BPath path;
|
||||
status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY :
|
||||
B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
if (status != B_OK)
|
||||
return NULL;
|
||||
return menu;
|
||||
|
||||
path.Append("mail_daemon");
|
||||
path.Append("inbound_protocols");
|
||||
@ -175,13 +164,11 @@ AutoConfigView::_SetupProtocolView(BRect rect)
|
||||
entry_ref protocolRef;
|
||||
while (dir.GetNextRef(&protocolRef) == B_OK)
|
||||
{
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
BEntry entry(&protocolRef);
|
||||
entry.GetName(name);
|
||||
|
||||
BMenuItem *item;
|
||||
BMessage *msg = new BMessage(kProtokollChangedMsg);
|
||||
menu->AddItem(item = new BMenuItem(name, msg));
|
||||
BMessage* msg = new BMessage(kProtokollChangedMsg);
|
||||
BMenuItem* item = new BMenuItem(entry.Name(), msg);
|
||||
menu->AddItem(item);
|
||||
msg->AddRef("protocol", &protocolRef);
|
||||
|
||||
item->SetMarked(true);
|
||||
@ -193,14 +180,12 @@ AutoConfigView::_SetupProtocolView(BRect rect)
|
||||
if (imapItem)
|
||||
imapItem->SetMarked(true);
|
||||
|
||||
BMenuField *protocolsMenuField = new BMenuField(rect, NULL, NULL, menu);
|
||||
protocolsMenuField->ResizeToPreferred();
|
||||
return protocolsMenuField;
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AutoConfigView::_GetSMTPAddonRef(entry_ref *ref)
|
||||
AutoConfigView::_GetSMTPAddOnRef(entry_ref *ref)
|
||||
{
|
||||
directory_which which[] = {
|
||||
B_USER_ADDONS_DIRECTORY,
|
||||
@ -279,30 +264,22 @@ AutoConfigView::IsValidMailAddress(BString email)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
ServerSettingsView::ServerSettingsView(const account_info &info)
|
||||
:
|
||||
BView(rect, NULL,B_FOLLOW_ALL,0),
|
||||
BGroupView("server", B_VERTICAL),
|
||||
fInboundAccount(true),
|
||||
fOutboundAccount(true),
|
||||
fInboundAuthMenu(NULL),
|
||||
fOutboundAuthMenu(NULL),
|
||||
fInboundEncrItemStart(NULL),
|
||||
fOutboundEncrItemStart(NULL),
|
||||
fImageId(-1)
|
||||
fImageID(-1)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
int32 divider = 120;
|
||||
|
||||
fInboundAccount = true;
|
||||
fOutboundAccount = true;
|
||||
|
||||
// inbound
|
||||
BRect boxRect = Bounds();
|
||||
boxRect.bottom /= 2;
|
||||
boxRect.bottom -= 5;
|
||||
|
||||
BBox *box = new BBox(boxRect);
|
||||
BBox* box = new BBox("inbound");
|
||||
box->SetLabel(B_TRANSLATE("Incoming"));
|
||||
AddChild(box);
|
||||
|
||||
@ -312,112 +289,124 @@ ServerSettingsView::ServerSettingsView(BRect rect, const account_info &info)
|
||||
else
|
||||
serverName = info.providerInfo.pop_server;
|
||||
|
||||
fInboundNameView = new BTextControl(BRect(10, 20, rect.Width() - 20, 35),
|
||||
"inbound", B_TRANSLATE("Server Name:"), serverName.String(),
|
||||
new BMessage(kServerChangedMsg));
|
||||
fInboundNameView->SetDivider(divider);
|
||||
BGridView* grid = new BGridView("inner");
|
||||
grid->GridLayout()->SetInsets(B_USE_DEFAULT_SPACING);
|
||||
box->AddChild(grid);
|
||||
|
||||
box->AddChild(fInboundNameView);
|
||||
fInboundNameView = new BTextControl("inbound", B_TRANSLATE("Server Name:"),
|
||||
serverName, new BMessage(kServerChangedMsg));
|
||||
grid->GridLayout()->AddItem(fInboundNameView->CreateLabelLayoutItem(),
|
||||
0, 0);
|
||||
grid->GridLayout()->AddItem(fInboundNameView->CreateTextViewLayoutItem(),
|
||||
1, 0);
|
||||
|
||||
_GetAuthEncrMenu(info.inboundProtocol, &fInboundAuthMenu,
|
||||
&fInboundEncryptionMenu);
|
||||
int32 row = 1;
|
||||
|
||||
_GetAuthEncrMenu(info.inboundProtocol, fInboundAuthMenu,
|
||||
fInboundEncryptionMenu);
|
||||
if (fInboundAuthMenu != NULL) {
|
||||
int authID = info.providerInfo.authentification_pop;
|
||||
if (info.inboundType == POP)
|
||||
fInboundAuthMenu->Menu()->ItemAt(authID)->SetMarked(true);
|
||||
fInboundAuthItemStart = fInboundAuthMenu->Menu()->FindMarked();
|
||||
box->AddChild(fInboundAuthMenu);
|
||||
fInboundAuthMenu->SetDivider(divider);
|
||||
fInboundAuthMenu->MoveTo(10, 50);
|
||||
|
||||
grid->GridLayout()->AddItem(fInboundAuthMenu->CreateLabelLayoutItem(),
|
||||
0, row);
|
||||
grid->GridLayout()->AddItem(fInboundAuthMenu->CreateMenuBarLayoutItem(),
|
||||
1, row++);
|
||||
}
|
||||
if (fInboundEncryptionMenu) {
|
||||
if (fInboundEncryptionMenu != NULL) {
|
||||
BMenuItem *item = NULL;
|
||||
if (info.inboundType == POP) {
|
||||
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 != NULL)
|
||||
item->SetMarked(true);
|
||||
fInboundEncryptionMenu->MoveTo(10, 50);
|
||||
}
|
||||
fInboundEncrItemStart = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||
box->AddChild(fInboundEncryptionMenu);
|
||||
fInboundEncryptionMenu->SetDivider(divider);
|
||||
}
|
||||
|
||||
if (!fInboundAccount) {
|
||||
fInboundNameView->SetEnabled(false);
|
||||
if (fInboundAuthMenu)
|
||||
fInboundAuthMenu->SetEnabled(false);
|
||||
grid->GridLayout()->AddItem(
|
||||
fInboundEncryptionMenu->CreateLabelLayoutItem(), 0, row);
|
||||
grid->GridLayout()->AddItem(
|
||||
fInboundEncryptionMenu->CreateMenuBarLayoutItem(), 1, row++);
|
||||
}
|
||||
grid->GridLayout()->AddItem(BSpaceLayoutItem::CreateGlue(), 0, row);
|
||||
|
||||
if (!fInboundAccount)
|
||||
box->Hide();
|
||||
|
||||
// outbound
|
||||
boxRect = Bounds();
|
||||
boxRect.top = boxRect.bottom / 2;
|
||||
boxRect.top += 5;
|
||||
|
||||
box = new BBox(boxRect);
|
||||
box = new BBox("outbound");
|
||||
box->SetLabel(B_TRANSLATE("Outgoing"));
|
||||
AddChild(box);
|
||||
|
||||
grid = new BGridView("inner");
|
||||
grid->GridLayout()->SetInsets(B_USE_DEFAULT_SPACING);
|
||||
box->AddChild(grid);
|
||||
|
||||
serverName = info.providerInfo.smtp_server;
|
||||
fOutboundNameView = new BTextControl(BRect(10, 20, rect.Width() - 20, 30),
|
||||
"outbound", B_TRANSLATE("Server name:"), serverName.String(),
|
||||
fOutboundNameView = new BTextControl("outbound",
|
||||
B_TRANSLATE("Server name:"), serverName.String(),
|
||||
new BMessage(kServerChangedMsg));
|
||||
fOutboundNameView->SetDivider(divider);
|
||||
grid->GridLayout()->AddItem(fOutboundNameView->CreateLabelLayoutItem(),
|
||||
0, 0);
|
||||
grid->GridLayout()->AddItem(fOutboundNameView->CreateTextViewLayoutItem(),
|
||||
1, 0);
|
||||
|
||||
box->AddChild(fOutboundNameView);
|
||||
row = 1;
|
||||
|
||||
_GetAuthEncrMenu(info.outboundProtocol, &fOutboundAuthMenu,
|
||||
&fOutboundEncryptionMenu);
|
||||
_GetAuthEncrMenu(info.outboundProtocol, fOutboundAuthMenu,
|
||||
fOutboundEncryptionMenu);
|
||||
if (fOutboundAuthMenu != NULL) {
|
||||
BMenuItem *item = fOutboundAuthMenu->Menu()->ItemAt(
|
||||
BMenuItem* item = fOutboundAuthMenu->Menu()->ItemAt(
|
||||
info.providerInfo.authentification_smtp);
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
fOutboundAuthItemStart = item;
|
||||
box->AddChild(fOutboundAuthMenu);
|
||||
fOutboundAuthMenu->SetDivider(divider);
|
||||
fOutboundAuthMenu->MoveTo(10, 50);
|
||||
|
||||
grid->GridLayout()->AddItem(fOutboundAuthMenu->CreateLabelLayoutItem(),
|
||||
0, row);
|
||||
grid->GridLayout()->AddItem(
|
||||
fOutboundAuthMenu->CreateMenuBarLayoutItem(), 1, row++);
|
||||
}
|
||||
if (fOutboundEncryptionMenu != NULL) {
|
||||
BMenuItem *item = fOutboundEncryptionMenu->Menu()->ItemAt(
|
||||
BMenuItem* item = fOutboundEncryptionMenu->Menu()->ItemAt(
|
||||
info.providerInfo.ssl_smtp);
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
fOutboundEncrItemStart = item;
|
||||
box->AddChild(fOutboundEncryptionMenu);
|
||||
fOutboundEncryptionMenu->SetDivider(divider);
|
||||
fOutboundEncryptionMenu->MoveTo(10, 80);
|
||||
}
|
||||
|
||||
if (!fOutboundAccount) {
|
||||
fOutboundNameView->SetEnabled(false);
|
||||
if (fOutboundAuthMenu)
|
||||
fOutboundAuthMenu->SetEnabled(false);
|
||||
grid->GridLayout()->AddItem(
|
||||
fOutboundEncryptionMenu->CreateLabelLayoutItem(), 0, row);
|
||||
grid->GridLayout()->AddItem(
|
||||
fOutboundEncryptionMenu->CreateMenuBarLayoutItem(), 1, row++);
|
||||
}
|
||||
grid->GridLayout()->AddItem(BSpaceLayoutItem::CreateGlue(), 0, row);
|
||||
|
||||
if (!fOutboundAccount)
|
||||
box->Hide();
|
||||
}
|
||||
|
||||
|
||||
ServerSettingsView::~ServerSettingsView()
|
||||
{
|
||||
// Remove manually, as their code may be located in an add-on
|
||||
RemoveChild(fInboundAuthMenu);
|
||||
RemoveChild(fInboundEncryptionMenu);
|
||||
delete fInboundAuthMenu;
|
||||
delete fInboundEncryptionMenu;
|
||||
unload_add_on(fImageId);
|
||||
unload_add_on(fImageID);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerSettingsView::GetServerInfo(account_info &info)
|
||||
ServerSettingsView::GetServerInfo(account_info& info)
|
||||
{
|
||||
if (info.inboundType == IMAP) {
|
||||
info.providerInfo.imap_server = fInboundNameView->Text();
|
||||
@ -470,27 +459,11 @@ ServerSettingsView::GetServerInfo(account_info &info)
|
||||
void
|
||||
ServerSettingsView::_DetectMenuChanges()
|
||||
{
|
||||
bool changed = false;
|
||||
if (fInboundAuthMenu != NULL) {
|
||||
BMenuItem *item = fInboundAuthMenu->Menu()->FindMarked();
|
||||
if (fInboundAuthItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
if (fInboundEncryptionMenu != NULL) {
|
||||
BMenuItem *item = fInboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (fInboundEncrItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
if (fOutboundAuthMenu != NULL) {
|
||||
BMenuItem *item = fOutboundAuthMenu->Menu()->FindMarked();
|
||||
if (fOutboundAuthItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
if (fOutboundEncryptionMenu != NULL) {
|
||||
BMenuItem *item = fOutboundEncryptionMenu->Menu()->FindMarked();
|
||||
if (fOutboundEncrItemStart != item)
|
||||
changed = true;
|
||||
}
|
||||
bool changed = _HasMarkedChanged(fInboundAuthMenu, fInboundAuthItemStart)
|
||||
| _HasMarkedChanged(fInboundEncryptionMenu, fInboundEncrItemStart)
|
||||
| _HasMarkedChanged(fOutboundAuthMenu, fOutboundAuthItemStart)
|
||||
| _HasMarkedChanged(fOutboundEncryptionMenu, fOutboundEncrItemStart);
|
||||
|
||||
if (changed) {
|
||||
BMessage msg(kServerChangedMsg);
|
||||
BMessenger messenger(NULL, Window()->Looper());
|
||||
@ -499,18 +472,31 @@ ServerSettingsView::_DetectMenuChanges()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ServerSettingsView::_HasMarkedChanged(BMenuField* field,
|
||||
BMenuItem* originalItem)
|
||||
{
|
||||
if (field != NULL) {
|
||||
BMenuItem *item = field->Menu()->FindMarked();
|
||||
if (item != originalItem)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerSettingsView::_GetAuthEncrMenu(entry_ref protocol,
|
||||
BMenuField** authField, BMenuField** sslField)
|
||||
BMenuField*& authField, BMenuField*& sslField)
|
||||
{
|
||||
BMailAccountSettings dummySettings;
|
||||
BView *view = new BStringView("", "Not here!");//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->RemoveChild(authField);
|
||||
view->RemoveChild(sslField);
|
||||
delete view;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2012, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2007-2015, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -12,10 +12,13 @@
|
||||
|
||||
#include <Box.h>
|
||||
#include <Entry.h>
|
||||
#include <GroupView.h>
|
||||
#include <MenuField.h>
|
||||
#include <String.h>
|
||||
#include <TextControl.h>
|
||||
|
||||
class BPopUpMenu;
|
||||
|
||||
|
||||
const int32 kNameChangedMsg = '?nch';
|
||||
const int32 kEMailChangedMsg = '?ech';
|
||||
@ -45,23 +48,23 @@ struct account_info {
|
||||
|
||||
class AutoConfigView : public BBox {
|
||||
public:
|
||||
AutoConfigView(BRect rect, AutoConfig& config);
|
||||
AutoConfigView(AutoConfig& config);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
bool GetBasicAccountInfo(account_info &info);
|
||||
bool GetBasicAccountInfo(account_info& info);
|
||||
bool IsValidMailAddress(BString email);
|
||||
|
||||
private:
|
||||
BMenuField* _SetupProtocolView(BRect rect);
|
||||
status_t _GetSMTPAddonRef(entry_ref *ref);
|
||||
BPopUpMenu* _SetupProtocolMenu();
|
||||
status_t _GetSMTPAddOnRef(entry_ref* ref);
|
||||
|
||||
BString _ExtractLocalPart(const char* email);
|
||||
void _ProposeUsername();
|
||||
|
||||
private:
|
||||
entry_ref fSMTPAddonRef;
|
||||
entry_ref fSMTPAddOnRef;
|
||||
BMenuField* fInProtocolsField;
|
||||
BTextControl* fNameView;
|
||||
BTextControl* fAccountNameView;
|
||||
@ -74,18 +77,19 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class ServerSettingsView : public BView {
|
||||
class ServerSettingsView : public BGroupView {
|
||||
public:
|
||||
ServerSettingsView(BRect rect,
|
||||
const account_info& info);
|
||||
ServerSettingsView(const account_info& info);
|
||||
~ServerSettingsView();
|
||||
void GetServerInfo(account_info& info);
|
||||
|
||||
private:
|
||||
void _DetectMenuChanges();
|
||||
bool _HasMarkedChanged(BMenuField* field,
|
||||
BMenuItem* originalItem);
|
||||
void _GetAuthEncrMenu(entry_ref protocol,
|
||||
BMenuField** authField,
|
||||
BMenuField** sslField);
|
||||
BMenuField*& authField,
|
||||
BMenuField*& sslField);
|
||||
|
||||
private:
|
||||
bool fInboundAccount;
|
||||
@ -102,7 +106,7 @@ private:
|
||||
BMenuItem* fOutboundAuthItemStart;
|
||||
BMenuItem* fOutboundEncrItemStart;
|
||||
|
||||
image_id fImageId;
|
||||
image_id fImageID;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2012, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2007-2015, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -16,6 +16,7 @@
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <MailSettings.h>
|
||||
#include <Message.h>
|
||||
#include <Path.h>
|
||||
@ -30,45 +31,35 @@
|
||||
AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent)
|
||||
:
|
||||
BWindow(rect, B_TRANSLATE("Create new account"), B_TITLED_WINDOW_LOOK,
|
||||
B_MODAL_APP_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT, B_ALL_WORKSPACES),
|
||||
B_MODAL_APP_WINDOW_FEEL, B_NOT_ZOOMABLE | B_AVOID_FRONT
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES),
|
||||
fParentWindow(parent),
|
||||
fAccount(NULL),
|
||||
fMainConfigState(true),
|
||||
fServerConfigState(false),
|
||||
fAutoConfigServer(true)
|
||||
{
|
||||
fRootView = new BView(Bounds(), "root auto config view",
|
||||
B_FOLLOW_ALL_SIDES, B_NAVIGABLE);
|
||||
fRootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(fRootView);
|
||||
fContainerView = new BGroupView("config container");
|
||||
|
||||
int32 buttonHeight = 25;
|
||||
int32 buttonWidth = 50;
|
||||
BRect buttonRect = Bounds();
|
||||
buttonRect.InsetBy(5,5);
|
||||
buttonRect.top = buttonRect.bottom - buttonHeight;
|
||||
buttonRect.left = buttonRect.right - 2 * buttonWidth - 5;
|
||||
buttonRect.right = buttonRect.left + buttonWidth;
|
||||
fBackButton = new BButton(buttonRect, "back", B_TRANSLATE("Back"),
|
||||
fBackButton = new BButton("back", B_TRANSLATE("Back"),
|
||||
new BMessage(kBackMsg));
|
||||
fBackButton->SetEnabled(false);
|
||||
fRootView->AddChild(fBackButton);
|
||||
|
||||
buttonRect.left += 5 + buttonWidth;
|
||||
buttonRect.right = buttonRect.left + buttonWidth;
|
||||
fNextButton = new BButton(buttonRect, "next", B_TRANSLATE("Next"),
|
||||
fNextButton = new BButton("next", B_TRANSLATE("Next"),
|
||||
new BMessage(kOkMsg));
|
||||
fNextButton->MakeDefault(true);
|
||||
fRootView->AddChild(fNextButton);
|
||||
|
||||
fBoxRect = Bounds();
|
||||
fBoxRect.InsetBy(5,5);
|
||||
fBoxRect.bottom-= buttonHeight + 5;
|
||||
|
||||
fMainView = new AutoConfigView(fBoxRect, fAutoConfig);
|
||||
fMainView = new AutoConfigView(fAutoConfig);
|
||||
fMainView->SetLabel(B_TRANSLATE("Account settings"));
|
||||
fRootView->AddChild(fMainView);
|
||||
fContainerView->AddChild(fMainView);
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||
.Add(fContainerView)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.AddGlue()
|
||||
.Add(fBackButton)
|
||||
.Add(fNextButton);
|
||||
|
||||
// Add a shortcut to close the window using Command-W
|
||||
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||
@ -77,7 +68,6 @@ AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent)
|
||||
|
||||
AutoConfigWindow::~AutoConfigWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +85,8 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
invalidMailAlert = new BAlert("invalidMailAlert",
|
||||
B_TRANSLATE("Enter a valid e-mail address."),
|
||||
B_TRANSLATE("OK"));
|
||||
invalidMailAlert->SetFlags(invalidMailAlert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
invalidMailAlert->SetFlags(invalidMailAlert->Flags()
|
||||
| B_CLOSE_ON_ESCAPE);
|
||||
invalidMailAlert->Go();
|
||||
return;
|
||||
}
|
||||
@ -114,8 +105,8 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
fServerConfigState = true;
|
||||
fMainView->Hide();
|
||||
|
||||
fServerView = new ServerSettingsView(fBoxRect, fAccountInfo);
|
||||
fRootView->AddChild(fServerView);
|
||||
fServerView = new ServerSettingsView(fAccountInfo);
|
||||
fContainerView->AddChild(fServerView);
|
||||
|
||||
fBackButton->SetEnabled(true);
|
||||
fNextButton->SetLabel(B_TRANSLATE("Finish"));
|
||||
@ -135,7 +126,7 @@ AutoConfigWindow::MessageReceived(BMessage* msg)
|
||||
fMainConfigState = true;
|
||||
fServerConfigState = false;
|
||||
|
||||
fRootView->RemoveChild(fServerView);
|
||||
fContainerView->RemoveChild(fServerView);
|
||||
delete fServerView;
|
||||
|
||||
fMainView->Show();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2011, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2007-2015, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -18,39 +18,41 @@
|
||||
#include "ConfigWindow.h"
|
||||
|
||||
|
||||
//message constants
|
||||
const int32 kBackMsg = '?bac';
|
||||
const int32 kOkMsg = '?bok';
|
||||
// message constants
|
||||
const int32 kBackMsg = '?bac';
|
||||
const int32 kOkMsg = '?bok';
|
||||
|
||||
class AutoConfigWindow : public BWindow
|
||||
{
|
||||
|
||||
class AutoConfigWindow : public BWindow {
|
||||
public:
|
||||
AutoConfigWindow(BRect rect, ConfigWindow *parent);
|
||||
~AutoConfigWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual bool QuitRequested(void);
|
||||
|
||||
AutoConfigWindow(BRect rect,
|
||||
ConfigWindow* parent);
|
||||
~AutoConfigWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
virtual bool QuitRequested(void);
|
||||
|
||||
private:
|
||||
account_info fAccountInfo;
|
||||
|
||||
BMailAccountSettings* GenerateBasicAccount();
|
||||
|
||||
BView *fRootView;
|
||||
BRect fBoxRect;
|
||||
ConfigWindow *fParentWindow;
|
||||
BMailAccountSettings *fAccount;
|
||||
AutoConfigView *fMainView;
|
||||
ServerSettingsView *fServerView;
|
||||
BButton *fBackButton;
|
||||
BButton *fNextButton;
|
||||
|
||||
bool fMainConfigState;
|
||||
bool fServerConfigState;
|
||||
bool fAutoConfigServer;
|
||||
|
||||
AutoConfig fAutoConfig;
|
||||
account_info fAccountInfo;
|
||||
|
||||
BMailAccountSettings*
|
||||
GenerateBasicAccount();
|
||||
|
||||
BView* fContainerView;
|
||||
ConfigWindow* fParentWindow;
|
||||
BMailAccountSettings*
|
||||
fAccount;
|
||||
AutoConfigView* fMainView;
|
||||
ServerSettingsView* fServerView;
|
||||
BButton* fBackButton;
|
||||
BButton* fNextButton;
|
||||
|
||||
bool fMainConfigState;
|
||||
bool fServerConfigState;
|
||||
bool fAutoConfigServer;
|
||||
|
||||
AutoConfig fAutoConfig;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif // AUTO_CONFIG_WINDOW_H
|
||||
|
@ -511,7 +511,8 @@ ConfigWindow::QuitRequested()
|
||||
void
|
||||
ConfigWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
BRect autoConfigRect(0, 0, 400, 300);
|
||||
float fontFactor = be_plain_font->Size() / 12.0f;
|
||||
BRect autoConfigRect(0, 0, 400 * fontFactor, 300 * fontFactor);
|
||||
BRect frame;
|
||||
|
||||
AutoConfigWindow *autoConfigWindow = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user