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, 11 insertions, 3 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index ed8a2ee..3231b45 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -10,98 +10,99 @@
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 <qiconset.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 <qmultilineedit.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.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 mPickLineEdit = 0; 56 mPickLineEdit = 0;
57 mEncoding = KOPrefs::instance()->mCurrentCodeName; 57 mEncoding = KOPrefs::instance()->mCurrentCodeName;
58 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 58 //managed from opiemail now
59 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 59 //connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
60 // this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
60 settings = sett; 61 settings = sett;
61 m_replyid = ""; 62 m_replyid = "";
62 if ( KOPrefs::instance()->mUseKapi) { 63 if ( KOPrefs::instance()->mUseKapi) {
63 KConfig config( locateLocal("config", "kabcrc") ); 64 KConfig config( locateLocal("config", "kabcrc") );
64 config.setGroup( "General" ); 65 config.setGroup( "General" );
65 QString whoami_uid = config.readEntry( "WhoAmI" ); 66 QString whoami_uid = config.readEntry( "WhoAmI" );
66 67
67 if ( whoami_uid.isEmpty() ) { 68 if ( whoami_uid.isEmpty() ) {
68 QMessageBox::information( 0, i18n( "Hint" ), 69 QMessageBox::information( 0, i18n( "Hint" ),
69 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 70 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
70 i18n( "Ok" ) ); 71 i18n( "Ok" ) );
71 72
72 73
73 fillSettings(); 74 fillSettings();
74 } else 75 } else
75 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 76 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
76 77
77 78
78#ifdef DESKTOP_VERSION 79#ifdef DESKTOP_VERSION
79 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 80 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
80 QStringList mails = con.emails(); 81 QStringList mails = con.emails();
81 QString defmail = con.preferredEmail(); 82 QString defmail = con.preferredEmail();
82 if ( mails.count() == 0) 83 if ( mails.count() == 0)
83 QMessageBox::information( 0, i18n( "Hint" ), 84 QMessageBox::information( 0, i18n( "Hint" ),
84 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 85 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
85 i18n( "Ok" ) ); 86 i18n( "Ok" ) );
86 if (defmail.length()!=0) { 87 if (defmail.length()!=0) {
87 fromBox->insertItem(defmail); 88 fromBox->insertItem(defmail);
88 } 89 }
89 QStringList::ConstIterator sit = mails.begin(); 90 QStringList::ConstIterator sit = mails.begin();
90 for (;sit!=mails.end();++sit) { 91 for (;sit!=mails.end();++sit) {
91 if ( (*sit)==defmail) 92 if ( (*sit)==defmail)
92 continue; 93 continue;
93 fromBox->insertItem((*sit)); 94 fromBox->insertItem((*sit));
94 } 95 }
95 senderNameEdit->setText(con.formattedName()); 96 senderNameEdit->setText(con.formattedName());
96#endif 97#endif
97 98
98 } else { 99 } else {
99 fillSettings(); 100 fillSettings();
100 } 101 }
101 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 102 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
102 103
103 attList->addColumn( i18n( "Name" ) ); 104 attList->addColumn( i18n( "Name" ) );
104 attList->addColumn( i18n( "Size" ) ); 105 attList->addColumn( i18n( "Size" ) );
105 QList<Account> accounts = settings->getAccounts(); 106 QList<Account> accounts = settings->getAccounts();
106 107
107 if ( QApplication::desktop()->width() < 320 ) 108 if ( QApplication::desktop()->width() < 320 )
@@ -215,118 +216,125 @@ void ComposeMail::saveAsDraft()
215} 216}
216void ComposeMail::clearStatus() 217void ComposeMail::clearStatus()
217{ 218{
218 topLevelWidget()->setCaption( i18n("Compose mail") ); 219 topLevelWidget()->setCaption( i18n("Compose mail") );
219} 220}
220void ComposeMail::setStatus( QString status ) 221void ComposeMail::setStatus( QString status )
221{ 222{
222 topLevelWidget()->setCaption( status ); 223 topLevelWidget()->setCaption( status );
223 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 224 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
224} 225}
225void ComposeMail::pickAddress( ) 226void ComposeMail::pickAddress( )
226{ 227{
227 228
228 QLineEdit *line = mPickLineEdit; 229 QLineEdit *line = mPickLineEdit;
229 if ( line == 0 ) 230 if ( line == 0 )
230 return; 231 return;
231#ifdef DESKTOP_VERSION 232#ifdef DESKTOP_VERSION
232 //qDebug(" ComposeMail::pickAddress "); 233 //qDebug(" ComposeMail::pickAddress ");
233 QString names ;//= AddressPicker::getNames(); 234 QString names ;//= AddressPicker::getNames();
234 235
235 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 236 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
236 uint i=0; 237 uint i=0;
237 for (i=0; i < list.count(); i++) { 238 for (i=0; i < list.count(); i++) {
238 if ( !list[i].preferredEmail().isEmpty()) { 239 if ( !list[i].preferredEmail().isEmpty()) {
239 if ( ! names.isEmpty() ) 240 if ( ! names.isEmpty() )
240 names+= ","; 241 names+= ",";
241 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 242 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
242 243
243 } 244 }
244 } 245 }
245 246
246 247
247 if ( line->text().isEmpty() ) { 248 if ( line->text().isEmpty() ) {
248 line->setText( names ); 249 line->setText( names );
249 } else if ( !names.isEmpty() ) { 250 } else if ( !names.isEmpty() ) {
250 line->setText( line->text() + ", " + names ); 251 line->setText( line->text() + ", " + names );
251 } 252 }
252#else 253#else
253 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 254 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
254 // the result should now arrive through method insertAttendees 255 // the result should now arrive through method insertAttendees
255#endif 256#endif
256} 257}
257//the map includes name/email pairs, that comes from Ka/Pi 258//the map includes name/email pairs, that comes from Ka/Pi
258void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 259void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
259{ 260{
260 //qDebug("ComposeMail::insertAttendees "); 261 //qDebug("ComposeMail::insertAttendees ");
261 raise(); 262 raise();
262 263
264 QString UID = uid;
265 if ( uid.left( 18 ) == (this->name() +QString("pick2")) ) {
266 mPickLineEdit = toLine;
267 UID = this->name();
268 subjectLine->setText( uid.mid( 18 ) );
269 }
270 //qDebug("ccc %s %s ", uid.latin1(), this->name());
263 if ( mPickLineEdit == 0 ) { //whoami received 271 if ( mPickLineEdit == 0 ) { //whoami received
264 QString defmail = uidList[0]; 272 QString defmail = uidList[0];
265 if ( emailList.count() == 0 ) 273 if ( emailList.count() == 0 )
266 QMessageBox::information( 0, i18n( "Hint" ), 274 QMessageBox::information( 0, i18n( "Hint" ),
267 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 275 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
268 i18n( "Ok" ) ); 276 i18n( "Ok" ) );
269 if (defmail.length()!=0) { 277 if (defmail.length()!=0) {
270 fromBox->insertItem(defmail); 278 fromBox->insertItem(defmail);
271 } 279 }
272 QStringList::ConstIterator sit = emailList.begin(); 280 QStringList::ConstIterator sit = emailList.begin();
273 int pref = 0; 281 int pref = 0;
274 for (;sit!=emailList.end();++sit) { 282 for (;sit!=emailList.end();++sit) {
275 if ( (*sit)==defmail) 283 if ( (*sit)==defmail)
276 continue; 284 continue;
277 fromBox->insertItem((*sit)); 285 fromBox->insertItem((*sit));
278 } 286 }
279 senderNameEdit->setText(nameList[0]); 287 senderNameEdit->setText(nameList[0]);
280 return; 288 return;
281 } 289 }
282 QString names ; 290 QString names ;
283 QLineEdit *line = mPickLineEdit; 291 QLineEdit *line = mPickLineEdit;
284 if (uid == this->name()) 292 if (UID == this->name())
285 { 293 {
286 for ( int i = 0; i < nameList.count(); i++) 294 for ( int i = 0; i < nameList.count(); i++)
287 { 295 {
288 QString _name = nameList[i]; 296 QString _name = nameList[i];
289 QString _email = emailList[i]; 297 QString _email = emailList[i];
290 QString _uid = uidList[i]; 298 QString _uid = uidList[i];
291 if ( ! _email.isEmpty() ) { 299 if ( ! _email.isEmpty() ) {
292 if ( ! names.isEmpty() ) 300 if ( ! names.isEmpty() )
293 names+= ","; 301 names+= ",";
294 names+= "\""+_name +"\"<" +_email +">"; 302 names+= "\""+_name +"\"<" +_email +">";
295 } 303 }
296 } 304 }
297 } 305 }
298 if ( line->text().isEmpty() ) { 306 if ( line->text().isEmpty() ) {
299 line->setText( names ); 307 line->setText( names );
300 } else if ( !names.isEmpty() ) { 308 } else if ( !names.isEmpty() ) {
301 line->setText( line->text() + ", " + names ); 309 line->setText( line->text() + ", " + names );
302 } 310 }
303} 311}
304 312
305void ComposeMail::setTo( const QString & to ) 313void ComposeMail::setTo( const QString & to )
306{ 314{
307 toLine->setText( to ); 315 toLine->setText( to );
308} 316}
309 317
310void ComposeMail::setSubject( const QString & subject ) 318void ComposeMail::setSubject( const QString & subject )
311{ 319{
312 subjectLine->setText( subject ); 320 subjectLine->setText( subject );
313} 321}
314 322
315void ComposeMail::setInReplyTo( const QString & messageId ) 323void ComposeMail::setInReplyTo( const QString & messageId )
316{ 324{
317 m_replyid = messageId; 325 m_replyid = messageId;
318} 326}
319 327
320void ComposeMail::setMessage( const QString & text ) 328void ComposeMail::setMessage( const QString & text )
321{ 329{
322 message->setText( text ); 330 message->setText( text );
323} 331}
324 332
325 333
326void ComposeMail::pickAddressTo() 334void ComposeMail::pickAddressTo()
327{ 335{
328 mPickLineEdit = toLine; 336 mPickLineEdit = toLine;
329 pickAddress( ); 337 pickAddress( );
330} 338}
331 339
332void ComposeMail::pickAddressCC() 340void ComposeMail::pickAddressCC()