Imported MDR. Some code still not entirely functional -- I haven't been able to figure out how to detect SSL, so IMAP and POP have it turned off. PPP auto-detect is also not functional at the moment. Other than that, it seems to work beautifully. Packaging will come later.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9016 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
#ifndef ZOIDBERG_MAIL_CHAIN_RUNNER_H
|
||||
#define ZOIDBERG_MAIL_CHAIN_RUNNER_H
|
||||
/* ChainRunner - runs the mail inbound and outbound chains
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <MailAddon.h>
|
||||
#include <MailSettings.h>
|
||||
#include <Looper.h>
|
||||
#include <status.h>
|
||||
|
||||
class BStringList;
|
||||
class BMailStatusWindow;
|
||||
class BMailChain;
|
||||
|
||||
class BMailChainCallback {
|
||||
public:
|
||||
virtual void Callback(status_t result) = 0;
|
||||
// Called by the callback routines in ChainRunner
|
||||
// result is the message that ended the chain
|
||||
// (MD_HANDLED, MD_DISCARD, MD_NO_MORE_MESSAGES)
|
||||
// Obviously, for process callbacks, result is
|
||||
// gauranteed to be MD_NO_MORE_MESSAGES.
|
||||
};
|
||||
|
||||
class BMailChainRunner : public BLooper {
|
||||
public:
|
||||
BMailChainRunner(BMailChain *chain, BMailStatusWindow *status,
|
||||
bool self_destruct_when_done = true, bool save_chain_when_done = false,
|
||||
bool destruct_chain_when_done = false);
|
||||
~BMailChainRunner();
|
||||
|
||||
//----Callback functions. Callback objects will be deleted for you.
|
||||
|
||||
void RegisterMessageCallback(BMailChainCallback *callback);
|
||||
// Your callback->Callback() function will be called when
|
||||
// the current message is done being processed.
|
||||
|
||||
void RegisterProcessCallback(BMailChainCallback *callback);
|
||||
// Your callback->Callback() function will be called when
|
||||
// a filter returns MD_PASS_COMPLETE and before we go back
|
||||
// to waiting for new messages, or when the fetch list
|
||||
// runs out.
|
||||
|
||||
void RegisterChainCallback(BMailChainCallback *callback);
|
||||
// Your callback->Callback() function will be called when
|
||||
// a filter returns MD_ALL_PASSES_DONE and before everything
|
||||
// is unloaded and sent home.
|
||||
|
||||
void Stop();
|
||||
void ReportProgress(int bytes, int messages, const char *message = NULL);
|
||||
void ResetProgress(const char *message = NULL);
|
||||
|
||||
void GetMessages(BStringList *list, int32 bytes);
|
||||
void GetSingleMessage(const char *uid, int32 length, BPath *into);
|
||||
// The bytes or length field is the total size, used for updating the
|
||||
// progress bar. Use -1 for unknown maximum size.
|
||||
|
||||
bool QuitRequested();
|
||||
|
||||
void ShowError(const char *error);
|
||||
void ShowMessage(const char *message);
|
||||
|
||||
BMailChain *Chain();
|
||||
|
||||
//----The big, bad asynchronous RunChain() function. Pretty harmless looking, huh?
|
||||
status_t RunChain(bool asynchronous = true);
|
||||
|
||||
void MessageReceived (BMessage *msg);
|
||||
|
||||
private:
|
||||
void CallCallbacksFor(BList &list, status_t code);
|
||||
void get_messages(BStringList *list);
|
||||
status_t Init();
|
||||
#if USE_NASTY_SYNC_THREAD_HACK
|
||||
static int32 thread_sync_func(void *arg);
|
||||
status_t init_addons();
|
||||
#endif
|
||||
|
||||
BMailChain *_chain;
|
||||
BList message_cb, process_cb, chain_cb;
|
||||
|
||||
bool destroy_self, destroy_chain, save_chain;
|
||||
|
||||
BMailStatusWindow *_status;
|
||||
BMailStatusView *_statview;
|
||||
BList addons;
|
||||
|
||||
bool suicide;
|
||||
uint8 _other_reserved[3];
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
BMailChainRunner *GetMailChainRunner(int32 chain_id, BMailStatusWindow *status, bool selfDestruct = true);
|
||||
|
||||
#endif /* ZOIDBERG_MAIL_CHAIN_RUNNER_H */
|
||||
@@ -0,0 +1,151 @@
|
||||
#ifndef ZOIDBERG_MAIL_ADDON_H
|
||||
#define ZOIDBERG_MAIL_ADDON_H
|
||||
/* Filter - the base class for all mail filters
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
class BMessage;
|
||||
class BView;
|
||||
class BPositionIO;
|
||||
class BEntry;
|
||||
class BPath;
|
||||
class BView;
|
||||
class BString;
|
||||
class BPositionIO;
|
||||
class BEntry;
|
||||
|
||||
enum {
|
||||
B_MAIL_DISCARD = B_MAIL_ERROR_BASE + 8,
|
||||
//--- This terminates the chain and removes the message being processed
|
||||
// both from disk and from the server.
|
||||
B_MAIL_END_FETCH,
|
||||
//--- Terminates the current operation
|
||||
B_MAIL_END_CHAIN
|
||||
//--- This is for yikes errors, like an unreachable server.
|
||||
};
|
||||
|
||||
class BMailStatusView;
|
||||
class BMailChainRunner;
|
||||
|
||||
class BMailFilter
|
||||
{
|
||||
public:
|
||||
BMailFilter(BMessage* settings);
|
||||
// How to support queueing messages until a time of the
|
||||
// day/week/month/year? The settings will contain a
|
||||
// persistent ChainID field, the same for all Filters
|
||||
// on the same "chain".
|
||||
|
||||
virtual ~BMailFilter();
|
||||
// This will be called when the settings for this Filter
|
||||
// are changed, or there are no new messages to consume
|
||||
// after settings->FindInt32("timeout") seconds.
|
||||
|
||||
virtual status_t InitCheck(BString* out_message = NULL) = 0;
|
||||
// Returns B_OK if the Filter was constructed success-
|
||||
// fully. Otherwise it returns an error code. If it is
|
||||
// passed a valid BString*, it may add an error message
|
||||
// to the end of that BString iff it returns an error.
|
||||
// If it returns an error code then the MailFilter will
|
||||
// probably be deleted and the error shown to the user.
|
||||
|
||||
virtual status_t ProcessMailMessage
|
||||
(
|
||||
BPositionIO** io_message, BEntry* io_entry,
|
||||
BMessage* io_headers, BPath* io_folder, const char *io_uid
|
||||
) = 0;
|
||||
// Filters a message. On input and output, the arguments
|
||||
// are expected to be as below; however it is allowed for
|
||||
// the MailFilter to alter any of these values as nece-
|
||||
// ssary, so long as the constraints are as described when
|
||||
// the function returns:
|
||||
//
|
||||
// * io_message - a PositionIO that contains the message
|
||||
// data, pointing to the first byte of the message's
|
||||
// header. This can be swapped if, eg, the message
|
||||
// is copied across volume boundries. When the chain
|
||||
// begins this is a file in /tmp.
|
||||
// * io_entry - The entry for the PositionIO above.
|
||||
// * io_headers - a list of attributes that will be added
|
||||
// to the message file.
|
||||
// * io_folder - The message's "folder"---may be com-
|
||||
// pletely unrelated to its on-disk Entry.
|
||||
// * io_uid - The unique ID provided by the message's
|
||||
// Protocol
|
||||
//
|
||||
// At most one Filter::ProcessMailMessage() for a given
|
||||
// chain (and thus ChainID) will be called at a time.
|
||||
|
||||
private:
|
||||
virtual void _ReservedFilter1();
|
||||
virtual void _ReservedFilter2();
|
||||
virtual void _ReservedFilter3();
|
||||
virtual void _ReservedFilter4();
|
||||
};
|
||||
|
||||
//
|
||||
// The addon interface: export instantiate_mailfilter()
|
||||
// and instantiate_mailconfig() to create a Filter addon
|
||||
//
|
||||
|
||||
extern "C" _EXPORT BView* instantiate_config_panel(BMessage *settings,BMessage *metadata);
|
||||
// return a view that configures the MailProtocol or MailFilter
|
||||
// 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.
|
||||
// A note on the metadata argument: The metadata pointer is
|
||||
// guaranteed to remain valid as long as this view exists. As it is
|
||||
// a pointer to the chain's metadata, your view can save any
|
||||
// chain-global settings to it in its Archive() function. Note that
|
||||
// you must cache this pointer yourself! You will never get it again.
|
||||
// Also note that it is possible for it to be NULL.
|
||||
|
||||
extern "C" _EXPORT BMailFilter* instantiate_mailfilter(BMessage *settings,
|
||||
BMailChainRunner *runner);
|
||||
// Return a MailProtocol or MailFilter ready to do its thing,
|
||||
// based on settings produced by archiving your config panel.
|
||||
// Note that a Mail::Protocol is a Mail::Filter, so use
|
||||
// instantiate_mailfilter to start things up.
|
||||
|
||||
extern "C" _EXPORT status_t descriptive_name(BMessage *msg, char *buffer);
|
||||
// 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,107 @@
|
||||
#ifndef ZOIDBERG_MAIL_PROTOCOL_H
|
||||
#define ZOIDBERG_MAIL_PROTOCOL_H
|
||||
/* Protocol - the base class for protocol filters
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <MailAddon.h>
|
||||
|
||||
|
||||
class BHandler;
|
||||
class BStringList;
|
||||
class BMailChainRunner;
|
||||
|
||||
class BMailProtocol : public BMailFilter
|
||||
{
|
||||
public:
|
||||
BMailProtocol(BMessage* settings, BMailChainRunner *runner);
|
||||
// Open a connection based on 'settings'. 'settings' will
|
||||
// contain a persistent uint32 ChainID field. At most one
|
||||
// Protocol per ChainID will exist at a given time.
|
||||
// The constructor of Mail::Protocol initializes manifest.
|
||||
// It is your responsibility to fill in unique_ids, *and
|
||||
// to keep it updated* in the course of whatever nefarious
|
||||
// things your protocol does.
|
||||
|
||||
virtual ~BMailProtocol();
|
||||
// Close the connection and clean up. This will be cal-
|
||||
// led after FetchMessage() or FetchNewMessage() returns
|
||||
// B_TIMED_OUT or B_ERROR, or when the settings for this
|
||||
// Protocol are changed.
|
||||
|
||||
virtual status_t GetMessage(
|
||||
const char* uid,
|
||||
BPositionIO** out_file, BMessage* out_headers,
|
||||
BPath* out_folder_location
|
||||
)=0;
|
||||
// Downloads the message with id uid, writing the message's
|
||||
// RFC2822 contents to *out_file and storing any headers it
|
||||
// wants to add other than those from the message itself into
|
||||
// out_headers. It may store a path (if this type of account
|
||||
// supports folders) in *out_folder_location.
|
||||
//
|
||||
// Returns B_OK if the message is now available in out_file,
|
||||
// B_NAME_NOT_FOUND if there is no message with id 'uid' on
|
||||
// the server, or another error if the connection failed.
|
||||
//
|
||||
// B_OK will cause the message to be stored and processed.
|
||||
// B_NAME_NOT_FOUND will cause appropriate recovery to be
|
||||
// taken (if such exists) but not cause the connection to
|
||||
// be terminated. Any other error will cause anything writen
|
||||
// to be discarded and and the connection closed.
|
||||
|
||||
// OBS:
|
||||
// The Protocol may replace *out_file with a custom (read-
|
||||
// only) BPositionIO-derived object that preserves the il-
|
||||
// lusion that the message is writen to *out_file, but in
|
||||
// fact only reads from the server and writes to *out_file
|
||||
// on demand. This BPositionIO must guarantee that any
|
||||
// data returned by Read() has also been writen to *out_-
|
||||
// file. It must return a read error if reading from the
|
||||
// network or writing to *out_file fails.
|
||||
//
|
||||
// The mail_daemon will delete *out_file before invoking
|
||||
// FetchMessage() or FetchNewMessage() again.
|
||||
|
||||
virtual status_t DeleteMessage(const char* uid)=0;
|
||||
// Removes the message from the server. After this, it's
|
||||
// assumed (but not required) that GetMessage(uid,...)
|
||||
// et al will fail with B_NAME_NOT_FOUND.
|
||||
|
||||
void CheckForDeletedMessages();
|
||||
// You can call this to trigger a sweep for deleted messages.
|
||||
// Automatically called at the beginning of the chain.
|
||||
|
||||
//------MailFilter calls
|
||||
virtual status_t ProcessMailMessage
|
||||
(
|
||||
BPositionIO** io_message, BEntry* io_entry,
|
||||
BMessage* io_headers, BPath* io_folder, const char* io_uid
|
||||
);
|
||||
|
||||
protected:
|
||||
BStringList *manifest, *unique_ids;
|
||||
BMessage *settings;
|
||||
|
||||
BMailChainRunner *runner;
|
||||
private:
|
||||
inline void error_alert(const char *process, status_t error);
|
||||
virtual void _ReservedProtocol1();
|
||||
virtual void _ReservedProtocol2();
|
||||
virtual void _ReservedProtocol3();
|
||||
virtual void _ReservedProtocol4();
|
||||
virtual void _ReservedProtocol5();
|
||||
|
||||
friend class DeletePass;
|
||||
|
||||
BHandler *trash_monitor;
|
||||
BStringList *uids_on_disk;
|
||||
|
||||
uint32 _reserved[3];
|
||||
};
|
||||
|
||||
#endif // ZOIDBERG_MAIL_PROTOCOL_H
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
|
||||
#define ZOIDBERG_PROTOCOL_CONFIG_VIEW_H
|
||||
/* ProtocolConfigView - the standard config view for all protocols
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <View.h>
|
||||
|
||||
typedef enum {
|
||||
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_config_options;
|
||||
|
||||
class BMailProtocolConfigView : 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(BMessage *archive);
|
||||
|
||||
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);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
private:
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
#endif /* ZOIDBERG_PROTOCOL_CONFIG_VIEW_H */
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef ZOIDBERG_MAIL_REMOTESTORAGEPROTOCOL_H
|
||||
#define ZOIDBERG_MAIL_REMOTESTORAGEPROTOCOL_H
|
||||
/* RemoteStorageProtocol - the base class for protocol filters
|
||||
**
|
||||
** Copyright 2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <MailProtocol.h>
|
||||
#include <StringList.h>
|
||||
|
||||
class BMailRemoteStorageProtocol : public BMailProtocol {
|
||||
public:
|
||||
BMailRemoteStorageProtocol(BMessage *settings, BMailChainRunner *runner);
|
||||
virtual ~BMailRemoteStorageProtocol();
|
||||
|
||||
virtual status_t GetMessage(const char *mailbox, const char *message, BPositionIO **, BMessage *headers) = 0;
|
||||
virtual status_t AddMessage(const char *mailbox, BPositionIO *data, BString *id) = 0;
|
||||
|
||||
virtual status_t DeleteMessage(const char *mailbox, const char *message) = 0;
|
||||
virtual status_t CopyMessage(const char *mailbox, const char *to_mailbox, BString *message) = 0;
|
||||
|
||||
virtual status_t CreateMailbox(const char *mailbox) = 0;
|
||||
virtual status_t DeleteMailbox(const char *mailbox) = 0;
|
||||
|
||||
void SyncMailbox(const char *mailbox);
|
||||
|
||||
//----Mail::Protocol stuff
|
||||
virtual status_t GetMessage(
|
||||
const char* uid,
|
||||
BPositionIO** out_file, BMessage* out_headers,
|
||||
BPath* out_folder_location);
|
||||
virtual status_t DeleteMessage(const char* uid);
|
||||
|
||||
//---Data members
|
||||
BStringList mailboxes;
|
||||
|
||||
private:
|
||||
BHandler *handler;
|
||||
};
|
||||
|
||||
#endif // ZOIDBERG_MAIL_REMOTESTORAGEPROTOCOL_H
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef ZOIDBERG_STRING_LIST_H
|
||||
#define ZOIDBERG_STRING_LIST_H
|
||||
/* StringList - a string list implementation
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <Flattenable.h>
|
||||
|
||||
class BList;
|
||||
|
||||
class BStringList : public BFlattenable {
|
||||
public:
|
||||
BStringList();
|
||||
BStringList(const BStringList&);
|
||||
|
||||
~BStringList(void);
|
||||
|
||||
BStringList &operator=(const BStringList &from);
|
||||
|
||||
/* Flattenable stuff */
|
||||
virtual bool IsFixedSize() const; //--false for obvious reasons
|
||||
virtual type_code TypeCode() const;
|
||||
virtual ssize_t FlattenedSize() const;
|
||||
virtual status_t Flatten(void *buffer, ssize_t size) const;
|
||||
virtual bool AllowsTypeCode(type_code code) const;
|
||||
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
|
||||
|
||||
/* Adding and removing items. */
|
||||
void AddItem(const char *item);
|
||||
void AddList(const BStringList *newItems);
|
||||
bool RemoveItem(const char *item);
|
||||
void MakeEmpty();
|
||||
|
||||
/* Retrieving items. */
|
||||
const char *ItemAt(int32) const;
|
||||
int32 IndexOf(const char *) const;
|
||||
|
||||
/* Querying the list. */
|
||||
bool HasItem(const char *item) const;
|
||||
int32 CountItems() const;
|
||||
bool IsEmpty() const;
|
||||
|
||||
/* Determining differences between lists */
|
||||
void NotHere(BStringList &other_list, BStringList *results);
|
||||
void NotThere(BStringList &other_list, BStringList *results);
|
||||
|
||||
/* Useful list logic operators */
|
||||
BStringList &operator += (const char *item);
|
||||
BStringList &operator += (BStringList &list);
|
||||
|
||||
BStringList &operator -= (const char *item);
|
||||
BStringList &operator -= (BStringList &list);
|
||||
|
||||
BStringList operator | (BStringList &list);
|
||||
BStringList &operator |= (BStringList &list);
|
||||
|
||||
BStringList operator ^ (BStringList &list);
|
||||
BStringList &operator ^= (BStringList &list);
|
||||
|
||||
bool operator == (BStringList &list);
|
||||
const char *operator [] (int32 index);
|
||||
|
||||
private:
|
||||
void *_buckets[256];
|
||||
int32 _items;
|
||||
BList *_indexed;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
#endif /* ZOIDBERG_STRING_LIST_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef FILE_CONFIG_VIEW
|
||||
#define FILE_CONFIG_VIEW
|
||||
/* FileConfigView - a file configuration view for filters
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <View.h>
|
||||
#include <FilePanel.h>
|
||||
|
||||
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);
|
||||
|
||||
void SetText(const char *pathOfFile);
|
||||
const char *Text() const;
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
|
||||
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(BMessage *archive,BMessage *metadata);
|
||||
virtual status_t Archive(BMessage *into,bool deep = true) const;
|
||||
|
||||
private:
|
||||
BMessage *fMeta;
|
||||
bool fUseMeta;
|
||||
const char *fName;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
#endif /* FILE_CONFIG_VIEW */
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef ZOIDBERG_MDR_LANGUAGE_H
|
||||
#define ZOIDBERG_MDR_LANGUAGE_H
|
||||
/*
|
||||
** Mail Daemon Replacement interim International Language Macros.
|
||||
**
|
||||
** Copyright 2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
**
|
||||
** The input for the language macro system is the MDR_DIALECT define which is
|
||||
** set by the makefile (you compile a version for the desired language, it
|
||||
** can't change at run-time using this temporary internationalization system).
|
||||
** MDR_DIALECT was set to 0 for English-USA, 1 for Japanese, and other numbers
|
||||
** for other language dialects. If it's not present, we use English-USA.
|
||||
**
|
||||
** $Log: MDRLanguage.h,v $
|
||||
** Revision 1.1 2004/09/20 22:31:42 nwhitehorn
|
||||
** Imported MDR. Some code still not entirely functional -- I haven't been able to figure out how to detect SSL, so IMAP and POP have it turned off. PPP auto-detect is also not functional at the moment. Other than that, it seems to work beautifully. Packaging will come later.
|
||||
**
|
||||
** Revision 1.3 2003/02/05 22:43:17 agmsmith
|
||||
** Default language (judging by the use of "color" in the bemail
|
||||
** preferences) changed to be English-USA.
|
||||
**
|
||||
** Revision 1.2 2003/01/30 23:52:12 agmsmith
|
||||
** Initial simple language system macros done.
|
||||
**
|
||||
** Revision 1.1 2003/01/30 23:26:07 agmsmith
|
||||
** Starting to add a simplistic internationalization system for "Koki",
|
||||
** who wants to use BeMail in Japanese. It should later be replaced by
|
||||
** a more comprehensive system, but at least this one will mark out the
|
||||
** spots where translated text is needed.
|
||||
*/
|
||||
|
||||
#define MDR_DIALECT_ENGLISH_USA 0
|
||||
#define MDR_DIALECT_JAPANESE 1
|
||||
|
||||
#ifndef MDR_DIALECT
|
||||
#define MDR_DIALECT MDR_DIALECT_ENGLISH_USA
|
||||
#endif
|
||||
|
||||
#if (MDR_DIALECT == MDR_DIALECT_ENGLISH_USA)
|
||||
#define MDR_DIALECT_CHOICE(EnglishUSA,Japanese) EnglishUSA
|
||||
#define MDR_COUNTRY "United States of America"
|
||||
#define MDR_LANGUAGE "English"
|
||||
#elif (MDR_DIALECT == MDR_DIALECT_JAPANESE)
|
||||
#define MDR_DIALECT_CHOICE(EnglishUSA,Japanese) Japanese
|
||||
#define MDR_COUNTRY "Japan"
|
||||
#define MDR_LANGUAGE "Japanese"
|
||||
#else
|
||||
#error "Unrecognized value specified for MDR_DIALECT macro constant."
|
||||
#endif
|
||||
|
||||
#endif /* ZOIDBERG_MDR_LANGUAGE_H */
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef ZOIDBERG_GARGOYLE_NODE_MESSAGE_H
|
||||
#define ZOIDBERG_GARGOYLE_NODE_MESSAGE_H
|
||||
/* NodeMessage - "streaming" interface and support functions for BNodes
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
These functions gives a nice BMessage interface to node attributes,
|
||||
by letting you transfer attributes to and from BMessages. It makes
|
||||
it so you can use all the convenient Find...() and Add...() functions
|
||||
provided by BMessage for attributes too. You use it as follows:
|
||||
|
||||
BMessage m;
|
||||
BNode n(path);
|
||||
if (reading) { n>>m; printf("woohoo=%s\n",m.FindString("woohoo")) }
|
||||
else { m.AddString("woohoo","it's howdy doody time"); n<<m; }
|
||||
|
||||
If there is more than one data item with a given name, the first
|
||||
item is the one writen to the node.
|
||||
*/
|
||||
|
||||
#include <Node.h>
|
||||
#include <Message.h>
|
||||
|
||||
#ifdef B_BEOS_VERSION_DANO
|
||||
#define _IMPEXP_MAIL
|
||||
#endif
|
||||
|
||||
_IMPEXP_MAIL BNode& operator<<(BNode& n, const BMessage& m);
|
||||
_IMPEXP_MAIL BNode& operator>>(BNode& n, BMessage& m);
|
||||
inline const BMessage& operator>>(const BMessage& m, BNode& n){n<<m;return m;}
|
||||
inline BMessage& operator<<( BMessage& m, BNode& n){n>>m;return m;}
|
||||
|
||||
#endif /* ZOIDBERG_GARGOYLE_NODE_MESSAGE_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef ZOIDBERG_CRYPT_H
|
||||
#define ZOIDBERG_CRYPT_H
|
||||
/* crypt - simple encryption algorithm used for passwords
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#define PASSWORD_LENGTH 32
|
||||
|
||||
|
||||
char *get_passwd(BMessage *msg,const char *name);
|
||||
bool set_passwd(BMessage *msg,const char *name,const char *password);
|
||||
|
||||
void passwd_crypt(char *in,char *out,int length);
|
||||
|
||||
#endif /* ZOIDBERG_CRYPT_H */
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef ZOIDBERG_DES_H
|
||||
#define ZOIDBERG_DES_H
|
||||
/* DES - encryption algorithm, removed double and triple DES
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
/* des.h - adapted from d3des.h:
|
||||
*
|
||||
* Headers and defines for d3des.c
|
||||
* Graven Imagery, 1992.
|
||||
*
|
||||
* Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
|
||||
* (GEnie : OUTER; CIS : [71755,204])
|
||||
*/
|
||||
|
||||
#define DES_ENCRYPT 0 /* MODE == encrypt */
|
||||
#define DES_DECRYPT 1 /* MODE == decrypt */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void des_setkey(unsigned char *, short);
|
||||
/* hexkey[8] MODE
|
||||
* Sets the internal key register according to the hexadecimal
|
||||
* key contained in the 8 bytes of hexkey, according to the DES,
|
||||
* for encryption or decryption according to MODE.
|
||||
*/
|
||||
|
||||
extern void des_usekey(unsigned long *);
|
||||
/* cookedkey[32]
|
||||
* Loads the internal key register with the data in cookedkey.
|
||||
*/
|
||||
|
||||
extern void des_cpkey(unsigned long *);
|
||||
/* cookedkey[32]
|
||||
* Copies the contents of the internal key register into the storage
|
||||
* located at &cookedkey[0].
|
||||
*/
|
||||
|
||||
extern void des_crypt(unsigned char *, unsigned char *);
|
||||
/* from[8] to[8]
|
||||
* Encrypts/Decrypts (according to the key currently loaded in the
|
||||
* internal key register) one block of eight bytes at address 'from'
|
||||
* into the block at address 'to'. They can be the same.
|
||||
*/
|
||||
|
||||
extern void des_encrypt(char *from,char *to);
|
||||
extern void des_decrypt(char *from,int fromLength,char *to);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZOIDBERG_DES_H */
|
||||
@@ -0,0 +1,85 @@
|
||||
#ifndef ZOIDBERG_GARGOYLE_MAIL_UTIL_H
|
||||
#define ZOIDBERG_GARGOYLE_MAIL_UTIL_H
|
||||
/* mail util - header parsing
|
||||
**
|
||||
** Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class BString;
|
||||
|
||||
// The next couple of functions are our wrapper around convert_to_utf8 and
|
||||
// convert_from_utf8 so that they can also convert from UTF-8 to UTF-8 by
|
||||
// specifying the MDR_UTF8_CONVERSION constant as the conversion operation.
|
||||
|
||||
status_t mail_convert_to_utf8(uint32 srcEncoding, const char *src,
|
||||
int32 *srcLen, char *dst, int32 *dstLen, int32 *state,
|
||||
char substitute = B_SUBSTITUTE);
|
||||
|
||||
status_t mail_convert_from_utf8(uint32 dstEncoding, const char *src,
|
||||
int32 *srcLen, char *dst, int32 *dstLen, int32 *state,
|
||||
char substitute = B_SUBSTITUTE);
|
||||
|
||||
|
||||
void trim_white_space(BString &string);
|
||||
// Remove leading and trailing white space from the string.
|
||||
|
||||
void SubjectToThread(BString &string);
|
||||
// Convert a subject to the core words (remove the extraneous RE: re: etc).
|
||||
|
||||
time_t ParseDateWithTimeZone(const char *DateString);
|
||||
// Converts a date to a time. Handles time zones too, unlike parsedate.
|
||||
|
||||
ssize_t rfc2047_to_utf8(char **buffer, size_t *bufLen, size_t strLen = 0);
|
||||
ssize_t utf8_to_rfc2047(char **bufp, ssize_t length,uint32 charset, char encoding);
|
||||
// convert (in place) RFC 2047-style escape sequences ("=?...?.?...?=")
|
||||
// in the first strLen characters of *buffer into UTF-8, and return the
|
||||
// length of the converted string or an error code less than 0 on error.
|
||||
//
|
||||
// This may cause the string to grow. If it grows bigger than *bufLen,
|
||||
// *buffer will be reallocated using realloc(), and its new length stored
|
||||
// in *bufLen.
|
||||
//
|
||||
// Unidentified charsets and conversion errors cause
|
||||
// the offending text to be skipped.
|
||||
|
||||
void FoldLineAtWhiteSpaceAndAddCRLF (BString &string);
|
||||
// Insert CRLF at various spots in the given string (before white space) so
|
||||
// that the line length is mostly under 78 bytes. Also makes sure there is a
|
||||
// CRLF at the very end.
|
||||
|
||||
ssize_t nextfoldedline(const char** header, char **buffer, size_t *buflen);
|
||||
ssize_t readfoldedline(FILE *file, char **buffer, size_t *buflen);
|
||||
ssize_t readfoldedline(BPositionIO &in, char **buffer, size_t *buflen);
|
||||
// Return in *buffer a \n-terminated line (even if the original is \r\n
|
||||
// terminated or not terminated at all (last line in file situation)) from a
|
||||
// memory buffer, FILE* or BPositionIO, after folding \r?\n(\s)->$1. Return
|
||||
// the length of the folded string directly, or a negative error code if there
|
||||
// was a memory allocation error or file read error. It will return zero only
|
||||
// when trying to read at end of file. *header, *file and &in are left
|
||||
// pointing to the first character after the line read.
|
||||
//
|
||||
// if buffer is not NULL return a pointer to the buffer in *buffer
|
||||
// if *buffer is not NULL, use the preallocated buffer, though it may get
|
||||
// realloc'd (so use malloc to allocate it and expect to have your *buffer
|
||||
// pointer modified to point to the new buffer if a realloc happens).
|
||||
// if buflen is not NULL, return the final size of the buffer in buflen
|
||||
// if buffer is not NULL, buflen is not NULL, and *buffer is not NULL
|
||||
// *buffer is a buffer of size *buflen
|
||||
// if buffer is NULL or *buffer is NULL, and buflen is not NULL then
|
||||
// start with a buffer of size *buflen
|
||||
|
||||
status_t parse_header(BMessage &headers, BPositionIO &input);
|
||||
|
||||
void extract_address(BString &address);
|
||||
// retrieves the mail address only from an address header formatted field
|
||||
|
||||
void extract_address_name(BString &address);
|
||||
// Given a header field (usually the From: e-mail address) with gobbledygook in
|
||||
// it, find the longest human-readable phrase (usually the person's name).
|
||||
|
||||
void get_address_list(BList &list, const char *string, void (*cleanupFunc)(BString &) = NULL);
|
||||
|
||||
#endif /* ZOIDBERG_GARGOYLE_MAIL_UTIL_H */
|
||||
@@ -0,0 +1,606 @@
|
||||
/* Definitions for data structures and routines for the regular
|
||||
expression library, version 0.12.
|
||||
Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* BeOS PPC has no regex in libroot */
|
||||
#if !__POWERPC__
|
||||
# include <posix/regex.h>
|
||||
#else
|
||||
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1
|
||||
|
||||
#ifdef __BEOS__
|
||||
# undef __STDC__
|
||||
# define __STDC__ 1
|
||||
#endif
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* POSIX says that <sys/types.h> must be included (by the caller) before
|
||||
<regex.h>. */
|
||||
|
||||
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
|
||||
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
|
||||
should be there. */
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* The following two types have to be signed and unsigned integer type
|
||||
wide enough to hold a value of a pointer. For most ANSI compilers
|
||||
ptrdiff_t and size_t should be likely OK. Still size of these two
|
||||
types is 2 for Microsoft C. Ugh... */
|
||||
typedef long int s_reg_t;
|
||||
typedef unsigned long int active_reg_t;
|
||||
|
||||
/* The following bits are used to determine the regexp syntax we
|
||||
recognize. The set/not-set meanings are chosen so that Emacs syntax
|
||||
remains the value 0. The bits are given in alphabetical order, and
|
||||
the definitions shifted by one from the previous bit; thus, when we
|
||||
add or remove a bit, only one other definition need change. */
|
||||
typedef unsigned long int reg_syntax_t;
|
||||
|
||||
/* If this bit is not set, then \ inside a bracket expression is literal.
|
||||
If set, then such a \ quotes the following character. */
|
||||
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
|
||||
|
||||
/* If this bit is not set, then + and ? are operators, and \+ and \? are
|
||||
literals.
|
||||
If set, then \+ and \? are operators and + and ? are literals. */
|
||||
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
|
||||
|
||||
/* If this bit is set, then character classes are supported. They are:
|
||||
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
|
||||
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
|
||||
If not set, then character classes are not supported. */
|
||||
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
|
||||
|
||||
/* If this bit is set, then ^ and $ are always anchors (outside bracket
|
||||
expressions, of course).
|
||||
If this bit is not set, then it depends:
|
||||
^ is an anchor if it is at the beginning of a regular
|
||||
expression or after an open-group or an alternation operator;
|
||||
$ is an anchor if it is at the end of a regular expression, or
|
||||
before a close-group or an alternation operator.
|
||||
|
||||
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
|
||||
POSIX draft 11.2 says that * etc. in leading positions is undefined.
|
||||
We already implemented a previous draft which made those constructs
|
||||
invalid, though, so we haven't changed the code back. */
|
||||
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
|
||||
|
||||
/* If this bit is set, then special characters are always special
|
||||
regardless of where they are in the pattern.
|
||||
If this bit is not set, then special characters are special only in
|
||||
some contexts; otherwise they are ordinary. Specifically,
|
||||
* + ? and intervals are only special when not after the beginning,
|
||||
open-group, or alternation operator. */
|
||||
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
|
||||
|
||||
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
|
||||
immediately after an alternation or begin-group operator. */
|
||||
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . matches newline.
|
||||
If not set, then it doesn't. */
|
||||
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . doesn't match NUL.
|
||||
If not set, then it does. */
|
||||
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, nonmatching lists [^...] do not match newline.
|
||||
If not set, they do. */
|
||||
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
|
||||
|
||||
/* If this bit is set, either \{...\} or {...} defines an
|
||||
interval, depending on RE_NO_BK_BRACES.
|
||||
If not set, \{, \}, {, and } are literals. */
|
||||
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, +, ? and | aren't recognized as operators.
|
||||
If not set, they are. */
|
||||
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
|
||||
|
||||
/* If this bit is set, newline is an alternation operator.
|
||||
If not set, newline is literal. */
|
||||
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
|
||||
|
||||
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
|
||||
are literals.
|
||||
If not set, then `\{...\}' defines an interval. */
|
||||
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
|
||||
|
||||
/* If this bit is set, (...) defines a group, and \( and \) are literals.
|
||||
If not set, \(...\) defines a group, and ( and ) are literals. */
|
||||
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
|
||||
|
||||
/* If this bit is set, then \<digit> matches <digit>.
|
||||
If not set, then \<digit> is a back-reference. */
|
||||
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
|
||||
|
||||
/* If this bit is set, then | is an alternation operator, and \| is literal.
|
||||
If not set, then \| is an alternation operator, and | is literal. */
|
||||
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
|
||||
|
||||
/* If this bit is set, then an ending range point collating higher
|
||||
than the starting range point, as in [z-a], is invalid.
|
||||
If not set, then when ending range point collates higher than the
|
||||
starting range point, the range is ignored. */
|
||||
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
|
||||
|
||||
/* If this bit is set, then an unmatched ) is ordinary.
|
||||
If not set, then an unmatched ) is invalid. */
|
||||
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
|
||||
|
||||
/* If this bit is set, succeed as soon as we match the whole pattern,
|
||||
without further backtracking. */
|
||||
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
|
||||
|
||||
/* If this bit is set, do not process the GNU regex operators.
|
||||
If not set, then the GNU regex operators are recognized. */
|
||||
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
|
||||
|
||||
/* If this bit is set, turn on internal regex debugging.
|
||||
If not set, and debugging was on, turn it off.
|
||||
This only works if regex.c is compiled -DDEBUG.
|
||||
We define this bit always, so that all that's needed to turn on
|
||||
debugging is to recompile regex.c; the calling code can always have
|
||||
this bit set, and it won't affect anything in the normal case. */
|
||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
||||
|
||||
/* This global variable defines the particular regexp syntax to use (for
|
||||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
already-compiled regexps. */
|
||||
extern reg_syntax_t re_syntax_options;
|
||||
|
||||
/* Define combinations of the above bits for the standard possibilities.
|
||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
||||
don't delete them!) */
|
||||
/* [[[begin syntaxes]]] */
|
||||
#define RE_SYNTAX_EMACS 0
|
||||
|
||||
#define RE_SYNTAX_AWK \
|
||||
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
|
||||
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GNU_AWK \
|
||||
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
|
||||
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
|
||||
|
||||
#define RE_SYNTAX_POSIX_AWK \
|
||||
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
|
||||
| RE_INTERVALS | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GREP \
|
||||
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
|
||||
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
|
||||
| RE_NEWLINE_ALT)
|
||||
|
||||
#define RE_SYNTAX_EGREP \
|
||||
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
|
||||
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
|
||||
| RE_NO_BK_VBAR)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EGREP \
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
|
||||
|
||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
/* Syntax bits common to both basic and extended POSIX regex syntax. */
|
||||
#define _RE_SYNTAX_POSIX_COMMON \
|
||||
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
|
||||
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
|
||||
|
||||
#define RE_SYNTAX_POSIX_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
|
||||
|
||||
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
|
||||
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
|
||||
isn't minimal, since other operators, such as \`, aren't disabled. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
|
||||
replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
/* [[[end syntaxes]]] */
|
||||
|
||||
/* Maximum number of duplicates an interval can allow. Some systems
|
||||
(erroneously) define this in other header files, but we want our
|
||||
value, so remove any previous define. */
|
||||
#ifdef RE_DUP_MAX
|
||||
# undef RE_DUP_MAX
|
||||
#endif
|
||||
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
|
||||
#define RE_DUP_MAX (0x7fff)
|
||||
|
||||
|
||||
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
|
||||
|
||||
/* If this bit is set, then use extended regular expression syntax.
|
||||
If not set, then use basic regular expression syntax. */
|
||||
#define REG_EXTENDED 1
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define REG_ICASE (REG_EXTENDED << 1)
|
||||
|
||||
/* If this bit is set, then anchors do not match at newline
|
||||
characters in the string.
|
||||
If not set, then anchors do match at newlines. */
|
||||
#define REG_NEWLINE (REG_ICASE << 1)
|
||||
|
||||
/* If this bit is set, then report only success or fail in regexec.
|
||||
If not set, then returns differ between not matching and errors. */
|
||||
#define REG_NOSUB (REG_NEWLINE << 1)
|
||||
|
||||
|
||||
/* POSIX `eflags' bits (i.e., information for regexec). */
|
||||
|
||||
/* If this bit is set, then the beginning-of-line operator doesn't match
|
||||
the beginning of the string (presumably because it's not the
|
||||
beginning of a line).
|
||||
If not set, then the beginning-of-line operator does match the
|
||||
beginning of the string. */
|
||||
#define REG_NOTBOL 1
|
||||
|
||||
/* Like REG_NOTBOL, except for the end-of-line. */
|
||||
#define REG_NOTEOL (1 << 1)
|
||||
|
||||
|
||||
/* If any error codes are removed, changed, or added, update the
|
||||
`re_error_msg' table in regex.c. */
|
||||
typedef enum
|
||||
{
|
||||
#ifdef _XOPEN_SOURCE
|
||||
REG_ENOSYS = -1, /* This will never happen for this implementation. */
|
||||
#endif
|
||||
|
||||
REG_NOERROR = 0, /* Success. */
|
||||
REG_NOMATCH, /* Didn't find a match (for regexec). */
|
||||
|
||||
/* POSIX regcomp return error codes. (In the order listed in the
|
||||
standard.) */
|
||||
REG_BADPAT, /* Invalid pattern. */
|
||||
REG_ECOLLATE, /* Not implemented. */
|
||||
REG_ECTYPE, /* Invalid character class name. */
|
||||
REG_EESCAPE, /* Trailing backslash. */
|
||||
REG_ESUBREG, /* Invalid back reference. */
|
||||
REG_EBRACK, /* Unmatched left bracket. */
|
||||
REG_EPAREN, /* Parenthesis imbalance. */
|
||||
REG_EBRACE, /* Unmatched \{. */
|
||||
REG_BADBR, /* Invalid contents of \{\}. */
|
||||
REG_ERANGE, /* Invalid range end. */
|
||||
REG_ESPACE, /* Ran out of memory. */
|
||||
REG_BADRPT, /* No preceding re for repetition op. */
|
||||
|
||||
/* Error codes we've added. */
|
||||
REG_EEND, /* Premature end. */
|
||||
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
|
||||
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
|
||||
} reg_errcode_t;
|
||||
|
||||
/* This data structure represents a compiled pattern. Before calling
|
||||
the pattern compiler, the fields `buffer', `allocated', `fastmap',
|
||||
`translate', and `no_sub' can be set. After the pattern has been
|
||||
compiled, the `re_nsub' field is available. All other fields are
|
||||
private to the regex routines. */
|
||||
|
||||
#ifndef RE_TRANSLATE_TYPE
|
||||
# define RE_TRANSLATE_TYPE char *
|
||||
#endif
|
||||
|
||||
struct re_pattern_buffer
|
||||
{
|
||||
/* [[[begin pattern_buffer]]] */
|
||||
/* Space that holds the compiled pattern. It is declared as
|
||||
`unsigned char *' because its elements are
|
||||
sometimes used as array indexes. */
|
||||
unsigned char *buffer;
|
||||
|
||||
/* Number of bytes to which `buffer' points. */
|
||||
unsigned long int allocated;
|
||||
|
||||
/* Number of bytes actually used in `buffer'. */
|
||||
unsigned long int used;
|
||||
|
||||
/* Syntax setting with which the pattern was compiled. */
|
||||
reg_syntax_t syntax;
|
||||
|
||||
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
|
||||
the fastmap, if there is one, to skip over impossible
|
||||
starting points for matches. */
|
||||
char *fastmap;
|
||||
|
||||
/* Either a translate table to apply to all characters before
|
||||
comparing them, or zero for no translation. The translation
|
||||
is applied to a pattern when it is compiled and to a string
|
||||
when it is matched. */
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
|
||||
/* Number of subexpressions found by the compiler. */
|
||||
size_t re_nsub;
|
||||
|
||||
/* Zero if this pattern cannot match the empty string, one else.
|
||||
Well, in truth it's used only in `re_search_2', to see
|
||||
whether or not we should use the fastmap, so we don't set
|
||||
this absolutely perfectly; see `re_compile_fastmap' (the
|
||||
`duplicate' case). */
|
||||
#if LITTLE_ENDIAN
|
||||
unsigned can_be_null : 1;
|
||||
|
||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
||||
If REGS_REALLOCATE, reallocate space if necessary.
|
||||
If REGS_FIXED, use what's there. */
|
||||
#define REGS_UNALLOCATED 0
|
||||
#define REGS_REALLOCATE 1
|
||||
#define REGS_FIXED 2
|
||||
unsigned regs_allocated : 2;
|
||||
|
||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
||||
by `re_compile_fastmap' if it updates the fastmap. */
|
||||
unsigned fastmap_accurate : 1;
|
||||
|
||||
/* If set, `re_match_2' does not return information about
|
||||
subexpressions. */
|
||||
unsigned no_sub : 1;
|
||||
|
||||
/* If set, a beginning-of-line anchor doesn't match at the
|
||||
beginning of the string. */
|
||||
unsigned not_bol : 1;
|
||||
|
||||
/* Similarly for an end-of-line anchor. */
|
||||
unsigned not_eol : 1;
|
||||
|
||||
/* If true, an anchor at a newline matches. */
|
||||
unsigned newline_anchor : 1;
|
||||
#else
|
||||
/* If true, an anchor at a newline matches. */
|
||||
unsigned newline_anchor : 1;
|
||||
|
||||
/* Similarly for an end-of-line anchor. */
|
||||
unsigned not_eol : 1;
|
||||
|
||||
/* If set, a beginning-of-line anchor doesn't match at the
|
||||
beginning of the string. */
|
||||
unsigned not_bol : 1;
|
||||
|
||||
/* If set, `re_match_2' does not return information about
|
||||
subexpressions. */
|
||||
unsigned no_sub : 1;
|
||||
|
||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
||||
by `re_compile_fastmap' if it updates the fastmap. */
|
||||
unsigned fastmap_accurate : 1;
|
||||
|
||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
||||
If REGS_REALLOCATE, reallocate space if necessary.
|
||||
If REGS_FIXED, use what's there. */
|
||||
#define REGS_UNALLOCATED 0
|
||||
#define REGS_REALLOCATE 1
|
||||
#define REGS_FIXED 2
|
||||
unsigned regs_allocated : 2;
|
||||
|
||||
unsigned can_be_null : 1;
|
||||
#endif
|
||||
/* [[[end pattern_buffer]]] */
|
||||
};
|
||||
|
||||
typedef struct re_pattern_buffer regex_t;
|
||||
|
||||
/* Type for byte offsets within the string. POSIX mandates this. */
|
||||
typedef int regoff_t;
|
||||
|
||||
|
||||
/* This is the structure we store register match data in. See
|
||||
regex.texinfo for a full description of what registers match. */
|
||||
struct re_registers
|
||||
{
|
||||
unsigned num_regs;
|
||||
regoff_t *start;
|
||||
regoff_t *end;
|
||||
};
|
||||
|
||||
|
||||
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
|
||||
`re_match_2' returns information about at least this many registers
|
||||
the first time a `regs' structure is passed. */
|
||||
#ifndef RE_NREGS
|
||||
# define RE_NREGS 30
|
||||
#endif
|
||||
|
||||
|
||||
/* POSIX specification for registers. Aside from the different names than
|
||||
`re_registers', POSIX uses an array of structures, instead of a
|
||||
structure of arrays. */
|
||||
typedef struct
|
||||
{
|
||||
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
|
||||
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
|
||||
} regmatch_t;
|
||||
|
||||
/* Declarations for routines. */
|
||||
|
||||
/* To avoid duplicating every routine declaration -- once with a
|
||||
prototype (if we are ANSI), and once without (if we aren't) -- we
|
||||
use the following macro to declare argument types. This
|
||||
unfortunately clutters up the declarations a bit, but I think it's
|
||||
worth it. */
|
||||
|
||||
#if __STDC__
|
||||
|
||||
# define _RE_ARGS(args) args
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
# define _RE_ARGS(args) ()
|
||||
|
||||
#endif /* not __STDC__ */
|
||||
|
||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
||||
You can also simply assign to the `re_syntax_options' variable. */
|
||||
extern reg_syntax_t __re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
||||
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
||||
|
||||
/* Compile the regular expression PATTERN, with length LENGTH
|
||||
and syntax given by the global `re_syntax_options', into the buffer
|
||||
BUFFER. Return NULL if successful, and an error string if not. */
|
||||
extern const char *__re_compile_pattern
|
||||
_RE_ARGS ((const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer));
|
||||
extern const char *re_compile_pattern
|
||||
_RE_ARGS ((const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
||||
accelerate searches. Return 0 if successful and -2 if was an
|
||||
internal error. */
|
||||
extern int __re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
/* Search in the string STRING (with length LENGTH) for the pattern
|
||||
compiled into BUFFER. Start searching at position START, for RANGE
|
||||
characters. Return the starting position of the match, -1 for no
|
||||
match, or -2 for an internal error. Also return register
|
||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
||||
extern int __re_search
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range, struct re_registers *regs));
|
||||
extern int re_search
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
||||
STRING2. Also, stop searching at index START + STOP. */
|
||||
extern int __re_search_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, int range, struct re_registers *regs, int stop));
|
||||
extern int re_search_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, int range, struct re_registers *regs, int stop));
|
||||
|
||||
|
||||
/* Like `re_search', but return how many characters in STRING the regexp
|
||||
in BUFFER matched, starting at position START. */
|
||||
extern int __re_match
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs));
|
||||
extern int re_match
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
||||
extern int __re_match_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, struct re_registers *regs, int stop));
|
||||
extern int re_match_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, struct re_registers *regs, int stop));
|
||||
|
||||
|
||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
||||
ENDS. Subsequent matches using BUFFER and REGS will use this memory
|
||||
for recording register information. STARTS and ENDS must be
|
||||
allocated with malloc, and must each be at least `NUM_REGS * sizeof
|
||||
(regoff_t)' bytes long.
|
||||
|
||||
If NUM_REGS == 0, then subsequent matches should allocate their own
|
||||
register data.
|
||||
|
||||
Unless this function is called, the first search or match using
|
||||
PATTERN_BUFFER will allocate its own register data, without
|
||||
freeing the old data. */
|
||||
extern void __re_set_registers
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
||||
extern void re_set_registers
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
||||
|
||||
#ifdef _REGEX_RE_COMP
|
||||
# ifndef _CRAY
|
||||
/* 4.2 bsd compatibility. */
|
||||
extern char *re_comp _RE_ARGS ((const char *));
|
||||
extern int re_exec _RE_ARGS ((const char *));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* POSIX compatibility. */
|
||||
extern int __regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
|
||||
int __cflags));
|
||||
extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
|
||||
int __cflags));
|
||||
|
||||
extern int __regexec _RE_ARGS ((const regex_t *__preg,
|
||||
const char *__string, size_t __nmatch,
|
||||
regmatch_t __pmatch[], int __eflags));
|
||||
extern int regexec _RE_ARGS ((const regex_t *__preg,
|
||||
const char *__string, size_t __nmatch,
|
||||
regmatch_t __pmatch[], int __eflags));
|
||||
|
||||
extern size_t __regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size));
|
||||
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size));
|
||||
|
||||
extern void __regfree _RE_ARGS ((regex_t *__preg));
|
||||
extern void regfree _RE_ARGS ((regex_t *__preg));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
#endif /* regex.h */
|
||||
|
||||
#endif /* __PPC__ */
|
||||
@@ -0,0 +1,83 @@
|
||||
#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 <Box.h>
|
||||
#include <List.h>
|
||||
#include <Alert.h>
|
||||
|
||||
class BStatusBar;
|
||||
class BStringView;
|
||||
class BMailStatusView;
|
||||
|
||||
class BMailStatusWindow : public BWindow {
|
||||
public:
|
||||
BMailStatusWindow(BRect rect, const char *name, uint32 show_when);
|
||||
~BMailStatusWindow();
|
||||
|
||||
virtual void FrameMoved(BPoint origin);
|
||||
virtual void WorkspaceActivated(int32 workspace, bool active);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
BMailStatusView *NewStatusView(const char *description, bool upstream);
|
||||
void RemoveView(BMailStatusView *view);
|
||||
int32 CountVisibleItems();
|
||||
|
||||
bool HasItems(void);
|
||||
void SetShowCriterion(uint32);
|
||||
void SetDefaultMessage(const BString &message);
|
||||
|
||||
private:
|
||||
friend class BMailStatusView;
|
||||
|
||||
void SetBorderStyle(int32 look);
|
||||
void ActuallyAddStatusView(BMailStatusView *status);
|
||||
|
||||
BList fStatusViews;
|
||||
uint32 fShowMode;
|
||||
BView *fDefaultView;
|
||||
BStringView *fMessageView;
|
||||
float fMinWidth;
|
||||
float fMinHeight;
|
||||
int32 fWindowMoved;
|
||||
int32 fLastWorkspace;
|
||||
BRect fFrame;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
class BMailStatusView : public BBox {
|
||||
public:
|
||||
void AddProgress(int32 how_much);
|
||||
void SetMessage(const char *msg);
|
||||
void SetMaximum(int32 max_bytes);
|
||||
int32 CountTotalItems();
|
||||
void SetTotalItems(int32 items);
|
||||
void AddItem(void);
|
||||
void Reset(bool hide = true);
|
||||
|
||||
virtual ~BMailStatusView();
|
||||
|
||||
private:
|
||||
friend class BMailStatusWindow;
|
||||
|
||||
BMailStatusView(BRect rect,const char *description,bool upstream);
|
||||
void AddSelfToWindow();
|
||||
|
||||
BStatusBar *status;
|
||||
BMailStatusWindow *window;
|
||||
int32 items_now;
|
||||
int32 total_items;
|
||||
bool is_upstream;
|
||||
bool by_bytes;
|
||||
char pre_text[255];
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
#endif /* ZOIDBERG_STATUS_WINDOW_H */
|
||||
Reference in New Issue
Block a user