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
@@ -1,503 +1,503 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3#include <kabc/addresseedialog.h> 3#include <kabc/addresseedialog.h>
4#include <kabc/stdaddressbook.h> 4#include <kabc/stdaddressbook.h>
5#include <kabc/addressee.h> 5#include <kabc/addressee.h>
6#ifdef DESKTOP_VERSION 6#ifdef DESKTOP_VERSION
7#include <qapplication.h> 7#include <qapplication.h>
8#include <kabc/addresseedialog.h> 8#include <kabc/addresseedialog.h>
9#endif //DESKTOP_VERSION 9#endif //DESKTOP_VERSION
10#include <libkdepim/externalapphandler.h> 10#include <libkdepim/externalapphandler.h>
11 11
12#include "koprefs.h" 12#include "koprefs.h"
13 13
14#ifdef MINIKDE_KDIALOG_H 14#ifdef MINIKDE_KDIALOG_H
15#undef MINIKDE_KDIALOG_H 15#undef MINIKDE_KDIALOG_H
16#endif 16#endif
17 17
18 18
19#include "composemail.h" 19#include "composemail.h"
20 20
21#include <libmailwrapper/smtpwrapper.h> 21#include <libmailwrapper/smtpwrapper.h>
22#include <libmailwrapper/storemail.h> 22#include <libmailwrapper/storemail.h>
23#include <libmailwrapper/abstractmail.h> 23#include <libmailwrapper/abstractmail.h>
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" ),
79 i18n( "Ok" ) ); 79 i18n( "Ok" ) );
80 if (defmail.length()!=0) { 80 if (defmail.length()!=0) {
81 fromBox->insertItem(defmail); 81 fromBox->insertItem(defmail);
82 } 82 }
83 QStringList::ConstIterator sit = mails.begin(); 83 QStringList::ConstIterator sit = mails.begin();
84 for (;sit!=mails.end();++sit) { 84 for (;sit!=mails.end();++sit) {
85 if ( (*sit)==defmail) 85 if ( (*sit)==defmail)
86 continue; 86 continue;
87 fromBox->insertItem((*sit)); 87 fromBox->insertItem((*sit));
88 } 88 }
89 senderNameEdit->setText(con.formattedName()); 89 senderNameEdit->setText(con.formattedName());
90#endif 90#endif
91 91
92 } else { 92 } else {
93 fillSettings(); 93 fillSettings();
94 } 94 }
95 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 95 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
96 96
97 attList->addColumn( i18n( "Name" ) ); 97 attList->addColumn( i18n( "Name" ) );
98 attList->addColumn( i18n( "Size" ) ); 98 attList->addColumn( i18n( "Size" ) );
99 QList<Account> accounts = settings->getAccounts(); 99 QList<Account> accounts = settings->getAccounts();
100 100
101 if ( QApplication::desktop()->width() < 320 ) 101 if ( QApplication::desktop()->width() < 320 )
102 smtpAccountBox->setMaximumWidth( 80 ); 102 smtpAccountBox->setMaximumWidth( 80 );
103 Account *it; 103 Account *it;
104 for ( it = accounts.first(); it; it = accounts.next() ) { 104 for ( it = accounts.first(); it; it = accounts.next() ) {
105 if ( it->getType()==MAILLIB::A_SMTP ) { 105 if ( it->getType()==MAILLIB::A_SMTP ) {
106 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 106 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
107 smtpAccountBox->insertItem( smtp->getAccountName() ); 107 smtpAccountBox->insertItem( smtp->getAccountName() );
108 smtpAccounts.append( smtp ); 108 smtpAccounts.append( smtp );
109 } 109 }
110 } 110 }
111 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 111 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
112 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 112 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
113 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 113 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
114 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 114 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
115 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 115 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
116 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 116 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
117 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 117 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
118 mMail = 0; 118 mMail = 0;
119 warnAttach = true; 119 warnAttach = true;
120 QIconSet icon; 120 QIconSet icon;
121 //icon = SmallIcon("fileexport"); 121 //icon = SmallIcon("fileexport");
122 icon = SmallIcon("filesave"); 122 icon = SmallIcon("filesave");
123 SaveButton->setIconSet (icon ) ; 123 SaveButton->setIconSet (icon ) ;
124 if ( QApplication::desktop()->width() < 320 ) { 124 if ( QApplication::desktop()->width() < 320 ) {
125 SaveButton->setText ("") ; 125 SaveButton->setText ("") ;
126 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; 126 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
127 } 127 }
128 else 128 else
129 SaveButton->setText (i18n("Save")); 129 SaveButton->setText (i18n("Save"));
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 131 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
132 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 132 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
133 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 133 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
134#endif 134#endif
135 message->setFont ( KOPrefs::instance()->mComposeFont ); 135 message->setFont ( KOPrefs::instance()->mComposeFont );
136 message->setWordWrap (QMultiLineEdit::WidgetWidth); 136 message->setWordWrap (QMultiLineEdit::WidgetWidth);
137 if ( smtpAccounts.count() > 0 ) { 137 if ( smtpAccounts.count() > 0 ) {
138 fillValues( smtpAccountBox->currentItem() ); 138 fillValues( smtpAccountBox->currentItem() );
139 } else { 139 } else {
140 QMessageBox::information( 0, i18n( "Problem" ), 140 QMessageBox::information( 0, i18n( "Problem" ),
141 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 141 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
142 i18n( "Ok" ) ); 142 i18n( "Ok" ) );
143 return; 143 return;
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}
205void ComposeMail::setStatus( QString status ) 205void ComposeMail::setStatus( QString status )
206{ 206{
207 topLevelWidget()->setCaption( status ); 207 topLevelWidget()->setCaption( status );
208 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 208 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
209} 209}
210void ComposeMail::pickAddress( ) 210void ComposeMail::pickAddress( )
211{ 211{
212 212
213 QLineEdit *line = mPickLineEdit; 213 QLineEdit *line = mPickLineEdit;
214 if ( line == 0 ) 214 if ( line == 0 )
215 return; 215 return;
216#ifdef DESKTOP_VERSION 216#ifdef DESKTOP_VERSION
217 //qDebug(" ComposeMail::pickAddress "); 217 //qDebug(" ComposeMail::pickAddress ");
218 QString names ;//= AddressPicker::getNames(); 218 QString names ;//= AddressPicker::getNames();
219 219
220 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 220 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
221 uint i=0; 221 uint i=0;
222 for (i=0; i < list.count(); i++) { 222 for (i=0; i < list.count(); i++) {
223 if ( !list[i].preferredEmail().isEmpty()) { 223 if ( !list[i].preferredEmail().isEmpty()) {
224 if ( ! names.isEmpty() ) 224 if ( ! names.isEmpty() )
225 names+= ","; 225 names+= ",";
226 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 226 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
227 227
228 } 228 }
229 } 229 }
230 230
231 231
232 if ( line->text().isEmpty() ) { 232 if ( line->text().isEmpty() ) {
233 line->setText( names ); 233 line->setText( names );
234 } else if ( !names.isEmpty() ) { 234 } else if ( !names.isEmpty() ) {
235 line->setText( line->text() + ", " + names ); 235 line->setText( line->text() + ", " + names );
236 } 236 }
237#else 237#else
238 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 238 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
239 // the result should now arrive through method insertAttendees 239 // the result should now arrive through method insertAttendees
240#endif 240#endif
241} 241}
242//the map includes name/email pairs, that comes from Ka/Pi 242//the map includes name/email pairs, that comes from Ka/Pi
243void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 243void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
244{ 244{
245 //qDebug("ComposeMail::insertAttendees "); 245 //qDebug("ComposeMail::insertAttendees ");
246 raise(); 246 raise();
247 247
248 if ( mPickLineEdit == 0 ) { //whoami received 248 if ( mPickLineEdit == 0 ) { //whoami received
249 QString defmail = uidList[0]; 249 QString defmail = uidList[0];
250 if ( emailList.count() == 0 ) 250 if ( emailList.count() == 0 )
251 QMessageBox::information( 0, i18n( "Hint" ), 251 QMessageBox::information( 0, i18n( "Hint" ),
252 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 252 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
253 i18n( "Ok" ) ); 253 i18n( "Ok" ) );
254 if (defmail.length()!=0) { 254 if (defmail.length()!=0) {
255 fromBox->insertItem(defmail); 255 fromBox->insertItem(defmail);
256 } 256 }
257 QStringList::ConstIterator sit = emailList.begin(); 257 QStringList::ConstIterator sit = emailList.begin();
258 int pref = 0; 258 int pref = 0;
259 for (;sit!=emailList.end();++sit) { 259 for (;sit!=emailList.end();++sit) {
260 if ( (*sit)==defmail) 260 if ( (*sit)==defmail)
261 continue; 261 continue;
262 fromBox->insertItem((*sit)); 262 fromBox->insertItem((*sit));
263 } 263 }
264 senderNameEdit->setText(nameList[0]); 264 senderNameEdit->setText(nameList[0]);
265 return; 265 return;
266 } 266 }
267 QString names ; 267 QString names ;
268 QLineEdit *line = mPickLineEdit; 268 QLineEdit *line = mPickLineEdit;
269 if (uid == this->name()) 269 if (uid == this->name())
270 { 270 {
271 for ( int i = 0; i < nameList.count(); i++) 271 for ( int i = 0; i < nameList.count(); i++)
272 { 272 {
273 QString _name = nameList[i]; 273 QString _name = nameList[i];
274 QString _email = emailList[i]; 274 QString _email = emailList[i];
275 QString _uid = uidList[i]; 275 QString _uid = uidList[i];
276 if ( ! _email.isEmpty() ) { 276 if ( ! _email.isEmpty() ) {
277 if ( ! names.isEmpty() ) 277 if ( ! names.isEmpty() )
278 names+= ","; 278 names+= ",";
279 names+= "\""+_name +"\"<" +_email +">"; 279 names+= "\""+_name +"\"<" +_email +">";
280 } 280 }
281 } 281 }
282 } 282 }
283 if ( line->text().isEmpty() ) { 283 if ( line->text().isEmpty() ) {
284 line->setText( names ); 284 line->setText( names );
285 } else if ( !names.isEmpty() ) { 285 } else if ( !names.isEmpty() ) {
286 line->setText( line->text() + ", " + names ); 286 line->setText( line->text() + ", " + names );
287 } 287 }
288} 288}
289 289
290void ComposeMail::setTo( const QString & to ) 290void ComposeMail::setTo( const QString & to )
291{ 291{
292 toLine->setText( to ); 292 toLine->setText( to );
293} 293}
294 294
295void ComposeMail::setSubject( const QString & subject ) 295void ComposeMail::setSubject( const QString & subject )
296{ 296{
297 subjectLine->setText( subject ); 297 subjectLine->setText( subject );
298} 298}
299 299
300void ComposeMail::setInReplyTo( const QString & messageId ) 300void ComposeMail::setInReplyTo( const QString & messageId )
301{ 301{
302 m_replyid = messageId; 302 m_replyid = messageId;
303} 303}
304 304
305void ComposeMail::setMessage( const QString & text ) 305void ComposeMail::setMessage( const QString & text )
306{ 306{
307 message->setText( text ); 307 message->setText( text );
308} 308}
309 309
310 310
311void ComposeMail::pickAddressTo() 311void ComposeMail::pickAddressTo()
312{ 312{
313 mPickLineEdit = toLine; 313 mPickLineEdit = toLine;
314 pickAddress( ); 314 pickAddress( );
315} 315}
316 316
317void ComposeMail::pickAddressCC() 317void ComposeMail::pickAddressCC()
318{ 318{
319 mPickLineEdit = ccLine; 319 mPickLineEdit = ccLine;
320 pickAddress( ); 320 pickAddress( );
321} 321}
322 322
323void ComposeMail::pickAddressBCC() 323void ComposeMail::pickAddressBCC()
324{ 324{
325 mPickLineEdit = bccLine; 325 mPickLineEdit = bccLine;
326 pickAddress( ); 326 pickAddress( );
327} 327}
328 328
329void ComposeMail::pickAddressReply() 329void ComposeMail::pickAddressReply()
330{ 330{
331 mPickLineEdit = replyLine; 331 mPickLineEdit = replyLine;
332 pickAddress( ); 332 pickAddress( );
333} 333}
334 334
335void ComposeMail::fillValues( int ) 335void ComposeMail::fillValues( int )
336{ 336{
337#if 0 337#if 0
338 SMTPaccount *smtp = smtpAccounts.at( current ); 338 SMTPaccount *smtp = smtpAccounts.at( current );
339 ccLine->clear(); 339 ccLine->clear();
340 if ( smtp->getUseCC() ) { 340 if ( smtp->getUseCC() ) {
341 ccLine->setText( smtp->getCC() ); 341 ccLine->setText( smtp->getCC() );
342 } 342 }
343 bccLine->clear(); 343 bccLine->clear();
344 if ( smtp->getUseBCC() ) { 344 if ( smtp->getUseBCC() ) {
345 bccLine->setText( smtp->getBCC() ); 345 bccLine->setText( smtp->getBCC() );
346 } 346 }
347 replyLine->clear(); 347 replyLine->clear();
348 if ( smtp->getUseReply() ) { 348 if ( smtp->getUseReply() ) {
349 replyLine->setText( smtp->getReply() ); 349 replyLine->setText( smtp->getReply() );
350 } 350 }
351 sigMultiLine->setText( smtp->getSignature() ); 351 sigMultiLine->setText( smtp->getSignature() );
352#endif 352#endif
353} 353}
354 354
355void ComposeMail::slotAdjustColumns() 355void ComposeMail::slotAdjustColumns()
356{ 356{
357 int currPage = tabWidget->currentPageIndex(); 357 int currPage = tabWidget->currentPageIndex();
358 358
359 tabWidget->showPage( attachTab ); 359 tabWidget->showPage( attachTab );
360 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 360 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
361 attList->setColumnWidth( 1, 80 ); 361 attList->setColumnWidth( 1, 80 );
362 362
363 tabWidget->setCurrentPage( currPage ); 363 tabWidget->setCurrentPage( currPage );
364} 364}
365 365
366void ComposeMail::addAttachment() 366void ComposeMail::addAttachment()
367{ 367{
368 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 368 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
369 if ( !lnk.isEmpty() ) { 369 if ( !lnk.isEmpty() ) {
370 Attachment *att = new Attachment( lnk ); 370 Attachment *att = new Attachment( lnk );
371 (void) new AttachViewItem( attList, att ); 371 (void) new AttachViewItem( attList, att );
372 } 372 }
373} 373}
374 374
375void ComposeMail::removeAttachment() 375void ComposeMail::removeAttachment()
376{ 376{
377 if ( !attList->currentItem() ) { 377 if ( !attList->currentItem() ) {
378 QMessageBox::information( this, i18n( "Error" ), 378 QMessageBox::information( this, i18n( "Error" ),
379 i18n( "<p>Please select a File.</p>" ), 379 i18n( "<p>Please select a File.</p>" ),
380 i18n( "Ok" ) ); 380 i18n( "Ok" ) );
381 } else { 381 } else {
382 attList->takeItem( attList->currentItem() ); 382 attList->takeItem( attList->currentItem() );
383 } 383 }
384} 384}
385 385
386void ComposeMail::accept() 386void 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?"),
459 i18n("Store message into drafts?\n"), 459 i18n("Store message into drafts?\n"),
460 i18n("Yes"), 460 i18n("Yes"),
461 i18n("No")); 461 i18n("No"));
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