Mail: minor cleanup.

This commit is contained in:
Axel Dörfler
2015-08-17 21:12:42 +02:00
parent f8300bd979
commit b20d210d5a
4 changed files with 319 additions and 351 deletions
+7
View File
@@ -1253,6 +1253,13 @@ BComboBox::Text() const
} }
int32
BComboBox::TextLength() const
{
return fText->TextLength();
}
BTextView * BTextView *
BComboBox::TextView() BComboBox::TextView()
{ {
+1
View File
@@ -150,6 +150,7 @@ public:
virtual void SetLabel(const char *text); virtual void SetLabel(const char *text);
virtual void SetText(const char *text); virtual void SetText(const char *text);
const char *Text() const; const char *Text() const;
int32 TextLength() const;
BTextView *TextView(); BTextView *TextView();
virtual void SetDivider(float dividing_line); virtual void SetDivider(float dividing_line);
float Divider() const; float Divider() const;
+111 -154
View File
@@ -138,11 +138,30 @@ static const uint32 kByForumlaItem = 'Fbyq';
// taken from src/kits/tracker/FindPanel.h // taken from src/kits/tracker/FindPanel.h
// static bitmap cache
BObjectList<TMailWindow::BitmapItem> TMailWindow::sBitmapCache;
BLocker TMailWindow::sBitmapCacheLock;
// static list for tracking of Windows // static list for tracking of Windows
BList TMailWindow::sWindowList; BList TMailWindow::sWindowList;
BLocker TMailWindow::sWindowListLock; BLocker TMailWindow::sWindowListLock;
class HorizontalLine : public BView {
public:
HorizontalLine(BRect rect)
:
BView (rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW)
{
}
virtual void Draw(BRect rect)
{
FillRect(rect, B_SOLID_HIGH);
}
};
// #pragma mark - // #pragma mark -
@@ -216,8 +235,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
// few seconds. // few seconds.
if (!fIncoming) { if (!fIncoming) {
QueryMenu *queryMenu; QueryMenu* queryMenu = new QueryMenu(B_TRANSLATE("Open draft"), false);
queryMenu = new QueryMenu(B_TRANSLATE("Open draft"), false);
queryMenu->SetTargetForItems(be_app); queryMenu->SetTargetForItems(be_app);
queryMenu->SetPredicate("MAIL:draft==1"); queryMenu->SetPredicate("MAIL:draft==1");
@@ -554,20 +572,17 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
} }
BObjectList<TMailWindow::BitmapItem> TMailWindow::fBitmapCache;
BLocker TMailWindow::fBitmapCacheLock;
BBitmap* BBitmap*
TMailWindow::_RetrieveVectorIcon(int32 id) TMailWindow::_RetrieveVectorIcon(int32 id)
{ {
// Lock access to the list // Lock access to the list
BAutolock lock(fBitmapCacheLock); BAutolock lock(sBitmapCacheLock);
if (!lock.IsLocked()) if (!lock.IsLocked())
return NULL; return NULL;
// Check for the bitmap in the cache first // Check for the bitmap in the cache first
BitmapItem* item; BitmapItem* item;
for (int32 i = 0; (item = fBitmapCache.ItemAt(i)) != NULL; i++) { for (int32 i = 0; (item = sBitmapCache.ItemAt(i)) != NULL; i++) {
if (item->id == id) if (item->id == id)
return item->bm; return item->bm;
} }
@@ -588,7 +603,7 @@ TMailWindow::_RetrieveVectorIcon(int32 id)
item = (BitmapItem*)malloc(sizeof(BitmapItem)); item = (BitmapItem*)malloc(sizeof(BitmapItem));
item->bm = bitmap; item->bm = bitmap;
item->id = id; item->id = id;
fBitmapCache.AddItem(item); sBitmapCache.AddItem(item);
return bitmap; return bitmap;
} }
@@ -599,7 +614,7 @@ TMailWindow::_RetrieveVectorIcon(int32 id)
void void
TMailWindow::BuildToolBar() TMailWindow::BuildToolBar()
{ {
fToolBar = new BToolBar(BRect(0, 0, 100, 50)); fToolBar = new BToolBar();
fToolBar->AddAction(M_NEW, this, _RetrieveVectorIcon(11), NULL, fToolBar->AddAction(M_NEW, this, _RetrieveVectorIcon(11), NULL,
B_TRANSLATE("New")); B_TRANSLATE("New"));
fToolBar->AddSeparator(); fToolBar->AddSeparator();
@@ -1039,7 +1054,7 @@ TMailWindow::MessageReceived(BMessage *msg)
fChanged = true; fChanged = true;
// Update title bar if "subject" has changed // Update title bar if "subject" has changed
if (!fIncoming && fieldMask & FIELD_SUBJECT) { if (!fIncoming && (fieldMask & FIELD_SUBJECT) != 0) {
// If no subject, set to "Mail" // If no subject, set to "Mail"
if (!fHeaderView->fSubject->TextView()->TextLength()) if (!fHeaderView->fSubject->TextView()->TextLength())
SetTitle(B_TRANSLATE_SYSTEM_NAME("Mail")); SetTitle(B_TRANSLATE_SYSTEM_NAME("Mail"));
@@ -1182,7 +1197,7 @@ TMailWindow::MessageReceived(BMessage *msg)
case M_DELETE_PREV: case M_DELETE_PREV:
case M_DELETE_NEXT: case M_DELETE_NEXT:
{ {
if (msg->what == M_DELETE_NEXT && (modifiers() & B_SHIFT_KEY)) if (msg->what == M_DELETE_NEXT && (modifiers() & B_SHIFT_KEY) != 0)
msg->what = M_DELETE_PREV; msg->what = M_DELETE_PREV;
bool foundRef = false; bool foundRef = false;
@@ -1272,10 +1287,8 @@ TMailWindow::MessageReceived(BMessage *msg)
break; break;
case M_CLOSE_CUSTOM: case M_CLOSE_CUSTOM:
if (msg->HasString("status")) { if (msg->HasString("status")) {
const char *str;
msg->FindString("status", (const char**) &str);
BMessage message(B_CLOSE_REQUESTED); BMessage message(B_CLOSE_REQUESTED);
message.AddString("status", str); message.AddString("status", msg->GetString("status"));
PostMessage(&message); PostMessage(&message);
} else { } else {
BRect r = Frame(); BRect r = Frame();
@@ -1331,7 +1344,7 @@ TMailWindow::MessageReceived(BMessage *msg)
case M_SAVE: case M_SAVE:
{ {
const char* address; const char* address;
if (msg->FindString("address", (const char**)&address) != B_NO_ERROR) if (msg->FindString("address", (const char**)&address) != B_OK)
break; break;
BVolumeRoster volumeRoster; BVolumeRoster volumeRoster;
@@ -1822,61 +1835,57 @@ TMailWindow::Zoom(BPoint /*pos*/, float /*x*/, float /*y*/)
{ {
float height; float height;
float width; float width;
BScreen screen(this);
BRect r;
BRect s_frame = screen.Frame();
r = Frame(); BRect rect = Frame();
width = 80 * fApp->ContentFont().StringWidth("M") width = 80 * fApp->ContentFont().StringWidth("M")
+ (r.Width() - fContentView->fTextView->Bounds().Width() + 6); + (rect.Width() - fContentView->fTextView->Bounds().Width() + 6);
if (width > (s_frame.Width() - 8))
width = s_frame.Width() - 8; BScreen screen(this);
BRect screenFrame = screen.Frame();
if (width > (screenFrame.Width() - 8))
width = screenFrame.Width() - 8;
height = max_c(fContentView->fTextView->CountLines(), 20) height = max_c(fContentView->fTextView->CountLines(), 20)
* fContentView->fTextView->LineHeight(0) * fContentView->fTextView->LineHeight(0)
+ (r.Height() - fContentView->fTextView->Bounds().Height()); + (rect.Height() - fContentView->fTextView->Bounds().Height());
if (height > (s_frame.Height() - 29)) if (height > (screenFrame.Height() - 29))
height = s_frame.Height() - 29; height = screenFrame.Height() - 29;
r.right = r.left + width; rect.right = rect.left + width;
r.bottom = r.top + height; rect.bottom = rect.top + height;
if (abs((int)(Frame().Width() - r.Width())) < 5 if (abs((int)(Frame().Width() - rect.Width())) < 5
&& abs((int)(Frame().Height() - r.Height())) < 5) { && abs((int)(Frame().Height() - rect.Height())) < 5) {
r = fZoom; rect = fZoom;
} else { } else {
fZoom = Frame(); fZoom = Frame();
s_frame.InsetBy(6, 6); screenFrame.InsetBy(6, 6);
if (r.Width() > s_frame.Width()) if (rect.Width() > screenFrame.Width())
r.right = r.left + s_frame.Width(); rect.right = rect.left + screenFrame.Width();
if (r.Height() > s_frame.Height()) if (rect.Height() > screenFrame.Height())
r.bottom = r.top + s_frame.Height(); rect.bottom = rect.top + screenFrame.Height();
if (r.right > s_frame.right) if (rect.right > screenFrame.right) {
{ rect.left -= rect.right - screenFrame.right;
r.left -= r.right - s_frame.right; rect.right = screenFrame.right;
r.right = s_frame.right;
} }
if (r.bottom > s_frame.bottom) if (rect.bottom > screenFrame.bottom) {
{ rect.top -= rect.bottom - screenFrame.bottom;
r.top -= r.bottom - s_frame.bottom; rect.bottom = screenFrame.bottom;
r.bottom = s_frame.bottom;
} }
if (r.left < s_frame.left) if (rect.left < screenFrame.left) {
{ rect.right += screenFrame.left - rect.left;
r.right += s_frame.left - r.left; rect.left = screenFrame.left;
r.left = s_frame.left;
} }
if (r.top < s_frame.top) if (rect.top < screenFrame.top) {
{ rect.bottom += screenFrame.top - rect.top;
r.bottom += s_frame.top - r.top; rect.top = screenFrame.top;
r.top = s_frame.top;
} }
} }
ResizeTo(r.Width(), r.Height()); ResizeTo(rect.Width(), rect.Height());
MoveTo(r.LeftTop()); MoveTo(rect.LeftTop());
} }
@@ -1939,19 +1948,6 @@ TMailWindow::Forward(entry_ref *ref, TMailWindow *window,
} }
class HorizontalLine : public BView {
public:
HorizontalLine(BRect rect)
:
BView (rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW) {}
virtual void Draw(BRect rect)
{
FillRect(rect, B_SOLID_HIGH);
}
};
void void
TMailWindow::Print() TMailWindow::Print()
{ {
@@ -1989,8 +1985,7 @@ TMailWindow::Print()
add_header_field(fSubject); add_header_field(fSubject);
add_header_field(fTo); add_header_field(fTo);
if ((fHeaderView->fCc != NULL) if (fHeaderView->fCc != NULL && fHeaderView->fCc->TextLength() != 0)
&& (strcmp(fHeaderView->fCc->Text(),"") != 0))
add_header_field(fCc); add_header_field(fCc);
if (fHeaderView->fDate != NULL) if (fHeaderView->fDate != NULL)
@@ -2025,21 +2020,18 @@ TMailWindow::Print()
BPoint(0.0, curPageRect.bottom - ((curPage == 1) BPoint(0.0, curPageRect.bottom - ((curPage == 1)
? header_height : 0))); ? header_height : 0)));
float curPageHeight = fContentView->fTextView-> float curPageHeight = fContentView->fTextView->TextHeight(
TextHeight(fromLine, lastLine) + ((curPage == 1) fromLine, lastLine) + (curPage == 1 ? header_height : 0);
? header_height : 0);
if (curPageHeight > pageRect.Height()) { if (curPageHeight > pageRect.Height()) {
curPageHeight = fContentView->fTextView->TextHeight( curPageHeight = fContentView->fTextView->TextHeight(
fromLine, --lastLine) + ((curPage == 1) fromLine, --lastLine) + (curPage == 1 ? header_height : 0);
? header_height : 0);
} }
curPageRect.bottom = curPageRect.top + curPageHeight - 1.0; curPageRect.bottom = curPageRect.top + curPageHeight - 1.0;
if ((curPage >= print.FirstPage()) if (curPage >= print.FirstPage() && curPage <= print.LastPage()) {
&& (curPage <= print.LastPage())) {
print.DrawView(fContentView->fTextView, curPageRect, print.DrawView(fContentView->fTextView, curPageRect,
BPoint(0.0, (curPage == 1) ? header_height : 0.0)); BPoint(0.0, curPage == 1 ? header_height : 0.0));
print.SpoolPage(); print.SpoolPage();
} }
@@ -2529,7 +2521,8 @@ TMailWindow::Send(bool now)
if (result != B_NO_ERROR && result != B_MAIL_NO_DAEMON) { if (result != B_NO_ERROR && result != B_MAIL_NO_DAEMON) {
beep(); beep();
BAlert* alert = new BAlert("", errorMessage.String(), B_TRANSLATE("OK")); BAlert* alert = new BAlert("", errorMessage.String(),
B_TRANSLATE("OK"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(); alert->Go();
} }
@@ -2547,20 +2540,20 @@ TMailWindow::Send(bool now)
status_t status_t
TMailWindow::SaveAsDraft() TMailWindow::SaveAsDraft()
{ {
status_t status;
BPath draftPath; BPath draftPath;
BDirectory dir; BDirectory dir;
BFile draft; BFile draft;
uint32 flags = 0; uint32 flags = 0;
if (fDraft) { if (fDraft) {
if ((status = draft.SetTo(fRef, status_t status = draft.SetTo(fRef,
B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE)) != B_OK) { B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
if (status != B_OK)
return status; return status;
}
} else { } else {
// Get the user home directory // Get the user home directory
if ((status = find_directory(B_USER_DIRECTORY, &draftPath)) != B_OK) status_t status = find_directory(B_USER_DIRECTORY, &draftPath);
if (status != B_OK)
return status; return status;
// Append the relative path of the draft directory // Append the relative path of the draft directory
@@ -2589,11 +2582,17 @@ TMailWindow::SaveAsDraft()
// convert /, \ and : to - // convert /, \ and : to -
for (char* bad = fileName; (bad = strchr(bad, '/')) != NULL; for (char* bad = fileName; (bad = strchr(bad, '/')) != NULL;
++bad) *bad = '-'; ++bad) {
*bad = '-';
}
for (char* bad = fileName; (bad = strchr(bad, '\\')) != NULL; for (char* bad = fileName; (bad = strchr(bad, '\\')) != NULL;
++bad) *bad = '-'; ++bad) {
*bad = '-';
}
for (char* bad = fileName; (bad = strchr(bad, ':')) != NULL; for (char* bad = fileName; (bad = strchr(bad, ':')) != NULL;
++bad) *bad = '-'; ++bad) {
*bad = '-';
}
// Create the file; if the name exists, find a unique name // Create the file; if the name exists, find a unique name
flags = B_WRITE_ONLY | B_CREATE_FILE | B_FAIL_IF_EXISTS; flags = B_WRITE_ONLY | B_CREATE_FILE | B_FAIL_IF_EXISTS;
@@ -2627,9 +2626,7 @@ TMailWindow::SaveAsDraft()
draft.Write(fContentView->fTextView->Text(), draft.Write(fContentView->fTextView->Text(),
fContentView->fTextView->TextLength()); fContentView->fTextView->TextLength());
//
// Add the header stuff as attributes // Add the header stuff as attributes
//
WriteAttrString(&draft, B_MAIL_ATTR_NAME, fHeaderView->fTo->Text()); WriteAttrString(&draft, B_MAIL_ATTR_NAME, fHeaderView->fTo->Text());
WriteAttrString(&draft, B_MAIL_ATTR_TO, fHeaderView->fTo->Text()); WriteAttrString(&draft, B_MAIL_ATTR_TO, fHeaderView->fTo->Text());
WriteAttrString(&draft, B_MAIL_ATTR_SUBJECT, fHeaderView->fSubject->Text()); WriteAttrString(&draft, B_MAIL_ATTR_SUBJECT, fHeaderView->fSubject->Text());
@@ -2655,11 +2652,10 @@ TMailWindow::SaveAsDraft()
// Add Attachment paths in attribute // Add Attachment paths in attribute
if (fEnclosuresView != NULL) { if (fEnclosuresView != NULL) {
TListItem* item; TListItem* item;
BPath path;
BString pathStr; BString pathStr;
for (int32 i = 0; (item = (TListItem *) for (int32 i = 0; (item = (TListItem*)fEnclosuresView->fList->ItemAt(i))
fEnclosuresView->fList->ItemAt(i)) != NULL; i++) { != NULL; i++) {
if (i > 0) if (i > 0)
pathStr.Append(":"); pathStr.Append(":");
@@ -2667,6 +2663,7 @@ TMailWindow::SaveAsDraft()
if (!entry.Exists()) if (!entry.Exists())
continue; continue;
BPath path;
entry.GetPath(&path); entry.GetPath(&path);
pathStr.Append(path.Path()); pathStr.Append(path.Path());
} }
@@ -2688,10 +2685,9 @@ TMailWindow::SaveAsDraft()
status_t status_t
TMailWindow::TrainMessageAs(const char *CommandWord) TMailWindow::TrainMessageAs(const char* commandWord)
{ {
status_t errorCode = -1; status_t errorCode = -1;
char errorString[1500];
BEntry fileEntry; BEntry fileEntry;
BPath filePath; BPath filePath;
BMessage replyMessage; BMessage replyMessage;
@@ -2700,7 +2696,7 @@ TMailWindow::TrainMessageAs(const char *CommandWord)
if (fRef == NULL) if (fRef == NULL)
goto ErrorExit; // Need to have a real file and name. goto ErrorExit; // Need to have a real file and name.
errorCode = fileEntry.SetTo(fRef, true /* traverse */); errorCode = fileEntry.SetTo(fRef, true);
if (errorCode != B_OK) if (errorCode != B_OK)
goto ErrorExit; goto ErrorExit;
errorCode = fileEntry.GetPath(&filePath); errorCode = fileEntry.GetPath(&filePath);
@@ -2717,15 +2713,17 @@ TMailWindow::TrainMessageAs(const char *CommandWord)
if (errorCode != B_OK) { if (errorCode != B_OK) {
BPath path; BPath path;
entry_ref ref; entry_ref ref;
directory_which places[] directory_which places[] = {B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
= {B_SYSTEM_NONPACKAGED_BIN_DIRECTORY, B_SYSTEM_BIN_DIRECTORY}; B_SYSTEM_BIN_DIRECTORY};
for (int32 i = 0; i < 2; i++) { for (int32 i = 0; i < 2; i++) {
find_directory(places[i],&path); find_directory(places[i],&path);
path.Append("spamdbm"); path.Append("spamdbm");
if (!BEntry(path.Path()).Exists()) if (!BEntry(path.Path()).Exists())
continue; continue;
get_ref_for_path(path.Path(),&ref); get_ref_for_path(path.Path(),&ref);
if ((errorCode = be_roster->Launch (&ref)) == B_OK)
errorCode = be_roster->Launch(&ref);
if (errorCode == B_OK)
break; break;
} }
if (errorCode != B_OK) if (errorCode != B_OK)
@@ -2751,9 +2749,9 @@ TMailWindow::TrainMessageAs(const char *CommandWord)
scriptingMessage.MakeEmpty(); scriptingMessage.MakeEmpty();
scriptingMessage.what = B_SET_PROPERTY; scriptingMessage.what = B_SET_PROPERTY;
scriptingMessage.AddSpecifier(CommandWord); scriptingMessage.AddSpecifier(commandWord);
errorCode = scriptingMessage.AddData("data", B_STRING_TYPE, errorCode = scriptingMessage.AddData("data", B_STRING_TYPE,
filePath.Path(), strlen(filePath.Path()) + 1, false /* fixed size */); filePath.Path(), strlen(filePath.Path()) + 1, false);
if (errorCode != B_OK) if (errorCode != B_OK)
goto ErrorExit; goto ErrorExit;
replyMessage.MakeEmpty(); replyMessage.MakeEmpty();
@@ -2770,9 +2768,10 @@ TMailWindow::TrainMessageAs(const char *CommandWord)
ErrorExit: ErrorExit:
beep(); beep();
sprintf(errorString, "Unable to train the message file \"%s\" as %s. " char errorString[1500];
"Possibly useful error code: %s (%" B_PRId32 ").", snprintf(errorString, sizeof(errorString), "Unable to train the message "
filePath.Path(), CommandWord, strerror(errorCode), errorCode); "file \"%s\" as %s. Possibly useful error code: %s (%" B_PRId32 ").",
filePath.Path(), commandWord, strerror(errorCode), errorCode);
BAlert* alert = new BAlert("", errorString, B_TRANSLATE("OK")); BAlert* alert = new BAlert("", errorString, B_TRANSLATE("OK"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(); alert->Go();
@@ -2784,9 +2783,7 @@ ErrorExit:
void void
TMailWindow::SetTitleForMessage() TMailWindow::SetTitleForMessage()
{ {
//
// Figure out the title of this message and set the title bar // Figure out the title of this message and set the title bar
//
BString title = B_TRANSLATE_SYSTEM_NAME("Mail"); BString title = B_TRANSLATE_SYSTEM_NAME("Mail");
if (fIncoming) { if (fIncoming) {
@@ -2804,14 +2801,14 @@ TMailWindow::SetTitleForMessage()
char numberString[30]; char numberString[30];
BString oldTitle(title); BString oldTitle(title);
float spamRatio; float spamRatio;
if (node.InitCheck() != B_OK || node.ReadAttrString if (node.InitCheck() != B_OK || node.ReadAttrString(
("MAIL:classification", &classification) != B_OK) "MAIL:classification", &classification) != B_OK)
classification = "Unrated"; classification = "Unrated";
if (classification != "Spam" && classification != "Genuine") { if (classification != "Spam" && classification != "Genuine") {
// Uncertain, Unrated and other unknown classes, show the ratio. // Uncertain, Unrated and other unknown classes, show the ratio.
if (node.InitCheck() == B_OK && sizeof (spamRatio) == if (node.InitCheck() == B_OK && node.ReadAttr("MAIL:ratio_spam",
node.ReadAttr("MAIL:ratio_spam", B_FLOAT_TYPE, 0, B_FLOAT_TYPE, 0, &spamRatio, sizeof(spamRatio))
&spamRatio, sizeof (spamRatio))) { == sizeof(spamRatio)) {
sprintf(numberString, "%.4f", spamRatio); sprintf(numberString, "%.4f", spamRatio);
classification << " " << numberString; classification << " " << numberString;
} }
@@ -2824,20 +2821,17 @@ TMailWindow::SetTitleForMessage()
} }
// /*! Open *another* message in the existing mail window. Some code here is
// Open *another* message in the existing mail window. Some code here is duplicated from various constructors.
// duplicated from various constructors. TODO: The duplicated code should be moved to a private initializer method
// The duplicated code should be in a private initializer method -- axeld. */
//
status_t status_t
TMailWindow::OpenMessage(const entry_ref* ref, uint32 characterSetForDecoding) TMailWindow::OpenMessage(const entry_ref* ref, uint32 characterSetForDecoding)
{ {
if (ref == NULL) if (ref == NULL)
return B_ERROR; return B_ERROR;
//
// Set some references to the email file // Set some references to the email file
//
delete fRef; delete fRef;
fRef = new entry_ref(*ref); fRef = new entry_ref(*ref);
@@ -2908,7 +2902,7 @@ TMailWindow::OpenMessage(const entry_ref *ref, uint32 characterSetForDecoding)
entry_ref enc_ref; entry_ref enc_ref;
char* s = strtok((char*)string.String(), ":"); char* s = strtok((char*)string.String(), ":");
while (s) { while (s != NULL) {
BEntry entry(s, true); BEntry entry(s, true);
if (entry.Exists()) { if (entry.Exists()) {
entry.GetRef(&enc_ref); entry.GetRef(&enc_ref);
@@ -2942,9 +2936,7 @@ TMailWindow::OpenMessage(const entry_ref *ref, uint32 characterSetForDecoding)
SetTitleForMessage(); SetTitleForMessage();
if (fIncoming) { if (fIncoming) {
//
// Put the addresses in the 'Save Address' Menu // Put the addresses in the 'Save Address' Menu
//
BMenuItem* item; BMenuItem* item;
while ((item = fSaveAddrMenu->RemoveItem((int32)0)) != NULL) while ((item = fSaveAddrMenu->RemoveItem((int32)0)) != NULL)
delete item; delete item;
@@ -2984,9 +2976,7 @@ TMailWindow::OpenMessage(const entry_ref *ref, uint32 characterSetForDecoding)
free(address); free(address);
} }
//
// Clear out existing contents of text view. // Clear out existing contents of text view.
//
fContentView->fTextView->SetText("", (int32)0); fContentView->fTextView->SetText("", (int32)0);
fContentView->fTextView->LoadMessage(fMail, false, NULL); fContentView->fTextView->LoadMessage(fMail, false, NULL);
@@ -3010,39 +3000,6 @@ TMailWindow::FrontmostWindow()
} }
/*
// Copied from src/kits/tracker/FindPanel.cpp.
uint32
TMailWindow::InitialMode(const BNode *node)
{
if (!node || node->InitCheck() != B_OK)
return kByNameItem;
uint32 result;
if (node->ReadAttr(kAttrQueryInitialMode, B_INT32_TYPE, 0,
(int32 *)&result, sizeof(int32)) <= 0)
return kByNameItem;
return result;
}
// Copied from src/kits/tracker/FindPanel.cpp.
int32
TMailWindow::InitialAttrCount(const BNode *node)
{
if (!node || node->InitCheck() != B_OK)
return 1;
int32 result;
if (node->ReadAttr(kAttrQueryInitialNumAttrs, B_INT32_TYPE, 0,
&result, sizeof(int32)) <= 0)
return 1;
return result;
}*/
// #pragma mark - // #pragma mark -
+8 -5
View File
@@ -65,6 +65,7 @@ class BMenuBar;
class BMenuItem; class BMenuItem;
class Words; class Words;
class TMailWindow : public BWindow { class TMailWindow : public BWindow {
public: public:
TMailWindow(BRect frame, const char* title, TMailWindow(BRect frame, const char* title,
@@ -94,7 +95,7 @@ class TMailWindow : public BWindow {
void PrintSetup(); void PrintSetup();
void Reply(entry_ref*, TMailWindow*, uint32); void Reply(entry_ref*, TMailWindow*, uint32);
void CopyMessage(entry_ref* ref, TMailWindow* src); void CopyMessage(entry_ref* ref, TMailWindow* src);
status_t Send(bool); status_t Send(bool now);
status_t SaveAsDraft(); status_t SaveAsDraft();
status_t OpenMessage(const entry_ref* ref, status_t OpenMessage(const entry_ref* ref,
uint32 characterSetForDecoding uint32 characterSetForDecoding
@@ -134,6 +135,9 @@ class TMailWindow : public BWindow {
void _SetDownloading(bool downloading); void _SetDownloading(bool downloading);
static BBitmap* _RetrieveVectorIcon(int32 id);
private:
TMailApp* fApp; TMailApp* fApp;
BEmailMessage* fMail; BEmailMessage* fMail;
@@ -166,13 +170,12 @@ class TMailWindow : public BWindow {
BMenu* fQueryMenu; BMenu* fQueryMenu;
BMenu* fLeaveStatusMenu; BMenu* fLeaveStatusMenu;
static BBitmap* _RetrieveVectorIcon(int32 id);
struct BitmapItem { struct BitmapItem {
BBitmap* bm; BBitmap* bm;
int32 id; int32 id;
}; };
static BObjectList<BitmapItem> fBitmapCache; static BObjectList<BitmapItem> sBitmapCache;
static BLocker fBitmapCacheLock; static BLocker sBitmapCacheLock;
BToolBar* fToolBar; BToolBar* fToolBar;
@@ -213,5 +216,5 @@ class TMailWindow : public BWindow {
bool fDownloading; bool fDownloading;
}; };
#endif // _MAIL_WINDOW_H
#endif // _MAIL_WINDOW_H