-rw-r--r-- | noncore/net/mail/opiemail.cpp | 101 |
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,18 +1,24 @@ | |||
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 | ||
18 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 24 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) |
@@ -32,5 +38,6 @@ void 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; |
@@ -38,5 +45,7 @@ void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | |||
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 | } |
@@ -46,14 +55,17 @@ void 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 | ||
@@ -73,28 +85,36 @@ void OpieMail::slotSendQueued() | |||
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 | } |
@@ -111,6 +131,5 @@ void 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 | ||
@@ -119,7 +138,6 @@ void OpieMail::slotEditAccounts() | |||
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(); |
@@ -140,7 +158,10 @@ void OpieMail::displayMail() | |||
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 | } |
@@ -151,5 +172,6 @@ void OpieMail::slotDeleteMail() | |||
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(); |
@@ -164,5 +186,6 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | |||
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())); |
@@ -177,8 +200,11 @@ void 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(); |
@@ -190,5 +216,6 @@ void OpieMail::refreshMailView(QList<RecMail>*list) | |||
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))); |
@@ -217,8 +244,10 @@ void OpieMail::slotMoveCopyMail() | |||
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>")); |