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