summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
authorzautrix <zautrix>2004-09-07 22:51:29 (UTC)
committer zautrix <zautrix>2004-09-07 22:51:29 (UTC)
commit2676646d4744ccceab1063dc02d772a26a203c61 (patch) (unidiff)
tree0a0d5261b9a804a29b61a38f68339979051282e2 /kmicromail/opiemail.cpp
parent64a8ef1629f523df3006de5cb2b9882a50d96a05 (diff)
downloadkdepimpi-2676646d4744ccceab1063dc02d772a26a203c61.zip
kdepimpi-2676646d4744ccceab1063dc02d772a26a203c61.tar.gz
kdepimpi-2676646d4744ccceab1063dc02d772a26a203c61.tar.bz2
Implemented Ompi - kapi connection
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 251f15a..3e560c5 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,234 +1,235 @@
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 12
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <libmailwrapper/smtpwrapper.h> 16#include <libmailwrapper/smtpwrapper.h>
17#include <libmailwrapper/mailtypes.h> 17#include <libmailwrapper/mailtypes.h>
18#include <libmailwrapper/abstractmail.h> 18#include <libmailwrapper/abstractmail.h>
19/* OPIE */ 19/* OPIE */
20//#include <qpe/resource.h> 20//#include <qpe/resource.h>
21//#include <qpe/qpeapplication.h> 21//#include <qpe/qpeapplication.h>
22 22
23/* QT */ 23/* QT */
24 24
25using namespace Opie::Core; 25using namespace Opie::Core;
26 26
27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
28 : MainWindow( parent, name) //, WStyle_ContextHelp ) 28 : MainWindow( parent, name) //, WStyle_ContextHelp )
29{ 29{
30 settings = new Settings(); 30 settings = new Settings();
31 31
32 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
33 33
34} 34}
35 35
36OpieMail::~OpieMail() 36OpieMail::~OpieMail()
37{ 37{
38 if (settings) delete settings; 38 if (settings) delete settings;
39} 39}
40 40
41void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 41void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
42{ 42{
43 43
44} 44}
45#include <stdlib.h> 45#include <stdlib.h>
46void OpieMail::message(const QCString &msg, const QByteArray &data) 46void OpieMail::message(const QCString &msg, const QByteArray &data)
47{ 47{
48 // copied from old mail2 48 // copied from old mail2
49 static int ii = 0; 49 static int ii = 0;
50 50
51 // block second call 51 // block second call
52 if ( ii < 2 ) { 52 if ( ii < 2 ) {
53 ++ii; 53 ++ii;
54 if ( ii > 1 ) { 54 if ( ii > 1 ) {
55 qDebug("qcop call blocked "); 55 qDebug("qcop call blocked ");
56 return; 56 return;
57 } 57 }
58 } 58 }
59 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 59 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
60 if (msg == "writeMail(QString,QString)") 60 if (msg == "writeMail(QString,QString)")
61 { 61 {
62 QDataStream stream(data,IO_ReadOnly); 62 QDataStream stream(data,IO_ReadOnly);
63 QString name, email; 63 QString name, email;
64 stream >> name >> email; 64 stream >> name >> email;
65 // removing the whitespaces at beginning and end is needed! 65 // removing the whitespaces at beginning and end is needed!
66 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 66 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
67 } 67 }
68 else if (msg == "newMail()") 68 else if (msg == "newMail()")
69 { 69 {
70 slotComposeMail(); 70 slotComposeMail();
71 } 71 }
72 else if (msg == "newMail(QString)") 72 else if (msg == "newMail(QString)")
73 { 73 {
74 QDataStream stream(data,IO_ReadOnly); 74 QDataStream stream(data,IO_ReadOnly);
75 QString nameemail; 75 QString nameemail;
76 stream >> nameemail; 76 stream >> nameemail;
77 // the format is 77 // the format is
78 // NAME <EMAIL>:SUBJECT 78 // NAME <EMAIL>:SUBJECT
79 //qDebug("message %s ", nameemail.latin1()); 79 //qDebug("message %s ", nameemail.latin1());
80 80
81 slotwriteMail2( nameemail ); 81 slotwriteMail2( nameemail );
82 } 82 }
83} 83}
84void OpieMail::slotwriteMail2(const QString& namemail ) 84void OpieMail::slotwriteMail2(const QString& namemail )
85{ 85{
86 // qDebug("OpieMail::slotwriteMail2 "); 86 // qDebug("OpieMail::slotwriteMail2 ");
87 qApp->processEvents(); 87 qApp->processEvents();
88 ComposeMail compose( settings, this, 0, true ); 88 ComposeMail compose( settings, this, 0, true );
89 if ( !namemail.isEmpty() ) { 89 if ( !namemail.isEmpty() ) {
90 QString to = namemail; 90 QString to = namemail;
91 if ( namemail.find( " <") > 1 ) { 91 if ( namemail.find( " <") > 1 ) {
92 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 92 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
93 } else 93 } else
94 if ( namemail.find( "<") > 1 ) { 94 if ( namemail.find( "<") > 1 ) {
95 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 95 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
96 } 96 }
97 int sub = to.find( ">:"); 97 int sub = to.find( ">:");
98 if ( sub > 0 ) { 98 if ( sub > 0 ) {
99 compose.setTo( to.left(sub+1) ); 99 compose.setTo( to.left(sub+1) );
100 compose.setSubject( to.mid(sub+2) ); 100 compose.setSubject( to.mid(sub+2) );
101 } else 101 } else
102 compose.setTo( to ); 102 compose.setTo( to );
103 } 103 }
104 compose.slotAdjustColumns(); 104 compose.slotAdjustColumns();
105 compose.showMaximized(); 105 compose.showMaximized();
106 compose.exec(); 106 compose.exec();
107 raise();
107 //qDebug("retttich "); 108 //qDebug("retttich ");
108} 109}
109void OpieMail::slotwriteMail(const QString&name,const QString&email) 110void OpieMail::slotwriteMail(const QString&name,const QString&email)
110{ 111{
111 // qDebug("OpieMail::slotwriteMail "); 112 // qDebug("OpieMail::slotwriteMail ");
112 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 113 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
113 if (!email.isEmpty()) 114 if (!email.isEmpty())
114 { 115 {
115 if (!name.isEmpty()) 116 if (!name.isEmpty())
116 { 117 {
117 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 118 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
118 } 119 }
119 else 120 else
120 { 121 {
121 compose.setTo(email); 122 compose.setTo(email);
122 } 123 }
123 } 124 }
124 compose.slotAdjustColumns(); 125 compose.slotAdjustColumns();
125 compose.showMaximized(); 126 compose.showMaximized();
126 compose.exec(); 127 compose.exec();
127} 128}
128 129
129void OpieMail::slotComposeMail() 130void OpieMail::slotComposeMail()
130{ 131{
131 slotwriteMail2( QString () ); 132 slotwriteMail2( QString () );
132 //slotwriteMail(0l,0l); 133 //slotwriteMail(0l,0l);
133} 134}
134 135
135void OpieMail::slotSendQueued() 136void OpieMail::slotSendQueued()
136{ 137{
137 SMTPaccount *smtp = 0; 138 SMTPaccount *smtp = 0;
138 139
139 QList<Account> list = settings->getAccounts(); 140 QList<Account> list = settings->getAccounts();
140 QList<SMTPaccount> smtpList; 141 QList<SMTPaccount> smtpList;
141 smtpList.setAutoDelete(false); 142 smtpList.setAutoDelete(false);
142 Account *it; 143 Account *it;
143 for ( it = list.first(); it; it = list.next() ) 144 for ( it = list.first(); it; it = list.next() )
144 { 145 {
145 if ( it->getType() == MAILLIB::A_SMTP ) 146 if ( it->getType() == MAILLIB::A_SMTP )
146 { 147 {
147 smtp = static_cast<SMTPaccount *>(it); 148 smtp = static_cast<SMTPaccount *>(it);
148 smtpList.append(smtp); 149 smtpList.append(smtp);
149 } 150 }
150 } 151 }
151 if (smtpList.count()==0) 152 if (smtpList.count()==0)
152 { 153 {
153 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); 154 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
154 return; 155 return;
155 } 156 }
156 if (smtpList.count()==1) 157 if (smtpList.count()==1)
157 { 158 {
158 smtp = smtpList.at(0); 159 smtp = smtpList.at(0);
159 } 160 }
160 else 161 else
161 { 162 {
162 smtp = 0; 163 smtp = 0;
163 selectsmtp selsmtp; 164 selectsmtp selsmtp;
164 selsmtp.setSelectionlist(&smtpList); 165 selsmtp.setSelectionlist(&smtpList);
165 selsmtp.showMaximized(); 166 selsmtp.showMaximized();
166 if ( selsmtp.exec() == QDialog::Accepted ) 167 if ( selsmtp.exec() == QDialog::Accepted )
167 { 168 {
168 smtp = selsmtp.selected_smtp(); 169 smtp = selsmtp.selected_smtp();
169 } 170 }
170 } 171 }
171 if (smtp) 172 if (smtp)
172 { 173 {
173 SMTPwrapper * wrap = new SMTPwrapper(smtp); 174 SMTPwrapper * wrap = new SMTPwrapper(smtp);
174 if ( wrap->flushOutbox() ) 175 if ( wrap->flushOutbox() )
175 { 176 {
176 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 177 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
177 } 178 }
178 delete wrap; 179 delete wrap;
179 } 180 }
180} 181}
181 182
182void OpieMail::slotSearchMails() 183void OpieMail::slotSearchMails()
183{ 184{
184 qDebug("OpieMail::slotSearchMails():not implemented "); 185 qDebug("OpieMail::slotSearchMails():not implemented ");
185} 186}
186 187
187void OpieMail::slotEditSettings() 188void OpieMail::slotEditSettings()
188{ 189{
189 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 190 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
190 settingsDialog.showMaximized(); 191 settingsDialog.showMaximized();
191 settingsDialog.exec(); 192 settingsDialog.exec();
192} 193}
193 194
194void OpieMail::slotEditAccounts() 195void OpieMail::slotEditAccounts()
195{ 196{
196 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 197 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
197 eaDialog.slotAdjustColumns(); 198 eaDialog.slotAdjustColumns();
198 eaDialog.showMaximized(); 199 eaDialog.showMaximized();
199 eaDialog.exec(); 200 eaDialog.exec();
200 if ( settings ) delete settings; 201 if ( settings ) delete settings;
201 settings = new Settings(); 202 settings = new Settings();
202 203
203 folderView->populate( settings->getAccounts() ); 204 folderView->populate( settings->getAccounts() );
204} 205}
205 206
206void OpieMail::displayMail() 207void OpieMail::displayMail()
207{ 208{
208 QListViewItem*item = mailView->currentItem(); 209 QListViewItem*item = mailView->currentItem();
209 if (!item) return; 210 if (!item) return;
210 RecMailP mail = ((MailListViewItem*)item)->data(); 211 RecMailP mail = ((MailListViewItem*)item)->data();
211 RecBodyP body = folderView->fetchBody(mail); 212 RecBodyP body = folderView->fetchBody(mail);
212 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 213 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
213 readMail.setBody( body ); 214 readMail.setBody( body );
214 readMail.setMail( mail ); 215 readMail.setMail( mail );
215 readMail.showMaximized(); 216 readMail.showMaximized();
216 readMail.exec(); 217 readMail.exec();
217 218
218 if ( readMail.deleted ) 219 if ( readMail.deleted )
219 { 220 {
220 folderView->refreshCurrent(); 221 folderView->refreshCurrent();
221 } 222 }
222 else 223 else
223 { 224 {
224 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 225 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
225 } 226 }
226} 227}
227 228
228void OpieMail::slotDeleteMail() 229void OpieMail::slotDeleteMail()
229{ 230{
230 if (!mailView->currentItem()) return; 231 if (!mailView->currentItem()) return;
231 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 232 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
232 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 233 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
233 { 234 {
234 mail->Wrapper()->deleteMail( mail ); 235 mail->Wrapper()->deleteMail( mail );