author | tille <tille> | 2002-06-18 23:53:27 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-18 23:53:27 (UTC) |
commit | 14881bb4baf3ac470a135bdde6ffb115c91ea124 (patch) (side-by-side diff) | |
tree | 6d088cdacd769076e64496abe6b9043168b75928 | |
parent | f2ecc05c1156ae0f99ea0528646609d63eaa84c0 (diff) | |
download | opie-14881bb4baf3ac470a135bdde6ffb115c91ea124.zip opie-14881bb4baf3ac470a135bdde6ffb115c91ea124.tar.gz opie-14881bb4baf3ac470a135bdde6ffb115c91ea124.tar.bz2 |
added menu and fix send queued
-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 @@ -61,17 +61,16 @@ void Composer::hide() _inLoop = false; qApp->exit_loop(); } } void Composer::exec() { show(); - if (!_inLoop) { _inLoop = true; qApp->enter_loop(); } } void Composer::setSendMail(SendMail &sendMail) { @@ -89,21 +88,17 @@ void Composer::setSendMail(SendMail &sendMail) if (attachView->isHidden()) attachView->show(); } } 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")); return; } @@ -166,25 +161,25 @@ 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()); smail.setFrom( str ); str = cfg.readEntry("reply"); @@ -244,23 +239,20 @@ void Composer::slotSendQueued() 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(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) { QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); return; @@ -305,24 +297,53 @@ 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; for (it = accounts.begin(); it != accounts.end(); it++) { if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) { 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 @@ -37,26 +37,29 @@ public slots: void slotSendQueued(); 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 @@ -3,50 +3,59 @@ #include <qcombobox.h> #include <qlineedit.h> #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); fromBox = new QComboBox(main); fromBox->insertItem(tr("From"), POPUP_FROM_FROM); 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 @@ -2,16 +2,18 @@ #define COMPOSERBASE_H #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 { Q_OBJECT @@ -34,16 +36,18 @@ protected: 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; + 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: void slotAttachfileChanged(bool toggled); void slotFromMenuChanged(int id); 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,10 +1,11 @@ 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 \ md5.cpp \ miscfunctions.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,10 +1,11 @@ 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 \ folderwidget.h \ listviewplus.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 @@ -2,47 +2,59 @@ #include <qtoolbutton.h> #include <qpopupmenu.h> #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" 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); stop->addTo(toolbar); 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 @@ -2,16 +2,18 @@ #define MAINWINDOWBASE_H #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 { Q_OBJECT @@ -21,15 +23,17 @@ public: protected slots: void slotFoldersToggled(bool toggled); 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; }; #endif |