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