summaryrefslogtreecommitdiff
path: root/noncore
authorleseb <leseb>2002-06-16 16:15:47 (UTC)
committer leseb <leseb>2002-06-16 16:15:47 (UTC)
commitea69cfbbde29fef2f792d1eab702699aada088bf (patch) (side-by-side diff)
tree1b908b905a16deaba7331d2f0b0c844f94235da0 /noncore
parentd4414131cdf32677e8d54a18827f2e772718c3f7 (diff)
downloadopie-ea69cfbbde29fef2f792d1eab702699aada088bf.zip
opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.gz
opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.bz2
Fix memory leaks
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composer.cpp28
-rw-r--r--noncore/unsupported/mail2/composer.h5
-rw-r--r--noncore/unsupported/mail2/mainwindow.cpp26
-rw-r--r--noncore/unsupported/mail2/searchdiag.cpp6
-rw-r--r--noncore/unsupported/mail2/viewmail.cpp44
-rw-r--r--noncore/unsupported/mail2/viewmail.h5
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,57 +1,83 @@
#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++) {
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
@@ -17,36 +17,41 @@ public:
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
@@ -27,39 +27,39 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl)
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
@@ -103,26 +103,26 @@ 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,38 +1,39 @@
#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>"
@@ -52,24 +53,49 @@ ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *paren
.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("&"), "&amp;");
string_.replace(QRegExp("<"), "&lt;");
string_.replace(QRegExp(">"), "&gt;");
string_.replace(QRegExp("\\n"), "<br>");
return string_;
}
void ViewMail::slotReply()
{
@@ -92,28 +118,28 @@ void ViewMail::slotReply()
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());
@@ -136,28 +162,28 @@ void ViewMail::slotForward()
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())));
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
@@ -34,32 +34,37 @@ public:
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