summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/mailwrapper.h
blob: 3e8b51fb4d5bc8468dfd397814fd105fbf4025b7 (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
#ifndef MAILWRAPPER_H
#define MAILWRAPPER_H

//#include <qpe/applnk.h>

#include <qbitarray.h>
#include <qdatetime.h>
#include <qfileinfo.h>
#include <kiconloader.h>

#include "settings.h"

#include <opie2/osmartpointer.h>
/*
class Attachment
{
public:
    Attachment( DocLnk lnk );
    virtual ~Attachment(){}
    const QString getFileName()const{ return doc.file(); }
    const QString getName()const{ return doc.name(); }
    const QString getMimeType()const{ return doc.type(); }
    const QPixmap getPixmap()const{ return doc.pixmap(); }
    const int getSize()const { return size; }
    DocLnk  getDocLnk() { return doc; }

protected:
    DocLnk doc;
    int size;

};
*/

class Attachment
{
public:
    Attachment( QString lnk );
    virtual ~Attachment(){}
    const QString getFileName()const{ return  doc; }
    const QString getName()const{ return QFileInfo( doc ).baseName (); }
    const QString getMimeType()const{ return QFileInfo( doc ).extension(false); }
    const QPixmap getPixmap()const{ return mPix; }
    const int getSize()const { return size; }
    QString  getDocLnk() { return doc; }

protected:
    QPixmap mPix;
    QString doc;
    int size;

};

class Mail:public Opie::Core::ORefCount
{
public:
    Mail();
    /* Possible that this destructor must not be declared virtual
     * 'cause it seems that it will never have some child classes.
     * in this case this object will not get a virtual table -> memory and
     * speed will be a little bit better?
     */
    virtual ~Mail(){}
    void addAttachment( Attachment *att ) { attList.append( att ); }
    const QList<Attachment>& getAttachments()const { return attList; }
    void removeAttachment( Attachment *att ) { attList.remove( att ); }
    const QString&getName()const { return name; }
    void setName( QString s ) { name = s; }
    const QString&getMail()const{ return mail; }
    void setMail( const QString&s ) { mail = s; }
    const QString&getTo()const{ return to; }
    void setTo( const QString&s ) { to = s; }
    const QString&getCC()const{ return cc; }
    void setCC( const QString&s ) { cc = s; }
    const QString&getBCC()const { return bcc; }
    void setBCC( const QString&s ) { bcc = s; }
    const QString&getMessage()const { return message; }
    void setMessage( const QString&s ) { message = s; }
    const QString&getSubject()const { return subject; }
    void setSubject( const QString&s ) { subject = s; }
    const QString&getReply()const{ return reply; }
    void setReply( const QString&a ) { reply = a; }
    void setInreply(const QStringList&list){m_in_reply_to = list;}
    const QStringList&Inreply()const{return m_in_reply_to;}

    void setCharset( const QString&a ) { charset= a; }
    const QString& getCharset() const { return charset; }

private:
    QList<Attachment> attList;
    QString name, mail, to, cc, bcc, reply, subject, message, charset;
    QStringList m_in_reply_to;
};

class Folder:public Opie::Core::ORefCount
{
public:
    Folder( const QString&init_name,const QString&sep );
    virtual ~Folder();
    const QString&getDisplayName()const { return nameDisplay; }
    const QString&getName()const { return name; }
    const QString&getPrefix()const{return prefix; }
    virtual bool may_select()const{return true;}
    virtual bool no_inferior()const{return true;}
    const QString&Separator()const;

protected:
    QString nameDisplay, name, separator,prefix;
};

typedef Opie::Core::OSmartPointer<Folder> FolderP;

class MHFolder : public Folder
{
public:
    MHFolder(const QString&disp_name,const QString&mbox);
    virtual ~MHFolder();
};

class IMAPFolder : public Folder
{
    public:
        IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
        virtual ~IMAPFolder();
        virtual bool may_select()const{return m_MaySelect;}
        virtual bool no_inferior()const{return m_NoInferior;}
        static QString decodeFolderName( const QString &name );
    private:
        bool m_MaySelect,m_NoInferior;
};

#endif