summaryrefslogtreecommitdiff
authortille <tille>2002-06-18 13:49:13 (UTC)
committer tille <tille>2002-06-18 13:49:13 (UTC)
commit99cf287037a0d9f99e4fc035d1b9f6db08bb6583 (patch) (side-by-side diff)
tree6c4707892003f6bfb1b4b088d57aba109ef63a4a
parent1e6635662a329dc8f7958b29044e1ce843ff7208 (diff)
downloadopie-99cf287037a0d9f99e4fc035d1b9f6db08bb6583.zip
opie-99cf287037a0d9f99e4fc035d1b9f6db08bb6583.tar.gz
opie-99cf287037a0d9f99e4fc035d1b9f6db08bb6583.tar.bz2
added queue mail support
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composer.cpp150
-rw-r--r--noncore/unsupported/mail2/composer.h7
-rw-r--r--noncore/unsupported/mail2/composerbase.cpp3
-rw-r--r--noncore/unsupported/mail2/composerbase.h2
-rw-r--r--noncore/unsupported/mail2/mainwindow.cpp10
-rw-r--r--noncore/unsupported/mail2/mainwindow.h1
-rw-r--r--noncore/unsupported/mail2/mainwindowbase.cpp3
-rw-r--r--noncore/unsupported/mail2/mainwindowbase.h2
8 files changed, 173 insertions, 5 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index c36d973..cabffe5 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -1,56 +1,60 @@
#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 <qapplication.h>
#include <qpe/resource.h>
+#include <qpe/config.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)
+Composer::Composer(QWidget *parent, const char *name, WFlags fl, bool sendQueue)
: ComposerBase(parent, name, fl), _inLoop(false)
{
+ _sendQueued = sendQueue;
abort->setEnabled(false);
to->setFocus();
connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail()));
+ connect(queuemail, SIGNAL(activated()), SLOT(slotQueueMail()));
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()));
+
}
Composer::~Composer()
{
hide();
}
void Composer::hide()
{
QWidget::hide();
if (_inLoop) {
@@ -81,24 +85,29 @@ void Composer::setSendMail(SendMail &sendMail)
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());
+ if (_sendQueued)
+ {
+ slotSendQueued();
+ close();
+ }
}
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);
@@ -147,24 +156,162 @@ void Composer::slotSendMail()
QString header, message;
MailFactory::genMail(header, message, smail, this);
if (header.isNull() || message.isNull()) return; // Aborted.
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::slotSendQueued()
+{
+
+ qDebug("Sending queued messages");
+ Config cfg( "mailqueue", Config::User );
+ cfg.setGroup( "Settings" );
+ int count = cfg.readNumEntry( "count", 0 );
+ // tille: should not be here
+ // but no error checking for the moment
+ cfg.writeEntry( "count", 0 );
+
+
+ qDebug("%i messages to send", count);
+ QString str;
+ for (int i=1;i<=count;i++)
+ {
+ qDebug("sending message %i",i);
+ cfg.setGroup( "Mail_" + QString::number(i) );
+ SendMail smail;
+ str = cfg.readEntry("from");
+ qDebug("setFrom %s",str.latin1());
+ smail.setFrom( str );
+ str = cfg.readEntry("reply");
+ qDebug("setReplyTo %s",str.latin1());
+ smail.setReplyTo( str );
+ QString toAdr = cfg.readEntry("to");
+ qDebug("to %s",toAdr.latin1());
+ smail.setTo( toAdr ); //to->text());
+ str = cfg.readEntry("cc");
+ qDebug("setCc %s",str.latin1());
+ smail.setCc( str ); //cc->text());
+ smail.setBcc( cfg.readEntry("bcc") ); //bcc->text());
+ str = cfg.readEntry("subject");
+ qDebug("setSubject %s",str.latin1());
+ smail.setSubject( str ); //subject->text());
+ str = cfg.readEntryCrypt("message");
+ qDebug("setMessage %s",str.latin1());
+ smail.setMessage( str ); //message->text());
+ smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true);
+
+ qDebug("setting account [%i]",cfg.readNumEntry("account"));
+ Account accnt = accountsLoaded[ cfg.readNumEntry("account") ];
+ smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]);
+
+
+ int prio = cfg.readNumEntry( "priority" );
+ qDebug("setting priority %i",prio);
+ if (prio == POPUP_PRIO_LOW) {
+ smail.setPriority("Low"); // No i18n on purpose
+ } else if (prio == POPUP_PRIO_NORMAL) {
+ smail.setPriority("Normal"); // No i18n on purpose
+ } else if (prio == POPUP_PRIO_HIGH) {
+ smail.setPriority("High"); // No i18n on purpose
+ }
+
+ QValueList<Attachment> attachments;
+ Attachment a;
+ QString an;
+
+ int ac = cfg.readNumEntry( "attachments", 0 );
+ qDebug("%i Attachments",ac);
+ for (int j = 0; i < ac; ac++) {
+ an = "Attachment_" + QString::number( j );
+ qDebug(an.latin1());
+ a.setFileName(cfg.readEntry( an + "fileName" ));
+ a.setNewName(cfg.readEntry( an + "newName" ));
+ a.setDescription(cfg.readEntry( an + "description" ));
+ a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) );
+ attachments.append( a );
+ }
+
+ smail.setAttachments(attachments);
+
+ qDebug("putting mail together");
+
+ QString header, message;
+ MailFactory::genMail(header, message, smail, this);
+ if (header.isNull() || message.isNull()) continue;//return; // Aborted.
+
+ // abort->setEnabled(true);
+
+ qDebug("Sending to %s",toAdr.latin1());
+ SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr);
+
+ 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 &)));
+
+ qDebug("remove mail %i", i);
+ cfg.clearGroup();
+ cfg.removeEntry( "Mail_" + QString::number(i) );
+ }
+}
+
+void Composer::slotQueueMail()
+{
+ 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;
+ }
+
+ Config cfg( "mailqueue", Config::User );
+
+ cfg.setGroup( "Settings" );
+ int count = cfg.readNumEntry( "count", 0 );
+ count++;
+ cfg.writeEntry( "count", count );
+ qDebug("queueing mail %i",count);
+
+ cfg.setGroup( "Mail_" + QString::number( count ));
+ cfg.writeEntry( "from", from->currentText() );
+ cfg.writeEntry( "reply", replyto->text());
+ cfg.writeEntry( "to", to->text());
+ cfg.writeEntry( "cc", cc->text());
+ cfg.writeEntry( "bcc", bcc->text());
+ cfg.writeEntry( "subject", subject->text());
+ cfg.writeEntryCrypt( "message", message->text());
+ cfg.writeEntry( "mime", attachView->childCount() == 0 );
+ cfg.writeEntry( "account", from->currentItem());
+ cfg.writeEntry( "priority", priority->currentItem() );
+ cfg.writeEntry( "attachments", attachView->childCount() );
+
+ Attachment a;
+ QListViewItem *item;
+ QString an;
+ int i = 0;
+ for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
+ a = ((AttachViewItem *)item)->attachment();
+ an = "Attachment_" + QString::number( i++ );
+ cfg.writeEntry( an + "fileName", a.fileName() );
+ cfg.writeEntry( an + "newName", a.newName() );
+ cfg.writeEntry( an + "description", a.description() );
+ cfg.writeEntry( an + "docLnk", a.docLnk().file() );
+ }
+
+ // cfg.close();
+}
+
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);
@@ -232,13 +379,12 @@ void Composer::slotAddAttach()
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/composer.h b/noncore/unsupported/mail2/composer.h
index 2640d7e..00235bf 100644
--- a/noncore/unsupported/mail2/composer.h
+++ b/noncore/unsupported/mail2/composer.h
@@ -16,42 +16,47 @@ public:
Attachment attachment() { return _attachment; }
private:
Attachment _attachment;
};
class Composer : public ComposerBase
{
Q_OBJECT
public:
- Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
+ Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal, bool sendQueue = false);
~Composer();
void hide();
void exec();
void setSendMail(SendMail &sendMail);
+public slots:
+ void slotSendQueued();
+
protected slots:
void slotPopupHandler(int itemid);
void slotSendMail();
+ void slotQueueMail();
void slotSendError(const QString &);
void slotSendFinished();
void slotResizing();
void slotFillStuff();
void slotFromChanged(int id);
void slotOpenAddressPicker();
void slotAddAttach();
void slotDelAttach();
protected:
QValueList<Account> accountsLoaded;
private:
+ bool _sendQueued;
bool _inLoop;
QString _inReplyTo;
};
#endif
diff --git a/noncore/unsupported/mail2/composerbase.cpp b/noncore/unsupported/mail2/composerbase.cpp
index 10d567d..6627701 100644
--- a/noncore/unsupported/mail2/composerbase.cpp
+++ b/noncore/unsupported/mail2/composerbase.cpp
@@ -17,24 +17,27 @@ ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl)
: QMainWindow(parent, name, fl)
{
setCaption(tr("Compose Message"));
setToolBarsMovable(false);
toolbar = new QPEToolBar(this);
addToolBar(toolbar);
toolbar->setHorizontalStretchable(true);
sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this);
sendmail->addTo(toolbar);
+ queuemail = new QAction(tr("Queue the mail"), QIconSet(Resource::loadPixmap("mail/sendall")), 0, 0, this);
+ queuemail->addTo(toolbar);
+
attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
attachfile->addTo(toolbar);
connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool)));
addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this);
addressbook->addTo(toolbar);
QLabel *spacer = new QLabel(toolbar);
spacer->setBackgroundMode(QWidget::PaletteButton);
toolbar->setStretchableWidget(spacer);
abort = new QAction(tr("Abort sending"), QIconSet(Resource::loadPixmap("mail/abort")), 0, 0, this);
diff --git a/noncore/unsupported/mail2/composerbase.h b/noncore/unsupported/mail2/composerbase.h
index 75b77f4..9d3e4fc 100644
--- a/noncore/unsupported/mail2/composerbase.h
+++ b/noncore/unsupported/mail2/composerbase.h
@@ -32,24 +32,24 @@ protected:
static const int POPUP_PRIO_HIGH = 2;
static const int POPUP_ATTACH_RENAME = 0;
static const int POPUP_ATTACH_DESC = 1;
static const int POPUP_ATTACH_REMOVE = 2;
QMultiLineEdit *message;
ListViewPlus *attachView;
QMainWindow *attachWindow;
QPopupMenu *attachPopup;
QPEToolBar *toolbar, *attachToolbar;
QComboBox *fromBox, *from, *receiversBox, *subjectBox, *priority;
QLineEdit *replyto, *to, *cc, *bcc, *subject;
- QAction *sendmail, *attachfile, *addressbook, *abort, *addattach, *delattach;
+ QAction *sendmail, *queuemail, *attachfile, *addressbook, *abort, *addattach, *delattach;
QLabel *fromLabel, *status;
protected slots:
void slotAttachfileChanged(bool toggled);
void slotFromMenuChanged(int id);
void slotReceiverMenuChanged(int id);
void slotSubjectMenuChanged(int id);
};
#endif
diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp
index 2230dc0..652db94 100644
--- a/noncore/unsupported/mail2/mainwindow.cpp
+++ b/noncore/unsupported/mail2/mainwindow.cpp
@@ -21,35 +21,45 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl)
connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder)));
connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(mailClicked(IMAPResponseFETCH, IMAPHandler *)));
connect(mailView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &)));
connect(mailView, SIGNAL(totalSteps(int)), statusProgress, SLOT(setTotalSteps(int)));
connect(mailView, SIGNAL(progress(int)), statusProgress, SLOT(setProgress(int)));
connect(mailView, SIGNAL(resetProgress()), statusProgress, SLOT(reset()));
connect(mailView, SIGNAL(stopEnabled(bool)), stop, SLOT(setEnabled(bool)));
connect(stop, SIGNAL(activated()), mailView, SLOT(stop()));
connect(compose, SIGNAL(activated()), SLOT(slotCompose()));
+ connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued()));
connect(findmails, SIGNAL(activated()), SLOT(slotSearch()));
connect(configure, SIGNAL(activated()), SLOT(slotConfigure()));
}
void MainWindow::slotCompose()
{
Composer composer(this, 0, true);
composer.showMaximized();
composer.exec();
}
+void MainWindow::slotSendQueued()
+{
+ Composer composer(this, 0, true, true);
+// composer.sendQueue();
+ composer.showMaximized();
+ composer.exec();
+// composer.close();
+}
+
void MainWindow::slotSearch()
{
SearchDiag searchDiag(this, 0, true);
searchDiag.showMaximized();
searchDiag.exec();
}
void MainWindow::slotConfigure()
{
ConfigDiag configDiag(this, 0, true);
configDiag.showMaximized();
configDiag.exec();
diff --git a/noncore/unsupported/mail2/mainwindow.h b/noncore/unsupported/mail2/mainwindow.h
index 1edf10b..27b527d 100644
--- a/noncore/unsupported/mail2/mainwindow.h
+++ b/noncore/unsupported/mail2/mainwindow.h
@@ -6,19 +6,20 @@
class IMAPHandler;
class IMAPResponseFETCH;
class MainWindow : public MainWindowBase
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
protected slots:
void slotCompose();
+ void slotSendQueued();
void slotSearch();
void slotConfigure();
void mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler);
};
#endif
diff --git a/noncore/unsupported/mail2/mainwindowbase.cpp b/noncore/unsupported/mail2/mainwindowbase.cpp
index c55bd90..24f030f 100644
--- a/noncore/unsupported/mail2/mainwindowbase.cpp
+++ b/noncore/unsupported/mail2/mainwindowbase.cpp
@@ -17,24 +17,27 @@ MainWindowBase::MainWindowBase(QWidget *parent, const char *name, WFlags fl)
: QMainWindow(parent, name, fl)
{
setCaption(tr("E-Mail"));
setToolBarsMovable(false);
toolbar = new QPEToolBar(this);
addToolBar(toolbar);
toolbar->setHorizontalStretchable(true);
compose = new QAction(tr("Compose new mail"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this);
compose->addTo(toolbar);
+ sendQueue = new QAction(tr("Send queued mails"), QIconSet(Resource::loadPixmap("mail/sendqueue")), 0, 0, this);
+ sendQueue->addTo(toolbar);
+
folders = new QAction(tr("Show/hide folders"), QIconSet(Resource::loadPixmap("mail/folder")), 0, 0, this, 0, true);
folders->addTo(toolbar);
connect(folders, SIGNAL(toggled(bool)), SLOT(slotFoldersToggled(bool)));
findmails = new QAction(tr("Search mails"), QIconSet(Resource::loadPixmap("mail/find")), 0, 0, this);
findmails->addTo(toolbar);
configure = new QAction(tr("Configuration"), QIconSet(Resource::loadPixmap("mail/configure")), 0, 0, this);
configure->addTo(toolbar);
QLabel *spacer = new QLabel(toolbar);
spacer->setBackgroundMode(QWidget::PaletteButton);
diff --git a/noncore/unsupported/mail2/mainwindowbase.h b/noncore/unsupported/mail2/mainwindowbase.h
index 0776f02..232d656 100644
--- a/noncore/unsupported/mail2/mainwindowbase.h
+++ b/noncore/unsupported/mail2/mainwindowbase.h
@@ -18,18 +18,18 @@ class MainWindowBase : public QMainWindow
public:
MainWindowBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
protected slots:
void slotFoldersToggled(bool toggled);
protected:
ServerConnection *serverConnection;
QProgressBar *statusProgress;
FolderWidget *folderView;
QPEToolBar *toolbar;
MailTable *mailView;
- QAction *compose, *folders, *findmails, *configure, *stop;
+ QAction *compose, *sendQueue, *folders, *findmails, *configure, *stop;
QLabel *statusLabel;
};
#endif