Source Code (Use browser search to find items of interest.)

Class Index

empath'EmpathMailbox (./kdepim/empath/lib/EmpathMailbox.h:51)

class EmpathMailbox : public QObject
{
    Q_OBJECT
    
    public:
        
        enum Type { Maildir, POP3, IMAP4 };
        
        EmpathMailbox();
    
        /**
         * Create a mailbox with the specified name.
         */
        EmpathMailbox(const QString & name);

        /**
         * Copy ctor.
         */
        EmpathMailbox(const EmpathMailbox &);

        EmpathMailbox & operator = (const EmpathMailbox &);

        virtual ~EmpathMailbox();
        
        bool operator == (const EmpathMailbox & other) const
        { return id_ == other.id_; }

        // Pure virtuals.

        /**
         * Initialise.
         */
        virtual void init() = 0;
        /**
         * Trigger a config save for this box.
         */
        virtual void saveConfig() = 0;
        
        /**
         * Trigger a config read for this box.
         */
        virtual void loadConfig() = 0;
 
        /**
         * Synchronise the index for the folder specified in the url.
         */
        virtual void sync(const EmpathURL &) = 0;

        virtual RMM::RMessage retrieveMessage(const EmpathURL & url) = 0;

        virtual QString writeMessage(RMM::RMessage &, const EmpathURL & f) = 0;
        
        virtual bool removeMessage(const EmpathURL & url) = 0;
        
        virtual EmpathSuccessMap removeMessage(
            const EmpathURL & folder,
            const QStringList & messageIDList) = 0;

        virtual bool markMessage(
            const EmpathURL & url,
            EmpathIndexRecord::Status
        ) = 0;

        virtual EmpathSuccessMap markMessage(
            const EmpathURL & folder,
            const QStringList & messageIDList,
            EmpathIndexRecord::Status) = 0;

        virtual bool createFolder(const EmpathURL & url) = 0;
        virtual bool removeFolder(const EmpathURL & url) = 0;
       
    public slots:

        virtual void s_checkMail()   = 0;
        
        // End pure virtual methods
    
    public:

        void        setID(unsigned int id)  { id_ = id; }
        unsigned int    id() const          { return id_; }
        /**
         * Check if the folder with the given path exists.
         */
        bool    folderExists(const EmpathURL & folderPath);
        /**
         * Get a pointer to the folder referenced by the given url.
         */
        EmpathFolder *    folder(const EmpathURL & url);
        /**
         * Get the list of folders contained by this mailbox.
         */
        const EmpathFolderList & folderList() const { return folderList_; }
        /**
         * Set whether this mailbox uses a timer.
         */
        void setAutoCheck(bool yn);
        /**
         * Set the timer interval for this box.
         */
        void setAutoCheckInterval(unsigned int);
        /**
         * Find out whether this mailbox uses a timer.
         */
        bool autoCheck() const { return autoCheck_; }
        /**
         * Report the timer interval for this box.
         */
        unsigned int autoCheckInterval() const { return autoCheckInterval_; }
        /**
         * Get the name of this box.
         */
        QString name()    const { return url_.mailboxName(); }
        /**
         * Change the name of this box.
         */
        void setName(const QString & name);
        /**
         * Get the full url to this box.
         */
        const EmpathURL & url() const { return url_; }
        /**
         * Get the count of messages contained within all folders
         * owned by this box.
         */
        unsigned int messageCount() const;
        /**
         * Get the count of unread messages contained within all folders
         * owned by this box.
         */
        unsigned int unreadMessageCount() const;
        /**
         * Report the type of this mailbox.
         */
        Type type() const { return type_; }
        /**
         * Report the type of this mailbox as a string.
         */
        QString typeAsString() const { return typeString_; }
        /**
         * Name of the desired pixmap to represent this box.
         */
        QString     pixmapName()    const { return pixmapName_; }
        /**
         * Find out if there's any new mail ready.
         */
        bool        newMailReady()  const { return (newMessagesCount_ != 0);}
        /**
         * Count the number of new mails ready.
         */
        unsigned int    newMails()      const { return newMessagesCount_; }

    signals:

        void rename(EmpathMailbox *, const QString &);
        void updateFolderLists();
        void syncFolderLists();
        void newMailArrived();
        void mailboxChangedByExternal();
        void countUpdated(unsigned int, unsigned int);
        
    public slots:

