summaryrefslogtreecommitdiffabout
path: root/kmicromail/composemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 8eb6d27..0cd0b23 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,496 +1,497 @@
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 <qapplication.h>
33#include <kabc/addresseedialog.h> 34#include <kabc/addresseedialog.h>
34#else //DESKTOP_VERSION
35#include <libkdepim/externalapphandler.h>
36#endif //DESKTOP_VERSION 35#endif //DESKTOP_VERSION
36#include <libkdepim/externalapphandler.h>
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 if ( QApplication::desktop()->width() < 320 ) 117 SaveButton->setIconSet (icon ) ;
118 if ( QApplication::desktop()->width() < 320 ) {
118 SaveButton->setText ("") ; 119 SaveButton->setText ("") ;
120 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
121 }
119 else 122 else
120 SaveButton->setText (i18n("Save")) ; 123 SaveButton->setText (i18n("Save"));
121 SaveButton->setIconSet (icon ) ;
122 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
123#ifndef DESKTOP_VERSION 124#ifndef DESKTOP_VERSION
124 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 125 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
125 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 126 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
126 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 127 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
127#endif 128#endif
128 message->setFont ( KOPrefs::instance()->mComposeFont ); 129 message->setFont ( KOPrefs::instance()->mComposeFont );
129 message->setWordWrap (QMultiLineEdit::WidgetWidth); 130 message->setWordWrap (QMultiLineEdit::WidgetWidth);
130 if ( smtpAccounts.count() > 0 ) { 131 if ( smtpAccounts.count() > 0 ) {
131 fillValues( smtpAccountBox->currentItem() ); 132 fillValues( smtpAccountBox->currentItem() );
132 } else { 133 } else {
133 QMessageBox::information( 0, i18n( "Problem" ), 134 QMessageBox::information( 0, i18n( "Problem" ),
134 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 135 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
135 i18n( "Ok" ) ); 136 i18n( "Ok" ) );
136 return; 137 return;
137 } 138 }
138 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 139 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
139 140
140 141
141} 142}
142 143
143void ComposeMail::fillSettings() 144void ComposeMail::fillSettings()
144{ 145{
145 if ( QApplication::desktop()->width() < 320 ) 146 if ( QApplication::desktop()->width() < 320 )
146 fromBox->setMaximumWidth( 100 ); 147 fromBox->setMaximumWidth( 100 );
147 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 148 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
148 QStringList::ConstIterator sit = mailList.begin(); 149 QStringList::ConstIterator sit = mailList.begin();
149 int pref = 0; 150 int pref = 0;
150 for (;sit!=mailList.end();++sit) { 151 for (;sit!=mailList.end();++sit) {
151 fromBox->insertItem((*sit)); 152 fromBox->insertItem((*sit));
152 } 153 }
153 senderNameEdit->setText(KOPrefs::instance()->mName); 154 senderNameEdit->setText(KOPrefs::instance()->mName);
154} 155}
155 156
156 157
157void ComposeMail::saveAsDraft() 158void ComposeMail::saveAsDraft()
158{ 159{
159 160
160 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 161 Opie::Core::OSmartPointer<Mail> mail= new Mail();
161 mail->setMail(fromBox->currentText()); 162 mail->setMail(fromBox->currentText());
162 mail->setTo( toLine->text() ); 163 mail->setTo( toLine->text() );
163 mail->setName(senderNameEdit->text()); 164 mail->setName(senderNameEdit->text());
164 mail->setCC( ccLine->text() ); 165 mail->setCC( ccLine->text() );
165 mail->setBCC( bccLine->text() ); 166 mail->setBCC( bccLine->text() );
166 mail->setReply( replyLine->text() ); 167 mail->setReply( replyLine->text() );
167 mail->setSubject( subjectLine->text() ); 168 mail->setSubject( subjectLine->text() );
168 if (!m_replyid.isEmpty()) { 169 if (!m_replyid.isEmpty()) {
169 QStringList ids; 170 QStringList ids;
170 ids.append(m_replyid); 171 ids.append(m_replyid);
171 mail->setInreply(ids); 172 mail->setInreply(ids);
172 } 173 }
173 QString txt = message->text(); 174 QString txt = message->text();
174 if ( !sigMultiLine->text().isEmpty() ) { 175 if ( !sigMultiLine->text().isEmpty() ) {
175 txt.append( "\n--\n" ); 176 txt.append( "\n--\n" );
176 txt.append( sigMultiLine->text() ); 177 txt.append( sigMultiLine->text() );
177 } 178 }
178 mail->setMessage( txt ); 179 mail->setMessage( txt );
179 180
180 /* only use the default drafts folder name! */ 181 /* only use the default drafts folder name! */
181 Storemail wrapper(AbstractMail::draftFolder()); 182 Storemail wrapper(AbstractMail::draftFolder());
182 wrapper.storeMail(mail); 183 wrapper.storeMail(mail);
183 184
184 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 185 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
185 /* attachments we will ignore! */ 186 /* attachments we will ignore! */
186 if ( it != 0 ) { 187 if ( it != 0 ) {
187 if ( warnAttach ) 188 if ( warnAttach )
188 QMessageBox::warning(0,i18n("Store message"), 189 QMessageBox::warning(0,i18n("Store message"),
189 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 190 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
190 warnAttach = false; 191 warnAttach = false;
191 } 192 }
192 setStatus( i18n("Mail saved as draft!") ); 193 setStatus( i18n("Mail saved as draft!") );
193} 194}
194void ComposeMail::clearStatus() 195void ComposeMail::clearStatus()
195{ 196{
196 topLevelWidget()->setCaption( i18n("Compose mail") ); 197 topLevelWidget()->setCaption( i18n("Compose mail") );
197} 198}
198void ComposeMail::setStatus( QString status ) 199void ComposeMail::setStatus( QString status )
199{ 200{
200 topLevelWidget()->setCaption( status ); 201 topLevelWidget()->setCaption( status );
201 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 202 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
202} 203}
203void ComposeMail::pickAddress( ) 204void ComposeMail::pickAddress( )
204{ 205{
205 206
206 QLineEdit *line = mPickLineEdit; 207 QLineEdit *line = mPickLineEdit;
207 if ( line == 0 ) 208 if ( line == 0 )
208 return; 209 return;
209#ifdef DESKTOP_VERSION 210#ifdef DESKTOP_VERSION
210 //qDebug(" ComposeMail::pickAddress "); 211 //qDebug(" ComposeMail::pickAddress ");
211 QString names ;//= AddressPicker::getNames(); 212 QString names ;//= AddressPicker::getNames();
212 213
213 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 214 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
214 uint i=0; 215 uint i=0;
215 for (i=0; i < list.count(); i++) { 216 for (i=0; i < list.count(); i++) {
216 if ( !list[i].preferredEmail().isEmpty()) { 217 if ( !list[i].preferredEmail().isEmpty()) {
217 if ( ! names.isEmpty() ) 218 if ( ! names.isEmpty() )
218 names+= ","; 219 names+= ",";
219 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 220 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
220 221
221 } 222 }
222 } 223 }
223 224
224 225
225 if ( line->text().isEmpty() ) { 226 if ( line->text().isEmpty() ) {
226 line->setText( names ); 227 line->setText( names );
227 } else if ( !names.isEmpty() ) { 228 } else if ( !names.isEmpty() ) {
228 line->setText( line->text() + ", " + names ); 229 line->setText( line->text() + ", " + names );
229 } 230 }
230#else 231#else
231 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 232 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
232 // the result should now arrive through method insertAttendees 233 // the result should now arrive through method insertAttendees
233#endif 234#endif
234} 235}
235//the map includes name/email pairs, that comes from Ka/Pi 236//the map includes name/email pairs, that comes from Ka/Pi
236void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 237void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
237{ 238{
238 //qDebug("ComposeMail::insertAttendees "); 239 //qDebug("ComposeMail::insertAttendees ");
239 raise(); 240 raise();
240 241
241 if ( mPickLineEdit == 0 ) { //whoami received 242 if ( mPickLineEdit == 0 ) { //whoami received
242 QString defmail = uidList[0]; 243 QString defmail = uidList[0];
243 if ( emailList.count() == 0 ) 244 if ( emailList.count() == 0 )
244 QMessageBox::information( 0, i18n( "Hint" ), 245 QMessageBox::information( 0, i18n( "Hint" ),
245 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 246 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
246 i18n( "Ok" ) ); 247 i18n( "Ok" ) );
247 if (defmail.length()!=0) { 248 if (defmail.length()!=0) {
248 fromBox->insertItem(defmail); 249 fromBox->insertItem(defmail);
249 } 250 }
250 QStringList::ConstIterator sit = emailList.begin(); 251 QStringList::ConstIterator sit = emailList.begin();
251 int pref = 0; 252 int pref = 0;
252 for (;sit!=emailList.end();++sit) { 253 for (;sit!=emailList.end();++sit) {
253 if ( (*sit)==defmail) 254 if ( (*sit)==defmail)
254 continue; 255 continue;
255 fromBox->insertItem((*sit)); 256 fromBox->insertItem((*sit));
256 } 257 }
257 senderNameEdit->setText(nameList[0]); 258 senderNameEdit->setText(nameList[0]);
258 return; 259 return;
259 } 260 }
260 QString names ; 261 QString names ;
261 QLineEdit *line = mPickLineEdit; 262 QLineEdit *line = mPickLineEdit;
262 if (uid == this->name()) 263 if (uid == this->name())
263 { 264 {
264 for ( int i = 0; i < nameList.count(); i++) 265 for ( int i = 0; i < nameList.count(); i++)
265 { 266 {
266 QString _name = nameList[i]; 267 QString _name = nameList[i];
267 QString _email = emailList[i]; 268 QString _email = emailList[i];
268 QString _uid = uidList[i]; 269 QString _uid = uidList[i];
269 if ( ! _email.isEmpty() ) { 270 if ( ! _email.isEmpty() ) {
270 if ( ! names.isEmpty() ) 271 if ( ! names.isEmpty() )
271 names+= ","; 272 names+= ",";
272 names+= "\""+_name +"\"<" +_email +">"; 273 names+= "\""+_name +"\"<" +_email +">";
273 } 274 }
274 } 275 }
275 } 276 }
276 if ( line->text().isEmpty() ) { 277 if ( line->text().isEmpty() ) {
277 line->setText( names ); 278 line->setText( names );
278 } else if ( !names.isEmpty() ) { 279 } else if ( !names.isEmpty() ) {
279 line->setText( line->text() + ", " + names ); 280 line->setText( line->text() + ", " + names );
280 } 281 }
281} 282}
282 283
283void ComposeMail::setTo( const QString & to ) 284void ComposeMail::setTo( const QString & to )
284{ 285{
285 toLine->setText( to ); 286 toLine->setText( to );
286} 287}
287 288
288void ComposeMail::setSubject( const QString & subject ) 289void ComposeMail::setSubject( const QString & subject )
289{ 290{
290 subjectLine->setText( subject ); 291 subjectLine->setText( subject );
291} 292}
292 293
293void ComposeMail::setInReplyTo( const QString & messageId ) 294void ComposeMail::setInReplyTo( const QString & messageId )
294{ 295{
295 m_replyid = messageId; 296 m_replyid = messageId;
296} 297}
297 298
298void ComposeMail::setMessage( const QString & text ) 299void ComposeMail::setMessage( const QString & text )
299{ 300{
300 message->setText( text ); 301 message->setText( text );
301} 302}
302 303
303 304
304void ComposeMail::pickAddressTo() 305void ComposeMail::pickAddressTo()
305{ 306{
306 mPickLineEdit = toLine; 307 mPickLineEdit = toLine;
307 pickAddress( ); 308 pickAddress( );
308} 309}
309 310
310void ComposeMail::pickAddressCC() 311void ComposeMail::pickAddressCC()
311{ 312{
312 mPickLineEdit = ccLine; 313 mPickLineEdit = ccLine;
313 pickAddress( ); 314 pickAddress( );
314} 315}
315 316
316void ComposeMail::pickAddressBCC() 317void ComposeMail::pickAddressBCC()
317{ 318{
318 mPickLineEdit = bccLine; 319 mPickLineEdit = bccLine;
319 pickAddress( ); 320 pickAddress( );
320} 321}
321 322
322void ComposeMail::pickAddressReply() 323void ComposeMail::pickAddressReply()
323{ 324{
324 mPickLineEdit = replyLine; 325 mPickLineEdit = replyLine;
325 pickAddress( ); 326 pickAddress( );
326} 327}
327 328
328void ComposeMail::fillValues( int ) 329void ComposeMail::fillValues( int )
329{ 330{
330#if 0 331#if 0
331 SMTPaccount *smtp = smtpAccounts.at( current ); 332 SMTPaccount *smtp = smtpAccounts.at( current );
332 ccLine->clear(); 333 ccLine->clear();
333 if ( smtp->getUseCC() ) { 334 if ( smtp->getUseCC() ) {
334 ccLine->setText( smtp->getCC() ); 335 ccLine->setText( smtp->getCC() );
335 } 336 }
336 bccLine->clear(); 337 bccLine->clear();
337 if ( smtp->getUseBCC() ) { 338 if ( smtp->getUseBCC() ) {
338 bccLine->setText( smtp->getBCC() ); 339 bccLine->setText( smtp->getBCC() );
339 } 340 }
340 replyLine->clear(); 341 replyLine->clear();
341 if ( smtp->getUseReply() ) { 342 if ( smtp->getUseReply() ) {
342 replyLine->setText( smtp->getReply() ); 343 replyLine->setText( smtp->getReply() );
343 } 344 }
344 sigMultiLine->setText( smtp->getSignature() ); 345 sigMultiLine->setText( smtp->getSignature() );
345#endif 346#endif
346} 347}
347 348
348void ComposeMail::slotAdjustColumns() 349void ComposeMail::slotAdjustColumns()
349{ 350{
350 int currPage = tabWidget->currentPageIndex(); 351 int currPage = tabWidget->currentPageIndex();
351 352
352 tabWidget->showPage( attachTab ); 353 tabWidget->showPage( attachTab );
353 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 354 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
354 attList->setColumnWidth( 1, 80 ); 355 attList->setColumnWidth( 1, 80 );
355 356
356 tabWidget->setCurrentPage( currPage ); 357 tabWidget->setCurrentPage( currPage );
357} 358}
358 359
359void ComposeMail::addAttachment() 360void ComposeMail::addAttachment()
360{ 361{
361 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 362 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
362 if ( !lnk.isEmpty() ) { 363 if ( !lnk.isEmpty() ) {
363 Attachment *att = new Attachment( lnk ); 364 Attachment *att = new Attachment( lnk );
364 (void) new AttachViewItem( attList, att ); 365 (void) new AttachViewItem( attList, att );
365 } 366 }
366} 367}
367 368
368void ComposeMail::removeAttachment() 369void ComposeMail::removeAttachment()
369{ 370{
370 if ( !attList->currentItem() ) { 371 if ( !attList->currentItem() ) {
371 QMessageBox::information( this, i18n( "Error" ), 372 QMessageBox::information( this, i18n( "Error" ),
372 i18n( "<p>Please select a File.</p>" ), 373 i18n( "<p>Please select a File.</p>" ),
373 i18n( "Ok" ) ); 374 i18n( "Ok" ) );
374 } else { 375 } else {
375 attList->takeItem( attList->currentItem() ); 376 attList->takeItem( attList->currentItem() );
376 } 377 }
377} 378}
378 379
379void ComposeMail::accept() 380void ComposeMail::accept()
380{ 381{
381 if ( smtpAccountBox->count() == 0 ) { 382 if ( smtpAccountBox->count() == 0 ) {
382 383
383 reject(); 384 reject();
384 return; 385 return;
385 } 386 }
386 387
387 if (! checkBoxLater->isChecked() ) { 388 if (! checkBoxLater->isChecked() ) {
388 int yesno = QMessageBox::warning(0,i18n("Stop editing message"), 389 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
389 i18n("Send this message?"), 390 i18n("Send this message?"),
390 i18n("Yes"), 391 i18n("Yes"),
391 i18n("Cancel")); 392 i18n("Cancel"));
392 393
393 if (yesno == 1) { 394 if (yesno == 1) {
394 return; 395 return;
395 } 396 }
396 } 397 }
397#if 0 398#if 0
398 odebug << "Sending Mail with " 399 odebug << "Sending Mail with "
399 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 400 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
400#endif 401#endif
401 Opie::Core::OSmartPointer<Mail> mail=new Mail; 402 Opie::Core::OSmartPointer<Mail> mail=new Mail;
402 403
403 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 404 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
404 mail->setMail(fromBox->currentText()); 405 mail->setMail(fromBox->currentText());
405 406
406 if ( !toLine->text().isEmpty() ) { 407 if ( !toLine->text().isEmpty() ) {
407 mail->setTo( toLine->text() ); 408 mail->setTo( toLine->text() );
408 } else { 409 } else {
409 QMessageBox::warning(0,i18n("Sending mail"), 410 QMessageBox::warning(0,i18n("Sending mail"),
410 i18n("No Receiver spezified" ) ); 411 i18n("No Receiver spezified" ) );
411 return; 412 return;
412 } 413 }
413 414
414 mail->setName(senderNameEdit->text()); 415 mail->setName(senderNameEdit->text());
415 mail->setCC( ccLine->text() ); 416 mail->setCC( ccLine->text() );
416 mail->setBCC( bccLine->text() ); 417 mail->setBCC( bccLine->text() );
417 mail->setReply( replyLine->text() ); 418 mail->setReply( replyLine->text() );
418 mail->setSubject( subjectLine->text() ); 419 mail->setSubject( subjectLine->text() );
419 if (!m_replyid.isEmpty()) { 420 if (!m_replyid.isEmpty()) {
420 QStringList ids; 421 QStringList ids;
421 ids.append(m_replyid); 422 ids.append(m_replyid);
422 mail->setInreply(ids); 423 mail->setInreply(ids);
423 } 424 }
424 QString txt = message->text(); 425 QString txt = message->text();
425 if ( !sigMultiLine->text().isEmpty() ) { 426 if ( !sigMultiLine->text().isEmpty() ) {
426 txt.append( "\n--\n" ); 427 txt.append( "\n--\n" );
427 txt.append( sigMultiLine->text() ); 428 txt.append( sigMultiLine->text() );
428 } 429 }
429 mail->setMessage( txt ); 430 mail->setMessage( txt );
430 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 431 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
431 while ( it != 0 ) { 432 while ( it != 0 ) {
432 mail->addAttachment( it->getAttachment() ); 433 mail->addAttachment( it->getAttachment() );
433 it = (AttachViewItem *) it->nextSibling(); 434 it = (AttachViewItem *) it->nextSibling();
434 } 435 }
435 436
436 SMTPwrapper wrapper( smtp ); 437 SMTPwrapper wrapper( smtp );
437 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 438 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
438 setStatus( tr ("Mail sent")); 439 setStatus( tr ("Mail sent"));
439 else { 440 else {
440 setStatus( tr ("Error: Something went wrong. Nothing sent")); 441 setStatus( tr ("Error: Something went wrong. Nothing sent"));
441 return; 442 return;
442 } 443 }
443 444
444 445
445 QDialog::accept(); 446 QDialog::accept();
446} 447}
447 448
448void ComposeMail::reject() 449void ComposeMail::reject()
449{ 450{
450 //qDebug("ComposeMail::reject() "); 451 //qDebug("ComposeMail::reject() ");
451 int yesno = QMessageBox::warning(0,i18n("Store message?"), 452 int yesno = QMessageBox::warning(0,i18n("Store message?"),
452 i18n("Store message into drafts?\n"), 453 i18n("Store message into drafts?\n"),
453 i18n("Yes"), 454 i18n("Yes"),
454 i18n("No")); 455 i18n("No"));
455 456
456 //qDebug("button %d ", yesno); 457 //qDebug("button %d ", yesno);
457 if (yesno == 0) { 458 if (yesno == 0) {
458 if ( toLine->text().isEmpty() ) { 459 if ( toLine->text().isEmpty() ) {
459 QMessageBox::warning(0,i18n("Sending mail"), 460 QMessageBox::warning(0,i18n("Sending mail"),
460 i18n("No Receiver spezified" ) ); 461 i18n("No Receiver spezified" ) );
461 return; 462 return;
462 } 463 }
463 saveAsDraft(); 464 saveAsDraft();
464 } 465 }
465 if (yesno == 2) { 466 if (yesno == 2) {
466 qDebug("return "); 467 qDebug("return ");
467 return; 468 return;
468 } 469 }
469 QDialog::reject(); 470 QDialog::reject();
470} 471}
471 472
472ComposeMail::~ComposeMail() 473ComposeMail::~ComposeMail()
473{ 474{
474} 475}
475 476
476void ComposeMail::reEditMail(const RecMailP&current) 477void ComposeMail::reEditMail(const RecMailP&current)
477{ 478{
478 RecMailP data = current; 479 RecMailP data = current;
479 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 480 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
480 subjectLine->setText( data->getSubject()); 481 subjectLine->setText( data->getSubject());
481 toLine->setText(data->To().join(",")); 482 toLine->setText(data->To().join(","));
482 ccLine->setText(data->CC().join(",")); 483 ccLine->setText(data->CC().join(","));
483 bccLine->setText(data->Bcc().join(",")); 484 bccLine->setText(data->Bcc().join(","));
484 replyLine->setText(data->Replyto()); 485 replyLine->setText(data->Replyto());
485} 486}
486 487
487AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 488AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
488 : QListViewItem( parent ) 489 : QListViewItem( parent )
489{ 490{
490 attachment = att; 491 attachment = att;
491 if ( !attachment->getPixmap().isNull() ) 492 if ( !attachment->getPixmap().isNull() )
492 setPixmap( 0,attachment->getPixmap() ); 493 setPixmap( 0,attachment->getPixmap() );
493 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 494 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
494 setText( 1, QString::number( att->getSize() ) ); 495 setText( 1, QString::number( att->getSize() ) );
495} 496}
496 497