summaryrefslogtreecommitdiff
path: root/noncore/net
authorharlekin <harlekin>2003-12-09 01:05:53 (UTC)
committer harlekin <harlekin>2003-12-09 01:05:53 (UTC)
commit6142ad15ac50090b95bb5d80116c1750ffc515de (patch) (unidiff)
tree177b72b44446824d6faa13e140ab95a25c931b81 /noncore/net
parente372949ac776a7d986cac91b2ff1a5022040d43b (diff)
downloadopie-6142ad15ac50090b95bb5d80116c1750ffc515de.zip
opie-6142ad15ac50090b95bb5d80116c1750ffc515de.tar.gz
opie-6142ad15ac50090b95bb5d80116c1750ffc515de.tar.bz2
beginning of a view mail part
Diffstat (limited to 'noncore/net') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mail.pro4
-rw-r--r--noncore/net/mail/mainwindow.cpp8
-rw-r--r--noncore/net/mail/viewmail.cpp216
-rw-r--r--noncore/net/mail/viewmail.h75
-rw-r--r--noncore/net/mail/viewmailbase.cpp75
-rw-r--r--noncore/net/mail/viewmailbase.h36
6 files changed, 413 insertions, 1 deletions
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 2142cdc..3ae1ddc 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -8,6 +8,8 @@ HEADERS = defines.h \
8 composemail.h \ 8 composemail.h \
9 accountview.h \ 9 accountview.h \
10 mainwindow.h \ 10 mainwindow.h \
11 viewmail.h \
12 viewmailbase.h \
11 opiemail.h \ 13 opiemail.h \
12 imapwrapper.h 14 imapwrapper.h
13 15
@@ -21,6 +23,8 @@ SOURCES = main.cpp \
21 addresspicker.cpp \ 23 addresspicker.cpp \
22 editaccounts.cpp \ 24 editaccounts.cpp \
23 logindialog.cpp \ 25 logindialog.cpp \
26 viewmail.cpp \
27 viewmailbase.cpp \
24 settings.cpp 28 settings.cpp
25 29
26 INTERFACES = editaccountsui.ui \ 30 INTERFACES = editaccountsui.ui \
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 6f054cc..6e8f4d3 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -6,6 +6,7 @@
6 6
7#include "defines.h" 7#include "defines.h"
8#include "mainwindow.h" 8#include "mainwindow.h"
9#include "viewmail.h"
9 10
10MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 11MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
11 : QMainWindow( parent, name, flags ) 12 : QMainWindow( parent, name, flags )
@@ -138,7 +139,12 @@ void MainWindow::displayMail(QListViewItem*item)
138 RecMail mail = ((MailListViewItem*)item)->data(); 139 RecMail mail = ((MailListViewItem*)item)->data();
139 QString body = folderView->fetchBody(mail); 140 QString body = folderView->fetchBody(mail);
140 141
141 qDebug(body); 142 ViewMail readMail( this );
143 readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body );
144 readMail.showMaximized();
145 readMail.exec();
146
147 qDebug(body );
142} 148}
143 149
144void MailListViewItem::showEntry() 150void MailListViewItem::showEntry()
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
new file mode 100644
index 0000000..b648b34
--- a/dev/null
+++ b/noncore/net/mail/viewmail.cpp
@@ -0,0 +1,216 @@
1#include <qtextbrowser.h>
2#include <qmessagebox.h>
3#include <qaction.h>
4#include <qapplication.h>
5
6//#include "mailfactory.h"
7//#include "composer.h"
8#include "viewmail.h"
9
10AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore)
11 : QListViewItem(parent), _attachItemStore(attachItemStore)
12{
13 setText(0, _attachItemStore.mimeType());
14 setText(1, _attachItemStore.fileName());
15 setText(2, _attachItemStore.description());
16}
17
18AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore)
19 : QListViewItem(parent), _attachItemStore(attachItemStore)
20{
21 setText(0, _attachItemStore.mimeType());
22 setText(1, _attachItemStore.fileName());
23 setText(2, _attachItemStore.description());
24}
25
26void ViewMail::setMailInfo( const QString & from, const QString & to, const QString & subject, const QString & cc, const QString & bcc, const QString & bodytext ) {
27
28m_mail[0] = from;
29m_mail[1] = to;
30m_mail[2] = subject;
31m_mail[3] = cc;
32m_mail[4] = bcc;
33m_mail[5] = bodytext;
34
35setText();
36
37}
38
39
40ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
41 : ViewMailBase(parent, name, fl), _inLoop(false)
42{
43 _gotBody = false;
44
45 connect(reply, SIGNAL(activated()), SLOT(slotReply()));
46 connect(forward, SIGNAL(activated()), SLOT(slotForward()));
47
48 attachments->setEnabled(_gotBody);
49
50 //_handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid()));
51 //connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &)));
52}
53
54void ViewMail::setText()
55{
56
57 setCaption( caption().arg( m_mail[0] ) );
58
59 _mailHtml = tr(
60 "<html><body>"
61 "<div align=center><b>%1</b></div>"
62 "<b>From:</b> %2<br>"
63 "<b>To:</b> %3<br>"
64 "%4"
65 "%5"
66 "<b>Date:</b> %6<hr>"
67 "<font face=fixed>%7</font>")
68 .arg( deHtml( m_mail[2] ) )
69 .arg( deHtml( m_mail[0] ) )
70 .arg( deHtml( m_mail[1] ) )
71 .arg( tr("<b>Cc:</b> %1<br>").arg( deHtml( m_mail[3] ) ) )
72 .arg( tr("<b>Bcc:</b> %1<br>").arg( deHtml( m_mail[4] ) ) )
73 .arg( tr("(no date)" ) )
74 .arg("%1");
75 browser->setText( QString(_mailHtml) + deHtml( m_mail[5] ) );
76}
77
78
79
80ViewMail::~ViewMail()
81{
82 hide();
83}
84
85void ViewMail::hide()
86{
87 QWidget::hide();
88
89 if (_inLoop) {
90 _inLoop = false;
91 qApp->exit_loop();
92 }
93}
94
95void ViewMail::exec()
96{
97 show();
98
99 if (!_inLoop) {
100 _inLoop = true;
101 qApp->enter_loop();
102 }
103}
104
105QString ViewMail::deHtml(const QString &string)
106{
107 QString string_ = string;
108 string_.replace(QRegExp("&"), "&amp;");
109 string_.replace(QRegExp("<"), "&lt;");
110 string_.replace(QRegExp(">"), "&gt;");
111 string_.replace(QRegExp("\\n"), "<br>");
112 return string_;
113}
114
115void ViewMail::slotReply()
116{
117 if (!_gotBody) {
118 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
119 return;
120 }
121
122 QString rtext;
123 // rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
124 // .arg(_mail.envelope().from()[0].toString())
125 // .arg(_mail.envelope().mailDate());
126
127 //QString text = _mail.bodyPart(1).data();
128 //QStringList lines = QStringList::split(QRegExp("\\n"), text);
129 QStringList::Iterator it;
130 //for (it = lines.begin(); it != lines.end(); it++) {
131 // rtext += "> " + *it + "\n";
132 //}
133 rtext += "\n";
134
135 QString prefix;
136 //if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = "";
137 // else prefix = "Re: "; // no i18n on purpose
138
139 //SendMail sendMail;
140 //sendMail.setTo(_mail.envelope().from()[0].toString());
141 //sendMail.setSubject(prefix + _mail.envelope().subject());
142 //sendMail.setInReplyTo(_mail.envelope().messageId());
143 //sendMail.setMessage(rtext);
144
145 //Composer composer(this, 0, true);
146 //composer.setSendMail(sendMail);
147 //composer.showMaximized();
148 //composer.exec();
149}
150
151void ViewMail::slotForward()
152{
153 if (!_gotBody) {
154 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
155 return;
156 }
157
158 QString ftext;
159 /*ftext += QString("\n----- Forwarded message from %1 -----\n\n")
160 .arg(_mail.envelope().from()[0].toString());
161 if (!_mail.envelope().mailDate().isNull())
162 ftext += QString("Date: %1\n")
163 .arg(_mail.envelope().mailDate());
164 if (!_mail.envelope().from()[0].toString().isNull())
165 ftext += QString("From: %1\n")
166 .arg(_mail.envelope().from()[0].toString());
167 if (!_mail.envelope().to().toString().isNull())
168 ftext += QString("To: %1\n")
169 .arg(_mail.envelope().to().toString());
170 if (!_mail.envelope().cc().toString().isNull())
171 ftext += QString("Cc: %1\n")
172 .arg(_mail.envelope().cc().toString());
173 if (!_mail.envelope().bcc().toString().isNull())
174 ftext += QString("Bcc: %1\n")
175 .arg(_mail.envelope().bcc().toString());
176 if (!_mail.envelope().subject().isNull())
177 ftext += QString("Subject: %1\n")
178 .arg(_mail.envelope().subject());
179
180 ftext += QString("\n%1\n")
181 .arg(_mail.bodyPart(1).data());
182
183 ftext += QString("----- End forwarded message -----\n");
184*/
185/*
186 SendMail sendMail;
187 sendMail.setSubject("Fwd: " + _mail.envelope().subject());
188 sendMail.setMessage(ftext);
189
190 Composer composer(this, 0, true);
191 composer.setSendMail(sendMail);
192 composer.showMaximized();
193 composer.exec();
194*/
195}
196
197/*
198void ViewMail::slotIMAPUid(IMAPResponse &response)
199{
200 disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &)));
201
202 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
203 QValueList<IMAPResponseBodyPart> bodyParts;
204 bodyParts.append(response.FETCH()[0].bodyPart(0));
205 _mail.setBodyParts(bodyParts);
206
207 browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data())));
208
209 // fillList(response.FETCH()[0].bodyStructure());
210
211 _gotBody = true;
212 } else {
213 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"));
214 }
215}
216*/
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
new file mode 100644
index 0000000..9d3c6e4
--- a/dev/null
+++ b/noncore/net/mail/viewmail.h
@@ -0,0 +1,75 @@
1#ifndef VIEWMAIL_H
2#define VIEWMAIL_H
3
4#include <qlistview.h>
5#include <qmap.h>
6
7#include "viewmailbase.h"
8//#include "imapresponse.h"
9//#include "mailtable.h"
10
11class AttachItemStore
12{
13public:
14 void setMimeType(QString mimeType) { _mimeType = mimeType; }
15 QString mimeType() { return _mimeType; }
16 void setFileName(QString fileName) { _fileName = fileName; }
17 QString fileName() { return _fileName; }
18 void setDescription(QString description) { _description = description; }
19 QString description() { return _description; }
20 void setPartNum(QString partNum) { _partNum = partNum; }
21 QString partNum() { return _partNum; }
22
23private:
24 QString _mimeType, _fileName, _description, _partNum;
25
26};
27
28class AttachItem : public QListViewItem
29{
30public:
31 AttachItem(QListView *parent, AttachItemStore &attachment);
32 AttachItem(QListViewItem *parent, AttachItemStore &attachment);
33
34 AttachItemStore attachItemStore() { return _attachItemStore; }
35
36private:
37 AttachItemStore _attachItemStore;
38
39};
40
41class ViewMail : public ViewMailBase
42{
43 Q_OBJECT
44
45public:
46 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
47 ~ViewMail();
48
49 void hide();
50 void exec();
51 static QString appName() { return QString::fromLatin1("mail"); }
52 void setMailInfo( const QString & from, const QString & to, const QString & subject, const QString & cc, const QString & bcc, const QString & bodytext );
53
54protected:
55 //void fillList(IMAPResponseBODYSTRUCTURE &structure);
56 QString deHtml(const QString &string);
57
58protected slots:
59 void slotReply();
60 void slotForward();
61 void setText();
62
63 //void slotIMAPUid(IMAPResponse &response);
64
65private:
66 bool _inLoop;
67 //IMAPResponseFETCH _mail;
68 //IMAPHandler *_handler;
69 QString _mailHtml;
70 bool _gotBody;
71 QMap <int,QString> m_mail;
72
73};
74
75#endif
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp
new file mode 100644
index 0000000..197a665
--- a/dev/null
+++ b/noncore/net/mail/viewmailbase.cpp
@@ -0,0 +1,75 @@
1#include <qtextbrowser.h>
2#include <qlistview.h>
3#include <qaction.h>
4#include <qlabel.h>
5#include <qvbox.h>
6#include <qpopupmenu.h>
7
8#include <qpe/qpetoolbar.h>
9#include <qmenubar.h>
10#include <qpe/resource.h>
11
12#include "viewmailbase.h"
13//#include "opendiag.h"
14
15ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
16 : QMainWindow(parent, name, fl)
17{
18 setCaption(tr("E-Mail by %1"));
19 setToolBarsMovable(false);
20
21 toolbar = new QToolBar(this);
22 menubar = new QMenuBar( toolbar );
23 mailmenu = new QPopupMenu( menubar );
24 menubar->insertItem( tr( "Mail" ), mailmenu );
25
26 toolbar->setHorizontalStretchable(true);
27 addToolBar(toolbar);
28
29 QLabel *spacer = new QLabel(toolbar);
30 spacer->setBackgroundMode(QWidget::PaletteButton);
31 toolbar->setStretchableWidget(spacer);
32
33 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this);
34 reply->addTo(toolbar);
35 reply->addTo(mailmenu);
36
37 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this);
38 forward->addTo(toolbar);
39 forward->addTo(mailmenu);
40
41 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
42 attachbutton->addTo(toolbar);
43 attachbutton->addTo(mailmenu);
44 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
45
46 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
47 deleteMail->addTo(toolbar);
48 deleteMail->addTo(mailmenu);
49
50 QVBox *view = new QVBox(this);
51 setCentralWidget(view);
52
53 attachments = new QListView(view);
54 attachments->setMinimumHeight(90);
55 attachments->setMaximumHeight(90);
56 attachments->setAllColumnsShowFocus(true);
57 attachments->addColumn("Mime Type", 100);
58 attachments->addColumn("Filename", 100);
59 attachments->addColumn("Description", 100);
60 attachments->hide();
61
62 browser = new QTextBrowser(view);
63
64 //openDiag = new OpenDiag(view);
65 //openDiag->hide();
66
67}
68
69void ViewMailBase::slotChangeAttachview(bool state)
70{
71 if (state) attachments->show();
72 else attachments->hide();
73}
74
75
diff --git a/noncore/net/mail/viewmailbase.h b/noncore/net/mail/viewmailbase.h
new file mode 100644
index 0000000..898522e
--- a/dev/null
+++ b/noncore/net/mail/viewmailbase.h
@@ -0,0 +1,36 @@
1#ifndef VIEWMAILBASE_H
2#define VIEWMAILBASE_H
3
4#include <qmainwindow.h>
5
6class QAction;
7class OpenDiag;
8class QListView;
9class QToolBar;
10class QTextBrowser;
11class QMenuBar;
12class QPopupMenu;
13
14class ViewMailBase : public QMainWindow
15{
16 Q_OBJECT
17
18public:
19 ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
20
21protected:
22 QAction *reply, *forward, *attachbutton, *deleteMail;
23 QListView *attachments;
24 QToolBar *toolbar;
25 QTextBrowser *browser;
26 OpenDiag *openDiag;
27 QMenuBar *menubar;
28 QPopupMenu *mailmenu;
29
30protected slots:
31 void slotChangeAttachview(bool state);
32
33};
34
35#endif
36