-rw-r--r-- | noncore/net/mail/accountview.cpp | 18 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 19 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 129 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 98 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 54 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 7 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 21 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 129 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 98 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.h | 54 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 34 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 19 |
18 files changed, 551 insertions, 191 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 1bde886..df9fc11 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,8 +1,9 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "mailtypes.h" | ||
3 | #include "defines.h" | 4 | #include "defines.h" |
4 | 5 | ||
5 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 6 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
6 | : AccountViewItem( parent ) | 7 | : AccountViewItem( parent ) |
7 | { | 8 | { |
8 | account = a; | 9 | account = a; |
@@ -19,13 +20,13 @@ IMAPviewItem::~IMAPviewItem() | |||
19 | 20 | ||
20 | IMAPwrapper *IMAPviewItem::getWrapper() | 21 | IMAPwrapper *IMAPviewItem::getWrapper() |
21 | { | 22 | { |
22 | return wrapper; | 23 | return wrapper; |
23 | } | 24 | } |
24 | 25 | ||
25 | void IMAPviewItem::refresh(Maillist&) | 26 | void IMAPviewItem::refresh(QList<RecMail>&) |
26 | { | 27 | { |
27 | QList<IMAPFolder> *folders = wrapper->listFolders(); | 28 | QList<IMAPFolder> *folders = wrapper->listFolders(); |
28 | 29 | ||
29 | QListViewItem *child = firstChild(); | 30 | QListViewItem *child = firstChild(); |
30 | while ( child ) { | 31 | while ( child ) { |
31 | QListViewItem *tmp = child; | 32 | QListViewItem *tmp = child; |
@@ -36,12 +37,16 @@ void IMAPviewItem::refresh(Maillist&) | |||
36 | IMAPFolder *it; | 37 | IMAPFolder *it; |
37 | for ( it = folders->first(); it; it = folders->next() ) { | 38 | for ( it = folders->first(); it; it = folders->next() ) { |
38 | (void) new IMAPfolderItem( it, this ); | 39 | (void) new IMAPfolderItem( it, this ); |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
43 | RecBody IMAPviewItem::fetchBody(const RecMail&) | ||
44 | { | ||
45 | return RecBody(); | ||
46 | } | ||
42 | 47 | ||
43 | IMAPfolderItem::~IMAPfolderItem() | 48 | IMAPfolderItem::~IMAPfolderItem() |
44 | { | 49 | { |
45 | delete folder; | 50 | delete folder; |
46 | } | 51 | } |
47 | 52 | ||
@@ -51,18 +56,18 @@ IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) | |||
51 | folder = folderInit; | 56 | folder = folderInit; |
52 | imap = parent; | 57 | imap = parent; |
53 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 58 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
54 | setText( 0, folder->getDisplayName() ); | 59 | setText( 0, folder->getDisplayName() ); |
55 | } | 60 | } |
56 | 61 | ||
57 | void IMAPfolderItem::refresh(Maillist&target) | 62 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
58 | { | 63 | { |
59 | imap->getWrapper()->listMessages( folder->getName(),target ); | 64 | imap->getWrapper()->listMessages( folder->getName(),target ); |
60 | } | 65 | } |
61 | 66 | ||
62 | QString IMAPfolderItem::fetchBody(const RecMail&aMail) | 67 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
63 | { | 68 | { |
64 | return imap->getWrapper()->fetchBody(aMail); | 69 | return imap->getWrapper()->fetchBody(aMail); |
65 | } | 70 | } |
66 | 71 | ||
67 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 72 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
68 | : QListView( parent, name, flags ) | 73 | : QListView( parent, name, flags ) |
@@ -85,27 +90,26 @@ void AccountView::populate( QList<Account> list ) | |||
85 | } | 90 | } |
86 | } | 91 | } |
87 | 92 | ||
88 | void AccountView::refresh(QListViewItem *item) { | 93 | void AccountView::refresh(QListViewItem *item) { |
89 | qDebug("AccountView refresh..."); | 94 | qDebug("AccountView refresh..."); |
90 | if ( item ) { | 95 | if ( item ) { |
91 | Maillist headerlist; | 96 | QList<RecMail> headerlist; |
92 | headerlist.setAutoDelete(true); | 97 | headerlist.setAutoDelete(true); |
93 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 98 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
94 | view->refresh(headerlist); | 99 | view->refresh(headerlist); |
95 | emit refreshMailview(&headerlist); | 100 | emit refreshMailview(&headerlist); |
96 | } | 101 | } |
97 | } | 102 | } |
98 | 103 | ||
99 | void AccountView::refreshAll() | 104 | void AccountView::refreshAll() |
100 | { | 105 | { |
101 | 106 | ||
102 | } | 107 | } |
103 | 108 | ||
104 | QString AccountView::fetchBody(const RecMail&aMail) | 109 | RecBody AccountView::fetchBody(const RecMail&aMail) |
105 | { | 110 | { |
106 | QString Body; | ||
107 | QListViewItem*item = selectedItem (); | 111 | QListViewItem*item = selectedItem (); |
108 | if (!item) return Body; | 112 | if (!item) return RecBody(); |
109 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 113 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
110 | return view->fetchBody(aMail); | 114 | return view->fetchBody(aMail); |
111 | } | 115 | } |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 2bc8023..805c2b3 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,34 +1,37 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | ||
5 | 6 | ||
6 | #include "settings.h" | 7 | #include "settings.h" |
7 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
8 | 9 | ||
9 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class RecMail; | ||
12 | class RecBody; | ||
10 | 13 | ||
11 | class AccountViewItem : public QListViewItem | 14 | class AccountViewItem : public QListViewItem |
12 | { | 15 | { |
13 | 16 | ||
14 | public: | 17 | public: |
15 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 18 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
16 | AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} | 19 | AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} |
17 | virtual void refresh(Maillist&)=0; | 20 | virtual void refresh(QList<RecMail>&)=0; |
18 | virtual QString fetchBody(const RecMail&)=0; | 21 | virtual RecBody fetchBody(const RecMail&)=0; |
19 | }; | 22 | }; |
20 | 23 | ||
21 | class IMAPviewItem : public AccountViewItem | 24 | class IMAPviewItem : public AccountViewItem |
22 | { | 25 | { |
23 | 26 | ||
24 | public: | 27 | public: |
25 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 28 | IMAPviewItem( IMAPaccount *a, QListView *parent ); |
26 | ~IMAPviewItem(); | 29 | ~IMAPviewItem(); |
27 | virtual void refresh(Maillist&); | 30 | virtual void refresh(QList<RecMail>&); |
28 | virtual QString fetchBody(const RecMail&){return "";} | 31 | virtual RecBody fetchBody(const RecMail&); |
29 | IMAPwrapper *getWrapper(); | 32 | IMAPwrapper *getWrapper(); |
30 | 33 | ||
31 | private: | 34 | private: |
32 | IMAPaccount *account; | 35 | IMAPaccount *account; |
33 | IMAPwrapper *wrapper; | 36 | IMAPwrapper *wrapper; |
34 | 37 | ||
@@ -37,14 +40,14 @@ private: | |||
37 | class IMAPfolderItem : public AccountViewItem | 40 | class IMAPfolderItem : public AccountViewItem |
38 | { | 41 | { |
39 | 42 | ||
40 | public: | 43 | public: |
41 | IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); | 44 | IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); |
42 | ~IMAPfolderItem(); | 45 | ~IMAPfolderItem(); |
43 | virtual void refresh(Maillist&); | 46 | virtual void refresh(QList<RecMail>&); |
44 | virtual QString fetchBody(const RecMail&); | 47 | virtual RecBody fetchBody(const RecMail&); |
45 | 48 | ||
46 | private: | 49 | private: |
47 | IMAPFolder *folder; | 50 | IMAPFolder *folder; |
48 | IMAPviewItem *imap; | 51 | IMAPviewItem *imap; |
49 | 52 | ||
50 | }; | 53 | }; |
@@ -53,17 +56,17 @@ class AccountView : public QListView | |||
53 | { | 56 | { |
54 | Q_OBJECT | 57 | Q_OBJECT |
55 | 58 | ||
56 | public: | 59 | public: |
57 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 60 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
58 | void populate( QList<Account> list ); | 61 | void populate( QList<Account> list ); |
59 | QString fetchBody(const RecMail&aMail); | 62 | RecBody fetchBody(const RecMail&aMail); |
60 | 63 | ||
61 | public slots: | 64 | public slots: |
62 | void refreshAll(); | 65 | void refreshAll(); |
63 | void refresh(QListViewItem *item); | 66 | void refresh(QListViewItem *item); |
64 | 67 | ||
65 | signals: | 68 | signals: |
66 | void refreshMailview(Maillist*); | 69 | void refreshMailview(QList<RecMail>*); |
67 | }; | 70 | }; |
68 | 71 | ||
69 | #endif | 72 | #endif |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 1acc036..725dcc9 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -1,10 +1,11 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | #include "mailtypes.h" | ||
5 | #include <libetpan/mailimap.h> | 6 | #include <libetpan/mailimap.h> |
6 | 7 | ||
7 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
8 | { | 9 | { |
9 | account = a; | 10 | account = a; |
10 | m_imap = 0; | 11 | m_imap = 0; |
@@ -61,13 +62,13 @@ void IMAPwrapper::logout() | |||
61 | err = mailimap_logout( m_imap ); | 62 | err = mailimap_logout( m_imap ); |
62 | err = mailimap_close( m_imap ); | 63 | err = mailimap_close( m_imap ); |
63 | mailimap_free( m_imap ); | 64 | mailimap_free( m_imap ); |
64 | m_imap = 0; | 65 | m_imap = 0; |
65 | } | 66 | } |
66 | 67 | ||
67 | void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | 68 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
68 | { | 69 | { |
69 | const char *mb; | 70 | const char *mb; |
70 | int err = MAILIMAP_NO_ERROR; | 71 | int err = MAILIMAP_NO_ERROR; |
71 | clist *result; | 72 | clist *result; |
72 | clistcell *current; | 73 | clistcell *current; |
73 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; | 74 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; |
@@ -326,15 +327,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
326 | m->setFlags(mFlags); | 327 | m->setFlags(mFlags); |
327 | } | 328 | } |
328 | return m; | 329 | return m; |
329 | } | 330 | } |
330 | 331 | ||
331 | #if 1 | 332 | #if 1 |
332 | QString IMAPwrapper::fetchBody(const RecMail&mail) | 333 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
333 | { | 334 | { |
334 | QString body = ""; | 335 | RecBody body; |
336 | QString body_text; | ||
337 | |||
335 | const char *mb; | 338 | const char *mb; |
336 | int err = MAILIMAP_NO_ERROR; | 339 | int err = MAILIMAP_NO_ERROR; |
337 | clist *result; | 340 | clist *result; |
338 | clistcell *current; | 341 | clistcell *current; |
339 | mailimap_fetch_att *fetchAtt; | 342 | mailimap_fetch_att *fetchAtt; |
340 | mailimap_fetch_type *fetchType; | 343 | mailimap_fetch_type *fetchType; |
@@ -365,13 +368,14 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) | |||
365 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 368 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
366 | mailimap_msg_att * msg_att; | 369 | mailimap_msg_att * msg_att; |
367 | msg_att = (mailimap_msg_att*)current->data; | 370 | msg_att = (mailimap_msg_att*)current->data; |
368 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 371 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; |
369 | 372 | ||
370 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | 373 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { |
371 | body = item->msg_att_static->rfc822_text; | 374 | body_text = item->msg_att_static->rfc822_text; |
375 | body.setBodytext(body_text); | ||
372 | } | 376 | } |
373 | } else { | 377 | } else { |
374 | qDebug("error fetching text: %s",m_imap->response); | 378 | qDebug("error fetching text: %s",m_imap->response); |
375 | } | 379 | } |
376 | 380 | ||
377 | clist_free(result); | 381 | clist_free(result); |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index b02d26d..1423faf 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -1,24 +1,27 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | ||
4 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
5 | 6 | ||
6 | struct mailimap; | 7 | struct mailimap; |
7 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | class RecMail; | ||
10 | class RecBody; | ||
8 | 11 | ||
9 | class IMAPwrapper : public QObject | 12 | class IMAPwrapper : public QObject |
10 | { | 13 | { |
11 | Q_OBJECT | 14 | Q_OBJECT |
12 | 15 | ||
13 | public: | 16 | public: |
14 | IMAPwrapper( IMAPaccount *a ); | 17 | IMAPwrapper( IMAPaccount *a ); |
15 | virtual ~IMAPwrapper(); | 18 | virtual ~IMAPwrapper(); |
16 | QList<IMAPFolder>* listFolders(); | 19 | QList<IMAPFolder>* listFolders(); |
17 | void listMessages(const QString & mailbox,Maillist&target ); | 20 | void listMessages(const QString & mailbox,QList<RecMail>&target ); |
18 | QString fetchBody(const RecMail&mail); | 21 | RecBody fetchBody(const RecMail&mail); |
19 | static void imap_progress( size_t current, size_t maximum ); | 22 | static void imap_progress( size_t current, size_t maximum ); |
20 | 23 | ||
21 | protected: | 24 | protected: |
22 | RecMail*parse_list_result(mailimap_msg_att*); | 25 | RecMail*parse_list_result(mailimap_msg_att*); |
23 | void login(); | 26 | void login(); |
24 | void logout(); | 27 | void logout(); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 1acc036..725dcc9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,10 +1,11 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | #include "mailtypes.h" | ||
5 | #include <libetpan/mailimap.h> | 6 | #include <libetpan/mailimap.h> |
6 | 7 | ||
7 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
8 | { | 9 | { |
9 | account = a; | 10 | account = a; |
10 | m_imap = 0; | 11 | m_imap = 0; |
@@ -61,13 +62,13 @@ void IMAPwrapper::logout() | |||
61 | err = mailimap_logout( m_imap ); | 62 | err = mailimap_logout( m_imap ); |
62 | err = mailimap_close( m_imap ); | 63 | err = mailimap_close( m_imap ); |
63 | mailimap_free( m_imap ); | 64 | mailimap_free( m_imap ); |
64 | m_imap = 0; | 65 | m_imap = 0; |
65 | } | 66 | } |
66 | 67 | ||
67 | void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | 68 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
68 | { | 69 | { |
69 | const char *mb; | 70 | const char *mb; |
70 | int err = MAILIMAP_NO_ERROR; | 71 | int err = MAILIMAP_NO_ERROR; |
71 | clist *result; | 72 | clist *result; |
72 | clistcell *current; | 73 | clistcell *current; |
73 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; | 74 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; |
@@ -326,15 +327,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
326 | m->setFlags(mFlags); | 327 | m->setFlags(mFlags); |
327 | } | 328 | } |
328 | return m; | 329 | return m; |
329 | } | 330 | } |
330 | 331 | ||
331 | #if 1 | 332 | #if 1 |
332 | QString IMAPwrapper::fetchBody(const RecMail&mail) | 333 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
333 | { | 334 | { |
334 | QString body = ""; | 335 | RecBody body; |
336 | QString body_text; | ||
337 | |||
335 | const char *mb; | 338 | const char *mb; |
336 | int err = MAILIMAP_NO_ERROR; | 339 | int err = MAILIMAP_NO_ERROR; |
337 | clist *result; | 340 | clist *result; |
338 | clistcell *current; | 341 | clistcell *current; |
339 | mailimap_fetch_att *fetchAtt; | 342 | mailimap_fetch_att *fetchAtt; |
340 | mailimap_fetch_type *fetchType; | 343 | mailimap_fetch_type *fetchType; |
@@ -365,13 +368,14 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) | |||
365 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 368 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
366 | mailimap_msg_att * msg_att; | 369 | mailimap_msg_att * msg_att; |
367 | msg_att = (mailimap_msg_att*)current->data; | 370 | msg_att = (mailimap_msg_att*)current->data; |
368 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 371 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; |
369 | 372 | ||
370 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | 373 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { |
371 | body = item->msg_att_static->rfc822_text; | 374 | body_text = item->msg_att_static->rfc822_text; |
375 | body.setBodytext(body_text); | ||
372 | } | 376 | } |
373 | } else { | 377 | } else { |
374 | qDebug("error fetching text: %s",m_imap->response); | 378 | qDebug("error fetching text: %s",m_imap->response); |
375 | } | 379 | } |
376 | 380 | ||
377 | clist_free(result); | 381 | clist_free(result); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index b02d26d..1423faf 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,24 +1,27 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | ||
4 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
5 | 6 | ||
6 | struct mailimap; | 7 | struct mailimap; |
7 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | class RecMail; | ||
10 | class RecBody; | ||
8 | 11 | ||
9 | class IMAPwrapper : public QObject | 12 | class IMAPwrapper : public QObject |
10 | { | 13 | { |
11 | Q_OBJECT | 14 | Q_OBJECT |
12 | 15 | ||
13 | public: | 16 | public: |
14 | IMAPwrapper( IMAPaccount *a ); | 17 | IMAPwrapper( IMAPaccount *a ); |
15 | virtual ~IMAPwrapper(); | 18 | virtual ~IMAPwrapper(); |
16 | QList<IMAPFolder>* listFolders(); | 19 | QList<IMAPFolder>* listFolders(); |
17 | void listMessages(const QString & mailbox,Maillist&target ); | 20 | void listMessages(const QString & mailbox,QList<RecMail>&target ); |
18 | QString fetchBody(const RecMail&mail); | 21 | RecBody fetchBody(const RecMail&mail); |
19 | static void imap_progress( size_t current, size_t maximum ); | 22 | static void imap_progress( size_t current, size_t maximum ); |
20 | 23 | ||
21 | protected: | 24 | protected: |
22 | RecMail*parse_list_result(mailimap_msg_att*); | 25 | RecMail*parse_list_result(mailimap_msg_att*); |
23 | void login(); | 26 | void login(); |
24 | void logout(); | 27 | void logout(); |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp new file mode 100644 index 0000000..9f2c9e3 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -0,0 +1,129 @@ | |||
1 | #include "mailtypes.h" | ||
2 | |||
3 | |||
4 | RecMail::RecMail() | ||
5 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) | ||
6 | { | ||
7 | } | ||
8 | |||
9 | void RecMail::setTo(const QStringList&list) | ||
10 | { | ||
11 | to = list; | ||
12 | } | ||
13 | |||
14 | const QStringList&RecMail::To()const | ||
15 | { | ||
16 | return to; | ||
17 | } | ||
18 | |||
19 | void RecMail::setCC(const QStringList&list) | ||
20 | { | ||
21 | cc = list; | ||
22 | } | ||
23 | |||
24 | const QStringList&RecMail::CC()const | ||
25 | { | ||
26 | return cc; | ||
27 | } | ||
28 | |||
29 | void RecMail::setBcc(const QStringList&list) | ||
30 | { | ||
31 | bcc = list; | ||
32 | } | ||
33 | |||
34 | const QStringList& RecMail::Bcc()const | ||
35 | { | ||
36 | return bcc; | ||
37 | } | ||
38 | |||
39 | |||
40 | RecPart::RecPart() | ||
41 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding) | ||
46 | : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | RecPart::~RecPart() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | const QString& RecPart::Type()const | ||
55 | { | ||
56 | return m_type; | ||
57 | } | ||
58 | |||
59 | void RecPart::setType(const QString&type) | ||
60 | { | ||
61 | m_type = type; | ||
62 | } | ||
63 | |||
64 | const QString& RecPart::Subtype()const | ||
65 | { | ||
66 | return m_subtype; | ||
67 | } | ||
68 | |||
69 | void RecPart::setSubtype(const QString&subtype) | ||
70 | { | ||
71 | m_subtype = subtype; | ||
72 | } | ||
73 | |||
74 | const QString& RecPart::Identifier()const | ||
75 | { | ||
76 | return m_identifier; | ||
77 | } | ||
78 | |||
79 | void RecPart::setIdentifier(const QString&identifier) | ||
80 | { | ||
81 | m_identifier = identifier; | ||
82 | } | ||
83 | |||
84 | const QString& RecPart::Encoding()const | ||
85 | { | ||
86 | return m_encoding; | ||
87 | } | ||
88 | |||
89 | void RecPart::setEncoding(const QString&encoding) | ||
90 | { | ||
91 | m_encoding = encoding; | ||
92 | } | ||
93 | |||
94 | RecBody::RecBody() | ||
95 | : m_BodyText(""),m_PartsList() | ||
96 | { | ||
97 | m_PartsList.setAutoDelete(true); | ||
98 | } | ||
99 | |||
100 | RecBody::~RecBody() | ||
101 | { | ||
102 | } | ||
103 | |||
104 | void RecBody::setBodytext(const QString&bodyText) | ||
105 | { | ||
106 | m_BodyText = bodyText; | ||
107 | } | ||
108 | |||
109 | const QString& RecBody::Bodytext()const | ||
110 | { | ||
111 | return m_BodyText; | ||
112 | } | ||
113 | |||
114 | void RecBody::setParts(const QList<RecPart>&parts) | ||
115 | { | ||
116 | m_PartsList = parts; | ||
117 | m_PartsList.setAutoDelete(true); | ||
118 | } | ||
119 | |||
120 | const QList<RecPart>& RecBody::Parts()const | ||
121 | { | ||
122 | return m_PartsList; | ||
123 | } | ||
124 | |||
125 | void RecBody::addPart(const RecPart& part) | ||
126 | { | ||
127 | RecPart*p = new RecPart(part); | ||
128 | m_PartsList.append(p); | ||
129 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h new file mode 100644 index 0000000..bb6a483 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -0,0 +1,98 @@ | |||
1 | #ifndef __MAIL_TYPES_H | ||
2 | #define __MAIL_TYPES_H | ||
3 | |||
4 | #define FLAG_ANSWERED 0 | ||
5 | #define FLAG_FLAGGED 1 | ||
6 | #define FLAG_DELETED 2 | ||
7 | #define FLAG_SEEN 3 | ||
8 | #define FLAG_DRAFT 4 | ||
9 | #define FLAG_RECENT 5 | ||
10 | |||
11 | #include <qlist.h> | ||
12 | #include <qbitarray.h> | ||
13 | #include <qstring.h> | ||
14 | #include <qstringlist.h> | ||
15 | |||
16 | /* a class to describe mails in a mailbox */ | ||
17 | /* Attention! | ||
18 | From programmers point of view it would make sense to | ||
19 | store the mail body into this class, too. | ||
20 | But: not from the point of view of the device. | ||
21 | Mailbodies can be real large. So we request them when | ||
22 | needed from the mail-wrapper class direct from the server itself | ||
23 | (imap) or from a file-based cache (pop3?) | ||
24 | So there is no interface "const QString&body()" but you should | ||
25 | make a request to the mailwrapper with this class as parameter to | ||
26 | get the body. Same words for the attachments. | ||
27 | */ | ||
28 | class RecMail | ||
29 | { | ||
30 | public: | ||
31 | RecMail(); | ||
32 | virtual ~RecMail(){} | ||
33 | |||
34 | const int getNumber()const{return msg_number;} | ||
35 | void setNumber(int number){msg_number=number;} | ||
36 | const QString&getDate()const{ return date; } | ||
37 | void setDate( const QString&a ) { date = a; } | ||
38 | const QString&getFrom()const{ return from; } | ||
39 | void setFrom( const QString&a ) { from = a; } | ||
40 | const QString&getSubject()const { return subject; } | ||
41 | void setSubject( const QString&s ) { subject = s; } | ||
42 | const QString&getMbox()const{return mbox;} | ||
43 | void setMbox(const QString&box){mbox = box;} | ||
44 | |||
45 | void setTo(const QStringList&list); | ||
46 | const QStringList&To()const; | ||
47 | void setCC(const QStringList&list); | ||
48 | const QStringList&CC()const; | ||
49 | void setBcc(const QStringList&list); | ||
50 | const QStringList&Bcc()const; | ||
51 | |||
52 | const QBitArray&getFlags()const{return msg_flags;} | ||
53 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
54 | |||
55 | protected: | ||
56 | QString subject,date,from,mbox; | ||
57 | int msg_number; | ||
58 | QBitArray msg_flags; | ||
59 | QStringList to,cc,bcc; | ||
60 | }; | ||
61 | |||
62 | class RecPart | ||
63 | { | ||
64 | protected: | ||
65 | QString m_type,m_subtype,m_identifier,m_encoding; | ||
66 | public: | ||
67 | RecPart(); | ||
68 | RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64"); | ||
69 | virtual ~RecPart(); | ||
70 | |||
71 | const QString&Type()const; | ||
72 | void setType(const QString&type); | ||
73 | const QString&Subtype()const; | ||
74 | void setSubtype(const QString&subtype); | ||
75 | const QString&Identifier()const; | ||
76 | void setIdentifier(const QString&identifier); | ||
77 | const QString&Encoding()const; | ||
78 | void setEncoding(const QString&encoding); | ||
79 | }; | ||
80 | |||
81 | class RecBody | ||
82 | { | ||
83 | protected: | ||
84 | QString m_BodyText; | ||
85 | QList<RecPart> m_PartsList; | ||
86 | |||
87 | public: | ||
88 | RecBody(); | ||
89 | virtual ~RecBody(); | ||
90 | void setBodytext(const QString&); | ||
91 | const QString& Bodytext()const; | ||
92 | |||
93 | void setParts(const QList<RecPart>&parts); | ||
94 | const QList<RecPart>& Parts()const; | ||
95 | void addPart(const RecPart&part); | ||
96 | }; | ||
97 | |||
98 | #endif | ||
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 7f67cd8..898e9d6 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -624,18 +624,6 @@ void MailWrapper::sendMail( Mail mail ) | |||
624 | } | 624 | } |
625 | 625 | ||
626 | Mail::Mail() | 626 | Mail::Mail() |
627 | :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 627 | :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
628 | { | 628 | { |
629 | } | 629 | } |
630 | |||
631 | RecMail::RecMail() | ||
632 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) | ||
633 | { | ||
634 | } | ||
635 | |||
636 | #if 0 | ||
637 | void RecMail::setDate(const QString&aDate) | ||
638 | { | ||
639 | mDate = QDateTime::fromString(aDate); | ||
640 | } | ||
641 | #endif | ||
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 332034f..34fd5c5 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -28,66 +28,12 @@ public: | |||
28 | protected: | 28 | protected: |
29 | DocLnk doc; | 29 | DocLnk doc; |
30 | int size; | 30 | int size; |
31 | 31 | ||
32 | }; | 32 | }; |
33 | 33 | ||
34 | #define FLAG_ANSWERED 0 | ||
35 | #define FLAG_FLAGGED 1 | ||
36 | #define FLAG_DELETED 2 | ||
37 | #define FLAG_SEEN 3 | ||
38 | #define FLAG_DRAFT 4 | ||
39 | #define FLAG_RECENT 5 | ||
40 | |||
41 | /* a class to describe mails in a mailbox */ | ||
42 | /* Attention! | ||
43 | From programmers point of view it would make sense to | ||
44 | store the mail body into this class, too. | ||
45 | But: not from the point of view of the device. | ||
46 | Mailbodies can be real large. So we request them when | ||
47 | needed from the mail-wrapper class direct from the server itself | ||
48 | (imap) or from a file-based cache (pop3?) | ||
49 | So there is no interface "const QString&body()" but you should | ||
50 | make a request to the mailwrapper with this class as parameter to | ||
51 | get the body. Same words for the attachments. | ||
52 | */ | ||
53 | class RecMail | ||
54 | { | ||
55 | public: | ||
56 | RecMail(); | ||
57 | virtual ~RecMail(){} | ||
58 | |||
59 | const int getNumber()const{return msg_number;} | ||
60 | void setNumber(int number){msg_number=number;} | ||
61 | const QString&getDate()const{ return date; } | ||
62 | void setDate( const QString&a ) { date = a; } | ||
63 | const QString&getFrom()const{ return from; } | ||
64 | void setFrom( const QString&a ) { from = a; } | ||
65 | const QString&getSubject()const { return subject; } | ||
66 | void setSubject( const QString&s ) { subject = s; } | ||
67 | const QString&getMbox()const{return mbox;} | ||
68 | void setMbox(const QString&box){mbox = box;} | ||
69 | const QBitArray&getFlags()const{return msg_flags;} | ||
70 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
71 | |||
72 | #if 0 | ||
73 | void setDate(const QString&dstring); | ||
74 | void setDate(const QDateTime&date){mDate = date;} | ||
75 | QString getDate()const{return mDate.toString();} | ||
76 | #endif | ||
77 | protected: | ||
78 | QString subject,date,from,mbox; | ||
79 | int msg_number; | ||
80 | QBitArray msg_flags; | ||
81 | #if 0 | ||
82 | QDateTime mDate; | ||
83 | #endif | ||
84 | }; | ||
85 | |||
86 | typedef QList<RecMail> Maillist; | ||
87 | |||
88 | class Mail | 34 | class Mail |
89 | { | 35 | { |
90 | public: | 36 | public: |
91 | Mail(); | 37 | Mail(); |
92 | /* Possible that this destructor must not be declared virtual | 38 | /* Possible that this destructor must not be declared virtual |
93 | * 'cause it seems that it will never have some child classes. | 39 | * 'cause it seems that it will never have some child classes. |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 3ae1ddc..55d95ba 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -8,13 +8,15 @@ HEADERS = defines.h \ | |||
8 | composemail.h \ | 8 | composemail.h \ |
9 | accountview.h \ | 9 | accountview.h \ |
10 | mainwindow.h \ | 10 | mainwindow.h \ |
11 | viewmail.h \ | 11 | viewmail.h \ |
12 | viewmailbase.h \ | 12 | viewmailbase.h \ |
13 | opiemail.h \ | 13 | opiemail.h \ |
14 | imapwrapper.h | 14 | imapwrapper.h \ |
15 | mailtypes.h \ | ||
16 | mailistviewitem.h | ||
15 | 17 | ||
16 | SOURCES = main.cpp \ | 18 | SOURCES = main.cpp \ |
17 | opiemail.cpp \ | 19 | opiemail.cpp \ |
18 | mainwindow.cpp \ | 20 | mainwindow.cpp \ |
19 | accountview.cpp \ | 21 | accountview.cpp \ |
20 | composemail.cpp \ | 22 | composemail.cpp \ |
@@ -22,13 +24,14 @@ SOURCES = main.cpp \ | |||
22 | imapwrapper.cpp \ | 24 | imapwrapper.cpp \ |
23 | addresspicker.cpp \ | 25 | addresspicker.cpp \ |
24 | editaccounts.cpp \ | 26 | editaccounts.cpp \ |
25 | logindialog.cpp \ | 27 | logindialog.cpp \ |
26 | viewmail.cpp \ | 28 | viewmail.cpp \ |
27 | viewmailbase.cpp \ | 29 | viewmailbase.cpp \ |
28 | settings.cpp | 30 | settings.cpp \ |
31 | mailtypes.cpp | ||
29 | 32 | ||
30 | INTERFACES = editaccountsui.ui \ | 33 | INTERFACES = editaccountsui.ui \ |
31 | selectmailtypeui.ui \ | 34 | selectmailtypeui.ui \ |
32 | imapconfigui.ui \ | 35 | imapconfigui.ui \ |
33 | pop3configui.ui \ | 36 | pop3configui.ui \ |
34 | nntpconfigui.ui \ | 37 | nntpconfigui.ui \ |
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h new file mode 100644 index 0000000..60bfdda --- a/dev/null +++ b/noncore/net/mail/mailistviewitem.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef __MAILLISTVIEWITEM_H | ||
2 | #define __MAILLISTVIEWITEM_H | ||
3 | |||
4 | #include <qlistview.h> | ||
5 | #include "mailtypes.h" | ||
6 | |||
7 | class MailListViewItem:public QListViewItem | ||
8 | { | ||
9 | public: | ||
10 | MailListViewItem(QListView * parent, MailListViewItem * after ); | ||
11 | virtual ~MailListViewItem(){} | ||
12 | |||
13 | void storeData(const RecMail&data); | ||
14 | const RecMail&data()const; | ||
15 | void showEntry(); | ||
16 | |||
17 | protected: | ||
18 | RecMail mail_data; | ||
19 | }; | ||
20 | |||
21 | #endif | ||
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp new file mode 100644 index 0000000..9f2c9e3 --- a/dev/null +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -0,0 +1,129 @@ | |||
1 | #include "mailtypes.h" | ||
2 | |||
3 | |||
4 | RecMail::RecMail() | ||
5 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) | ||
6 | { | ||
7 | } | ||
8 | |||
9 | void RecMail::setTo(const QStringList&list) | ||
10 | { | ||
11 | to = list; | ||
12 | } | ||
13 | |||
14 | const QStringList&RecMail::To()const | ||
15 | { | ||
16 | return to; | ||
17 | } | ||
18 | |||
19 | void RecMail::setCC(const QStringList&list) | ||
20 | { | ||
21 | cc = list; | ||
22 | } | ||
23 | |||
24 | const QStringList&RecMail::CC()const | ||
25 | { | ||
26 | return cc; | ||
27 | } | ||
28 | |||
29 | void RecMail::setBcc(const QStringList&list) | ||
30 | { | ||
31 | bcc = list; | ||
32 | } | ||
33 | |||
34 | const QStringList& RecMail::Bcc()const | ||
35 | { | ||
36 | return bcc; | ||
37 | } | ||
38 | |||
39 | |||
40 | RecPart::RecPart() | ||
41 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding) | ||
46 | : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | RecPart::~RecPart() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | const QString& RecPart::Type()const | ||
55 | { | ||
56 | return m_type; | ||
57 | } | ||
58 | |||
59 | void RecPart::setType(const QString&type) | ||
60 | { | ||
61 | m_type = type; | ||
62 | } | ||
63 | |||
64 | const QString& RecPart::Subtype()const | ||
65 | { | ||
66 | return m_subtype; | ||
67 | } | ||
68 | |||
69 | void RecPart::setSubtype(const QString&subtype) | ||
70 | { | ||
71 | m_subtype = subtype; | ||
72 | } | ||
73 | |||
74 | const QString& RecPart::Identifier()const | ||
75 | { | ||
76 | return m_identifier; | ||
77 | } | ||
78 | |||
79 | void RecPart::setIdentifier(const QString&identifier) | ||
80 | { | ||
81 | m_identifier = identifier; | ||
82 | } | ||
83 | |||
84 | const QString& RecPart::Encoding()const | ||
85 | { | ||
86 | return m_encoding; | ||
87 | } | ||
88 | |||
89 | void RecPart::setEncoding(const QString&encoding) | ||
90 | { | ||
91 | m_encoding = encoding; | ||
92 | } | ||
93 | |||
94 | RecBody::RecBody() | ||
95 | : m_BodyText(""),m_PartsList() | ||
96 | { | ||
97 | m_PartsList.setAutoDelete(true); | ||
98 | } | ||
99 | |||
100 | RecBody::~RecBody() | ||
101 | { | ||
102 | } | ||
103 | |||
104 | void RecBody::setBodytext(const QString&bodyText) | ||
105 | { | ||
106 | m_BodyText = bodyText; | ||
107 | } | ||
108 | |||
109 | const QString& RecBody::Bodytext()const | ||
110 | { | ||
111 | return m_BodyText; | ||
112 | } | ||
113 | |||
114 | void RecBody::setParts(const QList<RecPart>&parts) | ||
115 | { | ||
116 | m_PartsList = parts; | ||
117 | m_PartsList.setAutoDelete(true); | ||
118 | } | ||
119 | |||
120 | const QList<RecPart>& RecBody::Parts()const | ||
121 | { | ||
122 | return m_PartsList; | ||
123 | } | ||
124 | |||
125 | void RecBody::addPart(const RecPart& part) | ||
126 | { | ||
127 | RecPart*p = new RecPart(part); | ||
128 | m_PartsList.append(p); | ||
129 | } | ||
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h new file mode 100644 index 0000000..bb6a483 --- a/dev/null +++ b/noncore/net/mail/mailtypes.h | |||
@@ -0,0 +1,98 @@ | |||
1 | #ifndef __MAIL_TYPES_H | ||
2 | #define __MAIL_TYPES_H | ||
3 | |||
4 | #define FLAG_ANSWERED 0 | ||
5 | #define FLAG_FLAGGED 1 | ||
6 | #define FLAG_DELETED 2 | ||
7 | #define FLAG_SEEN 3 | ||
8 | #define FLAG_DRAFT 4 | ||
9 | #define FLAG_RECENT 5 | ||
10 | |||
11 | #include <qlist.h> | ||
12 | #include <qbitarray.h> | ||
13 | #include <qstring.h> | ||
14 | #include <qstringlist.h> | ||
15 | |||
16 | /* a class to describe mails in a mailbox */ | ||
17 | /* Attention! | ||
18 | From programmers point of view it would make sense to | ||
19 | store the mail body into this class, too. | ||
20 | But: not from the point of view of the device. | ||
21 | Mailbodies can be real large. So we request them when | ||
22 | needed from the mail-wrapper class direct from the server itself | ||
23 | (imap) or from a file-based cache (pop3?) | ||
24 | So there is no interface "const QString&body()" but you should | ||
25 | make a request to the mailwrapper with this class as parameter to | ||
26 | get the body. Same words for the attachments. | ||
27 | */ | ||
28 | class RecMail | ||
29 | { | ||
30 | public: | ||
31 | RecMail(); | ||
32 | virtual ~RecMail(){} | ||
33 | |||
34 | const int getNumber()const{return msg_number;} | ||
35 | void setNumber(int number){msg_number=number;} | ||
36 | const QString&getDate()const{ return date; } | ||
37 | void setDate( const QString&a ) { date = a; } | ||
38 | const QString&getFrom()const{ return from; } | ||
39 | void setFrom( const QString&a ) { from = a; } | ||
40 | const QString&getSubject()const { return subject; } | ||
41 | void setSubject( const QString&s ) { subject = s; } | ||
42 | const QString&getMbox()const{return mbox;} | ||
43 | void setMbox(const QString&box){mbox = box;} | ||
44 | |||
45 | void setTo(const QStringList&list); | ||
46 | const QStringList&To()const; | ||
47 | void setCC(const QStringList&list); | ||
48 | const QStringList&CC()const; | ||
49 | void setBcc(const QStringList&list); | ||
50 | const QStringList&Bcc()const; | ||
51 | |||
52 | const QBitArray&getFlags()const{return msg_flags;} | ||
53 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
54 | |||
55 | protected: | ||
56 | QString subject,date,from,mbox; | ||
57 | int msg_number; | ||
58 | QBitArray msg_flags; | ||
59 | QStringList to,cc,bcc; | ||
60 | }; | ||
61 | |||
62 | class RecPart | ||
63 | { | ||
64 | protected: | ||
65 | QString m_type,m_subtype,m_identifier,m_encoding; | ||
66 | public: | ||
67 | RecPart(); | ||
68 | RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64"); | ||
69 | virtual ~RecPart(); | ||
70 | |||
71 | const QString&Type()const; | ||
72 | void setType(const QString&type); | ||
73 | const QString&Subtype()const; | ||
74 | void setSubtype(const QString&subtype); | ||
75 | const QString&Identifier()const; | ||
76 | void setIdentifier(const QString&identifier); | ||
77 | const QString&Encoding()const; | ||
78 | void setEncoding(const QString&encoding); | ||
79 | }; | ||
80 | |||
81 | class RecBody | ||
82 | { | ||
83 | protected: | ||
84 | QString m_BodyText; | ||
85 | QList<RecPart> m_PartsList; | ||
86 | |||
87 | public: | ||
88 | RecBody(); | ||
89 | virtual ~RecBody(); | ||
90 | void setBodytext(const QString&); | ||
91 | const QString& Bodytext()const; | ||
92 | |||
93 | void setParts(const QList<RecPart>&parts); | ||
94 | const QList<RecPart>& Parts()const; | ||
95 | void addPart(const RecPart&part); | ||
96 | }; | ||
97 | |||
98 | #endif | ||
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index 7f67cd8..898e9d6 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp | |||
@@ -624,18 +624,6 @@ void MailWrapper::sendMail( Mail mail ) | |||
624 | } | 624 | } |
625 | 625 | ||
626 | Mail::Mail() | 626 | Mail::Mail() |
627 | :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 627 | :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
628 | { | 628 | { |
629 | } | 629 | } |
630 | |||
631 | RecMail::RecMail() | ||
632 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) | ||
633 | { | ||
634 | } | ||
635 | |||
636 | #if 0 | ||
637 | void RecMail::setDate(const QString&aDate) | ||
638 | { | ||
639 | mDate = QDateTime::fromString(aDate); | ||
640 | } | ||
641 | #endif | ||
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h index 332034f..34fd5c5 100644 --- a/noncore/net/mail/mailwrapper.h +++ b/noncore/net/mail/mailwrapper.h | |||
@@ -28,66 +28,12 @@ public: | |||
28 | protected: | 28 | protected: |
29 | DocLnk doc; | 29 | DocLnk doc; |
30 | int size; | 30 | int size; |
31 | 31 | ||
32 | }; | 32 | }; |
33 | 33 | ||
34 | #define FLAG_ANSWERED 0 | ||
35 | #define FLAG_FLAGGED 1 | ||
36 | #define FLAG_DELETED 2 | ||
37 | #define FLAG_SEEN 3 | ||
38 | #define FLAG_DRAFT 4 | ||
39 | #define FLAG_RECENT 5 | ||
40 | |||
41 | /* a class to describe mails in a mailbox */ | ||
42 | /* Attention! | ||
43 | From programmers point of view it would make sense to | ||
44 | store the mail body into this class, too. | ||
45 | But: not from the point of view of the device. | ||
46 | Mailbodies can be real large. So we request them when | ||
47 | needed from the mail-wrapper class direct from the server itself | ||
48 | (imap) or from a file-based cache (pop3?) | ||
49 | So there is no interface "const QString&body()" but you should | ||
50 | make a request to the mailwrapper with this class as parameter to | ||
51 | get the body. Same words for the attachments. | ||
52 | */ | ||
53 | class RecMail | ||
54 | { | ||
55 | public: | ||
56 | RecMail(); | ||
57 | virtual ~RecMail(){} | ||
58 | |||
59 | const int getNumber()const{return msg_number;} | ||
60 | void setNumber(int number){msg_number=number;} | ||
61 | const QString&getDate()const{ return date; } | ||
62 | void setDate( const QString&a ) { date = a; } | ||
63 | const QString&getFrom()const{ return from; } | ||
64 | void setFrom( const QString&a ) { from = a; } | ||
65 | const QString&getSubject()const { return subject; } | ||
66 | void setSubject( const QString&s ) { subject = s; } | ||
67 | const QString&getMbox()const{return mbox;} | ||
68 | void setMbox(const QString&box){mbox = box;} | ||
69 | const QBitArray&getFlags()const{return msg_flags;} | ||
70 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
71 | |||
72 | #if 0 | ||
73 | void setDate(const QString&dstring); | ||
74 | void setDate(const QDateTime&date){mDate = date;} | ||
75 | QString getDate()const{return mDate.toString();} | ||
76 | #endif | ||
77 | protected: | ||
78 | QString subject,date,from,mbox; | ||
79 | int msg_number; | ||
80 | QBitArray msg_flags; | ||
81 | #if 0 | ||
82 | QDateTime mDate; | ||
83 | #endif | ||
84 | }; | ||
85 | |||
86 | typedef QList<RecMail> Maillist; | ||
87 | |||
88 | class Mail | 34 | class Mail |
89 | { | 35 | { |
90 | public: | 36 | public: |
91 | Mail(); | 37 | Mail(); |
92 | /* Possible that this destructor must not be declared virtual | 38 | /* Possible that this destructor must not be declared virtual |
93 | * 'cause it seems that it will never have some child classes. | 39 | * 'cause it seems that it will never have some child classes. |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 7af7d83..b25db97 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -6,12 +6,14 @@ | |||
6 | 6 | ||
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | #include "defines.h" | 9 | #include "defines.h" |
10 | #include "mainwindow.h" | 10 | #include "mainwindow.h" |
11 | #include "viewmail.h" | 11 | #include "viewmail.h" |
12 | #include "mailtypes.h" | ||
13 | #include "mailistviewitem.h" | ||
12 | 14 | ||
13 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
14 | : QMainWindow( parent, name, flags ) | 16 | : QMainWindow( parent, name, flags ) |
15 | { | 17 | { |
16 | setCaption( tr( "Opie-Mail" ) ); | 18 | setCaption( tr( "Opie-Mail" ) ); |
17 | setToolBarsMovable( false ); | 19 | setToolBarsMovable( false ); |
@@ -97,13 +99,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
97 | layout->setStretchFactor( folderView, 1 ); | 99 | layout->setStretchFactor( folderView, 1 ); |
98 | layout->setStretchFactor( mailView, 2 ); | 100 | layout->setStretchFactor( mailView, 2 ); |
99 | 101 | ||
100 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 102 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
101 | SLOT( displayMail( QListViewItem * ) ) ); | 103 | SLOT( displayMail( QListViewItem * ) ) ); |
102 | 104 | ||
103 | connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*))); | 105 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
104 | 106 | ||
105 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 107 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
106 | } | 108 | } |
107 | 109 | ||
108 | void MainWindow::slotAdjustColumns() | 110 | void MainWindow::slotAdjustColumns() |
109 | { | 111 | { |
@@ -126,46 +128,50 @@ void MainWindow::slotShowFolders( bool show ) | |||
126 | } else if ( !show && !folderView->isHidden() ) { | 128 | } else if ( !show && !folderView->isHidden() ) { |
127 | qDebug( "-> hiding" ); | 129 | qDebug( "-> hiding" ); |
128 | folderView->hide(); | 130 | folderView->hide(); |
129 | } | 131 | } |
130 | } | 132 | } |
131 | 133 | ||
132 | void MainWindow::refreshMailView(Maillist*list) | 134 | void MainWindow::refreshMailView(QList<RecMail>*list) |
133 | { | 135 | { |
134 | MailListViewItem*item = 0; | 136 | MailListViewItem*item = 0; |
135 | mailView->clear(); | 137 | mailView->clear(); |
136 | #if 0 | ||
137 | QFont f = mailView->getFont(); | ||
138 | QFont bf = f; | ||
139 | #endif | ||
140 | for (unsigned int i = 0; i < list->count();++i) { | 138 | for (unsigned int i = 0; i < list->count();++i) { |
141 | item = new MailListViewItem(mailView,item); | 139 | item = new MailListViewItem(mailView,item); |
142 | item->storeData(*(list->at(i))); | 140 | item->storeData(*(list->at(i))); |
143 | item->showEntry(); | 141 | item->showEntry(); |
144 | #if 0 | ||
145 | if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) { | ||
146 | item->setFont(bf); | ||
147 | } | ||
148 | #endif | ||
149 | } | 142 | } |
150 | } | 143 | } |
151 | void MainWindow::displayMail(QListViewItem*item) | 144 | void MainWindow::displayMail(QListViewItem*item) |
152 | { | 145 | { |
153 | if (!item) return; | 146 | if (!item) return; |
154 | qDebug("View mail"); | 147 | qDebug("View mail"); |
155 | RecMail mail = ((MailListViewItem*)item)->data(); | 148 | RecMail mail = ((MailListViewItem*)item)->data(); |
156 | QString body = folderView->fetchBody(mail); | 149 | RecBody body = folderView->fetchBody(mail); |
157 | 150 | ||
158 | ViewMail readMail( this ); | 151 | ViewMail readMail( this ); |
159 | readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body ); | 152 | readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body.Bodytext() ); |
160 | readMail.showMaximized(); | 153 | readMail.showMaximized(); |
161 | readMail.exec(); | 154 | readMail.exec(); |
155 | } | ||
162 | 156 | ||
163 | qDebug(body ); | 157 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) |
158 | :QListViewItem(parent,after),mail_data() | ||
159 | { | ||
164 | } | 160 | } |
165 | 161 | ||
166 | void MailListViewItem::showEntry() | 162 | void MailListViewItem::showEntry() |
167 | { | 163 | { |
168 | setText(0,mail_data.getSubject()); | 164 | setText(0,mail_data.getSubject()); |
169 | setText(1,mail_data.getFrom()); | 165 | setText(1,mail_data.getFrom()); |
170 | setText(2,mail_data.getDate()); | 166 | setText(2,mail_data.getDate()); |
171 | } | 167 | } |
168 | |||
169 | void MailListViewItem::storeData(const RecMail&data) | ||
170 | { | ||
171 | mail_data = data; | ||
172 | } | ||
173 | |||
174 | const RecMail& MailListViewItem::data()const | ||
175 | { | ||
176 | return mail_data; | ||
177 | } | ||
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index a5142ab..6c87261 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h | |||
@@ -7,25 +7,27 @@ | |||
7 | 7 | ||
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | 10 | ||
11 | #include "accountview.h" | 11 | #include "accountview.h" |
12 | 12 | ||
13 | class RecMail; | ||
14 | |||
13 | class MainWindow : public QMainWindow | 15 | class MainWindow : public QMainWindow |
14 | { | 16 | { |
15 | Q_OBJECT | 17 | Q_OBJECT |
16 | 18 | ||
17 | public: | 19 | public: |
18 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 20 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
19 | 21 | ||
20 | public slots: | 22 | public slots: |
21 | void slotAdjustColumns(); | 23 | void slotAdjustColumns(); |
22 | 24 | ||
23 | protected slots: | 25 | protected slots: |
24 | virtual void slotShowFolders( bool show ); | 26 | virtual void slotShowFolders( bool show ); |
25 | virtual void refreshMailView(Maillist*); | 27 | virtual void refreshMailView(QList<RecMail>*); |
26 | virtual void displayMail(QListViewItem*); | 28 | virtual void displayMail(QListViewItem*); |
27 | 29 | ||
28 | protected: | 30 | protected: |
29 | QToolBar *toolBar; | 31 | QToolBar *toolBar; |
30 | QMenuBar *menuBar; | 32 | QMenuBar *menuBar; |
31 | QPopupMenu *mailMenu, *settingsMenu; | 33 | QPopupMenu *mailMenu, *settingsMenu; |
@@ -33,22 +35,7 @@ protected: | |||
33 | *editSettings, *editAccounts, *syncFolders; | 35 | *editSettings, *editAccounts, *syncFolders; |
34 | AccountView *folderView; | 36 | AccountView *folderView; |
35 | QListView *mailView; | 37 | QListView *mailView; |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | class MailListViewItem:public QListViewItem | ||
40 | { | ||
41 | public: | ||
42 | MailListViewItem(QListView * parent, MailListViewItem * after ) | ||
43 | :QListViewItem(parent,after),mail_data(){} | ||
44 | virtual ~MailListViewItem(){} | ||
45 | |||
46 | void storeData(const RecMail&data){mail_data = data;} | ||
47 | const RecMail&data()const{return mail_data;} | ||
48 | void showEntry(); | ||
49 | |||
50 | protected: | ||
51 | RecMail mail_data; | ||
52 | }; | ||
53 | |||
54 | #endif | 41 | #endif |