summaryrefslogtreecommitdiffabout
path: root/kmicromail/composemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 5945b7f..2dcbc75 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -24,55 +24,55 @@
24#include <libmailwrapper/mailtypes.h> 24#include <libmailwrapper/mailtypes.h>
25 25
26/* OPIE */ 26/* OPIE */
27//#include <opie2/ofiledialog.h> 27//#include <opie2/ofiledialog.h>
28//#include <opie2/odebug.h> 28//#include <opie2/odebug.h>
29#include <kfiledialog.h> 29#include <kfiledialog.h>
30//#include <qpe/resource.h> 30//#include <qpe/resource.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32//#include <qpe/contact.h> 32//#include <qpe/contact.h>
33 33
34 34
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37#include <qiconset.h> 37#include <qiconset.h>
38#include <qtimer.h> 38#include <qtimer.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qtabwidget.h> 43#include <qtabwidget.h>
44#include <qlistview.h> 44#include <qlistview.h>
45 45
46//using namespace Opie::Core; 46//using namespace Opie::Core;
47//using namespace Opie::Ui; 47//using namespace Opie::Ui;
48ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) 48ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal )
49 : ComposeMailUI( parent, name, modal ) 49 : ComposeMailUI( parent, name, modal )
50{ 50{
51 mPickLineEdit = 0; 51 mPickLineEdit = 0;
52 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 52 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
53 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 53 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
54 settings = s; 54 settings = sett;
55 m_replyid = ""; 55 m_replyid = "";
56 if ( KOPrefs::instance()->mUseKapi) { 56 if ( KOPrefs::instance()->mUseKapi) {
57 KConfig config( locateLocal("config", "kabcrc") ); 57 KConfig config( locateLocal("config", "kabcrc") );
58 config.setGroup( "General" ); 58 config.setGroup( "General" );
59 QString whoami_uid = config.readEntry( "WhoAmI" ); 59 QString whoami_uid = config.readEntry( "WhoAmI" );
60 60
61 if ( whoami_uid.isEmpty() ) { 61 if ( whoami_uid.isEmpty() ) {
62 QMessageBox::information( 0, i18n( "Hint" ), 62 QMessageBox::information( 0, i18n( "Hint" ),
63 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 63 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
64 i18n( "Ok" ) ); 64 i18n( "Ok" ) );
65 65
66 66
67 fillSettings(); 67 fillSettings();
68 } else 68 } else
69 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 69 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
70 70
71 71
72#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
73 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 73 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
74 QStringList mails = con.emails(); 74 QStringList mails = con.emails();
75 QString defmail = con.preferredEmail(); 75 QString defmail = con.preferredEmail();
76 if ( mails.count() == 0) 76 if ( mails.count() == 0)
77 QMessageBox::information( 0, i18n( "Hint" ), 77 QMessageBox::information( 0, i18n( "Hint" ),
78 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 78 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
@@ -144,61 +144,61 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m
144 } 144 }
145 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 145 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
146 146
147 147
148} 148}
149 149
150void ComposeMail::fillSettings() 150void ComposeMail::fillSettings()
151{ 151{
152 if ( QApplication::desktop()->width() < 320 ) 152 if ( QApplication::desktop()->width() < 320 )
153 fromBox->setMaximumWidth( 100 ); 153 fromBox->setMaximumWidth( 100 );
154 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 154 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
155 QStringList::ConstIterator sit = mailList.begin(); 155 QStringList::ConstIterator sit = mailList.begin();
156 int pref = 0; 156 int pref = 0;
157 for (;sit!=mailList.end();++sit) { 157 for (;sit!=mailList.end();++sit) {
158 fromBox->insertItem((*sit)); 158 fromBox->insertItem((*sit));
159 } 159 }
160 senderNameEdit->setText(KOPrefs::instance()->mName); 160 senderNameEdit->setText(KOPrefs::instance()->mName);
161} 161}
162 162
163 163
164void ComposeMail::saveAsDraft() 164void ComposeMail::saveAsDraft()
165{ 165{
166 166
167 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 167 Opie::Core::OSmartPointer<Mail> mail= new Mail();
168 mail->setMail(fromBox->currentText()); 168 mail->setMail(fromBox->currentText().utf8 ());
169 mail->setTo( toLine->text() ); 169 mail->setTo( toLine->text().utf8 () );
170 mail->setName(senderNameEdit->text()); 170 mail->setName(senderNameEdit->text().utf8 ());
171 mail->setCC( ccLine->text() ); 171 mail->setCC( ccLine->text().utf8 () );
172 mail->setBCC( bccLine->text() ); 172 mail->setBCC( bccLine->text().utf8 () );
173 mail->setReply( replyLine->text() ); 173 mail->setReply( replyLine->text().utf8 () );
174 mail->setSubject( subjectLine->text() ); 174 mail->setSubject( subjectLine->text().utf8 () );
175 if (!m_replyid.isEmpty()) { 175 if (!m_replyid.isEmpty()) {
176 QStringList ids; 176 QStringList ids;
177 ids.append(m_replyid); 177 ids.append(m_replyid);
178 mail->setInreply(ids); 178 mail->setInreply(ids);
179 } 179 }
180 QString txt = message->text(); 180 QString txt = message->text().utf8 ();
181 if ( !sigMultiLine->text().isEmpty() ) { 181 if ( !sigMultiLine->text().isEmpty() ) {
182 txt.append( "\n--\n" ); 182 txt.append( "\n--\n" );
183 txt.append( sigMultiLine->text() ); 183 txt.append( sigMultiLine->text() );
184 } 184 }
185 mail->setMessage( txt ); 185 mail->setMessage( txt );
186 186
187 /* only use the default drafts folder name! */ 187 /* only use the default drafts folder name! */
188 Storemail wrapper(AbstractMail::draftFolder()); 188 Storemail wrapper(AbstractMail::draftFolder());
189 wrapper.storeMail(mail); 189 wrapper.storeMail(mail);
190 190
191 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 191 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
192 /* attachments we will ignore! */ 192 /* attachments we will ignore! */
193 if ( it != 0 ) { 193 if ( it != 0 ) {
194 if ( warnAttach ) 194 if ( warnAttach )
195 QMessageBox::warning(0,i18n("Store message"), 195 QMessageBox::warning(0,i18n("Store message"),
196 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 196 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
197 warnAttach = false; 197 warnAttach = false;
198 } 198 }
199 setStatus( i18n("Mail saved as draft!") ); 199 setStatus( i18n("Mail saved as draft!") );
200} 200}
201void ComposeMail::clearStatus() 201void ComposeMail::clearStatus()
202{ 202{
203 topLevelWidget()->setCaption( i18n("Compose mail") ); 203 topLevelWidget()->setCaption( i18n("Compose mail") );
204} 204}
@@ -387,72 +387,72 @@ void ComposeMail::accept()
387{ 387{
388 if ( smtpAccountBox->count() == 0 ) { 388 if ( smtpAccountBox->count() == 0 ) {
389 389
390 reject(); 390 reject();
391 return; 391 return;
392 } 392 }
393 393
394 if (! checkBoxLater->isChecked() ) { 394 if (! checkBoxLater->isChecked() ) {
395 int yesno = QMessageBox::warning(0,i18n("Stop editing message"), 395 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
396 i18n("Send this message?"), 396 i18n("Send this message?"),
397 i18n("Yes"), 397 i18n("Yes"),
398 i18n("Cancel")); 398 i18n("Cancel"));
399 399
400 if (yesno == 1) { 400 if (yesno == 1) {
401 return; 401 return;
402 } 402 }
403 } 403 }
404#if 0 404#if 0
405 odebug << "Sending Mail with " 405 odebug << "Sending Mail with "
406 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 406 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
407#endif 407#endif
408 Opie::Core::OSmartPointer<Mail> mail=new Mail; 408 Opie::Core::OSmartPointer<Mail> mail=new Mail;
409 409
410 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 410 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
411 mail->setMail(fromBox->currentText()); 411 mail->setMail(fromBox->currentText().utf8 ());
412 412
413 if ( !toLine->text().isEmpty() ) { 413 if ( !toLine->text().isEmpty() ) {
414 mail->setTo( toLine->text() ); 414 mail->setTo( toLine->text().utf8 () );
415 } else { 415 } else {
416 QMessageBox::warning(0,i18n("Sending mail"), 416 QMessageBox::warning(0,i18n("Sending mail"),
417 i18n("No Receiver spezified" ) ); 417 i18n("No Receiver spezified" ) );
418 return; 418 return;
419 } 419 }
420 420
421 mail->setName(senderNameEdit->text()); 421 mail->setName(senderNameEdit->text().utf8 ());
422 mail->setCC( ccLine->text() ); 422 mail->setCC( ccLine->text().utf8 () );
423 mail->setBCC( bccLine->text() ); 423 mail->setBCC( bccLine->text().utf8 () );
424 mail->setReply( replyLine->text() ); 424 mail->setReply( replyLine->text().utf8 () );
425 mail->setSubject( subjectLine->text() ); 425 mail->setSubject( subjectLine->text().utf8 () );
426 if (!m_replyid.isEmpty()) { 426 if (!m_replyid.isEmpty()) {
427 QStringList ids; 427 QStringList ids;
428 ids.append(m_replyid); 428 ids.append(m_replyid.utf8 ());
429 mail->setInreply(ids); 429 mail->setInreply(ids);
430 } 430 }
431 QString txt = message->text(); 431 QString txt = message->text().utf8 ();
432 if ( !sigMultiLine->text().isEmpty() ) { 432 if ( !sigMultiLine->text().isEmpty() ) {
433 txt.append( "\n--\n" ); 433 txt.append( "\n--\n" );
434 txt.append( sigMultiLine->text() ); 434 txt.append( sigMultiLine->text().utf8 () );
435 } 435 }
436 mail->setMessage( txt ); 436 mail->setMessage( txt );
437 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 437 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
438 while ( it != 0 ) { 438 while ( it != 0 ) {
439 mail->addAttachment( it->getAttachment() ); 439 mail->addAttachment( it->getAttachment() );
440 it = (AttachViewItem *) it->nextSibling(); 440 it = (AttachViewItem *) it->nextSibling();
441 } 441 }
442 442
443 SMTPwrapper wrapper( smtp ); 443 SMTPwrapper wrapper( smtp );
444 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 444 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
445 setStatus( tr ("Mail sent")); 445 setStatus( tr ("Mail sent"));
446 else { 446 else {
447 setStatus( tr ("Error: Something went wrong. Nothing sent")); 447 setStatus( tr ("Error: Something went wrong. Nothing sent"));
448 return; 448 return;
449 } 449 }
450 450
451 451
452 QDialog::accept(); 452 QDialog::accept();
453} 453}
454 454
455void ComposeMail::reject() 455void ComposeMail::reject()
456{ 456{
457 //qDebug("ComposeMail::reject() "); 457 //qDebug("ComposeMail::reject() ");
458 int yesno = QMessageBox::warning(0,i18n("Store message?"), 458 int yesno = QMessageBox::warning(0,i18n("Store message?"),
@@ -462,42 +462,42 @@ void ComposeMail::reject()
462 462
463 //qDebug("button %d ", yesno); 463 //qDebug("button %d ", yesno);
464 if (yesno == 0) { 464 if (yesno == 0) {
465 if ( toLine->text().isEmpty() ) { 465 if ( toLine->text().isEmpty() ) {
466 QMessageBox::warning(0,i18n("Sending mail"), 466 QMessageBox::warning(0,i18n("Sending mail"),
467 i18n("No Receiver spezified" ) ); 467 i18n("No Receiver spezified" ) );
468 return; 468 return;
469 } 469 }
470 saveAsDraft(); 470 saveAsDraft();
471 } 471 }
472 if (yesno == 2) { 472 if (yesno == 2) {
473 qDebug("return "); 473 qDebug("return ");
474 return; 474 return;
475 } 475 }
476 QDialog::reject(); 476 QDialog::reject();
477} 477}
478 478
479ComposeMail::~ComposeMail() 479ComposeMail::~ComposeMail()
480{ 480{
481} 481}
482 482
483void ComposeMail::reEditMail(const RecMailP&current) 483void ComposeMail::reEditMail(const RecMailP&current)
484{ 484{
485 RecMailP data = current; 485 RecMailP data = current;
486 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 486 message->setText(QString::fromUtf8( data->Wrapper()->fetchBody(current)->Bodytext().latin1() ));
487 subjectLine->setText( data->getSubject()); 487 subjectLine->setText( QString::fromUtf8( data->getSubject().latin1() ));
488 toLine->setText(data->To().join(",")); 488 toLine->setText(QString::fromUtf8( data->To().join(",").latin1() ));
489 ccLine->setText(data->CC().join(",")); 489 ccLine->setText(QString::fromUtf8( data->CC().join(",").latin1() ));
490 bccLine->setText(data->Bcc().join(",")); 490 bccLine->setText(QString::fromUtf8( data->Bcc().join(",").latin1() ));
491 replyLine->setText(data->Replyto()); 491 replyLine->setText(QString::fromUtf8( data->Replyto().latin1() ));
492} 492}
493 493
494AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 494AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
495 : QListViewItem( parent ) 495 : QListViewItem( parent )
496{ 496{
497 attachment = att; 497 attachment = att;
498 if ( !attachment->getPixmap().isNull() ) 498 if ( !attachment->getPixmap().isNull() )
499 setPixmap( 0,attachment->getPixmap() ); 499 setPixmap( 0,attachment->getPixmap() );
500 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 500 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
501 setText( 1, QString::number( att->getSize() ) ); 501 setText( 1, QString::number( att->getSize() ) );
502} 502}
503 503