summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 5f7a76f..c504fdd 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,497 +1,494 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3#include "composemail.h" 3#include "composemail.h"
4 4
5#include <libmailwrapper/smtpwrapper.h> 5#include <libmailwrapper/smtpwrapper.h>
6#include <libmailwrapper/storemail.h> 6#include <libmailwrapper/storemail.h>
7#include <libmailwrapper/abstractmail.h> 7#include <libmailwrapper/abstractmail.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9 9
10/* OPIE */ 10/* OPIE */
11//#include <opie2/ofiledialog.h> 11//#include <opie2/ofiledialog.h>
12//#include <opie2/odebug.h> 12//#include <opie2/odebug.h>
13#include <kfiledialog.h> 13#include <kfiledialog.h>
14//#include <qpe/resource.h> 14//#include <qpe/resource.h>
15#include <qpe/global.h> 15#include <qpe/global.h>
16//#include <qpe/contact.h> 16//#include <qpe/contact.h>
17 17
18 18
19#include <qcombobox.h> 19#include <qcombobox.h>
20#include <qcheckbox.h> 20#include <qcheckbox.h>
21#include <qiconset.h> 21#include <qiconset.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qmultilineedit.h> 25#include <qmultilineedit.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <kabc/addresseedialog.h> 29#include <kabc/addresseedialog.h>
30#include <kabc/stdaddressbook.h> 30#include <kabc/stdaddressbook.h>
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32#ifdef DESKTOP_VERSION 32#ifdef DESKTOP_VERSION
33#include <kabc/addresseedialog.h> 33#include <kabc/addresseedialog.h>
34#else //DESKTOP_VERSION 34#else //DESKTOP_VERSION
35#include <libkdepim/externalapphandler.h> 35#include <libkdepim/externalapphandler.h>
36#endif //DESKTOP_VERSION 36#endif //DESKTOP_VERSION
37 37
38#include "koprefs.h" 38#include "koprefs.h"
39 39
40//using namespace Opie::Core; 40//using namespace Opie::Core;
41//using namespace Opie::Ui; 41//using namespace Opie::Ui;
42ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) 42ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal )
43 : ComposeMailUI( parent, name, modal ) 43 : ComposeMailUI( parent, name, modal )
44{ 44{
45 mPickLineEdit = 0; 45 mPickLineEdit = 0;
46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
48 settings = s; 48 settings = s;
49 m_replyid = ""; 49 m_replyid = "";
50 if ( KOPrefs::instance()->mUseKapi) { 50 if ( KOPrefs::instance()->mUseKapi) {
51 KConfig config( locateLocal("config", "kabcrc") ); 51 KConfig config( locateLocal("config", "kabcrc") );
52 config.setGroup( "General" ); 52 config.setGroup( "General" );
53 QString whoami_uid = config.readEntry( "WhoAmI" ); 53 QString whoami_uid = config.readEntry( "WhoAmI" );
54 54
55 if ( whoami_uid.isEmpty() ) { 55 if ( whoami_uid.isEmpty() ) {
56 QMessageBox::information( 0, i18n( "Hint" ), 56 QMessageBox::information( 0, i18n( "Hint" ),
57 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 57 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
58 i18n( "Ok" ) ); 58 i18n( "Ok" ) );
59 59
60 60
61 fillSettings(); 61 fillSettings();
62 } else 62 } else
63 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 63 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
64 64
65 65
66#ifdef DESKTOP_VERSION 66#ifdef DESKTOP_VERSION
67 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 67 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
68 QStringList mails = con.emails(); 68 QStringList mails = con.emails();
69 QString defmail = con.preferredEmail(); 69 QString defmail = con.preferredEmail();
70 if ( mails.count() == 0) 70 if ( mails.count() == 0)
71 QMessageBox::information( 0, i18n( "Hint" ), 71 QMessageBox::information( 0, i18n( "Hint" ),
72 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 72 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
73 i18n( "Ok" ) ); 73 i18n( "Ok" ) );
74 if (defmail.length()!=0) { 74 if (defmail.length()!=0) {
75 fromBox->insertItem(defmail); 75 fromBox->insertItem(defmail);
76 } 76 }
77 QStringList::ConstIterator sit = mails.begin(); 77 QStringList::ConstIterator sit = mails.begin();
78 for (;sit!=mails.end();++sit) { 78 for (;sit!=mails.end();++sit) {
79 if ( (*sit)==defmail) 79 if ( (*sit)==defmail)
80 continue; 80 continue;
81 fromBox->insertItem((*sit)); 81 fromBox->insertItem((*sit));
82 } 82 }
83 senderNameEdit->setText(con.formattedName()); 83 senderNameEdit->setText(con.formattedName());
84#endif 84#endif
85 85
86 } else { 86 } else {
87 fillSettings(); 87 fillSettings();
88 } 88 }
89 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 89 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
90 90
91 attList->addColumn( i18n( "Name" ) ); 91 attList->addColumn( i18n( "Name" ) );
92 attList->addColumn( i18n( "Size" ) ); 92 attList->addColumn( i18n( "Size" ) );
93 QList<Account> accounts = settings->getAccounts(); 93 QList<Account> accounts = settings->getAccounts();
94 94
95 if ( QApplication::desktop()->width() < 320 ) 95 if ( QApplication::desktop()->width() < 320 )
96 smtpAccountBox->setMaximumWidth( 80 ); 96 smtpAccountBox->setMaximumWidth( 80 );
97 Account *it; 97 Account *it;
98 for ( it = accounts.first(); it; it = accounts.next() ) { 98 for ( it = accounts.first(); it; it = accounts.next() ) {
99 if ( it->getType()==MAILLIB::A_SMTP ) { 99 if ( it->getType()==MAILLIB::A_SMTP ) {
100 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 100 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
101 smtpAccountBox->insertItem( smtp->getAccountName() ); 101 smtpAccountBox->insertItem( smtp->getAccountName() );
102 smtpAccounts.append( smtp ); 102 smtpAccounts.append( smtp );
103 } 103 }
104 } 104 }
105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
112 mMail = 0; 112 mMail = 0;
113 warnAttach = true; 113 warnAttach = true;
114 QIconSet icon; 114 QIconSet icon;
115 //icon = SmallIcon("fileexport"); 115 //icon = SmallIcon("fileexport");
116 icon = SmallIcon("filesave"); 116 icon = SmallIcon("filesave");
117
118 SaveButton->setText ("") ;
117 SaveButton->setIconSet (icon ) ; 119 SaveButton->setIconSet (icon ) ;
118 if ( QApplication::desktop()->width() < 320 ) { 120 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
119 SaveButton->setText ("") ;
120 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
121 }
122 else
123 SaveButton->setText (i18n("Save"));
124#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
125 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 122 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
126 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 123 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
127 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 124 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
128#endif 125#endif
129 message->setFont ( KOPrefs::instance()->mComposeFont ); 126 message->setFont ( KOPrefs::instance()->mComposeFont );
130 message->setWordWrap (QMultiLineEdit::WidgetWidth); 127 message->setWordWrap (QMultiLineEdit::WidgetWidth);
131 if ( smtpAccounts.count() > 0 ) { 128 if ( smtpAccounts.count() > 0 ) {
132 fillValues( smtpAccountBox->currentItem() ); 129 fillValues( smtpAccountBox->currentItem() );
133 } else { 130 } else {
134 QMessageBox::information( 0, i18n( "Problem" ), 131 QMessageBox::information( 0, i18n( "Problem" ),
135 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 132 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
136 i18n( "Ok" ) ); 133 i18n( "Ok" ) );
137 return; 134 return;
138 } 135 }
139 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 136 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
140 137
141 138
142} 139}
143 140
144void ComposeMail::fillSettings() 141void ComposeMail::fillSettings()
145{ 142{
146 if ( QApplication::desktop()->width() < 320 ) 143 if ( QApplication::desktop()->width() < 320 )
147 fromBox->setMaximumWidth( 100 ); 144 fromBox->setMaximumWidth( 100 );
148 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 145 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
149 QStringList::ConstIterator sit = mailList.begin(); 146 QStringList::ConstIterator sit = mailList.begin();
150 int pref = 0; 147 int pref = 0;
151 for (;sit!=mailList.end();++sit) { 148 for (;sit!=mailList.end();++sit) {
152 fromBox->insertItem((*sit)); 149 fromBox->insertItem((*sit));
153 } 150 }
154 senderNameEdit->setText(KOPrefs::instance()->mName); 151 senderNameEdit->setText(KOPrefs::instance()->mName);
155} 152}
156 153
157 154
158void ComposeMail::saveAsDraft() 155void ComposeMail::saveAsDraft()
159{ 156{
160 157
161 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 158 Opie::Core::OSmartPointer<Mail> mail= new Mail();
162 mail->setMail(fromBox->currentText()); 159 mail->setMail(fromBox->currentText());
163 mail->setTo( toLine->text() ); 160 mail->setTo( toLine->text() );
164 mail->setName(senderNameEdit->text()); 161 mail->setName(senderNameEdit->text());
165 mail->setCC( ccLine->text() ); 162 mail->setCC( ccLine->text() );
166 mail->setBCC( bccLine->text() ); 163 mail->setBCC( bccLine->text() );
167 mail->setReply( replyLine->text() ); 164 mail->setReply( replyLine->text() );
168 mail->setSubject( subjectLine->text() ); 165 mail->setSubject( subjectLine->text() );
169 if (!m_replyid.isEmpty()) { 166 if (!m_replyid.isEmpty()) {
170 QStringList ids; 167 QStringList ids;
171 ids.append(m_replyid); 168 ids.append(m_replyid);
172 mail->setInreply(ids); 169 mail->setInreply(ids);
173 } 170 }
174 QString txt = message->text(); 171 QString txt = message->text();
175 if ( !sigMultiLine->text().isEmpty() ) { 172 if ( !sigMultiLine->text().isEmpty() ) {
176 txt.append( "\n--\n" ); 173 txt.append( "\n--\n" );
177 txt.append( sigMultiLine->text() ); 174 txt.append( sigMultiLine->text() );
178 } 175 }
179 mail->setMessage( txt ); 176 mail->setMessage( txt );
180 177
181 /* only use the default drafts folder name! */ 178 /* only use the default drafts folder name! */
182 Storemail wrapper(AbstractMail::draftFolder()); 179 Storemail wrapper(AbstractMail::draftFolder());
183 wrapper.storeMail(mail); 180 wrapper.storeMail(mail);
184 181
185 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 182 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
186 /* attachments we will ignore! */ 183 /* attachments we will ignore! */
187 if ( it != 0 ) { 184 if ( it != 0 ) {
188 if ( warnAttach ) 185 if ( warnAttach )
189 QMessageBox::warning(0,i18n("Store message"), 186 QMessageBox::warning(0,i18n("Store message"),
190 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 187 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
191 warnAttach = false; 188 warnAttach = false;
192 } 189 }
193 setStatus( i18n("Mail saved as draft!") ); 190 setStatus( i18n("Mail saved as draft!") );
194} 191}
195void ComposeMail::clearStatus() 192void ComposeMail::clearStatus()
196{ 193{
197 topLevelWidget()->setCaption( i18n("Compose mail") ); 194 topLevelWidget()->setCaption( i18n("Compose mail") );
198} 195}
199void ComposeMail::setStatus( QString status ) 196void ComposeMail::setStatus( QString status )
200{ 197{
201 topLevelWidget()->setCaption( status ); 198 topLevelWidget()->setCaption( status );
202 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 199 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
203} 200}
204void ComposeMail::pickAddress( ) 201void ComposeMail::pickAddress( )
205{ 202{
206 203
207 QLineEdit *line = mPickLineEdit; 204 QLineEdit *line = mPickLineEdit;
208 if ( line == 0 ) 205 if ( line == 0 )
209 return; 206 return;
210#ifdef DESKTOP_VERSION 207#ifdef DESKTOP_VERSION
211 //qDebug(" ComposeMail::pickAddress "); 208 //qDebug(" ComposeMail::pickAddress ");
212 QString names ;//= AddressPicker::getNames(); 209 QString names ;//= AddressPicker::getNames();
213 210
214 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 211 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
215 uint i=0; 212 uint i=0;
216 for (i=0; i < list.count(); i++) { 213 for (i=0; i < list.count(); i++) {
217 if ( !list[i].preferredEmail().isEmpty()) { 214 if ( !list[i].preferredEmail().isEmpty()) {
218 if ( ! names.isEmpty() ) 215 if ( ! names.isEmpty() )
219 names+= ","; 216 names+= ",";
220 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 217 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
221 218
222 } 219 }
223 } 220 }
224 221
225 222
226 if ( line->text().isEmpty() ) { 223 if ( line->text().isEmpty() ) {
227 line->setText( names ); 224 line->setText( names );
228 } else if ( !names.isEmpty() ) { 225 } else if ( !names.isEmpty() ) {
229 line->setText( line->text() + ", " + names ); 226 line->setText( line->text() + ", " + names );
230 } 227 }
231#else 228#else
232 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 229 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
233 // the result should now arrive through method insertAttendees 230 // the result should now arrive through method insertAttendees
234#endif 231#endif
235} 232}
236//the map includes name/email pairs, that comes from Ka/Pi 233//the map includes name/email pairs, that comes from Ka/Pi
237void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 234void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
238{ 235{
239 //qDebug("ComposeMail::insertAttendees "); 236 //qDebug("ComposeMail::insertAttendees ");
240 raise(); 237 raise();
241 238
242 if ( mPickLineEdit == 0 ) { //whoami received 239 if ( mPickLineEdit == 0 ) { //whoami received
243 QString defmail = uidList[0]; 240 QString defmail = uidList[0];
244 if ( emailList.count() == 0 ) 241 if ( emailList.count() == 0 )
245 QMessageBox::information( 0, i18n( "Hint" ), 242 QMessageBox::information( 0, i18n( "Hint" ),
246 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 243 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
247 i18n( "Ok" ) ); 244 i18n( "Ok" ) );
248 if (defmail.length()!=0) { 245 if (defmail.length()!=0) {
249 fromBox->insertItem(defmail); 246 fromBox->insertItem(defmail);
250 } 247 }
251 QStringList::ConstIterator sit = emailList.begin(); 248 QStringList::ConstIterator sit = emailList.begin();
252 int pref = 0; 249 int pref = 0;
253 for (;sit!=emailList.end();++sit) { 250 for (;sit!=emailList.end();++sit) {
254 if ( (*sit)==defmail) 251 if ( (*sit)==defmail)
255 continue; 252 continue;
256 fromBox->insertItem((*sit)); 253 fromBox->insertItem((*sit));
257 } 254 }
258 senderNameEdit->setText(nameList[0]); 255 senderNameEdit->setText(nameList[0]);
259 return; 256 return;
260 } 257 }
261 QString names ; 258 QString names ;
262 QLineEdit *line = mPickLineEdit; 259 QLineEdit *line = mPickLineEdit;
263 if (uid == this->name()) 260 if (uid == this->name())
264 { 261 {
265 for ( int i = 0; i < nameList.count(); i++) 262 for ( int i = 0; i < nameList.count(); i++)
266 { 263 {
267 QString _name = nameList[i]; 264 QString _name = nameList[i];
268 QString _email = emailList[i]; 265 QString _email = emailList[i];
269 QString _uid = uidList[i]; 266 QString _uid = uidList[i];
270 if ( ! _email.isEmpty() ) { 267 if ( ! _email.isEmpty() ) {
271 if ( ! names.isEmpty() ) 268 if ( ! names.isEmpty() )
272 names+= ","; 269 names+= ",";
273 names+= "\""+_name +"\"<" +_email +">"; 270 names+= "\""+_name +"\"<" +_email +">";
274 } 271 }
275 } 272 }
276 } 273 }
277 if ( line->text().isEmpty() ) { 274 if ( line->text().isEmpty() ) {
278 line->setText( names ); 275 line->setText( names );
279 } else if ( !names.isEmpty() ) { 276 } else if ( !names.isEmpty() ) {
280 line->setText( line->text() + ", " + names ); 277 line->setText( line->text() + ", " + names );
281 } 278 }
282} 279}
283 280
284void ComposeMail::setTo( const QString & to ) 281void ComposeMail::setTo( const QString & to )
285{ 282{
286 toLine->setText( to ); 283 toLine->setText( to );
287} 284}
288 285
289void ComposeMail::setSubject( const QString & subject ) 286void ComposeMail::setSubject( const QString & subject )
290{ 287{
291 subjectLine->setText( subject ); 288 subjectLine->setText( subject );
292} 289}
293 290
294void ComposeMail::setInReplyTo( const QString & messageId ) 291void ComposeMail::setInReplyTo( const QString & messageId )
295{ 292{
296 m_replyid = messageId; 293 m_replyid = messageId;
297} 294}
298 295
299void ComposeMail::setMessage( const QString & text ) 296void ComposeMail::setMessage( const QString & text )
300{ 297{
301 message->setText( text ); 298 message->setText( text );
302} 299}
303 300
304 301
305void ComposeMail::pickAddressTo() 302void ComposeMail::pickAddressTo()
306{ 303{
307 mPickLineEdit = toLine; 304 mPickLineEdit = toLine;
308 pickAddress( ); 305 pickAddress( );
309} 306}
310 307
311void ComposeMail::pickAddressCC() 308void ComposeMail::pickAddressCC()
312{ 309{
313 mPickLineEdit = ccLine; 310 mPickLineEdit = ccLine;
314 pickAddress( ); 311 pickAddress( );
315} 312}
316 313
317void ComposeMail::pickAddressBCC() 314void ComposeMail::pickAddressBCC()
318{ 315{
319 mPickLineEdit = bccLine; 316 mPickLineEdit = bccLine;
320 pickAddress( ); 317 pickAddress( );
321} 318}
322 319
323void ComposeMail::pickAddressReply() 320void ComposeMail::pickAddressReply()
324{ 321{
325 mPickLineEdit = replyLine; 322 mPickLineEdit = replyLine;
326 pickAddress( ); 323 pickAddress( );
327} 324}
328 325
329void ComposeMail::fillValues( int ) 326void ComposeMail::fillValues( int )
330{ 327{
331#if 0 328#if 0
332 SMTPaccount *smtp = smtpAccounts.at( current ); 329 SMTPaccount *smtp = smtpAccounts.at( current );
333 ccLine->clear(); 330 ccLine->clear();
334 if ( smtp->getUseCC() ) { 331 if ( smtp->getUseCC() ) {
335 ccLine->setText( smtp->getCC() ); 332 ccLine->setText( smtp->getCC() );
336 } 333 }
337 bccLine->clear(); 334 bccLine->clear();
338 if ( smtp->getUseBCC() ) { 335 if ( smtp->getUseBCC() ) {
339 bccLine->setText( smtp->getBCC() ); 336 bccLine->setText( smtp->getBCC() );
340 } 337 }
341 replyLine->clear(); 338 replyLine->clear();
342 if ( smtp->getUseReply() ) { 339 if ( smtp->getUseReply() ) {
343 replyLine->setText( smtp->getReply() ); 340 replyLine->setText( smtp->getReply() );
344 } 341 }
345 sigMultiLine->setText( smtp->getSignature() ); 342 sigMultiLine->setText( smtp->getSignature() );
346#endif 343#endif
347} 344}
348 345
349void ComposeMail::slotAdjustColumns() 346void ComposeMail::slotAdjustColumns()
350{ 347{
351 int currPage = tabWidget->currentPageIndex(); 348 int currPage = tabWidget->currentPageIndex();
352 349
353 tabWidget->showPage( attachTab ); 350 tabWidget->showPage( attachTab );
354 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 351 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
355 attList->setColumnWidth( 1, 80 ); 352 attList->setColumnWidth( 1, 80 );
356 353
357 tabWidget->setCurrentPage( currPage ); 354 tabWidget->setCurrentPage( currPage );
358} 355}
359 356
360void ComposeMail::addAttachment() 357void ComposeMail::addAttachment()
361{ 358{
362 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 359 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
363 if ( !lnk.isEmpty() ) { 360 if ( !lnk.isEmpty() ) {
364 Attachment *att = new Attachment( lnk ); 361 Attachment *att = new Attachment( lnk );
365 (void) new AttachViewItem( attList, att ); 362 (void) new AttachViewItem( attList, att );
366 } 363 }
367} 364}
368 365
369void ComposeMail::removeAttachment() 366void ComposeMail::removeAttachment()
370{ 367{
371 if ( !attList->currentItem() ) { 368 if ( !attList->currentItem() ) {
372 QMessageBox::information( this, i18n( "Error" ), 369 QMessageBox::information( this, i18n( "Error" ),
373 i18n( "<p>Please select a File.</p>" ), 370 i18n( "<p>Please select a File.</p>" ),
374 i18n( "Ok" ) ); 371 i18n( "Ok" ) );
375 } else { 372 } else {
376 attList->takeItem( attList->currentItem() ); 373 attList->takeItem( attList->currentItem() );
377 } 374 }
378} 375}
379 376
380void ComposeMail::accept() 377void ComposeMail::accept()
381{ 378{
382 if ( smtpAccountBox->count() == 0 ) { 379 if ( smtpAccountBox->count() == 0 ) {
383 380
384 reject(); 381 reject();
385 return; 382 return;
386 } 383 }
387 384
388 if (! checkBoxLater->isChecked() ) { 385 if (! checkBoxLater->isChecked() ) {
389 int yesno = QMessageBox::warning(0,i18n("Stop editing message"), 386 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
390 i18n("Send this message?"), 387 i18n("Send this message?"),
391 i18n("Yes"), 388 i18n("Yes"),
392 i18n("Cancel")); 389 i18n("Cancel"));
393 390
394 if (yesno == 1) { 391 if (yesno == 1) {
395 return; 392 return;
396 } 393 }
397 } 394 }
398#if 0 395#if 0
399 odebug << "Sending Mail with " 396 odebug << "Sending Mail with "
400 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 397 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
401#endif 398#endif
402 Opie::Core::OSmartPointer<Mail> mail=new Mail; 399 Opie::Core::OSmartPointer<Mail> mail=new Mail;
403 400
404 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 401 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
405 mail->setMail(fromBox->currentText()); 402 mail->setMail(fromBox->currentText());
406 403
407 if ( !toLine->text().isEmpty() ) { 404 if ( !toLine->text().isEmpty() ) {
408 mail->setTo( toLine->text() ); 405 mail->setTo( toLine->text() );
409 } else { 406 } else {
410 QMessageBox::warning(0,i18n("Sending mail"), 407 QMessageBox::warning(0,i18n("Sending mail"),
411 i18n("No Receiver spezified" ) ); 408 i18n("No Receiver spezified" ) );
412 return; 409 return;
413 } 410 }
414 411
415 mail->setName(senderNameEdit->text()); 412 mail->setName(senderNameEdit->text());
416 mail->setCC( ccLine->text() ); 413 mail->setCC( ccLine->text() );
417 mail->setBCC( bccLine->text() ); 414 mail->setBCC( bccLine->text() );
418 mail->setReply( replyLine->text() ); 415 mail->setReply( replyLine->text() );
419 mail->setSubject( subjectLine->text() ); 416 mail->setSubject( subjectLine->text() );
420 if (!m_replyid.isEmpty()) { 417 if (!m_replyid.isEmpty()) {
421 QStringList ids; 418 QStringList ids;
422 ids.append(m_replyid); 419 ids.append(m_replyid);
423 mail->setInreply(ids); 420 mail->setInreply(ids);
424 } 421 }
425 QString txt = message->text(); 422 QString txt = message->text();
426 if ( !sigMultiLine->text().isEmpty() ) { 423 if ( !sigMultiLine->text().isEmpty() ) {
427 txt.append( "\n--\n" ); 424 txt.append( "\n--\n" );
428 txt.append( sigMultiLine->text() ); 425 txt.append( sigMultiLine->text() );
429 } 426 }
430 mail->setMessage( txt ); 427 mail->setMessage( txt );
431 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 428 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
432 while ( it != 0 ) { 429 while ( it != 0 ) {
433 mail->addAttachment( it->getAttachment() ); 430 mail->addAttachment( it->getAttachment() );
434 it = (AttachViewItem *) it->nextSibling(); 431 it = (AttachViewItem *) it->nextSibling();
435 } 432 }
436 433
437 SMTPwrapper wrapper( smtp ); 434 SMTPwrapper wrapper( smtp );
438 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 435 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
439 setStatus( tr ("Mail sent")); 436 setStatus( tr ("Mail sent"));
440 else { 437 else {
441 setStatus( tr ("Error: Something went wrong. Nothing sent")); 438 setStatus( tr ("Error: Something went wrong. Nothing sent"));
442 return; 439 return;
443 } 440 }
444 441
445 442
446 QDialog::accept(); 443 QDialog::accept();
447} 444}
448 445
449void ComposeMail::reject() 446void ComposeMail::reject()
450{ 447{
451 //qDebug("ComposeMail::reject() "); 448 //qDebug("ComposeMail::reject() ");
452 int yesno = QMessageBox::warning(0,i18n("Store message?"), 449 int yesno = QMessageBox::warning(0,i18n("Store message?"),
453 i18n("Store message into drafts?\n"), 450 i18n("Store message into drafts?\n"),
454 i18n("Yes"), 451 i18n("Yes"),
455 i18n("No")); 452 i18n("No"));
456 453
457 //qDebug("button %d ", yesno); 454 //qDebug("button %d ", yesno);
458 if (yesno == 0) { 455 if (yesno == 0) {
459 if ( toLine->text().isEmpty() ) { 456 if ( toLine->text().isEmpty() ) {
460 QMessageBox::warning(0,i18n("Sending mail"), 457 QMessageBox::warning(0,i18n("Sending mail"),
461 i18n("No Receiver spezified" ) ); 458 i18n("No Receiver spezified" ) );
462 return; 459 return;
463 } 460 }
464 saveAsDraft(); 461 saveAsDraft();
465 } 462 }
466 if (yesno == 2) { 463 if (yesno == 2) {
467 qDebug("return "); 464 qDebug("return ");
468 return; 465 return;
469 } 466 }
470 QDialog::reject(); 467 QDialog::reject();
471} 468}
472 469
473ComposeMail::~ComposeMail() 470ComposeMail::~ComposeMail()
474{ 471{
475} 472}
476 473
477void ComposeMail::reEditMail(const RecMailP&current) 474void ComposeMail::reEditMail(const RecMailP&current)
478{ 475{
479 RecMailP data = current; 476 RecMailP data = current;
480 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 477 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
481 subjectLine->setText( data->getSubject()); 478 subjectLine->setText( data->getSubject());
482 toLine->setText(data->To().join(",")); 479 toLine->setText(data->To().join(","));
483 ccLine->setText(data->CC().join(",")); 480 ccLine->setText(data->CC().join(","));
484 bccLine->setText(data->Bcc().join(",")); 481 bccLine->setText(data->Bcc().join(","));
485 replyLine->setText(data->Replyto()); 482 replyLine->setText(data->Replyto());
486} 483}
487 484
488AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 485AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
489 : QListViewItem( parent ) 486 : QListViewItem( parent )
490{ 487{
491 attachment = att; 488 attachment = att;
492 if ( !attachment->getPixmap().isNull() ) 489 if ( !attachment->getPixmap().isNull() )
493 setPixmap( 0,attachment->getPixmap() ); 490 setPixmap( 0,attachment->getPixmap() );
494 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 491 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
495 setText( 1, QString::number( att->getSize() ) ); 492 setText( 1, QString::number( att->getSize() ) );
496} 493}
497 494