summaryrefslogtreecommitdiff
path: root/lib/kolabaccount.h
blob: 4887370399887b4a77f6824c296c4753557566a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (C) 2012  Christian Mollekopf <mollekopf@kolabsys.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef KOLABACCOUNT_H
#define KOLABACCOUNT_H
#include <QObject>
#include <formathelpers.h>
#include <kolabobject.h>
#include <kimap/loginjob.h>
#include <kimap/listjob.h>
#include <kmime/kmime_message.h>
#include "object.h"

namespace KIMAP {
class Session;
}

class KolabAccount: public QObject
{
    Q_OBJECT
public:
    explicit KolabAccount(QObject* parent = 0);
    virtual ~KolabAccount();
    
    void setHost(const QString &host, qint16 port);
    void setCredentials(const QString &username, const QString &pw, const QString &authorizationName);
    void setEncryptionMode(KIMAP::LoginJob::EncryptionMode);
    void setAuthenticationMode(KIMAP::LoginJob::AuthenticationMode);
    bool init();

    void cleanAccount();
    void setupFolders();
    void appendObjectSync(Object obj, const QString &folder);
    KJob *appendObject(Object obj, const QString &folder);
    void createFolder(const QString &name, Kolab::FolderType folderType);
    void createFolder(const QString &name, const QByteArray &annotation);
    void setDryRun(bool);
    void setWipeTargetFolders(bool);

    KJob *logout();
    
    QList<Object> getObjects(const QString& folder);
    QStringList lookupFolderList();

    void setVersion(Kolab::Version);
    
    QString getUsername() const;
    
private slots:
    void mailBoxesReceived(const QList<KIMAP::MailBoxDescriptor> &descriptors, const QList< QList< QByteArray > > &flags);
private:
    KMime::Message::Ptr writeObject(const Object &obj);
    KIMAP::Session *mSession;
    QString mHost;
    int mPort;
    QString mAuthorizationName;
    QString mUsername;
    QString mPw;
    KIMAP::LoginJob::EncryptionMode mEncryptionMode;
    KIMAP::LoginJob::AuthenticationMode mAuthenticationMode;
    QList<KIMAP::MailBoxDescriptor> mMailboxes;
    QList<KIMAP::MailBoxDescriptor> mPersonalNamespaces;
    QList<KIMAP::MailBoxDescriptor> mExcludedNamespaces;
    QStringList mFolders;
    QStringList mCapabilities;
    bool mDryRun;
    bool mWipeTargetFolders;
    Kolab::Version mVersion;
};

#endif // KOLABACCOUNT_H