summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
authorzautrix <zautrix>2005-02-28 18:16:03 (UTC)
committer zautrix <zautrix>2005-02-28 18:16:03 (UTC)
commit27466d3bc668e7a4c4bdedb6f407e14844908347 (patch) (unidiff)
treeecc5f637b7430d34161a267bd4047cdd0de056f3 /kmicromail/opiemail.cpp
parent16575cca67c9047de72530080dfeb5793a66c935 (diff)
downloadkdepimpi-27466d3bc668e7a4c4bdedb6f407e14844908347.zip
kdepimpi-27466d3bc668e7a4c4bdedb6f407e14844908347.tar.gz
kdepimpi-27466d3bc668e7a4c4bdedb6f407e14844908347.tar.bz2
ompi fixes
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 197f7ec..b701446 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -80,273 +80,271 @@ void OpieMail::message(const QCString &msg, const QByteArray &data)
80 mPendingEmail = QString::null; 80 mPendingEmail = QString::null;
81 mPendingName = QString::null; 81 mPendingName = QString::null;
82 if (msg == "writeMail(QString,QString)") 82 if (msg == "writeMail(QString,QString)")
83 { 83 {
84 //qDebug("writeMail(QString,QString) "); 84 //qDebug("writeMail(QString,QString) ");
85 QDataStream stream(data,IO_ReadOnly); 85 QDataStream stream(data,IO_ReadOnly);
86 stream >> mPendingName >> mPendingEmail; 86 stream >> mPendingName >> mPendingEmail;
87 // removing the whitespaces at beginning and end is needed! 87 // removing the whitespaces at beginning and end is needed!
88 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 88 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
89 } 89 }
90 else if (msg == "newMail()") 90 else if (msg == "newMail()")
91 { 91 {
92 //qDebug("slotComposeMail() "); 92 //qDebug("slotComposeMail() ");
93 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 93 // 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 94 // 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 95 // with the Qtimer we call slotComposeMail() after we reached the main event loop
96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
97 // slotComposeMail(); 97 // slotComposeMail();
98 } 98 }
99 else if (msg == "newMail(QString)") 99 else if (msg == "newMail(QString)")
100 { 100 {
101 //qDebug(" newMail(QString)"); 101 //qDebug(" newMail(QString)");
102 QDataStream stream(data,IO_ReadOnly); 102 QDataStream stream(data,IO_ReadOnly);
103 stream >> mPendingName; 103 stream >> mPendingName;
104 // the format is 104 // the format is
105 // NAME <EMAIL>:SUBJECT 105 // NAME <EMAIL>:SUBJECT
106 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 106 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
107 } else { 107 } else {
108 mPendingData = data; 108 mPendingData = data;
109 mPendingMessage = msg; 109 mPendingMessage = msg;
110 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 110 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
111 } 111 }
112 112
113 //qDebug("END OpieMail::message "); 113 //qDebug("END OpieMail::message ");
114} 114}
115void OpieMail::slotExtAppHandler() 115void OpieMail::slotExtAppHandler()
116{ 116{
117 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 117 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
118} 118}
119void OpieMail::slotwriteMail2(const QString& namemail ) 119void OpieMail::slotwriteMail2(const QString& namemail )
120{ 120{
121 //qDebug("OpieMail::slotwriteMail2 "); 121 //qDebug("OpieMail::slotwriteMail2 ");
122 //qApp->processEvents(); 122 //qApp->processEvents();
123 ComposeMail compose( settings, this, 0, true ); 123 ComposeMail compose( settings, this, 0, true );
124 if ( !namemail.isEmpty() ) { 124 if ( !namemail.isEmpty() ) {
125 QString to = namemail; 125 QString to = namemail;
126 if ( namemail.find( " <") > 1 ) { 126 if ( namemail.find( " <") > 1 ) {
127 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 127 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
128 } else 128 } else
129 if ( namemail.find( "<") > 1 ) { 129 if ( namemail.find( "<") > 1 ) {
130 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 130 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
131 } 131 }
132 int sub = to.find( ">:"); 132 int sub = to.find( ">:");
133 if ( sub > 0 ) { 133 if ( sub > 0 ) {
134 compose.setTo( to.left(sub+1) ); 134 compose.setTo( to.left(sub+1) );
135 compose.setSubject( to.mid(sub+2) ); 135 compose.setSubject( to.mid(sub+2) );
136 } else 136 } else
137 compose.setTo( to ); 137 compose.setTo( to );
138 } 138 }
139 compose.slotAdjustColumns(); 139 compose.slotAdjustColumns();
140#ifndef DESKTOP_VERSION 140#ifndef DESKTOP_VERSION
141 compose.showMaximized(); 141 compose.showMaximized();
142#endif 142#endif
143 mCurrentComposer = &compose; 143 mCurrentComposer = &compose;
144 compose.exec(); 144 compose.exec();
145 mCurrentComposer = 0; 145 mCurrentComposer = 0;
146 folderView->refreshOutgoing(); 146 folderView->refreshOutgoing();
147 raise(); 147 raise();
148 //qDebug("retttich "); 148 //qDebug("retttich ");
149} 149}
150void OpieMail::slotwriteMail(const QString&name,const QString&email) 150void OpieMail::slotwriteMail(const QString&name,const QString&email)
151{ 151{
152 // qDebug("OpieMail::slotwriteMail "); 152 // qDebug("OpieMail::slotwriteMail ");
153 ComposeMail compose( settings, this, 0, true ); 153 ComposeMail compose( settings, this, 0, true );
154 if (!email.isEmpty()) 154 if (!email.isEmpty())
155 { 155 {
156 if (!name.isEmpty()) 156 if (!name.isEmpty())
157 { 157 {
158 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 158 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
159 } 159 }
160 else 160 else
161 { 161 {
162 compose.setTo(email); 162 compose.setTo(email);
163 } 163 }
164 } 164 }
165 compose.slotAdjustColumns(); 165 compose.slotAdjustColumns();
166#ifndef DESKTOP_VERSION 166#ifndef DESKTOP_VERSION
167 compose.showMaximized(); 167 compose.showMaximized();
168#endif 168#endif
169 169
170 mCurrentComposer = &compose; 170 mCurrentComposer = &compose;
171 compose.exec(); 171 compose.exec();
172 mCurrentComposer = 0; 172 mCurrentComposer = 0;
173 folderView->refreshOutgoing(); 173 folderView->refreshOutgoing();
174 raise(); 174 raise();
175} 175}
176 176
177void OpieMail::slotComposeMail() 177void OpieMail::slotComposeMail()
178{ 178{
179 if ( mPendingEmail == QString::null && mPendingName == QString::null) 179 if ( mPendingEmail == QString::null && mPendingName == QString::null)
180 slotwriteMail2( QString () ); 180 slotwriteMail2( QString () );
181 else { 181 else {
182 if ( mPendingEmail == QString::null ) 182 if ( mPendingEmail == QString::null )
183 slotwriteMail2( mPendingName ); 183 slotwriteMail2( mPendingName );
184 else 184 else
185 slotwriteMail( mPendingName, mPendingEmail ); 185 slotwriteMail( mPendingName, mPendingEmail );
186 } 186 }
187 //slotwriteMail(0l,0l); 187 //slotwriteMail(0l,0l);
188} 188}
189 189
190void OpieMail::slotSendQueued() 190void OpieMail::slotSendQueued()
191{ 191{
192 SMTPaccount *smtp = 0; 192 SMTPaccount *smtp = 0;
193 193
194 QList<Account> list = settings->getAccounts(); 194 QList<Account> list = settings->getAccounts();
195 QList<SMTPaccount> smtpList; 195 QList<SMTPaccount> smtpList;
196 smtpList.setAutoDelete(false); 196 smtpList.setAutoDelete(false);
197 Account *it; 197 Account *it;
198 for ( it = list.first(); it; it = list.next() ) 198 for ( it = list.first(); it; it = list.next() )
199 { 199 {
200 if ( it->getType() == MAILLIB::A_SMTP ) 200 if ( it->getType() == MAILLIB::A_SMTP )
201 { 201 {
202 smtp = static_cast<SMTPaccount *>(it); 202 smtp = static_cast<SMTPaccount *>(it);
203 smtpList.append(smtp); 203 smtpList.append(smtp);
204 } 204 }
205 } 205 }
206 if (smtpList.count()==0) 206 if (smtpList.count()==0)
207 { 207 {
208 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 208 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n"));
209 return; 209 return;
210 } 210 }
211 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 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 return; 212 return;
213 if (smtpList.count()==1) 213 if (smtpList.count()==1)
214 { 214 {
215 smtp = smtpList.at(0); 215 smtp = smtpList.at(0);
216 } 216 }
217 else 217 else
218 { 218 {
219 smtp = 0; 219 smtp = 0;
220 selectsmtp selsmtp; 220 selectsmtp selsmtp;
221 selsmtp.setSelectionlist(&smtpList); 221 selsmtp.setSelectionlist(&smtpList);
222#ifndef DESKTOP_VERSION 222 selsmtp.resize( selsmtp.sizeHint() );
223 selsmtp.showMaximized();
224#endif
225 if ( selsmtp.exec() == QDialog::Accepted ) 223 if ( selsmtp.exec() == QDialog::Accepted )
226 { 224 {
227 smtp = selsmtp.selected_smtp(); 225 smtp = selsmtp.selected_smtp();
228 } 226 }
229 } 227 }
230 if (smtp) 228 if (smtp)
231 { 229 {
232 230
233 Global::statusMessage("Sending mails...!"); 231 Global::statusMessage("Sending mails...!");
234 SMTPwrapper * wrap = new SMTPwrapper(smtp); 232 SMTPwrapper * wrap = new SMTPwrapper(smtp);
235 if ( wrap->flushOutbox() ) 233 if ( wrap->flushOutbox() )
236 { 234 {
237 Global::statusMessage("Mails sent!"); 235 Global::statusMessage("Mails sent!");
238 } 236 }
239 delete wrap; 237 delete wrap;
240 } 238 }
241 folderView->refreshOutgoing(); 239 folderView->refreshOutgoing();
242} 240}
243 241
244void OpieMail::slotSearchMails() 242void OpieMail::slotSearchMails()
245{ 243{
246 qDebug("OpieMail::slotSearchMails():not implemented "); 244 qDebug("OpieMail::slotSearchMails():not implemented ");
247} 245}
248 246
249void OpieMail::slotEditSettings() 247void OpieMail::slotEditSettings()
250{ 248{
251 249
252 KOPrefsDialog settingsDialog( this, "koprefs", true ); 250 KOPrefsDialog settingsDialog( this, "koprefs", true );
253#ifndef DESKTOP_VERSION 251#ifndef DESKTOP_VERSION
254 settingsDialog.showMaximized(); 252 settingsDialog.showMaximized();
255#endif 253#endif
256 settingsDialog.exec(); 254 settingsDialog.exec();
257 255
258 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 256 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
259 // KApplication::execDialog(settingsDialog); 257 // KApplication::execDialog(settingsDialog);
260} 258}
261 259
262void OpieMail::slotEditAccounts() 260void OpieMail::slotEditAccounts()
263{ 261{
264 EditAccounts eaDialog( settings, this, 0, true ); 262 EditAccounts eaDialog( settings, this, 0, true );
265 eaDialog.slotAdjustColumns(); 263 eaDialog.slotAdjustColumns();
266#ifndef DESKTOP_VERSION 264#ifndef DESKTOP_VERSION
267 eaDialog.showMaximized(); 265 eaDialog.showMaximized();
268#endif 266#endif
269 eaDialog.exec(); 267 eaDialog.exec();
270 if ( settings ) delete settings; 268 if ( settings ) delete settings;
271 settings = new Settings(); 269 settings = new Settings();
272 270
273 folderView->populate( settings->getAccounts() ); 271 folderView->populate( settings->getAccounts() );
274} 272}
275void OpieMail::replyMail() 273void OpieMail::replyMail()
276{ 274{
277 275
278 QListViewItem*item = mailView->currentItem(); 276 QListViewItem*item = mailView->currentItem();
279 if (!item) return; 277 if (!item) return;
280 RecMailP mail = ((MailListViewItem*)item)->data(); 278 RecMailP mail = ((MailListViewItem*)item)->data();
281 RecBodyP body = folderView->fetchBody(mail); 279 RecBodyP body = folderView->fetchBody(mail);
282 280
283 QString rtext; 281 QString rtext;
284 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 282 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
285 .arg( mail->getFrom()) 283 .arg( mail->getFrom())
286 .arg( mail->getDate()); 284 .arg( mail->getDate());
287 285
288 QString text = body->Bodytext(); 286 QString text = body->Bodytext();
289 QStringList lines = QStringList::split(QRegExp("\\n"), text); 287 QStringList lines = QStringList::split(QRegExp("\\n"), text);
290 QStringList::Iterator it; 288 QStringList::Iterator it;
291 for (it = lines.begin(); it != lines.end(); it++) 289 for (it = lines.begin(); it != lines.end(); it++)
292 { 290 {
293 rtext += "> " + *it + "\n"; 291 rtext += "> " + *it + "\n";
294 } 292 }
295 rtext += "\n"; 293 rtext += "\n";
296 294
297 QString prefix; 295 QString prefix;
298 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 296 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
299 else prefix = "Re: "; // no i18n on purpose 297 else prefix = "Re: "; // no i18n on purpose
300 298
301 Settings *settings = new Settings(); 299 Settings *settings = new Settings();
302 ComposeMail composer( settings ,this, 0, true); 300 ComposeMail composer( settings ,this, 0, true);
303 if (mail->Replyto().isEmpty()) { 301 if (mail->Replyto().isEmpty()) {
304 composer.setTo( mail->getFrom()); 302 composer.setTo( mail->getFrom());
305 } else { 303 } else {
306 composer.setTo( mail->Replyto()); 304 composer.setTo( mail->Replyto());
307 } 305 }
308 composer.setSubject( prefix + mail->getSubject()); 306 composer.setSubject( prefix + mail->getSubject());
309 composer.setMessage( rtext ); 307 composer.setMessage( rtext );
310 composer.setInReplyTo( mail->Msgid()); 308 composer.setInReplyTo( mail->Msgid());
311 composer.setCharset( body->getCharset() ); 309 composer.setCharset( body->getCharset() );
312 310
313 mCurrentComposer = &composer; 311 mCurrentComposer = &composer;
314 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 312 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
315 { 313 {
316 mail->Wrapper()->answeredMail(mail); 314 mail->Wrapper()->answeredMail(mail);
317 } 315 }
318 mCurrentComposer = 0; 316 mCurrentComposer = 0;
319 folderView->refreshOutgoing(); 317 folderView->refreshOutgoing();
320 delete settings; 318 delete settings;
321 319
322} 320}
323void OpieMail::closeViewMail(ViewMail * vm) 321void OpieMail::closeViewMail(ViewMail * vm)
324{ 322{
325 vm->hide(); 323 vm->hide();
326} 324}
327 325
328void OpieMail::slotDownloadMail( ) 326void OpieMail::slotDownloadMail( )
329{ 327{
330 QListViewItem*item = mailView->currentItem(); 328 QListViewItem*item = mailView->currentItem();
331 if (!item ) { 329 if (!item ) {
332 Global::statusMessage("Error: No item slected!"); 330 Global::statusMessage("Error: No item slected!");
333 return; 331 return;
334 } 332 }
335 RecMailP mail = ((MailListViewItem*)item)->data(); 333 RecMailP mail = ((MailListViewItem*)item)->data();
336 Account * acc = mail->Wrapper()->getAccount(); 334 Account * acc = mail->Wrapper()->getAccount();
337 if ( !acc ) { 335 if ( !acc ) {
338 Global::statusMessage("Mail is already stored locally!"); 336 Global::statusMessage("Mail is already stored locally!");
339 return; 337 return;
340 } 338 }
341 QString lfName = acc->getLocalFolder(); 339 QString lfName = acc->getLocalFolder();
342 //qDebug("local folder " + lfName ); 340 //qDebug("local folder " + lfName );
343 if ( lfName.isEmpty() ) 341 if ( lfName.isEmpty() )
344 lfName = acc->getAccountName(); 342 lfName = acc->getAccountName();
345 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); 343 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper();
346 //qDebug("target %d %d ",targetMail,mail->Wrapper() ); 344 //qDebug("target %d %d ",targetMail,mail->Wrapper() );
347 if ( targetMail == mail->Wrapper() ) { 345 if ( targetMail == mail->Wrapper() ) {
348 Global::statusMessage("Mail is already locally stored!"); 346 Global::statusMessage("Mail is already locally stored!");
349 return; 347 return;
350 } 348 }
351 if ( !targetMail->createMbox(lfName)) { 349 if ( !targetMail->createMbox(lfName)) {
352 Global::statusMessage("Error creating folder!"); 350 Global::statusMessage("Error creating folder!");