summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
authorzautrix <zautrix>2004-10-31 16:54:47 (UTC)
committer zautrix <zautrix>2004-10-31 16:54:47 (UTC)
commit3964a158be731f1bb244ca861262df5fa8d04cf3 (patch) (unidiff)
treefa4a8e9af345c144562be480f21df6e3d8d609c7 /kmicromail/opiemail.cpp
parentbed831cc1a38d38a4c5b9329bf37b1c663142c23 (diff)
downloadkdepimpi-3964a158be731f1bb244ca861262df5fa8d04cf3.zip
kdepimpi-3964a158be731f1bb244ca861262df5fa8d04cf3.tar.gz
kdepimpi-3964a158be731f1bb244ca861262df5fa8d04cf3.tar.bz2
changed showmaximized for desktop
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index fe9df87..8d16ae7 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,325 +1,331 @@
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 "koprefsdialog.h" 4#include "koprefsdialog.h"
5#include <kapplication.h> 5#include <kapplication.h>
6#include <libkdepim/externalapphandler.h> 6#include <libkdepim/externalapphandler.h>
7#include <libkdepim/kpimglobalprefs.h> 7#include <libkdepim/kpimglobalprefs.h>
8#ifdef MINIKDE_KDIALOG_H 8#ifdef MINIKDE_KDIALOG_H
9#undef MINIKDE_KDIALOG_H 9#undef MINIKDE_KDIALOG_H
10#endif 10#endif
11#include "settingsdialog.h" 11#include "settingsdialog.h"
12#include "opiemail.h" 12#include "opiemail.h"
13#include "editaccounts.h" 13#include "editaccounts.h"
14#include "composemail.h" 14#include "composemail.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "selectstore.h" 17#include "selectstore.h"
18#include "selectsmtp.h" 18#include "selectsmtp.h"
19#include "accountitem.h" 19#include "accountitem.h"
20#include "klocale.h" 20#include "klocale.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qregexp.h> 25#include <qregexp.h>
26 26
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qapplication.h> 28#include <qapplication.h>
29#else 29#else
30#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
31#endif 31#endif
32#include <libmailwrapper/smtpwrapper.h> 32#include <libmailwrapper/smtpwrapper.h>
33#include <libmailwrapper/mailtypes.h> 33#include <libmailwrapper/mailtypes.h>
34#include <libmailwrapper/abstractmail.h> 34#include <libmailwrapper/abstractmail.h>
35 35
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38OpieMail::OpieMail( QWidget *parent, const char *name ) 38OpieMail::OpieMail( QWidget *parent, const char *name )
39 : MainWindow( parent, name) //, WStyle_ContextHelp ) 39 : MainWindow( parent, name) //, WStyle_ContextHelp )
40{ 40{
41 settings = new Settings(); 41 settings = new Settings();
42 42
43 setIcon(SmallIcon( "kmicromail" ) ); 43 setIcon(SmallIcon( "kmicromail" ) );
44 folderView->populate( settings->getAccounts() ); 44 folderView->populate( settings->getAccounts() );
45 45
46} 46}
47 47
48OpieMail::~OpieMail() 48OpieMail::~OpieMail()
49{ 49{
50 if (settings) delete settings; 50 if (settings) delete settings;
51} 51}
52 52
53void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 53void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
54{ 54{
55 55
56} 56}
57#include <stdlib.h> 57#include <stdlib.h>
58void OpieMail::message(const QCString &msg, const QByteArray &data) 58void OpieMail::message(const QCString &msg, const QByteArray &data)
59{ 59{
60 // copied from old mail2 60 // copied from old mail2
61 static int ii = 0; 61 static int ii = 0;
62 //qDebug("QCOP CALL ############################# %d ", ii); 62 //qDebug("QCOP CALL ############################# %d ", ii);
63 //QString mess ( msg ); 63 //QString mess ( msg );
64 //qDebug("Message = %s ",mess.latin1()); 64 //qDebug("Message = %s ",mess.latin1());
65 ++ii; 65 ++ii;
66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
67 67
68 mPendingEmail = QString::null; 68 mPendingEmail = QString::null;
69 mPendingName = QString::null; 69 mPendingName = QString::null;
70 if (msg == "writeMail(QString,QString)") 70 if (msg == "writeMail(QString,QString)")
71 { 71 {
72 //qDebug("writeMail(QString,QString) "); 72 //qDebug("writeMail(QString,QString) ");
73 QDataStream stream(data,IO_ReadOnly); 73 QDataStream stream(data,IO_ReadOnly);
74 stream >> mPendingName >> mPendingEmail; 74 stream >> mPendingName >> mPendingEmail;
75 // removing the whitespaces at beginning and end is needed! 75 // removing the whitespaces at beginning and end is needed!
76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
77 } 77 }
78 else if (msg == "newMail()") 78 else if (msg == "newMail()")
79 { 79 {
80 //qDebug("slotComposeMail() "); 80 //qDebug("slotComposeMail() ");
81 // 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
82 // 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
83 // 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
84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
85 // slotComposeMail(); 85 // slotComposeMail();
86 } 86 }
87 else if (msg == "newMail(QString)") 87 else if (msg == "newMail(QString)")
88 { 88 {
89 //qDebug(" newMail(QString)"); 89 //qDebug(" newMail(QString)");
90 QDataStream stream(data,IO_ReadOnly); 90 QDataStream stream(data,IO_ReadOnly);
91 stream >> mPendingName; 91 stream >> mPendingName;
92 // the format is 92 // the format is
93 // NAME <EMAIL>:SUBJECT 93 // NAME <EMAIL>:SUBJECT
94 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 94 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
95 } else { 95 } else {
96 mPendingData = data; 96 mPendingData = data;
97 mPendingMessage = msg; 97 mPendingMessage = msg;
98 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 98 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
99 } 99 }
100 100
101 //qDebug("END OpieMail::message "); 101 //qDebug("END OpieMail::message ");
102} 102}
103void OpieMail::slotExtAppHandler() 103void OpieMail::slotExtAppHandler()
104{ 104{
105 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 105 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
106} 106}
107void OpieMail::slotwriteMail2(const QString& namemail ) 107void OpieMail::slotwriteMail2(const QString& namemail )
108{ 108{
109 //qDebug("OpieMail::slotwriteMail2 "); 109 //qDebug("OpieMail::slotwriteMail2 ");
110 //qApp->processEvents(); 110 //qApp->processEvents();
111 ComposeMail compose( settings, this, 0, true ); 111 ComposeMail compose( settings, this, 0, true );
112 if ( !namemail.isEmpty() ) { 112 if ( !namemail.isEmpty() ) {
113 QString to = namemail; 113 QString to = namemail;
114 if ( namemail.find( " <") > 1 ) { 114 if ( namemail.find( " <") > 1 ) {
115 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 115 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
116 } else 116 } else
117 if ( namemail.find( "<") > 1 ) { 117 if ( namemail.find( "<") > 1 ) {
118 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 118 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
119 } 119 }
120 int sub = to.find( ">:"); 120 int sub = to.find( ">:");
121 if ( sub > 0 ) { 121 if ( sub > 0 ) {
122 compose.setTo( to.left(sub+1) ); 122 compose.setTo( to.left(sub+1) );
123 compose.setSubject( to.mid(sub+2) ); 123 compose.setSubject( to.mid(sub+2) );
124 } else 124 } else
125 compose.setTo( to ); 125 compose.setTo( to );
126 } 126 }
127 compose.slotAdjustColumns(); 127 compose.slotAdjustColumns();
128#ifndef DESKTOP_VERSION
128 compose.showMaximized(); 129 compose.showMaximized();
130#endif
129 compose.exec(); 131 compose.exec();
130 raise(); 132 raise();
131 //qDebug("retttich "); 133 //qDebug("retttich ");
132} 134}
133void OpieMail::slotwriteMail(const QString&name,const QString&email) 135void OpieMail::slotwriteMail(const QString&name,const QString&email)
134{ 136{
135 // qDebug("OpieMail::slotwriteMail "); 137 // qDebug("OpieMail::slotwriteMail ");
136 ComposeMail compose( settings, this, 0, true ); 138 ComposeMail compose( settings, this, 0, true );
137 if (!email.isEmpty()) 139 if (!email.isEmpty())
138 { 140 {
139 if (!name.isEmpty()) 141 if (!name.isEmpty())
140 { 142 {
141 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 143 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
142 } 144 }
143 else 145 else
144 { 146 {
145 compose.setTo(email); 147 compose.setTo(email);
146 } 148 }
147 } 149 }
148 compose.slotAdjustColumns(); 150 compose.slotAdjustColumns();
151#ifndef DESKTOP_VERSION
149 compose.showMaximized(); 152 compose.showMaximized();
153#endif
150 compose.exec(); 154 compose.exec();
151 raise(); 155 raise();
152} 156}
153 157
154void OpieMail::slotComposeMail() 158void OpieMail::slotComposeMail()
155{ 159{
156 if ( mPendingEmail == QString::null && mPendingName == QString::null) 160 if ( mPendingEmail == QString::null && mPendingName == QString::null)
157 slotwriteMail2( QString () ); 161 slotwriteMail2( QString () );
158 else { 162 else {
159 if ( mPendingEmail == QString::null ) 163 if ( mPendingEmail == QString::null )
160 slotwriteMail2( mPendingName ); 164 slotwriteMail2( mPendingName );
161 else 165 else
162 slotwriteMail( mPendingName, mPendingEmail ); 166 slotwriteMail( mPendingName, mPendingEmail );
163 } 167 }
164 //slotwriteMail(0l,0l); 168 //slotwriteMail(0l,0l);
165} 169}
166 170
167void OpieMail::slotSendQueued() 171void OpieMail::slotSendQueued()
168{ 172{
169 SMTPaccount *smtp = 0; 173 SMTPaccount *smtp = 0;
170 174
171 QList<Account> list = settings->getAccounts(); 175 QList<Account> list = settings->getAccounts();
172 QList<SMTPaccount> smtpList; 176 QList<SMTPaccount> smtpList;
173 smtpList.setAutoDelete(false); 177 smtpList.setAutoDelete(false);
174 Account *it; 178 Account *it;
175 for ( it = list.first(); it; it = list.next() ) 179 for ( it = list.first(); it; it = list.next() )
176 { 180 {
177 if ( it->getType() == MAILLIB::A_SMTP ) 181 if ( it->getType() == MAILLIB::A_SMTP )
178 { 182 {
179 smtp = static_cast<SMTPaccount *>(it); 183 smtp = static_cast<SMTPaccount *>(it);
180 smtpList.append(smtp); 184 smtpList.append(smtp);
181 } 185 }
182 } 186 }
183 if (smtpList.count()==0) 187 if (smtpList.count()==0)
184 { 188 {
185 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 189 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n"));
186 return; 190 return;
187 } 191 }
188 if (smtpList.count()==1) 192 if (smtpList.count()==1)
189 { 193 {
190 smtp = smtpList.at(0); 194 smtp = smtpList.at(0);
191 } 195 }
192 else 196 else
193 { 197 {
194 smtp = 0; 198 smtp = 0;
195 selectsmtp selsmtp; 199 selectsmtp selsmtp;
196 selsmtp.setSelectionlist(&smtpList); 200 selsmtp.setSelectionlist(&smtpList);
201#ifndef DESKTOP_VERSION
197 selsmtp.showMaximized(); 202 selsmtp.showMaximized();
203#endif
198 if ( selsmtp.exec() == QDialog::Accepted ) 204 if ( selsmtp.exec() == QDialog::Accepted )
199 { 205 {
200 smtp = selsmtp.selected_smtp(); 206 smtp = selsmtp.selected_smtp();
201 } 207 }
202 } 208 }
203 if (smtp) 209 if (smtp)
204 { 210 {
205 SMTPwrapper * wrap = new SMTPwrapper(smtp); 211 SMTPwrapper * wrap = new SMTPwrapper(smtp);
206 if ( wrap->flushOutbox() ) 212 if ( wrap->flushOutbox() )
207 { 213 {
208 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); 214 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed"));
209 } 215 }
210 delete wrap; 216 delete wrap;
211 } 217 }
212} 218}
213 219
214void OpieMail::slotSearchMails() 220void OpieMail::slotSearchMails()
215{ 221{
216 qDebug("OpieMail::slotSearchMails():not implemented "); 222 qDebug("OpieMail::slotSearchMails():not implemented ");
217} 223}
218 224
219void OpieMail::slotEditSettings() 225void OpieMail::slotEditSettings()
220{ 226{
221 227
222 KOPrefsDialog settingsDialog( this, "koprefs", true ); 228 KOPrefsDialog settingsDialog( this, "koprefs", true );
223#ifndef DESKTOP_VERSION 229#ifndef DESKTOP_VERSION
224 settingsDialog.showMaximized(); 230 settingsDialog.showMaximized();
225#endif 231#endif
226 settingsDialog.exec(); 232 settingsDialog.exec();
227 233
228 // KApplication::execDialog(settingsDialog); 234 // KApplication::execDialog(settingsDialog);
229} 235}
230 236
231void OpieMail::slotEditAccounts() 237void OpieMail::slotEditAccounts()
232{ 238{
233 EditAccounts eaDialog( settings, this, 0, true ); 239 EditAccounts eaDialog( settings, this, 0, true );
234 eaDialog.slotAdjustColumns(); 240 eaDialog.slotAdjustColumns();
235#ifndef DESKTOP_VERSION 241#ifndef DESKTOP_VERSION
236 eaDialog.showMaximized(); 242 eaDialog.showMaximized();
237#endif 243#endif
238 eaDialog.exec(); 244 eaDialog.exec();
239 if ( settings ) delete settings; 245 if ( settings ) delete settings;
240 settings = new Settings(); 246 settings = new Settings();
241 247
242 folderView->populate( settings->getAccounts() ); 248 folderView->populate( settings->getAccounts() );
243} 249}
244void OpieMail::replyMail() 250void OpieMail::replyMail()
245{ 251{
246 252
247 QListViewItem*item = mailView->currentItem(); 253 QListViewItem*item = mailView->currentItem();
248 if (!item) return; 254 if (!item) return;
249 RecMailP mail = ((MailListViewItem*)item)->data(); 255 RecMailP mail = ((MailListViewItem*)item)->data();
250 RecBodyP body = folderView->fetchBody(mail); 256 RecBodyP body = folderView->fetchBody(mail);
251 257
252 QString rtext; 258 QString rtext;
253 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 259 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
254 .arg( QString::fromUtf8( mail->getFrom().latin1())) 260 .arg( QString::fromUtf8( mail->getFrom().latin1()))
255 .arg( QString::fromUtf8( mail->getDate().latin1() )); 261 .arg( QString::fromUtf8( mail->getDate().latin1() ));
256 262
257 QString text = QString::fromUtf8( body->Bodytext().latin1() ); 263 QString text = QString::fromUtf8( body->Bodytext().latin1() );
258 QStringList lines = QStringList::split(QRegExp("\\n"), text); 264 QStringList lines = QStringList::split(QRegExp("\\n"), text);
259 QStringList::Iterator it; 265 QStringList::Iterator it;
260 for (it = lines.begin(); it != lines.end(); it++) 266 for (it = lines.begin(); it != lines.end(); it++)
261 { 267 {
262 rtext += "> " + *it + "\n"; 268 rtext += "> " + *it + "\n";
263 } 269 }
264 rtext += "\n"; 270 rtext += "\n";
265 271
266 QString prefix; 272 QString prefix;
267 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 273 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
268 else prefix = "Re: "; // no i18n on purpose 274 else prefix = "Re: "; // no i18n on purpose
269 275
270 Settings *settings = new Settings(); 276 Settings *settings = new Settings();
271 ComposeMail composer( settings ,this, 0, true); 277 ComposeMail composer( settings ,this, 0, true);
272 if (mail->Replyto().isEmpty()) { 278 if (mail->Replyto().isEmpty()) {
273 composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); 279 composer.setTo( QString::fromUtf8( mail->getFrom().latin1()));
274 } else { 280 } else {
275 composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); 281 composer.setTo( QString::fromUtf8(mail->Replyto().latin1()));
276 } 282 }
277 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); 283 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) );
278 composer.setMessage( rtext ); 284 composer.setMessage( rtext );
279 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); 285 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1()));
280 286
281 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 287 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
282 { 288 {
283 mail->Wrapper()->answeredMail(mail); 289 mail->Wrapper()->answeredMail(mail);
284 } 290 }
285 delete settings; 291 delete settings;
286 292
287} 293}
288void OpieMail::displayMail() 294void OpieMail::displayMail()
289{ 295{
290 QListViewItem*item = mailView->currentItem(); 296 QListViewItem*item = mailView->currentItem();
291 if (!item) return; 297 if (!item) return;
292 RecMailP mail = ((MailListViewItem*)item)->data(); 298 RecMailP mail = ((MailListViewItem*)item)->data();
293 RecBodyP body = folderView->fetchBody(mail); 299 RecBodyP body = folderView->fetchBody(mail);
294 ViewMail readMail( this,"", Qt::WType_Modal ); 300 ViewMail readMail( this,"", Qt::WType_Modal );
295 readMail.setBody( body ); 301 readMail.setBody( body );
296 readMail.setMail( mail ); 302 readMail.setMail( mail );
297#ifndef DESKTOP_VERSION 303#ifndef DESKTOP_VERSION
298 readMail.showMaximized(); 304 readMail.showMaximized();
299#else 305#else
300 readMail.resize( 640, 480); 306 readMail.resize( 640, 480);
301#endif 307#endif
302 readMail.exec(); 308 readMail.exec();
303 309
304 if ( readMail.deleted ) 310 if ( readMail.deleted )
305 { 311 {
306 folderView->refreshCurrent(); 312 folderView->refreshCurrent();
307 } 313 }
308 else 314 else
309 { 315 {
310 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 316 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
311 } 317 }
312} 318}
313void OpieMail::slotGetAllMail() 319void OpieMail::slotGetAllMail()
314{ 320{
315 QListViewItem * item = folderView->firstChild(); 321 QListViewItem * item = folderView->firstChild();
316 while ( item ){ 322 while ( item ){
317 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 323 ((AccountViewItem *)item)->contextMenuSelected( 101 );
318 item = item->nextSibling (); 324 item = item->nextSibling ();
319 } 325 }
320} 326}
321void OpieMail::slotGetMail() 327void OpieMail::slotGetMail()
322{ 328{
323 QListViewItem * item = folderView->currentItem(); 329 QListViewItem * item = folderView->currentItem();
324 if ( ! item ) return; 330 if ( ! item ) return;
325 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 331 ((AccountViewItem *)item)->contextMenuSelected( 101 );