summaryrefslogtreecommitdiff
authorconber <conber>2002-06-15 20:16:02 (UTC)
committer conber <conber>2002-06-15 20:16:02 (UTC)
commite782feb7418fbf956547b9abb59afdde00745442 (patch) (side-by-side diff)
tree2eec1348e7d13c7b7f6db8e5d377cea0403ee43e
parentb15f8a613d83a2f3957fef515e20981f636b908b (diff)
downloadopie-e782feb7418fbf956547b9abb59afdde00745442.zip
opie-e782feb7418fbf956547b9abb59afdde00745442.tar.gz
opie-e782feb7418fbf956547b9abb59afdde00745442.tar.bz2
added message box
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/TODO5
-rw-r--r--noncore/unsupported/mail2/composer.cpp2
-rw-r--r--noncore/unsupported/mail2/libmail/mailfactory.cpp2
3 files changed, 6 insertions, 3 deletions
diff --git a/noncore/unsupported/mail2/TODO b/noncore/unsupported/mail2/TODO
index ef596dc..5873615 100644
--- a/noncore/unsupported/mail2/TODO
+++ b/noncore/unsupported/mail2/TODO
@@ -1,31 +1,32 @@
-LISAmail TODO
+Mail TODO
-----------------------------------------------------------------------------
General stuff:
+ - This program needs a name!
- If password is empty, ask for it during fetch.
- Check if all necessary fields in AccoundEditor are filled.
Protocol related:
- The IMAP implentation is kinda strange and slow.
- The SMTP implentation is goddamn strange.
- POP3 support would be nice.
- NNTP would be kinda neat, too.
- Implent a plugin system.
Security related:
- GnuPG support. This will require a seperate gpg managing utility in
the settings tab.
- sMIME? maybe in the distant future.
Mail management:
- Header caching
- Sieve filtering support?
- Enqueueing/Draft support both on the IMAP server and local.
Testing:
I'm using the courier-imap server at my developement site. I didn't have
much opportunity to test on other servers. Giving me test-accounts on other
servers would be helpfull.
-If you want something added, drop a mail. Comments are allways welcome.
+If you want something added, drop a mail. Comments are always welcome.
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index 2f13604..03d50b6 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -1,215 +1,217 @@
#include <qmultilineedit.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qaction.h>
#include <qtimer.h>
#include <qlabel.h>
#include <qpe/resource.h>
#include "addresspicker.h"
#include "listviewplus.h"
#include "smtphandler.h"
#include "attachdiag.h"
#include "composer.h"
#include "rename.h"
AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment)
: QListViewItem(parent), _attachment(attachment)
{
setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap());
setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName());
setText(1, _attachment.description());
}
Composer::Composer(QWidget *parent, const char *name, WFlags fl)
: ComposerBase(parent, name, fl)
{
abort->setEnabled(false);
to->setFocus();
connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail()));
connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker()));
connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach()));
connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach()));
connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int)));
connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int)));
QTimer::singleShot(0, this, SLOT(slotFillStuff()));
QTimer::singleShot(0, this, SLOT(slotResizing()));
}
void Composer::setSendMail(SendMail &sendMail)
{
to->setText(sendMail.to());
cc->setText(sendMail.cc());
bcc->setText(sendMail.bcc());
subject->setText(sendMail.subject());
message->setText(sendMail.message());
_inReplyTo = sendMail.inReplyTo();
QValueList<Attachment> attachments = sendMail.attachments();
QValueList<Attachment>::Iterator it;
for (it = attachments.begin(); it != attachments.end(); it++) {
(void) new AttachViewItem(attachView, *it);
if (attachView->isHidden()) attachView->show();
}
}
void Composer::slotResizing()
{
from->setMaximumWidth(width() - fromBox->width());
from->resize(width() - fromBox->width(), y());
}
void Composer::slotPopupHandler(int itemid)
{
if (attachView->currentItem() == NULL) {
QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok"));
return;
}
if (itemid == POPUP_ATTACH_RENAME) {
QString tmp = Rename::rename(attachView->currentItem()->text(0), this);
if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp);
} else if (itemid == POPUP_ATTACH_DESC) {
QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this);
if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp);
} else if (itemid == POPUP_ATTACH_REMOVE) {
attachView->takeItem(attachView->currentItem());
}
}
void Composer::slotSendMail()
{
if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
return;
}
SendMail smail;
smail.setFrom(from->currentText());
smail.setReplyTo(replyto->text());
smail.setTo(to->text());
smail.setCc(cc->text());
smail.setBcc(bcc->text());
smail.setSubject(subject->text());
smail.setMessage(message->text());
smail.setNeedsMime(attachView->childCount() == 0 ? false : true);
smail.setAccount(accountsLoaded[from->currentItem()]);
if (priority->currentItem() == POPUP_PRIO_LOW) {
smail.setPriority("Low"); // No i18n on purpose
} else if (priority->currentItem() == POPUP_PRIO_NORMAL) {
smail.setPriority("Normal"); // No i18n on purpose
} else if (priority->currentItem() == POPUP_PRIO_HIGH) {
smail.setPriority("High"); // No i18n on purpose
}
QValueList<Attachment> attachments;
QListViewItem *item;
for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
attachments.append(((AttachViewItem *)item)->attachment());
}
smail.setAttachments(attachments);
QString header, message;
MailFactory::genMail(header, message, smail, this);
abort->setEnabled(true);
SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text());
connect(handler, SIGNAL(finished()), SLOT(slotSendFinished()));
connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &)));
connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &)));
}
void Composer::slotSendError(const QString &error)
{
status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>"));
QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok"));
}
void Composer::slotSendFinished()
{
+ QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok"));
+
status->setText(QString(0));
abort->setEnabled(false);
}
void Composer::slotFillStuff()
{
QValueList<Account> accounts = ConfigFile::getAccounts();
int i = 0;
QValueList<Account>::Iterator it;
for (it = accounts.begin(); it != accounts.end(); it++) {
if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) {
if (!(*it).realName().isEmpty())
from->insertItem((*it).realName() + " <" + (*it).email() + ">", i);
else
from->insertItem((*it).email());
accountsLoaded.append(*it);
i++;
}
}
}
void Composer::slotFromChanged(int id)
{
Account account = accountsLoaded[id];
if (account.defaultCc()) cc->setText(account.cc());
if (account.defaultBcc()) bcc->setText(account.bcc());
if (account.defaultReplyTo()) replyto->setText(account.replyTo());
if (!account.signature().isEmpty())
message->setText(message->text() + "\n\n-- \n" + account.signature());
}
void Composer::slotOpenAddressPicker()
{
if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) {
if (to->text().isEmpty()) {
to->setText(AddressPicker::getNames());
} else {
to->setText(to->text() + ", " + AddressPicker::getNames());
}
} else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) {
if (cc->text().isEmpty()) {
cc->setText(AddressPicker::getNames());
} else {
cc->setText(cc->text() + ", " + AddressPicker::getNames());
}
} else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) {
if (bcc->text().isEmpty()) {
bcc->setText(AddressPicker::getNames());
} else {
bcc->setText(bcc->text() + ", " + AddressPicker::getNames());
}
}
}
void Composer::slotAddAttach()
{
DocLnk lnk = AttachDiag::getFile();
if (lnk.name().isEmpty()) return;
Attachment attachment;
attachment.setFileName(lnk.file());
attachment.setNewName(lnk.name());
attachment.setDocLnk(&lnk);
(void) new AttachViewItem(attachView, attachment);
}
void Composer::slotDelAttach()
{
if (attachView->currentItem() == NULL) return;
attachView->takeItem(attachView->currentItem());
}
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
@@ -1,173 +1,173 @@
#include <qmessagebox.h>
#include <qtextstream.h>
#include <qfile.h>
#include <qpe/mimetype.h>
#include "miscfunctions.h"
#include "mailfactory.h"
#include "defines.h"
MailFactory::MailFactory(SendMail &smail, QWidget *parent)
: QObject(), _smail(smail), _parent(parent)
{
_abort = false;
Account account = _smail.account();
if (!_smail.from().isEmpty())
_header += "From: " + _smail.from() + "\n";
if (!_smail.replyTo().isEmpty())
_header += "Reply-To: " + _smail.replyTo() + "\n";
if (!_smail.to().isEmpty())
_header += "To: " + _smail.to() + "\n";
if (!_smail.cc().isEmpty())
_header += "Cc: " + _smail.cc() + "\n";
if (!_smail.bcc().isEmpty())
_header += "Bcc: " + _smail.bcc() + "\n";
if (!_smail.subject().isEmpty())
_header += "Subject: " + _smail.subject() + "\n";
if (!_smail.priority().isEmpty() || (_smail.priority() != "Normal"))
_header += "Priority: " + _smail.priority() + "\n";
_header += "Date: " + MiscFunctions::rfcDate() + "\n";
if (!_smail.account().org().isEmpty())
_header += "Organization: " + _smail.account().org() + "\n";
if (_smail.needsMime())
_header += "Mime-Version: 1.0\n";
_header += "Message-Id: <" + MiscFunctions::uniqueString() + "." + account.email() + ">\n";
if (!_smail.inReplyTo().isEmpty())
_header += "In-Reply-To: " + _smail.inReplyTo() + "\n";
if (!QString((QString) USERAGENT).isEmpty())
_header += (QString) "User-Agent: " + USERAGENT + "\n";
if (!_smail.needsMime()) {
// if (_smail.encrypt() && !_smail.sign()) {
// openPgpEncrypt(_smail.message(), _header, _body);
// } else if (!_smail.encrypt() && _smail.sign()) {
// openPgpSign(_smail.message(), _header, _body);
// } else if (_smail.encrypt() && _smail.sign()) {
// openPgpSignEncrypt(_smail.message(), _header, _body);
// } else {
_body += _smail.message();
// }
} else {
QString boundary = MiscFunctions::uniqueString();
_header += "Content-Type: multipart/mixed; boundary=\"" + boundary + "\"\n";
_body += "This is a multi-part message in MIME format.\n\n";
_body += "--" + boundary + "\n";
// if (_smail.encrypt() && !_smail.sign()) {
// QString header, body;
// openPgpEncrypt(_smail.message(), header, body);
// _body += header + "\n" + body + "\n";
// } else if (!_smail.encrypt() && _smail.sign()) {
// QString header, body;
// openPgpSign(_smail.message(), header, body);
// _body += header + "\n" + body + "\n";
// } else if (_smail.encrypt() && _smail.sign()) {
// QString header, body;
// openPgpSignEncrypt(_smail.message(), header, body);
// _body += header + "\n" + body + "\n";
// } else {
// TODO: Do proper charset handling!
_body += "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
_body += "Content-Transfer-Encoding: 8bit\n\n";
_body += _smail.message() + "\n";
// }
QValueList<Attachment> attachments = _smail.attachments();
QValueList<Attachment>::Iterator it;
for (it = attachments.begin(); it != attachments.end(); it++) {
QFile f((*it).fileName());
if (f.open(IO_ReadOnly)) {
QTextStream t(&f);
QString file;
while (!t.atEnd()) file += t.readLine() + "\n";
f.close();
QString mimetype = (new MimeType(*(*it).docLnk()))->id();
_body += "\n--" + boundary + "\n";
_body += "Content-Type: " + mimetype + "; name=\"" + (*it).newName() + "\"\n";
// TODO: Decide which content transfer encoding is best. B64 for binary, QP for text.
_body += "Content-Transfer-Encoding: base64\n";
_body += "Content-Disposition: attachment; filename=\"" + (*it).newName() + "\"\n";
if (!(*it).description().isEmpty())
_body += "Content-Description: " + (*it).description() + "\n";
_body += "\n" + MiscFunctions::encodeBase64(file) + "\n";
} else {
- int ret = QMessageBox::critical(_parent, tr("Error"), tr("<p>Couldn't attach file '%1'. Continue anyway or abort?</p>"), tr("Continue"), tr("Abort"));
+ 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"));
if (ret == 1) {
it = attachments.end();
_abort = true;
}
}
}
_body += "\n--" + boundary + "--";
}
if (_abort) {
_body = QString(0);
_header = QString(0);
}
}
// Unfinished GPG code.
/*
void MailFactory::openPgpEncrypt(const QString &text, QString &header, QString &body)
{
QString boundary = MiscFunctions::uniqueString();
header += "Content-Type: multipart/encrypted; boundary=\"" + boundary + "\"; protocol=\"application/pgp-encrypted\"\n";
body += "--" + boundary + "\n";
body += "Content-Type: application/pgp-encrypted\n\n";
body += "Version: 1\n\n";
body += "--" + boundary + "\n";
body += "Content-Type: application/octet-stream\n\n";
body += GpgHandling::encrypt(_smail.gpgReceivers(), text);
body += "\n--" + boundary + "--\n";
}
void MailFactory::openPgpSign(const QString &text, QString &header, QString &body)
{
QString boundary = MiscFunctions::uniqueString();
header += "Content-Type: multipart/signed; boundary=\"" + boundary + "\"; protocol=\"application/pgp-signature\"\n";
body += "--" + boundary + "\n";
QString temp;
temp += "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
temp += "Content-Transfer-Encoding: quoted-printable\n\n";
temp += MiscFunctions::encodeQPrintable(text) + "\n";
body += temp;
temp.replace(QRegExp("\n"), "\r\n");
QString signature = GpgHandling::sign(temp, _parent);
body += "\n--" + boundary + "\n";
body += "Content-Type: application/pgp-signature\n\n";
body += signature + "\n";
body += "\n--" + boundary + "--\n";
}
void MailFactory::openPgpSignEncrypt(const QString &text, QString &header, QString &message)
{
QString header_, message_;
openPgpSign(text, header_, message_);
openPgpEncrypt(header_ + "\n" + message_, header, message);
}
*/
void MailFactory::genMail(QString &header, QString &message, SendMail &smail, QWidget *parent)
{
MailFactory factory(smail, parent);
header = factory._header;
message = factory._body;
}