* Style cleanup, no functional change. There would be still lots of stuff to
do, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36650 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
83bc49d051
commit
d55567bbf9
@ -1,7 +1,9 @@
|
||||
/* Account - provides an "account" view on the mail chains
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
//! Provides an "account" view on the mail chains.
|
||||
|
||||
|
||||
#include "Account.h"
|
||||
@ -30,9 +32,11 @@
|
||||
|
||||
#include <MDRLanguage.h>
|
||||
|
||||
|
||||
#undef TR_CONTEXT
|
||||
#define TR_CONTEXT "Account"
|
||||
|
||||
|
||||
static BList gAccounts;
|
||||
static BListView *gListView;
|
||||
static BView *gConfigView;
|
||||
@ -44,14 +48,14 @@ const char *kInboundProtocolAddOnPath = "mail_daemon/inbound_protocols";
|
||||
const char *kOutboundProtocolAddOnPath = "mail_daemon/outbound_protocols";
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
AccountItem::AccountItem(const char *label,Account *account,int32 type)
|
||||
: BStringItem(label),
|
||||
account(account),
|
||||
type(type)
|
||||
AccountItem::AccountItem(const char *label, Account *account, int32 type)
|
||||
:
|
||||
BStringItem(label),
|
||||
account(account),
|
||||
type(type)
|
||||
{
|
||||
}
|
||||
|
||||
@ -61,7 +65,8 @@ AccountItem::~AccountItem()
|
||||
}
|
||||
|
||||
|
||||
void AccountItem::Update(BView *owner, const BFont *font)
|
||||
void
|
||||
AccountItem::Update(BView *owner, const BFont *font)
|
||||
{
|
||||
if (type == ACCOUNT_ITEM)
|
||||
font = be_bold_font;
|
||||
@ -70,11 +75,11 @@ void AccountItem::Update(BView *owner, const BFont *font)
|
||||
}
|
||||
|
||||
|
||||
void AccountItem::DrawItem(BView *owner, BRect rect, bool complete)
|
||||
void
|
||||
AccountItem::DrawItem(BView *owner, BRect rect, bool complete)
|
||||
{
|
||||
owner->PushState();
|
||||
if (type == ACCOUNT_ITEM)
|
||||
{
|
||||
if (type == ACCOUNT_ITEM) {
|
||||
// BFont font;
|
||||
// owner->GetFont(&font);
|
||||
// font.SetFace(B_BOLD_FACE);
|
||||
@ -85,18 +90,18 @@ void AccountItem::DrawItem(BView *owner, BRect rect, bool complete)
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
Account::Account(BMailChain *inbound,BMailChain *outbound)
|
||||
: fInbound(inbound),
|
||||
fOutbound(outbound),
|
||||
Account::Account(BMailChain *inbound, BMailChain *outbound)
|
||||
:
|
||||
fInbound(inbound),
|
||||
fOutbound(outbound),
|
||||
|
||||
fAccountItem(NULL),
|
||||
fInboundItem(NULL),
|
||||
fOutboundItem(NULL),
|
||||
fFilterItem(NULL)
|
||||
fAccountItem(NULL),
|
||||
fInboundItem(NULL),
|
||||
fOutboundItem(NULL),
|
||||
fFilterItem(NULL)
|
||||
{
|
||||
fSettings = fInbound ? fInbound : fOutbound;
|
||||
|
||||
@ -105,32 +110,34 @@ Account::Account(BMailChain *inbound,BMailChain *outbound)
|
||||
label << fSettings->Name();
|
||||
else
|
||||
label << TR("Unnamed");
|
||||
fAccountItem = new AccountItem(label.String(),this,ACCOUNT_ITEM);
|
||||
fAccountItem = new AccountItem(label.String(), this, ACCOUNT_ITEM);
|
||||
|
||||
fInboundItem = new AccountItem(TR (" · Incoming"),this,INBOUND_ITEM);
|
||||
fOutboundItem = new AccountItem(TR (" · Outgoing"),this,OUTBOUND_ITEM);
|
||||
fFilterItem = new AccountItem(TR (" · E-mail filters"),this,FILTER_ITEM);
|
||||
fInboundItem = new AccountItem(TR(" · Incoming"), this, INBOUND_ITEM);
|
||||
fOutboundItem = new AccountItem(TR(" · Outgoing"), this, OUTBOUND_ITEM);
|
||||
fFilterItem = new AccountItem(TR(" · E-mail filters"), this, FILTER_ITEM);
|
||||
}
|
||||
|
||||
|
||||
Account::~Account()
|
||||
{
|
||||
if (gListView)
|
||||
{
|
||||
if (gListView) {
|
||||
gListView->RemoveItem(fAccountItem);
|
||||
gListView->RemoveItem(fInboundItem);
|
||||
gListView->RemoveItem(fOutboundItem);
|
||||
gListView->RemoveItem(fFilterItem);
|
||||
}
|
||||
delete fAccountItem; delete fFilterItem;
|
||||
delete fInboundItem; delete fOutboundItem;
|
||||
delete fAccountItem;
|
||||
delete fFilterItem;
|
||||
delete fInboundItem;
|
||||
delete fOutboundItem;
|
||||
|
||||
delete fInbound;
|
||||
delete fOutbound;
|
||||
}
|
||||
|
||||
|
||||
void Account::AddToListView()
|
||||
void
|
||||
Account::AddToListView()
|
||||
{
|
||||
if (!gListView)
|
||||
return;
|
||||
@ -148,22 +155,23 @@ void Account::AddToListView()
|
||||
}
|
||||
|
||||
|
||||
void Account::SetName(const char *name)
|
||||
void
|
||||
Account::SetName(const char *name)
|
||||
{
|
||||
if (fInbound)
|
||||
fInbound->SetName(name);
|
||||
if (fOutbound)
|
||||
fOutbound->SetName(name);
|
||||
|
||||
if (name && *name)
|
||||
{
|
||||
if (name && *name) {
|
||||
fAccountItem->SetText(name);
|
||||
gListView->InvalidateItem(gListView->IndexOf(fAccountItem));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *Account::Name() const
|
||||
const char *
|
||||
Account::Name() const
|
||||
{
|
||||
if (fInbound)
|
||||
return fInbound->Name();
|
||||
@ -174,23 +182,23 @@ const char *Account::Name() const
|
||||
}
|
||||
|
||||
|
||||
void Account::SetRealName(const char *realName)
|
||||
void
|
||||
Account::SetRealName(const char *realName)
|
||||
{
|
||||
BMessage *msg;
|
||||
if (fInbound && (msg = fInbound->MetaData()) != NULL)
|
||||
{
|
||||
if (msg->ReplaceString("real_name",realName) < B_OK)
|
||||
msg->AddString("real_name",realName);
|
||||
if (fInbound && (msg = fInbound->MetaData()) != NULL) {
|
||||
if (msg->ReplaceString("real_name", realName) < B_OK)
|
||||
msg->AddString("real_name", realName);
|
||||
}
|
||||
if (fOutbound && (msg = fOutbound->MetaData()) != NULL)
|
||||
{
|
||||
if (msg->ReplaceString("real_name",realName) < B_OK)
|
||||
msg->AddString("real_name",realName);
|
||||
if (fOutbound && (msg = fOutbound->MetaData()) != NULL) {
|
||||
if (msg->ReplaceString("real_name", realName) < B_OK)
|
||||
msg->AddString("real_name", realName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *Account::RealName() const
|
||||
const char *
|
||||
Account::RealName() const
|
||||
{
|
||||
if (fInbound && fInbound->MetaData())
|
||||
return fInbound->MetaData()->FindString("real_name");
|
||||
@ -204,23 +212,23 @@ const char *Account::RealName() const
|
||||
}
|
||||
|
||||
|
||||
void Account::SetReturnAddress(const char *returnAddress)
|
||||
void
|
||||
Account::SetReturnAddress(const char *returnAddress)
|
||||
{
|
||||
BMessage *msg;
|
||||
if (fInbound && (msg = fInbound->MetaData()) != NULL)
|
||||
{
|
||||
if (msg->ReplaceString("reply_to",returnAddress) < B_OK)
|
||||
msg->AddString("reply_to",returnAddress);
|
||||
if (fInbound && (msg = fInbound->MetaData()) != NULL) {
|
||||
if (msg->ReplaceString("reply_to", returnAddress) < B_OK)
|
||||
msg->AddString("reply_to", returnAddress);
|
||||
}
|
||||
if (fOutbound && (msg = fOutbound->MetaData()) != NULL)
|
||||
{
|
||||
if (msg->ReplaceString("reply_to",returnAddress) < B_OK)
|
||||
msg->AddString("reply_to",returnAddress);
|
||||
if (fOutbound && (msg = fOutbound->MetaData()) != NULL) {
|
||||
if (msg->ReplaceString("reply_to", returnAddress) < B_OK)
|
||||
msg->AddString("reply_to", returnAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *Account::ReturnAddress() const
|
||||
const char *
|
||||
Account::ReturnAddress() const
|
||||
{
|
||||
if (fInbound && fInbound->MetaData())
|
||||
return fInbound->MetaData()->FindString("reply_to");
|
||||
@ -231,22 +239,20 @@ const char *Account::ReturnAddress() const
|
||||
}
|
||||
|
||||
|
||||
void Account::CopyMetaData(BMailChain *targetChain, BMailChain *sourceChain)
|
||||
void
|
||||
Account::CopyMetaData(BMailChain *targetChain, BMailChain *sourceChain)
|
||||
{
|
||||
BMessage *otherMsg, *thisMsg;
|
||||
if (sourceChain && (otherMsg = sourceChain->MetaData()) != NULL
|
||||
&& (thisMsg = targetChain->MetaData()) != NULL)
|
||||
{
|
||||
&& (thisMsg = targetChain->MetaData()) != NULL) {
|
||||
const char *string;
|
||||
if ((string = otherMsg->FindString("real_name")) != NULL)
|
||||
{
|
||||
if (thisMsg->ReplaceString("real_name",string) < B_OK)
|
||||
thisMsg->AddString("real_name",string);
|
||||
if ((string = otherMsg->FindString("real_name")) != NULL) {
|
||||
if (thisMsg->ReplaceString("real_name", string) < B_OK)
|
||||
thisMsg->AddString("real_name", string);
|
||||
}
|
||||
if ((string = otherMsg->FindString("reply_to")) != NULL)
|
||||
{
|
||||
if (thisMsg->ReplaceString("reply_to",string) < B_OK)
|
||||
thisMsg->AddString("reply_to",string);
|
||||
if ((string = otherMsg->FindString("reply_to")) != NULL) {
|
||||
if (thisMsg->ReplaceString("reply_to", string) < B_OK)
|
||||
thisMsg->AddString("reply_to", string);
|
||||
}
|
||||
if ((string = sourceChain->Name()) != NULL)
|
||||
targetChain->SetName(string);
|
||||
@ -254,21 +260,18 @@ void Account::CopyMetaData(BMailChain *targetChain, BMailChain *sourceChain)
|
||||
}
|
||||
|
||||
|
||||
void Account::CreateInbound()
|
||||
void
|
||||
Account::CreateInbound()
|
||||
{
|
||||
|
||||
if (!(fInbound = NewMailChain()))
|
||||
{
|
||||
(new BAlert(
|
||||
TR ("E-mail"),
|
||||
TR ("Could not create inbound chain."),
|
||||
TR ("OK")))->Go();
|
||||
if (!(fInbound = NewMailChain())) {
|
||||
(new BAlert(TR("E-mail"), TR("Could not create inbound chain."),
|
||||
TR("OK")))->Go();
|
||||
return;
|
||||
}
|
||||
fInbound->SetChainDirection(inbound);
|
||||
|
||||
BPath path,addOnPath;
|
||||
find_directory(B_USER_ADDONS_DIRECTORY,&addOnPath);
|
||||
find_directory(B_USER_ADDONS_DIRECTORY, &addOnPath);
|
||||
|
||||
BMessage msg;
|
||||
entry_ref ref;
|
||||
@ -278,101 +281,99 @@ void Account::CreateInbound()
|
||||
path.Append(kInboundProtocolAddOnPath);
|
||||
path.Append("POP3");
|
||||
if (!BEntry(path.Path()).Exists()) {
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY,&path);
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
path.Append(kInboundProtocolAddOnPath);
|
||||
path.Append("POP3");
|
||||
}
|
||||
BEntry(path.Path()).GetRef(&ref);
|
||||
fInbound->AddFilter(msg,ref);
|
||||
fInbound->AddFilter(msg, ref);
|
||||
|
||||
// Message Parser
|
||||
// Message Parser
|
||||
path = addOnPath;
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("Message Parser");
|
||||
if (!BEntry(path.Path()).Exists()) {
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY,&path);
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("Message Parser");
|
||||
}
|
||||
BEntry(path.Path()).GetRef(&ref);
|
||||
fInbound->AddFilter(msg,ref);
|
||||
fInbound->AddFilter(msg, ref);
|
||||
|
||||
// New Mail Notification
|
||||
path = addOnPath;
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append(TR ("New mail notification"));
|
||||
path.Append(TR("New mail notification"));
|
||||
if (!BEntry(path.Path()).Exists()) {
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY,&path);
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("New mail notification");
|
||||
}
|
||||
BEntry(path.Path()).GetRef(&ref);
|
||||
fInbound->AddFilter(msg,ref);
|
||||
fInbound->AddFilter(msg, ref);
|
||||
|
||||
// Inbox
|
||||
path = addOnPath;
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("Inbox");
|
||||
if (!BEntry(path.Path()).Exists()) {
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY,&path);
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("Inbox");
|
||||
}
|
||||
BEntry(path.Path()).GetRef(&ref);
|
||||
fInbound->AddFilter(msg,ref);
|
||||
fInbound->AddFilter(msg, ref);
|
||||
|
||||
// set already made account settings
|
||||
CopyMetaData(fInbound,fOutbound);
|
||||
}
|
||||
|
||||
|
||||
void Account::CreateOutbound()
|
||||
void
|
||||
Account::CreateOutbound()
|
||||
{
|
||||
|
||||
if (!(fOutbound = NewMailChain()))
|
||||
{
|
||||
(new BAlert(
|
||||
TR ("E-mail"),
|
||||
TR ("Could not create outbound chain."),
|
||||
TR ("OK")))->Go();
|
||||
if (!(fOutbound = NewMailChain())) {
|
||||
(new BAlert(TR("E-mail"), TR("Could not create outbound chain."),
|
||||
TR("OK")))->Go();
|
||||
return;
|
||||
}
|
||||
fOutbound->SetChainDirection(outbound);
|
||||
|
||||
BPath path,addOnPath;
|
||||
find_directory(B_USER_ADDONS_DIRECTORY,&addOnPath);
|
||||
find_directory(B_USER_ADDONS_DIRECTORY, &addOnPath);
|
||||
|
||||
BMessage msg;
|
||||
entry_ref ref;
|
||||
|
||||
|
||||
path = addOnPath;
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("Outbox");
|
||||
if (!BEntry(path.Path()).Exists()) {
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY,&path);
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
path.Append(kSystemFilterAddOnPath);
|
||||
path.Append("Outbox");
|
||||
}
|
||||
BEntry(path.Path()).GetRef(&ref);
|
||||
fOutbound->AddFilter(msg,ref);
|
||||
fOutbound->AddFilter(msg, ref);
|
||||
|
||||
path = addOnPath;
|
||||
path.Append(kOutboundProtocolAddOnPath);
|
||||
path.Append("SMTP");
|
||||
if (!BEntry(path.Path()).Exists()) {
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY,&path);
|
||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
||||
path.Append(kOutboundProtocolAddOnPath);
|
||||
path.Append("SMTP");
|
||||
}
|
||||
BEntry(path.Path()).GetRef(&ref);
|
||||
fOutbound->AddFilter(msg,ref);
|
||||
fOutbound->AddFilter(msg, ref);
|
||||
|
||||
// set already made account settings
|
||||
CopyMetaData(fOutbound,fInbound);
|
||||
}
|
||||
|
||||
|
||||
void Account::SetType(int32 type)
|
||||
void
|
||||
Account::SetType(int32 type)
|
||||
{
|
||||
if (type < INBOUND_TYPE || type > IN_AND_OUTBOUND_TYPE)
|
||||
return;
|
||||
@ -380,8 +381,7 @@ void Account::SetType(int32 type)
|
||||
int32 index = gListView->IndexOf(fAccountItem) + 1;
|
||||
|
||||
// missing inbound
|
||||
if ((type == INBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE) && !Inbound())
|
||||
{
|
||||
if ((type == INBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE) && !Inbound()) {
|
||||
if (!fInbound)
|
||||
CreateInbound();
|
||||
|
||||
@ -392,20 +392,20 @@ void Account::SetType(int32 type)
|
||||
index++;
|
||||
|
||||
// missing outbound
|
||||
if ((type == OUTBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE) && !Outbound())
|
||||
{
|
||||
if ((type == OUTBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE)
|
||||
&& !Outbound()) {
|
||||
if (!fOutbound)
|
||||
CreateOutbound();
|
||||
|
||||
if (fOutbound)
|
||||
gListView->AddItem(fOutboundItem,index);
|
||||
gListView->AddItem(fOutboundItem, index);
|
||||
}
|
||||
if (Outbound())
|
||||
index++;
|
||||
|
||||
// missing filter
|
||||
if (!gListView->HasItem(fFilterItem))
|
||||
gListView->AddItem(fFilterItem,index);
|
||||
gListView->AddItem(fFilterItem, index);
|
||||
|
||||
// remove inbound
|
||||
if (type == OUTBOUND_TYPE && Inbound())
|
||||
@ -417,24 +417,26 @@ void Account::SetType(int32 type)
|
||||
}
|
||||
|
||||
|
||||
int32 Account::Type() const
|
||||
int32
|
||||
Account::Type() const
|
||||
{
|
||||
return Inbound() ? (Outbound() ? 2 : 0) : (Outbound() ? 1 : -1);
|
||||
}
|
||||
|
||||
|
||||
void Account::Selected(int32 type)
|
||||
void
|
||||
Account::Selected(int32 type)
|
||||
{
|
||||
if (!gConfigView)
|
||||
return;
|
||||
|
||||
|
||||
gConfigView->Hide();
|
||||
((CenterContainer *)gConfigView)->DeleteChildren();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case ACCOUNT_ITEM:
|
||||
gConfigView->AddChild(new AccountConfigView(gConfigView->Bounds(),this));
|
||||
gConfigView->AddChild(new AccountConfigView(gConfigView->Bounds(),
|
||||
this));
|
||||
break;
|
||||
case INBOUND_ITEM:
|
||||
{
|
||||
@ -442,22 +444,19 @@ void Account::Selected(int32 type)
|
||||
break;
|
||||
|
||||
int32 count = fInbound->CountFilters();
|
||||
for (int32 i = 0;;i++)
|
||||
{
|
||||
for (int32 i = 0;; i++) {
|
||||
BMessage *msg = new BMessage();
|
||||
entry_ref *ref = new entry_ref;
|
||||
|
||||
// we just want to have the first and the last two filters:
|
||||
// Protocol, Parser, Notifier, Folder
|
||||
if (i == 2)
|
||||
{
|
||||
if (i == 2) {
|
||||
i = count - 2;
|
||||
if (i < 2) // defensive programming...
|
||||
i = 3;
|
||||
}
|
||||
|
||||
if (fInbound->GetFilter(i,msg,ref) < B_OK)
|
||||
{
|
||||
if (fInbound->GetFilter(i, msg, ref) < B_OK) {
|
||||
delete msg;
|
||||
delete ref;
|
||||
break;
|
||||
@ -466,9 +465,9 @@ void Account::Selected(int32 type)
|
||||
// the filter view takes ownership of "msg" and "ref"
|
||||
FilterConfigView *view;
|
||||
if (i == 0)
|
||||
view = new ProtocolsConfigView(fInbound,i,msg,ref);
|
||||
view = new ProtocolsConfigView(fInbound, i, msg, ref);
|
||||
else
|
||||
view = new FilterConfigView(fInbound,i,msg,ref);
|
||||
view = new FilterConfigView(fInbound, i, msg, ref);
|
||||
|
||||
if (view->InitCheck() >= B_OK)
|
||||
gConfigView->AddChild(view);
|
||||
@ -484,32 +483,31 @@ void Account::Selected(int32 type)
|
||||
|
||||
// we just want to have the first and the last filter here
|
||||
int32 count = fOutbound->CountFilters();
|
||||
for (int32 i = 0;i < count;i += count-1)
|
||||
{
|
||||
for (int32 i = 0; i < count; i += count - 1) {
|
||||
BMessage *msg = new BMessage();
|
||||
entry_ref *ref = new entry_ref;
|
||||
|
||||
if (fOutbound->GetFilter(i,msg,ref) < B_OK)
|
||||
{
|
||||
if (fOutbound->GetFilter(i, msg, ref) < B_OK) {
|
||||
delete msg;
|
||||
delete ref;
|
||||
break;
|
||||
}
|
||||
|
||||
// the filter view takes ownership of "msg" and "ref"
|
||||
if (FilterConfigView *view = new FilterConfigView(fOutbound,i,msg,ref))
|
||||
{
|
||||
if (view->InitCheck() >= B_OK)
|
||||
gConfigView->AddChild(view);
|
||||
else
|
||||
delete view;
|
||||
}
|
||||
FilterConfigView *view = new FilterConfigView(fOutbound, i, msg,
|
||||
ref);
|
||||
|
||||
if (view->InitCheck() >= B_OK)
|
||||
gConfigView->AddChild(view);
|
||||
else
|
||||
delete view;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FILTER_ITEM:
|
||||
{
|
||||
gConfigView->AddChild(new FiltersConfigView(gConfigView->Bounds(),this));
|
||||
gConfigView->AddChild(new FiltersConfigView(gConfigView->Bounds(),
|
||||
this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -518,14 +516,14 @@ void Account::Selected(int32 type)
|
||||
}
|
||||
|
||||
|
||||
void Account::Remove(int32 type)
|
||||
void
|
||||
Account::Remove(int32 type)
|
||||
{
|
||||
// this should only be called if necessary, but if it's used
|
||||
// in the GUI, this will always be the case
|
||||
((CenterContainer *)gConfigView)->DeleteChildren();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case ACCOUNT_ITEM:
|
||||
gListView->RemoveItem(fAccountItem);
|
||||
gListView->RemoveItem(fInboundItem);
|
||||
@ -552,19 +550,22 @@ void Account::Remove(int32 type)
|
||||
}
|
||||
|
||||
|
||||
BMailChain *Account::Inbound() const
|
||||
BMailChain *
|
||||
Account::Inbound() const
|
||||
{
|
||||
return gListView && gListView->HasItem(fInboundItem) ? fInbound : NULL;
|
||||
}
|
||||
|
||||
|
||||
BMailChain *Account::Outbound() const
|
||||
BMailChain *
|
||||
Account::Outbound() const
|
||||
{
|
||||
return gListView && gListView->HasItem(fOutboundItem) ? fOutbound : NULL;
|
||||
}
|
||||
|
||||
|
||||
void Account::Save()
|
||||
void
|
||||
Account::Save()
|
||||
{
|
||||
if (Inbound())
|
||||
fInbound->Save();
|
||||
@ -578,7 +579,8 @@ void Account::Save()
|
||||
}
|
||||
|
||||
|
||||
void Account::Delete(int32 type)
|
||||
void
|
||||
Account::Delete(int32 type)
|
||||
{
|
||||
if (fInbound && (type == INBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE))
|
||||
fInbound->Delete();
|
||||
@ -591,7 +593,8 @@ void Account::Delete(int32 type)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int Accounts::Compare(const void *_a, const void *_b)
|
||||
int
|
||||
Accounts::Compare(const void *_a, const void *_b)
|
||||
{
|
||||
const char *a = (*(Account **)_a)->Name();
|
||||
const char *b = (*(Account **)_b)->Name();
|
||||
@ -603,7 +606,8 @@ int Accounts::Compare(const void *_a, const void *_b)
|
||||
}
|
||||
|
||||
|
||||
void Accounts::Create(BListView *listView, BView *configView)
|
||||
void
|
||||
Accounts::Create(BListView *listView, BView *configView)
|
||||
{
|
||||
gListView = listView;
|
||||
gConfigView = configView;
|
||||
@ -615,19 +619,16 @@ void Accounts::Create(BListView *listView, BView *configView)
|
||||
|
||||
// create inbound accounts and assign matching outbound chains
|
||||
|
||||
for (int32 i = inbound.CountItems();i-- > 0;)
|
||||
{
|
||||
for (int32 i = inbound.CountItems(); i-- > 0;) {
|
||||
BMailChain *inChain = (BMailChain *)inbound.ItemAt(i);
|
||||
BMailChain *outChain = NULL;
|
||||
for (int32 j = outbound.CountItems();j-- > 0;)
|
||||
{
|
||||
for (int32 j = outbound.CountItems(); j-- > 0;) {
|
||||
outChain = (BMailChain *)outbound.ItemAt(j);
|
||||
|
||||
if (!strcmp(inChain->Name(),outChain->Name()))
|
||||
if (!strcmp(inChain->Name(), outChain->Name()))
|
||||
break;
|
||||
outChain = NULL;
|
||||
}
|
||||
gAccounts.AddItem(new Account(inChain,outChain));
|
||||
gAccounts.AddItem(new Account(inChain, outChain));
|
||||
inbound.RemoveItem(i);
|
||||
if (outChain)
|
||||
outbound.RemoveItem(outChain);
|
||||
@ -635,47 +636,47 @@ void Accounts::Create(BListView *listView, BView *configView)
|
||||
|
||||
// create remaining outbound only accounts
|
||||
|
||||
for (int32 i = outbound.CountItems();i-- > 0;)
|
||||
{
|
||||
for (int32 i = outbound.CountItems(); i-- > 0;) {
|
||||
BMailChain *outChain = (BMailChain *)outbound.ItemAt(i);
|
||||
|
||||
gAccounts.AddItem(new Account(NULL,outChain));
|
||||
gAccounts.AddItem(new Account(NULL, outChain));
|
||||
outbound.RemoveItem(i);
|
||||
}
|
||||
|
||||
// sort the list alphabetically
|
||||
gAccounts.SortItems(Accounts::Compare);
|
||||
|
||||
for (int32 i = 0;Account *account = (Account *)gAccounts.ItemAt(i);i++)
|
||||
|
||||
for (int32 i = 0; Account *account = (Account *)gAccounts.ItemAt(i); i++)
|
||||
account->AddToListView();
|
||||
}
|
||||
|
||||
|
||||
Account* Accounts::NewAccount()
|
||||
Account*
|
||||
Accounts::NewAccount()
|
||||
{
|
||||
Account *account = new Account();
|
||||
gAccounts.AddItem(account);
|
||||
account->AddToListView();
|
||||
|
||||
|
||||
if (gListView)
|
||||
gListView->Select(gListView->IndexOf(account->fAccountItem));
|
||||
return account;
|
||||
}
|
||||
|
||||
|
||||
void Accounts::Save()
|
||||
void
|
||||
Accounts::Save()
|
||||
{
|
||||
for (int32 i = gAccounts.CountItems();i-- > 0;)
|
||||
for (int32 i = gAccounts.CountItems(); i-- > 0;)
|
||||
((Account *)gAccounts.ItemAt(i))->Save();
|
||||
}
|
||||
|
||||
|
||||
void Accounts::Delete()
|
||||
void
|
||||
Accounts::Delete()
|
||||
{
|
||||
for (int32 i = gAccounts.CountItems();i-- > 0;)
|
||||
{
|
||||
for (int32 i = gAccounts.CountItems(); i-- > 0;) {
|
||||
Account *account = (Account *)gAccounts.RemoveItem(i);
|
||||
delete account;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,14 @@
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku, Inc. All rights reserved.
|
||||
/*
|
||||
* Copyright 2007-2010, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
//! main E-Mail config window
|
||||
|
||||
|
||||
#include "ConfigWindow.h"
|
||||
#include "CenterContainer.h"
|
||||
#include "Account.h"
|
||||
@ -89,10 +91,10 @@ class AccountsListView : public BListView {
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes) {
|
||||
if (numBytes != 1)
|
||||
return;
|
||||
|
||||
|
||||
if ((*bytes == B_DELETE) || (*bytes == B_BACKSPACE))
|
||||
Window()->PostMessage(kMsgRemoveAccount);
|
||||
|
||||
|
||||
BListView::KeyDown(bytes,numBytes);
|
||||
}
|
||||
};
|
||||
@ -216,7 +218,7 @@ class AboutTextView : public BTextView
|
||||
virtual void Draw(BRect updateRect)
|
||||
{
|
||||
BTextView::Draw(updateRect);
|
||||
|
||||
|
||||
BRect rect(fMail.Frame());
|
||||
StrokeLine(BPoint(rect.left,rect.bottom-2),BPoint(rect.right,rect.bottom-2));
|
||||
rect = fBugsite.Frame();
|
||||
@ -238,18 +240,18 @@ class AboutTextView : public BTextView
|
||||
be_roster->Launch("text/html", 1, arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
BRegion fWebsite,fMail,fBugsite;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
ConfigWindow::ConfigWindow()
|
||||
: BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW,
|
||||
:
|
||||
BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fLastSelectedAccount(NULL),
|
||||
fSaveSettings(false)
|
||||
@ -257,43 +259,46 @@ ConfigWindow::ConfigWindow()
|
||||
// create controls
|
||||
|
||||
BRect rect(Bounds());
|
||||
BView *top = new BView(rect,NULL,B_FOLLOW_ALL,0);
|
||||
BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0);
|
||||
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(top);
|
||||
|
||||
// determine font height
|
||||
font_height fontHeight;
|
||||
top->GetFontHeight(&fontHeight);
|
||||
int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5;
|
||||
int32 height = (int32)(fontHeight.ascent + fontHeight.descent
|
||||
+ fontHeight.leading) + 5;
|
||||
|
||||
rect.InsetBy(5,5); rect.bottom -= 11 + height;
|
||||
BTabView *tabView = new BTabView(rect,NULL);
|
||||
rect.InsetBy(5, 5); rect.bottom -= 11 + height;
|
||||
BTabView *tabView = new BTabView(rect, NULL);
|
||||
|
||||
BView *view;
|
||||
rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4;
|
||||
tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0));
|
||||
tabView->TabAt(0)->SetLabel(TR ("Accounts"));
|
||||
rect = tabView->Bounds();
|
||||
rect.bottom -= tabView->TabHeight() + 4;
|
||||
tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0));
|
||||
tabView->TabAt(0)->SetLabel(TR("Accounts"));
|
||||
view->SetViewColor(top->ViewColor());
|
||||
|
||||
|
||||
// accounts listview
|
||||
|
||||
rect = view->Bounds().InsetByCopy(8,8);
|
||||
rect = view->Bounds().InsetByCopy(8, 8);
|
||||
rect.right = 140 - B_V_SCROLL_BAR_WIDTH;
|
||||
rect.bottom -= height + 12;
|
||||
fAccountsListView = new AccountsListView(rect);
|
||||
view->AddChild(new BScrollView(NULL,fAccountsListView,B_FOLLOW_ALL,0,false,true));
|
||||
view->AddChild(new BScrollView(NULL, fAccountsListView, B_FOLLOW_ALL, 0,
|
||||
false, true));
|
||||
rect.right += B_V_SCROLL_BAR_WIDTH;
|
||||
|
||||
rect.top = rect.bottom + 8; rect.bottom = rect.top + height;
|
||||
BRect sizeRect = rect;
|
||||
sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR ("Add"));
|
||||
view->AddChild(new BButton(sizeRect,NULL,TR ("Add"),
|
||||
new BMessage(kMsgAddAccount),B_FOLLOW_BOTTOM));
|
||||
sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR("Add"));
|
||||
view->AddChild(new BButton(sizeRect, NULL, TR("Add"),
|
||||
new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM));
|
||||
|
||||
sizeRect.left = sizeRect.right+3;
|
||||
sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR ("Remove"));
|
||||
view->AddChild(fRemoveButton = new BButton(sizeRect,NULL,TR ("Remove"),
|
||||
new BMessage(kMsgRemoveAccount),B_FOLLOW_BOTTOM));
|
||||
sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR("Remove"));
|
||||
view->AddChild(fRemoveButton = new BButton(sizeRect, NULL, TR("Remove"),
|
||||
new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM));
|
||||
|
||||
// accounts config view
|
||||
rect = view->Bounds();
|
||||
@ -305,92 +310,97 @@ ConfigWindow::ConfigWindow()
|
||||
|
||||
// general settings
|
||||
|
||||
rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4;
|
||||
rect = tabView->Bounds();
|
||||
rect.bottom -= tabView->TabHeight() + 4;
|
||||
tabView->AddTab(view = new CenterContainer(rect));
|
||||
tabView->TabAt(1)->SetLabel(TR ("Settings"));
|
||||
tabView->TabAt(1)->SetLabel(TR("Settings"));
|
||||
|
||||
rect = view->Bounds().InsetByCopy(8,8);
|
||||
rect.right -= 1; rect.bottom = rect.top + height * 5 + 15;
|
||||
rect = view->Bounds().InsetByCopy(8, 8);
|
||||
rect.right -= 1;
|
||||
rect.bottom = rect.top + height * 5 + 15;
|
||||
BBox *box = new BBox(rect);
|
||||
box->SetLabel(TR ("Mail checking"));
|
||||
box->SetLabel(TR("Mail checking"));
|
||||
view->AddChild(box);
|
||||
|
||||
rect = box->Bounds().InsetByCopy(8,8);
|
||||
rect.top += 7; rect.bottom = rect.top + height + 5;
|
||||
BRect tile = rect.OffsetByCopy(0,1);
|
||||
int32 labelWidth = (int32)view->StringWidth(TR ("Check every"))+6;
|
||||
rect = box->Bounds().InsetByCopy(8, 8);
|
||||
rect.top += 7;
|
||||
rect.bottom = rect.top + height + 5;
|
||||
BRect tile = rect.OffsetByCopy(0, 1);
|
||||
int32 labelWidth = (int32)view->StringWidth(TR("Check every")) + 6;
|
||||
tile.right = 80 + labelWidth;
|
||||
fIntervalControl = new BTextControl(tile,"time",TR ("Check every"),
|
||||
NULL,NULL);
|
||||
fIntervalControl = new BTextControl(tile, "time", TR("Check every"), NULL,
|
||||
NULL);
|
||||
fIntervalControl->SetDivider(labelWidth);
|
||||
box->AddChild(fIntervalControl);
|
||||
|
||||
BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
|
||||
const char *frequencyStrings[] = {
|
||||
TR ("never"),
|
||||
TR ("minutes"),
|
||||
TR ("hours"),
|
||||
TR ("days")};
|
||||
TR("never"),
|
||||
TR("minutes"),
|
||||
TR("hours"),
|
||||
TR("days")};
|
||||
BMenuItem *item;
|
||||
for (int32 i = 0;i < 4;i++)
|
||||
{
|
||||
frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],new BMessage(kMsgIntervalUnitChanged)));
|
||||
for (int32 i = 0; i < 4; i++) {
|
||||
frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],
|
||||
new BMessage(kMsgIntervalUnitChanged)));
|
||||
if (i == 1)
|
||||
item->SetMarked(true);
|
||||
}
|
||||
tile.left = tile.right + 5; tile.right = rect.right;
|
||||
tile.left = tile.right + 5;
|
||||
tile.right = rect.right;
|
||||
tile.OffsetBy(0,-1);
|
||||
fIntervalUnitField = new BMenuField(tile,"frequency", B_EMPTY_STRING, frequencyPopUp);
|
||||
fIntervalUnitField = new BMenuField(tile, "frequency", B_EMPTY_STRING,
|
||||
frequencyPopUp);
|
||||
fIntervalUnitField->SetDivider(0.0);
|
||||
box->AddChild(fIntervalUnitField);
|
||||
|
||||
rect.OffsetBy(0,height + 9); rect.bottom -= 2;
|
||||
fPPPActiveCheckBox = new BCheckBox(rect,"ppp active",
|
||||
TR ("Only when dial-up is connected"), NULL);
|
||||
rect.OffsetBy(0,height + 9);
|
||||
rect.bottom -= 2;
|
||||
fPPPActiveCheckBox = new BCheckBox(rect, "ppp active",
|
||||
TR("Only when dial-up is connected"), NULL);
|
||||
box->AddChild(fPPPActiveCheckBox);
|
||||
|
||||
rect.OffsetBy(0,height + 9); rect.bottom -= 2;
|
||||
fPPPActiveSendCheckBox = new BCheckBox(rect,"ppp activesend",
|
||||
TR ("Schedule outgoing mail when dial-up is disconnected"), NULL);
|
||||
|
||||
rect.OffsetBy(0,height + 9);
|
||||
rect.bottom -= 2;
|
||||
fPPPActiveSendCheckBox = new BCheckBox(rect, "ppp activesend",
|
||||
TR("Schedule outgoing mail when dial-up is disconnected"), NULL);
|
||||
box->AddChild(fPPPActiveSendCheckBox);
|
||||
|
||||
// Miscellaneous settings box
|
||||
|
||||
rect = box->Frame(); rect.bottom = rect.top + 3*height + 30;
|
||||
|
||||
rect = box->Frame(); rect.bottom = rect.top + 3 * height + 30;
|
||||
box = new BBox(rect);
|
||||
box->SetLabel(TR ("Miscellaneous"));
|
||||
box->SetLabel(TR("Miscellaneous"));
|
||||
view->AddChild(box);
|
||||
|
||||
BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
|
||||
const char *statusModes[] = {
|
||||
TR ("Never"),
|
||||
TR ("While sending"),
|
||||
TR ("While sending and receiving"),
|
||||
TR ("Always")};
|
||||
TR("Never"),
|
||||
TR("While sending"),
|
||||
TR("While sending and receiving"),
|
||||
TR("Always")};
|
||||
BMessage *msg;
|
||||
for (int32 i = 0;i < 4;i++)
|
||||
{
|
||||
statusPopUp->AddItem(item = new BMenuItem(statusModes[i],msg = new BMessage(kMsgShowStatusWindowChanged)));
|
||||
msg->AddInt32("ShowStatusWindow",i);
|
||||
for (int32 i = 0; i < 4; i++) {
|
||||
statusPopUp->AddItem(item = new BMenuItem(statusModes[i],
|
||||
msg = new BMessage(kMsgShowStatusWindowChanged)));
|
||||
msg->AddInt32("ShowStatusWindow", i);
|
||||
if (i == 0)
|
||||
item->SetMarked(true);
|
||||
}
|
||||
rect = box->Bounds().InsetByCopy(8,8);
|
||||
rect.top += 7;
|
||||
rect.bottom = rect.top + height + 5;
|
||||
labelWidth = (int32)view->StringWidth(
|
||||
TR ("Show connection status window:")) + 8;
|
||||
fStatusModeField = new BMenuField(rect,"show status",
|
||||
TR ("Show connection status window:"),
|
||||
statusPopUp);
|
||||
labelWidth
|
||||
= (int32)view->StringWidth(TR("Show connection status window:")) + 8;
|
||||
fStatusModeField = new BMenuField(rect, "show status",
|
||||
TR("Show connection status window:"), statusPopUp);
|
||||
fStatusModeField->SetDivider(labelWidth);
|
||||
box->AddChild(fStatusModeField);
|
||||
|
||||
rect = fStatusModeField->Frame();;
|
||||
rect.OffsetBy(0, rect.Height() + 10);
|
||||
BButton *button = new BButton(rect,B_EMPTY_STRING,
|
||||
TR ("Edit mailbox menu…"),
|
||||
msg = new BMessage(B_REFS_RECEIVED));
|
||||
BButton *button = new BButton(rect, B_EMPTY_STRING,
|
||||
TR("Edit mailbox menu…"), msg = new BMessage(B_REFS_RECEIVED));
|
||||
button->ResizeToPreferred();
|
||||
box->AddChild(button);
|
||||
button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
|
||||
@ -409,8 +419,8 @@ ConfigWindow::ConfigWindow()
|
||||
|
||||
rect = button->Frame();
|
||||
rect.OffsetBy(rect.Width() + 30,0);
|
||||
fAutoStartCheckBox = new BCheckBox(rect,"start daemon",
|
||||
TR ("Start mail services on startup"),NULL);
|
||||
fAutoStartCheckBox = new BCheckBox(rect, "start daemon",
|
||||
TR("Start mail services on startup"), NULL);
|
||||
fAutoStartCheckBox->ResizeToPreferred();
|
||||
box->AddChild(fAutoStartCheckBox);
|
||||
|
||||
@ -419,20 +429,19 @@ ConfigWindow::ConfigWindow()
|
||||
top->AddChild(tabView);
|
||||
|
||||
rect = tabView->Frame();
|
||||
rect.top = rect.bottom + 5; rect.bottom = rect.top + height + 5;
|
||||
BButton *saveButton = new BButton(rect,"apply",
|
||||
TR ("Apply"),
|
||||
rect.top = rect.bottom + 5;
|
||||
rect.bottom = rect.top + height + 5;
|
||||
BButton *saveButton = new BButton(rect, "apply", TR("Apply"),
|
||||
new BMessage(kMsgSaveSettings));
|
||||
float w,h;
|
||||
saveButton->GetPreferredSize(&w,&h);
|
||||
saveButton->ResizeTo(w,h);
|
||||
saveButton->GetPreferredSize(&w, &h);
|
||||
saveButton->ResizeTo(w, h);
|
||||
saveButton->MoveTo(rect.right - w, rect.top);
|
||||
top->AddChild(saveButton);
|
||||
|
||||
BButton *revertButton = new BButton(rect,"revert",
|
||||
TR ("Revert"),
|
||||
BButton *revertButton = new BButton(rect, "revert", TR("Revert"),
|
||||
new BMessage(kMsgRevertSettings));
|
||||
revertButton->GetPreferredSize(&w,&h);
|
||||
revertButton->GetPreferredSize(&w, &h);
|
||||
revertButton->ResizeTo(w,h);
|
||||
revertButton->MoveTo(saveButton->Frame().left - 25 - w, rect.top);
|
||||
top->AddChild(revertButton);
|
||||
@ -457,9 +466,11 @@ ConfigWindow::MakeHowToView()
|
||||
BResources *resources = BApplication::AppResources();
|
||||
if (resources) {
|
||||
size_t length;
|
||||
char *buffer = (char *)resources->FindResource(B_LARGE_ICON_TYPE, 101, &length);
|
||||
char *buffer = (char *)resources->FindResource(B_LARGE_ICON_TYPE, 101,
|
||||
&length);
|
||||
if (buffer) {
|
||||
BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63), B_CMAP8);
|
||||
BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
|
||||
B_CMAP8);
|
||||
if (bitmap && bitmap->InitCheck() == B_OK) {
|
||||
// copy and enlarge a 32x32 8-bit bitmap
|
||||
char *bits = (char *)bitmap->Bits();
|
||||
@ -481,7 +492,8 @@ ConfigWindow::MakeHowToView()
|
||||
BFile appFile(&info.ref, B_READ_ONLY);
|
||||
BAppFileInfo appFileInfo(&appFile);
|
||||
if (appFileInfo.InitCheck() == B_OK) {
|
||||
BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63), B_RGBA32);
|
||||
BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
|
||||
B_RGBA32);
|
||||
if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
|
||||
fConfigView->AddChild(new BitmapView(bitmap));
|
||||
} else
|
||||
@ -491,14 +503,13 @@ ConfigWindow::MakeHowToView()
|
||||
#endif // HAIKU_TARGET_PLATFORM_HAIKU
|
||||
|
||||
BRect rect = fConfigView->Bounds();
|
||||
BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE,
|
||||
B_WILL_DRAW);
|
||||
text->SetViewColor(fConfigView->Parent()->ViewColor());
|
||||
text->SetAlignment(B_ALIGN_CENTER);
|
||||
text->SetText(
|
||||
TR ("\n\nCreate a new account with the Add button.\n\n"
|
||||
text->SetText(TR("\n\nCreate a new account with the Add button.\n\n"
|
||||
"Remove an account with the Remove button on the selected item.\n\n"
|
||||
"Select an item in the list to change its settings."
|
||||
));
|
||||
"Select an item in the list to change its settings."));
|
||||
rect = text->Bounds();
|
||||
text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
|
||||
text->SetTextRect(rect);
|
||||
@ -507,7 +518,7 @@ ConfigWindow::MakeHowToView()
|
||||
text->MakeSelectable(false);
|
||||
|
||||
fConfigView->AddChild(text);
|
||||
|
||||
|
||||
static_cast<CenterContainer *>(fConfigView)->Layout();
|
||||
}
|
||||
|
||||
@ -525,8 +536,8 @@ ConfigWindow::LoadSettings()
|
||||
// move own window
|
||||
MoveTo(settings.ConfigWindowFrame().LeftTop());
|
||||
} else {
|
||||
fprintf(stderr, TR("Error retrieving general settings: %s\n"
|
||||
), strerror(status));
|
||||
fprintf(stderr, TR("Error retrieving general settings: %s\n"),
|
||||
strerror(status));
|
||||
}
|
||||
|
||||
BScreen screen(this);
|
||||
@ -555,7 +566,8 @@ ConfigWindow::SaveSettings()
|
||||
float interval;
|
||||
sscanf(fIntervalControl->Text(),"%f",&interval);
|
||||
float multiplier = 0;
|
||||
switch (fIntervalUnitField->Menu()->IndexOf(fIntervalUnitField->Menu()->FindMarked())) {
|
||||
switch (fIntervalUnitField->Menu()->IndexOf(
|
||||
fIntervalUnitField->Menu()->FindMarked())) {
|
||||
case 1: // minutes
|
||||
multiplier = 60;
|
||||
break;
|
||||
@ -572,12 +584,16 @@ ConfigWindow::SaveSettings()
|
||||
BMailSettings settings;
|
||||
if (fSaveSettings) {
|
||||
settings.SetAutoCheckInterval(time * 1e6);
|
||||
settings.SetCheckOnlyIfPPPUp(fPPPActiveCheckBox->Value() == B_CONTROL_ON);
|
||||
settings.SetSendOnlyIfPPPUp(fPPPActiveSendCheckBox->Value() == B_CONTROL_ON);
|
||||
settings.SetDaemonAutoStarts(fAutoStartCheckBox->Value() == B_CONTROL_ON);
|
||||
settings.SetCheckOnlyIfPPPUp(fPPPActiveCheckBox->Value()
|
||||
== B_CONTROL_ON);
|
||||
settings.SetSendOnlyIfPPPUp(fPPPActiveSendCheckBox->Value()
|
||||
== B_CONTROL_ON);
|
||||
settings.SetDaemonAutoStarts(fAutoStartCheckBox->Value()
|
||||
== B_CONTROL_ON);
|
||||
|
||||
// status mode (alway, fetching/retrieving, ...)
|
||||
int32 index = fStatusModeField->Menu()->IndexOf(fStatusModeField->Menu()->FindMarked());
|
||||
int32 index = fStatusModeField->Menu()->IndexOf(
|
||||
fStatusModeField->Menu()->FindMarked());
|
||||
settings.SetShowStatusWindow(index);
|
||||
|
||||
} else {
|
||||
@ -639,10 +655,10 @@ ConfigWindow::MessageReceived(BMessage *msg)
|
||||
case kMsgAddAccount:
|
||||
{
|
||||
frame = Frame();
|
||||
autoConfigRect.OffsetTo(frame.left + (frame.Width() - autoConfigRect.Width()) / 2,
|
||||
frame.top + (frame.Width() - autoConfigRect.Height()) / 2);
|
||||
autoConfigWindow = new AutoConfigWindow(autoConfigRect,
|
||||
this);
|
||||
autoConfigRect.OffsetTo(
|
||||
frame.left + (frame.Width() - autoConfigRect.Width()) / 2,
|
||||
frame.top + (frame.Width() - autoConfigRect.Height()) / 2);
|
||||
autoConfigWindow = new AutoConfigWindow(autoConfigRect, this);
|
||||
autoConfigWindow->Show();
|
||||
break;
|
||||
}
|
||||
@ -650,8 +666,9 @@ ConfigWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
int32 index = fAccountsListView->CurrentSelection();
|
||||
if (index >= 0) {
|
||||
AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(index);
|
||||
if (item) {
|
||||
AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(
|
||||
index);
|
||||
if (item != NULL) {
|
||||
item->account->Remove(item->type);
|
||||
MakeHowToView();
|
||||
}
|
||||
@ -731,7 +748,8 @@ ConfigWindow::SetToGeneralSettings(BMailSettings *settings)
|
||||
|
||||
fAutoStartCheckBox->SetValue(settings->DaemonAutoStarts());
|
||||
|
||||
if (BMenuItem *item = fStatusModeField->Menu()->ItemAt(settings->ShowStatusWindow()))
|
||||
if (BMenuItem *item
|
||||
= fStatusModeField->Menu()->ItemAt(settings->ShowStatusWindow()))
|
||||
item->SetMarked(true);
|
||||
|
||||
return B_OK;
|
||||
@ -748,14 +766,13 @@ ConfigWindow::RevertToLastSettings()
|
||||
settings.SetStatusWindowLook(settings.StatusWindowLook());
|
||||
|
||||
status_t status = SetToGeneralSettings(&settings);
|
||||
if (status != B_OK)
|
||||
{
|
||||
if (status != B_OK) {
|
||||
char text[256];
|
||||
sprintf(text,
|
||||
TR ("\nThe general settings couldn't be reverted.\n\n"
|
||||
"Error retrieving general settings:\n%s\n"),
|
||||
sprintf(text, TR("\nThe general settings couldn't be reverted.\n\n"
|
||||
"Error retrieving general settings:\n%s\n"),
|
||||
strerror(status));
|
||||
(new BAlert("Error",text,"OK",NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT))->Go();
|
||||
(new BAlert("Error", text, "OK", NULL, NULL, B_WIDTH_AS_USUAL,
|
||||
B_WARNING_ALERT))->Go();
|
||||
}
|
||||
|
||||
// revert account data
|
||||
@ -769,4 +786,3 @@ ConfigWindow::RevertToLastSettings()
|
||||
if (fConfigView->CountChildren() == 0)
|
||||
MakeHowToView();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user