* 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:
Axel Dörfler 2010-05-06 14:16:19 +00:00
parent 83bc49d051
commit d55567bbf9
3 changed files with 602 additions and 575 deletions

View File

@ -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" #include "Account.h"
@ -30,9 +32,11 @@
#include <MDRLanguage.h> #include <MDRLanguage.h>
#undef TR_CONTEXT #undef TR_CONTEXT
#define TR_CONTEXT "Account" #define TR_CONTEXT "Account"
static BList gAccounts; static BList gAccounts;
static BListView *gListView; static BListView *gListView;
static BView *gConfigView; static BView *gConfigView;
@ -44,14 +48,14 @@ const char *kInboundProtocolAddOnPath = "mail_daemon/inbound_protocols";
const char *kOutboundProtocolAddOnPath = "mail_daemon/outbound_protocols"; const char *kOutboundProtocolAddOnPath = "mail_daemon/outbound_protocols";
//---------------------------------------------------------------------------------------
// #pragma mark - // #pragma mark -
AccountItem::AccountItem(const char *label,Account *account,int32 type) AccountItem::AccountItem(const char *label, Account *account, int32 type)
: BStringItem(label), :
account(account), BStringItem(label),
type(type) 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) if (type == ACCOUNT_ITEM)
font = be_bold_font; 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(); owner->PushState();
if (type == ACCOUNT_ITEM) if (type == ACCOUNT_ITEM) {
{
// BFont font; // BFont font;
// owner->GetFont(&font); // owner->GetFont(&font);
// font.SetFace(B_BOLD_FACE); // font.SetFace(B_BOLD_FACE);
@ -85,18 +90,18 @@ void AccountItem::DrawItem(BView *owner, BRect rect, bool complete)
} }
//---------------------------------------------------------------------------------------
// #pragma mark - // #pragma mark -
Account::Account(BMailChain *inbound,BMailChain *outbound) Account::Account(BMailChain *inbound, BMailChain *outbound)
: fInbound(inbound), :
fOutbound(outbound), fInbound(inbound),
fOutbound(outbound),
fAccountItem(NULL), fAccountItem(NULL),
fInboundItem(NULL), fInboundItem(NULL),
fOutboundItem(NULL), fOutboundItem(NULL),
fFilterItem(NULL) fFilterItem(NULL)
{ {
fSettings = fInbound ? fInbound : fOutbound; fSettings = fInbound ? fInbound : fOutbound;
@ -105,32 +110,34 @@ Account::Account(BMailChain *inbound,BMailChain *outbound)
label << fSettings->Name(); label << fSettings->Name();
else else
label << TR("Unnamed"); 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); fInboundItem = new AccountItem(TR(" · Incoming"), this, INBOUND_ITEM);
fOutboundItem = new AccountItem(TR (" · Outgoing"),this,OUTBOUND_ITEM); fOutboundItem = new AccountItem(TR(" · Outgoing"), this, OUTBOUND_ITEM);
fFilterItem = new AccountItem(TR (" · E-mail filters"),this,FILTER_ITEM); fFilterItem = new AccountItem(TR(" · E-mail filters"), this, FILTER_ITEM);
} }
Account::~Account() Account::~Account()
{ {
if (gListView) if (gListView) {
{
gListView->RemoveItem(fAccountItem); gListView->RemoveItem(fAccountItem);
gListView->RemoveItem(fInboundItem); gListView->RemoveItem(fInboundItem);
gListView->RemoveItem(fOutboundItem); gListView->RemoveItem(fOutboundItem);
gListView->RemoveItem(fFilterItem); gListView->RemoveItem(fFilterItem);
} }
delete fAccountItem; delete fFilterItem; delete fAccountItem;
delete fInboundItem; delete fOutboundItem; delete fFilterItem;
delete fInboundItem;
delete fOutboundItem;
delete fInbound; delete fInbound;
delete fOutbound; delete fOutbound;
} }
void Account::AddToListView() void
Account::AddToListView()
{ {
if (!gListView) if (!gListView)
return; return;
@ -148,22 +155,23 @@ void Account::AddToListView()
} }
void Account::SetName(const char *name) void
Account::SetName(const char *name)
{ {
if (fInbound) if (fInbound)
fInbound->SetName(name); fInbound->SetName(name);
if (fOutbound) if (fOutbound)
fOutbound->SetName(name); fOutbound->SetName(name);
if (name && *name) if (name && *name) {
{
fAccountItem->SetText(name); fAccountItem->SetText(name);
gListView->InvalidateItem(gListView->IndexOf(fAccountItem)); gListView->InvalidateItem(gListView->IndexOf(fAccountItem));
} }
} }
const char *Account::Name() const const char *
Account::Name() const
{ {
if (fInbound) if (fInbound)
return fInbound->Name(); 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; BMessage *msg;
if (fInbound && (msg = fInbound->MetaData()) != NULL) if (fInbound && (msg = fInbound->MetaData()) != NULL) {
{ if (msg->ReplaceString("real_name", realName) < B_OK)
if (msg->ReplaceString("real_name",realName) < B_OK) msg->AddString("real_name", realName);
msg->AddString("real_name",realName);
} }
if (fOutbound && (msg = fOutbound->MetaData()) != NULL) if (fOutbound && (msg = fOutbound->MetaData()) != NULL) {
{ if (msg->ReplaceString("real_name", realName) < B_OK)
if (msg->ReplaceString("real_name",realName) < B_OK) msg->AddString("real_name", realName);
msg->AddString("real_name",realName);
} }
} }
const char *Account::RealName() const const char *
Account::RealName() const
{ {
if (fInbound && fInbound->MetaData()) if (fInbound && fInbound->MetaData())
return fInbound->MetaData()->FindString("real_name"); 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; BMessage *msg;
if (fInbound && (msg = fInbound->MetaData()) != NULL) if (fInbound && (msg = fInbound->MetaData()) != NULL) {
{ if (msg->ReplaceString("reply_to", returnAddress) < B_OK)
if (msg->ReplaceString("reply_to",returnAddress) < B_OK) msg->AddString("reply_to", returnAddress);
msg->AddString("reply_to",returnAddress);
} }
if (fOutbound && (msg = fOutbound->MetaData()) != NULL) if (fOutbound && (msg = fOutbound->MetaData()) != NULL) {
{ if (msg->ReplaceString("reply_to", returnAddress) < B_OK)
if (msg->ReplaceString("reply_to",returnAddress) < B_OK) msg->AddString("reply_to", returnAddress);
msg->AddString("reply_to",returnAddress);
} }
} }
const char *Account::ReturnAddress() const const char *
Account::ReturnAddress() const
{ {
if (fInbound && fInbound->MetaData()) if (fInbound && fInbound->MetaData())
return fInbound->MetaData()->FindString("reply_to"); 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; BMessage *otherMsg, *thisMsg;
if (sourceChain && (otherMsg = sourceChain->MetaData()) != NULL if (sourceChain && (otherMsg = sourceChain->MetaData()) != NULL
&& (thisMsg = targetChain->MetaData()) != NULL) && (thisMsg = targetChain->MetaData()) != NULL) {
{
const char *string; const char *string;
if ((string = otherMsg->FindString("real_name")) != NULL) if ((string = otherMsg->FindString("real_name")) != NULL) {
{ if (thisMsg->ReplaceString("real_name", string) < B_OK)
if (thisMsg->ReplaceString("real_name",string) < B_OK) thisMsg->AddString("real_name", string);
thisMsg->AddString("real_name",string);
} }
if ((string = otherMsg->FindString("reply_to")) != NULL) if ((string = otherMsg->FindString("reply_to")) != NULL) {
{ if (thisMsg->ReplaceString("reply_to", string) < B_OK)
if (thisMsg->ReplaceString("reply_to",string) < B_OK) thisMsg->AddString("reply_to", string);
thisMsg->AddString("reply_to",string);
} }
if ((string = sourceChain->Name()) != NULL) if ((string = sourceChain->Name()) != NULL)
targetChain->SetName(string); targetChain->SetName(string);
@ -254,21 +260,18 @@ void Account::CopyMetaData(BMailChain *targetChain, BMailChain *sourceChain)
} }
void Account::CreateInbound() void
Account::CreateInbound()
{ {
if (!(fInbound = NewMailChain())) {
if (!(fInbound = NewMailChain())) (new BAlert(TR("E-mail"), TR("Could not create inbound chain."),
{ TR("OK")))->Go();
(new BAlert(
TR ("E-mail"),
TR ("Could not create inbound chain."),
TR ("OK")))->Go();
return; return;
} }
fInbound->SetChainDirection(inbound); fInbound->SetChainDirection(inbound);
BPath path,addOnPath; BPath path,addOnPath;
find_directory(B_USER_ADDONS_DIRECTORY,&addOnPath); find_directory(B_USER_ADDONS_DIRECTORY, &addOnPath);
BMessage msg; BMessage msg;
entry_ref ref; entry_ref ref;
@ -278,101 +281,99 @@ void Account::CreateInbound()
path.Append(kInboundProtocolAddOnPath); path.Append(kInboundProtocolAddOnPath);
path.Append("POP3"); path.Append("POP3");
if (!BEntry(path.Path()).Exists()) { if (!BEntry(path.Path()).Exists()) {
find_directory(B_BEOS_ADDONS_DIRECTORY,&path); find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
path.Append(kInboundProtocolAddOnPath); path.Append(kInboundProtocolAddOnPath);
path.Append("POP3"); path.Append("POP3");
} }
BEntry(path.Path()).GetRef(&ref); BEntry(path.Path()).GetRef(&ref);
fInbound->AddFilter(msg,ref); fInbound->AddFilter(msg, ref);
// Message Parser // Message Parser
path = addOnPath; path = addOnPath;
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("Message Parser"); path.Append("Message Parser");
if (!BEntry(path.Path()).Exists()) { if (!BEntry(path.Path()).Exists()) {
find_directory(B_BEOS_ADDONS_DIRECTORY,&path); find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("Message Parser"); path.Append("Message Parser");
} }
BEntry(path.Path()).GetRef(&ref); BEntry(path.Path()).GetRef(&ref);
fInbound->AddFilter(msg,ref); fInbound->AddFilter(msg, ref);
// New Mail Notification // New Mail Notification
path = addOnPath; path = addOnPath;
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append(TR ("New mail notification")); path.Append(TR("New mail notification"));
if (!BEntry(path.Path()).Exists()) { if (!BEntry(path.Path()).Exists()) {
find_directory(B_BEOS_ADDONS_DIRECTORY,&path); find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("New mail notification"); path.Append("New mail notification");
} }
BEntry(path.Path()).GetRef(&ref); BEntry(path.Path()).GetRef(&ref);
fInbound->AddFilter(msg,ref); fInbound->AddFilter(msg, ref);
// Inbox // Inbox
path = addOnPath; path = addOnPath;
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("Inbox"); path.Append("Inbox");
if (!BEntry(path.Path()).Exists()) { if (!BEntry(path.Path()).Exists()) {
find_directory(B_BEOS_ADDONS_DIRECTORY,&path); find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("Inbox"); path.Append("Inbox");
} }
BEntry(path.Path()).GetRef(&ref); BEntry(path.Path()).GetRef(&ref);
fInbound->AddFilter(msg,ref); fInbound->AddFilter(msg, ref);
// set already made account settings // set already made account settings
CopyMetaData(fInbound,fOutbound); CopyMetaData(fInbound,fOutbound);
} }
void Account::CreateOutbound() void
Account::CreateOutbound()
{ {
if (!(fOutbound = NewMailChain())) {
if (!(fOutbound = NewMailChain())) (new BAlert(TR("E-mail"), TR("Could not create outbound chain."),
{ TR("OK")))->Go();
(new BAlert(
TR ("E-mail"),
TR ("Could not create outbound chain."),
TR ("OK")))->Go();
return; return;
} }
fOutbound->SetChainDirection(outbound); fOutbound->SetChainDirection(outbound);
BPath path,addOnPath; BPath path,addOnPath;
find_directory(B_USER_ADDONS_DIRECTORY,&addOnPath); find_directory(B_USER_ADDONS_DIRECTORY, &addOnPath);
BMessage msg; BMessage msg;
entry_ref ref; entry_ref ref;
path = addOnPath; path = addOnPath;
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("Outbox"); path.Append("Outbox");
if (!BEntry(path.Path()).Exists()) { if (!BEntry(path.Path()).Exists()) {
find_directory(B_BEOS_ADDONS_DIRECTORY,&path); find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
path.Append(kSystemFilterAddOnPath); path.Append(kSystemFilterAddOnPath);
path.Append("Outbox"); path.Append("Outbox");
} }
BEntry(path.Path()).GetRef(&ref); BEntry(path.Path()).GetRef(&ref);
fOutbound->AddFilter(msg,ref); fOutbound->AddFilter(msg, ref);
path = addOnPath; path = addOnPath;
path.Append(kOutboundProtocolAddOnPath); path.Append(kOutboundProtocolAddOnPath);
path.Append("SMTP"); path.Append("SMTP");
if (!BEntry(path.Path()).Exists()) { if (!BEntry(path.Path()).Exists()) {
find_directory(B_BEOS_ADDONS_DIRECTORY,&path); find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
path.Append(kOutboundProtocolAddOnPath); path.Append(kOutboundProtocolAddOnPath);
path.Append("SMTP"); path.Append("SMTP");
} }
BEntry(path.Path()).GetRef(&ref); BEntry(path.Path()).GetRef(&ref);
fOutbound->AddFilter(msg,ref); fOutbound->AddFilter(msg, ref);
// set already made account settings // set already made account settings
CopyMetaData(fOutbound,fInbound); CopyMetaData(fOutbound,fInbound);
} }
void Account::SetType(int32 type) void
Account::SetType(int32 type)
{ {
if (type < INBOUND_TYPE || type > IN_AND_OUTBOUND_TYPE) if (type < INBOUND_TYPE || type > IN_AND_OUTBOUND_TYPE)
return; return;
@ -380,8 +381,7 @@ void Account::SetType(int32 type)
int32 index = gListView->IndexOf(fAccountItem) + 1; int32 index = gListView->IndexOf(fAccountItem) + 1;
// missing inbound // missing inbound
if ((type == INBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE) && !Inbound()) if ((type == INBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE) && !Inbound()) {
{
if (!fInbound) if (!fInbound)
CreateInbound(); CreateInbound();
@ -392,20 +392,20 @@ void Account::SetType(int32 type)
index++; index++;
// missing outbound // missing outbound
if ((type == OUTBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE) && !Outbound()) if ((type == OUTBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE)
{ && !Outbound()) {
if (!fOutbound) if (!fOutbound)
CreateOutbound(); CreateOutbound();
if (fOutbound) if (fOutbound)
gListView->AddItem(fOutboundItem,index); gListView->AddItem(fOutboundItem, index);
} }
if (Outbound()) if (Outbound())
index++; index++;
// missing filter // missing filter
if (!gListView->HasItem(fFilterItem)) if (!gListView->HasItem(fFilterItem))
gListView->AddItem(fFilterItem,index); gListView->AddItem(fFilterItem, index);
// remove inbound // remove inbound
if (type == OUTBOUND_TYPE && 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); return Inbound() ? (Outbound() ? 2 : 0) : (Outbound() ? 1 : -1);
} }
void Account::Selected(int32 type) void
Account::Selected(int32 type)
{ {
if (!gConfigView) if (!gConfigView)
return; return;
gConfigView->Hide(); gConfigView->Hide();
((CenterContainer *)gConfigView)->DeleteChildren(); ((CenterContainer *)gConfigView)->DeleteChildren();
switch (type) switch (type) {
{
case ACCOUNT_ITEM: case ACCOUNT_ITEM:
gConfigView->AddChild(new AccountConfigView(gConfigView->Bounds(),this)); gConfigView->AddChild(new AccountConfigView(gConfigView->Bounds(),
this));
break; break;
case INBOUND_ITEM: case INBOUND_ITEM:
{ {
@ -442,22 +444,19 @@ void Account::Selected(int32 type)
break; break;
int32 count = fInbound->CountFilters(); int32 count = fInbound->CountFilters();
for (int32 i = 0;;i++) for (int32 i = 0;; i++) {
{
BMessage *msg = new BMessage(); BMessage *msg = new BMessage();
entry_ref *ref = new entry_ref; entry_ref *ref = new entry_ref;
// we just want to have the first and the last two filters: // we just want to have the first and the last two filters:
// Protocol, Parser, Notifier, Folder // Protocol, Parser, Notifier, Folder
if (i == 2) if (i == 2) {
{
i = count - 2; i = count - 2;
if (i < 2) // defensive programming... if (i < 2) // defensive programming...
i = 3; i = 3;
} }
if (fInbound->GetFilter(i,msg,ref) < B_OK) if (fInbound->GetFilter(i, msg, ref) < B_OK) {
{
delete msg; delete msg;
delete ref; delete ref;
break; break;
@ -466,9 +465,9 @@ void Account::Selected(int32 type)
// the filter view takes ownership of "msg" and "ref" // the filter view takes ownership of "msg" and "ref"
FilterConfigView *view; FilterConfigView *view;
if (i == 0) if (i == 0)
view = new ProtocolsConfigView(fInbound,i,msg,ref); view = new ProtocolsConfigView(fInbound, i, msg, ref);
else else
view = new FilterConfigView(fInbound,i,msg,ref); view = new FilterConfigView(fInbound, i, msg, ref);
if (view->InitCheck() >= B_OK) if (view->InitCheck() >= B_OK)
gConfigView->AddChild(view); gConfigView->AddChild(view);
@ -484,32 +483,31 @@ void Account::Selected(int32 type)
// we just want to have the first and the last filter here // we just want to have the first and the last filter here
int32 count = fOutbound->CountFilters(); 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(); BMessage *msg = new BMessage();
entry_ref *ref = new entry_ref; 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 msg;
delete ref; delete ref;
break; break;
} }
// the filter view takes ownership of "msg" and "ref" // the filter view takes ownership of "msg" and "ref"
if (FilterConfigView *view = new FilterConfigView(fOutbound,i,msg,ref)) FilterConfigView *view = new FilterConfigView(fOutbound, i, msg,
{ ref);
if (view->InitCheck() >= B_OK)
gConfigView->AddChild(view); if (view->InitCheck() >= B_OK)
else gConfigView->AddChild(view);
delete view; else
} delete view;
} }
break; break;
} }
case FILTER_ITEM: case FILTER_ITEM:
{ {
gConfigView->AddChild(new FiltersConfigView(gConfigView->Bounds(),this)); gConfigView->AddChild(new FiltersConfigView(gConfigView->Bounds(),
this));
break; 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 // this should only be called if necessary, but if it's used
// in the GUI, this will always be the case // in the GUI, this will always be the case
((CenterContainer *)gConfigView)->DeleteChildren(); ((CenterContainer *)gConfigView)->DeleteChildren();
switch (type) switch (type) {
{
case ACCOUNT_ITEM: case ACCOUNT_ITEM:
gListView->RemoveItem(fAccountItem); gListView->RemoveItem(fAccountItem);
gListView->RemoveItem(fInboundItem); 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; return gListView && gListView->HasItem(fInboundItem) ? fInbound : NULL;
} }
BMailChain *Account::Outbound() const BMailChain *
Account::Outbound() const
{ {
return gListView && gListView->HasItem(fOutboundItem) ? fOutbound : NULL; return gListView && gListView->HasItem(fOutboundItem) ? fOutbound : NULL;
} }
void Account::Save() void
Account::Save()
{ {
if (Inbound()) if (Inbound())
fInbound->Save(); 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)) if (fInbound && (type == INBOUND_TYPE || type == IN_AND_OUTBOUND_TYPE))
fInbound->Delete(); fInbound->Delete();
@ -591,7 +593,8 @@ void Account::Delete(int32 type)
// #pragma mark - // #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 *a = (*(Account **)_a)->Name();
const char *b = (*(Account **)_b)->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; gListView = listView;
gConfigView = configView; gConfigView = configView;
@ -615,19 +619,16 @@ void Accounts::Create(BListView *listView, BView *configView)
// create inbound accounts and assign matching outbound chains // 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 *inChain = (BMailChain *)inbound.ItemAt(i);
BMailChain *outChain = NULL; BMailChain *outChain = NULL;
for (int32 j = outbound.CountItems();j-- > 0;) for (int32 j = outbound.CountItems(); j-- > 0;) {
{
outChain = (BMailChain *)outbound.ItemAt(j); outChain = (BMailChain *)outbound.ItemAt(j);
if (!strcmp(inChain->Name(), outChain->Name()))
if (!strcmp(inChain->Name(),outChain->Name()))
break; break;
outChain = NULL; outChain = NULL;
} }
gAccounts.AddItem(new Account(inChain,outChain)); gAccounts.AddItem(new Account(inChain, outChain));
inbound.RemoveItem(i); inbound.RemoveItem(i);
if (outChain) if (outChain)
outbound.RemoveItem(outChain); outbound.RemoveItem(outChain);
@ -635,47 +636,47 @@ void Accounts::Create(BListView *listView, BView *configView)
// create remaining outbound only accounts // 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); BMailChain *outChain = (BMailChain *)outbound.ItemAt(i);
gAccounts.AddItem(new Account(NULL,outChain)); gAccounts.AddItem(new Account(NULL, outChain));
outbound.RemoveItem(i); outbound.RemoveItem(i);
} }
// sort the list alphabetically // sort the list alphabetically
gAccounts.SortItems(Accounts::Compare); 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->AddToListView();
} }
Account* Accounts::NewAccount() Account*
Accounts::NewAccount()
{ {
Account *account = new Account(); Account *account = new Account();
gAccounts.AddItem(account); gAccounts.AddItem(account);
account->AddToListView(); account->AddToListView();
if (gListView) if (gListView)
gListView->Select(gListView->IndexOf(account->fAccountItem)); gListView->Select(gListView->IndexOf(account->fAccountItem));
return account; 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(); ((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); Account *account = (Account *)gAccounts.RemoveItem(i);
delete account; delete account;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -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. * Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
//! main E-Mail config window //! main E-Mail config window
#include "ConfigWindow.h" #include "ConfigWindow.h"
#include "CenterContainer.h" #include "CenterContainer.h"
#include "Account.h" #include "Account.h"
@ -89,10 +91,10 @@ class AccountsListView : public BListView {
virtual void KeyDown(const char *bytes, int32 numBytes) { virtual void KeyDown(const char *bytes, int32 numBytes) {
if (numBytes != 1) if (numBytes != 1)
return; return;
if ((*bytes == B_DELETE) || (*bytes == B_BACKSPACE)) if ((*bytes == B_DELETE) || (*bytes == B_BACKSPACE))
Window()->PostMessage(kMsgRemoveAccount); Window()->PostMessage(kMsgRemoveAccount);
BListView::KeyDown(bytes,numBytes); BListView::KeyDown(bytes,numBytes);
} }
}; };
@ -216,7 +218,7 @@ class AboutTextView : public BTextView
virtual void Draw(BRect updateRect) virtual void Draw(BRect updateRect)
{ {
BTextView::Draw(updateRect); BTextView::Draw(updateRect);
BRect rect(fMail.Frame()); BRect rect(fMail.Frame());
StrokeLine(BPoint(rect.left,rect.bottom-2),BPoint(rect.right,rect.bottom-2)); StrokeLine(BPoint(rect.left,rect.bottom-2),BPoint(rect.right,rect.bottom-2));
rect = fBugsite.Frame(); rect = fBugsite.Frame();
@ -238,18 +240,18 @@ class AboutTextView : public BTextView
be_roster->Launch("text/html", 1, arg); be_roster->Launch("text/html", 1, arg);
} }
} }
private: private:
BRegion fWebsite,fMail,fBugsite; BRegion fWebsite,fMail,fBugsite;
}; };
//--------------------------------------------------------------------------------------
// #pragma mark - // #pragma mark -
ConfigWindow::ConfigWindow() 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), B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fLastSelectedAccount(NULL), fLastSelectedAccount(NULL),
fSaveSettings(false) fSaveSettings(false)
@ -257,43 +259,46 @@ ConfigWindow::ConfigWindow()
// create controls // create controls
BRect rect(Bounds()); 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)); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(top); AddChild(top);
// determine font height // determine font height
font_height fontHeight; font_height fontHeight;
top->GetFontHeight(&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; rect.InsetBy(5, 5); rect.bottom -= 11 + height;
BTabView *tabView = new BTabView(rect,NULL); BTabView *tabView = new BTabView(rect, NULL);
BView *view; BView *view;
rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; rect = tabView->Bounds();
tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0)); rect.bottom -= tabView->TabHeight() + 4;
tabView->TabAt(0)->SetLabel(TR ("Accounts")); tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0));
tabView->TabAt(0)->SetLabel(TR("Accounts"));
view->SetViewColor(top->ViewColor()); view->SetViewColor(top->ViewColor());
// accounts listview // accounts listview
rect = view->Bounds().InsetByCopy(8,8); rect = view->Bounds().InsetByCopy(8, 8);
rect.right = 140 - B_V_SCROLL_BAR_WIDTH; rect.right = 140 - B_V_SCROLL_BAR_WIDTH;
rect.bottom -= height + 12; rect.bottom -= height + 12;
fAccountsListView = new AccountsListView(rect); 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.right += B_V_SCROLL_BAR_WIDTH;
rect.top = rect.bottom + 8; rect.bottom = rect.top + height; rect.top = rect.bottom + 8; rect.bottom = rect.top + height;
BRect sizeRect = rect; BRect sizeRect = rect;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR ("Add")); sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR("Add"));
view->AddChild(new BButton(sizeRect,NULL,TR ("Add"), view->AddChild(new BButton(sizeRect, NULL, TR("Add"),
new BMessage(kMsgAddAccount),B_FOLLOW_BOTTOM)); new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM));
sizeRect.left = sizeRect.right+3; sizeRect.left = sizeRect.right+3;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR ("Remove")); sizeRect.right = sizeRect.left + 30 + view->StringWidth(TR("Remove"));
view->AddChild(fRemoveButton = new BButton(sizeRect,NULL,TR ("Remove"), view->AddChild(fRemoveButton = new BButton(sizeRect, NULL, TR("Remove"),
new BMessage(kMsgRemoveAccount),B_FOLLOW_BOTTOM)); new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM));
// accounts config view // accounts config view
rect = view->Bounds(); rect = view->Bounds();
@ -305,92 +310,97 @@ ConfigWindow::ConfigWindow()
// general settings // 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->AddTab(view = new CenterContainer(rect));
tabView->TabAt(1)->SetLabel(TR ("Settings")); tabView->TabAt(1)->SetLabel(TR("Settings"));
rect = view->Bounds().InsetByCopy(8,8); rect = view->Bounds().InsetByCopy(8, 8);
rect.right -= 1; rect.bottom = rect.top + height * 5 + 15; rect.right -= 1;
rect.bottom = rect.top + height * 5 + 15;
BBox *box = new BBox(rect); BBox *box = new BBox(rect);
box->SetLabel(TR ("Mail checking")); box->SetLabel(TR("Mail checking"));
view->AddChild(box); view->AddChild(box);
rect = box->Bounds().InsetByCopy(8,8); rect = box->Bounds().InsetByCopy(8, 8);
rect.top += 7; rect.bottom = rect.top + height + 5; rect.top += 7;
BRect tile = rect.OffsetByCopy(0,1); rect.bottom = rect.top + height + 5;
int32 labelWidth = (int32)view->StringWidth(TR ("Check every"))+6; BRect tile = rect.OffsetByCopy(0, 1);
int32 labelWidth = (int32)view->StringWidth(TR("Check every")) + 6;
tile.right = 80 + labelWidth; tile.right = 80 + labelWidth;
fIntervalControl = new BTextControl(tile,"time",TR ("Check every"), fIntervalControl = new BTextControl(tile, "time", TR("Check every"), NULL,
NULL,NULL); NULL);
fIntervalControl->SetDivider(labelWidth); fIntervalControl->SetDivider(labelWidth);
box->AddChild(fIntervalControl); box->AddChild(fIntervalControl);
BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING); BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
const char *frequencyStrings[] = { const char *frequencyStrings[] = {
TR ("never"), TR("never"),
TR ("minutes"), TR("minutes"),
TR ("hours"), TR("hours"),
TR ("days")}; TR("days")};
BMenuItem *item; BMenuItem *item;
for (int32 i = 0;i < 4;i++) for (int32 i = 0; i < 4; i++) {
{ frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],
frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],new BMessage(kMsgIntervalUnitChanged))); new BMessage(kMsgIntervalUnitChanged)));
if (i == 1) if (i == 1)
item->SetMarked(true); 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); 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); fIntervalUnitField->SetDivider(0.0);
box->AddChild(fIntervalUnitField); box->AddChild(fIntervalUnitField);
rect.OffsetBy(0,height + 9); rect.bottom -= 2; rect.OffsetBy(0,height + 9);
fPPPActiveCheckBox = new BCheckBox(rect,"ppp active", rect.bottom -= 2;
TR ("Only when dial-up is connected"), NULL); fPPPActiveCheckBox = new BCheckBox(rect, "ppp active",
TR("Only when dial-up is connected"), NULL);
box->AddChild(fPPPActiveCheckBox); box->AddChild(fPPPActiveCheckBox);
rect.OffsetBy(0,height + 9); rect.bottom -= 2; rect.OffsetBy(0,height + 9);
fPPPActiveSendCheckBox = new BCheckBox(rect,"ppp activesend", rect.bottom -= 2;
TR ("Schedule outgoing mail when dial-up is disconnected"), NULL); fPPPActiveSendCheckBox = new BCheckBox(rect, "ppp activesend",
TR("Schedule outgoing mail when dial-up is disconnected"), NULL);
box->AddChild(fPPPActiveSendCheckBox); box->AddChild(fPPPActiveSendCheckBox);
// Miscellaneous settings box // 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 = new BBox(rect);
box->SetLabel(TR ("Miscellaneous")); box->SetLabel(TR("Miscellaneous"));
view->AddChild(box); view->AddChild(box);
BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING); BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
const char *statusModes[] = { const char *statusModes[] = {
TR ("Never"), TR("Never"),
TR ("While sending"), TR("While sending"),
TR ("While sending and receiving"), TR("While sending and receiving"),
TR ("Always")}; TR("Always")};
BMessage *msg; BMessage *msg;
for (int32 i = 0;i < 4;i++) for (int32 i = 0; i < 4; i++) {
{ statusPopUp->AddItem(item = new BMenuItem(statusModes[i],
statusPopUp->AddItem(item = new BMenuItem(statusModes[i],msg = new BMessage(kMsgShowStatusWindowChanged))); msg = new BMessage(kMsgShowStatusWindowChanged)));
msg->AddInt32("ShowStatusWindow",i); msg->AddInt32("ShowStatusWindow", i);
if (i == 0) if (i == 0)
item->SetMarked(true); item->SetMarked(true);
} }
rect = box->Bounds().InsetByCopy(8,8); rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7; rect.top += 7;
rect.bottom = rect.top + height + 5; rect.bottom = rect.top + height + 5;
labelWidth = (int32)view->StringWidth( labelWidth
TR ("Show connection status window:")) + 8; = (int32)view->StringWidth(TR("Show connection status window:")) + 8;
fStatusModeField = new BMenuField(rect,"show status", fStatusModeField = new BMenuField(rect, "show status",
TR ("Show connection status window:"), TR("Show connection status window:"), statusPopUp);
statusPopUp);
fStatusModeField->SetDivider(labelWidth); fStatusModeField->SetDivider(labelWidth);
box->AddChild(fStatusModeField); box->AddChild(fStatusModeField);
rect = fStatusModeField->Frame();; rect = fStatusModeField->Frame();;
rect.OffsetBy(0, rect.Height() + 10); rect.OffsetBy(0, rect.Height() + 10);
BButton *button = new BButton(rect,B_EMPTY_STRING, BButton *button = new BButton(rect, B_EMPTY_STRING,
TR ("Edit mailbox menu…"), TR("Edit mailbox menu…"), msg = new BMessage(B_REFS_RECEIVED));
msg = new BMessage(B_REFS_RECEIVED));
button->ResizeToPreferred(); button->ResizeToPreferred();
box->AddChild(button); box->AddChild(button);
button->SetTarget(BMessenger("application/x-vnd.Be-TRAK")); button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
@ -409,8 +419,8 @@ ConfigWindow::ConfigWindow()
rect = button->Frame(); rect = button->Frame();
rect.OffsetBy(rect.Width() + 30,0); rect.OffsetBy(rect.Width() + 30,0);
fAutoStartCheckBox = new BCheckBox(rect,"start daemon", fAutoStartCheckBox = new BCheckBox(rect, "start daemon",
TR ("Start mail services on startup"),NULL); TR("Start mail services on startup"), NULL);
fAutoStartCheckBox->ResizeToPreferred(); fAutoStartCheckBox->ResizeToPreferred();
box->AddChild(fAutoStartCheckBox); box->AddChild(fAutoStartCheckBox);
@ -419,20 +429,19 @@ ConfigWindow::ConfigWindow()
top->AddChild(tabView); top->AddChild(tabView);
rect = tabView->Frame(); rect = tabView->Frame();
rect.top = rect.bottom + 5; rect.bottom = rect.top + height + 5; rect.top = rect.bottom + 5;
BButton *saveButton = new BButton(rect,"apply", rect.bottom = rect.top + height + 5;
TR ("Apply"), BButton *saveButton = new BButton(rect, "apply", TR("Apply"),
new BMessage(kMsgSaveSettings)); new BMessage(kMsgSaveSettings));
float w,h; float w,h;
saveButton->GetPreferredSize(&w,&h); saveButton->GetPreferredSize(&w, &h);
saveButton->ResizeTo(w,h); saveButton->ResizeTo(w, h);
saveButton->MoveTo(rect.right - w, rect.top); saveButton->MoveTo(rect.right - w, rect.top);
top->AddChild(saveButton); top->AddChild(saveButton);
BButton *revertButton = new BButton(rect,"revert", BButton *revertButton = new BButton(rect, "revert", TR("Revert"),
TR ("Revert"),
new BMessage(kMsgRevertSettings)); new BMessage(kMsgRevertSettings));
revertButton->GetPreferredSize(&w,&h); revertButton->GetPreferredSize(&w, &h);
revertButton->ResizeTo(w,h); revertButton->ResizeTo(w,h);
revertButton->MoveTo(saveButton->Frame().left - 25 - w, rect.top); revertButton->MoveTo(saveButton->Frame().left - 25 - w, rect.top);
top->AddChild(revertButton); top->AddChild(revertButton);
@ -457,9 +466,11 @@ ConfigWindow::MakeHowToView()
BResources *resources = BApplication::AppResources(); BResources *resources = BApplication::AppResources();
if (resources) { if (resources) {
size_t length; 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) { 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) { if (bitmap && bitmap->InitCheck() == B_OK) {
// copy and enlarge a 32x32 8-bit bitmap // copy and enlarge a 32x32 8-bit bitmap
char *bits = (char *)bitmap->Bits(); char *bits = (char *)bitmap->Bits();
@ -481,7 +492,8 @@ ConfigWindow::MakeHowToView()
BFile appFile(&info.ref, B_READ_ONLY); BFile appFile(&info.ref, B_READ_ONLY);
BAppFileInfo appFileInfo(&appFile); BAppFileInfo appFileInfo(&appFile);
if (appFileInfo.InitCheck() == B_OK) { 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) { if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
fConfigView->AddChild(new BitmapView(bitmap)); fConfigView->AddChild(new BitmapView(bitmap));
} else } else
@ -491,14 +503,13 @@ ConfigWindow::MakeHowToView()
#endif // HAIKU_TARGET_PLATFORM_HAIKU #endif // HAIKU_TARGET_PLATFORM_HAIKU
BRect rect = fConfigView->Bounds(); 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->SetViewColor(fConfigView->Parent()->ViewColor());
text->SetAlignment(B_ALIGN_CENTER); text->SetAlignment(B_ALIGN_CENTER);
text->SetText( text->SetText(TR("\n\nCreate a new account with the Add button.\n\n"
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" "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(); rect = text->Bounds();
text->ResizeTo(rect.Width(), text->TextHeight(0, 42)); text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
text->SetTextRect(rect); text->SetTextRect(rect);
@ -507,7 +518,7 @@ ConfigWindow::MakeHowToView()
text->MakeSelectable(false); text->MakeSelectable(false);
fConfigView->AddChild(text); fConfigView->AddChild(text);
static_cast<CenterContainer *>(fConfigView)->Layout(); static_cast<CenterContainer *>(fConfigView)->Layout();
} }
@ -525,8 +536,8 @@ ConfigWindow::LoadSettings()
// move own window // move own window
MoveTo(settings.ConfigWindowFrame().LeftTop()); MoveTo(settings.ConfigWindowFrame().LeftTop());
} else { } else {
fprintf(stderr, TR("Error retrieving general settings: %s\n" fprintf(stderr, TR("Error retrieving general settings: %s\n"),
), strerror(status)); strerror(status));
} }
BScreen screen(this); BScreen screen(this);
@ -555,7 +566,8 @@ ConfigWindow::SaveSettings()
float interval; float interval;
sscanf(fIntervalControl->Text(),"%f",&interval); sscanf(fIntervalControl->Text(),"%f",&interval);
float multiplier = 0; float multiplier = 0;
switch (fIntervalUnitField->Menu()->IndexOf(fIntervalUnitField->Menu()->FindMarked())) { switch (fIntervalUnitField->Menu()->IndexOf(
fIntervalUnitField->Menu()->FindMarked())) {
case 1: // minutes case 1: // minutes
multiplier = 60; multiplier = 60;
break; break;
@ -572,12 +584,16 @@ ConfigWindow::SaveSettings()
BMailSettings settings; BMailSettings settings;
if (fSaveSettings) { if (fSaveSettings) {
settings.SetAutoCheckInterval(time * 1e6); settings.SetAutoCheckInterval(time * 1e6);
settings.SetCheckOnlyIfPPPUp(fPPPActiveCheckBox->Value() == B_CONTROL_ON); settings.SetCheckOnlyIfPPPUp(fPPPActiveCheckBox->Value()
settings.SetSendOnlyIfPPPUp(fPPPActiveSendCheckBox->Value() == B_CONTROL_ON); == B_CONTROL_ON);
settings.SetDaemonAutoStarts(fAutoStartCheckBox->Value() == B_CONTROL_ON); settings.SetSendOnlyIfPPPUp(fPPPActiveSendCheckBox->Value()
== B_CONTROL_ON);
settings.SetDaemonAutoStarts(fAutoStartCheckBox->Value()
== B_CONTROL_ON);
// status mode (alway, fetching/retrieving, ...) // status mode (alway, fetching/retrieving, ...)
int32 index = fStatusModeField->Menu()->IndexOf(fStatusModeField->Menu()->FindMarked()); int32 index = fStatusModeField->Menu()->IndexOf(
fStatusModeField->Menu()->FindMarked());
settings.SetShowStatusWindow(index); settings.SetShowStatusWindow(index);
} else { } else {
@ -639,10 +655,10 @@ ConfigWindow::MessageReceived(BMessage *msg)
case kMsgAddAccount: case kMsgAddAccount:
{ {
frame = Frame(); frame = Frame();
autoConfigRect.OffsetTo(frame.left + (frame.Width() - autoConfigRect.Width()) / 2, autoConfigRect.OffsetTo(
frame.top + (frame.Width() - autoConfigRect.Height()) / 2); frame.left + (frame.Width() - autoConfigRect.Width()) / 2,
autoConfigWindow = new AutoConfigWindow(autoConfigRect, frame.top + (frame.Width() - autoConfigRect.Height()) / 2);
this); autoConfigWindow = new AutoConfigWindow(autoConfigRect, this);
autoConfigWindow->Show(); autoConfigWindow->Show();
break; break;
} }
@ -650,8 +666,9 @@ ConfigWindow::MessageReceived(BMessage *msg)
{ {
int32 index = fAccountsListView->CurrentSelection(); int32 index = fAccountsListView->CurrentSelection();
if (index >= 0) { if (index >= 0) {
AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(index); AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(
if (item) { index);
if (item != NULL) {
item->account->Remove(item->type); item->account->Remove(item->type);
MakeHowToView(); MakeHowToView();
} }
@ -731,7 +748,8 @@ ConfigWindow::SetToGeneralSettings(BMailSettings *settings)
fAutoStartCheckBox->SetValue(settings->DaemonAutoStarts()); fAutoStartCheckBox->SetValue(settings->DaemonAutoStarts());
if (BMenuItem *item = fStatusModeField->Menu()->ItemAt(settings->ShowStatusWindow())) if (BMenuItem *item
= fStatusModeField->Menu()->ItemAt(settings->ShowStatusWindow()))
item->SetMarked(true); item->SetMarked(true);
return B_OK; return B_OK;
@ -748,14 +766,13 @@ ConfigWindow::RevertToLastSettings()
settings.SetStatusWindowLook(settings.StatusWindowLook()); settings.SetStatusWindowLook(settings.StatusWindowLook());
status_t status = SetToGeneralSettings(&settings); status_t status = SetToGeneralSettings(&settings);
if (status != B_OK) if (status != B_OK) {
{
char text[256]; char text[256];
sprintf(text, sprintf(text, TR("\nThe general settings couldn't be reverted.\n\n"
TR ("\nThe general settings couldn't be reverted.\n\n" "Error retrieving general settings:\n%s\n"),
"Error retrieving general settings:\n%s\n"),
strerror(status)); 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 // revert account data
@ -769,4 +786,3 @@ ConfigWindow::RevertToLastSettings()
if (fConfigView->CountChildren() == 0) if (fConfigView->CountChildren() == 0)
MakeHowToView(); MakeHowToView();
} }