* The Deskbar tray icon menu "Check Mail" and the status window "Check Now" button
are now only enabled if there are any inbound accounts. * BMailSettings::StatusWindowFrame() now returns some useful defaults. * Minor cleanup. * The MDR kit needs some serious overhaul before it can be part of R1. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21493 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4976138306
commit
ca13bd31a7
@ -1,15 +1,18 @@
|
||||
/*
|
||||
* Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2004-2007, Haiku Inc. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef ZOIDBERG_STATUS_WINDOW_H
|
||||
#define ZOIDBERG_STATUS_WINDOW_H
|
||||
/* StatusWindow - the status window while fetching/sending mails
|
||||
**
|
||||
** Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
#include <Alert.h>
|
||||
#include <Box.h>
|
||||
#include <List.h>
|
||||
#include <Alert.h>
|
||||
#include <Node.h>
|
||||
#include <Window.h>
|
||||
|
||||
class BStatusBar;
|
||||
class BStringView;
|
||||
@ -17,7 +20,7 @@ class BMailStatusView;
|
||||
|
||||
class BMailStatusWindow : public BWindow {
|
||||
public:
|
||||
BMailStatusWindow(BRect rect, const char *name, uint32 show_when);
|
||||
BMailStatusWindow(BRect rect, const char *name, uint32 showMode);
|
||||
~BMailStatusWindow();
|
||||
|
||||
virtual void FrameMoved(BPoint origin);
|
||||
@ -35,9 +38,12 @@ class BMailStatusWindow : public BWindow {
|
||||
private:
|
||||
friend class BMailStatusView;
|
||||
|
||||
void _CheckChains();
|
||||
void SetBorderStyle(int32 look);
|
||||
void ActuallyAddStatusView(BMailStatusView *status);
|
||||
|
||||
node_ref fChainDirectory;
|
||||
BButton* fCheckNowButton;
|
||||
BList fStatusViews;
|
||||
uint32 fShowMode;
|
||||
BView *fDefaultView;
|
||||
|
@ -1,8 +1,14 @@
|
||||
/* BMailSettings - the mail daemon's settings
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
/*
|
||||
* Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2004-2007, Haiku Inc. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//! The mail daemon's settings
|
||||
|
||||
|
||||
#include <MailSettings.h>
|
||||
|
||||
#include <Message.h>
|
||||
#include <FindDirectory.h>
|
||||
@ -17,103 +23,22 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
class BMailSettings;
|
||||
|
||||
namespace MailInternal {
|
||||
status_t WriteMessageFile(const BMessage& archive, const BPath& path, const char* name);
|
||||
}
|
||||
|
||||
#include <MailSettings.h>
|
||||
|
||||
BMailSettings::BMailSettings()
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
|
||||
BMailSettings::~BMailSettings()
|
||||
{
|
||||
}
|
||||
|
||||
status_t BMailSettings::InitCheck() const
|
||||
{
|
||||
return B_OK;
|
||||
status_t WriteMessageFile(const BMessage& archive, const BPath& path,
|
||||
const char* name);
|
||||
}
|
||||
|
||||
|
||||
status_t BMailSettings::Save(bigtime_t /*timeout*/)
|
||||
{
|
||||
status_t ret;
|
||||
//
|
||||
// Find chain-saving directory
|
||||
//
|
||||
|
||||
BPath path;
|
||||
ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (ret != B_OK)
|
||||
{
|
||||
fprintf(stderr, "Couldn't find user settings directory: %s\n",
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
path.Append("Mail");
|
||||
|
||||
status_t result = MailInternal::WriteMessageFile(data,path,"new_mail_daemon");
|
||||
if (result < B_OK)
|
||||
return result;
|
||||
|
||||
BMessenger("application/x-vnd.Be-POST").SendMessage('mrrs');
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t BMailSettings::Reload()
|
||||
{
|
||||
status_t ret;
|
||||
|
||||
BPath path;
|
||||
ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (ret != B_OK)
|
||||
{
|
||||
fprintf(stderr, "Couldn't find user settings directory: %s\n",
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
path.Append("Mail/new_mail_daemon");
|
||||
|
||||
// open
|
||||
BFile settings(path.Path(),B_READ_ONLY);
|
||||
ret = settings.InitCheck();
|
||||
if (ret != B_OK)
|
||||
{
|
||||
fprintf(stderr, "Couldn't open settings file '%s': %s\n",
|
||||
path.Path(), strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// read settings
|
||||
BMessage tmp;
|
||||
ret = tmp.Unflatten(&settings);
|
||||
if (ret != B_OK)
|
||||
{
|
||||
fprintf(stderr, "Couldn't read settings from '%s': %s\n",
|
||||
path.Path(), strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// clobber old settings
|
||||
data = tmp;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// Chain methods
|
||||
// #pragma mark - Chain methods
|
||||
|
||||
//
|
||||
// To do
|
||||
//
|
||||
_EXPORT BMailChain* NewMailChain()
|
||||
BMailChain*
|
||||
NewMailChain()
|
||||
{
|
||||
// attempted solution: use time(NULL) and hope it's unique. Is there a better idea?
|
||||
// note that two chains in two second is quite possible. how to fix this?
|
||||
@ -141,41 +66,38 @@ _EXPORT BMailChain* NewMailChain()
|
||||
id++;
|
||||
string_id = "";
|
||||
string_id << id;
|
||||
} while ((outbound_dir.Contains(string_id.String())) || (inbound_dir.Contains(string_id.String())));
|
||||
|
||||
} while ((outbound_dir.Contains(string_id.String()))
|
||||
|| (inbound_dir.Contains(string_id.String())));
|
||||
|
||||
chain_dir.WriteAttr("last_issued_chain_id",B_INT32_TYPE,0,&id,sizeof(id));
|
||||
|
||||
return new BMailChain(id);
|
||||
}
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
_EXPORT BMailChain* GetMailChain(uint32 id)
|
||||
|
||||
BMailChain*
|
||||
GetMailChain(uint32 id)
|
||||
{
|
||||
return new BMailChain(id);
|
||||
}
|
||||
|
||||
_EXPORT status_t GetInboundMailChains(BList *list)
|
||||
|
||||
status_t
|
||||
GetInboundMailChains(BList *list)
|
||||
{
|
||||
BPath path;
|
||||
status_t ret = B_OK;
|
||||
|
||||
ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (ret != B_OK)
|
||||
{
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr, "Couldn't find user settings directory: %s\n",
|
||||
strerror(ret));
|
||||
return ret;
|
||||
strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
path.Append("Mail/chains/inbound");
|
||||
BDirectory chain_dir(path.Path());
|
||||
BDirectory chainDirectory(path.Path());
|
||||
entry_ref ref;
|
||||
|
||||
while (chain_dir.GetNextRef(&ref)==B_OK)
|
||||
{
|
||||
while (chainDirectory.GetNextRef(&ref) == B_OK) {
|
||||
char *end;
|
||||
uint32 id = strtoul(ref.name, &end, 10);
|
||||
|
||||
@ -183,94 +105,215 @@ _EXPORT status_t GetInboundMailChains(BList *list)
|
||||
list->AddItem((void*)new BMailChain(id));
|
||||
}
|
||||
|
||||
return ret;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
_EXPORT status_t GetOutboundMailChains(BList *list)
|
||||
|
||||
status_t
|
||||
GetOutboundMailChains(BList *list)
|
||||
{
|
||||
BPath path;
|
||||
status_t ret = B_OK;
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr, "Couldn't find user settings directory: %s\n",
|
||||
strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (ret != B_OK)
|
||||
path.Append("Mail/chains/outbound");
|
||||
BDirectory chainDirectory(path.Path());
|
||||
entry_ref ref;
|
||||
|
||||
while (chainDirectory.GetNextRef(&ref) == B_OK) {
|
||||
char *end;
|
||||
uint32 id = strtoul(ref.name, &end, 10);
|
||||
if (!end || *end == '\0')
|
||||
list->AddItem((void*)new BMailChain(id));
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BMailSettings
|
||||
|
||||
|
||||
BMailSettings::BMailSettings()
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
|
||||
|
||||
BMailSettings::~BMailSettings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMailSettings::InitCheck() const
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMailSettings::Save(bigtime_t /*timeout*/)
|
||||
{
|
||||
status_t ret;
|
||||
//
|
||||
// Find chain-saving directory
|
||||
//
|
||||
|
||||
BPath path;
|
||||
ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (ret != B_OK) {
|
||||
fprintf(stderr, "Couldn't find user settings directory: %s\n",
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
path.Append("Mail/chains/outbound");
|
||||
BDirectory chain_dir(path.Path());
|
||||
entry_ref ref;
|
||||
path.Append("Mail");
|
||||
|
||||
while (chain_dir.GetNextRef(&ref)==B_OK)
|
||||
{
|
||||
char *end;
|
||||
uint32 id = strtoul(ref.name, &end, 10);
|
||||
if (!end || *end == '\0')
|
||||
list->AddItem((void*)new BMailChain(id));
|
||||
status_t result = MailInternal::WriteMessageFile(data,path,"new_mail_daemon");
|
||||
if (result < B_OK)
|
||||
return result;
|
||||
|
||||
BMessenger("application/x-vnd.Be-POST").SendMessage('mrrs');
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMailSettings::Reload()
|
||||
{
|
||||
status_t ret;
|
||||
|
||||
BPath path;
|
||||
ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (ret != B_OK) {
|
||||
fprintf(stderr, "Couldn't find user settings directory: %s\n",
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
path.Append("Mail/new_mail_daemon");
|
||||
|
||||
// Global settings
|
||||
int32 BMailSettings::WindowFollowsCorner()
|
||||
// open
|
||||
BFile settings(path.Path(),B_READ_ONLY);
|
||||
ret = settings.InitCheck();
|
||||
if (ret != B_OK) {
|
||||
fprintf(stderr, "Couldn't open settings file '%s': %s\n",
|
||||
path.Path(), strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// read settings
|
||||
BMessage tmp;
|
||||
ret = tmp.Unflatten(&settings);
|
||||
if (ret != B_OK) {
|
||||
fprintf(stderr, "Couldn't read settings from '%s': %s\n",
|
||||
path.Path(), strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// clobber old settings
|
||||
data = tmp;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// # pragma mark - Global settings
|
||||
|
||||
|
||||
int32
|
||||
BMailSettings::WindowFollowsCorner()
|
||||
{
|
||||
return data.FindInt32("WindowFollowsCorner");
|
||||
}
|
||||
void BMailSettings::SetWindowFollowsCorner(int32 which_corner)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetWindowFollowsCorner(int32 which_corner)
|
||||
{
|
||||
if (data.ReplaceInt32("WindowFollowsCorner",which_corner))
|
||||
data.AddInt32("WindowFollowsCorner",which_corner);
|
||||
}
|
||||
|
||||
uint32 BMailSettings::ShowStatusWindow()
|
||||
|
||||
uint32
|
||||
BMailSettings::ShowStatusWindow()
|
||||
{
|
||||
return data.FindInt32("ShowStatusWindow");
|
||||
}
|
||||
void BMailSettings::SetShowStatusWindow(uint32 mode)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetShowStatusWindow(uint32 mode)
|
||||
{
|
||||
if (data.ReplaceInt32("ShowStatusWindow",mode))
|
||||
data.AddInt32("ShowStatusWindow",mode);
|
||||
}
|
||||
|
||||
bool BMailSettings::DaemonAutoStarts()
|
||||
|
||||
bool
|
||||
BMailSettings::DaemonAutoStarts()
|
||||
{
|
||||
return data.FindBool("DaemonAutoStarts");
|
||||
}
|
||||
void BMailSettings::SetDaemonAutoStarts(bool does_it)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetDaemonAutoStarts(bool does_it)
|
||||
{
|
||||
if (data.ReplaceBool("DaemonAutoStarts",does_it))
|
||||
data.AddBool("DaemonAutoStarts",does_it);
|
||||
}
|
||||
|
||||
BRect BMailSettings::ConfigWindowFrame()
|
||||
|
||||
BRect
|
||||
BMailSettings::ConfigWindowFrame()
|
||||
{
|
||||
return data.FindRect("ConfigWindowFrame");
|
||||
}
|
||||
void BMailSettings::SetConfigWindowFrame(BRect frame)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetConfigWindowFrame(BRect frame)
|
||||
{
|
||||
if (data.ReplaceRect("ConfigWindowFrame",frame))
|
||||
data.AddRect("ConfigWindowFrame",frame);
|
||||
}
|
||||
|
||||
BRect BMailSettings::StatusWindowFrame()
|
||||
|
||||
BRect
|
||||
BMailSettings::StatusWindowFrame()
|
||||
{
|
||||
return data.FindRect("StatusWindowFrame");
|
||||
BRect frame;
|
||||
if (data.FindRect("StatusWindowFrame", &frame) != B_OK)
|
||||
return BRect(100, 100, 200, 120);
|
||||
|
||||
return frame;
|
||||
}
|
||||
void BMailSettings::SetStatusWindowFrame(BRect frame)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetStatusWindowFrame(BRect frame)
|
||||
{
|
||||
if (data.ReplaceRect("StatusWindowFrame",frame))
|
||||
data.AddRect("StatusWindowFrame",frame);
|
||||
}
|
||||
|
||||
int32 BMailSettings::StatusWindowWorkspaces()
|
||||
|
||||
int32
|
||||
BMailSettings::StatusWindowWorkspaces()
|
||||
{
|
||||
return data.FindInt32("StatusWindowWorkSpace");
|
||||
}
|
||||
void BMailSettings::SetStatusWindowWorkspaces(int32 workspace)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetStatusWindowWorkspaces(int32 workspace)
|
||||
{
|
||||
if (data.ReplaceInt32("StatusWindowWorkSpace",workspace))
|
||||
data.AddInt32("StatusWindowWorkSpace",workspace);
|
||||
@ -280,11 +323,16 @@ void BMailSettings::SetStatusWindowWorkspaces(int32 workspace)
|
||||
BMessenger("application/x-vnd.Be-POST").SendMessage(&msg);
|
||||
}
|
||||
|
||||
int32 BMailSettings::StatusWindowLook()
|
||||
|
||||
int32
|
||||
BMailSettings::StatusWindowLook()
|
||||
{
|
||||
return data.FindInt32("StatusWindowLook");
|
||||
}
|
||||
void BMailSettings::SetStatusWindowLook(int32 look)
|
||||
|
||||
|
||||
void
|
||||
BMailSettings::SetStatusWindowLook(int32 look)
|
||||
{
|
||||
if (data.ReplaceInt32("StatusWindowLook",look))
|
||||
data.AddInt32("StatusWindowLook",look);
|
||||
@ -294,40 +342,64 @@ void BMailSettings::SetStatusWindowLook(int32 look)
|
||||
BMessenger("application/x-vnd.Be-POST").SendMessage(&msg);
|
||||
}
|
||||
|
||||
bigtime_t BMailSettings::AutoCheckInterval() {
|
||||
|
||||
bigtime_t
|
||||
BMailSettings::AutoCheckInterval()
|
||||
{
|
||||
bigtime_t value = B_INFINITE_TIMEOUT;
|
||||
data.FindInt64("AutoCheckInterval",&value);
|
||||
return value;
|
||||
}
|
||||
|
||||
void BMailSettings::SetAutoCheckInterval(bigtime_t interval) {
|
||||
|
||||
void
|
||||
BMailSettings::SetAutoCheckInterval(bigtime_t interval)
|
||||
{
|
||||
if (data.ReplaceInt64("AutoCheckInterval",interval))
|
||||
data.AddInt64("AutoCheckInterval",interval);
|
||||
}
|
||||
|
||||
bool BMailSettings::CheckOnlyIfPPPUp() {
|
||||
|
||||
bool
|
||||
BMailSettings::CheckOnlyIfPPPUp()
|
||||
{
|
||||
return data.FindBool("CheckOnlyIfPPPUp");
|
||||
}
|
||||
|
||||
void BMailSettings::SetCheckOnlyIfPPPUp(bool yes) {
|
||||
|
||||
void
|
||||
BMailSettings::SetCheckOnlyIfPPPUp(bool yes)
|
||||
{
|
||||
if (data.ReplaceBool("CheckOnlyIfPPPUp",yes))
|
||||
data.AddBool("CheckOnlyIfPPPUp",yes);
|
||||
}
|
||||
|
||||
bool BMailSettings::SendOnlyIfPPPUp() {
|
||||
|
||||
bool
|
||||
BMailSettings::SendOnlyIfPPPUp()
|
||||
{
|
||||
return data.FindBool("SendOnlyIfPPPUp");
|
||||
}
|
||||
|
||||
void BMailSettings::SetSendOnlyIfPPPUp(bool yes) {
|
||||
|
||||
void
|
||||
BMailSettings::SetSendOnlyIfPPPUp(bool yes)
|
||||
{
|
||||
if (data.ReplaceBool("SendOnlyIfPPPUp",yes))
|
||||
data.AddBool("SendOnlyIfPPPUp",yes);
|
||||
}
|
||||
|
||||
uint32 BMailSettings::DefaultOutboundChainID() {
|
||||
|
||||
uint32
|
||||
BMailSettings::DefaultOutboundChainID()
|
||||
{
|
||||
return data.FindInt32("DefaultOutboundChainID");
|
||||
}
|
||||
|
||||
void BMailSettings::SetDefaultOutboundChainID(uint32 to) {
|
||||
|
||||
void
|
||||
BMailSettings::SetDefaultOutboundChainID(uint32 to)
|
||||
{
|
||||
if (data.ReplaceInt32("DefaultOutboundChainID",to))
|
||||
data.AddInt32("DefaultOutboundChainID",to);
|
||||
}
|
||||
|
@ -1,58 +1,58 @@
|
||||
/* BMailStatusWindow - the status window while fetching/sending mails
|
||||
**
|
||||
** Copyright (c) 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
/*
|
||||
* Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2004-2007, Haiku Inc. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//! The status window while fetching/sending mails
|
||||
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <StringView.h>
|
||||
#include <Screen.h>
|
||||
#include <String.h>
|
||||
#include <StatusBar.h>
|
||||
#include <Roster.h>
|
||||
#include <Locker.h>
|
||||
#include <E-mail.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
class _EXPORT BMailStatusWindow;
|
||||
class _EXPORT BMailStatusView;
|
||||
|
||||
#include "status.h"
|
||||
#include "MailSettings.h"
|
||||
|
||||
#include <MDRLanguage.h>
|
||||
|
||||
/*------------------------------------------------
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Directory.h>
|
||||
#include <E-mail.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Locker.h>
|
||||
#include <NodeMonitor.h>
|
||||
#include <Path.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <StatusBar.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
|
||||
BMailStatusWindow
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
------------------------------------------------*/
|
||||
|
||||
static BLocker sLock;
|
||||
|
||||
|
||||
BMailStatusWindow::BMailStatusWindow(BRect rect, const char *name, uint32 s)
|
||||
BMailStatusWindow::BMailStatusWindow(BRect rect, const char *name, uint32 showMode)
|
||||
: BWindow(rect, name, B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_CLOSABLE | B_NO_WORKSPACE_ACTIVATION | B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE),
|
||||
fShowMode(s),
|
||||
B_NOT_CLOSABLE | B_NO_WORKSPACE_ACTIVATION | B_NOT_V_RESIZABLE
|
||||
| B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE),
|
||||
fShowMode(showMode),
|
||||
fWindowMoved(0L)
|
||||
{
|
||||
BRect frame(Bounds());
|
||||
frame.InsetBy(90.0 + 5.0, 5.0);
|
||||
|
||||
BButton *button = new BButton(frame, "check_mail",
|
||||
fCheckNowButton = new BButton(frame, "check_mail",
|
||||
MDR_DIALECT_CHOICE ("Check Mail Now","メールチェック"),
|
||||
new BMessage('mbth'), B_FOLLOW_LEFT_RIGHT,
|
||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE);
|
||||
button->ResizeToPreferred();
|
||||
frame = button->Frame();
|
||||
fCheckNowButton->ResizeToPreferred();
|
||||
frame = fCheckNowButton->Frame();
|
||||
|
||||
button->ResizeTo(button->Bounds().Width(),25);
|
||||
button->SetTarget(be_app_messenger);
|
||||
fCheckNowButton->SetTarget(be_app_messenger);
|
||||
|
||||
frame.OffsetBy(0.0, frame.Height());
|
||||
frame.InsetBy(-90.0, 0.0);
|
||||
@ -69,11 +69,11 @@ BMailStatusWindow::BMailStatusWindow(BRect rect, const char *name, uint32 s)
|
||||
frame.InsetBy(-5.0, -5.0);
|
||||
frame.top = 0.0;
|
||||
|
||||
fDefaultView = new BBox(frame, "default_view", B_FOLLOW_LEFT_RIGHT,
|
||||
B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
||||
fDefaultView = new BView(frame, "default_view", B_FOLLOW_LEFT_RIGHT,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP);
|
||||
fDefaultView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
fDefaultView->AddChild(button);
|
||||
fDefaultView->AddChild(fCheckNowButton);
|
||||
fDefaultView->AddChild(fMessageView);
|
||||
|
||||
fMinWidth = fDefaultView->Bounds().Width();
|
||||
@ -95,7 +95,7 @@ BMailStatusWindow::BMailStatusWindow(BRect rect, const char *name, uint32 s)
|
||||
|
||||
ResizeBy(x_off_set, y_off_set);
|
||||
fDefaultView->ResizeBy(x_off_set, y_off_set);
|
||||
button->ResizeBy(x_off_set, y_off_set);
|
||||
fCheckNowButton->ResizeBy(x_off_set, y_off_set);
|
||||
fMessageView->ResizeBy(x_off_set, y_off_set);
|
||||
}
|
||||
}
|
||||
@ -115,8 +115,22 @@ BMailStatusWindow::BMailStatusWindow(BRect rect, const char *name, uint32 s)
|
||||
|
||||
fFrame = Frame();
|
||||
|
||||
BPath path;
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status == B_OK) {
|
||||
path.Append("Mail/chains/inbound");
|
||||
create_directory(path.Path(), 0755);
|
||||
BDirectory chainDirectory(path.Path());
|
||||
if (chainDirectory.GetNodeRef(&fChainDirectory) == B_OK) {
|
||||
// Watch this directory for changes
|
||||
watch_node(&fChainDirectory, B_WATCH_DIRECTORY, this);
|
||||
_CheckChains();
|
||||
}
|
||||
}
|
||||
|
||||
if (fShowMode != B_MAIL_SHOW_STATUS_WINDOW_ALWAYS)
|
||||
Hide();
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
@ -134,6 +148,21 @@ BMailStatusWindow::~BMailStatusWindow()
|
||||
general.SetStatusWindowWorkspaces((int32)Workspaces());
|
||||
general.Save();
|
||||
}
|
||||
|
||||
stop_watching(this);
|
||||
}
|
||||
|
||||
|
||||
//! Activate the "Check Now" button only if there are inbound accounts
|
||||
void
|
||||
BMailStatusWindow::_CheckChains()
|
||||
{
|
||||
BDirectory directory(&fChainDirectory);
|
||||
|
||||
entry_ref ref;
|
||||
bool isEmpty = directory.GetNextRef(&ref) != B_OK;
|
||||
|
||||
fCheckNowButton->SetEnabled(!isEmpty);
|
||||
}
|
||||
|
||||
|
||||
@ -190,6 +219,10 @@ BMailStatusWindow::MessageReceived(BMessage *msg)
|
||||
be_roster->Launch(B_MAIL_TYPE, msg);
|
||||
break;
|
||||
|
||||
case B_NODE_MONITOR:
|
||||
_CheckChains();
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* DeskbarView - main_daemon's deskbar menu and view
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
@ -279,7 +279,9 @@ DeskbarView::MessageReceived(BMessage *message)
|
||||
}
|
||||
}
|
||||
|
||||
void DeskbarView::ChangeIcon(int32 icon)
|
||||
|
||||
void
|
||||
DeskbarView::ChangeIcon(int32 icon)
|
||||
{
|
||||
if (fCurrentIconState == icon)
|
||||
return;
|
||||
@ -287,15 +289,15 @@ void DeskbarView::ChangeIcon(int32 icon)
|
||||
BBitmap *newIcon(NULL);
|
||||
|
||||
image_info info;
|
||||
if (our_image(&info) == B_OK)
|
||||
{
|
||||
if (our_image(&info) == B_OK) {
|
||||
BFile file(info.name, B_READ_ONLY);
|
||||
if (file.InitCheck() < B_OK)
|
||||
goto err;
|
||||
|
||||
BResources rsrc(&file);
|
||||
size_t len;
|
||||
const void *data = rsrc.LoadResource('BBMP',icon == NEW_MAIL ? "New" : "Read",&len);
|
||||
const void *data = rsrc.LoadResource('BBMP', icon == NEW_MAIL
|
||||
? "New" : "Read",&len);
|
||||
if (len == 0)
|
||||
goto err;
|
||||
|
||||
@ -305,8 +307,7 @@ void DeskbarView::ChangeIcon(int32 icon)
|
||||
if (archive.Unflatten(&stream) != B_OK)
|
||||
goto err;
|
||||
newIcon = new BBitmap(&archive);
|
||||
}
|
||||
else
|
||||
} else
|
||||
fputs("no image!", stderr);
|
||||
|
||||
err:
|
||||
@ -316,12 +317,16 @@ err:
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void DeskbarView::Pulse()
|
||||
|
||||
void
|
||||
DeskbarView::Pulse()
|
||||
{
|
||||
// Check if mail_daemon is still running
|
||||
// TODO: Check if mail_daemon is still running
|
||||
}
|
||||
|
||||
void DeskbarView::MouseUp(BPoint pos)
|
||||
|
||||
void
|
||||
DeskbarView::MouseUp(BPoint pos)
|
||||
{
|
||||
if (fLastButtons & B_PRIMARY_MOUSE_BUTTON) {
|
||||
if (OpenFolder("mail/mailbox") != B_OK)
|
||||
@ -334,22 +339,27 @@ void DeskbarView::MouseUp(BPoint pos)
|
||||
BMailDaemon::CheckMail(true);
|
||||
}
|
||||
|
||||
void DeskbarView::MouseDown(BPoint pos)
|
||||
|
||||
void
|
||||
DeskbarView::MouseDown(BPoint pos)
|
||||
{
|
||||
Looper()->CurrentMessage()->FindInt32("buttons",&fLastButtons);
|
||||
Looper()->CurrentMessage()->PrintToStream();
|
||||
|
||||
if (fLastButtons & B_SECONDARY_MOUSE_BUTTON)
|
||||
{
|
||||
if (fLastButtons & B_SECONDARY_MOUSE_BUTTON) {
|
||||
ConvertToScreen(&pos);
|
||||
|
||||
BPopUpMenu *menu = BuildMenu();
|
||||
if (menu)
|
||||
menu->Go(pos,true,true,BRect(pos.x - 2, pos.y - 2, pos.x + 2, pos.y + 2),true);
|
||||
if (menu) {
|
||||
menu->Go(pos, true, true, BRect(pos.x - 2, pos.y - 2,
|
||||
pos.x + 2, pos.y + 2), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DeskbarView::CreateMenuLinks(BDirectory &directory,BPath &path)
|
||||
|
||||
bool
|
||||
DeskbarView::CreateMenuLinks(BDirectory &directory,BPath &path)
|
||||
{
|
||||
status_t status = directory.SetTo(path.Path());
|
||||
if (status == B_OK)
|
||||
@ -390,13 +400,16 @@ bool DeskbarView::CreateMenuLinks(BDirectory &directory,BPath &path)
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeskbarView::CreateNewMailQuery(BEntry &query)
|
||||
|
||||
void
|
||||
DeskbarView::CreateNewMailQuery(BEntry &query)
|
||||
{
|
||||
BFile file(&query, B_READ_WRITE | B_CREATE_FILE);
|
||||
if (file.InitCheck() != B_OK)
|
||||
return;
|
||||
|
||||
BString string("((" B_MAIL_ATTR_STATUS "==\"[nN][eE][wW]\")&&((BEOS:TYPE==\"text/x-email\")||(BEOS:TYPE==\"text/x-partial-email\")))");
|
||||
BString string("((" B_MAIL_ATTR_STATUS "==\"[nN][eE][wW]\")&&((BEOS:TYPE=="
|
||||
"\"text/x-email\")||(BEOS:TYPE==\"text/x-partial-email\")))");
|
||||
file.WriteAttrString("_trk/qrystr", &string);
|
||||
string = "E-mail";
|
||||
file.WriteAttrString("_trk/qryinitmime", &string);
|
||||
@ -426,12 +439,10 @@ DeskbarView::BuildMenu()
|
||||
path.Append("Mail/Menu Links");
|
||||
|
||||
BDirectory directory;
|
||||
if (CreateMenuLinks(directory,path))
|
||||
{
|
||||
if (CreateMenuLinks(directory, path)) {
|
||||
int32 count = 0;
|
||||
|
||||
while (directory.GetNextRef(&ref) == B_OK)
|
||||
{
|
||||
while (directory.GetNextRef(&ref) == B_OK) {
|
||||
count++;
|
||||
|
||||
path.SetTo(&ref);
|
||||
@ -442,12 +453,10 @@ DeskbarView::BuildMenu()
|
||||
// we are using the NavMenu only for directories and queries
|
||||
bool useNavMenu = false;
|
||||
|
||||
if (entry.InitCheck() == B_OK)
|
||||
{
|
||||
if (entry.InitCheck() == B_OK) {
|
||||
if (entry.IsDirectory())
|
||||
useNavMenu = true;
|
||||
else if (entry.IsFile())
|
||||
{
|
||||
else if (entry.IsFile()) {
|
||||
// Files should use the BMenuItem unless they are queries
|
||||
char mimeString[B_MIME_TYPE_LENGTH];
|
||||
BNode node(&entry);
|
||||
@ -464,12 +473,11 @@ DeskbarView::BuildMenu()
|
||||
msg = new BMessage(B_REFS_RECEIVED);
|
||||
msg->AddRef("refs", &ref);
|
||||
|
||||
if (useNavMenu)
|
||||
{
|
||||
item = new BMenuItem(navMenu = new BNavMenu(path.Leaf(),B_REFS_RECEIVED,tracker), msg);
|
||||
if (useNavMenu) {
|
||||
item = new BMenuItem(navMenu = new BNavMenu(path.Leaf(),
|
||||
B_REFS_RECEIVED, tracker), msg);
|
||||
navMenu->SetNavDir(&ref);
|
||||
}
|
||||
else
|
||||
} else
|
||||
item = new BMenuItem(path.Leaf(), msg);
|
||||
|
||||
menu->AddItem(item);
|
||||
@ -490,11 +498,11 @@ DeskbarView::BuildMenu()
|
||||
|
||||
// The New E-mail query
|
||||
|
||||
if (fNewMessages > 0)
|
||||
{
|
||||
if (fNewMessages > 0) {
|
||||
BString string;
|
||||
MDR_DIALECT_CHOICE(
|
||||
string << fNewMessages << " new message" << ((fNewMessages != 1) ? "s" : B_EMPTY_STRING),
|
||||
string << fNewMessages << " new message"
|
||||
<< (fNewMessages != 1 ? "s" : B_EMPTY_STRING),
|
||||
string << fNewMessages << " 通の未読メッセージ");
|
||||
|
||||
find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
@ -505,26 +513,23 @@ DeskbarView::BuildMenu()
|
||||
CreateNewMailQuery(query);
|
||||
query.GetRef(&ref);
|
||||
|
||||
item = new BMenuItem(
|
||||
navMenu = new BNavMenu(string.String(),B_REFS_RECEIVED,BMessenger(kTrackerSignature)),
|
||||
item = new BMenuItem(navMenu = new BNavMenu(string.String(),
|
||||
B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
|
||||
msg = new BMessage(B_REFS_RECEIVED));
|
||||
msg->AddRef("refs", &ref);
|
||||
navMenu->SetNavDir(&ref);
|
||||
|
||||
menu->AddItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
menu->AddItem(item = new BMenuItem(
|
||||
MDR_DIALECT_CHOICE ("No new messages","未読メッセージなし"), NULL));
|
||||
item->SetEnabled(false);
|
||||
}
|
||||
|
||||
if (modifiers() & B_SHIFT_KEY)
|
||||
{
|
||||
BList list;
|
||||
GetInboundMailChains(&list);
|
||||
|
||||
if (modifiers() & B_SHIFT_KEY) {
|
||||
BMenu *chainMenu = new BMenu(
|
||||
MDR_DIALECT_CHOICE ("Check For Mails Only","R) メール受信のみ"));
|
||||
BFont font;
|
||||
@ -540,6 +545,11 @@ DeskbarView::BuildMenu()
|
||||
chainMenu->AddItem(new BMenuItem(chain->Name(), message));
|
||||
delete chain;
|
||||
}
|
||||
if (list.IsEmpty()) {
|
||||
item = new BMenuItem("<no accounts>", NULL);
|
||||
item->SetEnabled(false);
|
||||
chainMenu->AddItem(item);
|
||||
}
|
||||
chainMenu->SetTargetForItems(this);
|
||||
menu->AddItem(new BMenuItem(chainMenu, new BMessage(MD_CHECK_FOR_MAILS)));
|
||||
|
||||
@ -549,19 +559,20 @@ DeskbarView::BuildMenu()
|
||||
menu->AddItem(new BMenuItem(
|
||||
MDR_DIALECT_CHOICE ("Send Pending Mails", "M) 保留メールを送信"),
|
||||
new BMessage(MD_SEND_MAILS)));
|
||||
}
|
||||
else
|
||||
menu->AddItem(new BMenuItem(
|
||||
} else {
|
||||
menu->AddItem(item = new BMenuItem(
|
||||
MDR_DIALECT_CHOICE ("Check For Mail Now", "C) メールチェック"),
|
||||
new BMessage(MD_CHECK_SEND_NOW)));
|
||||
if (list.IsEmpty())
|
||||
item->SetEnabled(false);
|
||||
}
|
||||
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem(
|
||||
MDR_DIALECT_CHOICE ("Edit Preferences","P) メール環境設定") B_UTF8_ELLIPSIS,
|
||||
new BMessage(MD_OPEN_PREFS)));
|
||||
|
||||
if (modifiers() & B_SHIFT_KEY)
|
||||
{
|
||||
if (modifiers() & B_SHIFT_KEY) {
|
||||
menu->AddItem(new BMenuItem(
|
||||
MDR_DIALECT_CHOICE ("Shutdown Mail Services","Q) 終了"),
|
||||
new BMessage(B_QUIT_REQUESTED)));
|
||||
@ -569,11 +580,9 @@ DeskbarView::BuildMenu()
|
||||
|
||||
// Reset Item Targets (only those which aren't already set)
|
||||
|
||||
for (int32 i = menu->CountItems();i-- > 0;)
|
||||
{
|
||||
for (int32 i = menu->CountItems(); i-- > 0;) {
|
||||
item = menu->ItemAt(i);
|
||||
if (item && (msg = item->Message()) != NULL)
|
||||
{
|
||||
if (item && (msg = item->Message()) != NULL) {
|
||||
if (msg->what == B_REFS_RECEIVED)
|
||||
item->SetTarget(tracker);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user