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