bincdrop status / Binc 1.5.x

Jerry Lundström <[email protected]> Fri, 29 Jul 2005 15:36:43 +0200
Newsgroups gmane.mail.imap.binc.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------090606010201030304070208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi all,

As I know been working on bincdrop for a week trying to get the 
functionallity to work with the binc 1.3 branch I have run into alot of 
problems.
All these problems has made me start to think about a rework of the 
classes in Binc, especally the Depot structure to make it more object 
oriented and usable in other contexts then just IMAP.

The attached document is a work-in-progress for a suggested class layout 
of future version of binc.

What I have thought about when designing the super classes is to slim 
them down to the common funtions that all (that I know) 
depot/mailbox/message should have.
After that we can add specific functions to Maildir and suchs.
I also think its is a very good idea that we start using STL to the 
fullest, for example reading raw data from a message should be a class 
with the ostream as super class. How this data in the ostream has been 
put there isnt for the others to know, it can be a fostream or a sstream 
or whatever.

As you look at the layout you will see that alot is missing but I hope 
the generall idea is there.
Also, this kind of design fits very well into a libbinc.

Please, imagen to work with it and comment... and have a nice weekend!

Cheers,
Jerry

-- 
Jerry Lundström, System Developer
Section for IT and Media, Stockholms University, Sweden
+46 (0)8 16 19 99 / http://www.it.su.se

--------------090606010201030304070208
Content-Type: text/plain;
 name="BINC-1.5.0"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="BINC-1.5.0"

// Suggested layout of BINC-1.5.0
/////////////////////////////////

#include <iostream>

// Super Class Depot
class Depot
{
public:
    Depot(const std::string &depotName);
    virtual ~Depot();

    inline const std::string &getName(void);
    inline const std::string &getLastError(void);

    virtual bool open(void);
    virtual bool close(void);
    virtual bool flush(void);
    virtual Mailbox &getMailbox(const std::string &mailboxName);
    virtual Mailbox &newMailbox(const std::string &mailboxName);
    virtual std::vector<const std::string> &mailboxes(void);
    
protected:
    std::string depot_name;
    std::string depot_lastError;
};


// Super Class Mailbox
class Mailbox
{
    friend class Depot;

public:
    virtual ~Mailbox();

    inline const std::string &getName(void);
    inline const std::string &getLastError(void);
    inline Depot &getDepot(void);

    virtual bool open(void);
    virtual bool close(void);
    virtual bool flush(void);
    virtual bool remove(void);
    virtual Message &getMessage(const std::string &messageId);
    virtual Message &newMessage(const std::string &messageId);
    virtual std::vector<const std::string> &messages(void);

protected:
    Mailbox(Depot &mailboxDepot);

    std::string mailbox_name;
    std::string mailbox_lastError;
    Depot &mailbox_depot();
};

class Mailbox
{
    class Maildir : public Mailbox
    {
    public:
        std::vector<std::string> &getUnseenMessages(void);
        const std::string &getUidValidity(void);
        const std::string &getUidNext(void);
        std::vector<const std::string> &getFlags(void);
    };

    class IMAPdir : public Mailbox
    {
    public:
        std::vector<std::string> &getUnseenMessages(void);
        const std::string &getUidValidity(void);
        const std::string &getUidNext(void);
        std::vector<const std::string> &getFlags(void);
    };
}

// Super Class Message
class Message
{
    friend class Mailbox;

public:
    virtual ~Message();

    inline const std::string &getId(void);
    inline const std::string &getLastError(void);
    inline Mailbox &getMailbox(void);

    virtual bool open(void);
    virtual bool close(void);
    virtual bool flush(void);
    virtual bool remove(void);
    virtual bool copy(Message &copyMessage);
    virtual std::istream &getIStream(void);
    virtual std::ostream &getOStream(void);
    virtual Mime &getMime(void);
    
protected:
    Message(Mailbox &messageMailbox);

    std::string message_id;
    std::string message_lastError;
    Mailbox &message_mailbox();
};

class Message
{
    class Maildir : public Message
    {
    public:
        const std::string &getFlag(const std::string &flagName);
        bool setFlag(const std::string &flagName);
        bool clearFlag(const std::string &flagName);
    };

    class IMAPdir : public Message
    {
    public:
        const std::string &getFlag(const std::string &flagName);
        bool setFlag(const std::string &flagName);
        bool clearFlag(const std::string &flagName);
    };
};

// Super Class Mime
class Mime
{
public:
    class Header : std::vector<std::string>
    {
        friend class Mime;

    public:
        virtual ~Mime();

    protected:
        Header(Mime &headerMime);

        Mime &header_mime();
    };

    Mime();
    Mime(std::istream &in); // read-only
    Mime(std::ostream &out); // write-only
    Mime(std::istream &in, std::ostream &out);
    Mime(std::iostream &in_out);
    ~Mime();

    inline const std::string &getName(void);
    inline const std::string &getLastError(void);
    inline Mime &getMimeParent(void);

    virtual bool open(void);
    virtual bool close(void);
    virtual bool flush(void);
    virtual bool remove(void);
    virtual Mime::Header &getHeader(const std::string &headerName);
    virtual Mime::Header &newHeader(const std::string &headerName);
    virtual std::vector<const std::string> &headers(void);
    virtual size_t getSize(void);
    virtual Mime &getMimeChild(const std::string &mimeName);
    virtual Mime &newMimeChild(const std::string &mimeName);
    virtual std::vector<const std::string> &mimeChildren(void);

protected:
    Mime(Mime &mimeParent);

    std::string mime_name;
    std::string mime_lastError;
    Mime &mime_parent();
    std::vector<Mime *> mime_children;
};

--------------090606010201030304070208--