first part of a big cleanup of the Mail code

* separated window, app and context menu code
* got rid of all the global variables (which were accessed completely without
  locking, and the code with regards to the preference window sill needs
  fixing)
* extracted some defines and helper functions to MailSupport.cpp, though I later
  saw Utilities.cpp...
* got rid of the FONT_SIZE define which was used in some (but not all) controls
  to override the system font size
* worked in Header.cpp to get the controls layout font sensitive with correct
  alignment too, some problems remain when resizing the window


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22122 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2007-08-30 19:32:38 +00:00
parent 74c17141dc
commit 7ebe0d01cf
21 changed files with 2381 additions and 1725 deletions

View File

@ -32,11 +32,6 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
//--------------------------------------------------------------------
//
// Content.cpp
//
//--------------------------------------------------------------------
#include <stdlib.h>
#include <string.h>
@ -72,7 +67,10 @@ All rights reserved.
#include <MDRLanguage.h>
#include "Mail.h"
#include "MailApp.h"
#include "MailSupport.h"
#include "MailWindow.h"
#include "Messages.h"
#include "Content.h"
#include "Utilities.h"
#include "FieldMsg.h"
@ -99,9 +97,6 @@ const rgb_color kQuoteColors[] =
};
const int32 kNumQuoteColors = 3;
extern bool header_flag;
extern bool gColoredQuotes;
void Unicode2UTF8(int32 c, char **out);
@ -573,15 +568,13 @@ TextRunArray::~TextRunArray()
// #pragma mark -
TContentView::TContentView(BRect rect, bool incoming, BEmailMessage *mail, BFont *font)
TContentView::TContentView(BRect rect, bool incoming, BEmailMessage *mail,
BFont* font, bool showHeader, bool coloredQuotes)
: BView(rect, "m_content", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
fFocus(false),
fIncoming(incoming)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BFont v_font = *be_plain_font;
v_font.SetSize(FONT_SIZE);
fOffset = 12;
BRect r(rect);
@ -593,7 +586,8 @@ TContentView::TContentView(BRect rect, bool incoming, BEmailMessage *mail, BFont
text.OffsetTo(0, 0);
text.InsetBy(5, 5);
fTextView = new TTextView(r, text, fIncoming, mail, this, font);
fTextView = new TTextView(r, text, fIncoming, mail, this, font,
showHeader, coloredQuotes);
BScrollView *scroll = new BScrollView("", fTextView, B_FOLLOW_ALL, 0, true, true);
AddChild(scroll);
}
@ -768,12 +762,6 @@ TContentView::Focus(bool focus)
void
TContentView::FrameResized(float /* width */, float /* height */)
{
BFont v_font = *be_plain_font;
v_font.SetSize(FONT_SIZE);
font_height fHeight;
v_font.GetHeight(&fHeight);
BRect r(fTextView->Bounds());
r.OffsetTo(0, 0);
r.InsetBy(5, 5);
@ -785,10 +773,12 @@ TContentView::FrameResized(float /* width */, float /* height */)
// #pragma mark -
TTextView::TTextView(BRect frame, BRect text, bool incoming, BEmailMessage *mail,
TContentView *view, BFont *font)
TTextView::TTextView(BRect frame, BRect text, bool incoming,
BEmailMessage *mail, TContentView *view, BFont *font,
bool showHeader, bool coloredQuotes)
: BTextView(frame, "", text, B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE),
fHeader(header_flag),
fHeader(showHeader),
fColoredQuotes(coloredQuotes),
fReady(false),
fYankBuffer(NULL),
fLastPosition(-1),
@ -2355,7 +2345,7 @@ TTextView::Reader::Insert(const char *line, int32 count, bool isHyperLink, bool
BFont font(fView->Font());
TextRunArray style(count / 8 + 8);
if (gColoredQuotes && !isHeader && !isHyperLink)
if (fView->fColoredQuotes && !isHeader && !isHyperLink)
FillInQuoteTextRuns(fView, line, count, font, &style.Array(), style.MaxEntries());
else {
text_run_array &array = style.Array();
@ -3067,7 +3057,7 @@ TTextView::AddQuote(int32 start, int32 finish)
free(text);
Delete();
if (gColoredQuotes) {
if (fColoredQuotes) {
const BFont *font = Font();
TextRunArray style(targetLength / 8 + 8);
@ -3144,7 +3134,7 @@ TTextView::RemoveQuote(int32 start, int32 finish)
if (removed) {
Delete();
if (gColoredQuotes) {
if (fColoredQuotes) {
const BFont *font = Font();
TextRunArray style(length / 8 + 8);

View File

@ -116,7 +116,8 @@ class TSavePanel;
class TContentView : public BView
{
public:
TContentView(BRect, bool incoming, BEmailMessage *mail, BFont *);
TContentView(BRect, bool incoming, BEmailMessage *mail, BFont*,
bool showHeader, bool coloredQuotes);
virtual void MessageReceived(BMessage *);
void FindString(const char *);
void Focus(bool);
@ -140,7 +141,8 @@ enum {
class TTextView : public BTextView
{
public:
TTextView(BRect, BRect, bool incoming, BEmailMessage *mail, TContentView *,BFont *);
TTextView(BRect, BRect, bool incoming, BEmailMessage *mail,
TContentView *, BFont *, bool showHeader, bool coloredQuotes);
~TTextView();
virtual void AttachedToWindow();
@ -175,6 +177,7 @@ class TTextView : public BTextView
const BFont *Font() const { return &fFont; }
bool fHeader;
bool fColoredQuotes;
bool fReady;
private:

View File

@ -39,7 +39,6 @@ All rights reserved.
// and the view containing the list and handling the messages (TEnclosuresView).
//--------------------------------------------------------------------
#include "Mail.h"
#include "Enclosures.h"
#include <Debug.h>
@ -48,6 +47,7 @@ All rights reserved.
#include <MenuItem.h>
#include <Alert.h>
#include <NodeMonitor.h>
#include <PopUpMenu.h>
#include <MailAttachment.h>
#include <MailMessage.h>
@ -58,9 +58,13 @@ All rights reserved.
#include <stdlib.h>
#include <string.h>
#include "MailApp.h"
#include "MailSupport.h"
#include "MailWindow.h"
#include "Messages.h"
//====================================================================
static const float kPlainFontSizeScale = 0.9;
static status_t
GetTrackerIcon(BMimeType &type, BBitmap *icon, icon_size iconSize)
@ -125,10 +129,10 @@ TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BFont font = *be_plain_font;
font.SetSize(FONT_SIZE);
font_height fHeight;
font.GetHeight(&fHeight);
BFont font(be_plain_font);
font.SetSize(font.Size() * kPlainFontSizeScale);
SetFont(&font);
fOffset = 12;
BRect r;
@ -166,16 +170,13 @@ TEnclosuresView::Draw(BRect where)
{
BView::Draw(where);
BFont font = *be_plain_font;
font.SetSize(FONT_SIZE);
SetFont(&font);
SetHighColor(0, 0, 0);
SetLowColor(ViewColor());
font_height fHeight;
font.GetHeight(&fHeight);
font_height fh;
GetFontHeight(&fh);
MovePenTo(ENCLOSE_TEXT_H, ENCLOSE_TEXT_V + fHeight.ascent);
MovePenTo(ENCLOSE_TEXT_H, ENCLOSE_TEXT_V + fh.ascent);
DrawString(ENCLOSE_TEXT);
}
@ -396,8 +397,8 @@ TListView::AttachedToWindow()
{
BListView::AttachedToWindow();
BFont font = *be_plain_font;
font.SetSize(FONT_SIZE);
BFont font(be_plain_font);
font.SetSize(font.Size() * kPlainFontSizeScale);
SetFont(&font);
}
@ -509,7 +510,7 @@ TListItem::DrawItem(BView *owner, BRect r, bool /* complete */)
owner->SetHighColor(0, 0, 0);
BFont font = *be_plain_font;
font.SetSize(FONT_SIZE);
font.SetSize(font.Size() * kPlainFontSizeScale);
owner->SetFont(&font);
owner->MovePenTo(r.left + 24, r.bottom - 4);

View File

@ -38,7 +38,9 @@ All rights reserved.
// ===========================================================================
#include "FindWindow.h"
#include "Mail.h"
#include "MailApp.h"
#include "MailWindow.h"
#include "Messages.h"
#include "AutoTextControl.h"
#include <TextView.h>

View File

@ -32,7 +32,10 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "Mail.h"
#include "MailApp.h"
#include "MailSupport.h"
#include "MailWindow.h"
#include "Messages.h"
#include "Header.h"
#include "Utilities.h"
#include "QueryMenu.h"
@ -46,6 +49,7 @@ All rights reserved.
#include <CharacterSet.h>
#include <CharacterSetRoster.h>
#include <E-mail.h>
#include <MenuBar.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
@ -69,13 +73,13 @@ All rights reserved.
using namespace BPrivate;
using std::map;
extern uint32 gDefaultChain;
const char* kDateLabel = "Date:";
const uint32 kMsgFrom = 'hFrm';
const uint32 kMsgEncoding = 'encd';
const uint32 kMsgAddressChosen = 'acsn';
static const float kTextControlDividerOffset = 0;
static const float kMenuFieldDividerOffset = 6;
class QPopupMenu : public QueryMenu {
public:
@ -116,21 +120,26 @@ mail_to_filter(const char* text, int32& length, const text_run_array*& runs)
}
static const float kPlainFontSizeScale = 0.9;
// #pragma mark - THeaderView
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
BEmailMessage *mail, bool resending, uint32 defaultCharacterSet)
BEmailMessage *mail, bool resending, uint32 defaultCharacterSet,
uint32 defaultChain)
: BBox(rect, "m_header", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW, B_NO_BORDER),
fAccountMenu(NULL),
fEncodingMenu(NULL),
fChain(gDefaultChain),
fChain(defaultChain),
fAccountTo(NULL),
fAccount(NULL),
fBcc(NULL),
fCc(NULL),
fSubject(NULL),
fTo(NULL),
fDateLabel(NULL),
fDate(NULL),
fIncoming(incoming),
fCharacterSetUserSees(defaultCharacterSet),
@ -143,13 +152,19 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
BMenuField* field;
BMessage* msg;
BFont font = *be_plain_font;
font.SetSize(FONT_SIZE);
SetFont(&font);
float x = font.StringWidth( /* The longest title string in the header area */
float x = StringWidth( /* The longest title string in the header area */
MDR_DIALECT_CHOICE ("Enclosures: ","添付ファイル:")) + 9;
float y = TO_FIELD_V;
float menuFieldHeight;
BMenuBar* dummy = new BMenuBar(BRect(0, 0, 100, 15), "Dummy");
AddChild(dummy);
float width;
dummy->GetPreferredSize(&width, &menuFieldHeight);
menuFieldHeight += floorf(be_plain_font->Size() / 1.15);
dummy->RemoveSelf();
delete dummy;
if (!fIncoming) {
InitEmailCompletion();
InitGroupCompletion();
@ -195,8 +210,8 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
item->SetMarked(true);
markedCharSet = true;
}
if (font.StringWidth(name.String()) > widestCharacterSet)
widestCharacterSet = font.StringWidth(name.String());
if (StringWidth(name.String()) > widestCharacterSet)
widestCharacterSet = StringWidth(name.String());
}
msg = new BMessage(kMsgEncoding);
@ -226,31 +241,34 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
if (fIncoming && !resending) {
// Set up the character set pop-up menu on the right of "To" box.
r.Set (windowRect.Width() - widestCharacterSet -
font.StringWidth (DECODING_TEXT) - 2 * SEPARATOR_MARGIN,
y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT + 2);
StringWidth (DECODING_TEXT) - 2 * SEPARATOR_MARGIN, y - 2,
windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight + 2);
field = new BMenuField (r, "decoding", DECODING_TEXT, fEncodingMenu,
true /* fixedSize */,
B_FOLLOW_TOP | B_FOLLOW_RIGHT,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
field->SetFont (&font);
field->SetDivider (font.StringWidth(DECODING_TEXT) + 5);
field->SetDivider(field->StringWidth(DECODING_TEXT) + 5);
AddChild(field);
r.Set(x - font.StringWidth(FROM_TEXT) - 11, y,
field->Frame().left - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT);
r.Set(SEPARATOR_MARGIN, y,
field->Frame().left - SEPARATOR_MARGIN, y + menuFieldHeight);
sprintf(string, FROM_TEXT);
} else {
r.Set(x - 11, y, windowRect.Width() - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT);
r.Set(x - 12, y, windowRect.Width() - SEPARATOR_MARGIN,
y + menuFieldHeight);
string[0] = 0;
}
y += FIELD_HEIGHT;
fTo = new TTextControl(r, string, new BMessage(TO_FIELD), fIncoming, resending,
B_FOLLOW_LEFT_RIGHT);
y += menuFieldHeight;
fTo = new TTextControl(r, string, new BMessage(TO_FIELD), fIncoming,
resending, B_FOLLOW_LEFT_RIGHT);
fTo->SetFilter(mail_to_filter);
if (!fIncoming || resending) {
fTo->SetChoiceList(&fEmailList);
fTo->SetAutoComplete(true);
} else {
fTo->SetDivider(x - 12 - SEPARATOR_MARGIN);
fTo->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
}
AddChild(fTo);
@ -259,11 +277,12 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
fTo->SetModificationMessage(msg);
if (!fIncoming || resending) {
r.right = r.left + 8;
r.left = r.right - be_plain_font->StringWidth(TO_TEXT) - 30;
r.right = r.left - 5;
r.left = r.right - be_plain_font->StringWidth(TO_TEXT) - 15;
r.top -= 1;
fToMenu = new QPopupMenu(TO_TEXT);
field = new BMenuField(r, "", "", fToMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field = new BMenuField(r, "", "", fToMenu,
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field->SetDivider(0.0);
field->SetEnabled(true);
AddChild(field);
@ -273,14 +292,13 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
if (!fIncoming || resending) {
// Put the character set box on the right of the From field.
r.Set(windowRect.Width() - widestCharacterSet -
font.StringWidth(ENCODING_TEXT) - 2 * SEPARATOR_MARGIN,
y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT + 2);
StringWidth(ENCODING_TEXT) - 2 * SEPARATOR_MARGIN,
y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight + 2);
field = new BMenuField (r, "encoding", ENCODING_TEXT, fEncodingMenu,
true /* fixedSize */,
B_FOLLOW_TOP | B_FOLLOW_LEFT,
B_FOLLOW_TOP | B_FOLLOW_RIGHT,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
field->SetFont(&font);
field->SetDivider(font.StringWidth(ENCODING_TEXT) + 5);
field->SetDivider(field->StringWidth(ENCODING_TEXT) + 5);
AddChild(field);
// And now the "from account" pop-up menu, on the left side, taking the
@ -303,7 +321,7 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
msg->AddInt32("id", chain->ID());
if (gDefaultChain == chain->ID()) {
if (defaultChain == chain->ID()) {
item->SetMarked(true);
marked = true;
}
@ -322,30 +340,36 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
fChain = ~0UL;
}
// default chain is invalid, set to marked
gDefaultChain = fChain;
// TODO: do this differently, no casting and knowledge
// of TMailApp here....
if (TMailApp* app = dynamic_cast<TMailApp*>(be_app))
app->SetDefaultChain(fChain);
}
}
r.Set(x - font.StringWidth(FROM_TEXT) - 11, y - 2,
field->Frame().left - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT + 2);
r.Set(SEPARATOR_MARGIN, y - 2,
field->Frame().left - SEPARATOR_MARGIN, y + menuFieldHeight + 2);
field = new BMenuField(r, "account", FROM_TEXT, fAccountMenu,
true /* fixedSize */,
B_FOLLOW_TOP | B_FOLLOW_LEFT,
B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
field->SetFont(&font);
field->SetDivider(font.StringWidth(FROM_TEXT) + 11);
AddChild(field);
field->SetDivider(x - 12 - SEPARATOR_MARGIN + kMenuFieldDividerOffset);
field->SetAlignment(B_ALIGN_RIGHT);
// field->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
y += FIELD_HEIGHT;
y += menuFieldHeight;
} else {
// To: account
bool account = count_pop_accounts() > 0;
r.Set(x - font.StringWidth(TO_TEXT) - 11, y,
windowRect.Width() - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT);
r.Set(SEPARATOR_MARGIN, y,
windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight);
if (account)
r.right -= SEPARATOR_MARGIN + ACCOUNT_FIELD_WIDTH;
fAccountTo = new TTextControl(r, TO_TEXT, NULL, fIncoming, false, B_FOLLOW_LEFT_RIGHT);
fAccountTo->SetEnabled(false);
fAccountTo->SetDivider(x - 12 - SEPARATOR_MARGIN);
fAccountTo->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
AddChild(fAccountTo);
if (account) {
@ -354,26 +378,27 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
fAccount->SetEnabled(false);
AddChild(fAccount);
}
y += FIELD_HEIGHT;
y += menuFieldHeight;
}
--y;
r.Set(x - font.StringWidth(SUBJECT_TEXT) - 11, y,
windowRect.Width() - SEPARATOR_MARGIN, y + TO_FIELD_HEIGHT);
y += FIELD_HEIGHT;
r.Set(SEPARATOR_MARGIN, y,
windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight);
y += menuFieldHeight;
fSubject = new TTextControl(r, SUBJECT_TEXT, new BMessage(SUBJECT_FIELD),
fIncoming, false, B_FOLLOW_LEFT_RIGHT);
AddChild(fSubject);
(msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_SUBJECT);
fSubject->SetModificationMessage(msg);
fSubject->SetDivider(x - 12 - SEPARATOR_MARGIN);
fSubject->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
if (fResending)
fSubject->SetEnabled(false);
--y;
if (!fIncoming) {
r.Set(x - 11, y, CC_FIELD_H + CC_FIELD_WIDTH, y + CC_FIELD_HEIGHT);
r.Set(x - 12, y, CC_FIELD_H + CC_FIELD_WIDTH, y + menuFieldHeight);
fCc = new TTextControl(r, "", new BMessage(CC_FIELD), fIncoming, false);
fCc->SetFilter(mail_to_filter);
fCc->SetChoiceList(&fEmailList);
@ -382,19 +407,20 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
(msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_CC);
fCc->SetModificationMessage(msg);
r.right = r.left + 9;
r.left = r.right - be_plain_font->StringWidth(CC_TEXT) - 30;
r.right = r.left - 5;
r.left = r.right - be_plain_font->StringWidth(CC_TEXT) - 15;
r.top -= 1;
fCcMenu = new QPopupMenu(CC_TEXT);
field = new BMenuField(r, "", "", fCcMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field = new BMenuField(r, "", "", fCcMenu,
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field->SetDivider(0.0);
field->SetEnabled(true);
AddChild(field);
r.Set(BCC_FIELD_H + be_plain_font->StringWidth(BCC_TEXT), y,
windowRect.Width() - SEPARATOR_MARGIN, y + BCC_FIELD_HEIGHT);
y += FIELD_HEIGHT;
windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight);
y += menuFieldHeight;
fBcc = new TTextControl(r, "", new BMessage(BCC_FIELD),
fIncoming, false, B_FOLLOW_LEFT_RIGHT);
fBcc->SetFilter(mail_to_filter);
@ -404,23 +430,31 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
(msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_BCC);
fBcc->SetModificationMessage(msg);
r.right = r.left + 9;
r.left = r.right - be_plain_font->StringWidth(BCC_TEXT) - 30;
r.right = r.left - 5;
r.left = r.right - be_plain_font->StringWidth(BCC_TEXT) - 15;
r.top -= 1;
fBccMenu = new QPopupMenu(BCC_TEXT);
field = new BMenuField(r, "", "", fBccMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field = new BMenuField(r, "", "", fBccMenu,
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field->SetDivider(0.0);
field->SetEnabled(true);
AddChild(field);
} else {
r.Set(x - font.StringWidth(kDateLabel) - 10, y + 4,
windowRect.Width(), y + TO_FIELD_HEIGHT + 1);
y += TO_FIELD_HEIGHT + 5;
y -= SEPARATOR_MARGIN;
r.Set(SEPARATOR_MARGIN, y, x - 12 - 1, y + menuFieldHeight + 1);
fDateLabel = new BStringView(r, "", kDateLabel);
fDateLabel->SetAlignment(B_ALIGN_RIGHT);
AddChild(fDateLabel);
fDateLabel->SetHighColor(0, 0, 0);
r.Set(r.right + 9, y, windowRect.Width() - SEPARATOR_MARGIN,
y + menuFieldHeight + 1);
fDate = new BStringView(r, "", "");
AddChild(fDate);
fDate->SetFont(&font);
fDate->SetHighColor(0, 0, 0);
y += menuFieldHeight + 5;
LoadMessage(mail);
}
ResizeTo(Bounds().Width(), y);
@ -656,7 +690,7 @@ THeaderView::LoadMessage(BEmailMessage *mail)
// Set the date on this message
const char *dateField = mail->Date();
char string[256];
sprintf(string, "%s %s", kDateLabel, dateField != NULL ? dateField : "Unknown");
sprintf(string, "%s", dateField != NULL ? dateField : "Unknown");
fDate->SetText(string);
// Set contents of header fields
@ -711,18 +745,11 @@ TTextControl::TTextControl(BRect rect, char *label, BMessage *msg,
void
TTextControl::AttachedToWindow()
{
BFont font = *be_plain_font;
BTextView *text;
SetHighColor(0, 0, 0);
// BTextControl::AttachedToWindow();
BComboBox::AttachedToWindow();
font.SetSize(FONT_SIZE);
SetFont(&font);
SetDivider(StringWidth(fLabel) + 6);
text = (BTextView *)ChildAt(0);
text->SetFont(&font);
SetDivider(Divider() + kTextControlDividerOffset);
}

View File

@ -56,8 +56,6 @@ All rights reserved.
#define TO_FIELD_V 7
#define TO_FIELD_WIDTH 270
#define FROM_FIELD_WIDTH 280
#define TO_FIELD_HEIGHT 16
#define FIELD_HEIGHT 24
#define ACCOUNT_TEXT "Account:"
#define ACCOUNT_FIELD_WIDTH 165
@ -91,7 +89,7 @@ class QPopupMenu;
class THeaderView : public BBox {
public:
THeaderView(BRect, BRect, bool incoming, BEmailMessage *mail,
bool resending, uint32 defaultCharacterSet);
bool resending, uint32 defaultCharacterSet, uint32 defaultChain);
virtual void MessageReceived(BMessage *);
virtual void AttachedToWindow(void);
@ -106,6 +104,7 @@ class THeaderView : public BBox {
TTextControl *fCc;
TTextControl *fSubject;
TTextControl *fTo;
BStringView *fDateLabel;
BStringView *fDate;
bool fIncoming;
uint32 fCharacterSetUserSees;

View File

@ -1,6 +1,7 @@
SubDir HAIKU_TOP src apps mail ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
if $(TARGET_PLATFORM) != haiku {
UsePublicHeaders mail ;
@ -20,7 +21,10 @@ Application Mail :
Enclosures.cpp
FindWindow.cpp
Header.cpp
Mail.cpp
MailApp.cpp
MailPopUpMenu.cpp
MailSupport.cpp
MailWindow.cpp
Prefs.cpp
QueryMenu.cpp
Signature.cpp
@ -35,3 +39,9 @@ LinkAgainst Mail : be tracker $(TARGET_LIBSTDC++) libmail.so libtextencoding.so
Package haiku-maildaemon-cvs :
Mail :
boot beos apps ;
if ( $(TARGET_PLATFORM) = libbe_test ) {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Mail
: tests!apps ;
}

View File

@ -1,348 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
//--------------------------------------------------------------------
//
// Mail.h
//
//--------------------------------------------------------------------
#ifndef _MAIL_H
#define _MAIL_H
#include <Application.h>
#include <Font.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MessageFilter.h>
#include <Point.h>
#include <PopUpMenu.h>
#include <Rect.h>
#include <Window.h>
#include <Entry.h>
#include <mail_encoding.h>
#define MAX_DICTIONARIES 8
#define TITLE_BAR_HEIGHT 25
#define WIND_WIDTH 457
#define WIND_HEIGHT 400
#define RIGHT_BOUNDARY 8191
#define SEPARATOR_MARGIN 7
#define FONT_SIZE 11.0
#define QUOTE "> "
enum MESSAGES {
REFS_RECEIVED = 64,
LIST_INVOKED,
WINDOW_CLOSED,
CHANGE_FONT,
RESET_BUTTONS,
PREFS_CHANGED,
CHARSET_CHOICE_MADE
};
enum TEXT {
SUBJECT_FIELD = REFS_RECEIVED + 64,
TO_FIELD,
ENCLOSE_FIELD,
CC_FIELD,
BCC_FIELD,
NAME_FIELD
};
enum MENUS {
/* app */
M_NEW = SUBJECT_FIELD + 64,
M_PREFS,
M_EDIT_SIGNATURE,
M_FONT,
M_STYLE,
M_SIZE,
M_BEGINNER,
M_EXPERT,
/* file */
M_REPLY,
M_REPLY_TO_SENDER,
M_REPLY_ALL,
M_FORWARD,
M_FORWARD_WITHOUT_ATTACHMENTS,
M_RESEND,
M_COPY_TO_NEW,
M_HEADER,
M_RAW,
M_SEND_NOW,
M_SAVE_AS_DRAFT,
M_SAVE,
M_PRINT_SETUP,
M_PRINT,
M_DELETE,
M_DELETE_PREV,
M_DELETE_NEXT,
M_CLOSE_READ,
M_CLOSE_SAVED,
M_CLOSE_SAME,
M_CLOSE_CUSTOM,
M_STATUS,
M_OPEN_MAIL_BOX,
M_OPEN_MAIL_FOLDER,
/* edit */
M_SELECT,
M_QUOTE,
M_REMOVE_QUOTE,
M_CHECK_SPELLING,
M_SIGNATURE,
M_RANDOM_SIG,
M_SIG_MENU,
M_FIND,
M_FIND_AGAIN,
/* encls */
M_ADD,
M_REMOVE,
M_OPEN,
M_COPY,
/* nav */
M_NEXTMSG,
M_PREVMSG,
M_SAVE_POSITION,
/* Spam GUI button and menu items. Order is important. */
M_SPAM_BUTTON,
M_TRAIN_SPAM_AND_DELETE,
M_TRAIN_SPAM,
M_UNTRAIN,
M_TRAIN_GENUINE,
M_REDO
};
enum USER_LEVEL {
L_BEGINNER = 0,
L_EXPERT
};
enum WINDOW_TYPES {
MAIL_WINDOW = 0,
PREFS_WINDOW,
SIG_WINDOW
};
class TMailWindow;
class THeaderView;
class TEnclosuresView;
class TContentView;
class TMenu;
class TPrefsWindow;
class TSignatureWindow;
class BMenuItem;
class BmapButton;
class BFile;
class BFilePanel;
class ButtonBar;
class BMenuBar;
class Words;
class BEmailMessage;
//====================================================================
class TMailApp : public BApplication {
public:
TMailApp();
~TMailApp();
virtual void AboutRequested();
virtual void ArgvReceived(int32, char **);
virtual void MessageReceived(BMessage *);
virtual bool QuitRequested();
virtual void ReadyToRun();
virtual void RefsReceived(BMessage *);
TMailWindow *FindWindow(const entry_ref &);
void FontChange();
TMailWindow *NewWindow(const entry_ref *rec = NULL, const char *to = NULL,
bool resend = false, BMessenger *messenger = NULL);
BFont fFont;
private:
void ClearPrintSettings();
void CheckForSpamFilterExistence();
status_t GetSettingsPath(BPath &path);
status_t LoadOldSettings();
status_t SaveSettings();
status_t LoadSettings();
BList fWindowList;
int32 fWindowCount;
TPrefsWindow *fPrefsWindow;
TSignatureWindow *fSigWindow;
uint8 fPreviousShowButtonBar;
};
//--------------------------------------------------------------------
class BMailMessage;
class TMailWindow : public BWindow {
public:
TMailWindow(BRect, const char *, const entry_ref *, const char *,
const BFont *font, bool, BMessenger *trackerMessenger);
virtual ~TMailWindow();
virtual void FrameResized(float width, float height);
virtual void MenusBeginning();
virtual void MessageReceived(BMessage*);
virtual bool QuitRequested();
virtual void Show();
virtual void Zoom(BPoint, float, float);
virtual void WindowActivated(bool state);
void SetTo(const char *mailTo, const char *subject, const char *ccTo = NULL,
const char *bccTo = NULL, const BString *body = NULL, BMessage *enclosures = NULL);
void AddSignature(BMailMessage *);
void Forward(entry_ref *, TMailWindow *, bool includeAttachments);
void Print();
void PrintSetup();
void Reply(entry_ref *, TMailWindow *, uint32);
void CopyMessage(entry_ref *ref, TMailWindow *src);
status_t Send(bool);
status_t SaveAsDraft( void );
status_t OpenMessage(entry_ref *ref, uint32 characterSetForDecoding = B_MAIL_NULL_CONVERSION);
status_t GetMailNodeRef(node_ref &nodeRef) const;
BEmailMessage *Mail() const { return fMail; }
bool GetTrackerWindowFile(entry_ref *, bool dir) const;
void SaveTrackerPosition(entry_ref *);
void SetOriginatingWindow(BWindow *window);
void SetCurrentMessageRead();
void SetTrackerSelectionToCurrent();
TMailWindow* FrontmostWindow();
void UpdateViews();
protected:
void SetTitleForMessage();
void AddEnclosure(BMessage *msg);
void BuildButtonBar();
status_t TrainMessageAs (const char *CommandWord);
private:
BEmailMessage *fMail;
entry_ref *fRef; // Reference to currently displayed file
int32 fFieldState;
BFilePanel *fPanel;
BMenuBar *fMenuBar;
BMenuItem *fAdd;
BMenuItem *fCut;
BMenuItem *fCopy;
BMenuItem *fHeader;
BMenuItem *fPaste;
BMenuItem *fPrint;
BMenuItem *fPrintSetup;
BMenuItem *fQuote;
BMenuItem *fRaw;
BMenuItem *fRemove;
BMenuItem *fRemoveQuote;
BMenuItem *fSendNow;
BMenuItem *fSendLater;
BMenuItem *fUndo;
BMenuItem *fRedo;
BMenuItem *fNextMsg;
BMenuItem *fPrevMsg;
BMenuItem *fDeleteNext;
BMenuItem *fSpelling;
BMenu *fSaveAddrMenu;
ButtonBar *fButtonBar;
BmapButton *fSendButton;
BmapButton *fSaveButton;
BmapButton *fPrintButton;
BmapButton *fSigButton;
BRect fZoom;
TContentView *fContentView;
THeaderView *fHeaderView;
TEnclosuresView *fEnclosuresView;
TMenu *fSignature;
BMessenger fTrackerMessenger;
// Talks to tracker window that this was launched from.
entry_ref fPrevRef, fNextRef;
bool fPrevTrackerPositionSaved : 1;
bool fNextTrackerPositionSaved : 1;
static BList sWindowList;
static BLocker sWindowListLock;
bool fSigAdded;
bool fIncoming;
bool fReplying;
bool fResending;
bool fSent;
bool fDraft;
bool fChanged;
char *fStartingText;
entry_ref fRepliedMail;
BMessenger *fOriginatingWindow;
};
class TMenu: public BPopUpMenu {
public:
TMenu(const char* name, const char* attribute, int32, bool popup = false,
bool addRandom = true);
~TMenu();
virtual BPoint ScreenLocation(void);
virtual void AttachedToWindow();
void BuildMenu();
private:
char* fAttribute;
bool fPopup, fAddRandom;
int32 fMessage;
};
//====================================================================
int32 header_len(BFile *);
extern Words *gWords[MAX_DICTIONARIES];
extern Words *gExactWords[MAX_DICTIONARIES];
extern int32 gUserDict;
extern BFile *gUserDictFile;
extern int32 gDictCount;
#endif // #ifndef _MAIL_H

1254
src/apps/mail/MailApp.cpp Normal file

File diff suppressed because it is too large Load Diff

137
src/apps/mail/MailApp.h Normal file
View File

@ -0,0 +1,137 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _MAIL_APP_H
#define _MAIL_APP_H
#include <Application.h>
#include <Entry.h>
#include <Font.h>
#include <List.h>
#include <String.h>
class BFile;
class BMessenger;
class TMailWindow;
class TPrefsWindow;
class TSignatureWindow;
class TMailApp : public BApplication {
public:
TMailApp();
virtual ~TMailApp();
virtual void AboutRequested();
virtual void ArgvReceived(int32, char**);
virtual void MessageReceived(BMessage*);
virtual bool QuitRequested();
virtual void ReadyToRun();
virtual void RefsReceived(BMessage*);
TMailWindow* FindWindow(const entry_ref&);
void FontChange();
TMailWindow* NewWindow(const entry_ref* rec = NULL,
const char* to = NULL, bool resend = false,
BMessenger* messenger = NULL);
void SetPrintSettings(const BMessage* settings);
bool HasPrintSettings();
BMessage PrintSettings();
void SetLastWindowFrame(BRect frame);
// TODO: move these into a MailSettings class
BString Signature();
BString ReplyPreamble();
bool WrapMode();
void SetShowHeader(bool show);
bool ShowHeader();
bool AttachAttributes();
bool ColoredQuotes();
uint8 ShowButtonBar();
bool WarnAboutUnencodableCharacters();
bool StartWithSpellCheckOn();
void SetDefaultChain(uint32 chain);
uint32 DefaultChain();
int32 UseAccountFrom();
uint32 MailCharacterSet();
bool ShowSpamGUI() const
{ return fShowSpamGUI; }
BFont ContentFont();
private:
void _ClearPrintSettings();
void _CheckForSpamFilterExistence();
status_t GetSettingsPath(BPath &path);
status_t LoadOldSettings();
status_t SaveSettings();
status_t LoadSettings();
BList fWindowList;
int32 fWindowCount;
TPrefsWindow* fPrefsWindow;
TSignatureWindow* fSigWindow;
uint8 fPreviousShowButtonBar;
BRect fMailWindowFrame;
BRect fLastMailWindowFrame;
BRect fSignatureWindowFrame;
BPoint fPrefsWindowPos;
BMessage* fPrintSettings;
bool fPrintHelpAndExit;
// TODO: these should go into a settings class
char* fSignature;
char* fReplyPreamble;
bool fWrapMode;
bool fShowHeader;
bool fAttachAttributes;
bool fColoredQuotes;
uint8 fShowButtonBar;
bool fWarnAboutUnencodableCharacters;
bool fStartWithSpellCheckOn;
bool fShowSpamGUI;
uint32 fDefaultChain;
int32 fUseAccountFrom;
uint32 fMailCharacterSet;
BFont fContentFont;
};
#endif // #ifndef _MAIL_H

View File

@ -0,0 +1,106 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "MailPopUpMenu.h"
#include <MenuItem.h>
#include <Message.h>
#include <malloc.h>
#include <string.h>
#include <MDRLanguage.h>
#include "MailSupport.h"
#include "Messages.h"
TMenu::TMenu(const char *name, const char *attribute, int32 message, bool popup,
bool addRandom)
: BPopUpMenu(name, false, false),
fPopup(popup),
fAddRandom(addRandom),
fMessage(message)
{
fAttribute = strdup(attribute);
BuildMenu();
}
TMenu::~TMenu()
{
free(fAttribute);
}
void
TMenu::AttachedToWindow()
{
BuildMenu();
BPopUpMenu::AttachedToWindow();
}
BPoint
TMenu::ScreenLocation(void)
{
if (fPopup)
return BPopUpMenu::ScreenLocation();
return BMenu::ScreenLocation();
}
void
TMenu::BuildMenu()
{
RemoveItems(0, CountItems(), true);
add_query_menu_items(this, fAttribute, fMessage, NULL, fPopup);
if (fAddRandom && CountItems() > 0) {
AddItem(new BSeparatorItem(), 0);
BMessage *msg = new BMessage(M_RANDOM_SIG);
if (!fPopup) {
AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Random","R) 自動決定"), msg,
'0'), 0);
} else {
AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Random","R) 自動決定"), msg),
0);
}
}
}

View File

@ -0,0 +1,60 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _MAIL_POPUPMENU_H
#define _MAIL_POPUPMENU_H
#include <PopUpMenu.h>
class TMenu: public BPopUpMenu {
public:
TMenu(const char* name, const char* attribute,
int32 message, bool popup = false,
bool addRandom = true);
virtual ~TMenu();
virtual BPoint ScreenLocation(void);
virtual void AttachedToWindow();
void BuildMenu();
private:
char* fAttribute;
bool fPopup;
bool fAddRandom;
int32 fMessage;
};
#endif // _MAIL_POPUPMENU_H

View File

@ -0,0 +1,173 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "MailSupport.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <Autolock.h>
#include <Clipboard.h>
#include <Debug.h>
#include <E-mail.h>
#include <InterfaceKit.h>
#include <Roster.h>
#include <Screen.h>
#include <StorageKit.h>
#include <String.h>
#include <TextView.h>
#include <UTF8.h>
#include <fs_index.h>
#include <fs_info.h>
#include <MailMessage.h>
#include <MailSettings.h>
#include <MailDaemon.h>
#include <mail_util.h>
#include <MDRLanguage.h>
#include <CharacterSetRoster.h>
#include "Utilities.h"
using namespace BPrivate ;
#ifdef HAIKU_TARGET_PLATFORM_BEOS
#include <netdb.h>
#endif
#include "Words.h"
// global variables
Words* gWords[MAX_DICTIONARIES];
Words* gExactWords[MAX_DICTIONARIES];
int32 gUserDict;
BFile* gUserDictFile;
int32 gDictCount = 0;
// int32 level = L_BEGINNER;
const char* kSpamServerSignature = "application/x-vnd.agmsmith.spamdbm";
const char* kDraftPath = "mail/draft";
const char* kDraftType = "text/x-vnd.Be-MailDraft";
const char* kMailFolder = "mail";
const char* kMailboxFolder = "mail/mailbox";
int32
header_len(BFile *file)
{
char *buffer;
int32 length;
int32 result = 0;
off_t size;
if (file->ReadAttr(B_MAIL_ATTR_HEADER, B_INT32_TYPE, 0, &result,
sizeof(int32)) != sizeof(int32)) {
file->GetSize(&size);
buffer = (char *)malloc(size);
if (buffer) {
file->Seek(0, 0);
if (file->Read(buffer, size) == size) {
while ((length = linelen(buffer + result, size - result, true)) > 2)
result += length;
result += length;
}
free(buffer);
file->WriteAttr(B_MAIL_ATTR_HEADER, B_INT32_TYPE, 0, &result, sizeof(int32));
}
}
return result;
}
int32
add_query_menu_items(BMenu* menu, const char* attribute, uint32 what,
const char* format, bool popup)
{
BVolume volume;
BVolumeRoster().GetBootVolume(&volume);
BQuery query;
query.SetVolume(&volume);
query.PushAttr(attribute);
query.PushString("*");
query.PushOp(B_EQ);
query.Fetch();
int32 index = 0;
BEntry entry;
while (query.GetNextEntry(&entry) == B_OK) {
BFile file(&entry, B_READ_ONLY);
if (file.InitCheck() == B_OK) {
BMessage* message = new BMessage(what);
entry_ref ref;
entry.GetRef(&ref);
message->AddRef("ref", &ref);
BString value;
if (file.ReadAttrString(attribute, &value) < B_OK)
continue;
message->AddString("attribute", value.String());
char name[256];
if (format != NULL)
snprintf(name, sizeof(name), format, value.String());
else
strlcpy(name, value.String(), sizeof(name));
if (index < 9 && !popup)
menu->AddItem(new BMenuItem(name, message, '1' + index));
else
menu->AddItem(new BMenuItem(name, message));
index++;
}
}
return index;
}

View File

@ -0,0 +1,84 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _MAIL_SUPPORT_H
#define _MAIL_SUPPORT_H
#include <SupportDefs.h>
#define MAX_DICTIONARIES 8
#define TITLE_BAR_HEIGHT 25
#define WIND_WIDTH 457
#define WIND_HEIGHT 400
#define RIGHT_BOUNDARY 8191
#define SEPARATOR_MARGIN 7
#define QUOTE "> "
enum USER_LEVEL {
L_BEGINNER = 0,
L_EXPERT
};
enum WINDOW_TYPES {
MAIL_WINDOW = 0,
PREFS_WINDOW,
SIG_WINDOW
};
class BFile;
class Words;
int32 header_len(BFile*);
int32 add_query_menu_items(BMenu* menu, const char* attribute, uint32 what,
const char* format, bool popup = false);
extern Words* gWords[MAX_DICTIONARIES];
extern Words* gExactWords[MAX_DICTIONARIES];
extern int32 gUserDict;
extern BFile* gUserDictFile;
extern int32 gDictCount;
extern const char* kSpamServerSignature;
extern const char* kDraftPath;
extern const char* kDraftType;
extern const char* kMailFolder;
extern const char* kMailboxFolder;
#endif // _MAIL_SUPPORT_H

File diff suppressed because it is too large Load Diff

188
src/apps/mail/MailWindow.h Normal file
View File

@ -0,0 +1,188 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _MAIL_WINDOW_H
#define _MAIL_WINDOW_H
#include <Entry.h>
#include <Font.h>
#include <List.h>
#include <Locker.h>
#include <Messenger.h>
#include <Window.h>
#include <mail_encoding.h>
class TContentView;
class TEnclosuresView;
class THeaderView;
class TMailApp;
class TMenu;
class TPrefsWindow;
class TSignatureWindow;
class BEmailMessage;
class BFile;
class BFilePanel;
class BMailMessage;
class BMenuBar;
class BMenuItem;
class BmapButton;
class ButtonBar;
class Words;
class TMailWindow : public BWindow {
public:
TMailWindow(BRect frame, const char* title,
TMailApp* app, const entry_ref* ref,
const char* to, const BFont *font,
bool resending,
BMessenger* trackerMessenger);
virtual ~TMailWindow();
virtual void FrameResized(float width, float height);
virtual void MenusBeginning();
virtual void MessageReceived(BMessage*);
virtual bool QuitRequested();
virtual void Show();
virtual void Zoom(BPoint, float, float);
virtual void WindowActivated(bool state);
void SetTo(const char* mailTo, const char* subject,
const char* ccTo = NULL,
const char* bccTo = NULL,
const BString* body = NULL,
BMessage* enclosures = NULL);
void AddSignature(BMailMessage*);
void Forward(entry_ref*, TMailWindow*,
bool includeAttachments);
void Print();
void PrintSetup();
void Reply(entry_ref*, TMailWindow*, uint32);
void CopyMessage(entry_ref* ref, TMailWindow* src);
status_t Send(bool);
status_t SaveAsDraft();
status_t OpenMessage(entry_ref* ref,
uint32 characterSetForDecoding
= B_MAIL_NULL_CONVERSION);
status_t GetMailNodeRef(node_ref &nodeRef) const;
BEmailMessage* Mail() const { return fMail; }
bool GetTrackerWindowFile(entry_ref*,
bool dir) const;
void SaveTrackerPosition(entry_ref*);
void SetOriginatingWindow(BWindow* window);
void SetCurrentMessageRead();
void SetTrackerSelectionToCurrent();
TMailWindow* FrontmostWindow();
void UpdateViews();
protected:
void SetTitleForMessage();
void AddEnclosure(BMessage* msg);
void BuildButtonBar();
status_t TrainMessageAs(const char* commandWord);
private:
TMailApp* fApp;
BEmailMessage* fMail;
entry_ref* fRef;
// Reference to currently displayed file
int32 fFieldState;
BFilePanel* fPanel;
BMenuBar* fMenuBar;
BMenuItem* fAdd;
BMenuItem* fCut;
BMenuItem* fCopy;
BMenuItem* fHeader;
BMenuItem* fPaste;
BMenuItem* fPrint;
BMenuItem* fPrintSetup;
BMenuItem* fQuote;
BMenuItem* fRaw;
BMenuItem* fRemove;
BMenuItem* fRemoveQuote;
BMenuItem* fSendNow;
BMenuItem* fSendLater;
BMenuItem* fUndo;
BMenuItem* fRedo;
BMenuItem* fNextMsg;
BMenuItem* fPrevMsg;
BMenuItem* fDeleteNext;
BMenuItem* fSpelling;
BMenu* fSaveAddrMenu;
ButtonBar* fButtonBar;
BmapButton* fSendButton;
BmapButton* fSaveButton;
BmapButton* fPrintButton;
BmapButton* fSigButton;
BRect fZoom;
TContentView* fContentView;
THeaderView* fHeaderView;
TEnclosuresView* fEnclosuresView;
TMenu* fSignature;
BMessenger fTrackerMessenger;
// Talks to tracker window that this was launched from.
BMessenger fMessengerToSpamServer;
entry_ref fPrevRef;
entry_ref fNextRef;
bool fPrevTrackerPositionSaved : 1;
bool fNextTrackerPositionSaved : 1;
entry_ref fOpenFolder;
bool fSigAdded : 1;
bool fIncoming : 1;
bool fReplying : 1;
bool fResending : 1;
bool fSent : 1;
bool fDraft : 1;
bool fChanged : 1;
static BList sWindowList;
static BLocker sWindowListLock;
char* fStartingText;
entry_ref fRepliedMail;
BMessenger* fOriginatingWindow;
};
#endif // _MAIL_WINDOW_H

120
src/apps/mail/Messages.h Normal file
View File

@ -0,0 +1,120 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _MESSAGES_H
#define _MESSAGES_H
enum MESSAGES {
REFS_RECEIVED = 64,
LIST_INVOKED,
WINDOW_CLOSED,
CHANGE_FONT,
RESET_BUTTONS,
PREFS_CHANGED,
CHARSET_CHOICE_MADE
};
enum TEXT {
SUBJECT_FIELD = REFS_RECEIVED + 64,
TO_FIELD,
ENCLOSE_FIELD,
CC_FIELD,
BCC_FIELD,
NAME_FIELD
};
enum MENUS {
/* app */
M_NEW = SUBJECT_FIELD + 64,
M_PREFS,
M_EDIT_SIGNATURE,
M_FONT,
M_STYLE,
M_SIZE,
M_BEGINNER,
M_EXPERT,
/* file */
M_REPLY,
M_REPLY_TO_SENDER,
M_REPLY_ALL,
M_FORWARD,
M_FORWARD_WITHOUT_ATTACHMENTS,
M_RESEND,
M_COPY_TO_NEW,
M_HEADER,
M_RAW,
M_SEND_NOW,
M_SAVE_AS_DRAFT,
M_SAVE,
M_PRINT_SETUP,
M_PRINT,
M_DELETE,
M_DELETE_PREV,
M_DELETE_NEXT,
M_CLOSE_READ,
M_CLOSE_SAVED,
M_CLOSE_SAME,
M_CLOSE_CUSTOM,
M_STATUS,
M_OPEN_MAIL_BOX,
M_OPEN_MAIL_FOLDER,
/* edit */
M_SELECT,
M_QUOTE,
M_REMOVE_QUOTE,
M_CHECK_SPELLING,
M_SIGNATURE,
M_RANDOM_SIG,
M_SIG_MENU,
M_FIND,
M_FIND_AGAIN,
/* encls */
M_ADD,
M_REMOVE,
M_OPEN,
M_COPY,
/* nav */
M_NEXTMSG,
M_PREVMSG,
M_SAVE_POSITION,
/* Spam GUI button and menu items. Order is important. */
M_SPAM_BUTTON,
M_TRAIN_SPAM_AND_DELETE,
M_TRAIN_SPAM,
M_UNTRAIN,
M_TRAIN_GENUINE,
M_REDO
};
#endif // _MESSAGES_H

View File

@ -32,11 +32,8 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
//--------------------------------------------------------------------
//
// Prefs.cpp
//
//--------------------------------------------------------------------
#include "Prefs.h"
#include <stdio.h>
#include <stdlib.h>
@ -56,8 +53,10 @@ All rights reserved.
using namespace BPrivate;
#include "Mail.h"
#include "Prefs.h"
#include "MailApp.h"
#include "MailSupport.h"
#include "MailWindow.h"
#include "Messages.h"
#define BUTTON_WIDTH 70
#define BUTTON_HEIGHT 20
@ -304,10 +303,9 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap,
TPrefsWindow::~TPrefsWindow()
{
prefs_window = Frame().LeftTop();
BMessage msg(WINDOW_CLOSED);
msg.AddInt32("kind", PREFS_WINDOW);
msg.AddPoint("window pos", Frame().LeftTop());
be_app->PostMessage(&msg);
}

View File

@ -31,25 +31,25 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
//--------------------------------------------------------------------
//
// Signature.cpp
//
//--------------------------------------------------------------------
#include "Signature.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Clipboard.h>
#include <InterfaceKit.h>
#include <StorageKit.h>
#include "Mail.h"
#include "Signature.h"
#include "MailApp.h"
#include "MailPopUpMenu.h"
#include "MailSupport.h"
#include "MailWindow.h"
#include "Messages.h"
#include <MDRLanguage.h>
extern BRect signature_window;
extern const char *kUndoStrings[];
extern const char *kRedoStrings[];
@ -114,7 +114,6 @@ TSignatureWindow::TSignatureWindow(BRect rect)
TSignatureWindow::~TSignatureWindow()
{
signature_window = Frame();
}
@ -245,6 +244,7 @@ TSignatureWindow::QuitRequested()
if (Clear()) {
BMessage msg(WINDOW_CLOSED);
msg.AddInt32("kind", SIG_WINDOW);
msg.AddRect("window frame", Frame());
be_app->PostMessage(&msg);
return true;

View File

@ -31,9 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "Mail.h"
#include "Status.h"
#include <Button.h>
@ -52,6 +49,10 @@ All rights reserved.
#include <stdlib.h>
#include <string.h>
#include "MailApp.h"
#include "MailWindow.h"
#include "Messages.h"
#define STATUS_TEXT "Status:"
#define STATUS_FIELD_H 10