-rw-r--r-- | kmicromail/opiemail.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index b701446..4436ad6 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,247 +1,248 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | 4 | ||
5 | #define protected public | 5 | #define protected public |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #undef protected | 7 | #undef protected |
8 | #include "koprefsdialog.h" | 8 | #include "koprefsdialog.h" |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | #include <libkdepim/externalapphandler.h> | 10 | #include <libkdepim/externalapphandler.h> |
11 | #include <libkdepim/kpimglobalprefs.h> | 11 | #include <libkdepim/kpimglobalprefs.h> |
12 | #ifdef MINIKDE_KDIALOG_H | 12 | #ifdef MINIKDE_KDIALOG_H |
13 | #undef MINIKDE_KDIALOG_H | 13 | #undef MINIKDE_KDIALOG_H |
14 | #endif | 14 | #endif |
15 | #include "settingsdialog.h" | 15 | #include "settingsdialog.h" |
16 | #include "opiemail.h" | 16 | #include "opiemail.h" |
17 | #include "editaccounts.h" | 17 | #include "editaccounts.h" |
18 | #include "composemail.h" | 18 | #include "composemail.h" |
19 | #include "mailistviewitem.h" | 19 | #include "mailistviewitem.h" |
20 | #include "viewmail.h" | 20 | #include "viewmail.h" |
21 | #include "selectstore.h" | 21 | #include "selectstore.h" |
22 | #include "selectsmtp.h" | 22 | #include "selectsmtp.h" |
23 | #include "accountitem.h" | 23 | #include "accountitem.h" |
24 | #include "accountview.h" | 24 | #include "accountview.h" |
25 | #include "klocale.h" | 25 | #include "klocale.h" |
26 | 26 | ||
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcursor.h> | 29 | #include <qcursor.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #ifdef DESKTOP_VERSION | 34 | #ifdef DESKTOP_VERSION |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #else | 36 | #else |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #endif | 38 | #endif |
39 | #include <libmailwrapper/smtpwrapper.h> | 39 | #include <libmailwrapper/smtpwrapper.h> |
40 | #include <libmailwrapper/mailtypes.h> | 40 | #include <libmailwrapper/mailtypes.h> |
41 | #include <libmailwrapper/abstractmail.h> | 41 | #include <libmailwrapper/abstractmail.h> |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | 43 | ||
44 | //using namespace Opie::Core; | 44 | //using namespace Opie::Core; |
45 | 45 | ||
46 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 46 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | mCurrentComposer = 0; | 49 | mCurrentComposer = 0; |
50 | settings = new Settings(); | 50 | settings = new Settings(); |
51 | tb = 0; | 51 | tb = 0; |
52 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
53 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
56 | folderView->setFocus(); | ||
56 | } | 57 | } |
57 | 58 | ||
58 | OpieMail::~OpieMail() | 59 | OpieMail::~OpieMail() |
59 | { | 60 | { |
60 | if (settings) delete settings; | 61 | if (settings) delete settings; |
61 | if ( tb ) | 62 | if ( tb ) |
62 | delete tb; | 63 | delete tb; |
63 | } | 64 | } |
64 | 65 | ||
65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 66 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
66 | { | 67 | { |
67 | 68 | ||
68 | } | 69 | } |
69 | #include <stdlib.h> | 70 | #include <stdlib.h> |
70 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 71 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
71 | { | 72 | { |
72 | // copied from old mail2 | 73 | // copied from old mail2 |
73 | static int ii = 0; | 74 | static int ii = 0; |
74 | //qDebug("QCOP CALL ############################# %d ", ii); | 75 | //qDebug("QCOP CALL ############################# %d ", ii); |
75 | //QString mess ( msg ); | 76 | //QString mess ( msg ); |
76 | //qDebug("Message = %s ",mess.latin1()); | 77 | //qDebug("Message = %s ",mess.latin1()); |
77 | ++ii; | 78 | ++ii; |
78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 79 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
79 | 80 | ||
80 | mPendingEmail = QString::null; | 81 | mPendingEmail = QString::null; |
81 | mPendingName = QString::null; | 82 | mPendingName = QString::null; |
82 | if (msg == "writeMail(QString,QString)") | 83 | if (msg == "writeMail(QString,QString)") |
83 | { | 84 | { |
84 | //qDebug("writeMail(QString,QString) "); | 85 | //qDebug("writeMail(QString,QString) "); |
85 | QDataStream stream(data,IO_ReadOnly); | 86 | QDataStream stream(data,IO_ReadOnly); |
86 | stream >> mPendingName >> mPendingEmail; | 87 | stream >> mPendingName >> mPendingEmail; |
87 | // removing the whitespaces at beginning and end is needed! | 88 | // removing the whitespaces at beginning and end is needed! |
88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 89 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
89 | } | 90 | } |
90 | else if (msg == "newMail()") | 91 | else if (msg == "newMail()") |
91 | { | 92 | { |
92 | //qDebug("slotComposeMail() "); | 93 | //qDebug("slotComposeMail() "); |
93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 94 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
94 | // and a QCOP call does not like a processevents in his execution | 95 | // and a QCOP call does not like a processevents in his execution |
95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 96 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 97 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
97 | // slotComposeMail(); | 98 | // slotComposeMail(); |
98 | } | 99 | } |
99 | else if (msg == "newMail(QString)") | 100 | else if (msg == "newMail(QString)") |
100 | { | 101 | { |
101 | //qDebug(" newMail(QString)"); | 102 | //qDebug(" newMail(QString)"); |
102 | QDataStream stream(data,IO_ReadOnly); | 103 | QDataStream stream(data,IO_ReadOnly); |
103 | stream >> mPendingName; | 104 | stream >> mPendingName; |
104 | // the format is | 105 | // the format is |
105 | // NAME <EMAIL>:SUBJECT | 106 | // NAME <EMAIL>:SUBJECT |
106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 107 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
107 | } else { | 108 | } else { |
108 | mPendingData = data; | 109 | mPendingData = data; |
109 | mPendingMessage = msg; | 110 | mPendingMessage = msg; |
110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 111 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
111 | } | 112 | } |
112 | 113 | ||
113 | //qDebug("END OpieMail::message "); | 114 | //qDebug("END OpieMail::message "); |
114 | } | 115 | } |
115 | void OpieMail::slotExtAppHandler() | 116 | void OpieMail::slotExtAppHandler() |
116 | { | 117 | { |
117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 118 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
118 | } | 119 | } |
119 | void OpieMail::slotwriteMail2(const QString& namemail ) | 120 | void OpieMail::slotwriteMail2(const QString& namemail ) |
120 | { | 121 | { |
121 | //qDebug("OpieMail::slotwriteMail2 "); | 122 | //qDebug("OpieMail::slotwriteMail2 "); |
122 | //qApp->processEvents(); | 123 | //qApp->processEvents(); |
123 | ComposeMail compose( settings, this, 0, true ); | 124 | ComposeMail compose( settings, this, 0, true ); |
124 | if ( !namemail.isEmpty() ) { | 125 | if ( !namemail.isEmpty() ) { |
125 | QString to = namemail; | 126 | QString to = namemail; |
126 | if ( namemail.find( " <") > 1 ) { | 127 | if ( namemail.find( " <") > 1 ) { |
127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 128 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
128 | } else | 129 | } else |
129 | if ( namemail.find( "<") > 1 ) { | 130 | if ( namemail.find( "<") > 1 ) { |
130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 131 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
131 | } | 132 | } |
132 | int sub = to.find( ">:"); | 133 | int sub = to.find( ">:"); |
133 | if ( sub > 0 ) { | 134 | if ( sub > 0 ) { |
134 | compose.setTo( to.left(sub+1) ); | 135 | compose.setTo( to.left(sub+1) ); |
135 | compose.setSubject( to.mid(sub+2) ); | 136 | compose.setSubject( to.mid(sub+2) ); |
136 | } else | 137 | } else |
137 | compose.setTo( to ); | 138 | compose.setTo( to ); |
138 | } | 139 | } |
139 | compose.slotAdjustColumns(); | 140 | compose.slotAdjustColumns(); |
140 | #ifndef DESKTOP_VERSION | 141 | #ifndef DESKTOP_VERSION |
141 | compose.showMaximized(); | 142 | compose.showMaximized(); |
142 | #endif | 143 | #endif |
143 | mCurrentComposer = &compose; | 144 | mCurrentComposer = &compose; |
144 | compose.exec(); | 145 | compose.exec(); |
145 | mCurrentComposer = 0; | 146 | mCurrentComposer = 0; |
146 | folderView->refreshOutgoing(); | 147 | folderView->refreshOutgoing(); |
147 | raise(); | 148 | raise(); |
148 | //qDebug("retttich "); | 149 | //qDebug("retttich "); |
149 | } | 150 | } |
150 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 151 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
151 | { | 152 | { |
152 | // qDebug("OpieMail::slotwriteMail "); | 153 | // qDebug("OpieMail::slotwriteMail "); |
153 | ComposeMail compose( settings, this, 0, true ); | 154 | ComposeMail compose( settings, this, 0, true ); |
154 | if (!email.isEmpty()) | 155 | if (!email.isEmpty()) |
155 | { | 156 | { |
156 | if (!name.isEmpty()) | 157 | if (!name.isEmpty()) |
157 | { | 158 | { |
158 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 159 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
159 | } | 160 | } |
160 | else | 161 | else |
161 | { | 162 | { |
162 | compose.setTo(email); | 163 | compose.setTo(email); |
163 | } | 164 | } |
164 | } | 165 | } |
165 | compose.slotAdjustColumns(); | 166 | compose.slotAdjustColumns(); |
166 | #ifndef DESKTOP_VERSION | 167 | #ifndef DESKTOP_VERSION |
167 | compose.showMaximized(); | 168 | compose.showMaximized(); |
168 | #endif | 169 | #endif |
169 | 170 | ||
170 | mCurrentComposer = &compose; | 171 | mCurrentComposer = &compose; |
171 | compose.exec(); | 172 | compose.exec(); |
172 | mCurrentComposer = 0; | 173 | mCurrentComposer = 0; |
173 | folderView->refreshOutgoing(); | 174 | folderView->refreshOutgoing(); |
174 | raise(); | 175 | raise(); |
175 | } | 176 | } |
176 | 177 | ||
177 | void OpieMail::slotComposeMail() | 178 | void OpieMail::slotComposeMail() |
178 | { | 179 | { |
179 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 180 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
180 | slotwriteMail2( QString () ); | 181 | slotwriteMail2( QString () ); |
181 | else { | 182 | else { |
182 | if ( mPendingEmail == QString::null ) | 183 | if ( mPendingEmail == QString::null ) |
183 | slotwriteMail2( mPendingName ); | 184 | slotwriteMail2( mPendingName ); |
184 | else | 185 | else |
185 | slotwriteMail( mPendingName, mPendingEmail ); | 186 | slotwriteMail( mPendingName, mPendingEmail ); |
186 | } | 187 | } |
187 | //slotwriteMail(0l,0l); | 188 | //slotwriteMail(0l,0l); |
188 | } | 189 | } |
189 | 190 | ||
190 | void OpieMail::slotSendQueued() | 191 | void OpieMail::slotSendQueued() |
191 | { | 192 | { |
192 | SMTPaccount *smtp = 0; | 193 | SMTPaccount *smtp = 0; |
193 | 194 | ||
194 | QList<Account> list = settings->getAccounts(); | 195 | QList<Account> list = settings->getAccounts(); |
195 | QList<SMTPaccount> smtpList; | 196 | QList<SMTPaccount> smtpList; |
196 | smtpList.setAutoDelete(false); | 197 | smtpList.setAutoDelete(false); |
197 | Account *it; | 198 | Account *it; |
198 | for ( it = list.first(); it; it = list.next() ) | 199 | for ( it = list.first(); it; it = list.next() ) |
199 | { | 200 | { |
200 | if ( it->getType() == MAILLIB::A_SMTP ) | 201 | if ( it->getType() == MAILLIB::A_SMTP ) |
201 | { | 202 | { |
202 | smtp = static_cast<SMTPaccount *>(it); | 203 | smtp = static_cast<SMTPaccount *>(it); |
203 | smtpList.append(smtp); | 204 | smtpList.append(smtp); |
204 | } | 205 | } |
205 | } | 206 | } |
206 | if (smtpList.count()==0) | 207 | if (smtpList.count()==0) |
207 | { | 208 | { |
208 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); | 209 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); |
209 | return; | 210 | return; |
210 | } | 211 | } |
211 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 212 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
212 | return; | 213 | return; |
213 | if (smtpList.count()==1) | 214 | if (smtpList.count()==1) |
214 | { | 215 | { |
215 | smtp = smtpList.at(0); | 216 | smtp = smtpList.at(0); |
216 | } | 217 | } |
217 | else | 218 | else |
218 | { | 219 | { |
219 | smtp = 0; | 220 | smtp = 0; |
220 | selectsmtp selsmtp; | 221 | selectsmtp selsmtp; |
221 | selsmtp.setSelectionlist(&smtpList); | 222 | selsmtp.setSelectionlist(&smtpList); |
222 | selsmtp.resize( selsmtp.sizeHint() ); | 223 | selsmtp.resize( selsmtp.sizeHint() ); |
223 | if ( selsmtp.exec() == QDialog::Accepted ) | 224 | if ( selsmtp.exec() == QDialog::Accepted ) |
224 | { | 225 | { |
225 | smtp = selsmtp.selected_smtp(); | 226 | smtp = selsmtp.selected_smtp(); |
226 | } | 227 | } |
227 | } | 228 | } |
228 | if (smtp) | 229 | if (smtp) |
229 | { | 230 | { |
230 | 231 | ||
231 | Global::statusMessage("Sending mails...!"); | 232 | Global::statusMessage("Sending mails...!"); |
232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 233 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
233 | if ( wrap->flushOutbox() ) | 234 | if ( wrap->flushOutbox() ) |
234 | { | 235 | { |
235 | Global::statusMessage("Mails sent!"); | 236 | Global::statusMessage("Mails sent!"); |
236 | } | 237 | } |
237 | delete wrap; | 238 | delete wrap; |
238 | } | 239 | } |
239 | folderView->refreshOutgoing(); | 240 | folderView->refreshOutgoing(); |
240 | } | 241 | } |
241 | 242 | ||
242 | void OpieMail::slotSearchMails() | 243 | void OpieMail::slotSearchMails() |
243 | { | 244 | { |
244 | qDebug("OpieMail::slotSearchMails():not implemented "); | 245 | qDebug("OpieMail::slotSearchMails():not implemented "); |
245 | } | 246 | } |
246 | 247 | ||
247 | void OpieMail::slotEditSettings() | 248 | void OpieMail::slotEditSettings() |