-rw-r--r-- | kmicromail/composemail.cpp | 14 |
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 | |||
@@ -26,66 +26,67 @@ | |||
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; |
52 | ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) | 52 | ComposeMail::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) |
@@ -231,86 +232,93 @@ void ComposeMail::pickAddress( ) | |||
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 |
258 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 259 | void 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 | ||
305 | void ComposeMail::setTo( const QString & to ) | 313 | void ComposeMail::setTo( const QString & to ) |
306 | { | 314 | { |
307 | toLine->setText( to ); | 315 | toLine->setText( to ); |
308 | } | 316 | } |
309 | 317 | ||
310 | void ComposeMail::setSubject( const QString & subject ) | 318 | void ComposeMail::setSubject( const QString & subject ) |
311 | { | 319 | { |
312 | subjectLine->setText( subject ); | 320 | subjectLine->setText( subject ); |
313 | } | 321 | } |
314 | 322 | ||
315 | void ComposeMail::setInReplyTo( const QString & messageId ) | 323 | void ComposeMail::setInReplyTo( const QString & messageId ) |
316 | { | 324 | { |