summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/libmail/mailfactory.cpp
authorconber <conber>2002-06-15 20:16:02 (UTC)
committer conber <conber>2002-06-15 20:16:02 (UTC)
commite782feb7418fbf956547b9abb59afdde00745442 (patch) (unidiff)
tree2eec1348e7d13c7b7f6db8e5d377cea0403ee43e /noncore/unsupported/mail2/libmail/mailfactory.cpp
parentb15f8a613d83a2f3957fef515e20981f636b908b (diff)
downloadopie-e782feb7418fbf956547b9abb59afdde00745442.zip
opie-e782feb7418fbf956547b9abb59afdde00745442.tar.gz
opie-e782feb7418fbf956547b9abb59afdde00745442.tar.bz2
added message box
Diffstat (limited to 'noncore/unsupported/mail2/libmail/mailfactory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/libmail/mailfactory.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/unsupported/mail2/libmail/mailfactory.cpp b/noncore/unsupported/mail2/libmail/mailfactory.cpp
index 58cf5f8..427e72c 100644
--- a/noncore/unsupported/mail2/libmail/mailfactory.cpp
+++ b/noncore/unsupported/mail2/libmail/mailfactory.cpp
@@ -55,97 +55,97 @@ MailFactory::MailFactory(SendMail &smail, QWidget *parent)
55 _header += "Content-Type: multipart/mixed; boundary=\"" + boundary + "\"\n"; 55 _header += "Content-Type: multipart/mixed; boundary=\"" + boundary + "\"\n";
56 56
57 _body += "This is a multi-part message in MIME format.\n\n"; 57 _body += "This is a multi-part message in MIME format.\n\n";
58 _body += "--" + boundary + "\n"; 58 _body += "--" + boundary + "\n";
59 59
60 // if (_smail.encrypt() && !_smail.sign()) { 60 // if (_smail.encrypt() && !_smail.sign()) {
61 // QString header, body; 61 // QString header, body;
62 // openPgpEncrypt(_smail.message(), header, body); 62 // openPgpEncrypt(_smail.message(), header, body);
63 // _body += header + "\n" + body + "\n"; 63 // _body += header + "\n" + body + "\n";
64 // } else if (!_smail.encrypt() && _smail.sign()) { 64 // } else if (!_smail.encrypt() && _smail.sign()) {
65 // QString header, body; 65 // QString header, body;
66 // openPgpSign(_smail.message(), header, body); 66 // openPgpSign(_smail.message(), header, body);
67 // _body += header + "\n" + body + "\n"; 67 // _body += header + "\n" + body + "\n";
68 // } else if (_smail.encrypt() && _smail.sign()) { 68 // } else if (_smail.encrypt() && _smail.sign()) {
69 // QString header, body; 69 // QString header, body;
70 // openPgpSignEncrypt(_smail.message(), header, body); 70 // openPgpSignEncrypt(_smail.message(), header, body);
71 // _body += header + "\n" + body + "\n"; 71 // _body += header + "\n" + body + "\n";
72 // } else { 72 // } else {
73 73
74 // TODO: Do proper charset handling! 74 // TODO: Do proper charset handling!
75 _body += "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; 75 _body += "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
76 _body += "Content-Transfer-Encoding: 8bit\n\n"; 76 _body += "Content-Transfer-Encoding: 8bit\n\n";
77 _body += _smail.message() + "\n"; 77 _body += _smail.message() + "\n";
78 // } 78 // }
79 79
80 QValueList<Attachment> attachments = _smail.attachments(); 80 QValueList<Attachment> attachments = _smail.attachments();
81 QValueList<Attachment>::Iterator it; 81 QValueList<Attachment>::Iterator it;
82 for (it = attachments.begin(); it != attachments.end(); it++) { 82 for (it = attachments.begin(); it != attachments.end(); it++) {
83 QFile f((*it).fileName()); 83 QFile f((*it).fileName());
84 if (f.open(IO_ReadOnly)) { 84 if (f.open(IO_ReadOnly)) {
85 QTextStream t(&f); 85 QTextStream t(&f);
86 QString file; 86 QString file;
87 while (!t.atEnd()) file += t.readLine() + "\n"; 87 while (!t.atEnd()) file += t.readLine() + "\n";
88 f.close(); 88 f.close();
89 QString mimetype = (new MimeType(*(*it).docLnk()))->id(); 89 QString mimetype = (new MimeType(*(*it).docLnk()))->id();
90 90
91 _body += "\n--" + boundary + "\n"; 91 _body += "\n--" + boundary + "\n";
92 _body += "Content-Type: " + mimetype + "; name=\"" + (*it).newName() + "\"\n"; 92 _body += "Content-Type: " + mimetype + "; name=\"" + (*it).newName() + "\"\n";
93 93
94 // TODO: Decide which content transfer encoding is best. B64 for binary, QP for text. 94 // TODO: Decide which content transfer encoding is best. B64 for binary, QP for text.
95 _body += "Content-Transfer-Encoding: base64\n"; 95 _body += "Content-Transfer-Encoding: base64\n";
96 96
97 _body += "Content-Disposition: attachment; filename=\"" + (*it).newName() + "\"\n"; 97 _body += "Content-Disposition: attachment; filename=\"" + (*it).newName() + "\"\n";
98 if (!(*it).description().isEmpty()) 98 if (!(*it).description().isEmpty())
99 _body += "Content-Description: " + (*it).description() + "\n"; 99 _body += "Content-Description: " + (*it).description() + "\n";
100 100
101 _body += "\n" + MiscFunctions::encodeBase64(file) + "\n"; 101 _body += "\n" + MiscFunctions::encodeBase64(file) + "\n";
102 } else { 102 } else {
103 int ret = QMessageBox::critical(_parent, tr("Error"), tr("<p>Couldn't attach file '%1'. Continue anyway or abort?</p>"), tr("Continue"), tr("Abort")); 103 int ret = QMessageBox::critical(_parent, tr("Error"), tr("<p>Couldn't attach file '%1'. Continue anyway or abort?</p>").arg((*it).fileName()), tr("Continue"), tr("Abort"));
104 if (ret == 1) { 104 if (ret == 1) {
105 it = attachments.end(); 105 it = attachments.end();
106 _abort = true; 106 _abort = true;
107 } 107 }
108 } 108 }
109 } 109 }
110 _body += "\n--" + boundary + "--"; 110 _body += "\n--" + boundary + "--";
111 } 111 }
112 112
113 if (_abort) { 113 if (_abort) {
114 _body = QString(0); 114 _body = QString(0);
115 _header = QString(0); 115 _header = QString(0);
116 } 116 }
117} 117}
118 118
119// Unfinished GPG code. 119// Unfinished GPG code.
120/* 120/*
121void MailFactory::openPgpEncrypt(const QString &text, QString &header, QString &body) 121void MailFactory::openPgpEncrypt(const QString &text, QString &header, QString &body)
122{ 122{
123 QString boundary = MiscFunctions::uniqueString(); 123 QString boundary = MiscFunctions::uniqueString();
124 124
125 header += "Content-Type: multipart/encrypted; boundary=\"" + boundary + "\"; protocol=\"application/pgp-encrypted\"\n"; 125 header += "Content-Type: multipart/encrypted; boundary=\"" + boundary + "\"; protocol=\"application/pgp-encrypted\"\n";
126 126
127 body += "--" + boundary + "\n"; 127 body += "--" + boundary + "\n";
128 body += "Content-Type: application/pgp-encrypted\n\n"; 128 body += "Content-Type: application/pgp-encrypted\n\n";
129 body += "Version: 1\n\n"; 129 body += "Version: 1\n\n";
130 body += "--" + boundary + "\n"; 130 body += "--" + boundary + "\n";
131 body += "Content-Type: application/octet-stream\n\n"; 131 body += "Content-Type: application/octet-stream\n\n";
132 body += GpgHandling::encrypt(_smail.gpgReceivers(), text); 132 body += GpgHandling::encrypt(_smail.gpgReceivers(), text);
133 body += "\n--" + boundary + "--\n"; 133 body += "\n--" + boundary + "--\n";
134} 134}
135 135
136void MailFactory::openPgpSign(const QString &text, QString &header, QString &body) 136void MailFactory::openPgpSign(const QString &text, QString &header, QString &body)
137{ 137{
138 QString boundary = MiscFunctions::uniqueString(); 138 QString boundary = MiscFunctions::uniqueString();
139 139
140 header += "Content-Type: multipart/signed; boundary=\"" + boundary + "\"; protocol=\"application/pgp-signature\"\n"; 140 header += "Content-Type: multipart/signed; boundary=\"" + boundary + "\"; protocol=\"application/pgp-signature\"\n";
141 141
142 body += "--" + boundary + "\n"; 142 body += "--" + boundary + "\n";
143 143
144 QString temp; 144 QString temp;
145 temp += "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; 145 temp += "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
146 temp += "Content-Transfer-Encoding: quoted-printable\n\n"; 146 temp += "Content-Transfer-Encoding: quoted-printable\n\n";
147 temp += MiscFunctions::encodeQPrintable(text) + "\n"; 147 temp += MiscFunctions::encodeQPrintable(text) + "\n";
148 body += temp; 148 body += temp;
149 149
150 temp.replace(QRegExp("\n"), "\r\n"); 150 temp.replace(QRegExp("\n"), "\r\n");
151 QString signature = GpgHandling::sign(temp, _parent); 151 QString signature = GpgHandling::sign(temp, _parent);