* 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
+100 -99
View File
@@ -1,9 +1,11 @@
/* 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 "ConfigViews.h"
#include "CenterContainer.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,12 +48,12 @@ 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),
:
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,12 +90,12 @@ void AccountItem::DrawItem(BView *owner, BRect rect, bool complete)
}
//---------------------------------------------------------------------------------------
// #pragma mark -
Account::Account(BMailChain *inbound, BMailChain *outbound)
: fInbound(inbound),
:
fInbound(inbound),
fOutbound(outbound),
fAccountItem(NULL),
@@ -115,22 +120,24 @@ Account::Account(BMailChain *inbound,BMailChain *outbound)
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 (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 (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 (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 (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,20 +239,18 @@ 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 ((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 ((string = otherMsg->FindString("reply_to")) != NULL) {
if (thisMsg->ReplaceString("reply_to", string) < B_OK)
thisMsg->AddString("reply_to", string);
}
@@ -254,14 +260,11 @@ 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."),
if (!(fInbound = NewMailChain())) {
(new BAlert(TR("E-mail"), TR("Could not create inbound chain."),
TR("OK")))->Go();
return;
}
@@ -326,14 +329,11 @@ void Account::CreateInbound()
}
void Account::CreateOutbound()
void
Account::CreateOutbound()
{
if (!(fOutbound = NewMailChain()))
{
(new BAlert(
TR ("E-mail"),
TR ("Could not create outbound chain."),
if (!(fOutbound = NewMailChain())) {
(new BAlert(TR("E-mail"), TR("Could not create outbound chain."),
TR("OK")))->Go();
return;
}
@@ -372,7 +372,8 @@ void Account::CreateOutbound()
}
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,8 +392,8 @@ 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();
@@ -417,13 +417,15 @@ 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;
@@ -431,10 +433,10 @@ void Account::Selected(int32 type)
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;
@@ -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))
{
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,14 +619,11 @@ 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()))
break;
outChain = NULL;
@@ -635,8 +636,7 @@ 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));
@@ -651,7 +651,8 @@ void Accounts::Create(BListView *listView, BView *configView)
}
Account* Accounts::NewAccount()
Account*
Accounts::NewAccount()
{
Account *account = new Account();
gAccounts.AddItem(account);
@@ -663,19 +664,19 @@ Account* Accounts::NewAccount()
}
void Accounts::Save()
void
Accounts::Save()
{
for (int32 i = gAccounts.CountItems(); i-- > 0;)
((Account *)gAccounts.ItemAt(i))->Save();
}
void Accounts::Delete()
{
for (int32 i = gAccounts.CountItems();i-- > 0;)
void
Accounts::Delete()
{
for (int32 i = gAccounts.CountItems(); i-- > 0;) {
Account *account = (Account *)gAccounts.RemoveItem(i);
delete account;
}
}
+155 -145
View File
@@ -1,9 +1,11 @@
/* ConfigViews - config views for the account, protocols, and filters
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
/*
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
//! Config views for the account, protocols, and filters.
#include "ConfigViews.h"
#include "Account.h"
#include "CenterContainer.h"
@@ -54,7 +56,8 @@ const uint32 kMsgFilterSelected = 'fsel';
AccountConfigView::AccountConfigView(BRect rect, Account *account)
: BBox(rect),
:
BBox(rect),
fAccount(account)
{
SetLabel(TR("Account settings"));
@@ -67,18 +70,22 @@ AccountConfigView::AccountConfigView(BRect rect,Account *account)
// determine font height
font_height fontHeight;
view->GetFontHeight(&fontHeight);
int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5;
int32 height = (int32)(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading) + 5;
rect = view->Bounds();
rect.bottom = height + 5;
float labelWidth = view->StringWidth(TR("Account name:")) + 6;
view->AddChild(fNameControl = new BTextControl(rect,NULL,TR ("Account name:"),NULL,new BMessage(kMsgAccountNameChanged)));
view->AddChild(fNameControl = new BTextControl(rect, NULL,
TR("Account name:"), NULL, new BMessage(kMsgAccountNameChanged)));
fNameControl->SetDivider(labelWidth);
view->AddChild(fRealNameControl = new BTextControl(rect,NULL,TR ("Real name:"),NULL,NULL));
view->AddChild(fRealNameControl = new BTextControl(rect, NULL,
TR("Real name:"), NULL, NULL));
fRealNameControl->SetDivider(labelWidth);
view->AddChild(fReturnAddressControl = new BTextControl(rect,NULL,TR ("Return address:"),NULL,NULL));
view->AddChild(fReturnAddressControl = new BTextControl(rect, NULL,
TR("Return address:"), NULL, NULL));
fReturnAddressControl->SetDivider(labelWidth);
// control->TextView()->HideTyping(true);
@@ -88,8 +95,10 @@ AccountConfigView::AccountConfigView(BRect rect,Account *account)
TR("Send mail only"),
TR("Send and receive mail")};
BMenuItem *item;
for (int32 i = 0;i < 3;i++)
chainsPopUp->AddItem(item = new BMenuItem(chainModes[i],new BMessage(kMsgAccountTypeChanged)));
for (int32 i = 0;i < 3;i++) {
chainsPopUp->AddItem(item = new BMenuItem(chainModes[i],
new BMessage(kMsgAccountTypeChanged)));
}
fTypeField = new BMenuField(rect, NULL, TR("Account type:"), chainsPopUp);
fTypeField->SetDivider(labelWidth + 3);
@@ -104,7 +113,8 @@ AccountConfigView::AccountConfigView(BRect rect,Account *account)
}
void AccountConfigView::DetachedFromWindow()
void
AccountConfigView::DetachedFromWindow()
{
fAccount->SetName(fNameControl->Text());
fAccount->SetRealName(fRealNameControl->Text());
@@ -112,7 +122,8 @@ void AccountConfigView::DetachedFromWindow()
}
void AccountConfigView::AttachedToWindow()
void
AccountConfigView::AttachedToWindow()
{
UpdateViews();
fNameControl->SetTarget(this);
@@ -120,18 +131,17 @@ void AccountConfigView::AttachedToWindow()
}
void AccountConfigView::MessageReceived(BMessage *msg)
{
switch (msg->what)
void
AccountConfigView::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kMsgAccountTypeChanged:
{
int32 index;
if (msg->FindInt32("index", &index) < B_OK)
break;
if (fAccount->Type() < 0)
{
if (fAccount->Type() < 0) {
fNameControl->SetEnabled(true);
fRealNameControl->SetEnabled(true);
fReturnAddressControl->SetEnabled(true);
@@ -150,10 +160,10 @@ void AccountConfigView::MessageReceived(BMessage *msg)
}
void AccountConfigView::UpdateViews()
{
if (!fAccount->Inbound() && !fAccount->Outbound())
void
AccountConfigView::UpdateViews()
{
if (!fAccount->Inbound() && !fAccount->Outbound()) {
if (BMenuItem *item = fTypeField->Menu()->FindMarked())
item->SetMarked(false);
fTypeField->Menu()->Superitem()->SetLabel(TR("Select account type"));
@@ -172,12 +182,13 @@ void AccountConfigView::UpdateViews()
}
//---------------------------------------------------------------------------------------
// #pragma mark -
#include <stdio.h>
FilterConfigView::FilterConfigView(BMailChain *chain,int32 index,BMessage *msg,entry_ref *ref)
: BBox(BRect(0,0,100,100)),
FilterConfigView::FilterConfigView(BMailChain *chain, int32 index,
BMessage *msg, entry_ref *ref)
:
BBox(BRect(0,0,100,100)),
fConfigView(NULL),
fChain(chain),
fIndex(index),
@@ -196,7 +207,8 @@ FilterConfigView::~FilterConfigView()
}
void FilterConfigView::Load(BMessage *msg,entry_ref *ref)
void
FilterConfigView::Load(BMessage *msg, entry_ref *ref)
{
ResizeTo(264,30);
@@ -206,8 +218,8 @@ void FilterConfigView::Load(BMessage *msg,entry_ref *ref)
if (fImage < B_OK)
return;
if (get_image_symbol(fImage,"instantiate_config_panel",B_SYMBOL_TYPE_TEXT,(void **)&instantiate_config) < B_OK)
{
if (get_image_symbol(fImage, "instantiate_config_panel",
B_SYMBOL_TYPE_TEXT,(void **)&instantiate_config) < B_OK) {
unload_add_on(fImage);
fImage = B_MISSING_SYMBOL;
return;
@@ -223,19 +235,18 @@ void FilterConfigView::Load(BMessage *msg,entry_ref *ref)
}
void FilterConfigView::Remove(bool deleteMessage)
void
FilterConfigView::Remove(bool deleteMessage)
{
// remove config view here, because they may not be available
// anymore, if the add-on is unloaded
if (fConfigView && RemoveChild(fConfigView))
{
if (fConfigView && RemoveChild(fConfigView)) {
delete fConfigView;
fConfigView = NULL;
}
unload_add_on(fImage);
if (deleteMessage)
{
if (deleteMessage) {
delete fMessage;
fMessage = NULL;
}
@@ -244,13 +255,15 @@ void FilterConfigView::Remove(bool deleteMessage)
}
status_t FilterConfigView::InitCheck()
status_t
FilterConfigView::InitCheck()
{
return fImage;
}
void FilterConfigView::DetachedFromWindow()
void
FilterConfigView::DetachedFromWindow()
{
if (fConfigView == NULL)
return;
@@ -260,25 +273,27 @@ void FilterConfigView::DetachedFromWindow()
}
void FilterConfigView::AttachedToWindow()
void
FilterConfigView::AttachedToWindow()
{
}
//---------------------------------------------------------------------------------------
// #pragma mark -
ProtocolsConfigView::ProtocolsConfigView(BMailChain *chain,int32 index,BMessage *msg,entry_ref *ref)
: FilterConfigView(chain,index,msg,ref)
ProtocolsConfigView::ProtocolsConfigView(BMailChain *chain, int32 index,
BMessage *msg, entry_ref *ref)
:
FilterConfigView(chain, index, msg, ref)
{
BPopUpMenu *menu = new BPopUpMenu("Choose Protocol");
for (int i = 0; i < 2; i++) {
BPath path;
status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY : B_BEOS_ADDONS_DIRECTORY,&path);
if (status != B_OK)
{
status_t status = find_directory(
i == 0 ? B_USER_ADDONS_DIRECTORY : B_BEOS_ADDONS_DIRECTORY, &path);
if (status != B_OK) {
fImage = status;
return;
}
@@ -292,15 +307,15 @@ ProtocolsConfigView::ProtocolsConfigView(BMailChain *chain,int32 index,BMessage
BDirectory dir(path.Path());
entry_ref protocolRef;
while (dir.GetNextRef(&protocolRef) == B_OK)
{
while (dir.GetNextRef(&protocolRef) == B_OK) {
char name[B_FILE_NAME_LENGTH];
BEntry entry(&protocolRef);
entry.GetName(name);
BMenuItem *item;
BMessage *msg;
menu->AddItem(item = new BMenuItem(name,msg = new BMessage(kMsgProtocolChanged)));
menu->AddItem(item = new BMenuItem(name,
msg = new BMessage(kMsgProtocolChanged)));
msg->AddRef("protocol", &protocolRef);
if (*ref == protocolRef)
@@ -308,31 +323,31 @@ ProtocolsConfigView::ProtocolsConfigView(BMailChain *chain,int32 index,BMessage
}
}
fProtocolsMenuField = new BMenuField(BRect(0,0,200,40),NULL,NULL,menu);
fProtocolsMenuField
= new BMenuField(BRect(0, 0, 200, 40), NULL, NULL, menu);
fProtocolsMenuField->ResizeToPreferred();
SetLabel(fProtocolsMenuField);
if (fConfigView)
{
if (fConfigView) {
fConfigView->MoveTo(3, 21);
ResizeBy(0, 8);
}
else
} else
fImage = B_OK;
}
void ProtocolsConfigView::AttachedToWindow()
void
ProtocolsConfigView::AttachedToWindow()
{
FilterConfigView::AttachedToWindow();
fProtocolsMenuField->Menu()->SetTargetForItems(this);
}
void ProtocolsConfigView::MessageReceived(BMessage *msg)
{
switch (msg->what)
void
ProtocolsConfigView::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kMsgProtocolChanged:
{
entry_ref ref;
@@ -347,16 +362,15 @@ void ProtocolsConfigView::MessageReceived(BMessage *msg)
fChain->SetFilter(fIndex, *fMessage, *fEntryRef);
// resize view
if (LockLooperWithTimeout(1000000L) == B_OK)
{
if (fConfigView)
{
if (LockLooperWithTimeout(1000000L) == B_OK) {
if (fConfigView) {
fConfigView->MoveTo(3, 21);
ResizeBy(0, 8);
}
UnlockLooper();
if (CenterContainer *container = dynamic_cast<CenterContainer *>(Parent()))
if (CenterContainer *container
= dynamic_cast<CenterContainer *>(Parent()))
container->Layout();
}
break;
@@ -368,16 +382,17 @@ void ProtocolsConfigView::MessageReceived(BMessage *msg)
}
//---------------------------------------------------------------------------------------
// #pragma mark -
#include <stdio.h>
class DragListView : public BListView
{
class DragListView : public BListView {
public:
DragListView(BRect frame,const char *name,list_view_type type = B_SINGLE_SELECTION_LIST,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,BMessage *itemMovedMsg = NULL)
: BListView(frame,name,type,resizingMode),
DragListView(BRect frame, const char *name,
list_view_type type = B_SINGLE_SELECTION_LIST,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
BMessage *itemMovedMsg = NULL)
:
BListView(frame, name, type, resizingMode),
fDragging(false),
fItemMovedMessage(itemMovedMsg)
{
@@ -386,12 +401,12 @@ class DragListView : public BListView
virtual bool InitiateDrag(BPoint point, int32 index, bool wasSelected)
{
BRect frame(ItemFrame(index));
BBitmap *bitmap = new BBitmap(frame.OffsetToCopy(B_ORIGIN),B_RGBA32,true);
BBitmap *bitmap = new BBitmap(frame.OffsetToCopy(B_ORIGIN), B_RGBA32,
true);
BView *view = new BView(bitmap->Bounds(), NULL, 0, 0);
bitmap->AddChild(view);
if (view->LockLooper())
{
if (view->LockLooper()) {
BListItem *item = ItemAt(index);
bool selected = item->IsSelected();
@@ -440,7 +455,8 @@ class DragListView : public BListView
{
BListView::MouseMoved(point, transit, msg);
if ((transit != B_ENTERED_VIEW && transit != B_INSIDE_VIEW) || !fDragging)
if ((transit != B_ENTERED_VIEW && transit != B_INSIDE_VIEW)
|| !fDragging)
return;
int32 target = IndexOf(point);
@@ -466,8 +482,7 @@ class DragListView : public BListView
virtual void MouseUp(BPoint point)
{
if (fDragging)
{
if (fDragging) {
fDragging = false;
if (fLastDragTarget != -1)
DrawDragTargetIndicator(fLastDragTarget);
@@ -477,8 +492,7 @@ class DragListView : public BListView
virtual void MessageReceived(BMessage *msg)
{
switch(msg->what)
{
switch (msg->what) {
case kMsgItemDragged:
{
int32 source = msg->FindInt32("index");
@@ -490,12 +504,10 @@ class DragListView : public BListView
if (to == -1)
to = CountItems() - 1;
if (source != to)
{
if (source != to) {
MoveItem(source,to);
if (fItemMovedMessage != NULL)
{
if (fItemMovedMessage != NULL) {
BMessage msg(fItemMovedMessage->what);
msg.AddInt32("from",source);
msg.AddInt32("to",to);
@@ -515,7 +527,8 @@ class DragListView : public BListView
};
void GetPrettyDescriptiveName(BPath &path, char *name, BMessage *msg = NULL)
void
GetPrettyDescriptiveName(BPath &path, char *name, BMessage *msg = NULL)
{
strcpy(name, path.Leaf());
@@ -537,7 +550,8 @@ void GetPrettyDescriptiveName(BPath &path, char *name, BMessage *msg = NULL)
FiltersConfigView::FiltersConfigView(BRect rect, Account *account)
: BBox(rect),
:
BBox(rect),
fAccount(account),
fFilterView(NULL)
{
@@ -545,18 +559,17 @@ FiltersConfigView::FiltersConfigView(BRect rect,Account *account)
BMenuItem *item;
BMessage *msg;
if ((fChain = fAccount->Inbound()))
{
menu->AddItem(item = new BMenuItem(TR ("Incoming mail filters"),msg = new BMessage(kMsgChainSelected)));
if ((fChain = fAccount->Inbound())) {
menu->AddItem(item = new BMenuItem(TR("Incoming mail filters"),
msg = new BMessage(kMsgChainSelected)));
msg->AddPointer("chain", fChain);
item->SetMarked(true);
}
if (BMailChain *chain = fAccount->Outbound())
{
menu->AddItem(item = new BMenuItem(TR ("Outgoing mail filters"),msg = new BMessage(kMsgChainSelected)));
if (BMailChain *chain = fAccount->Outbound()) {
menu->AddItem(item = new BMenuItem(TR("Outgoing mail filters"),
msg = new BMessage(kMsgChainSelected)));
msg->AddPointer("chain", chain);
if (fChain == NULL)
{
if (fChain == NULL) {
item->SetMarked(true);
fChain = chain;
}
@@ -569,21 +582,26 @@ FiltersConfigView::FiltersConfigView(BRect rect,Account *account)
// determine font height
font_height fontHeight;
fChainsField->GetFontHeight(&fontHeight);
int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5;
int32 height = (int32)(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading) + 5;
rect = Bounds().InsetByCopy(10, 10);
rect.top += 18;
rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom = rect.top + 4 * height + 2;
fListView = new DragListView(rect,NULL,B_SINGLE_SELECTION_LIST,B_FOLLOW_ALL,new BMessage(kMsgFilterMoved));
fListView = new DragListView(rect, NULL, B_SINGLE_SELECTION_LIST,
B_FOLLOW_ALL, new BMessage(kMsgFilterMoved));
AddChild(new BScrollView(NULL, fListView, B_FOLLOW_ALL, 0, false, true));
rect.right += B_V_SCROLL_BAR_WIDTH;
// fListView->Select(gSettings.formats.IndexOf(format));
fListView->SetSelectionMessage(new BMessage(kMsgFilterSelected));
rect.top = rect.bottom + 8; rect.bottom = rect.top + height;
BRect sizeRect = rect; sizeRect.right = sizeRect.left + 30 + fChainsField->StringWidth(TR ("Add filter"));
rect.top = rect.bottom + 8;
rect.bottom = rect.top + height;
BRect sizeRect = rect;
sizeRect.right = sizeRect.left + 30
+ fChainsField->StringWidth(TR("Add filter"));
menu = new BPopUpMenu(TR("Add filter"));
menu->SetRadioMode(false);
@@ -592,9 +610,12 @@ FiltersConfigView::FiltersConfigView(BRect rect,Account *account)
fAddField->ResizeToPreferred();
AddChild(fAddField);
sizeRect.left = sizeRect.right + 5; sizeRect.right = sizeRect.left + 30 + fChainsField->StringWidth(TR ("Remove"));
sizeRect.left = sizeRect.right + 5;
sizeRect.right = sizeRect.left + 30
+ fChainsField->StringWidth(TR("Remove"));
sizeRect.top--;
AddChild(fRemoveButton = new BButton(sizeRect,NULL,TR ("Remove"),new BMessage(kMsgRemoveFilter),B_FOLLOW_BOTTOM));
AddChild(fRemoveButton = new BButton(sizeRect, NULL, TR("Remove"),
new BMessage(kMsgRemoveFilter), B_FOLLOW_BOTTOM));
ResizeTo(Bounds().Width(), sizeRect.bottom + 10);
SetTo(fChain);
@@ -606,18 +627,19 @@ FiltersConfigView::~FiltersConfigView()
}
void FiltersConfigView::SelectFilter(int32 index)
void
FiltersConfigView::SelectFilter(int32 index)
{
if (Parent())
Parent()->Hide();
// remove old config view
if (fFilterView)
{
if (fFilterView) {
Parent()->RemoveChild(fFilterView);
// update the name in the list
BStringItem *item = (BStringItem *)fListView->ItemAt(fFilterView->fIndex - fFirst);
BStringItem *item = (BStringItem *)fListView->ItemAt(
fFilterView->fIndex - fFirst);
char name[B_FILE_NAME_LENGTH];
BPath path(fFilterView->fEntryRef);
@@ -628,24 +650,19 @@ void FiltersConfigView::SelectFilter(int32 index)
fFilterView = NULL;
}
if (index >= 0)
{
if (index >= 0) {
// add new config view
BMessage *msg = new BMessage();
entry_ref *ref = new entry_ref();
if (fChain->GetFilter(index + fFirst,msg,ref) >= B_OK && Parent())
{
if (fChain->GetFilter(index + fFirst, msg, ref) >= B_OK && Parent()) {
fFilterView = new FilterConfigView(fChain,index + fFirst, msg, ref);
if (fFilterView->InitCheck() >= B_OK)
Parent()->AddChild(fFilterView);
else
{
else {
delete fFilterView;
fFilterView = NULL;
}
}
else
{
} else {
delete msg;
delete ref;
}
@@ -660,34 +677,30 @@ void FiltersConfigView::SelectFilter(int32 index)
}
void FiltersConfigView::SetTo(BMailChain *chain)
void
FiltersConfigView::SetTo(BMailChain *chain)
{
// remove the filter config view
SelectFilter(-1);
for (int32 i = fListView->CountItems();i-- > 0;)
{
for (int32 i = fListView->CountItems(); i-- > 0;) {
BStringItem *item = (BStringItem *)fListView->RemoveItem(i);
delete item;
}
if (chain->ChainDirection() == inbound)
{
if (chain->ChainDirection() == inbound) {
fFirst = 2; // skip protocol (e.g. POP3), and Parser
fLast = 2; // skip Notifier, and Folder
}
else
{
} else {
fFirst = 1; // skip Producer
fLast = 1; // skip protocol (e.g. SMTP)
}
int32 last = chain->CountFilters() - fLast;
for (int32 i = fFirst;i < last;i++)
{
for (int32 i = fFirst; i < last; i++) {
BMessage msg;
entry_ref ref;
if (chain->GetFilter(i,&msg,&ref) == B_OK)
{
if (chain->GetFilter(i, &msg, &ref) == B_OK) {
char name[B_FILE_NAME_LENGTH];
BPath addon(&ref);
GetPrettyDescriptiveName(addon, name, &msg);
@@ -701,15 +714,15 @@ void FiltersConfigView::SetTo(BMailChain *chain)
// remove old filter items
BMenu *menu = fAddField->Menu();
for (int32 i = menu->CountItems();i-- > 0;)
{
for (int32 i = menu->CountItems(); i-- > 0;) {
BMenuItem *item = menu->RemoveItem(i);
delete item;
}
for (int i = 0; i < 2; i++) {
BPath path;
status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY : B_BEOS_ADDONS_DIRECTORY,&path);
status_t status = find_directory(
i == 0 ? B_USER_ADDONS_DIRECTORY : B_BEOS_ADDONS_DIRECTORY, &path);
if (status != B_OK)
return;
@@ -722,15 +735,15 @@ void FiltersConfigView::SetTo(BMailChain *chain)
BDirectory dir(path.Path());
entry_ref ref;
while (dir.GetNextRef(&ref) == B_OK)
{
while (dir.GetNextRef(&ref) == B_OK) {
char name[B_FILE_NAME_LENGTH];
BPath path(&ref);
GetPrettyDescriptiveName(path, name);
BMenuItem *item;
BMessage *msg;
menu->AddItem(item = new BMenuItem(name,msg = new BMessage(kMsgAddFilter)));
menu->AddItem(item = new BMenuItem(name,
msg = new BMessage(kMsgAddFilter)));
msg->AddRef("filter", &ref);
}
}
@@ -738,7 +751,8 @@ void FiltersConfigView::SetTo(BMailChain *chain)
}
void FiltersConfigView::AttachedToWindow()
void
FiltersConfigView::AttachedToWindow()
{
fChainsField->Menu()->SetTargetForItems(this);
fListView->SetTarget(this);
@@ -747,10 +761,10 @@ void FiltersConfigView::AttachedToWindow()
}
void FiltersConfigView::MessageReceived(BMessage *msg)
{
switch (msg->what)
void
FiltersConfigView::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kMsgChainSelected:
{
BMailChain *chain;
@@ -767,8 +781,8 @@ void FiltersConfigView::MessageReceived(BMessage *msg)
break;
BMessage msg;
if (fChain->AddFilter(fChain->CountFilters() - fLast, msg, ref) >= B_OK)
{
if (fChain->AddFilter(fChain->CountFilters() - fLast, msg, ref)
>= B_OK) {
char name[B_FILE_NAME_LENGTH];
BPath path(&ref);
GetPrettyDescriptiveName(path, name, &msg);
@@ -783,8 +797,8 @@ void FiltersConfigView::MessageReceived(BMessage *msg)
break;
SelectFilter(-1);
if (BStringItem *item = (BStringItem *)fListView->RemoveItem(index))
{
if (BStringItem *item
= (BStringItem *)fListView->RemoveItem(index)) {
fChain->RemoveFilter(index + fFirst);
delete item;
}
@@ -811,39 +825,36 @@ void FiltersConfigView::MessageReceived(BMessage *msg)
entry_ref ref;
BMessage settings;
if (fChain->GetFilter(from,&settings,&ref) == B_OK)
{
if (fChain->GetFilter(from, &settings, &ref) == B_OK) {
// disable filter view saving
if (fFilterView && fFilterView->fIndex == from)
fFilterView->fIndex = -1;
fChain->RemoveFilter(from);
if (fChain->AddFilter(to,settings,ref) < B_OK)
{
(new BAlert("E-mail",TR (
"The filter could not be moved. Deleting filter."
),TR("OK")))->Go();
if (fChain->AddFilter(to, settings, ref) < B_OK) {
(new BAlert("E-mail",
TR("The filter could not be moved. Deleting filter."),
TR("OK")))->Go();
// the filter view belongs to the moved filter
if (fFilterView && fFilterView->fIndex == -1)
SelectFilter(-1);
fListView->RemoveItem(msg->FindInt32("to"));
}
else if (fFilterView)
{
} else if (fFilterView) {
int32 index = fFilterView->fIndex;
if (index == -1)
if (index == -1) {
// the view belongs to the moved filter
fFilterView->fIndex = to;
else if (index > from && index < to)
} else if (index > from && index < to) {
// the view belongs to another filter (between the
// 'from' & 'to' positions) - all others can keep
// their index value
fFilterView->fIndex--;
}
}
}
break;
}
default:
@@ -851,4 +862,3 @@ void FiltersConfigView::MessageReceived(BMessage *msg)
break;
}
}
+75 -59
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.
*
* Distributed under the terms of the MIT License.
*/
//! main E-Mail config window
#include "ConfigWindow.h"
#include "CenterContainer.h"
#include "Account.h"
@@ -244,12 +246,12 @@ class AboutTextView : public BTextView
};
//--------------------------------------------------------------------------------------
// #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)
@@ -264,13 +266,15 @@ ConfigWindow::ConfigWindow()
// 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);
BView *view;
rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4;
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());
@@ -281,7 +285,8 @@ ConfigWindow::ConfigWindow()
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;
@@ -305,23 +310,26 @@ 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"));
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);
box->SetLabel(TR("Mail checking"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8, 8);
rect.top += 7; rect.bottom = rect.top + height + 5;
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);
@@ -332,24 +340,28 @@ ConfigWindow::ConfigWindow()
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;
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;
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);
@@ -368,9 +380,9 @@ ConfigWindow::ConfigWindow()
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)));
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);
@@ -378,19 +390,17 @@ ConfigWindow::ConfigWindow()
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;
labelWidth
= (int32)view->StringWidth(TR("Show connection status window:")) + 8;
fStatusModeField = new BMenuField(rect, "show status",
TR ("Show connection status window:"),
statusPopUp);
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));
TR("Edit mailbox menu…"), msg = new BMessage(B_REFS_RECEIVED));
button->ResizeToPreferred();
box->AddChild(button);
button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
@@ -419,9 +429,9 @@ 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);
@@ -429,8 +439,7 @@ ConfigWindow::ConfigWindow()
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->ResizeTo(w,h);
@@ -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);
@@ -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,
autoConfigRect.OffsetTo(
frame.left + (frame.Width() - autoConfigRect.Width()) / 2,
frame.top + (frame.Width() - autoConfigRect.Height()) / 2);
autoConfigWindow = new AutoConfigWindow(autoConfigRect,
this);
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"
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();
}