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