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