-rw-r--r-- | kmicromail/composemail.cpp | 99 |
1 files changed, 88 insertions, 11 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 654cfc0..5f446fa 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -1,333 +1,410 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | #include "composemail.h" | 3 | #include "composemail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/smtpwrapper.h> | 5 | #include <libmailwrapper/smtpwrapper.h> |
6 | #include <libmailwrapper/storemail.h> | 6 | #include <libmailwrapper/storemail.h> |
7 | #include <libmailwrapper/abstractmail.h> | 7 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/ofiledialog.h> | 11 | //#include <opie2/ofiledialog.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | #include <kfiledialog.h> | 13 | #include <kfiledialog.h> |
14 | //#include <qpe/resource.h> | 14 | //#include <qpe/resource.h> |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/global.h> | 16 | #include <qpe/global.h> |
17 | //#include <qpe/contact.h> | 17 | //#include <qpe/contact.h> |
18 | 18 | ||
19 | 19 | ||
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 | 32 | #ifdef DESKTOP_VERSION | |
33 | #include <kabc/addresseedialog.h> | ||
34 | #else //DESKTOP_VERSION | ||
35 | #include <libkdepim/externalapphandler.h> | ||
36 | #endif //DESKTOP_VERSION | ||
33 | 37 | ||
34 | 38 | ||
35 | //using namespace Opie::Core; | 39 | //using namespace Opie::Core; |
36 | //using namespace Opie::Ui; | 40 | //using namespace Opie::Ui; |
37 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
38 | : ComposeMailUI( parent, name, modal, flags ) | 42 | : ComposeMailUI( parent, name, modal, flags ) |
39 | { | 43 | { |
40 | 44 | ||
45 | mPickLineEdit = 0; | ||
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&))); | ||
41 | settings = s; | 48 | settings = s; |
42 | m_replyid = ""; | 49 | m_replyid = ""; |
50 | KConfig config( locateLocal("config", "kabcrc") ); | ||
51 | config.setGroup( "General" ); | ||
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | ||
53 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | ||
54 | #ifdef DESKTOP_VERSION | ||
43 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 55 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
44 | QStringList mails = con.emails(); | 56 | QStringList mails = con.emails(); |
45 | QString defmail = con.preferredEmail(); | 57 | QString defmail = con.preferredEmail(); |
46 | if ( mails.count() == 0) | 58 | if ( mails.count() == 0) |
47 | QMessageBox::information( 0, tr( "Hint" ), | 59 | QMessageBox::information( 0, tr( "Hint" ), |
48 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 60 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
49 | tr( "Ok" ) ); | 61 | tr( "Ok" ) ); |
50 | if (defmail.length()!=0) { | 62 | if (defmail.length()!=0) { |
51 | fromBox->insertItem(defmail); | 63 | fromBox->insertItem(defmail); |
52 | } | 64 | } |
53 | QStringList::ConstIterator sit = mails.begin(); | 65 | QStringList::ConstIterator sit = mails.begin(); |
54 | for (;sit!=mails.end();++sit) { | 66 | for (;sit!=mails.end();++sit) { |
55 | if ( (*sit)==defmail) | 67 | if ( (*sit)==defmail) |
56 | continue; | 68 | continue; |
57 | fromBox->insertItem((*sit)); | 69 | fromBox->insertItem((*sit)); |
58 | } | 70 | } |
59 | senderNameEdit->setText(con.formattedName()); | 71 | senderNameEdit->setText(con.formattedName()); |
72 | #endif | ||
60 | Config cfg( "mail" ); | 73 | Config cfg( "mail" ); |
61 | cfg.setGroup( "Compose" ); | 74 | cfg.setGroup( "Compose" ); |
62 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 75 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
63 | 76 | ||
64 | attList->addColumn( tr( "Name" ) ); | 77 | attList->addColumn( tr( "Name" ) ); |
65 | attList->addColumn( tr( "Size" ) ); | 78 | attList->addColumn( tr( "Size" ) ); |
66 | 79 | ||
67 | QList<Account> accounts = settings->getAccounts(); | 80 | QList<Account> accounts = settings->getAccounts(); |
68 | 81 | ||
69 | Account *it; | 82 | Account *it; |
70 | for ( it = accounts.first(); it; it = accounts.next() ) { | 83 | for ( it = accounts.first(); it; it = accounts.next() ) { |
71 | if ( it->getType()==MAILLIB::A_SMTP ) { | 84 | if ( it->getType()==MAILLIB::A_SMTP ) { |
72 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 85 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
73 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 86 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
74 | smtpAccounts.append( smtp ); | 87 | smtpAccounts.append( smtp ); |
75 | } | 88 | } |
76 | } | 89 | } |
77 | if ( smtpAccounts.count() > 0 ) { | 90 | if ( smtpAccounts.count() > 0 ) { |
78 | fillValues( smtpAccountBox->currentItem() ); | 91 | fillValues( smtpAccountBox->currentItem() ); |
79 | } else { | 92 | } else { |
80 | QMessageBox::information( 0, tr( "Problem" ), | 93 | QMessageBox::information( 0, tr( "Problem" ), |
81 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | 94 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), |
82 | tr( "Ok" ) ); | 95 | tr( "Ok" ) ); |
83 | return; | 96 | return; |
84 | } | 97 | } |
85 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 98 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
86 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 99 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
87 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 100 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
88 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 101 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
89 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 102 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
90 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 103 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
91 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 104 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
92 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 105 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
93 | mMail = 0; | 106 | mMail = 0; |
94 | warnAttach = true; | 107 | warnAttach = true; |
95 | 108 | ||
96 | } | 109 | } |
110 | |||
111 | |||
112 | |||
97 | void ComposeMail::saveAsDraft() | 113 | void ComposeMail::saveAsDraft() |
98 | { | 114 | { |
99 | 115 | ||
100 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 116 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
101 | mail->setMail(fromBox->currentText()); | 117 | mail->setMail(fromBox->currentText()); |
102 | mail->setTo( toLine->text() ); | 118 | mail->setTo( toLine->text() ); |
103 | mail->setName(senderNameEdit->text()); | 119 | mail->setName(senderNameEdit->text()); |
104 | mail->setCC( ccLine->text() ); | 120 | mail->setCC( ccLine->text() ); |
105 | mail->setBCC( bccLine->text() ); | 121 | mail->setBCC( bccLine->text() ); |
106 | mail->setReply( replyLine->text() ); | 122 | mail->setReply( replyLine->text() ); |
107 | mail->setSubject( subjectLine->text() ); | 123 | mail->setSubject( subjectLine->text() ); |
108 | if (!m_replyid.isEmpty()) { | 124 | if (!m_replyid.isEmpty()) { |
109 | QStringList ids; | 125 | QStringList ids; |
110 | ids.append(m_replyid); | 126 | ids.append(m_replyid); |
111 | mail->setInreply(ids); | 127 | mail->setInreply(ids); |
112 | } | 128 | } |
113 | QString txt = message->text(); | 129 | QString txt = message->text(); |
114 | if ( !sigMultiLine->text().isEmpty() ) { | 130 | if ( !sigMultiLine->text().isEmpty() ) { |
115 | txt.append( "\n--\n" ); | 131 | txt.append( "\n--\n" ); |
116 | txt.append( sigMultiLine->text() ); | 132 | txt.append( sigMultiLine->text() ); |
117 | } | 133 | } |
118 | mail->setMessage( txt ); | 134 | mail->setMessage( txt ); |
119 | 135 | ||
120 | /* only use the default drafts folder name! */ | 136 | /* only use the default drafts folder name! */ |
121 | Storemail wrapper(AbstractMail::draftFolder()); | 137 | Storemail wrapper(AbstractMail::draftFolder()); |
122 | wrapper.storeMail(mail); | 138 | wrapper.storeMail(mail); |
123 | 139 | ||
124 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 140 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
125 | /* attachments we will ignore! */ | 141 | /* attachments we will ignore! */ |
126 | if ( it != 0 ) { | 142 | if ( it != 0 ) { |
127 | if ( warnAttach ) | 143 | if ( warnAttach ) |
128 | QMessageBox::warning(0,tr("Store message"), | 144 | QMessageBox::warning(0,tr("Store message"), |
129 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 145 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
130 | warnAttach = false; | 146 | warnAttach = false; |
131 | } | 147 | } |
132 | setStatus( tr("Mail saved as draft!") ); | 148 | setStatus( tr("Mail saved as draft!") ); |
133 | } | 149 | } |
134 | void ComposeMail::clearStatus() | 150 | void ComposeMail::clearStatus() |
135 | { | 151 | { |
136 | topLevelWidget()->setCaption( tr("Compose mail") ); | 152 | topLevelWidget()->setCaption( tr("Compose mail") ); |
137 | } | 153 | } |
138 | void ComposeMail::setStatus( QString status ) | 154 | void ComposeMail::setStatus( QString status ) |
139 | { | 155 | { |
140 | topLevelWidget()->setCaption( status ); | 156 | topLevelWidget()->setCaption( status ); |
141 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 157 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
142 | } | 158 | } |
143 | void ComposeMail::pickAddress( QLineEdit *line ) | 159 | void ComposeMail::pickAddress( ) |
144 | { | 160 | { |
161 | |||
162 | QLineEdit *line = mPickLineEdit; | ||
163 | if ( line == 0 ) | ||
164 | return; | ||
165 | #ifdef DESKTOP_VERSION | ||
145 | //qDebug(" ComposeMail::pickAddress "); | 166 | //qDebug(" ComposeMail::pickAddress "); |
146 | QString names ;//= AddressPicker::getNames(); | 167 | QString names ;//= AddressPicker::getNames(); |
147 | 168 | ||
148 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 169 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
149 | uint i=0; | 170 | uint i=0; |
150 | for (i=0; i < list.count(); i++) { | 171 | for (i=0; i < list.count(); i++) { |
151 | if ( !list[i].preferredEmail().isEmpty()) { | 172 | if ( !list[i].preferredEmail().isEmpty()) { |
152 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 173 | if ( ! names.isEmpty() ) |
153 | if ( i < list.count() -1 ) | ||
154 | names+= ","; | 174 | names+= ","; |
175 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | ||
176 | |||
155 | } | 177 | } |
156 | } | 178 | } |
157 | 179 | ||
158 | 180 | ||
159 | if ( line->text().isEmpty() ) { | 181 | if ( line->text().isEmpty() ) { |
160 | line->setText( names ); | 182 | line->setText( names ); |
161 | } else if ( !names.isEmpty() ) { | 183 | } else if ( !names.isEmpty() ) { |
162 | line->setText( line->text() + ", " + names ); | 184 | line->setText( line->text() + ", " + names ); |
163 | } | 185 | } |
186 | #else | ||
187 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | ||
188 | // the result should now arrive through method insertAttendees | ||
189 | #endif | ||
190 | } | ||
191 | //the map includes name/email pairs, that comes from Ka/Pi | ||
192 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | ||
193 | { | ||
194 | qDebug("ComposeMail::insertAttendees "); | ||
195 | raise(); | ||
196 | |||
197 | if ( mPickLineEdit == 0 ) { //whoami received | ||
198 | |||
199 | QString defmail = uidList[0]; | ||
200 | if ( emailList.count() == 0 ) | ||
201 | QMessageBox::information( 0, tr( "Hint" ), | ||
202 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | ||
203 | tr( "Ok" ) ); | ||
204 | if (defmail.length()!=0) { | ||
205 | fromBox->insertItem(defmail); | ||
206 | } | ||
207 | QStringList::ConstIterator sit = emailList.begin(); | ||
208 | int pref = 0; | ||
209 | for (;sit!=emailList.end();++sit) { | ||
210 | if ( (*sit)==defmail) | ||
211 | continue; | ||
212 | fromBox->insertItem((*sit)); | ||
213 | } | ||
214 | senderNameEdit->setText(nameList[0]); | ||
215 | return; | ||
216 | } | ||
217 | QString names ; | ||
218 | QLineEdit *line = mPickLineEdit; | ||
219 | if (uid == this->name()) | ||
220 | { | ||
221 | for ( int i = 0; i < nameList.count(); i++) | ||
222 | { | ||
223 | QString _name = nameList[i]; | ||
224 | QString _email = emailList[i]; | ||
225 | QString _uid = uidList[i]; | ||
226 | if ( ! _email.isEmpty() ) { | ||
227 | if ( ! names.isEmpty() ) | ||
228 | names+= ","; | ||
229 | names+= "\""+_name +"\"<" +_email +">"; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | if ( line->text().isEmpty() ) { | ||
234 | line->setText( names ); | ||
235 | } else if ( !names.isEmpty() ) { | ||
236 | line->setText( line->text() + ", " + names ); | ||
237 | } | ||
164 | } | 238 | } |
165 | |||
166 | 239 | ||
167 | void ComposeMail::setTo( const QString & to ) | 240 | void ComposeMail::setTo( const QString & to ) |
168 | { | 241 | { |
169 | toLine->setText( to ); | 242 | toLine->setText( to ); |
170 | } | 243 | } |
171 | 244 | ||
172 | void ComposeMail::setSubject( const QString & subject ) | 245 | void ComposeMail::setSubject( const QString & subject ) |
173 | { | 246 | { |
174 | subjectLine->setText( subject ); | 247 | subjectLine->setText( subject ); |
175 | } | 248 | } |
176 | 249 | ||
177 | void ComposeMail::setInReplyTo( const QString & messageId ) | 250 | void ComposeMail::setInReplyTo( const QString & messageId ) |
178 | { | 251 | { |
179 | m_replyid = messageId; | 252 | m_replyid = messageId; |
180 | } | 253 | } |
181 | 254 | ||
182 | void ComposeMail::setMessage( const QString & text ) | 255 | void ComposeMail::setMessage( const QString & text ) |
183 | { | 256 | { |
184 | message->setText( text ); | 257 | message->setText( text ); |
185 | } | 258 | } |
186 | 259 | ||
187 | 260 | ||
188 | void ComposeMail::pickAddressTo() | 261 | void ComposeMail::pickAddressTo() |
189 | { | 262 | { |
190 | pickAddress( toLine ); | 263 | mPickLineEdit = toLine; |
264 | pickAddress( ); | ||
191 | } | 265 | } |
192 | 266 | ||
193 | void ComposeMail::pickAddressCC() | 267 | void ComposeMail::pickAddressCC() |
194 | { | 268 | { |
195 | pickAddress( ccLine ); | 269 | mPickLineEdit = ccLine; |
270 | pickAddress( ); | ||
196 | } | 271 | } |
197 | 272 | ||
198 | void ComposeMail::pickAddressBCC() | 273 | void ComposeMail::pickAddressBCC() |
199 | { | 274 | { |
200 | pickAddress( bccLine ); | 275 | mPickLineEdit = bccLine; |
276 | pickAddress( ); | ||
201 | } | 277 | } |
202 | 278 | ||
203 | void ComposeMail::pickAddressReply() | 279 | void ComposeMail::pickAddressReply() |
204 | { | 280 | { |
205 | pickAddress( replyLine ); | 281 | mPickLineEdit = replyLine; |
282 | pickAddress( ); | ||
206 | } | 283 | } |
207 | 284 | ||
208 | void ComposeMail::fillValues( int ) | 285 | void ComposeMail::fillValues( int ) |
209 | { | 286 | { |
210 | #if 0 | 287 | #if 0 |
211 | SMTPaccount *smtp = smtpAccounts.at( current ); | 288 | SMTPaccount *smtp = smtpAccounts.at( current ); |
212 | ccLine->clear(); | 289 | ccLine->clear(); |
213 | if ( smtp->getUseCC() ) { | 290 | if ( smtp->getUseCC() ) { |
214 | ccLine->setText( smtp->getCC() ); | 291 | ccLine->setText( smtp->getCC() ); |
215 | } | 292 | } |
216 | bccLine->clear(); | 293 | bccLine->clear(); |
217 | if ( smtp->getUseBCC() ) { | 294 | if ( smtp->getUseBCC() ) { |
218 | bccLine->setText( smtp->getBCC() ); | 295 | bccLine->setText( smtp->getBCC() ); |
219 | } | 296 | } |
220 | replyLine->clear(); | 297 | replyLine->clear(); |
221 | if ( smtp->getUseReply() ) { | 298 | if ( smtp->getUseReply() ) { |
222 | replyLine->setText( smtp->getReply() ); | 299 | replyLine->setText( smtp->getReply() ); |
223 | } | 300 | } |
224 | sigMultiLine->setText( smtp->getSignature() ); | 301 | sigMultiLine->setText( smtp->getSignature() ); |
225 | #endif | 302 | #endif |
226 | } | 303 | } |
227 | 304 | ||
228 | void ComposeMail::slotAdjustColumns() | 305 | void ComposeMail::slotAdjustColumns() |
229 | { | 306 | { |
230 | int currPage = tabWidget->currentPageIndex(); | 307 | int currPage = tabWidget->currentPageIndex(); |
231 | 308 | ||
232 | tabWidget->showPage( attachTab ); | 309 | tabWidget->showPage( attachTab ); |
233 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 310 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
234 | attList->setColumnWidth( 1, 80 ); | 311 | attList->setColumnWidth( 1, 80 ); |
235 | 312 | ||
236 | tabWidget->setCurrentPage( currPage ); | 313 | tabWidget->setCurrentPage( currPage ); |
237 | } | 314 | } |
238 | 315 | ||
239 | void ComposeMail::addAttachment() | 316 | void ComposeMail::addAttachment() |
240 | { | 317 | { |
241 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 318 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
242 | if ( !lnk.isEmpty() ) { | 319 | if ( !lnk.isEmpty() ) { |
243 | Attachment *att = new Attachment( lnk ); | 320 | Attachment *att = new Attachment( lnk ); |
244 | (void) new AttachViewItem( attList, att ); | 321 | (void) new AttachViewItem( attList, att ); |
245 | } | 322 | } |
246 | } | 323 | } |
247 | 324 | ||
248 | void ComposeMail::removeAttachment() | 325 | void ComposeMail::removeAttachment() |
249 | { | 326 | { |
250 | if ( !attList->currentItem() ) { | 327 | if ( !attList->currentItem() ) { |
251 | QMessageBox::information( this, tr( "Error" ), | 328 | QMessageBox::information( this, tr( "Error" ), |
252 | tr( "<p>Please select a File.</p>" ), | 329 | tr( "<p>Please select a File.</p>" ), |
253 | tr( "Ok" ) ); | 330 | tr( "Ok" ) ); |
254 | } else { | 331 | } else { |
255 | attList->takeItem( attList->currentItem() ); | 332 | attList->takeItem( attList->currentItem() ); |
256 | } | 333 | } |
257 | } | 334 | } |
258 | 335 | ||
259 | void ComposeMail::accept() | 336 | void ComposeMail::accept() |
260 | { | 337 | { |
261 | if ( smtpAccountBox->count() == 0 ) { | 338 | if ( smtpAccountBox->count() == 0 ) { |
262 | 339 | ||
263 | reject(); | 340 | reject(); |
264 | return; | 341 | return; |
265 | } | 342 | } |
266 | 343 | ||
267 | if (! checkBoxLater->isChecked() ) { | 344 | if (! checkBoxLater->isChecked() ) { |
268 | int yesno = QMessageBox::warning(0,tr("Stop editing message"), | 345 | int yesno = QMessageBox::warning(0,tr("Stop editing message"), |
269 | tr("Send this message?"), | 346 | tr("Send this message?"), |
270 | tr("Yes"), | 347 | tr("Yes"), |
271 | tr("Cancel")); | 348 | tr("Cancel")); |
272 | 349 | ||
273 | if (yesno == 1) { | 350 | if (yesno == 1) { |
274 | return; | 351 | return; |
275 | } | 352 | } |
276 | } | 353 | } |
277 | #if 0 | 354 | #if 0 |
278 | odebug << "Sending Mail with " | 355 | odebug << "Sending Mail with " |
279 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; | 356 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; |
280 | #endif | 357 | #endif |
281 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 358 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
282 | 359 | ||
283 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 360 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
284 | mail->setMail(fromBox->currentText()); | 361 | mail->setMail(fromBox->currentText()); |
285 | 362 | ||
286 | if ( !toLine->text().isEmpty() ) { | 363 | if ( !toLine->text().isEmpty() ) { |
287 | mail->setTo( toLine->text() ); | 364 | mail->setTo( toLine->text() ); |
288 | } else { | 365 | } else { |
289 | QMessageBox::warning(0,tr("Sending mail"), | 366 | QMessageBox::warning(0,tr("Sending mail"), |
290 | tr("No Receiver spezified" ) ); | 367 | tr("No Receiver spezified" ) ); |
291 | return; | 368 | return; |
292 | } | 369 | } |
293 | 370 | ||
294 | mail->setName(senderNameEdit->text()); | 371 | mail->setName(senderNameEdit->text()); |
295 | mail->setCC( ccLine->text() ); | 372 | mail->setCC( ccLine->text() ); |
296 | mail->setBCC( bccLine->text() ); | 373 | mail->setBCC( bccLine->text() ); |
297 | mail->setReply( replyLine->text() ); | 374 | mail->setReply( replyLine->text() ); |
298 | mail->setSubject( subjectLine->text() ); | 375 | mail->setSubject( subjectLine->text() ); |
299 | if (!m_replyid.isEmpty()) { | 376 | if (!m_replyid.isEmpty()) { |
300 | QStringList ids; | 377 | QStringList ids; |
301 | ids.append(m_replyid); | 378 | ids.append(m_replyid); |
302 | mail->setInreply(ids); | 379 | mail->setInreply(ids); |
303 | } | 380 | } |
304 | QString txt = message->text(); | 381 | QString txt = message->text(); |
305 | if ( !sigMultiLine->text().isEmpty() ) { | 382 | if ( !sigMultiLine->text().isEmpty() ) { |
306 | txt.append( "\n--\n" ); | 383 | txt.append( "\n--\n" ); |
307 | txt.append( sigMultiLine->text() ); | 384 | txt.append( sigMultiLine->text() ); |
308 | } | 385 | } |
309 | mail->setMessage( txt ); | 386 | mail->setMessage( txt ); |
310 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 387 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
311 | while ( it != 0 ) { | 388 | while ( it != 0 ) { |
312 | mail->addAttachment( it->getAttachment() ); | 389 | mail->addAttachment( it->getAttachment() ); |
313 | it = (AttachViewItem *) it->nextSibling(); | 390 | it = (AttachViewItem *) it->nextSibling(); |
314 | } | 391 | } |
315 | 392 | ||
316 | SMTPwrapper wrapper( smtp ); | 393 | SMTPwrapper wrapper( smtp ); |
317 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) | 394 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) |
318 | setStatus( tr ("Mail sent")); | 395 | setStatus( tr ("Mail sent")); |
319 | else { | 396 | else { |
320 | setStatus( tr ("Error: Something went wrong. Nothing sent")); | 397 | setStatus( tr ("Error: Something went wrong. Nothing sent")); |
321 | return; | 398 | return; |
322 | } | 399 | } |
323 | 400 | ||
324 | 401 | ||
325 | QDialog::accept(); | 402 | QDialog::accept(); |
326 | } | 403 | } |
327 | 404 | ||
328 | void ComposeMail::reject() | 405 | void ComposeMail::reject() |
329 | { | 406 | { |
330 | //qDebug("ComposeMail::reject() "); | 407 | //qDebug("ComposeMail::reject() "); |
331 | int yesno = QMessageBox::warning(0,tr("Store message?"), | 408 | int yesno = QMessageBox::warning(0,tr("Store message?"), |
332 | tr("Store message into drafts?\n"), | 409 | tr("Store message into drafts?\n"), |
333 | tr("Yes"), | 410 | tr("Yes"), |