summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/emailhandler.h
Unidiff
Diffstat (limited to 'noncore/unsupported/mailit/emailhandler.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/mailit/emailhandler.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/noncore/unsupported/mailit/emailhandler.h b/noncore/unsupported/mailit/emailhandler.h
new file mode 100644
index 0000000..17c4414
--- a/dev/null
+++ b/noncore/unsupported/mailit/emailhandler.h
@@ -0,0 +1,147 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef EmailHandler_H
21#define EmailHandler_H
22
23#include <qobject.h>
24#include <qstring.h>
25#include <qdatetime.h>
26#include <qlist.h>
27#include <qstringlist.h>
28#include <qfile.h>
29#include <qstringlist.h>
30#include <qcollection.h>
31
32#include "smtpclient.h"
33#include "popclient.h"
34#include "textparser.h"
35#include "maillist.h"
36
37struct Enclosure
38{
39 int id;
40 QString originalName;
41 QString name;
42 QString path;
43 QString contentType;
44 QString contentAttribute;
45 QString encoding;
46 QString body; //might use to much mem. check!!
47 bool saved, installed;
48};
49
50class EnclosureList : public QList<Enclosure>
51{
52public:
53 Item newItem(Item d);
54private:
55 Enclosure* dupl(Enclosure *in);
56 Enclosure *ac;
57};
58
59struct Email
60{
61 QString id;
62 QString from;
63 QString fromMail;
64 QStringList recipients;
65 QStringList carbonCopies;
66 QString date;
67 QString subject;
68 QString body;
69 QString bodyPlain;
70 bool sent, received, read, downloaded;
71 QString rawMail;
72 int mimeType; //1 = Mime 1.0
73 int serverId;
74 int internalId;
75 int fromAccountId;
76 QString contentType; //0 = text
77 QString contentAttribute; //0 = plain, 1 = html
78 EnclosureList files;
79 uint size;
80
81 void addEnclosure(Enclosure *e)
82 {
83 files.append(e);
84 }
85};
86
87struct MailAccount
88{
89 QString accountName;
90 QString name;
91 QString emailAddress;
92 QString popUserName;
93 QString popPasswd;
94 QString popServer;
95 QString smtpServer;
96 bool synchronize;
97 int lastServerMailCount;
98 int id;
99};
100
101 const int ErrUnknownResponse = 1001;
102 const int ErrLoginFailed = 1002;
103 const int ErrCancel = 1003;
104
105
106class EmailHandler : public QObject
107{
108 Q_OBJECT
109
110public:
111 EmailHandler();
112 void setAccount(MailAccount account);
113 void sendMail(QList<Email> *mailList);
114 void getMail();
115 void getMailHeaders();
116 void getMailByList(MailList *mailList);
117 bool parse(QString in, QString lineShift, Email *mail);
118 bool getEnclosure(Enclosure *ePtr);
119 int parse64base(char *src, char *dest);
120 int encodeMime(Email *mail);
121 int encodeFile(QString fileName, QString *toBody);
122 void encode64base(char *src, QString *dest, int len);
123 void cancel();
124
125signals:
126 void mailSent();
127 void smtpError(int);
128 void popError(int);
129 void mailArrived(const Email &, bool);
130 void updatePopStatus(const QString &);
131 void updateSmtpStatus(const QString &);
132 void mailTransfered(int);
133 void mailboxSize(int);
134 void currentMailSize(int);
135 void downloadedSize(int);
136
137public slots:
138 void messageArrived(const QString &, int id, uint size, bool complete);
139
140private:
141 MailAccount mailAccount;
142 SmtpClient *smtpClient;
143 PopClient *popClient;
144 bool headers;
145};
146
147#endif