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