summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/mail.pro6
-rw-r--r--noncore/net/mail/opiemail.cpp22
-rw-r--r--noncore/net/mail/selectsmtp.cpp56
-rw-r--r--noncore/net/mail/selectsmtp.h27
4 files changed, 106 insertions, 5 deletions
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
@@ -1,59 +1,61 @@
CONFIG += qt warn_on debug quick-app
HEADERS = defines.h \
editaccounts.h \
composemail.h \
accountview.h \
accountitem.h \
mainwindow.h \
viewmail.h \
viewmailbase.h \
opiemail.h \
mailistviewitem.h \
settingsdialog.h \
statuswidget.h \
newmaildir.h \
- selectstore.h
+ selectstore.h \
+ selectsmtp.h
SOURCES = main.cpp \
opiemail.cpp \
mainwindow.cpp \
accountview.cpp \
accountitem.cpp \
composemail.cpp \
addresspicker.cpp \
editaccounts.cpp \
viewmail.cpp \
viewmailbase.cpp \
mailistviewitem.cpp \
settingsdialog.cpp \
statuswidget.cpp \
newmaildir.cpp \
- selectstore.cpp
+ selectstore.cpp \
+ selectsmtp.cpp
INTERFACES = editaccountsui.ui \
selectmailtypeui.ui \
imapconfigui.ui \
pop3configui.ui \
nntpconfigui.ui \
smtpconfigui.ui \
addresspickerui.ui \
composemailui.ui \
settingsdialogui.ui \
statuswidgetui.ui \
newmaildirui.ui \
selectstoreui.ui
INCLUDEPATH += $(OPIEDIR)/include
CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
contains( CONFTEST, y ){
LIBS += -lqpe -lopie -lmailwrapper -liconv
}else{
LIBS += -lqpe -lopie -lmailwrapper
}
TARGET = opiemail
include ( $(OPIEDIR)/include.pro )
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
@@ -1,175 +1,191 @@
#include <qmessagebox.h>
#include "settingsdialog.h"
#include "opiemail.h"
#include "editaccounts.h"
#include "composemail.h"
#include <libmailwrapper/smtpwrapper.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qapplication.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
#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 )
{
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
OpieMail::~OpieMail()
{
if (settings) delete settings;
}
void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
{
// copied from old mail2
if (msg == "writeMail(QString,QString)") {
QDataStream stream(data,IO_ReadOnly);
QString name, email;
stream >> name >> email;
// removing the whitespaces at beginning and end is needed!
slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
} else if (msg == "newMail()") {
slotComposeMail();
}
}
void OpieMail::slotwriteMail(const QString&name,const QString&email)
{
ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
if (!email.isEmpty()) {
if (!name.isEmpty()) {
compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
} else {
compose.setTo(email);
}
}
compose.showMaximized();
compose.slotAdjustColumns();
compose.exec();
}
void OpieMail::slotComposeMail()
{
qDebug( "Compose Mail" );
slotwriteMail(0l,0l);
}
void OpieMail::slotSendQueued()
{
qDebug( "Send Queued" );
SMTPaccount *smtp = 0;
QList<Account> list = settings->getAccounts();
+ QList<SMTPaccount> 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<SMTPaccount *>(it);
- break;
+ 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) ) {
QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
}
}
}
void OpieMail::slotSearchMails()
{
qDebug( "Search Mails" );
}
void OpieMail::slotEditSettings()
{
SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
settingsDialog.showMaximized();
settingsDialog.exec();
}
void OpieMail::slotEditAccounts()
{
qDebug( "Edit Accounts" );
EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
eaDialog.showMaximized();
eaDialog.slotAdjustColumns();
eaDialog.exec();
if ( settings ) delete settings;
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
void OpieMail::displayMail()
{
QListViewItem*item = mailView->currentItem();
if (!item) return;
RecMail mail = ((MailListViewItem*)item)->data();
RecBody body = folderView->fetchBody(mail);
ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
readMail.setBody( body );
readMail.setMail( mail );
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted ) {
folderView->refreshCurrent();
} else {
( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
}
}
void OpieMail::slotDeleteMail()
{
if (!mailView->currentItem()) return;
RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
mail.Wrapper()->deleteMail( mail );
folderView->refreshCurrent();
}
}
void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
{
/* just the RIGHT button - or hold on pda */
if (button!=2) {return;}
qDebug("Event right/hold");
if (!item) return;
QPopupMenu *m = new QPopupMenu(0);
if (m) {
m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
}
}
void OpieMail::slotShowFolders( bool show )
{
qDebug( "Show Folders" );
if ( show && folderView->isHidden() ) {
qDebug( "-> showing" );
folderView->show();
} else if ( !show && !folderView->isHidden() ) {
qDebug( "-> hiding" );
folderView->hide();
}
}
void OpieMail::refreshMailView(QList<RecMail>*list)
{
MailListViewItem*item = 0;
mailView->clear();
for (unsigned int i = 0; i < list->count();++i) {
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 <libmailwrapper/mailwrapper.h>
+#include <qlist.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qframe.h>
+#include <qlineedit.h>
+#include <qcombobox.h>
+
+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("<center>Select SMTP account to use</center>"));
+ headlabel->hide();
+ folderSelection->hide();
+ folderLabel->hide();
+ accountlabel->setText("<center>SMTP Accounts</center>");
+ 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<SMTPaccount>*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 <qt.h>
+#include "selectstoreui.h"
+#include <qlist.h>
+
+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<SMTPaccount>*list);
+ SMTPaccount*selected_smtp();
+
+protected:
+ QList<SMTPaccount>*m_smtpList;
+ SMTPaccount*m_current_smtp;
+
+protected slots:
+ virtual void slotAccountselected(int);
+};
+
+#endif