-rw-r--r-- | kmicromail/composemail.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 01dd406..9efa932 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -20,90 +20,92 @@ | |||
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qcheckbox.h> | 21 | #include <qcheckbox.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qmultilineedit.h> | 25 | #include <qmultilineedit.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <kabc/addresseedialog.h> | 29 | #include <kabc/addresseedialog.h> |
30 | #include <kabc/stdaddressbook.h> | 30 | #include <kabc/stdaddressbook.h> |
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #ifdef DESKTOP_VERSION | 32 | #ifdef DESKTOP_VERSION |
33 | #include <kabc/addresseedialog.h> | 33 | #include <kabc/addresseedialog.h> |
34 | #else //DESKTOP_VERSION | 34 | #else //DESKTOP_VERSION |
35 | #include <libkdepim/externalapphandler.h> | 35 | #include <libkdepim/externalapphandler.h> |
36 | #endif //DESKTOP_VERSION | 36 | #endif //DESKTOP_VERSION |
37 | 37 | ||
38 | 38 | ||
39 | //using namespace Opie::Core; | 39 | //using namespace Opie::Core; |
40 | //using namespace Opie::Ui; | 40 | //using namespace Opie::Ui; |
41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) | 41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) |
42 | : ComposeMailUI( parent, name, modal ) | 42 | : ComposeMailUI( parent, name, modal ) |
43 | { | 43 | { |
44 | 44 | ||
45 | mPickLineEdit = 0; | 45 | mPickLineEdit = 0; |
46 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 46 | 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&))); | 47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
48 | settings = s; | 48 | settings = s; |
49 | m_replyid = ""; | 49 | m_replyid = ""; |
50 | KConfig config( locateLocal("config", "kabcrc") ); | 50 | KConfig config( locateLocal("config", "kabcrc") ); |
51 | config.setGroup( "General" ); | 51 | config.setGroup( "General" ); |
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 52 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
53 | |||
53 | if ( whoami_uid.isEmpty() ) { | 54 | if ( whoami_uid.isEmpty() ) { |
54 | QMessageBox::information( 0, tr( "Hint" ), | 55 | QMessageBox::information( 0, tr( "Hint" ), |
55 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 56 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
56 | tr( "Ok" ) ); | 57 | tr( "Ok" ) ); |
57 | 58 | ||
58 | } else | 59 | } else |
59 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 60 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
61 | |||
62 | |||
60 | #ifdef DESKTOP_VERSION | 63 | #ifdef DESKTOP_VERSION |
61 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 64 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
62 | QStringList mails = con.emails(); | 65 | QStringList mails = con.emails(); |
63 | QString defmail = con.preferredEmail(); | 66 | QString defmail = con.preferredEmail(); |
64 | if ( mails.count() == 0) | 67 | if ( mails.count() == 0) |
65 | QMessageBox::information( 0, tr( "Hint" ), | 68 | QMessageBox::information( 0, tr( "Hint" ), |
66 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 69 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
67 | tr( "Ok" ) ); | 70 | tr( "Ok" ) ); |
68 | if (defmail.length()!=0) { | 71 | if (defmail.length()!=0) { |
69 | fromBox->insertItem(defmail); | 72 | fromBox->insertItem(defmail); |
70 | } | 73 | } |
71 | QStringList::ConstIterator sit = mails.begin(); | 74 | QStringList::ConstIterator sit = mails.begin(); |
72 | for (;sit!=mails.end();++sit) { | 75 | for (;sit!=mails.end();++sit) { |
73 | if ( (*sit)==defmail) | 76 | if ( (*sit)==defmail) |
74 | continue; | 77 | continue; |
75 | fromBox->insertItem((*sit)); | 78 | fromBox->insertItem((*sit)); |
76 | } | 79 | } |
77 | senderNameEdit->setText(con.formattedName()); | 80 | senderNameEdit->setText(con.formattedName()); |
78 | #endif | 81 | #endif |
79 | Config cfg( "mail" ); | 82 | Config cfg( "mail" ); |
80 | cfg.setGroup( "Compose" ); | 83 | cfg.setGroup( "Compose" ); |
81 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 84 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
82 | 85 | ||
83 | attList->addColumn( tr( "Name" ) ); | 86 | attList->addColumn( tr( "Name" ) ); |
84 | attList->addColumn( tr( "Size" ) ); | 87 | attList->addColumn( tr( "Size" ) ); |
85 | |||
86 | QList<Account> accounts = settings->getAccounts(); | 88 | QList<Account> accounts = settings->getAccounts(); |
87 | 89 | ||
88 | Account *it; | 90 | Account *it; |
89 | for ( it = accounts.first(); it; it = accounts.next() ) { | 91 | for ( it = accounts.first(); it; it = accounts.next() ) { |
90 | if ( it->getType()==MAILLIB::A_SMTP ) { | 92 | if ( it->getType()==MAILLIB::A_SMTP ) { |
91 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 93 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
92 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 94 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
93 | smtpAccounts.append( smtp ); | 95 | smtpAccounts.append( smtp ); |
94 | } | 96 | } |
95 | } | 97 | } |
96 | if ( smtpAccounts.count() > 0 ) { | 98 | if ( smtpAccounts.count() > 0 ) { |
97 | fillValues( smtpAccountBox->currentItem() ); | 99 | fillValues( smtpAccountBox->currentItem() ); |
98 | } else { | 100 | } else { |
99 | QMessageBox::information( 0, tr( "Problem" ), | 101 | QMessageBox::information( 0, tr( "Problem" ), |
100 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | 102 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), |
101 | tr( "Ok" ) ); | 103 | tr( "Ok" ) ); |
102 | return; | 104 | return; |
103 | } | 105 | } |
104 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 106 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
105 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 107 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
106 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 108 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
107 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 109 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
108 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 110 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
109 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 111 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
@@ -176,53 +178,52 @@ void ComposeMail::pickAddress( ) | |||
176 | uint i=0; | 178 | uint i=0; |
177 | for (i=0; i < list.count(); i++) { | 179 | for (i=0; i < list.count(); i++) { |
178 | if ( !list[i].preferredEmail().isEmpty()) { | 180 | if ( !list[i].preferredEmail().isEmpty()) { |
179 | if ( ! names.isEmpty() ) | 181 | if ( ! names.isEmpty() ) |
180 | names+= ","; | 182 | names+= ","; |
181 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 183 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
182 | 184 | ||
183 | } | 185 | } |
184 | } | 186 | } |
185 | 187 | ||
186 | 188 | ||
187 | if ( line->text().isEmpty() ) { | 189 | if ( line->text().isEmpty() ) { |
188 | line->setText( names ); | 190 | line->setText( names ); |
189 | } else if ( !names.isEmpty() ) { | 191 | } else if ( !names.isEmpty() ) { |
190 | line->setText( line->text() + ", " + names ); | 192 | line->setText( line->text() + ", " + names ); |
191 | } | 193 | } |
192 | #else | 194 | #else |
193 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 195 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
194 | // the result should now arrive through method insertAttendees | 196 | // the result should now arrive through method insertAttendees |
195 | #endif | 197 | #endif |
196 | } | 198 | } |
197 | //the map includes name/email pairs, that comes from Ka/Pi | 199 | //the map includes name/email pairs, that comes from Ka/Pi |
198 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 200 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
199 | { | 201 | { |
200 | qDebug("ComposeMail::insertAttendees "); | 202 | //qDebug("ComposeMail::insertAttendees "); |
201 | raise(); | 203 | raise(); |
202 | 204 | ||
203 | if ( mPickLineEdit == 0 ) { //whoami received | 205 | if ( mPickLineEdit == 0 ) { //whoami received |
204 | qDebug("returnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn "); | ||
205 | QString defmail = uidList[0]; | 206 | QString defmail = uidList[0]; |
206 | if ( emailList.count() == 0 ) | 207 | if ( emailList.count() == 0 ) |
207 | QMessageBox::information( 0, tr( "Hint" ), | 208 | QMessageBox::information( 0, tr( "Hint" ), |
208 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 209 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
209 | tr( "Ok" ) ); | 210 | tr( "Ok" ) ); |
210 | if (defmail.length()!=0) { | 211 | if (defmail.length()!=0) { |
211 | fromBox->insertItem(defmail); | 212 | fromBox->insertItem(defmail); |
212 | } | 213 | } |
213 | QStringList::ConstIterator sit = emailList.begin(); | 214 | QStringList::ConstIterator sit = emailList.begin(); |
214 | int pref = 0; | 215 | int pref = 0; |
215 | for (;sit!=emailList.end();++sit) { | 216 | for (;sit!=emailList.end();++sit) { |
216 | if ( (*sit)==defmail) | 217 | if ( (*sit)==defmail) |
217 | continue; | 218 | continue; |
218 | fromBox->insertItem((*sit)); | 219 | fromBox->insertItem((*sit)); |
219 | } | 220 | } |
220 | senderNameEdit->setText(nameList[0]); | 221 | senderNameEdit->setText(nameList[0]); |
221 | return; | 222 | return; |
222 | } | 223 | } |
223 | QString names ; | 224 | QString names ; |
224 | QLineEdit *line = mPickLineEdit; | 225 | QLineEdit *line = mPickLineEdit; |
225 | if (uid == this->name()) | 226 | if (uid == this->name()) |
226 | { | 227 | { |
227 | for ( int i = 0; i < nameList.count(); i++) | 228 | for ( int i = 0; i < nameList.count(); i++) |
228 | { | 229 | { |