From 334a1b57629211cdd77af4ea6857bfc41ab0cefb Mon Sep 17 00:00:00 2001 From: alwin Date: Mon, 12 Jan 2004 15:47:40 +0000 Subject: when flush sendmail queue the user will be asked for selecting an smtp account to use when there are more than one smtp-accounts --- (limited to 'noncore/net') diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 552f0e5..184b5b3 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro @@ -13,7 +13,8 @@ HEADERS = defines.h \ settingsdialog.h \ statuswidget.h \ newmaildir.h \ - selectstore.h + selectstore.h \ + selectsmtp.h SOURCES = main.cpp \ opiemail.cpp \ @@ -29,7 +30,8 @@ SOURCES = main.cpp \ settingsdialog.cpp \ statuswidget.cpp \ newmaildir.cpp \ - selectstore.cpp + selectstore.cpp \ + selectsmtp.cpp INTERFACES = editaccountsui.ui \ selectmailtypeui.ui \ diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index d3d3cdb..ea0019d 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -13,6 +13,7 @@ #include "mailistviewitem.h" #include "viewmail.h" #include "selectstore.h" +#include "selectsmtp.h" OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) : MainWindow( parent, name, WStyle_ContextHelp ) @@ -68,15 +69,30 @@ void OpieMail::slotSendQueued() SMTPaccount *smtp = 0; QList list = settings->getAccounts(); + QList smtpList; + smtpList.setAutoDelete(false); Account *it; -// if (list.count()==1) { - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) { - smtp = static_cast(it); - break; - } + for ( it = list.first(); it; it = list.next() ) { + if ( it->getType().compare( "SMTP" ) == 0 ) { + smtp = static_cast(it); + smtpList.append(smtp); } -// } + } + if (smtpList.count()==0) { + QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); + return; + } + if (smtpList.count()==1) { + smtp = smtpList.at(0); + } else { + smtp = 0; + selectsmtp selsmtp; + selsmtp.setSelectionlist(&smtpList); + selsmtp.showMaximized(); + if (selsmtp.exec()==QDialog::Accepted) { + smtp = selsmtp.selected_smtp(); + } + } if (smtp) { SMTPwrapper * wrap = new SMTPwrapper(settings); if ( wrap->flushOutbox(smtp) ) { diff --git a/noncore/net/mail/selectsmtp.cpp b/noncore/net/mail/selectsmtp.cpp new file mode 100644 index 0000000..e82c6ca --- a/dev/null +++ b/noncore/net/mail/selectsmtp.cpp @@ -0,0 +1,56 @@ +#include "selectsmtp.h" +#include +#include +#include +#include +#include +#include +#include +#include + +selectsmtp::selectsmtp(QWidget* parent, const char* name, bool modal, WFlags fl) + : selectstoreui(parent,name,modal,fl) +{ + //m_smtpList.setAutoDelete(false); + m_smtpList = 0; + //headlabel->setText(tr("
Select SMTP account to use
")); + headlabel->hide(); + folderSelection->hide(); + folderLabel->hide(); + accountlabel->setText("
SMTP Accounts
"); + Line1->hide(); + newFoldersel->hide(); + newFolderedit->hide(); + newFolderLabel->hide(); + Line2->hide(); + selMove->hide(); + m_current_smtp = 0; + setCaption(tr("Select SMTP Account")); +} + +selectsmtp::~selectsmtp() +{ +} + +void selectsmtp::slotAccountselected(int which) +{ + if (!m_smtpList || (unsigned)which>=m_smtpList->count() || which < 0) { + m_current_smtp = 0; + return; + } + m_current_smtp = m_smtpList->at(which); +} + +void selectsmtp::setSelectionlist(QList*list) +{ + m_smtpList = list; + accountSelection->clear(); + for (unsigned i = 0; m_smtpList!=0 && i < m_smtpList->count(); ++i) { + accountSelection->insertItem( m_smtpList->at(i)->getAccountName()); + } +} + +SMTPaccount*selectsmtp::selected_smtp() +{ + return m_current_smtp; +} diff --git a/noncore/net/mail/selectsmtp.h b/noncore/net/mail/selectsmtp.h new file mode 100644 index 0000000..4bb2437 --- a/dev/null +++ b/noncore/net/mail/selectsmtp.h @@ -0,0 +1,27 @@ +#ifndef __selectsmtp_h +#define __selectstmp_h + +#include +#include "selectstoreui.h" +#include + +class SMTPaccount; + +class selectsmtp : public selectstoreui +{ + Q_OBJECT +public: + selectsmtp(QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 ); + virtual ~selectsmtp(); + void setSelectionlist(QList*list); + SMTPaccount*selected_smtp(); + +protected: + QList*m_smtpList; + SMTPaccount*m_current_smtp; + +protected slots: + virtual void slotAccountselected(int); +}; + +#endif -- cgit v0.9.0.2