-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 95 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 27 |
3 files changed, 43 insertions, 84 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 6d13a8b..1d6e901 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -90,96 +90,95 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
90 | layout->addWidget( mailView ); | 90 | layout->addWidget( mailView ); |
91 | layout->setStretchFactor( folderView, 1 ); | 91 | layout->setStretchFactor( folderView, 1 ); |
92 | layout->setStretchFactor( mailView, 2 ); | 92 | layout->setStretchFactor( mailView, 2 ); |
93 | 93 | ||
94 | slotAdjustLayout(); | 94 | slotAdjustLayout(); |
95 | 95 | ||
96 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 96 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
97 | SLOT( displayMail( QListViewItem * ) ) ); | 97 | SLOT( displayMail( QListViewItem * ) ) ); |
98 | 98 | ||
99 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 99 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
100 | 100 | ||
101 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 101 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | void MainWindow::slotAdjustLayout() { | 105 | void MainWindow::slotAdjustLayout() { |
106 | 106 | ||
107 | QWidget *d = QApplication::desktop(); | 107 | QWidget *d = QApplication::desktop(); |
108 | 108 | ||
109 | if ( d->width() < d->height() ) { | 109 | if ( d->width() < d->height() ) { |
110 | layout->setDirection( QBoxLayout::TopToBottom ); | 110 | layout->setDirection( QBoxLayout::TopToBottom ); |
111 | } else { | 111 | } else { |
112 | layout->setDirection( QBoxLayout::LeftToRight ); | 112 | layout->setDirection( QBoxLayout::LeftToRight ); |
113 | } | 113 | } |
114 | delete d; | 114 | delete d; |
115 | } | 115 | } |
116 | 116 | ||
117 | void MainWindow::slotAdjustColumns() | 117 | void MainWindow::slotAdjustColumns() |
118 | { | 118 | { |
119 | bool hidden = folderView->isHidden(); | 119 | bool hidden = folderView->isHidden(); |
120 | if ( hidden ) folderView->show(); | 120 | if ( hidden ) folderView->show(); |
121 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 121 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
122 | if ( hidden ) folderView->hide(); | 122 | if ( hidden ) folderView->hide(); |
123 | 123 | ||
124 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); | 124 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); |
125 | mailView->setColumnWidth( 1, 80 ); | 125 | mailView->setColumnWidth( 1, 80 ); |
126 | mailView->setColumnWidth( 2, 50 ); | 126 | mailView->setColumnWidth( 2, 50 ); |
127 | } | 127 | } |
128 | 128 | ||
129 | void MainWindow::slotShowFolders( bool show ) | 129 | void MainWindow::slotShowFolders( bool show ) |
130 | { | 130 | { |
131 | qDebug( "Show Folders" ); | 131 | qDebug( "Show Folders" ); |
132 | if ( show && folderView->isHidden() ) { | 132 | if ( show && folderView->isHidden() ) { |
133 | qDebug( "-> showing" ); | 133 | qDebug( "-> showing" ); |
134 | folderView->show(); | 134 | folderView->show(); |
135 | } else if ( !show && !folderView->isHidden() ) { | 135 | } else if ( !show && !folderView->isHidden() ) { |
136 | qDebug( "-> hiding" ); | 136 | qDebug( "-> hiding" ); |
137 | folderView->hide(); | 137 | folderView->hide(); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | void MainWindow::refreshMailView(QList<RecMail>*list) | 141 | void MainWindow::refreshMailView(QList<RecMail>*list) |
142 | { | 142 | { |
143 | MailListViewItem*item = 0; | 143 | MailListViewItem*item = 0; |
144 | mailView->clear(); | 144 | mailView->clear(); |
145 | for (unsigned int i = 0; i < list->count();++i) { | 145 | for (unsigned int i = 0; i < list->count();++i) { |
146 | item = new MailListViewItem(mailView,item); | 146 | item = new MailListViewItem(mailView,item); |
147 | item->storeData(*(list->at(i))); | 147 | item->storeData(*(list->at(i))); |
148 | item->showEntry(); | 148 | item->showEntry(); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | void MainWindow::displayMail(QListViewItem*item) | 151 | void MainWindow::displayMail(QListViewItem*item) |
152 | { | 152 | { |
153 | if (!item) return; | 153 | if (!item) return; |
154 | qDebug("View mail"); | ||
155 | RecMail mail = ((MailListViewItem*)item)->data(); | 154 | RecMail mail = ((MailListViewItem*)item)->data(); |
156 | RecBody body = folderView->fetchBody(mail); | 155 | RecBody body = folderView->fetchBody(mail); |
157 | 156 | ||
158 | ViewMail readMail( this ); | 157 | ViewMail readMail( this ); |
159 | 158 | readMail.setBody( body ); | |
160 | readMail.setMailInfo( mail.getFrom(), mail.To(), mail.getSubject(), mail.CC(), mail.Bcc(), mail.getDate(), body.Bodytext(), mail.Msgid() ); | 159 | readMail.setMail( mail ); |
161 | readMail.showMaximized(); | 160 | readMail.showMaximized(); |
162 | readMail.exec(); | 161 | readMail.exec(); |
163 | } | 162 | } |
164 | 163 | ||
165 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) | 164 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) |
166 | :QListViewItem(parent,after),mail_data() | 165 | :QListViewItem(parent,after),mail_data() |
167 | { | 166 | { |
168 | } | 167 | } |
169 | 168 | ||
170 | void MailListViewItem::showEntry() | 169 | void MailListViewItem::showEntry() |
171 | { | 170 | { |
172 | setText(0,mail_data.getSubject()); | 171 | setText(0,mail_data.getSubject()); |
173 | setText(1,mail_data.getFrom()); | 172 | setText(1,mail_data.getFrom()); |
174 | setText(2,mail_data.getDate()); | 173 | setText(2,mail_data.getDate()); |
175 | } | 174 | } |
176 | 175 | ||
177 | void MailListViewItem::storeData(const RecMail&data) | 176 | void MailListViewItem::storeData(const RecMail&data) |
178 | { | 177 | { |
179 | mail_data = data; | 178 | mail_data = data; |
180 | } | 179 | } |
181 | 180 | ||
182 | const RecMail& MailListViewItem::data()const | 181 | const RecMail& MailListViewItem::data()const |
183 | { | 182 | { |
184 | return mail_data; | 183 | return mail_data; |
185 | } | 184 | } |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 7969235..7b8494d 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,225 +1,196 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qapplication.h> | 4 | #include <qapplication.h> |
5 | 5 | ||
6 | #include "settings.h" | 6 | #include "settings.h" |
7 | #include "composemail.h" | 7 | #include "composemail.h" |
8 | #include "viewmail.h" | 8 | #include "viewmail.h" |
9 | 9 | ||
10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
11 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 11 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
12 | { | 12 | { |
13 | setText(0, _attachItemStore.mimeType()); | 13 | setText(0, _attachItemStore.mimeType()); |
14 | setText(1, _attachItemStore.fileName()); | 14 | setText(1, _attachItemStore.fileName()); |
15 | setText(2, _attachItemStore.description()); | 15 | setText(2, _attachItemStore.description()); |
16 | } | 16 | } |
17 | 17 | ||
18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | 18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) |
19 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 19 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
20 | { | 20 | { |
21 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
22 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
23 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
24 | } | 24 | } |
25 | 25 | ||
26 | void ViewMail::setMailInfo( const QString & from, const QStringList & to, const QString & subject, const QStringList & cc, const QStringList & bcc, const QString & date, const QString & bodytext, const QString & messageID ) { | ||
27 | 26 | ||
28 | m_mail[0] = from; | 27 | void ViewMail::setBody( RecBody body ) { |
29 | m_mail2[0] = to; | 28 | |
30 | m_mail[1] = subject; | 29 | m_mail[2] = body.Bodytext(); |
31 | m_mail2[1] = cc; | 30 | |
32 | m_mail2[2] = bcc; | 31 | } |
33 | m_mail[2] = bodytext; | 32 | |
34 | m_mail[3] = date; | 33 | void ViewMail::setMail( RecMail mail ) { |
35 | m_mail[4] = messageID; | 34 | |
35 | m_mail[0] = mail.getFrom(); | ||
36 | m_mail[1] = mail.getSubject(); | ||
37 | m_mail[3] = mail.getDate(); | ||
38 | m_mail[4] = mail.Msgid(); | ||
39 | |||
40 | m_mail2[0] = mail.To(); | ||
41 | m_mail2[1] = mail.CC(); | ||
42 | m_mail2[2] = mail.Bcc(); | ||
36 | 43 | ||
37 | setText(); | 44 | setText(); |
38 | } | 45 | } |
39 | 46 | ||
40 | 47 | ||
48 | |||
41 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 49 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
42 | : ViewMailBase(parent, name, fl), _inLoop(false) | 50 | : ViewMailBase(parent, name, fl), _inLoop(false) |
43 | { | 51 | { |
44 | _gotBody = false; | 52 | m_gotBody = false; |
45 | 53 | ||
46 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 54 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
47 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 55 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
48 | 56 | ||
49 | attachments->setEnabled(_gotBody); | 57 | attachments->setEnabled(m_gotBody); |
50 | |||
51 | //_handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | ||
52 | //connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | ||
53 | } | 58 | } |
54 | 59 | ||
55 | void ViewMail::setText() | 60 | void ViewMail::setText() |
56 | { | 61 | { |
57 | 62 | ||
58 | QString toString; | 63 | QString toString; |
59 | QString ccString; | 64 | QString ccString; |
60 | QString bccString; | 65 | QString bccString; |
61 | 66 | ||
62 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 67 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
63 | toString += (*it); | 68 | toString += (*it); |
64 | } | 69 | } |
65 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 70 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
66 | ccString += (*it); | 71 | ccString += (*it); |
67 | } | 72 | } |
68 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 73 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
69 | bccString += (*it); | 74 | bccString += (*it); |
70 | } | 75 | } |
71 | 76 | ||
72 | setCaption( caption().arg( m_mail[0] ) ); | 77 | setCaption( caption().arg( m_mail[0] ) ); |
73 | 78 | ||
74 | _mailHtml = tr( | 79 | m_mailHtml = "<html><body>" |
75 | "<html><body>" | 80 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
76 | "<div align=center><b><font color=#0000FF>%1</b></font></div>" | 81 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
77 | "<b>From:</b><font color=#6C86C0> %2</font><br>" | 82 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
78 | "<b>To:</b><font color=#6C86C0> %3</font><br>" | 83 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
79 | "%4" | 84 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
80 | "<b>Date:</b> %5<hr>" | 85 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
81 | "<font face=fixed>") | 86 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
82 | .arg( deHtml( m_mail[1] ) ) | 87 | "</td></tr></table><font face=fixed>"; |
83 | .arg( deHtml( m_mail[0] ) ) | 88 | |
84 | .arg( deHtml( toString ) ) | 89 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
85 | .arg( tr("<b>Cc:</b> %1<br>").arg( deHtml( ccString ) ) ) | ||
86 | .arg( m_mail[3] ); | ||
87 | browser->setText( QString(_mailHtml) + deHtml( m_mail[2] ) + "</font>" ); | ||
88 | // remove later in favor of a real handling | 90 | // remove later in favor of a real handling |
89 | _gotBody = true; | 91 | m_gotBody = true; |
90 | } | 92 | } |
91 | 93 | ||
92 | 94 | ||
93 | |||
94 | ViewMail::~ViewMail() | 95 | ViewMail::~ViewMail() |
95 | { | 96 | { |
96 | hide(); | 97 | hide(); |
97 | } | 98 | } |
98 | 99 | ||
99 | void ViewMail::hide() | 100 | void ViewMail::hide() |
100 | { | 101 | { |
101 | QWidget::hide(); | 102 | QWidget::hide(); |
102 | 103 | ||
103 | if (_inLoop) { | 104 | if (_inLoop) { |
104 | _inLoop = false; | 105 | _inLoop = false; |
105 | qApp->exit_loop(); | 106 | qApp->exit_loop(); |
106 | } | 107 | } |
107 | } | 108 | } |
108 | 109 | ||
109 | void ViewMail::exec() | 110 | void ViewMail::exec() |
110 | { | 111 | { |
111 | show(); | 112 | show(); |
112 | 113 | ||
113 | if (!_inLoop) { | 114 | if (!_inLoop) { |
114 | _inLoop = true; | 115 | _inLoop = true; |
115 | qApp->enter_loop(); | 116 | qApp->enter_loop(); |
116 | } | 117 | } |
117 | } | 118 | } |
118 | 119 | ||
119 | QString ViewMail::deHtml(const QString &string) | 120 | QString ViewMail::deHtml(const QString &string) |
120 | { | 121 | { |
121 | QString string_ = string; | 122 | QString string_ = string; |
122 | string_.replace(QRegExp("&"), "&"); | 123 | string_.replace(QRegExp("&"), "&"); |
123 | string_.replace(QRegExp("<"), "<"); | 124 | string_.replace(QRegExp("<"), "<"); |
124 | string_.replace(QRegExp(">"), ">"); | 125 | string_.replace(QRegExp(">"), ">"); |
125 | string_.replace(QRegExp("\\n"), "<br>"); | 126 | string_.replace(QRegExp("\\n"), "<br>"); |
126 | return string_; | 127 | return string_; |
127 | } | 128 | } |
128 | 129 | ||
129 | void ViewMail::slotReply() | 130 | void ViewMail::slotReply() |
130 | { | 131 | { |
131 | if (!_gotBody) { | 132 | if (!m_gotBody) { |
132 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 133 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
133 | return; | 134 | return; |
134 | } | 135 | } |
135 | 136 | ||
136 | QString rtext; | 137 | QString rtext; |
137 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 138 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
138 | .arg( m_mail[1] ) | 139 | .arg( m_mail[1] ) |
139 | .arg( m_mail[3] ); | 140 | .arg( m_mail[3] ); |
140 | 141 | ||
141 | QString text = m_mail[2]; | 142 | QString text = m_mail[2]; |
142 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 143 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
143 | QStringList::Iterator it; | 144 | QStringList::Iterator it; |
144 | for (it = lines.begin(); it != lines.end(); it++) { | 145 | for (it = lines.begin(); it != lines.end(); it++) { |
145 | rtext += "> " + *it + "\n"; | 146 | rtext += "> " + *it + "\n"; |
146 | } | 147 | } |
147 | rtext += "\n"; | 148 | rtext += "\n"; |
148 | 149 | ||
149 | QString prefix; | 150 | QString prefix; |
150 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 151 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
151 | else prefix = "Re: "; // no i18n on purpose | 152 | else prefix = "Re: "; // no i18n on purpose |
152 | 153 | ||
153 | Settings *settings = new Settings(); | 154 | Settings *settings = new Settings(); |
154 | ComposeMail composer( settings ,this, 0, true); | 155 | ComposeMail composer( settings ,this, 0, true); |
155 | composer.setTo( m_mail[0] ); | 156 | composer.setTo( m_mail[0] ); |
156 | composer.setSubject( "Re: " + m_mail[1] ); | 157 | composer.setSubject( "Re: " + m_mail[1] ); |
157 | composer.setMessage( rtext ); | 158 | composer.setMessage( rtext ); |
158 | composer.showMaximized(); | 159 | composer.showMaximized(); |
159 | composer.exec(); | 160 | composer.exec(); |
160 | 161 | ||
161 | qDebug ( rtext ); | ||
162 | } | 162 | } |
163 | 163 | ||
164 | void ViewMail::slotForward() | 164 | void ViewMail::slotForward() |
165 | { | 165 | { |
166 | if (!_gotBody) { | 166 | if (!m_gotBody) { |
167 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 167 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | QString ftext; | 171 | QString ftext; |
172 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 172 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
173 | .arg( m_mail[0] ); | 173 | .arg( m_mail[0] ); |
174 | if (!m_mail[3].isNull()) | 174 | if (!m_mail[3].isNull()) |
175 | ftext += QString("Date: %1\n") | 175 | ftext += QString("Date: %1\n") |
176 | .arg( m_mail[3] ); | 176 | .arg( m_mail[3] ); |
177 | if (!m_mail[0].isNull()) | 177 | if (!m_mail[0].isNull()) |
178 | ftext += QString("From: %1\n") | 178 | ftext += QString("From: %1\n") |
179 | .arg( m_mail[0] ); | 179 | .arg( m_mail[0] ); |
180 | //if (!_mail.envelope().to().toString().isNull()) | ||
181 | //ftext += QString("To: %1\n") | ||
182 | // .arg(_mail.envelope().to().toString()); | ||
183 | //if (!_mail.envelope().cc().toString().isNull()) | ||
184 | //ftext += QString("Cc: %1\n") | ||
185 | // .arg(_mail.envelope().cc().toString()); | ||
186 | if (!m_mail[1].isNull()) | 180 | if (!m_mail[1].isNull()) |
187 | ftext += QString("Subject: %1\n") | 181 | ftext += QString("Subject: %1\n") |
188 | .arg( m_mail[1] ); | 182 | .arg( m_mail[1] ); |
189 | 183 | ||
190 | ftext += QString("\n%1\n") | 184 | ftext += QString("\n%1\n") |
191 | .arg( m_mail[2]); | 185 | .arg( m_mail[2]); |
192 | 186 | ||
193 | ftext += QString("----- End forwarded message -----\n"); | 187 | ftext += QString("----- End forwarded message -----\n"); |
194 | 188 | ||
195 | qDebug( ftext ); | ||
196 | |||
197 | |||
198 | Settings *settings = new Settings(); | 189 | Settings *settings = new Settings(); |
199 | ComposeMail composer( settings ,this, 0, true); | 190 | ComposeMail composer( settings ,this, 0, true); |
200 | composer.setSubject( "Fwd: " + m_mail[1] ); | 191 | composer.setSubject( "Fwd: " + m_mail[1] ); |
201 | composer.setMessage( ftext ); | 192 | composer.setMessage( ftext ); |
202 | composer.showMaximized(); | 193 | composer.showMaximized(); |
203 | composer.exec(); | 194 | composer.exec(); |
204 | } | 195 | } |
205 | 196 | ||
206 | /* | ||
207 | void ViewMail::slotIMAPUid(IMAPResponse &response) | ||
208 | { | ||
209 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | ||
210 | |||
211 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | ||
212 | QValueList<IMAPResponseBodyPart> bodyParts; | ||
213 | bodyParts.append(response.FETCH()[0].bodyPart(0)); | ||
214 | _mail.setBodyParts(bodyParts); | ||
215 | |||
216 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); | ||
217 | |||
218 | // fillList(response.FETCH()[0].bodyStructure()); | ||
219 | |||
220 | _gotBody = true; | ||
221 | } else { | ||
222 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); | ||
223 | } | ||
224 | } | ||
225 | */ | ||
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 258c09b..61baa1d 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h | |||
@@ -1,85 +1,74 @@ | |||
1 | #ifndef VIEWMAIL_H | 1 | #ifndef VIEWMAIL_H |
2 | #define VIEWMAIL_H | 2 | #define VIEWMAIL_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | 7 | ||
8 | #include "viewmailbase.h" | 8 | #include "viewmailbase.h" |
9 | //#include "imapresponse.h" | 9 | #include "mailtypes.h" |
10 | //#include "mailtable.h" | ||
11 | 10 | ||
12 | class AttachItemStore | 11 | class AttachItemStore |
13 | { | 12 | { |
14 | public: | 13 | public: |
15 | void setMimeType(QString mimeType) { _mimeType = mimeType; } | 14 | void setMimeType(QString mimeType) { _mimeType = mimeType; } |
16 | QString mimeType() { return _mimeType; } | 15 | QString mimeType() { return _mimeType; } |
17 | void setFileName(QString fileName) { _fileName = fileName; } | 16 | void setFileName(QString fileName) { _fileName = fileName; } |
18 | QString fileName() { return _fileName; } | 17 | QString fileName() { return _fileName; } |
19 | void setDescription(QString description) { _description = description; } | 18 | void setDescription(QString description) { _description = description; } |
20 | QString description() { return _description; } | 19 | QString description() { return _description; } |
21 | void setPartNum(QString partNum) { _partNum = partNum; } | 20 | void setPartNum(QString partNum) { _partNum = partNum; } |
22 | QString partNum() { return _partNum; } | 21 | QString partNum() { return _partNum; } |
23 | 22 | ||
24 | private: | 23 | private: |
25 | QString _mimeType, _fileName, _description, _partNum; | 24 | QString _mimeType, _fileName, _description, _partNum; |
26 | 25 | ||
27 | }; | 26 | }; |
28 | 27 | ||
29 | class AttachItem : public QListViewItem | 28 | class AttachItem : public QListViewItem |
30 | { | 29 | { |
31 | public: | 30 | public: |
32 | AttachItem(QListView *parent, AttachItemStore &attachment); | 31 | AttachItem(QListView *parent, AttachItemStore &attachment); |
33 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); | 32 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); |
34 | 33 | ||
35 | AttachItemStore attachItemStore() { return _attachItemStore; } | 34 | AttachItemStore attachItemStore() { return _attachItemStore; } |
36 | 35 | ||
37 | private: | 36 | private: |
38 | AttachItemStore _attachItemStore; | 37 | AttachItemStore _attachItemStore; |
39 | 38 | ||
40 | }; | 39 | }; |
41 | 40 | ||
42 | class ViewMail : public ViewMailBase | 41 | class ViewMail : public ViewMailBase |
43 | { | 42 | { |
44 | Q_OBJECT | 43 | Q_OBJECT |
45 | 44 | ||
46 | public: | 45 | public: |
47 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 46 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
48 | ~ViewMail(); | 47 | ~ViewMail(); |
49 | 48 | ||
50 | void hide(); | 49 | void hide(); |
51 | void exec(); | 50 | void exec(); |
52 | static QString appName() { return QString::fromLatin1("mail"); } | 51 | void setMail( RecMail mail ); |
53 | void setMailInfo( const QString & from, const QStringList & to, const QString & subject, const QStringList & cc, const QStringList & bcc,const QString & date, const QString & bodytext, const QString & messageID ); | 52 | void setBody( RecBody body ); |
54 | 53 | ||
55 | protected: | 54 | protected: |
56 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); | ||
57 | QString deHtml(const QString &string); | 55 | QString deHtml(const QString &string); |
58 | 56 | ||
59 | protected slots: | 57 | protected slots: |
60 | void slotReply(); | 58 | void slotReply(); |
61 | void slotForward(); | 59 | void slotForward(); |
62 | void setText(); | 60 | void setText(); |
63 | 61 | ||
64 | //void slotIMAPUid(IMAPResponse &response); | ||
65 | |||
66 | private: | 62 | private: |
67 | bool _inLoop; | 63 | bool _inLoop; |
68 | //IMAPResponseFETCH _mail; | 64 | QString m_mailHtml; |
69 | //IMAPHandler *_handler; | 65 | bool m_gotBody; |
70 | QString _mailHtml; | 66 | |
71 | bool _gotBody; | 67 | // 0 from 1 subject 2 bodytext 3 date |
72 | |||
73 | // 0 from | ||
74 | // 1 subject | ||
75 | // 2 bodytext | ||
76 | // 3 date | ||
77 | QMap <int,QString> m_mail; | 68 | QMap <int,QString> m_mail; |
78 | // 0 to | 69 | // 0 to 1 cc 2 bcc |
79 | // 1 cc | ||
80 | // 2 bcc | ||
81 | QMap <int,QStringList> m_mail2; | 70 | QMap <int,QStringList> m_mail2; |
82 | 71 | ||
83 | }; | 72 | }; |
84 | 73 | ||
85 | #endif | 74 | #endif |