/* * Copyright (C) 2015 Christian Mollekopf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #pragma once #include #include #include #include #include struct Message { qint64 uid; qint64 size; QPair attributes; QList flags; KMime::Message::Ptr msg; }; class ImapServerProxy { KIMAP::Session *mSession; public: ImapServerProxy(const QString &serverUrl, int port); //Standard IMAP calls KAsync::Job login(const QString &username, const QString &password); KAsync::Job select(const QString &mailbox); KAsync::Job append(const QString &mailbox, const QByteArray &content, const QList &flags = QList(), const QDateTime &internalDate = QDateTime()); typedef std::function &, const QMap &, const QMap &, const QMap &, const QMap &)> FetchCallback; KAsync::Job fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback); KAsync::Job list(KIMAP::ListJob::Option option, const std::function &mailboxes,const QList > &flags)> &callback); //Composed calls that do login etc. KAsync::Job> fetchHeaders(const QString &mailbox); KAsync::Future fetchFolders(std::function callback); KAsync::Future fetchMessages(const QString &folder, std::function &)> callback); };