summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/settings.h
blob: ba3ec89b5673c9e5b773b7f365b8e410a1191169 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef SETTINGS_H
#define SETTINGS_H

#include "maildefines.h"

/* OPIE */

/* QT */
#include <qobject.h>
#include <qlist.h>

class Account
{

public:
    Account();
    virtual ~Account() {}

    void remove();
    void setAccountName( QString name ) { accountName = name; }
    const QString&getAccountName()const{ return accountName; }
    MAILLIB::ATYPE getType()const{ return type; }

    void setServer(const QString&str){ server = str; }
    const QString&getServer()const{ return server; }

    void setPort(const QString&str) { port = str; }
    const QString&getPort()const{ return port; }

    void setUser(const QString&str){ user = str; }
    const QString&getUser()const{ return user; }

    void setPassword(const QString&str) { password = str; }
    const QString&getPassword()const { return password; }

    void setSSL( bool b ) { ssl = b; }
    bool getSSL() { return ssl; }

    void setConnectionType( int x ) { connectionType = x; }
    int ConnectionType() { return connectionType; }


    void setOffline(bool b) {offline = b;}
    bool getOffline()const{return offline;}

    virtual QString getFileName() { return accountName; }
    virtual void read() { ; }
    virtual void save() { ; }

protected:
    QString accountName, server, port, user, password;
    bool ssl;
    int connectionType;
    bool offline;
    MAILLIB::ATYPE type;
};

class IMAPaccount : public Account
{

public:
    IMAPaccount();
    IMAPaccount( QString filename );

    static QString getUniqueFileName();

    virtual void read();
    virtual void save();
    virtual QString getFileName();

    void setPrefix(const QString&str) {prefix=str;}
    const QString&getPrefix()const{return prefix;}

private:
    QString file,prefix;

};

class POP3account : public Account
{

public:
    POP3account();
    POP3account( QString filename );

    static QString getUniqueFileName();

    virtual void read();
    virtual void save();
    virtual QString getFileName();

private:
    QString file;

};

class SMTPaccount : public Account
{

public:
    SMTPaccount();
    SMTPaccount( QString filename );

    static QString getUniqueFileName();

    virtual void read();
    virtual void save();
    virtual QString getFileName();

    void setLogin( bool b ) { login = b; }
    bool getLogin() { return login; }

private:
    QString file, name, mail, org, cc, bcc, reply, signature;
    bool useCC, useBCC, useReply, login;

};

class NNTPaccount : public Account
{

public:
    NNTPaccount();
    NNTPaccount( QString filename );

    static QString getUniqueFileName();

    virtual void read();
    virtual void save();
    virtual QString getFileName();

    void setLogin( bool b ) { login = b; }
    bool getLogin() { return login; }

    void setGroups( QStringList list )  { subscribedGroups = list; }
    QStringList getGroups()  { return subscribedGroups; }

private:
    QString file;
    bool login;
    QStringList subscribedGroups;

};

class Settings : public QObject
{
    Q_OBJECT

public:
    Settings();
    QList<Account> getAccounts();
    void addAccount(Account *account);
    void delAccount(Account *account);
    void saveAccounts();
    void readAccounts();
    static void checkDirectory();

private:
    void updateAccounts();
    QList<Account> accounts;

};

#endif