Re: RFC mailbox interface

After following this thread I came up with the following interface.

enum Flags {READ=1, NEW=2, TRASH=4, DRAFT=8, FLAGGED=16};
enum Type {MAILDIR=1, MBOX, MH, IMAP};

struct _Folder;
struct _Server;

typedef struct _Message {
	struct _Folder *Folder;
	Flags flags;
	//perhaps return a string instead?
	glist (*getHeaders)(const char[] hdrs);
	glist (*getAllHeaders)();
	char* (*getBody)();
	char* (*getAll)();

typedef struct _Stats {
	int New;
	int Draft;
	int Flagged;
	int Read;
	int Total;
} Stats;
typedef struct _Folder {
	Server *server;
	int (*open)();
	int (*close)();
	int (*sync)();
	Stats (*check)();

	Message* (*getMessage)(int msg);
	int (*deleteMessage)(int msg);
	int (*alterMessage)(int msg, const char data[]);
	int (*addMessage)(char data[], Flags flags);
	//using copy-in allows for vfolders
	int (*copyMessage)(int msg, Folder *src);

	glist (*findMessage)(const char srch[]);
} Folder;

typedef struct _Server {
	int (*logon)(const char server[], const char user[],
			const char passwd[]);
	int (*logoff)();

	//Type is only valid for servers that support multiple types
	int (*newFolder)(const char path[], Type type);
	//return list of available Folder paths for getFolder
	glist (*scanFolders)(const char path[]);
	Folder* (*getFolder)(const char path[]);

K. Haley <>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]