-rw-r--r-- | noncore/unsupported/mail2/composer.cpp | 55 | ||||
-rw-r--r-- | noncore/unsupported/mail2/composer.h | 3 | ||||
-rw-r--r-- | noncore/unsupported/mail2/composerbase.cpp | 9 | ||||
-rw-r--r-- | noncore/unsupported/mail2/composerbase.h | 4 | ||||
-rw-r--r-- | noncore/unsupported/mail2/libmail/libmail.pro | 3 | ||||
-rw-r--r-- | noncore/unsupported/mail2/mail.pro | 3 | ||||
-rw-r--r-- | noncore/unsupported/mail2/mainwindowbase.cpp | 12 | ||||
-rw-r--r-- | noncore/unsupported/mail2/mainwindowbase.h | 4 |
8 files changed, 74 insertions, 19 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp index 1d793ee..72a7242 100644 --- a/noncore/unsupported/mail2/composer.cpp +++ b/noncore/unsupported/mail2/composer.cpp @@ -63,13 +63,12 @@ void Composer::hide() } } void Composer::exec() { show(); - if (!_inLoop) { _inLoop = true; qApp->enter_loop(); } } @@ -91,17 +90,13 @@ void Composer::setSendMail(SendMail &sendMail) } void Composer::slotResizing() { from->setMaximumWidth(width() - fromBox->width()); from->resize(width() - fromBox->width(), y()); - if (_sendQueued) - { - slotSendQueued(); - close(); - } + if (_sendQueued) slotSendQueued(); } void Composer::slotPopupHandler(int itemid) { if (attachView->currentItem() == NULL) { QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); @@ -168,21 +163,21 @@ void Composer::slotSendMail() 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 ); + _sendCount = 0; + _sendError = 0; + _toSend = cfg.readNumEntry( "count", 0 ); + if (_toSend == 0) close(); - qDebug("%i messages to send", count); + qDebug("%i messages to send", _toSend); QString str; - for (int i=1;i<=count;i++) + for (int i=1;i<=_toSend;i++) { qDebug("sending message %i",i); cfg.setGroup( "Mail_" + QString::number(i) ); SendMail smail; str = cfg.readEntry("from"); qDebug("setFrom %s",str.latin1()); @@ -246,19 +241,16 @@ void Composer::slotSendQueued() // 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(finished()), SLOT(slotSendQueuedFinished())); + connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(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) { @@ -307,20 +299,49 @@ void Composer::slotQueueMail() 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::slotSendQueuedError(const QString &error) +{ + _sendError++; + qDebug("error send mail %i",_sendCount); + 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::slotSendQueuedFinished() +{ + + _sendCount++; + qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError); + if (_sendCount < _toSend) return; + if (_sendError == _toSend) close(); + QMessageBox::information(this, tr("Success"), tr("<p>The queued mails ")+QString::number(_toSend-_sendError)+tr(" of ")+QString::number(_toSend)+(" were sent successfully.</p>"), tr("Ok")); + Config cfg( "mailqueue", Config::User ); + cfg.setGroup( "Settings" ); + cfg.writeEntry( "count", 0 ); + for (int i=1;i<=_sendCount;i++) + { + cfg.setGroup( "Mail_" + QString::number(i) ); + qDebug("remove mail %i", i); + cfg.clearGroup(); + cfg.removeEntry( "Mail_" + QString::number(i) ); + } + close(); +} + void Composer::slotFillStuff() { QValueList<Account> accounts = ConfigFile::getAccounts(); int i = 0; QValueList<Account>::Iterator it; diff --git a/noncore/unsupported/mail2/composer.h b/noncore/unsupported/mail2/composer.h index 00235bf..0b2a54c 100644 --- a/noncore/unsupported/mail2/composer.h +++ b/noncore/unsupported/mail2/composer.h @@ -39,24 +39,27 @@ public slots: protected slots: void slotPopupHandler(int itemid); void slotSendMail(); void slotQueueMail(); void slotSendError(const QString &); void slotSendFinished(); + void slotSendQueuedError(const QString &); + void slotSendQueuedFinished(); void slotResizing(); void slotFillStuff(); void slotFromChanged(int id); void slotOpenAddressPicker(); void slotAddAttach(); void slotDelAttach(); protected: QValueList<Account> accountsLoaded; private: bool _sendQueued; + int _toSend, _sendCount, _sendError; bool _inLoop; QString _inReplyTo; }; #endif diff --git a/noncore/unsupported/mail2/composerbase.cpp b/noncore/unsupported/mail2/composerbase.cpp index 6627701..ff00a73 100644 --- a/noncore/unsupported/mail2/composerbase.cpp +++ b/noncore/unsupported/mail2/composerbase.cpp @@ -5,46 +5,55 @@ #include <qlayout.h> #include <qaction.h> #include <qlabel.h> #include <qvbox.h> #include <qpe/qpetoolbar.h> +#include <qpe/qpemenubar.h> #include <qpe/resource.h> #include "listviewplus.h" #include "composerbase.h" ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("Compose Message")); setToolBarsMovable(false); toolbar = new QPEToolBar(this); + menubar = new QPEMenuBar( toolbar ); + mailmenu = new QPopupMenu( menubar ); + menubar->insertItem( tr( "Mail" ), mailmenu ); addToolBar(toolbar); toolbar->setHorizontalStretchable(true); sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this); sendmail->addTo(toolbar); + sendmail->addTo(mailmenu); queuemail = new QAction(tr("Queue the mail"), QIconSet(Resource::loadPixmap("mail/sendall")), 0, 0, this); queuemail->addTo(toolbar); + queuemail->addTo(mailmenu); attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); attachfile->addTo(toolbar); + attachfile->addTo(mailmenu); connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool))); addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this); addressbook->addTo(toolbar); + addressbook->addTo(mailmenu); 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); abort->addTo(toolbar); + abort->addTo(mailmenu); QWidget *main = new QWidget(this); setCentralWidget(main); QGridLayout *layout = new QGridLayout(main); diff --git a/noncore/unsupported/mail2/composerbase.h b/noncore/unsupported/mail2/composerbase.h index 9d3e4fc..d832623 100644 --- a/noncore/unsupported/mail2/composerbase.h +++ b/noncore/unsupported/mail2/composerbase.h @@ -4,12 +4,14 @@ #include <qmainwindow.h> class QMultiLineEdit; class ListViewPlus; class QPopupMenu; class QPEToolBar; +class QPEMenuBar; +class QPopupMenu; class QComboBox; class QLineEdit; class QAction; class QLabel; class ComposerBase : public QMainWindow @@ -36,12 +38,14 @@ protected: QMultiLineEdit *message; ListViewPlus *attachView; QMainWindow *attachWindow; QPopupMenu *attachPopup; QPEToolBar *toolbar, *attachToolbar; + QPEMenuBar *menubar; + QPopupMenu *mailmenu; QComboBox *fromBox, *from, *receiversBox, *subjectBox, *priority; QLineEdit *replyto, *to, *cc, *bcc, *subject; QAction *sendmail, *queuemail, *attachfile, *addressbook, *abort, *addattach, *delattach; QLabel *fromLabel, *status; protected slots: diff --git a/noncore/unsupported/mail2/libmail/libmail.pro b/noncore/unsupported/mail2/libmail/libmail.pro index 662af90..ddabd07 100644 --- a/noncore/unsupported/mail2/libmail/libmail.pro +++ b/noncore/unsupported/mail2/libmail/libmail.pro @@ -1,8 +1,9 @@ TEMPLATE = lib -CONFIG = qt warn_on release +CONFIG = qt warn_on debug +#CONFIG = qt warn_on release HEADERS = configfile.h \ defines.h \ imapbase.h \ imaphandler.h \ imapresponse.h \ mailfactory.h \ diff --git a/noncore/unsupported/mail2/mail.pro b/noncore/unsupported/mail2/mail.pro index 50d7c68..76b7996 100644 --- a/noncore/unsupported/mail2/mail.pro +++ b/noncore/unsupported/mail2/mail.pro @@ -1,8 +1,9 @@ TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on debug +#CONFIG = qt warn_on release HEADERS = accounteditor.h \ addresspicker.h \ attachdiag.h \ composer.h \ composerbase.h \ configdiag.h \ diff --git a/noncore/unsupported/mail2/mainwindowbase.cpp b/noncore/unsupported/mail2/mainwindowbase.cpp index 24f030f..9ffe6f0 100644 --- a/noncore/unsupported/mail2/mainwindowbase.cpp +++ b/noncore/unsupported/mail2/mainwindowbase.cpp @@ -4,12 +4,13 @@ #include <qaction.h> #include <qheader.h> #include <qlabel.h> #include <qvbox.h> #include <qpe/qpetoolbar.h> +#include <qpe/qpemenubar.h> #include <qpe/resource.h> #include "mainwindowbase.h" #include "folderwidget.h" #include "mailtable.h" @@ -17,30 +18,41 @@ MainWindowBase::MainWindowBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("E-Mail")); setToolBarsMovable(false); toolbar = new QPEToolBar(this); + menubar = new QPEMenuBar( toolbar ); + mailmenu = new QPopupMenu( menubar ); + servermenu = new QPopupMenu( menubar ); + menubar->insertItem( tr( "Mail" ), mailmenu ); + menubar->insertItem( tr( "Servers" ), servermenu ); + addToolBar(toolbar); toolbar->setHorizontalStretchable(true); compose = new QAction(tr("Compose new mail"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); compose->addTo(toolbar); + compose->addTo(mailmenu); sendQueue = new QAction(tr("Send queued mails"), QIconSet(Resource::loadPixmap("mail/sendqueue")), 0, 0, this); sendQueue->addTo(toolbar); + sendQueue->addTo(mailmenu); folders = new QAction(tr("Show/hide folders"), QIconSet(Resource::loadPixmap("mail/folder")), 0, 0, this, 0, true); folders->addTo(toolbar); + folders->addTo(servermenu); 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); + findmails->addTo(mailmenu); configure = new QAction(tr("Configuration"), QIconSet(Resource::loadPixmap("mail/configure")), 0, 0, this); configure->addTo(toolbar); + configure->addTo(servermenu); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); stop = new QAction(tr("Abort"), QIconSet(Resource::loadPixmap("mail/abort")), 0, 0, this); diff --git a/noncore/unsupported/mail2/mainwindowbase.h b/noncore/unsupported/mail2/mainwindowbase.h index 232d656..d8faeba 100644 --- a/noncore/unsupported/mail2/mainwindowbase.h +++ b/noncore/unsupported/mail2/mainwindowbase.h @@ -4,12 +4,14 @@ #include <qmainwindow.h> class ServerConnection; class QProgressBar; class FolderWidget; class QPEToolBar; +class QPEMenuBar; +class QPopupMenu; class MailTable; class QAction; class QLabel; class MainWindowBase : public QMainWindow { @@ -23,12 +25,14 @@ protected slots: protected: ServerConnection *serverConnection; QProgressBar *statusProgress; FolderWidget *folderView; QPEToolBar *toolbar; + QPEMenuBar *menubar; + QPopupMenu *mailmenu, *servermenu; MailTable *mailView; QAction *compose, *sendQueue, *folders, *findmails, *configure, *stop; QLabel *statusLabel; }; |