author | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
commit | ea69cfbbde29fef2f792d1eab702699aada088bf (patch) (side-by-side diff) | |
tree | 1b908b905a16deaba7331d2f0b0c844f94235da0 | |
parent | d4414131cdf32677e8d54a18827f2e772718c3f7 (diff) | |
download | opie-ea69cfbbde29fef2f792d1eab702699aada088bf.zip opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.gz opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.bz2 |
Fix memory leaks
-rw-r--r-- | noncore/unsupported/mail2/composer.cpp | 28 | ||||
-rw-r--r-- | noncore/unsupported/mail2/composer.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/mail2/mainwindow.cpp | 26 | ||||
-rw-r--r-- | noncore/unsupported/mail2/searchdiag.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.cpp | 44 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.h | 5 |
6 files changed, 88 insertions, 26 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp index 82ed117..7f65dba 100644 --- a/noncore/unsupported/mail2/composer.cpp +++ b/noncore/unsupported/mail2/composer.cpp @@ -1,218 +1,244 @@ #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 "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) - : ComposerBase(parent, name, fl) + : ComposerBase(parent, name, fl), _inLoop(false) { abort->setEnabled(false); to->setFocus(); connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); 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) { + _inLoop = false; + qApp->exit_loop(); + } +} + +void Composer::exec() +{ + show(); + + if (!_inLoop) { + _inLoop = true; + qApp->enter_loop(); + } +} + void Composer::setSendMail(SendMail &sendMail) { to->setText(sendMail.to()); cc->setText(sendMail.cc()); bcc->setText(sendMail.bcc()); subject->setText(sendMail.subject()); message->setText(sendMail.message()); _inReplyTo = sendMail.inReplyTo(); 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()); } 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); } else if (itemid == POPUP_ATTACH_DESC) { QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); } else if (itemid == POPUP_ATTACH_REMOVE) { attachView->takeItem(attachView->currentItem()); } } void Composer::slotSendMail() { 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; } SendMail smail; smail.setFrom(from->currentText()); smail.setReplyTo(replyto->text()); smail.setTo(to->text()); smail.setCc(cc->text()); smail.setBcc(bcc->text()); smail.setSubject(subject->text()); smail.setMessage(message->text()); smail.setNeedsMime(attachView->childCount() == 0 ? false : true); smail.setAccount(accountsLoaded[from->currentItem()]); if (priority->currentItem() == POPUP_PRIO_LOW) { smail.setPriority("Low"); // No i18n on purpose } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { smail.setPriority("Normal"); // No i18n on purpose } else if (priority->currentItem() == POPUP_PRIO_HIGH) { smail.setPriority("High"); // No i18n on purpose } QValueList<Attachment> attachments; QListViewItem *item; for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { attachments.append(((AttachViewItem *)item)->attachment()); } smail.setAttachments(attachments); 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::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); } 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()) { if (!(*it).realName().isEmpty()) from->insertItem((*it).realName() + " <" + (*it).email() + ">", i); else from->insertItem((*it).email()); accountsLoaded.append(*it); i++; } } } void Composer::slotFromChanged(int id) { Account account = accountsLoaded[id]; if (account.defaultCc()) cc->setText(account.cc()); if (account.defaultBcc()) bcc->setText(account.bcc()); if (account.defaultReplyTo()) replyto->setText(account.replyTo()); if (!account.signature().isEmpty()) message->setText(message->text() + "\n\n-- \n" + account.signature()); } void Composer::slotOpenAddressPicker() { if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) { if (to->text().isEmpty()) { to->setText(AddressPicker::getNames()); } else { to->setText(to->text() + ", " + AddressPicker::getNames()); } } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) { if (cc->text().isEmpty()) { cc->setText(AddressPicker::getNames()); } else { cc->setText(cc->text() + ", " + AddressPicker::getNames()); } } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) { if (bcc->text().isEmpty()) { bcc->setText(AddressPicker::getNames()); } else { bcc->setText(bcc->text() + ", " + AddressPicker::getNames()); } } } void Composer::slotAddAttach() { DocLnk lnk = AttachDiag::getFile(this); if (lnk.name().isEmpty()) return; Attachment attachment; 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 a1af121..2640d7e 100644 --- a/noncore/unsupported/mail2/composer.h +++ b/noncore/unsupported/mail2/composer.h @@ -1,52 +1,57 @@ #ifndef COMPOSER_H #define COMPOSER_H #include <qlistview.h> #include <qpe/applnk.h> #include "mailfactory.h" #include "composerbase.h" #include "configfile.h" class AttachViewItem : public QListViewItem { public: AttachViewItem(QListView *parent, Attachment &attachment); 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(); + + void hide(); + void exec(); void setSendMail(SendMail &sendMail); protected slots: void slotPopupHandler(int itemid); void slotSendMail(); 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 _inLoop; QString _inReplyTo; }; #endif diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp index 4d15e23..2230dc0 100644 --- a/noncore/unsupported/mail2/mainwindow.cpp +++ b/noncore/unsupported/mail2/mainwindow.cpp @@ -1,65 +1,65 @@ #include <qprogressbar.h> #include <qmessagebox.h> #include <qaction.h> #include <qlabel.h> #include "folderwidget.h" #include "mainwindow.h" #include "configdiag.h" #include "configfile.h" #include "searchdiag.h" #include "mailtable.h" #include "composer.h" #include "viewmail.h" MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) : MainWindowBase(parent, name, fl) { stop->setEnabled(false); connect(folderView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &))); 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(findmails, SIGNAL(activated()), SLOT(slotSearch())); connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); } void MainWindow::slotCompose() { - Composer *composer = new Composer(); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.showMaximized(); + composer.exec(); } void MainWindow::slotSearch() { - SearchDiag *searchDiag = new SearchDiag(this, 0, true); - searchDiag->showMaximized(); - searchDiag->show(); + SearchDiag searchDiag(this, 0, true); + searchDiag.showMaximized(); + searchDiag.exec(); } void MainWindow::slotConfigure() { - ConfigDiag *configDiag = new ConfigDiag(this, 0, true); - configDiag->showMaximized(); - configDiag->show(); + ConfigDiag configDiag(this, 0, true); + configDiag.showMaximized(); + configDiag.exec(); - connect(configDiag, SIGNAL(changed()), folderView, SLOT(update())); + connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update())); } void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) { - ViewMail *viewMail = new ViewMail(mail, handler); - viewMail->showMaximized(); - viewMail->show(); + ViewMail viewMail(mail, handler, this, 0, true); + viewMail.showMaximized(); + viewMail.exec(); } diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp index 33b8afb..907f6ff 100644 --- a/noncore/unsupported/mail2/searchdiag.cpp +++ b/noncore/unsupported/mail2/searchdiag.cpp @@ -1,128 +1,128 @@ #include <qmessagebox.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qlineedit.h> #include <qpe/qpeapplication.h> #include "imaphandler.h" #include "searchdiag.h" #include "viewmail.h" #define INMENU_BODY 0 #define INMENU_HEADERF 1 #define INMENU_SUBJECT 2 #define INMENU_FROM 3 #define INMENU_TO 4 SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) : SearchDiagBase(parent, name, fl) { _selected = false; in->insertItem(tr("Body"), INMENU_BODY); in->insertItem(tr("Header Field"), INMENU_HEADERF); in->insertItem(tr("Subject"), INMENU_SUBJECT); in->insertItem(tr("From"), INMENU_FROM); in->insertItem(tr("To"), INMENU_TO); connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder))); connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int))); connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(slotMailClicked(IMAPResponseFETCH, IMAPHandler *))); } void SearchDiag::accept() { if (searchFor->text().isEmpty()) { QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok")); return; } if (!_selected) { QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok")); return; } if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) { QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok")); return; } _folder.topFolder().handler()->iSelect(_folder.fullName()); connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); } void SearchDiag::folderSelected(Folder folder) { _selected = true; _folder = folder; } void SearchDiag::slotIMAPSelect(IMAPResponse &response) { disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); if (response.statusResponse().status() == IMAPResponseEnums::OK) { if (in->currentItem() == INMENU_BODY) { response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\""); } else if (in->currentItem() == INMENU_HEADERF) { response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\""); } else if (in->currentItem() == INMENU_SUBJECT) { response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\""); } else if (in->currentItem() == INMENU_FROM) { response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\""); } else if (in->currentItem() == INMENU_TO) { response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\""); } else return; connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSearch(IMAPResponse &))); } else { QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); } } void SearchDiag::slotIMAPSearch(IMAPResponse &response) { disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); if (response.statusResponse().status() == IMAPResponseEnums::OK) { IMAPResponseSEARCH results = response.SEARCH()[0]; if (results.mails().count() == 0) { QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok")); return; } response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID"); connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); } else { QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); } } void SearchDiag::slotIMAPFetch(IMAPResponse &response) { disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); if (response.statusResponse().status() == IMAPResponseEnums::OK) { mailTable->setHeaders(response.FETCH()); } else { QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); } } void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) { - ViewMail *viewMail = new ViewMail(fetch, _folder.topFolder().handler()); - viewMail->showMaximized(); - viewMail->show(); + ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); + viewMail.showMaximized(); + viewMail.exec(); } void SearchDiag::slotInItemActivated(int index) { if (index == INMENU_HEADERF) { other->setEnabled(true); } else { other->setEnabled(false); } } diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index ae1f5f3..3c88d99 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp @@ -1,172 +1,198 @@ #include <qtextbrowser.h> #include <qmessagebox.h> #include <qaction.h> +#include <qapplication.h> #include "mailfactory.h" #include "composer.h" #include "viewmail.h" AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) : QListViewItem(parent), _attachItemStore(attachItemStore) { setText(0, _attachItemStore.mimeType()); setText(1, _attachItemStore.fileName()); setText(2, _attachItemStore.description()); } AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) : QListViewItem(parent), _attachItemStore(attachItemStore) { setText(0, _attachItemStore.mimeType()); setText(1, _attachItemStore.fileName()); setText(2, _attachItemStore.description()); } ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) - : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler) + : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) { setCaption(caption().arg(mail.envelope().from()[0].name())); _gotBody = false; _mailHtml = tr( "<html><body>" "<div align=center><b>%1</b></div>" "<b>From:</b> %2<br>" "<b>To:</b> %3<br>" "%4" "%5" "<b>Date:</b> %6<hr>" "<font face=fixed>%7</font>") .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") : deHtml(mail.envelope().subject()))) .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") : mail.envelope().from().toString())) .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") : mail.envelope().to().toString())) .arg(mail.envelope().cc().toString().isNull() ? QString(0) : tr("<b>Cc:</b> %1<br>").arg(deHtml(mail.envelope().cc().toString()))) .arg(mail.envelope().bcc().toString().isNull() ? QString(0) : tr("<b>Bcc:</b> %1<br>").arg(deHtml(mail.envelope().bcc().toString()))) .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") : mail.envelope().mailDate()) .arg("%1"); connect(reply, SIGNAL(activated()), SLOT(slotReply())); connect(forward, SIGNAL(activated()), SLOT(slotForward())); attachments->setEnabled(_gotBody); browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); } +ViewMail::~ViewMail() +{ + hide(); +} + +void ViewMail::hide() +{ + QWidget::hide(); + + if (_inLoop) { + _inLoop = false; + qApp->exit_loop(); + } +} + +void ViewMail::exec() +{ + show(); + + if (!_inLoop) { + _inLoop = true; + qApp->enter_loop(); + } +} + QString ViewMail::deHtml(const QString &string) { QString string_ = string; string_.replace(QRegExp("&"), "&"); string_.replace(QRegExp("<"), "<"); string_.replace(QRegExp(">"), ">"); string_.replace(QRegExp("\\n"), "<br>"); return string_; } void ViewMail::slotReply() { if (!_gotBody) { QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); return; } QString rtext; rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose .arg(_mail.envelope().from()[0].toString()) .arg(_mail.envelope().mailDate()); QString text = _mail.bodyPart(1).data(); QStringList lines = QStringList::split(QRegExp("\\n"), text); QStringList::Iterator it; for (it = lines.begin(); it != lines.end(); it++) { rtext += "> " + *it + "\n"; } rtext += "\n"; QString prefix; if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose SendMail sendMail; sendMail.setTo(_mail.envelope().from()[0].toString()); sendMail.setSubject(prefix + _mail.envelope().subject()); sendMail.setInReplyTo(_mail.envelope().messageId()); sendMail.setMessage(rtext); - Composer *composer = new Composer(0, 0, Qt::WType_Modal); - composer->setSendMail(sendMail); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.setSendMail(sendMail); + composer.showMaximized(); + composer.exec(); } void ViewMail::slotForward() { if (!_gotBody) { QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); return; } QString ftext; ftext += QString("\n----- Forwarded message from %1 -----\n\n") .arg(_mail.envelope().from()[0].toString()); if (!_mail.envelope().mailDate().isNull()) ftext += QString("Date: %1\n") .arg(_mail.envelope().mailDate()); if (!_mail.envelope().from()[0].toString().isNull()) ftext += QString("From: %1\n") .arg(_mail.envelope().from()[0].toString()); if (!_mail.envelope().to().toString().isNull()) ftext += QString("To: %1\n") .arg(_mail.envelope().to().toString()); if (!_mail.envelope().cc().toString().isNull()) ftext += QString("Cc: %1\n") .arg(_mail.envelope().cc().toString()); if (!_mail.envelope().bcc().toString().isNull()) ftext += QString("Bcc: %1\n") .arg(_mail.envelope().bcc().toString()); if (!_mail.envelope().subject().isNull()) ftext += QString("Subject: %1\n") .arg(_mail.envelope().subject()); ftext += QString("\n%1\n") .arg(_mail.bodyPart(1).data()); ftext += QString("----- End forwarded message -----\n"); SendMail sendMail; sendMail.setSubject("Fwd: " + _mail.envelope().subject()); sendMail.setMessage(ftext); - Composer *composer = new Composer(0, 0, Qt::WType_Modal); - composer->setSendMail(sendMail); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.setSendMail(sendMail); + composer.showMaximized(); + composer.exec(); } void ViewMail::slotIMAPUid(IMAPResponse &response) { disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); if (response.statusResponse().status() == IMAPResponseEnums::OK) { QValueList<IMAPResponseBodyPart> bodyParts; bodyParts.append(response.FETCH()[0].bodyPart(1)); _mail.setBodyParts(bodyParts); browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(1).data()))); // fillList(response.FETCH()[0].bodyStructure()); _gotBody = true; } else { QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); } } diff --git a/noncore/unsupported/mail2/viewmail.h b/noncore/unsupported/mail2/viewmail.h index a013e43..efc2300 100644 --- a/noncore/unsupported/mail2/viewmail.h +++ b/noncore/unsupported/mail2/viewmail.h @@ -1,65 +1,70 @@ #ifndef VIEWMAIL_H #define VIEWMAIL_H #include <qlistview.h> #include "viewmailbase.h" #include "imapresponse.h" #include "mailtable.h" class AttachItemStore { public: void setMimeType(QString mimeType) { _mimeType = mimeType; } QString mimeType() { return _mimeType; } void setFileName(QString fileName) { _fileName = fileName; } QString fileName() { return _fileName; } void setDescription(QString description) { _description = description; } QString description() { return _description; } void setPartNum(QString partNum) { _partNum = partNum; } QString partNum() { return _partNum; } private: QString _mimeType, _fileName, _description, _partNum; }; class AttachItem : public QListViewItem { public: AttachItem(QListView *parent, AttachItemStore &attachment); AttachItem(QListViewItem *parent, AttachItemStore &attachment); AttachItemStore attachItemStore() { return _attachItemStore; } private: AttachItemStore _attachItemStore; }; class ViewMail : public ViewMailBase { Q_OBJECT public: ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); + ~ViewMail(); + + void hide(); + void exec(); protected: // void fillList(IMAPResponseBODYSTRUCTURE &structure); QString deHtml(const QString &string); protected slots: void slotReply(); void slotForward(); void slotIMAPUid(IMAPResponse &response); private: + bool _inLoop; IMAPResponseFETCH _mail; IMAPHandler *_handler; QString _mailHtml; bool _gotBody; }; #endif |