#ifndef MAILBOARD_H #define MAILBOARD_H 1 #include <stdio.h> #include <set> #include <list> #include "Object.h" #include "MudObject.h" //! a message, containing a data field and any number of headers. class Message : public map<string, string> { public: string data; const char *header(const char *n) const; void show(MudObject *who); }; //! a file containing a list of messages in order. class MessageFile { //! the actual messages list<Message> msg; //! the maximum id no that has ever been used for this file int maxid; //! the property that seen info for this is kept in string prop; //! the directory this is kept in string m_dir; //! the filename this is kept in string m_file; //! obtain the property const char *propname() { return prop.c_str(); } //! get the set of seen messages from /who/ set<int> get_seen(MudObject *who, int min=0); //! set the set of seen message on /who/ void set_seen(MudObject *who, const set<int> &s); //! flush the contents of this to the file. void output(); public: //! load the file MessageFile(const char *dir, const char *file); //! obtain message with index /idx/ const Message *get(int idx); //! obtain the count of messages. int count_messages(); //! obtain the count of news messages as seen by /who/ int count_new(MudObject *who); //! convert a transient (current) index to a permanent id int index2id(int); //! obtain a transient (current) index from a permanent id int id2index(int); //! show an index of this to /who/. void list_contents(MudObject *who, const char *cmd, set<int> *td=0); //! show message /which/ to /who/ bool show_message(MudObject *who, int which); //! send given message. void send_message(const char *name, const char *owner, const char *subject, const char *date, const char *data); //! delete message with given index. void delete_message(int); //! obtain the header /b/ from /which/ const char *get_header(int which, const char *b); }; //! send a mail const char *sendmail(const char *to, const char *from, const char *subject, const char*date, const char *data); #endif