Work in progress of mail rework.
* Not everything compiles; all protocols, and inbound filters do, though. * Renamed a few classes to give a better idea what they are for; prefixed public classes with the 'B' prefix. * Moved ProtocolConfigView's classes into the BPrivate namespace. * Moved BMailFilter into its own file. * Added BMailFilter::DescriptiveName(). This is now used by the RuleFilter in order to give a description of what it's doing (ie. no more dozens of "Rule filter" entries in the preferences). * Removed no longer used MailAddon.h. * Renamed Addon to AddOn where found, since that is more consistent with the rest of the API. * Merged the former MailProtocol with the former MailProtocolThread; the differentiation between those two was pretty messy. * All configuration views touched so far are now using the layout kit. * The RuleFilter is currently broken functionality wise; I have not yet decided how to solve the stuff it uses (TriggerFileMove() does not exist anymore, for example). * BMailAddOnSettings (formerly known as AddonSettings) now directly subclass BMessage; there are no Settings() and EditSettings() method anymore. The class uses a copy of itself to determine whether or not it has been changed. * Lots of cleanup.
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
/* Filter - the base class for all mail filters
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
#ifndef ZOIDBERG_MAIL_ADDON_H
|
||||
#define ZOIDBERG_MAIL_ADDON_H
|
||||
|
||||
|
||||
#include "MailProtocol.h"
|
||||
#include "MailSettings.h"
|
||||
|
||||
|
||||
class BView;
|
||||
|
||||
//
|
||||
// The addon interface: export instantiate_mailfilter()
|
||||
// and instantiate_mailconfig() to create a Filter addon
|
||||
//
|
||||
|
||||
extern "C" _EXPORT InboundProtocol* instantiate_inbound_protocol(
|
||||
BMailAccountSettings* settings);
|
||||
extern "C" _EXPORT OutboundProtocol* instantiate_outbound_protocol(
|
||||
BMailAccountSettings* settings);
|
||||
extern "C" _EXPORT BView* instantiate_config_panel(MailAddonSettings&,
|
||||
BMailAccountSettings&);
|
||||
// return a view that configures the MailProtocol
|
||||
// returned by the functions below. BView::Archive(foo,true)
|
||||
// produces this addon's settings, which are passed to the in-
|
||||
// stantiate_* functions and stored persistently. This function
|
||||
// should gracefully handle empty and NULL settings.
|
||||
|
||||
extern "C" _EXPORT BView* instantiate_filter_config_panel(AddonSettings&);
|
||||
extern "C" _EXPORT MailFilter* instantiate_mailfilter(MailProtocol& protocol,
|
||||
AddonSettings* settings);
|
||||
|
||||
extern "C" _EXPORT BString descriptive_name();
|
||||
// the config panel will show this name in the chains filter
|
||||
// list if this function returns B_OK.
|
||||
// The buffer is as big as B_FILE_NAME_LENGTH.
|
||||
|
||||
// standard Filters:
|
||||
//
|
||||
// * Parser - does ParseRFC2822(io_message,io_headers)
|
||||
// * Folder - stores the message in the specified folder,
|
||||
// optionally under io_folder, returns MD_HANDLED
|
||||
// * HeaderFilter(regex,Yes_fiters,No_filters) -
|
||||
// Applies Nes_filters to messages that have a header
|
||||
// matching regex; applies No_filters otherwise.
|
||||
// * CompatabilityFilter - Invokes the standard mail_dae-
|
||||
// mon filter ~/config/settings/add-ons/MailDaemon/Filter
|
||||
// on the message's Entry.
|
||||
// * Producer - Reads outbound messages from disk and inserts
|
||||
// them into the queue.
|
||||
// * SMTPSender - Sends the message, via the specified
|
||||
// SMTP server, to the people in header field
|
||||
// "MAIL:recipients", changes the the Entry's
|
||||
// "MAIL:flags" field to no longer pending, changes the
|
||||
// "MAIL:status" header field to "Sent", and adds a header
|
||||
// field "MAIL:when" with the time it was sent.
|
||||
// * Dumper - returns MD_DISCARD
|
||||
//
|
||||
//
|
||||
// Standard chain types:
|
||||
//
|
||||
// Incoming Mail: Protocol - Parser - Notifier - Folder
|
||||
// Outgoing Mail: Producer - SMTPSender
|
||||
//
|
||||
// "chains" are lists of addons that appear in, or can be
|
||||
// added to, the "Accounts" list in the config panel, a tree-
|
||||
// view ordered by the chain type and the chain's AccountName().
|
||||
// Their config views should be shown, one after the other,
|
||||
// in the config panel.
|
||||
|
||||
#endif /* ZOIDBERG_MAIL_ADDON_H */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2011-2012, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef MAIL_FILTER_H
|
||||
#define MAIL_FILTER_H
|
||||
|
||||
|
||||
#include "MailProtocol.h"
|
||||
#include "MailSettings.h"
|
||||
|
||||
|
||||
class BMailProtocol;
|
||||
class BView;
|
||||
|
||||
|
||||
class BMailFilter {
|
||||
public:
|
||||
BMailFilter(BMailProtocol& protocol,
|
||||
BMailAddOnSettings* settings);
|
||||
virtual ~BMailFilter();
|
||||
|
||||
virtual BString DescriptiveName() const = 0;
|
||||
|
||||
// Message hooks if filter is installed to an inbound protocol
|
||||
virtual void HeaderFetched(const entry_ref& ref,
|
||||
BFile* file);
|
||||
virtual void BodyFetched(const entry_ref& ref, BFile* file);
|
||||
virtual void MailboxSynchronized(status_t status);
|
||||
|
||||
// Message hooks if filter is installed to an outbound protocol
|
||||
virtual void MessageReadyToSend(const entry_ref& ref,
|
||||
BFile* file);
|
||||
virtual void MessageSent(const entry_ref& ref,
|
||||
BFile* file);
|
||||
|
||||
protected:
|
||||
BMailProtocol& fMailProtocol;
|
||||
BMailAddOnSettings* fSettings;
|
||||
};
|
||||
|
||||
|
||||
// Your filter needs to export these hooks in order to be picked up
|
||||
extern "C" BView* instantiate_filter_config_panel(BMailAddOnSettings& settings);
|
||||
extern "C" BMailFilter* instantiate_filter(BMailProtocol& protocol,
|
||||
BMailAddOnSettings* settings);
|
||||
extern "C" BString filter_name();
|
||||
|
||||
|
||||
#endif // MAIL_FILTER_H
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <MailSettings.h>
|
||||
|
||||
|
||||
class BMailFilter;
|
||||
|
||||
|
||||
class BMailNotifier {
|
||||
public:
|
||||
virtual ~BMailNotifier() {}
|
||||
@@ -38,71 +41,47 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class MailProtocol;
|
||||
|
||||
|
||||
class MailFilter {
|
||||
class BMailProtocol : BLooper {
|
||||
public:
|
||||
MailFilter(MailProtocol& protocol,
|
||||
AddonSettings* settings);
|
||||
virtual ~MailFilter();
|
||||
BMailProtocol(
|
||||
const BMailAccountSettings& settings);
|
||||
virtual ~BMailProtocol();
|
||||
|
||||
//! Message hooks if filter is installed to an inbound protocol
|
||||
virtual void HeaderFetched(const entry_ref& ref,
|
||||
BFile* file);
|
||||
virtual void BodyFetched(const entry_ref& ref, BFile* file);
|
||||
virtual void MailboxSynced(status_t status);
|
||||
|
||||
//! Message hooks if filter is installed to an outbound protocol
|
||||
virtual void MessageReadyToSend(const entry_ref& ref,
|
||||
BFile* file);
|
||||
virtual void MessageSent(const entry_ref& ref,
|
||||
BFile* file);
|
||||
protected:
|
||||
MailProtocol& fMailProtocol;
|
||||
AddonSettings* fAddonSettings;
|
||||
};
|
||||
|
||||
|
||||
class MailProtocolThread;
|
||||
|
||||
|
||||
class MailProtocol {
|
||||
public:
|
||||
MailProtocol(BMailAccountSettings* settings);
|
||||
virtual ~MailProtocol();
|
||||
|
||||
virtual void SetStopNow() {}
|
||||
|
||||
BMailAccountSettings& AccountSettings();
|
||||
|
||||
void SetProtocolThread(
|
||||
MailProtocolThread* protocolThread);
|
||||
virtual void AddedToLooper() {}
|
||||
MailProtocolThread* Looper();
|
||||
/*! Add handler to the handler list. The handler is installed /
|
||||
removed to the according BLooper automatically. */
|
||||
bool AddHandler(BHandler* handler);
|
||||
//! Does not delete handler
|
||||
bool RemoveHandler(BHandler* handler);
|
||||
const BMailAccountSettings& AccountSettings() const;
|
||||
|
||||
void SetMailNotifier(BMailNotifier* mailNotifier);
|
||||
BMailNotifier* MailNotifier() const;
|
||||
|
||||
virtual void ShowError(const char* error);
|
||||
virtual void ShowMessage(const char* message);
|
||||
virtual void SetTotalItems(int32 items);
|
||||
virtual void SetTotalItemsSize(int32 size);
|
||||
virtual void ReportProgress(int bytes, int messages,
|
||||
//! We take ownership of the filters
|
||||
bool AddFilter(BMailFilter* filter);
|
||||
int32 CountFilter() const;
|
||||
BMailFilter* FilterAt(int32 index) const;
|
||||
BMailFilter* RemoveFilter(int32 index);
|
||||
bool RemoveFilter(BMailFilter* filter);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
// Mail storage operations
|
||||
virtual status_t MoveMessage(const entry_ref& ref,
|
||||
BDirectory& dir);
|
||||
virtual status_t DeleteMessage(const entry_ref& ref);
|
||||
|
||||
virtual void FileRenamed(const entry_ref& from,
|
||||
const entry_ref& to);
|
||||
virtual void FileDeleted(const node_ref& node);
|
||||
|
||||
// Convenience methods that call the BMailNotifier
|
||||
void ShowError(const char* error);
|
||||
void ShowMessage(const char* message);
|
||||
|
||||
protected:
|
||||
void SetTotalItems(uint32 items);
|
||||
void SetTotalItemsSize(uint64 size);
|
||||
void ReportProgress(uint32 messages, uint64 bytes,
|
||||
const char* message = NULL);
|
||||
virtual void ResetProgress(const char* message = NULL);
|
||||
|
||||
//! MailProtocol takes ownership of the filters
|
||||
bool AddFilter(MailFilter* filter);
|
||||
int32 CountFilter();
|
||||
MailFilter* FilterAt(int32 index);
|
||||
MailFilter* RemoveFilter(int32 index);
|
||||
bool RemoveFilter(MailFilter* filter);
|
||||
void ResetProgress(const char* message = NULL);
|
||||
|
||||
// Filter notifications
|
||||
void NotifyNewMessagesToFetch(int32 nMessages);
|
||||
void NotifyHeaderFetched(const entry_ref& ref,
|
||||
BFile* mail);
|
||||
@@ -113,35 +92,29 @@ public:
|
||||
void NotifyMessageSent(const entry_ref& ref,
|
||||
BFile* mail);
|
||||
|
||||
//! mail storage operations
|
||||
virtual status_t MoveMessage(const entry_ref& ref,
|
||||
BDirectory& dir);
|
||||
virtual status_t DeleteMessage(const entry_ref& ref);
|
||||
void LoadFilters(
|
||||
const BMailProtocolSettings& settings);
|
||||
|
||||
virtual void FileRenamed(const entry_ref& from,
|
||||
const entry_ref& to);
|
||||
virtual void FileDeleted(const node_ref& node);
|
||||
private:
|
||||
BMailFilter* _LoadFilter(BMailAddOnSettings* filterSettings);
|
||||
|
||||
protected:
|
||||
void LoadFilters(MailAddonSettings& settings);
|
||||
|
||||
BMailAccountSettings fAccountSettings;
|
||||
const BMailAccountSettings fAccountSettings;
|
||||
BMailNotifier* fMailNotifier;
|
||||
|
||||
private:
|
||||
MailFilter* _LoadFilter(AddonSettings* filterSettings);
|
||||
|
||||
MailProtocolThread* fProtocolThread;
|
||||
BObjectList<BHandler> fHandlerList;
|
||||
BObjectList<MailFilter> fFilterList;
|
||||
std::map<entry_ref, image_id> fFilterImages;
|
||||
BObjectList<BMailFilter> fFilterList;
|
||||
std::map<entry_ref, image_id> fFilterImages;
|
||||
};
|
||||
|
||||
|
||||
class InboundProtocol : public MailProtocol {
|
||||
class BInboundMailProtocol : public BMailProtocol {
|
||||
public:
|
||||
InboundProtocol(BMailAccountSettings* settings);
|
||||
virtual ~InboundProtocol();
|
||||
BInboundMailProtocol(
|
||||
const BMailAccountSettings& settings);
|
||||
virtual ~BInboundMailProtocol();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual status_t SyncMessages() = 0;
|
||||
virtual status_t FetchBody(const entry_ref& ref) = 0;
|
||||
@@ -149,78 +122,33 @@ public:
|
||||
read_flags flag = B_READ);
|
||||
virtual status_t DeleteMessage(const entry_ref& ref) = 0;
|
||||
virtual status_t AppendMessage(const entry_ref& ref);
|
||||
|
||||
protected:
|
||||
void NotiyMailboxSynchronized(status_t status);
|
||||
};
|
||||
|
||||
|
||||
class OutboundProtocol : public MailProtocol {
|
||||
class BOutboundMailProtocol : public BMailProtocol {
|
||||
public:
|
||||
OutboundProtocol(
|
||||
BMailAccountSettings* settings);
|
||||
virtual ~OutboundProtocol();
|
||||
BOutboundMailProtocol(
|
||||
const BMailAccountSettings& settings);
|
||||
virtual ~BOutboundMailProtocol();
|
||||
|
||||
virtual status_t SendMessages(const std::vector<entry_ref>&
|
||||
mails, size_t totalBytes) = 0;
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual status_t SendMessages(
|
||||
const std::vector<entry_ref>& mails,
|
||||
size_t totalBytes) = 0;
|
||||
};
|
||||
|
||||
|
||||
class MailProtocolThread : public BLooper {
|
||||
public:
|
||||
MailProtocolThread(MailProtocol* protocol);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
MailProtocol* Protocol() { return fMailProtocol; }
|
||||
|
||||
void SetStopNow();
|
||||
/*! These function post a message to the loop to trigger the action.
|
||||
*/
|
||||
void TriggerFileMove(const entry_ref& ref,
|
||||
BDirectory& dir);
|
||||
void TriggerFileDeletion(const entry_ref& ref);
|
||||
|
||||
void TriggerFileRenamed(const entry_ref& from,
|
||||
const entry_ref& to);
|
||||
void TriggerFileDeleted(const node_ref& node);
|
||||
private:
|
||||
MailProtocol* fMailProtocol;
|
||||
};
|
||||
|
||||
|
||||
class InboundProtocolThread : public MailProtocolThread {
|
||||
public:
|
||||
InboundProtocolThread(
|
||||
InboundProtocol* protocol);
|
||||
~InboundProtocolThread();
|
||||
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
void SyncMessages();
|
||||
void FetchBody(const entry_ref& ref,
|
||||
BMessenger* listener = NULL);
|
||||
void MarkMessageAsRead(const entry_ref& ref,
|
||||
read_flags flag = B_READ);
|
||||
void DeleteMessage(const entry_ref& ref);
|
||||
void AppendMessage(const entry_ref& ref);
|
||||
private:
|
||||
void _NotiyMailboxSynced(status_t status);
|
||||
|
||||
InboundProtocol* fProtocol;
|
||||
};
|
||||
|
||||
|
||||
class OutboundProtocolThread : public MailProtocolThread {
|
||||
public:
|
||||
OutboundProtocolThread(
|
||||
OutboundProtocol* protocol);
|
||||
~OutboundProtocolThread();
|
||||
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
void SendMessages(const std::vector<entry_ref>&
|
||||
mails, size_t totalBytes);
|
||||
|
||||
private:
|
||||
OutboundProtocol* fProtocol;
|
||||
};
|
||||
// Your protocol needs to export these hooks in order to be picked up
|
||||
extern "C" _EXPORT BInboundMailProtocol* instantiate_inbound_protocol(
|
||||
const BMailAccountSettings& settings);
|
||||
extern "C" _EXPORT BOutboundMailProtocol* instantiate_outbound_protocol(
|
||||
const BMailAccountSettings& settings);
|
||||
extern "C" _EXPORT BView* instantiate_protocol_config_panel(
|
||||
BMailAccountSettings& settings);
|
||||
|
||||
|
||||
#endif // MAIL_PROTOCOL_H
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/* ProtocolConfigView - the standard config view for all protocols
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
#ifndef ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
|
||||
#define ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
|
||||
/*
|
||||
* Copyright 2004-2012, Haiku Inc. All rights reserved.
|
||||
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PROTOCOL_CONFIG_VIEW_H
|
||||
#define _PROTOCOL_CONFIG_VIEW_H
|
||||
|
||||
|
||||
#include <CheckBox.h>
|
||||
@@ -11,19 +13,29 @@
|
||||
#include <TextControl.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "MailSettings.h"
|
||||
#include <MailSettings.h>
|
||||
|
||||
|
||||
class BCheckBox;
|
||||
class BGridLayout;
|
||||
class BMenuField;
|
||||
class BTextControl;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class BodyDownloadConfig : public BView {
|
||||
public:
|
||||
BodyDownloadConfig();
|
||||
|
||||
void SetTo(MailAddonSettings& settings);
|
||||
void SetTo(BMailProtocolSettings& settings);
|
||||
|
||||
void MessageReceived(BMessage *msg);
|
||||
void MessageReceived(BMessage* message);
|
||||
void AttachedToWindow();
|
||||
void GetPreferredSize(float *width, float *height);
|
||||
status_t Archive(BMessage *into, bool) const;
|
||||
void GetPreferredSize(float* width, float* height);
|
||||
status_t Archive(BMessage* into, bool deep = true) const;
|
||||
|
||||
private:
|
||||
BTextControl* fSizeBox;
|
||||
BCheckBox* fPartialBox;
|
||||
@@ -31,39 +43,64 @@ private:
|
||||
};
|
||||
|
||||
|
||||
typedef enum {
|
||||
B_MAIL_PROTOCOL_HAS_AUTH_METHODS = 1,
|
||||
enum mail_protocol_config_options {
|
||||
B_MAIL_PROTOCOL_HAS_AUTH_METHODS = 1,
|
||||
B_MAIL_PROTOCOL_HAS_FLAVORS = 2,
|
||||
B_MAIL_PROTOCOL_HAS_USERNAME = 4,
|
||||
B_MAIL_PROTOCOL_HAS_PASSWORD = 8,
|
||||
B_MAIL_PROTOCOL_HAS_HOSTNAME = 16,
|
||||
B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER = 32,
|
||||
B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD = 64
|
||||
} b_mail_protocol_config_options;
|
||||
B_MAIL_PROTOCOL_HAS_USERNAME = 4,
|
||||
B_MAIL_PROTOCOL_HAS_PASSWORD = 8,
|
||||
B_MAIL_PROTOCOL_HAS_HOSTNAME = 16,
|
||||
B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER = 32,
|
||||
B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD = 64
|
||||
};
|
||||
|
||||
|
||||
class BMailProtocolConfigView : public BView {
|
||||
class MailProtocolConfigView : public BView {
|
||||
public:
|
||||
BMailProtocolConfigView(uint32 options_mask
|
||||
= B_MAIL_PROTOCOL_HAS_FLAVORS
|
||||
| B_MAIL_PROTOCOL_HAS_USERNAME
|
||||
| B_MAIL_PROTOCOL_HAS_PASSWORD
|
||||
| B_MAIL_PROTOCOL_HAS_HOSTNAME);
|
||||
virtual ~BMailProtocolConfigView();
|
||||
|
||||
void SetTo(MailAddonSettings& archive);
|
||||
|
||||
void AddFlavor(const char *label);
|
||||
void AddAuthMethod(const char *label,
|
||||
MailProtocolConfigView(uint32 optionsMask
|
||||
= B_MAIL_PROTOCOL_HAS_FLAVORS
|
||||
| B_MAIL_PROTOCOL_HAS_USERNAME
|
||||
| B_MAIL_PROTOCOL_HAS_PASSWORD
|
||||
| B_MAIL_PROTOCOL_HAS_HOSTNAME);
|
||||
virtual ~MailProtocolConfigView();
|
||||
|
||||
void SetTo(BMailProtocolSettings& settings);
|
||||
|
||||
void AddFlavor(const char* label);
|
||||
void AddAuthMethod(const char* label,
|
||||
bool needUserPassword = true);
|
||||
|
||||
virtual status_t Archive(BMessage *into, bool deep = true) const;
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
BGridLayout* Layout() const;
|
||||
|
||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
BTextControl* _AddTextControl(BGridLayout* layout,
|
||||
const char* name, const char* label);
|
||||
BMenuField* _AddMenuField(BGridLayout* layout,
|
||||
const char* name, const char* label);
|
||||
void _StoreIndexOfMarked(BMessage& message,
|
||||
const char* name, BMenuField* field) const;
|
||||
void _StoreCheckBox(BMessage& message,
|
||||
const char* name,
|
||||
BCheckBox* checkBox) const;
|
||||
void _SetCredentialsEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
BTextControl* fHostControl;
|
||||
BTextControl* fUserControl;
|
||||
BTextControl* fPasswordControl;
|
||||
BMenuField* fFlavorField;
|
||||
BMenuField* fAuthenticationField;
|
||||
BCheckBox* fLeaveOnServerCheckBox;
|
||||
BCheckBox* fRemoveFromServerCheckBox;
|
||||
BodyDownloadConfig* fBodyDownloadConfig;
|
||||
};
|
||||
|
||||
#endif /* ZOIDBERG_PROTOCOL_CONFIG_VIEW_H */
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif /* _PROTOCOL_CONFIG_VIEW_H */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Copyright 2004-2012, Haiku Inc. All rights reserved.
|
||||
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2011 Clemens Zeidler.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef MAIL_SETTINGS_H
|
||||
@@ -77,49 +79,49 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class AddonSettings {
|
||||
class BMailAddOnSettings : public BMessage {
|
||||
public:
|
||||
AddonSettings();
|
||||
BMailAddOnSettings();
|
||||
virtual ~BMailAddOnSettings();
|
||||
|
||||
bool Load(const BMessage& message);
|
||||
bool Save(BMessage& message);
|
||||
virtual status_t Load(const BMessage& message);
|
||||
virtual status_t Save(BMessage& message);
|
||||
|
||||
void SetAddonRef(const entry_ref& ref);
|
||||
const entry_ref& AddonRef() const;
|
||||
void SetAddOnRef(const entry_ref& ref);
|
||||
const entry_ref& AddOnRef() const;
|
||||
|
||||
const BMessage& Settings() const;
|
||||
BMessage& EditSettings();
|
||||
|
||||
bool HasBeenModified();
|
||||
virtual bool HasBeenModified() const;
|
||||
|
||||
private:
|
||||
BMessage fSettings;
|
||||
entry_ref fAddonRef;
|
||||
|
||||
bool fModified;
|
||||
BMessage fOriginalSettings;
|
||||
entry_ref fRef;
|
||||
entry_ref fOriginalRef;
|
||||
};
|
||||
|
||||
|
||||
class MailAddonSettings : public AddonSettings {
|
||||
class BMailProtocolSettings : public BMailAddOnSettings {
|
||||
public:
|
||||
bool Load(const BMessage& message);
|
||||
bool Save(BMessage& message);
|
||||
BMailProtocolSettings();
|
||||
virtual ~BMailProtocolSettings();
|
||||
|
||||
int32 CountFilterSettings();
|
||||
virtual status_t Load(const BMessage& message);
|
||||
virtual status_t Save(BMessage& message);
|
||||
|
||||
int32 CountFilterSettings() const;
|
||||
int32 AddFilterSettings(const entry_ref* ref = NULL);
|
||||
bool RemoveFilterSettings(int32 index);
|
||||
void RemoveFilterSettings(int32 index);
|
||||
bool MoveFilterSettings(int32 from, int32 to);
|
||||
AddonSettings* FilterSettingsAt(int32 index);
|
||||
BMailAddOnSettings* FilterSettingsAt(int32 index) const;
|
||||
|
||||
bool HasBeenModified();
|
||||
virtual bool HasBeenModified() const;
|
||||
|
||||
private:
|
||||
std::vector<AddonSettings> fFiltersSettings;
|
||||
BObjectList<BMailAddOnSettings> fFiltersSettings;
|
||||
};
|
||||
|
||||
|
||||
class BMailAccountSettings {
|
||||
public:
|
||||
public:
|
||||
BMailAccountSettings();
|
||||
BMailAccountSettings(BEntry account);
|
||||
~BMailAccountSettings();
|
||||
@@ -127,24 +129,26 @@ class BMailAccountSettings {
|
||||
status_t InitCheck() { return fStatus; }
|
||||
|
||||
void SetAccountID(int32 id);
|
||||
int32 AccountID();
|
||||
int32 AccountID() const;
|
||||
|
||||
void SetName(const char* name);
|
||||
const char* Name() const;
|
||||
const char* Name() const;
|
||||
|
||||
void SetRealName(const char* realName);
|
||||
const char* RealName() const;
|
||||
const char* RealName() const;
|
||||
|
||||
void SetReturnAddress(const char* returnAddress);
|
||||
const char* ReturnAddress() const;
|
||||
const char* ReturnAddress() const;
|
||||
|
||||
bool SetInboundAddon(const char* name);
|
||||
bool SetOutboundAddon(const char* name);
|
||||
const entry_ref& InboundPath() const;
|
||||
const entry_ref& OutboundPath() const;
|
||||
bool SetInboundAddOn(const char* name);
|
||||
bool SetOutboundAddOn(const char* name);
|
||||
const entry_ref& InboundAddOnRef() const;
|
||||
const entry_ref& OutboundAddOnRef() const;
|
||||
|
||||
MailAddonSettings& InboundSettings();
|
||||
MailAddonSettings& OutboundSettings();
|
||||
BMailProtocolSettings& InboundSettings();
|
||||
const BMailProtocolSettings& InboundSettings() const;
|
||||
BMailProtocolSettings& OutboundSettings();
|
||||
const BMailProtocolSettings& OutboundSettings() const;
|
||||
|
||||
bool HasInbound();
|
||||
bool HasOutbound();
|
||||
@@ -158,9 +162,9 @@ class BMailAccountSettings {
|
||||
status_t Save();
|
||||
status_t Delete();
|
||||
|
||||
bool HasBeenModified();
|
||||
bool HasBeenModified() const;
|
||||
|
||||
const BEntry& AccountFile();
|
||||
const BEntry& AccountFile() const;
|
||||
|
||||
private:
|
||||
status_t _CreateAccountFilePath();
|
||||
@@ -175,8 +179,8 @@ private:
|
||||
BString fRealName;
|
||||
BString fReturnAdress;
|
||||
|
||||
MailAddonSettings fInboundSettings;
|
||||
MailAddonSettings fOutboundSettings;
|
||||
BMailProtocolSettings fInboundSettings;
|
||||
BMailProtocolSettings fOutboundSettings;
|
||||
|
||||
bool fInboundEnabled;
|
||||
bool fOutboundEnabled;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#ifndef FILE_CONFIG_VIEW
|
||||
#define FILE_CONFIG_VIEW
|
||||
/* FileConfigView - a file configuration view for filters
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2004-2012, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _FILE_CONFIG_VIEW_H
|
||||
#define _FILE_CONFIG_VIEW_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
@@ -13,45 +15,56 @@
|
||||
class BTextControl;
|
||||
class BButton;
|
||||
|
||||
class BFileControl : public BView
|
||||
{
|
||||
public:
|
||||
BFileControl(BRect rect,const char *name,const char *label,const char *pathOfFile = NULL,uint32 flavors = B_DIRECTORY_NODE);
|
||||
~BFileControl();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
namespace BPrivate {
|
||||
|
||||
void SetText(const char *pathOfFile);
|
||||
const char *Text() const;
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
class FileControl : public BView {
|
||||
public:
|
||||
FileControl(const char* name, const char* label,
|
||||
const char* pathOfFile = NULL,
|
||||
uint32 flavors = B_DIRECTORY_NODE);
|
||||
virtual ~FileControl();
|
||||
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
BTextControl *fText;
|
||||
BButton *fButton;
|
||||
void SetText(const char* pathOfFile);
|
||||
const char* Text() const;
|
||||
|
||||
BFilePanel *fPanel;
|
||||
|
||||
uint32 _reserved[5];
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
BTextControl* fText;
|
||||
BButton* fButton;
|
||||
|
||||
BFilePanel* fPanel;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
class BMailFileConfigView : public BFileControl
|
||||
{
|
||||
public:
|
||||
BMailFileConfigView(const char *label,const char *name,bool useMeta = false,const char *defaultPath = NULL,uint32 flavors = B_DIRECTORY_NODE);
|
||||
|
||||
void SetTo(const BMessage *archive, BMessage *metadata);
|
||||
virtual status_t Archive(BMessage *into, bool deep = true) const;
|
||||
class MailFileConfigView : public FileControl {
|
||||
public:
|
||||
MailFileConfigView(const char* label,
|
||||
const char* name, bool useMeta = false,
|
||||
const char* defaultPath = NULL,
|
||||
uint32 flavors = B_DIRECTORY_NODE);
|
||||
|
||||
private:
|
||||
BMessage *fMeta;
|
||||
bool fUseMeta;
|
||||
const char *fName;
|
||||
void SetTo(const BMessage* archive,
|
||||
BMessage* metadata);
|
||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||
|
||||
uint32 _reserved[5];
|
||||
private:
|
||||
BMessage* fMeta;
|
||||
bool fUseMeta;
|
||||
const char* fName;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
#endif /* FILE_CONFIG_VIEW */
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _FILE_CONFIG_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user