        void s_countUpdated(unsigned int, unsigned int);
        
    protected:
        
        EmpathFolderList    folderList_;

        EmpathIndex * index_;

        EmpathURL url_;

        Type type_;
        QString typeString_;

        unsigned int newMessagesCount_;

        bool autoCheck_;
        unsigned int autoCheckInterval_;
        
        QTimer      timer_;
        QString     pixmapName_;

        unsigned int id_;
        unsigned int seq_;

    private:

        void _connectUp();
        void _runQueue();
};

#endif

// vim:ts=4:sw=4:tw=78

empath'EmpathMailbox::EmpathMailbox() (./kdepim/empath/lib/EmpathMailbox.cpp:35)

EmpathMailbox::EmpathMailbox(const QString & name)
    :   url_(name, QString::null, QString::null),
        autoCheck_(false),
        autoCheckInterval_(0)
{
    pixmapName_ = "menu-mailbox";
    
    folderList_.setAutoDelete(true);
    
    _connectUp();
}


empath'EmpathMailbox::~EmpathMailbox() (./kdepim/empath/lib/EmpathMailbox.cpp:47)

EmpathMailbox::~EmpathMailbox()
{
    // Empty.
}

    void

empath'EmpathMailbox::setAutoCheck() (./kdepim/empath/lib/EmpathMailbox.cpp:53)

EmpathMailbox::setAutoCheck(bool yn)
{
    autoCheck_ = yn;
    
    timer_.stop();
    
    if (autoCheck_)
        timer_.start(autoCheckInterval_ * 60000);
}

    void

empath'EmpathMailbox::setAutoCheckInterval() (./kdepim/empath/lib/EmpathMailbox.cpp:64)

EmpathMailbox::setAutoCheckInterval(unsigned int i)
{
    autoCheckInterval_ = i;

    if (autoCheck_) {
        timer_.stop();
        timer_.start(autoCheckInterval_ * 60000);
    }
}

    void

empath'EmpathMailbox::setName() (./kdepim/empath/lib/EmpathMailbox.cpp:75)

EmpathMailbox::setName(const QString & s) 
{
    QString oldName = url_.mailboxName();
    url_.setMailboxName(s);
    emit(rename(this, oldName));
}

    unsigned int

empath'EmpathMailbox::messageCount() (./kdepim/empath/lib/EmpathMailbox.cpp:83)

EmpathMailbox::messageCount() const
{
    unsigned int c = 0;
    
    EmpathFolderListIterator it(folderList_);
    
    for (; it.current(); ++it)
        c += it.current()->index()->count();

    return c;
}

    unsigned int

empath'EmpathMailbox::unreadMessageCount() (./kdepim/empath/lib/EmpathMailbox.cpp:96)

EmpathMailbox::unreadMessageCount() const
{
    unsigned int c = 0;
    
    EmpathFolderListIterator it(folderList_);
    
    for (; it.current(); ++it)
        c += it.current()->index()->countUnread();

    return c;
}

    void

empath'EmpathMailbox::s_countUpdated() (./kdepim/empath/lib/EmpathMailbox.cpp:109)

EmpathMailbox::s_countUpdated(unsigned int, unsigned int)
{
    emit(countUpdated(unreadMessageCount(), messageCount()));
}

    EmpathFolder *

empath'EmpathMailbox::folder() (./kdepim/empath/lib/EmpathMailbox.cpp:115)

EmpathMailbox::folder(const EmpathURL & url)
{
    QString fp(url.folderPath());

    // If the first char is '/', remove it.
    if (fp.at(0) == '/')
        fp.remove(0, 1);
    
    // If the last char is '/', remove it.
    if (fp.at(fp.length() - 1) == '/')
        fp.remove(fp.length() - 1, 1);
    
    return folderList_[fp];
}

    void

empath'EmpathMailbox::_connectUp() (./kdepim/empath/lib/EmpathMailbox.cpp:131)

EmpathMailbox::_connectUp()
{
    QObject::connect(
        empath, SIGNAL(checkMail()),
        this,   SLOT(s_checkMail()));

    QObject::connect(
        this, SIGNAL(newMailArrived()),
        empath, SLOT(s_newMailArrived()));

    QObject::connect(
        this,   SIGNAL(updateFolderLists()),
        empath, SLOT(s_updateFolderLists()));
}


// vim:ts=4:sw=4:tw=78