Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

emailhandler.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Palmtop Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef EmailHandler_H
00021 #define EmailHandler_H
00022 
00023 #include <qobject.h>
00024 #include <qstring.h>
00025 #include <qdatetime.h>
00026 #include <qlist.h>
00027 #include <qstringlist.h>
00028 #include <qfile.h>
00029 #include <qstringlist.h>
00030 #include <qcollection.h>
00031 #include <qpe/qcopenvelope_qws.h>
00032 
00033 #include "smtpclient.h"
00034 #include "popclient.h"
00035 #include "textparser.h"
00036 #include "maillist.h"
00037 
00038 struct Enclosure
00039 {
00040   int id;
00041   QString originalName;
00042   QString name;
00043   QString path;
00044   QString contentType;
00045   QString contentAttribute;
00046   QString encoding;
00047   QString body;     //might use to much mem. check!!
00048   bool saved, installed;
00049 };
00050 
00051 class EnclosureList : public QList<Enclosure>
00052 {
00053 public:
00054   Item newItem(Item d);
00055 private:
00056   Enclosure* dupl(Enclosure *in);
00057   Enclosure *ac;
00058 };
00059 
00060 struct Email
00061 {
00062   QString id;
00063   QString from;
00064   QString fromMail;
00065   QStringList recipients;
00066   QStringList carbonCopies;
00067   QString date;
00068   QString subject;
00069   QString body;
00070   QString bodyPlain;
00071   bool sent, received, read, downloaded;
00072   QString rawMail;
00073   int mimeType;         //1 = Mime 1.0
00074   int serverId;
00075   int internalId;
00076   int fromAccountId;
00077   QString contentType;        //0 = text
00078   QString contentAttribute;     //0 = plain, 1 = html
00079   EnclosureList files;
00080   uint size;
00081   
00082   void addEnclosure(Enclosure *e)
00083   {
00084     files.append(e);
00085   }
00086 };
00087 
00088 struct MailAccount
00089 {
00090   QString accountName;
00091   QString name;
00092   QString emailAddress;
00093   QString popUserName;
00094   QString popPasswd;
00095   QString popServer;
00096   QString smtpServer;
00097   bool synchronize;
00098   int syncLimit;
00099   int lastServerMailCount;
00100   int id;
00101 };
00102 
00103   const int ErrUnknownResponse = 1001;
00104   const int ErrLoginFailed = 1002;
00105   const int ErrCancel = 1003;
00106   
00107 
00108 class EmailHandler : public QObject
00109 {
00110   Q_OBJECT
00111 
00112 public:
00113   EmailHandler();
00114   void setAccount(MailAccount account);
00115   MailAccount* getAccount(){return &mailAccount;}
00116   void sendMail(QList<Email> *mailList);
00117   void getMail();
00118   void getMailHeaders();
00119   void getMailByList(MailList *mailList);
00120   bool parse(const QString &in, const QString &lineShift, Email *mail);
00121   bool getEnclosure(Enclosure *ePtr);
00122   int parse64base(char *src, char *dest);
00123   int encodeMime(Email *mail);
00124   int encodeFile(const QString &fileName, QString *toBody);
00125   void encode64base(char *src, QString *dest, int len);
00126   void cancel();
00127   
00128 signals:
00129   void mailSent();
00130   void smtpError(int, const QString & Msg );
00131   void popError(int, const QString & Msg );
00132   void mailArrived(const Email &, bool);
00133   void updatePopStatus(const QString &);
00134   void updateSmtpStatus(const QString &);
00135   void mailTransfered(int);
00136   void mailboxSize(int);
00137   void currentMailSize(int);
00138   void downloadedSize(int);
00139 
00140 public slots:
00141   void messageArrived(const QString &, int id, uint size, bool complete);
00142   
00143 private:
00144   MailAccount mailAccount;
00145   SmtpClient *smtpClient;
00146   PopClient *popClient;
00147   bool headers;
00148 };
00149 
00150 #endif

Generated on Sat Nov 5 16:18:09 2005 for OPIE by  doxygen 1.4.2