summaryrefslogtreecommitdiff
path: root/noncore/net/mail/opiemail.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/opiemail.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/opiemail.cpp101
1 files changed, 65 insertions, 36 deletions
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 0795436..abf93dc 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,19 +1,25 @@
1#include <qmessagebox.h> 1
2#include "settingsdialog.h" 2#include "settingsdialog.h"
3#include "opiemail.h" 3#include "opiemail.h"
4#include "editaccounts.h" 4#include "editaccounts.h"
5#include "composemail.h" 5#include "composemail.h"
6#include "mailistviewitem.h"
7#include "viewmail.h"
8#include "selectstore.h"
9#include "selectsmtp.h"
10
11/* OPIE */
6#include <libmailwrapper/smtpwrapper.h> 12#include <libmailwrapper/smtpwrapper.h>
13#include <libmailwrapper/mailtypes.h>
14#include <libmailwrapper/abstractmail.h>
7#include <qpe/qcopenvelope_qws.h> 15#include <qpe/qcopenvelope_qws.h>
8#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qpeapplication.h>
18
19/* QT */
20#include <qmessagebox.h>
9#include <qaction.h> 21#include <qaction.h>
10#include <qapplication.h> 22#include <qapplication.h>
11#include <libmailwrapper/mailtypes.h>
12#include <libmailwrapper/abstractmail.h>
13#include "mailistviewitem.h"
14#include "viewmail.h"
15#include "selectstore.h"
16#include "selectsmtp.h"
17 23
18OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 24OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
19 : MainWindow( parent, name, WStyle_ContextHelp ) 25 : MainWindow( parent, name, WStyle_ContextHelp )
@@ -31,13 +37,16 @@ OpieMail::~OpieMail()
31void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 37void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
32{ 38{
33 // copied from old mail2 39 // copied from old mail2
34 if (msg == "writeMail(QString,QString)") { 40 if (msg == "writeMail(QString,QString)")
41 {
35 QDataStream stream(data,IO_ReadOnly); 42 QDataStream stream(data,IO_ReadOnly);
36 QString name, email; 43 QString name, email;
37 stream >> name >> email; 44 stream >> name >> email;
38 // removing the whitespaces at beginning and end is needed! 45 // removing the whitespaces at beginning and end is needed!
39 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 46 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
40 } else if (msg == "newMail()") { 47 }
48 else if (msg == "newMail()")
49 {
41 slotComposeMail(); 50 slotComposeMail();
42 } 51 }
43} 52}
@@ -45,16 +54,19 @@ void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
45void OpieMail::slotwriteMail(const QString&name,const QString&email) 54void OpieMail::slotwriteMail(const QString&name,const QString&email)
46{ 55{
47 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 56 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
48 if (!email.isEmpty()) { 57 if (!email.isEmpty())
49 if (!name.isEmpty()) { 58 {
59 if (!name.isEmpty())
60 {
50 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 61 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
51 } else { 62 }
63 else
64 {
52 compose.setTo(email); 65 compose.setTo(email);
53 } 66 }
54 } 67 }
55 compose.showMaximized();
56 compose.slotAdjustColumns(); 68 compose.slotAdjustColumns();
57 compose.exec(); 69 QPEApplication::execDialog( &compose );
58} 70}
59 71
60void OpieMail::slotComposeMail() 72void OpieMail::slotComposeMail()
@@ -72,30 +84,38 @@ void OpieMail::slotSendQueued()
72 QList<SMTPaccount> smtpList; 84 QList<SMTPaccount> smtpList;
73 smtpList.setAutoDelete(false); 85 smtpList.setAutoDelete(false);
74 Account *it; 86 Account *it;
75 for ( it = list.first(); it; it = list.next() ) { 87 for ( it = list.first(); it; it = list.next() )
76 if ( it->getType().compare( "SMTP" ) == 0 ) { 88 {
89 if ( it->getType().compare( "SMTP" ) == 0 )
90 {
77 smtp = static_cast<SMTPaccount *>(it); 91 smtp = static_cast<SMTPaccount *>(it);
78 smtpList.append(smtp); 92 smtpList.append(smtp);
79 } 93 }
80 } 94 }
81 if (smtpList.count()==0) { 95 if (smtpList.count()==0)
96 {
82 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 97 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
83 return; 98 return;
84 } 99 }
85 if (smtpList.count()==1) { 100 if (smtpList.count()==1)
101 {
86 smtp = smtpList.at(0); 102 smtp = smtpList.at(0);
87 } else { 103 }
104 else
105 {
88 smtp = 0; 106 smtp = 0;
89 selectsmtp selsmtp; 107 selectsmtp selsmtp;
90 selsmtp.setSelectionlist(&smtpList); 108 selsmtp.setSelectionlist(&smtpList);
91 selsmtp.showMaximized(); 109 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
92 if (selsmtp.exec()==QDialog::Accepted) { 110 {
93 smtp = selsmtp.selected_smtp(); 111 smtp = selsmtp.selected_smtp();
94 } 112 }
95 } 113 }
96 if (smtp) { 114 if (smtp)
115 {
97 SMTPwrapper * wrap = new SMTPwrapper(smtp); 116 SMTPwrapper * wrap = new SMTPwrapper(smtp);
98 if ( wrap->flushOutbox() ) { 117 if ( wrap->flushOutbox() )
118 {
99 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 119 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
100 } 120 }
101 delete wrap; 121 delete wrap;
@@ -110,17 +130,15 @@ void OpieMail::slotSearchMails()
110void OpieMail::slotEditSettings() 130void OpieMail::slotEditSettings()
111{ 131{
112 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 132 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
113 settingsDialog.showMaximized(); 133 QPEApplication::execDialog( &settingsDialog );
114 settingsDialog.exec();
115} 134}
116 135
117void OpieMail::slotEditAccounts() 136void OpieMail::slotEditAccounts()
118{ 137{
119 qDebug( "Edit Accounts" ); 138 qDebug( "Edit Accounts" );
120 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 139 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
121 eaDialog.showMaximized();
122 eaDialog.slotAdjustColumns(); 140 eaDialog.slotAdjustColumns();
123 eaDialog.exec(); 141 QPEApplication::execDialog( &eaDialog );
124 if ( settings ) delete settings; 142 if ( settings ) delete settings;
125 settings = new Settings(); 143 settings = new Settings();
126 144
@@ -139,9 +157,12 @@ void OpieMail::displayMail()
139 readMail.showMaximized(); 157 readMail.showMaximized();
140 readMail.exec(); 158 readMail.exec();
141 159
142 if ( readMail.deleted ) { 160 if ( readMail.deleted )
161 {
143 folderView->refreshCurrent(); 162 folderView->refreshCurrent();
144 } else { 163 }
164 else
165 {
145 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); 166 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
146 } 167 }
147} 168}
@@ -150,7 +171,8 @@ void OpieMail::slotDeleteMail()
150{ 171{
151 if (!mailView->currentItem()) return; 172 if (!mailView->currentItem()) return;
152 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 173 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
153 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 ) { 174 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 )
175 {
154 mail.Wrapper()->deleteMail( mail ); 176 mail.Wrapper()->deleteMail( mail );
155 folderView->refreshCurrent(); 177 folderView->refreshCurrent();
156 } 178 }
@@ -163,7 +185,8 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
163 qDebug("Event right/hold"); 185 qDebug("Event right/hold");
164 if (!item) return; 186 if (!item) return;
165 QPopupMenu *m = new QPopupMenu(0); 187 QPopupMenu *m = new QPopupMenu(0);
166 if (m) { 188 if (m)
189 {
167 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 190 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
168 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 191 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
169 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 192 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
@@ -176,10 +199,13 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
176void OpieMail::slotShowFolders( bool show ) 199void OpieMail::slotShowFolders( bool show )
177{ 200{
178 qDebug( "Show Folders" ); 201 qDebug( "Show Folders" );
179 if ( show && folderView->isHidden() ) { 202 if ( show && folderView->isHidden() )
203 {
180 qDebug( "-> showing" ); 204 qDebug( "-> showing" );
181 folderView->show(); 205 folderView->show();
182 } else if ( !show && !folderView->isHidden() ) { 206 }
207 else if ( !show && !folderView->isHidden() )
208 {
183 qDebug( "-> hiding" ); 209 qDebug( "-> hiding" );
184 folderView->hide(); 210 folderView->hide();
185 } 211 }
@@ -189,7 +215,8 @@ void OpieMail::refreshMailView(QList<RecMail>*list)
189{ 215{
190 MailListViewItem*item = 0; 216 MailListViewItem*item = 0;
191 mailView->clear(); 217 mailView->clear();
192 for (unsigned int i = 0; i < list->count();++i) { 218 for (unsigned int i = 0; i < list->count();++i)
219 {
193 item = new MailListViewItem(mailView,item); 220 item = new MailListViewItem(mailView,item);
194 item->storeData(*(list->at(i))); 221 item->storeData(*(list->at(i)));
195 item->showEntry(); 222 item->showEntry();
@@ -216,10 +243,12 @@ void OpieMail::slotMoveCopyMail()
216 targetMail = sels.currentMail(); 243 targetMail = sels.currentMail();
217 targetFolder = sels.currentFolder(); 244 targetFolder = sels.currentFolder();
218 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || 245 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) ||
219 targetFolder.isEmpty()) { 246 targetFolder.isEmpty())
247 {
220 return; 248 return;
221 } 249 }
222 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { 250 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
251 {
223 QMessageBox::critical(0,tr("Error creating new Folder"), 252 QMessageBox::critical(0,tr("Error creating new Folder"),
224 tr("<center>Error while creating<br>new folder - breaking.</center>")); 253 tr("<center>Error while creating<br>new folder - breaking.</center>"));
225 return; 254 return;