-rw-r--r-- | kmicromail/composemail.cpp | 12 | ||||
-rw-r--r-- | kmicromail/koprefs.cpp | 7 | ||||
-rw-r--r-- | kmicromail/koprefs.h | 5 | ||||
-rw-r--r-- | kmicromail/koprefsdialog.cpp | 19 | ||||
-rw-r--r-- | kmicromail/koprefsdialog.h | 1 | ||||
-rw-r--r-- | kmicromail/libetpan/mime/mailmime_decode.c | 203 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 9 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 16 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 19 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 4 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 45 | ||||
-rw-r--r-- | kmicromail/mainwindow.h | 3 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 16 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 20 |
16 files changed, 244 insertions, 137 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 2dcbc75..f44100b 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -102,402 +102,402 @@ ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, boo | |||
102 | smtpAccountBox->setMaximumWidth( 80 ); | 102 | smtpAccountBox->setMaximumWidth( 80 ); |
103 | Account *it; | 103 | Account *it; |
104 | for ( it = accounts.first(); it; it = accounts.next() ) { | 104 | for ( it = accounts.first(); it; it = accounts.next() ) { |
105 | if ( it->getType()==MAILLIB::A_SMTP ) { | 105 | if ( it->getType()==MAILLIB::A_SMTP ) { |
106 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 106 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
107 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 107 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
108 | smtpAccounts.append( smtp ); | 108 | smtpAccounts.append( smtp ); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 111 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
112 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 112 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
113 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 113 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
114 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 114 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
115 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 115 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
116 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 116 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
117 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 117 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
118 | mMail = 0; | 118 | mMail = 0; |
119 | warnAttach = true; | 119 | warnAttach = true; |
120 | QIconSet icon; | 120 | QIconSet icon; |
121 | //icon = SmallIcon("fileexport"); | 121 | //icon = SmallIcon("fileexport"); |
122 | icon = SmallIcon("filesave"); | 122 | icon = SmallIcon("filesave"); |
123 | SaveButton->setIconSet (icon ) ; | 123 | SaveButton->setIconSet (icon ) ; |
124 | if ( QApplication::desktop()->width() < 320 ) { | 124 | if ( QApplication::desktop()->width() < 320 ) { |
125 | SaveButton->setText ("") ; | 125 | SaveButton->setText ("") ; |
126 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; | 126 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; |
127 | } | 127 | } |
128 | else | 128 | else |
129 | SaveButton->setText (i18n("Save")); | 129 | SaveButton->setText (i18n("Save")); |
130 | #ifndef DESKTOP_VERSION | 130 | #ifndef DESKTOP_VERSION |
131 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | 131 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); |
132 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); | 132 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); |
133 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); | 133 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); |
134 | #endif | 134 | #endif |
135 | message->setFont ( KOPrefs::instance()->mComposeFont ); | 135 | message->setFont ( KOPrefs::instance()->mComposeFont ); |
136 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | 136 | message->setWordWrap (QMultiLineEdit::WidgetWidth); |
137 | if ( smtpAccounts.count() > 0 ) { | 137 | if ( smtpAccounts.count() > 0 ) { |
138 | fillValues( smtpAccountBox->currentItem() ); | 138 | fillValues( smtpAccountBox->currentItem() ); |
139 | } else { | 139 | } else { |
140 | QMessageBox::information( 0, i18n( "Problem" ), | 140 | QMessageBox::information( 0, i18n( "Problem" ), |
141 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), | 141 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), |
142 | i18n( "Ok" ) ); | 142 | i18n( "Ok" ) ); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 145 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
146 | 146 | ||
147 | 147 | ||
148 | } | 148 | } |
149 | 149 | ||
150 | void ComposeMail::fillSettings() | 150 | void ComposeMail::fillSettings() |
151 | { | 151 | { |
152 | if ( QApplication::desktop()->width() < 320 ) | 152 | if ( QApplication::desktop()->width() < 320 ) |
153 | fromBox->setMaximumWidth( 100 ); | 153 | fromBox->setMaximumWidth( 100 ); |
154 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | 154 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); |
155 | QStringList::ConstIterator sit = mailList.begin(); | 155 | QStringList::ConstIterator sit = mailList.begin(); |
156 | int pref = 0; | 156 | int pref = 0; |
157 | for (;sit!=mailList.end();++sit) { | 157 | for (;sit!=mailList.end();++sit) { |
158 | fromBox->insertItem((*sit)); | 158 | fromBox->insertItem((*sit)); |
159 | } | 159 | } |
160 | senderNameEdit->setText(KOPrefs::instance()->mName); | 160 | senderNameEdit->setText(KOPrefs::instance()->mName); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | void ComposeMail::saveAsDraft() | 164 | void ComposeMail::saveAsDraft() |
165 | { | 165 | { |
166 | 166 | ||
167 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 167 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
168 | mail->setMail(fromBox->currentText().utf8 ()); | 168 | mail->setMail(fromBox->currentText().utf8 ()); |
169 | mail->setTo( toLine->text().utf8 () ); | 169 | mail->setTo( toLine->text().utf8 () ); |
170 | mail->setName(senderNameEdit->text().utf8 ()); | 170 | mail->setName(senderNameEdit->text().utf8 ()); |
171 | mail->setCC( ccLine->text().utf8 () ); | 171 | mail->setCC( ccLine->text().utf8 () ); |
172 | mail->setBCC( bccLine->text().utf8 () ); | 172 | mail->setBCC( bccLine->text().utf8 () ); |
173 | mail->setReply( replyLine->text().utf8 () ); | 173 | mail->setReply( replyLine->text().utf8 () ); |
174 | mail->setSubject( subjectLine->text().utf8 () ); | 174 | mail->setSubject( subjectLine->text().utf8 () ); |
175 | if (!m_replyid.isEmpty()) { | 175 | if (!m_replyid.isEmpty()) { |
176 | QStringList ids; | 176 | QStringList ids; |
177 | ids.append(m_replyid); | 177 | ids.append(m_replyid); |
178 | mail->setInreply(ids); | 178 | mail->setInreply(ids); |
179 | } | 179 | } |
180 | QString txt = message->text().utf8 (); | 180 | QString txt = message->text().utf8 (); |
181 | if ( !sigMultiLine->text().isEmpty() ) { | 181 | if ( !sigMultiLine->text().isEmpty() ) { |
182 | txt.append( "\n--\n" ); | 182 | txt.append( "\n--\n" ); |
183 | txt.append( sigMultiLine->text() ); | 183 | txt.append( sigMultiLine->text() ); |
184 | } | 184 | } |
185 | mail->setMessage( txt ); | 185 | mail->setMessage( txt ); |
186 | 186 | ||
187 | /* only use the default drafts folder name! */ | 187 | /* only use the default drafts folder name! */ |
188 | Storemail wrapper(AbstractMail::draftFolder()); | 188 | Storemail wrapper(AbstractMail::draftFolder()); |
189 | wrapper.storeMail(mail); | 189 | wrapper.storeMail(mail); |
190 | 190 | ||
191 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 191 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
192 | /* attachments we will ignore! */ | 192 | /* attachments we will ignore! */ |
193 | if ( it != 0 ) { | 193 | if ( it != 0 ) { |
194 | if ( warnAttach ) | 194 | if ( warnAttach ) |
195 | QMessageBox::warning(0,i18n("Store message"), | 195 | QMessageBox::warning(0,i18n("Store message"), |
196 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 196 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
197 | warnAttach = false; | 197 | warnAttach = false; |
198 | } | 198 | } |
199 | setStatus( i18n("Mail saved as draft!") ); | 199 | setStatus( i18n("Mail saved as draft!") ); |
200 | } | 200 | } |
201 | void ComposeMail::clearStatus() | 201 | void ComposeMail::clearStatus() |
202 | { | 202 | { |
203 | topLevelWidget()->setCaption( i18n("Compose mail") ); | 203 | topLevelWidget()->setCaption( i18n("Compose mail") ); |
204 | } | 204 | } |
205 | void ComposeMail::setStatus( QString status ) | 205 | void ComposeMail::setStatus( QString status ) |
206 | { | 206 | { |
207 | topLevelWidget()->setCaption( status ); | 207 | topLevelWidget()->setCaption( status ); |
208 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 208 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
209 | } | 209 | } |
210 | void ComposeMail::pickAddress( ) | 210 | void ComposeMail::pickAddress( ) |
211 | { | 211 | { |
212 | 212 | ||
213 | QLineEdit *line = mPickLineEdit; | 213 | QLineEdit *line = mPickLineEdit; |
214 | if ( line == 0 ) | 214 | if ( line == 0 ) |
215 | return; | 215 | return; |
216 | #ifdef DESKTOP_VERSION | 216 | #ifdef DESKTOP_VERSION |
217 | //qDebug(" ComposeMail::pickAddress "); | 217 | //qDebug(" ComposeMail::pickAddress "); |
218 | QString names ;//= AddressPicker::getNames(); | 218 | QString names ;//= AddressPicker::getNames(); |
219 | 219 | ||
220 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 220 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
221 | uint i=0; | 221 | uint i=0; |
222 | for (i=0; i < list.count(); i++) { | 222 | for (i=0; i < list.count(); i++) { |
223 | if ( !list[i].preferredEmail().isEmpty()) { | 223 | if ( !list[i].preferredEmail().isEmpty()) { |
224 | if ( ! names.isEmpty() ) | 224 | if ( ! names.isEmpty() ) |
225 | names+= ","; | 225 | names+= ","; |
226 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 226 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
227 | 227 | ||
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | if ( line->text().isEmpty() ) { | 232 | if ( line->text().isEmpty() ) { |
233 | line->setText( names ); | 233 | line->setText( names ); |
234 | } else if ( !names.isEmpty() ) { | 234 | } else if ( !names.isEmpty() ) { |
235 | line->setText( line->text() + ", " + names ); | 235 | line->setText( line->text() + ", " + names ); |
236 | } | 236 | } |
237 | #else | 237 | #else |
238 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 238 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
239 | // the result should now arrive through method insertAttendees | 239 | // the result should now arrive through method insertAttendees |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | //the map includes name/email pairs, that comes from Ka/Pi | 242 | //the map includes name/email pairs, that comes from Ka/Pi |
243 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 243 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
244 | { | 244 | { |
245 | //qDebug("ComposeMail::insertAttendees "); | 245 | //qDebug("ComposeMail::insertAttendees "); |
246 | raise(); | 246 | raise(); |
247 | 247 | ||
248 | if ( mPickLineEdit == 0 ) { //whoami received | 248 | if ( mPickLineEdit == 0 ) { //whoami received |
249 | QString defmail = uidList[0]; | 249 | QString defmail = uidList[0]; |
250 | if ( emailList.count() == 0 ) | 250 | if ( emailList.count() == 0 ) |
251 | QMessageBox::information( 0, i18n( "Hint" ), | 251 | QMessageBox::information( 0, i18n( "Hint" ), |
252 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 252 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
253 | i18n( "Ok" ) ); | 253 | i18n( "Ok" ) ); |
254 | if (defmail.length()!=0) { | 254 | if (defmail.length()!=0) { |
255 | fromBox->insertItem(defmail); | 255 | fromBox->insertItem(defmail); |
256 | } | 256 | } |
257 | QStringList::ConstIterator sit = emailList.begin(); | 257 | QStringList::ConstIterator sit = emailList.begin(); |
258 | int pref = 0; | 258 | int pref = 0; |
259 | for (;sit!=emailList.end();++sit) { | 259 | for (;sit!=emailList.end();++sit) { |
260 | if ( (*sit)==defmail) | 260 | if ( (*sit)==defmail) |
261 | continue; | 261 | continue; |
262 | fromBox->insertItem((*sit)); | 262 | fromBox->insertItem((*sit)); |
263 | } | 263 | } |
264 | senderNameEdit->setText(nameList[0]); | 264 | senderNameEdit->setText(nameList[0]); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | QString names ; | 267 | QString names ; |
268 | QLineEdit *line = mPickLineEdit; | 268 | QLineEdit *line = mPickLineEdit; |
269 | if (uid == this->name()) | 269 | if (uid == this->name()) |
270 | { | 270 | { |
271 | for ( int i = 0; i < nameList.count(); i++) | 271 | for ( int i = 0; i < nameList.count(); i++) |
272 | { | 272 | { |
273 | QString _name = nameList[i]; | 273 | QString _name = nameList[i]; |
274 | QString _email = emailList[i]; | 274 | QString _email = emailList[i]; |
275 | QString _uid = uidList[i]; | 275 | QString _uid = uidList[i]; |
276 | if ( ! _email.isEmpty() ) { | 276 | if ( ! _email.isEmpty() ) { |
277 | if ( ! names.isEmpty() ) | 277 | if ( ! names.isEmpty() ) |
278 | names+= ","; | 278 | names+= ","; |
279 | names+= "\""+_name +"\"<" +_email +">"; | 279 | names+= "\""+_name +"\"<" +_email +">"; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | } | 282 | } |
283 | if ( line->text().isEmpty() ) { | 283 | if ( line->text().isEmpty() ) { |
284 | line->setText( names ); | 284 | line->setText( names ); |
285 | } else if ( !names.isEmpty() ) { | 285 | } else if ( !names.isEmpty() ) { |
286 | line->setText( line->text() + ", " + names ); | 286 | line->setText( line->text() + ", " + names ); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | void ComposeMail::setTo( const QString & to ) | 290 | void ComposeMail::setTo( const QString & to ) |
291 | { | 291 | { |
292 | toLine->setText( to ); | 292 | toLine->setText( to ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void ComposeMail::setSubject( const QString & subject ) | 295 | void ComposeMail::setSubject( const QString & subject ) |
296 | { | 296 | { |
297 | subjectLine->setText( subject ); | 297 | subjectLine->setText( subject ); |
298 | } | 298 | } |
299 | 299 | ||
300 | void ComposeMail::setInReplyTo( const QString & messageId ) | 300 | void ComposeMail::setInReplyTo( const QString & messageId ) |
301 | { | 301 | { |
302 | m_replyid = messageId; | 302 | m_replyid = messageId; |
303 | } | 303 | } |
304 | 304 | ||
305 | void ComposeMail::setMessage( const QString & text ) | 305 | void ComposeMail::setMessage( const QString & text ) |
306 | { | 306 | { |
307 | message->setText( text ); | 307 | message->setText( text ); |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | void ComposeMail::pickAddressTo() | 311 | void ComposeMail::pickAddressTo() |
312 | { | 312 | { |
313 | mPickLineEdit = toLine; | 313 | mPickLineEdit = toLine; |
314 | pickAddress( ); | 314 | pickAddress( ); |
315 | } | 315 | } |
316 | 316 | ||
317 | void ComposeMail::pickAddressCC() | 317 | void ComposeMail::pickAddressCC() |
318 | { | 318 | { |
319 | mPickLineEdit = ccLine; | 319 | mPickLineEdit = ccLine; |
320 | pickAddress( ); | 320 | pickAddress( ); |
321 | } | 321 | } |
322 | 322 | ||
323 | void ComposeMail::pickAddressBCC() | 323 | void ComposeMail::pickAddressBCC() |
324 | { | 324 | { |
325 | mPickLineEdit = bccLine; | 325 | mPickLineEdit = bccLine; |
326 | pickAddress( ); | 326 | pickAddress( ); |
327 | } | 327 | } |
328 | 328 | ||
329 | void ComposeMail::pickAddressReply() | 329 | void ComposeMail::pickAddressReply() |
330 | { | 330 | { |
331 | mPickLineEdit = replyLine; | 331 | mPickLineEdit = replyLine; |
332 | pickAddress( ); | 332 | pickAddress( ); |
333 | } | 333 | } |
334 | 334 | ||
335 | void ComposeMail::fillValues( int ) | 335 | void ComposeMail::fillValues( int ) |
336 | { | 336 | { |
337 | #if 0 | 337 | #if 0 |
338 | SMTPaccount *smtp = smtpAccounts.at( current ); | 338 | SMTPaccount *smtp = smtpAccounts.at( current ); |
339 | ccLine->clear(); | 339 | ccLine->clear(); |
340 | if ( smtp->getUseCC() ) { | 340 | if ( smtp->getUseCC() ) { |
341 | ccLine->setText( smtp->getCC() ); | 341 | ccLine->setText( smtp->getCC() ); |
342 | } | 342 | } |
343 | bccLine->clear(); | 343 | bccLine->clear(); |
344 | if ( smtp->getUseBCC() ) { | 344 | if ( smtp->getUseBCC() ) { |
345 | bccLine->setText( smtp->getBCC() ); | 345 | bccLine->setText( smtp->getBCC() ); |
346 | } | 346 | } |
347 | replyLine->clear(); | 347 | replyLine->clear(); |
348 | if ( smtp->getUseReply() ) { | 348 | if ( smtp->getUseReply() ) { |
349 | replyLine->setText( smtp->getReply() ); | 349 | replyLine->setText( smtp->getReply() ); |
350 | } | 350 | } |
351 | sigMultiLine->setText( smtp->getSignature() ); | 351 | sigMultiLine->setText( smtp->getSignature() ); |
352 | #endif | 352 | #endif |
353 | } | 353 | } |
354 | 354 | ||
355 | void ComposeMail::slotAdjustColumns() | 355 | void ComposeMail::slotAdjustColumns() |
356 | { | 356 | { |
357 | int currPage = tabWidget->currentPageIndex(); | 357 | int currPage = tabWidget->currentPageIndex(); |
358 | 358 | ||
359 | tabWidget->showPage( attachTab ); | 359 | tabWidget->showPage( attachTab ); |
360 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 360 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
361 | attList->setColumnWidth( 1, 80 ); | 361 | attList->setColumnWidth( 1, 80 ); |
362 | 362 | ||
363 | tabWidget->setCurrentPage( currPage ); | 363 | tabWidget->setCurrentPage( currPage ); |
364 | } | 364 | } |
365 | 365 | ||
366 | void ComposeMail::addAttachment() | 366 | void ComposeMail::addAttachment() |
367 | { | 367 | { |
368 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 368 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
369 | if ( !lnk.isEmpty() ) { | 369 | if ( !lnk.isEmpty() ) { |
370 | Attachment *att = new Attachment( lnk ); | 370 | Attachment *att = new Attachment( lnk ); |
371 | (void) new AttachViewItem( attList, att ); | 371 | (void) new AttachViewItem( attList, att ); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | void ComposeMail::removeAttachment() | 375 | void ComposeMail::removeAttachment() |
376 | { | 376 | { |
377 | if ( !attList->currentItem() ) { | 377 | if ( !attList->currentItem() ) { |
378 | QMessageBox::information( this, i18n( "Error" ), | 378 | QMessageBox::information( this, i18n( "Error" ), |
379 | i18n( "<p>Please select a File.</p>" ), | 379 | i18n( "<p>Please select a File.</p>" ), |
380 | i18n( "Ok" ) ); | 380 | i18n( "Ok" ) ); |
381 | } else { | 381 | } else { |
382 | attList->takeItem( attList->currentItem() ); | 382 | attList->takeItem( attList->currentItem() ); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | void ComposeMail::accept() | 386 | void ComposeMail::accept() |
387 | { | 387 | { |
388 | if ( smtpAccountBox->count() == 0 ) { | 388 | if ( smtpAccountBox->count() == 0 ) { |
389 | 389 | ||
390 | reject(); | 390 | reject(); |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | 393 | ||
394 | if (! checkBoxLater->isChecked() ) { | 394 | if (! checkBoxLater->isChecked() ) { |
395 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), | 395 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), |
396 | i18n("Send this message?"), | 396 | i18n("Send this message?"), |
397 | i18n("Yes"), | 397 | i18n("Yes"), |
398 | i18n("Cancel")); | 398 | i18n("Cancel")); |
399 | 399 | ||
400 | if (yesno == 1) { | 400 | if (yesno == 1) { |
401 | return; | 401 | return; |
402 | } | 402 | } |
403 | } | 403 | } |
404 | #if 0 | 404 | #if 0 |
405 | odebug << "Sending Mail with " | 405 | odebug << "Sending Mail with " |
406 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; | 406 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; |
407 | #endif | 407 | #endif |
408 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 408 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
409 | 409 | ||
410 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 410 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
411 | mail->setMail(fromBox->currentText().utf8 ()); | 411 | mail->setMail(fromBox->currentText().utf8 ()); |
412 | 412 | ||
413 | if ( !toLine->text().isEmpty() ) { | 413 | if ( !toLine->text().isEmpty() ) { |
414 | mail->setTo( toLine->text().utf8 () ); | 414 | mail->setTo( toLine->text().utf8 () ); |
415 | } else { | 415 | } else { |
416 | QMessageBox::warning(0,i18n("Sending mail"), | 416 | QMessageBox::warning(0,i18n("Sending mail"), |
417 | i18n("No Receiver spezified" ) ); | 417 | i18n("No Receiver spezified" ) ); |
418 | return; | 418 | return; |
419 | } | 419 | } |
420 | 420 | ||
421 | mail->setName(senderNameEdit->text().utf8 ()); | 421 | mail->setName(senderNameEdit->text().utf8 ()); |
422 | mail->setCC( ccLine->text().utf8 () ); | 422 | mail->setCC( ccLine->text().utf8 () ); |
423 | mail->setBCC( bccLine->text().utf8 () ); | 423 | mail->setBCC( bccLine->text().utf8 () ); |
424 | mail->setReply( replyLine->text().utf8 () ); | 424 | mail->setReply( replyLine->text().utf8 () ); |
425 | mail->setSubject( subjectLine->text().utf8 () ); | 425 | mail->setSubject( subjectLine->text().utf8 () ); |
426 | if (!m_replyid.isEmpty()) { | 426 | if (!m_replyid.isEmpty()) { |
427 | QStringList ids; | 427 | QStringList ids; |
428 | ids.append(m_replyid.utf8 ()); | 428 | ids.append(m_replyid.utf8 ()); |
429 | mail->setInreply(ids); | 429 | mail->setInreply(ids); |
430 | } | 430 | } |
431 | QString txt = message->text().utf8 (); | 431 | QString txt = message->text().utf8 (); |
432 | if ( !sigMultiLine->text().isEmpty() ) { | 432 | if ( !sigMultiLine->text().isEmpty() ) { |
433 | txt.append( "\n--\n" ); | 433 | txt.append( "\n--\n" ); |
434 | txt.append( sigMultiLine->text().utf8 () ); | 434 | txt.append( sigMultiLine->text().utf8 () ); |
435 | } | 435 | } |
436 | mail->setMessage( txt ); | 436 | mail->setMessage( txt ); |
437 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 437 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
438 | while ( it != 0 ) { | 438 | while ( it != 0 ) { |
439 | mail->addAttachment( it->getAttachment() ); | 439 | mail->addAttachment( it->getAttachment() ); |
440 | it = (AttachViewItem *) it->nextSibling(); | 440 | it = (AttachViewItem *) it->nextSibling(); |
441 | } | 441 | } |
442 | 442 | ||
443 | SMTPwrapper wrapper( smtp ); | 443 | SMTPwrapper wrapper( smtp ); |
444 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) | 444 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) |
445 | setStatus( tr ("Mail sent")); | 445 | setStatus( tr ("Mail sent")); |
446 | else { | 446 | else { |
447 | setStatus( tr ("Error: Something went wrong. Nothing sent")); | 447 | setStatus( tr ("Error: Something went wrong. Nothing sent")); |
448 | return; | 448 | return; |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | QDialog::accept(); | 452 | QDialog::accept(); |
453 | } | 453 | } |
454 | 454 | ||
455 | void ComposeMail::reject() | 455 | void ComposeMail::reject() |
456 | { | 456 | { |
457 | //qDebug("ComposeMail::reject() "); | 457 | //qDebug("ComposeMail::reject() "); |
458 | int yesno = QMessageBox::warning(0,i18n("Store message?"), | 458 | int yesno = QMessageBox::warning(0,i18n("Store message?"), |
459 | i18n("Store message into drafts?\n"), | 459 | i18n("Store message into drafts?\n"), |
460 | i18n("Yes"), | 460 | i18n("Yes"), |
461 | i18n("No")); | 461 | i18n("No")); |
462 | 462 | ||
463 | //qDebug("button %d ", yesno); | 463 | //qDebug("button %d ", yesno); |
464 | if (yesno == 0) { | 464 | if (yesno == 0) { |
465 | if ( toLine->text().isEmpty() ) { | 465 | if ( toLine->text().isEmpty() ) { |
466 | QMessageBox::warning(0,i18n("Sending mail"), | 466 | QMessageBox::warning(0,i18n("Sending mail"), |
467 | i18n("No Receiver spezified" ) ); | 467 | i18n("No Receiver spezified" ) ); |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | saveAsDraft(); | 470 | saveAsDraft(); |
471 | } | 471 | } |
472 | if (yesno == 2) { | 472 | if (yesno == 2) { |
473 | qDebug("return "); | 473 | qDebug("return "); |
474 | return; | 474 | return; |
475 | } | 475 | } |
476 | QDialog::reject(); | 476 | QDialog::reject(); |
477 | } | 477 | } |
478 | 478 | ||
479 | ComposeMail::~ComposeMail() | 479 | ComposeMail::~ComposeMail() |
480 | { | 480 | { |
481 | } | 481 | } |
482 | 482 | ||
483 | void ComposeMail::reEditMail(const RecMailP¤t) | 483 | void ComposeMail::reEditMail(const RecMailP¤t) |
484 | { | 484 | { |
485 | RecMailP data = current; | 485 | RecMailP data = current; |
486 | message->setText(QString::fromUtf8( data->Wrapper()->fetchBody(current)->Bodytext().latin1() )); | 486 | message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); |
487 | subjectLine->setText( QString::fromUtf8( data->getSubject().latin1() )); | 487 | subjectLine->setText( data->getSubject()); |
488 | toLine->setText(QString::fromUtf8( data->To().join(",").latin1() )); | 488 | toLine->setText(data->To().join(",")); |
489 | ccLine->setText(QString::fromUtf8( data->CC().join(",").latin1() )); | 489 | ccLine->setText(data->CC().join(",")); |
490 | bccLine->setText(QString::fromUtf8( data->Bcc().join(",").latin1() )); | 490 | bccLine->setText(data->Bcc().join(",")); |
491 | replyLine->setText(QString::fromUtf8( data->Replyto().latin1() )); | 491 | replyLine->setText(data->Replyto()); |
492 | } | 492 | } |
493 | 493 | ||
494 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 494 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
495 | : QListViewItem( parent ) | 495 | : QListViewItem( parent ) |
496 | { | 496 | { |
497 | attachment = att; | 497 | attachment = att; |
498 | if ( !attachment->getPixmap().isNull() ) | 498 | if ( !attachment->getPixmap().isNull() ) |
499 | setPixmap( 0,attachment->getPixmap() ); | 499 | setPixmap( 0,attachment->getPixmap() ); |
500 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 500 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
501 | setText( 1, QString::number( att->getSize() ) ); | 501 | setText( 1, QString::number( att->getSize() ) ); |
502 | } | 502 | } |
503 | 503 | ||
diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp index 8143b6f..342bbf3 100644 --- a/kmicromail/koprefs.cpp +++ b/kmicromail/koprefs.cpp | |||
@@ -1,122 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | 44 | ||
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "mainwindow.h" | 46 | #include "mainwindow.h" |
47 | 47 | ||
48 | 48 | ||
49 | KOPrefs *KOPrefs::mInstance = 0; | 49 | KOPrefs *KOPrefs::mInstance = 0; |
50 | static KStaticDeleter<KOPrefs> insd; | 50 | static KStaticDeleter<KOPrefs> insd; |
51 | 51 | ||
52 | KOPrefs::KOPrefs() : | 52 | KOPrefs::KOPrefs() : |
53 | KPimPrefs("kopiemailrc") | 53 | KPimPrefs("kopiemailrc") |
54 | { | 54 | { |
55 | mAppFont = QFont("helvetica",12); | 55 | mAppFont = QFont("helvetica",12); |
56 | mComposeFont = QFont("helvetica",12); | 56 | mComposeFont = QFont("helvetica",12); |
57 | mReadFont = QFont("helvetica",12); | 57 | mReadFont = QFont("helvetica",12); |
58 | 58 | ||
59 | KPrefs::setCurrentGroup("General"); | 59 | KPrefs::setCurrentGroup("General"); |
60 | addItemString("SendCodec",&mSendCodec,i18n ("userdefined") ); | ||
60 | addItemString("SenderName",&mName,i18n ("Please set at") ); | 61 | addItemString("SenderName",&mName,i18n ("Please set at") ); |
61 | addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); | 62 | addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); |
62 | addItemBool("ViewMailAsHtml",&mViewAsHtml,false); | 63 | addItemBool("ViewMailAsHtml",&mViewAsHtml,false); |
63 | addItemBool("SendMailLater",&mSendLater,true); | 64 | addItemBool("SendMailLater",&mSendLater,true); |
64 | addItemBool("UseKapi",&mUseKapi,false); | 65 | addItemBool("UseKapi",&mUseKapi,false); |
66 | addItemInt("CurrentCodec",&mCurrentCodec,0); | ||
65 | 67 | ||
66 | KPrefs::setCurrentGroup("Fonts"); | 68 | KPrefs::setCurrentGroup("Fonts"); |
67 | addItemFont("Application Font",&mAppFont); | 69 | addItemFont("Application Font",&mAppFont); |
68 | addItemFont("Compose Font",&mComposeFont); | 70 | addItemFont("Compose Font",&mComposeFont); |
69 | addItemFont("Read Font",&mReadFont); | 71 | addItemFont("Read Font",&mReadFont); |
70 | fillMailDefaults(); | 72 | fillMailDefaults(); |
71 | 73 | isDirty = false; | |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
75 | KOPrefs::~KOPrefs() | 77 | KOPrefs::~KOPrefs() |
76 | { | 78 | { |
79 | if ( isDirty ) | ||
80 | writeConfig(); | ||
77 | if (mInstance == this) | 81 | if (mInstance == this) |
78 | mInstance = insd.setObject(0); | 82 | mInstance = insd.setObject(0); |
79 | 83 | ||
80 | } | 84 | } |
81 | 85 | ||
82 | 86 | ||
83 | KOPrefs *KOPrefs::instance() | 87 | KOPrefs *KOPrefs::instance() |
84 | { | 88 | { |
85 | if (!mInstance) { | 89 | if (!mInstance) { |
86 | mInstance = insd.setObject(new KOPrefs()); | 90 | mInstance = insd.setObject(new KOPrefs()); |
87 | mInstance->readConfig(); | 91 | mInstance->readConfig(); |
88 | } | 92 | } |
89 | 93 | ||
90 | return mInstance; | 94 | return mInstance; |
91 | } | 95 | } |
92 | 96 | ||
93 | void KOPrefs::usrSetDefaults() | 97 | void KOPrefs::usrSetDefaults() |
94 | { | 98 | { |
95 | 99 | ||
96 | } | 100 | } |
97 | 101 | ||
98 | void KOPrefs::fillMailDefaults() | 102 | void KOPrefs::fillMailDefaults() |
99 | { | 103 | { |
100 | if (mName.isEmpty()) mName = i18n ("Please set at"); | 104 | if (mName.isEmpty()) mName = i18n ("Please set at"); |
101 | if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB"); | 105 | if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB"); |
102 | } | 106 | } |
103 | 107 | ||
104 | void KOPrefs::usrReadConfig() | 108 | void KOPrefs::usrReadConfig() |
105 | { | 109 | { |
106 | 110 | ||
107 | KPimPrefs::usrReadConfig(); | 111 | KPimPrefs::usrReadConfig(); |
108 | } | 112 | } |
109 | 113 | ||
110 | 114 | ||
111 | void KOPrefs::usrWriteConfig() | 115 | void KOPrefs::usrWriteConfig() |
112 | { | 116 | { |
113 | |||
114 | KPimPrefs::usrWriteConfig(); | 117 | KPimPrefs::usrWriteConfig(); |
115 | } | 118 | } |
116 | 119 | ||
117 | 120 | ||
118 | 121 | ||
119 | KConfig* KOPrefs::getConfig() | 122 | KConfig* KOPrefs::getConfig() |
120 | { | 123 | { |
121 | return config(); | 124 | return config(); |
122 | } | 125 | } |
diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h index f0a4463..91f3fa3 100644 --- a/kmicromail/koprefs.h +++ b/kmicromail/koprefs.h | |||
@@ -1,77 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | 28 | ||
29 | class KConfig; | 29 | class KConfig; |
30 | class QFont; | 30 | class QFont; |
31 | class QColor; | 31 | class QColor; |
32 | class QStringList; | 32 | class QStringList; |
33 | 33 | ||
34 | class KOPrefs : public KPimPrefs | 34 | class KOPrefs : public KPimPrefs |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | virtual ~KOPrefs(); | 37 | virtual ~KOPrefs(); |
38 | 38 | ||
39 | /** Get instance of KOPrefs. It is made sure that there is only one | 39 | /** Get instance of KOPrefs. It is made sure that there is only one |
40 | instance. */ | 40 | instance. */ |
41 | static KOPrefs *instance(); | 41 | static KOPrefs *instance(); |
42 | 42 | ||
43 | /** Set preferences to default values */ | 43 | /** Set preferences to default values */ |
44 | void usrSetDefaults(); | 44 | void usrSetDefaults(); |
45 | 45 | ||
46 | /** Read preferences from config file */ | 46 | /** Read preferences from config file */ |
47 | void usrReadConfig(); | 47 | void usrReadConfig(); |
48 | 48 | ||
49 | /** Write preferences to config file */ | 49 | /** Write preferences to config file */ |
50 | void usrWriteConfig(); | 50 | void usrWriteConfig(); |
51 | void setCategoryDefaults(){;}; | 51 | void setCategoryDefaults(){;}; |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | 54 | ||
55 | /** Fill empty mail fields with default values. */ | 55 | /** Fill empty mail fields with default values. */ |
56 | void fillMailDefaults(); | 56 | void fillMailDefaults(); |
57 | 57 | ||
58 | private: | 58 | private: |
59 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 59 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
60 | object. */ | 60 | object. */ |
61 | KOPrefs(); | 61 | KOPrefs(); |
62 | 62 | ||
63 | static KOPrefs *mInstance; | 63 | static KOPrefs *mInstance; |
64 | public: | 64 | public: |
65 | // preferences data | 65 | // preferences data |
66 | KConfig* getConfig(); | 66 | KConfig* getConfig(); |
67 | QFont mAppFont; | 67 | QFont mAppFont; |
68 | QFont mComposeFont; | 68 | QFont mComposeFont; |
69 | QFont mReadFont; | 69 | QFont mReadFont; |
70 | QString mName; | 70 | QString mName; |
71 | QString mSendCodec; | ||
71 | QString mEmail; | 72 | QString mEmail; |
72 | bool mSendLater, mViewAsHtml, mUseKapi; | 73 | QString mCurrentCodeName; |
74 | int mCurrentCodec; | ||
75 | bool mSendLater, mViewAsHtml, mUseKapi, isDirty; | ||
73 | private: | 76 | private: |
74 | 77 | ||
75 | }; | 78 | }; |
76 | 79 | ||
77 | #endif | 80 | #endif |
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp index c878fc9..4abf859 100644 --- a/kmicromail/koprefsdialog.cpp +++ b/kmicromail/koprefsdialog.cpp | |||
@@ -1,588 +1,593 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #include <kdialog.h> | 23 | #include <kdialog.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | 44 | ||
45 | #include <kcolorbutton.h> | 45 | #include <kcolorbutton.h> |
46 | #include <kdebug.h> | 46 | #include <kdebug.h> |
47 | #include <klocale.h> | 47 | #include <klocale.h> |
48 | #include <kglobal.h> | 48 | #include <kglobal.h> |
49 | #include <kfontdialog.h> | 49 | #include <kfontdialog.h> |
50 | #include <kfiledialog.h> | 50 | #include <kfiledialog.h> |
51 | #include <kmessagebox.h> | 51 | #include <kmessagebox.h> |
52 | #include <kcolordialog.h> | 52 | #include <kcolordialog.h> |
53 | #include <kiconloader.h> | 53 | #include <kiconloader.h> |
54 | #include <kemailsettings.h> | 54 | #include <kemailsettings.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | 56 | ||
57 | #include <klineedit.h> | 57 | #include <klineedit.h> |
58 | 58 | ||
59 | 59 | ||
60 | #include "koprefs.h" | 60 | #include "koprefs.h" |
61 | 61 | ||
62 | #include "koprefsdialog.h" | 62 | #include "koprefsdialog.h" |
63 | //#include <kprefswidget.h> | 63 | //#include <kprefswidget.h> |
64 | 64 | ||
65 | 65 | ||
66 | KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : | 66 | KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : |
67 | KPrefsDialog(KOPrefs::instance(),parent,name,true) | 67 | KPrefsDialog(KOPrefs::instance(),parent,name,true) |
68 | { | 68 | { |
69 | 69 | ||
70 | setCaption( i18n("Settings - some need a restart (nr)")); | 70 | setCaption( i18n("Settings - some need a restart (nr)")); |
71 | setupGlobalTab(); | 71 | setupGlobalTab(); |
72 | setupMainTab(); | 72 | setupMainTab(); |
73 | setupMailTab();; | 73 | setupMailTab();; |
74 | setupFontsTab(); | 74 | setupFontsTab(); |
75 | readConfig(); | 75 | readConfig(); |
76 | 76 | ||
77 | #if 0 | 77 | #if 0 |
78 | 78 | ||
79 | setupMainTab(); | 79 | setupMainTab(); |
80 | setupLocaleTab(); | 80 | setupLocaleTab(); |
81 | setupTimeZoneTab(); | 81 | setupTimeZoneTab(); |
82 | setupTimeTab(); | 82 | setupTimeTab(); |
83 | setupLocaleDateTab(); | 83 | setupLocaleDateTab(); |
84 | setupFontsTab(); | 84 | setupFontsTab(); |
85 | setupColorsTab(); | 85 | setupColorsTab(); |
86 | setupViewsTab(); | 86 | setupViewsTab(); |
87 | //setupSyncTab(); | 87 | //setupSyncTab(); |
88 | //setupSyncAlgTab(); | 88 | //setupSyncAlgTab(); |
89 | //setupPrinterTab(); | 89 | //setupPrinterTab(); |
90 | //setupGroupSchedulingTab(); | 90 | //setupGroupSchedulingTab(); |
91 | //setupGroupAutomationTab(); | 91 | //setupGroupAutomationTab(); |
92 | #endif | 92 | #endif |
93 | } | 93 | } |
94 | 94 | ||
95 | #include "kpimglobalprefs.h" | 95 | #include "kpimglobalprefs.h" |
96 | 96 | ||
97 | KOPrefsDialog::~KOPrefsDialog() | 97 | KOPrefsDialog::~KOPrefsDialog() |
98 | { | 98 | { |
99 | } | 99 | } |
100 | void KOPrefsDialog::setupGlobalTab() | 100 | void KOPrefsDialog::setupGlobalTab() |
101 | { | 101 | { |
102 | QFrame *topFrame = addPage(i18n("Global"),0,0); | 102 | QFrame *topFrame = addPage(i18n("Global"),0,0); |
103 | kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); | 103 | kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); |
104 | QVBoxLayout *topLayout = new QVBoxLayout(topFrame); | 104 | QVBoxLayout *topLayout = new QVBoxLayout(topFrame); |
105 | topLayout->addWidget( kdelibcfg ); | 105 | topLayout->addWidget( kdelibcfg ); |
106 | 106 | ||
107 | 107 | ||
108 | } | 108 | } |
109 | void KOPrefsDialog::setupMainTab() | 109 | void KOPrefsDialog::setupMainTab() |
110 | { | 110 | { |
111 | QFrame *topFrame = addPage(i18n("General"),0,0); | 111 | QFrame *topFrame = addPage(i18n("General"),0,0); |
112 | 112 | ||
113 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 113 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
114 | topLayout->setSpacing(spacingHint()); | 114 | topLayout->setSpacing(spacingHint()); |
115 | topLayout->setMargin(marginHint()); | 115 | topLayout->setMargin(marginHint()); |
116 | 116 | ||
117 | 117 | ||
118 | mNameEdit = new QLineEdit(topFrame); | 118 | mNameEdit = new QLineEdit(topFrame); |
119 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); | 119 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); |
120 | topLayout->addWidget(mNameLabel,0,0); | 120 | topLayout->addWidget(mNameLabel,0,0); |
121 | topLayout->addWidget(mNameEdit,0,1); | 121 | topLayout->addWidget(mNameEdit,0,1); |
122 | 122 | ||
123 | mEmailEdit = new QLineEdit(topFrame); | 123 | mEmailEdit = new QLineEdit(topFrame); |
124 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); | 124 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); |
125 | topLayout->addWidget(mEmailLabel,1,0); | 125 | topLayout->addWidget(mEmailLabel,1,0); |
126 | topLayout->addWidget(mEmailEdit,1,1); | 126 | topLayout->addWidget(mEmailEdit,1,1); |
127 | QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); | 127 | QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); |
128 | topLayout->addMultiCellWidget(lab,2,2,0,1); | 128 | topLayout->addMultiCellWidget(lab,2,2,0,1); |
129 | KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), | 129 | KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), |
130 | &(KOPrefs::instance()->mUseKapi),topFrame); | 130 | &(KOPrefs::instance()->mUseKapi),topFrame); |
131 | topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); | 131 | topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); |
132 | } | 132 | } |
133 | 133 | ||
134 | void KOPrefsDialog::setupMailTab() | 134 | void KOPrefsDialog::setupMailTab() |
135 | { | 135 | { |
136 | QFrame *topFrame = addPage(i18n("Mail"),0,0); | 136 | QFrame *topFrame = addPage(i18n("Mail"),0,0); |
137 | 137 | ||
138 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 138 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
139 | topLayout->setSpacing(spacingHint()); | 139 | topLayout->setSpacing(spacingHint()); |
140 | topLayout->setMargin(marginHint()); | 140 | topLayout->setMargin(marginHint()); |
141 | 141 | ||
142 | KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), | 142 | KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), |
143 | &(KOPrefs::instance()->mViewAsHtml),topFrame); | 143 | &(KOPrefs::instance()->mViewAsHtml),topFrame); |
144 | topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); | 144 | topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); |
145 | 145 | ||
146 | 146 | ||
147 | ttt = addWidBool(i18n("Send mails later"), | 147 | ttt = addWidBool(i18n("Send mails later"), |
148 | &(KOPrefs::instance()->mSendLater),topFrame); | 148 | &(KOPrefs::instance()->mSendLater),topFrame); |
149 | topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); | 149 | topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); |
150 | 150 | mCodecEdit = new QLineEdit(topFrame); | |
151 | topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1); | ||
152 | topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1); | ||
153 | topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1); | ||
151 | 154 | ||
152 | } | 155 | } |
153 | void KOPrefsDialog::setupFontsTab() | 156 | void KOPrefsDialog::setupFontsTab() |
154 | { | 157 | { |
155 | 158 | ||
156 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); | 159 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); |
157 | // DesktopIcon("fonts",KIcon::SizeMedium)); | 160 | // DesktopIcon("fonts",KIcon::SizeMedium)); |
158 | 161 | ||
159 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); | 162 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); |
160 | topLayout->setSpacing(1); | 163 | topLayout->setSpacing(1); |
161 | topLayout->setMargin(3); | 164 | topLayout->setMargin(3); |
162 | KPrefsDialogWidFont * tVFont; | 165 | KPrefsDialogWidFont * tVFont; |
163 | int i = 0; | 166 | int i = 0; |
164 | KPrefsDialogWidFont *timeLabelsFont = | 167 | KPrefsDialogWidFont *timeLabelsFont = |
165 | addWidFont(i18n("OK"),i18n("Application(nr)"), | 168 | addWidFont(i18n("OK"),i18n("Application(nr)"), |
166 | &(KOPrefs::instance()->mAppFont),topFrame); | 169 | &(KOPrefs::instance()->mAppFont),topFrame); |
167 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 170 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
168 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 171 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
169 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 172 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
170 | ++i; | 173 | ++i; |
171 | 174 | ||
172 | 175 | ||
173 | timeLabelsFont = | 176 | timeLabelsFont = |
174 | addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), | 177 | addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), |
175 | &(KOPrefs::instance()->mComposeFont),topFrame); | 178 | &(KOPrefs::instance()->mComposeFont),topFrame); |
176 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 179 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
177 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 180 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
178 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 181 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
179 | ++i; | 182 | ++i; |
180 | 183 | ||
181 | KPrefsDialogWidFont *timeBarFont = | 184 | KPrefsDialogWidFont *timeBarFont = |
182 | addWidFont(i18n("Hello"),i18n("Read mail:"), | 185 | addWidFont(i18n("Hello"),i18n("Read mail:"), |
183 | &(KOPrefs::instance()->mReadFont),topFrame); | 186 | &(KOPrefs::instance()->mReadFont),topFrame); |
184 | topLayout->addWidget(timeBarFont->label(),i,0); | 187 | topLayout->addWidget(timeBarFont->label(),i,0); |
185 | topLayout->addWidget(timeBarFont->preview(),i,1); | 188 | topLayout->addWidget(timeBarFont->preview(),i,1); |
186 | topLayout->addWidget(timeBarFont->button(),i,2); | 189 | topLayout->addWidget(timeBarFont->button(),i,2); |
187 | ++i; | 190 | ++i; |
188 | 191 | ||
189 | topLayout->setColStretch(1,1); | 192 | topLayout->setColStretch(1,1); |
190 | topLayout->setRowStretch(4,1); | 193 | topLayout->setRowStretch(4,1); |
191 | 194 | ||
192 | } | 195 | } |
193 | void KOPrefsDialog::usrReadConfig() | 196 | void KOPrefsDialog::usrReadConfig() |
194 | { | 197 | { |
195 | 198 | ||
196 | mNameEdit->setText(KOPrefs::instance()->mName); | 199 | mNameEdit->setText(KOPrefs::instance()->mName); |
197 | mEmailEdit->setText(KOPrefs::instance()->mEmail); | 200 | mEmailEdit->setText(KOPrefs::instance()->mEmail); |
201 | mCodecEdit->setText(KOPrefs::instance()->mSendCodec); | ||
198 | kdelibcfg->readConfig(); | 202 | kdelibcfg->readConfig(); |
199 | } | 203 | } |
200 | void KOPrefsDialog::usrWriteConfig() | 204 | void KOPrefsDialog::usrWriteConfig() |
201 | { | 205 | { |
202 | KOPrefs::instance()->mName = mNameEdit->text(); | 206 | KOPrefs::instance()->mName = mNameEdit->text(); |
203 | KOPrefs::instance()->mEmail = mEmailEdit->text(); | 207 | KOPrefs::instance()->mEmail = mEmailEdit->text(); |
204 | kdelibcfg->writeConfig(); | 208 | KOPrefs::instance()->mSendCodec = mCodecEdit->text(); |
209 | kdelibcfg->writeConfig(); | ||
205 | 210 | ||
206 | 211 | ||
207 | } | 212 | } |
208 | 213 | ||
209 | #if 0 | 214 | #if 0 |
210 | void KOPrefsDialog::setupLocaleDateTab() | 215 | void KOPrefsDialog::setupLocaleDateTab() |
211 | { | 216 | { |
212 | QFrame *topFrame = addPage(i18n("Date Format"),0,0); | 217 | QFrame *topFrame = addPage(i18n("Date Format"),0,0); |
213 | QGridLayout *topLayout = new QGridLayout(topFrame,3,2); | 218 | QGridLayout *topLayout = new QGridLayout(topFrame,3,2); |
214 | topLayout->setSpacing(spacingHint()); | 219 | topLayout->setSpacing(spacingHint()); |
215 | topLayout->setMargin(marginHint()); | 220 | topLayout->setMargin(marginHint()); |
216 | int iii = 0; | 221 | int iii = 0; |
217 | 222 | ||
218 | 223 | ||
219 | KPrefsWidRadios *syncPrefsGroup = | 224 | KPrefsWidRadios *syncPrefsGroup = |
220 | addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); | 225 | addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); |
221 | QString format; | 226 | QString format; |
222 | if ( QApplication::desktop()->width() < 480 ) | 227 | if ( QApplication::desktop()->width() < 480 ) |
223 | format = "(%d.%m.%Y)"; | 228 | format = "(%d.%m.%Y)"; |
224 | else | 229 | else |
225 | format = "(%d.%m.%Y|%A %d %B %Y)"; | 230 | format = "(%d.%m.%Y|%A %d %B %Y)"; |
226 | syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); | 231 | syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); |
227 | if ( QApplication::desktop()->width() < 480 ) | 232 | if ( QApplication::desktop()->width() < 480 ) |
228 | format = "(%m.%d.%Y)"; | 233 | format = "(%m.%d.%Y)"; |
229 | else | 234 | else |
230 | format = "(%m.%d.%Y|%A %B %d %Y)"; | 235 | format = "(%m.%d.%Y|%A %B %d %Y)"; |
231 | syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); | 236 | syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); |
232 | if ( QApplication::desktop()->width() < 480 ) | 237 | if ( QApplication::desktop()->width() < 480 ) |
233 | format = "(%Y-%m-%d)"; | 238 | format = "(%Y-%m-%d)"; |
234 | else | 239 | else |
235 | format = "(%Y-%m-%d|%A %Y %B %d)"; | 240 | format = "(%Y-%m-%d|%A %Y %B %d)"; |
236 | syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); | 241 | syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); |
237 | syncPrefsGroup->addRadio(i18n("User defined")); | 242 | syncPrefsGroup->addRadio(i18n("User defined")); |
238 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 243 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
239 | ++iii; | 244 | ++iii; |
240 | ++iii; | 245 | ++iii; |
241 | QLabel * lab; | 246 | QLabel * lab; |
242 | mUserDateFormatLong = new QLineEdit(topFrame); | 247 | mUserDateFormatLong = new QLineEdit(topFrame); |
243 | lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); | 248 | lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); |
244 | topLayout->addWidget(lab ,iii,0); | 249 | topLayout->addWidget(lab ,iii,0); |
245 | topLayout->addWidget(mUserDateFormatLong,iii,1); | 250 | topLayout->addWidget(mUserDateFormatLong,iii,1); |
246 | ++iii; | 251 | ++iii; |
247 | mUserDateFormatShort = new QLineEdit(topFrame); | 252 | mUserDateFormatShort = new QLineEdit(topFrame); |
248 | lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); | 253 | lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); |
249 | topLayout->addWidget(lab ,iii,0); | 254 | topLayout->addWidget(lab ,iii,0); |
250 | topLayout->addWidget(mUserDateFormatShort,iii,1); | 255 | topLayout->addWidget(mUserDateFormatShort,iii,1); |
251 | ++iii; | 256 | ++iii; |
252 | lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); | 257 | lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); |
253 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 258 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
254 | ++iii; | 259 | ++iii; |
255 | lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); | 260 | lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); |
256 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 261 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
257 | ++iii; | 262 | ++iii; |
258 | lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); | 263 | lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); |
259 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 264 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
260 | ++iii; | 265 | ++iii; |
261 | 266 | ||
262 | } | 267 | } |
263 | 268 | ||
264 | void KOPrefsDialog::setupLocaleTab() | 269 | void KOPrefsDialog::setupLocaleTab() |
265 | { | 270 | { |
266 | QFrame *topFrame = addPage(i18n("Locale"),0,0); | 271 | QFrame *topFrame = addPage(i18n("Locale"),0,0); |
267 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 272 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
268 | topLayout->setSpacing(spacingHint()); | 273 | topLayout->setSpacing(spacingHint()); |
269 | topLayout->setMargin(marginHint()); | 274 | topLayout->setMargin(marginHint()); |
270 | int iii = 0; | 275 | int iii = 0; |
271 | KPrefsWidRadios *syncPrefsGroup = | 276 | KPrefsWidRadios *syncPrefsGroup = |
272 | addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); | 277 | addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); |
273 | syncPrefsGroup->addRadio(i18n("English")); | 278 | syncPrefsGroup->addRadio(i18n("English")); |
274 | syncPrefsGroup->addRadio(i18n("German")); | 279 | syncPrefsGroup->addRadio(i18n("German")); |
275 | syncPrefsGroup->addRadio(i18n("French")); | 280 | syncPrefsGroup->addRadio(i18n("French")); |
276 | syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); | 281 | syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); |
277 | if ( QApplication::desktop()->width() < 300 ) | 282 | if ( QApplication::desktop()->width() < 300 ) |
278 | ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 283 | ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
279 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 284 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
280 | ++iii; | 285 | ++iii; |
281 | 286 | ||
282 | syncPrefsGroup = | 287 | syncPrefsGroup = |
283 | addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); | 288 | addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); |
284 | if ( QApplication::desktop()->width() > 300 ) | 289 | if ( QApplication::desktop()->width() > 300 ) |
285 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 290 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
286 | syncPrefsGroup->addRadio(i18n("24:00")); | 291 | syncPrefsGroup->addRadio(i18n("24:00")); |
287 | syncPrefsGroup->addRadio(i18n("12:00am")); | 292 | syncPrefsGroup->addRadio(i18n("12:00am")); |
288 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 293 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
289 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 294 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
290 | ++iii; | 295 | ++iii; |
291 | KPrefsDialogWidBool *sb; | 296 | KPrefsDialogWidBool *sb; |
292 | if ( QApplication::desktop()->width() < 300 ) { | 297 | if ( QApplication::desktop()->width() < 300 ) { |
293 | sb = | 298 | sb = |
294 | addWidBool(i18n("Week starts on Sunday"), | 299 | addWidBool(i18n("Week starts on Sunday"), |
295 | &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); | 300 | &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); |
296 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 301 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
297 | ++iii; | 302 | ++iii; |
298 | sb = | 303 | sb = |
299 | addWidBool(i18n("Use short date in (WN/E) view"), | 304 | addWidBool(i18n("Use short date in (WN/E) view"), |
300 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); | 305 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); |
301 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 306 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
302 | } | 307 | } |
303 | else { | 308 | else { |
304 | QWidget * hb = new QWidget( topFrame ); | 309 | QWidget * hb = new QWidget( topFrame ); |
305 | QHBoxLayout *hbLayout = new QHBoxLayout(hb); | 310 | QHBoxLayout *hbLayout = new QHBoxLayout(hb); |
306 | sb = | 311 | sb = |
307 | addWidBool(i18n("Week starts on Sunday"), | 312 | addWidBool(i18n("Week starts on Sunday"), |
308 | &(KOPrefs::instance()->mWeekStartsOnSunday),hb); | 313 | &(KOPrefs::instance()->mWeekStartsOnSunday),hb); |
309 | hbLayout->addWidget(sb->checkBox() ); | 314 | hbLayout->addWidget(sb->checkBox() ); |
310 | sb = | 315 | sb = |
311 | addWidBool(i18n("Use short date in (WN/E) view"), | 316 | addWidBool(i18n("Use short date in (WN/E) view"), |
312 | &(KOPrefs::instance()->mShortDateInViewer),hb); | 317 | &(KOPrefs::instance()->mShortDateInViewer),hb); |
313 | hbLayout->addWidget(sb->checkBox() ); | 318 | hbLayout->addWidget(sb->checkBox() ); |
314 | topLayout->addMultiCellWidget(hb, iii,iii,0,1); | 319 | topLayout->addMultiCellWidget(hb, iii,iii,0,1); |
315 | 320 | ||
316 | } | 321 | } |
317 | //#ifndef DESKTOP_VERSION | 322 | //#ifndef DESKTOP_VERSION |
318 | #if 0 | 323 | #if 0 |
319 | ++iii; | 324 | ++iii; |
320 | sb = | 325 | sb = |
321 | addWidBool(i18n("Quick load/save (w/o Unicode)"), | 326 | addWidBool(i18n("Quick load/save (w/o Unicode)"), |
322 | &(KOPrefs::instance()->mUseQuicksave),topFrame); | 327 | &(KOPrefs::instance()->mUseQuicksave),topFrame); |
323 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 328 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
324 | #endif | 329 | #endif |
325 | } | 330 | } |
326 | void KOPrefsDialog::showSyncPage() | 331 | void KOPrefsDialog::showSyncPage() |
327 | { | 332 | { |
328 | showPage ( 2 ) ; | 333 | showPage ( 2 ) ; |
329 | 334 | ||
330 | } | 335 | } |
331 | void KOPrefsDialog::setupSyncAlgTab() | 336 | void KOPrefsDialog::setupSyncAlgTab() |
332 | { | 337 | { |
333 | #if 0 | 338 | #if 0 |
334 | QLabel * lab; | 339 | QLabel * lab; |
335 | QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); | 340 | QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); |
336 | mSetupSyncAlgTab = topFrame; | 341 | mSetupSyncAlgTab = topFrame; |
337 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 342 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
338 | topLayout->setSpacing(spacingHint()); | 343 | topLayout->setSpacing(spacingHint()); |
339 | topLayout->setMargin(marginHint()); | 344 | topLayout->setMargin(marginHint()); |
340 | int iii = 0; | 345 | int iii = 0; |
341 | 346 | ||
342 | KPrefsDialogWidBool *sb = | 347 | KPrefsDialogWidBool *sb = |
343 | addWidBool(i18n("Ask for preferences before syncing"), | 348 | addWidBool(i18n("Ask for preferences before syncing"), |
344 | &(KOPrefs::instance()->mAskForPreferences),topFrame); | 349 | &(KOPrefs::instance()->mAskForPreferences),topFrame); |
345 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 350 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
346 | 351 | ||
347 | ++iii; | 352 | ++iii; |
348 | 353 | ||
349 | KPrefsWidRadios *syncPrefsGroup = | 354 | KPrefsWidRadios *syncPrefsGroup = |
350 | addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), | 355 | addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), |
351 | topFrame); | 356 | topFrame); |
352 | syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 357 | syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
353 | syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 358 | syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
354 | syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 359 | syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
355 | syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 360 | syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
356 | syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 361 | syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
357 | syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 362 | syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
358 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 363 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
359 | ++iii; | 364 | ++iii; |
360 | sb = | 365 | sb = |
361 | addWidBool(i18n("Show summary after syncing"), | 366 | addWidBool(i18n("Show summary after syncing"), |
362 | &(KOPrefs::instance()->mShowSyncSummary),topFrame); | 367 | &(KOPrefs::instance()->mShowSyncSummary),topFrame); |
363 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 368 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
364 | 369 | ||
365 | ++iii; | 370 | ++iii; |
366 | #endif | 371 | #endif |
367 | 372 | ||
368 | 373 | ||
369 | 374 | ||
370 | } | 375 | } |
371 | 376 | ||
372 | 377 | ||
373 | void KOPrefsDialog::setupSyncTab() | 378 | void KOPrefsDialog::setupSyncTab() |
374 | { | 379 | { |
375 | #if 0 | 380 | #if 0 |
376 | QLabel * lab; | 381 | QLabel * lab; |
377 | QFrame *topFrame = addPage(i18n("Sync Network"),0,0); | 382 | QFrame *topFrame = addPage(i18n("Sync Network"),0,0); |
378 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 383 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
379 | topLayout->setSpacing(spacingHint()); | 384 | topLayout->setSpacing(spacingHint()); |
380 | topLayout->setMargin(marginHint()); | 385 | topLayout->setMargin(marginHint()); |
381 | lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); | 386 | lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); |
382 | int iii = 0; | 387 | int iii = 0; |
383 | topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 388 | topLayout->addMultiCellWidget(lab , iii,iii,0,1); |
384 | ++iii; | 389 | ++iii; |
385 | 390 | ||
386 | mRemoteIPEdit = new QLineEdit(topFrame); | 391 | mRemoteIPEdit = new QLineEdit(topFrame); |
387 | lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); | 392 | lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); |
388 | topLayout->addWidget(lab ,iii,0); | 393 | topLayout->addWidget(lab ,iii,0); |
389 | topLayout->addWidget(mRemoteIPEdit,iii,1); | 394 | topLayout->addWidget(mRemoteIPEdit,iii,1); |
390 | ++iii; | 395 | ++iii; |
391 | mRemoteUser = new QLineEdit(topFrame); | 396 | mRemoteUser = new QLineEdit(topFrame); |
392 | lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); | 397 | lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); |
393 | topLayout->addWidget(lab ,iii,0); | 398 | topLayout->addWidget(lab ,iii,0); |
394 | topLayout->addWidget(mRemoteUser, iii,1); | 399 | topLayout->addWidget(mRemoteUser, iii,1); |
395 | ++iii; | 400 | ++iii; |
396 | 401 | ||
397 | mRemoteFile = new QLineEdit(topFrame); | 402 | mRemoteFile = new QLineEdit(topFrame); |
398 | lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); | 403 | lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); |
399 | topLayout->addWidget(lab ,iii,0); | 404 | topLayout->addWidget(lab ,iii,0); |
400 | topLayout->addWidget(mRemoteFile,iii,1); | 405 | topLayout->addWidget(mRemoteFile,iii,1); |
401 | ++iii; | 406 | ++iii; |
402 | 407 | ||
403 | mLocalTempFile = new QLineEdit(topFrame); | 408 | mLocalTempFile = new QLineEdit(topFrame); |
404 | lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); | 409 | lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); |
405 | topLayout->addWidget(lab ,iii,0); | 410 | topLayout->addWidget(lab ,iii,0); |
406 | topLayout->addWidget(mLocalTempFile,iii,1); | 411 | topLayout->addWidget(mLocalTempFile,iii,1); |
407 | ++iii; | 412 | ++iii; |
408 | 413 | ||
409 | KPrefsDialogWidBool *wb = | 414 | KPrefsDialogWidBool *wb = |
410 | addWidBool(i18n("Write back synced file"), | 415 | addWidBool(i18n("Write back synced file"), |
411 | &(KOPrefs::instance()->mWriteBackFile),topFrame); | 416 | &(KOPrefs::instance()->mWriteBackFile),topFrame); |
412 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); | 417 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); |
413 | ++iii; | 418 | ++iii; |
414 | wb = | 419 | wb = |
415 | addWidBool(i18n("Write back existing entries only"), | 420 | addWidBool(i18n("Write back existing entries only"), |
416 | &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); | 421 | &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); |
417 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); | 422 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); |
418 | ++iii; | 423 | ++iii; |
419 | 424 | ||
420 | #endif | 425 | #endif |
421 | } | 426 | } |
422 | 427 | ||
423 | void KOPrefsDialog::setupMainTab() | 428 | void KOPrefsDialog::setupMainTab() |
424 | { | 429 | { |
425 | QFrame *topFrame = addPage(i18n("General"),0,0); | 430 | QFrame *topFrame = addPage(i18n("General"),0,0); |
426 | // DesktopIcon("identity",KIcon::SizeMedium)); | 431 | // DesktopIcon("identity",KIcon::SizeMedium)); |
427 | 432 | ||
428 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 433 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
429 | topLayout->setSpacing(spacingHint()); | 434 | topLayout->setSpacing(spacingHint()); |
430 | topLayout->setMargin(marginHint()); | 435 | topLayout->setMargin(marginHint()); |
431 | 436 | ||
432 | // KPrefsDialogWidBool *emailControlCenter = | 437 | // KPrefsDialogWidBool *emailControlCenter = |
433 | // addWidBool(i18n("&Use email settings from Control Center"), | 438 | // addWidBool(i18n("&Use email settings from Control Center"), |
434 | // &(KOPrefs::instance()->mEmailControlCenter),topFrame); | 439 | // &(KOPrefs::instance()->mEmailControlCenter),topFrame); |
435 | // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); | 440 | // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); |
436 | // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), | 441 | // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), |
437 | // SLOT(toggleEmailSettings(bool))); | 442 | // SLOT(toggleEmailSettings(bool))); |
438 | 443 | ||
439 | mNameEdit = new QLineEdit(topFrame); | 444 | mNameEdit = new QLineEdit(topFrame); |
440 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); | 445 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); |
441 | topLayout->addWidget(mNameLabel,0,0); | 446 | topLayout->addWidget(mNameLabel,0,0); |
442 | topLayout->addWidget(mNameEdit,0,1); | 447 | topLayout->addWidget(mNameEdit,0,1); |
443 | 448 | ||
444 | mEmailEdit = new QLineEdit(topFrame); | 449 | mEmailEdit = new QLineEdit(topFrame); |
445 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); | 450 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); |
446 | topLayout->addWidget(mEmailLabel,1,0); | 451 | topLayout->addWidget(mEmailLabel,1,0); |
447 | topLayout->addWidget(mEmailEdit,1,1); | 452 | topLayout->addWidget(mEmailEdit,1,1); |
448 | KPrefsDialogWidBool *wb; | 453 | KPrefsDialogWidBool *wb; |
449 | QHBox *dummy; | 454 | QHBox *dummy; |
450 | if ( QApplication::desktop()->width() > 480 ) { | 455 | if ( QApplication::desktop()->width() > 480 ) { |
451 | dummy = new QHBox(topFrame); | 456 | dummy = new QHBox(topFrame); |
452 | } else { | 457 | } else { |
453 | dummy = new QVBox(topFrame); | 458 | dummy = new QVBox(topFrame); |
454 | } | 459 | } |
455 | 460 | ||
456 | topLayout->addMultiCellWidget(dummy, 2,2,0,1); | 461 | topLayout->addMultiCellWidget(dummy, 2,2,0,1); |
457 | addWidBool(i18n("Full menu bar(nr)"), | 462 | addWidBool(i18n("Full menu bar(nr)"), |
458 | &(KOPrefs::instance()->mShowFullMenu),dummy); | 463 | &(KOPrefs::instance()->mShowFullMenu),dummy); |
459 | 464 | ||
460 | 465 | ||
461 | addWidBool(i18n("Mini icons in toolbar(nr)"), | 466 | addWidBool(i18n("Mini icons in toolbar(nr)"), |
462 | &(KOPrefs::instance()->mToolBarMiniIcons),dummy); | 467 | &(KOPrefs::instance()->mToolBarMiniIcons),dummy); |
463 | 468 | ||
464 | 469 | ||
465 | dummy = new QHBox(topFrame); | 470 | dummy = new QHBox(topFrame); |
466 | new QLabel(i18n("Days in What's Next:"),dummy); | 471 | new QLabel(i18n("Days in What's Next:"),dummy); |
467 | mWhatsNextSpin = new QSpinBox(1,14,1,dummy); | 472 | mWhatsNextSpin = new QSpinBox(1,14,1,dummy); |
468 | 473 | ||
469 | topLayout->addMultiCellWidget(dummy,3,3,0,1); | 474 | topLayout->addMultiCellWidget(dummy,3,3,0,1); |
470 | 475 | ||
471 | 476 | ||
472 | 477 | ||
473 | dummy = new QHBox(topFrame); | 478 | dummy = new QHBox(topFrame); |
474 | new QLabel(i18n("Days in Next-X-Days:"),dummy); | 479 | new QLabel(i18n("Days in Next-X-Days:"),dummy); |
475 | mNextXDaysSpin = new QSpinBox(2,14,1,dummy); | 480 | mNextXDaysSpin = new QSpinBox(2,14,1,dummy); |
476 | 481 | ||
477 | topLayout->addMultiCellWidget(dummy,4,4,0,1); | 482 | topLayout->addMultiCellWidget(dummy,4,4,0,1); |
478 | 483 | ||
479 | QHBox *prioBox = new QHBox(topFrame); | 484 | QHBox *prioBox = new QHBox(topFrame); |
480 | // intervalBox->setSpacing(spacingHint()); | 485 | // intervalBox->setSpacing(spacingHint()); |
481 | topLayout->addMultiCellWidget(prioBox,5,5,0,1); | 486 | topLayout->addMultiCellWidget(prioBox,5,5,0,1); |
482 | QString messa = i18n("Show topmost todo prios in What's Next:"); | 487 | QString messa = i18n("Show topmost todo prios in What's Next:"); |
483 | 488 | ||
484 | if ( QApplication::desktop()->width() < 300 ) | 489 | if ( QApplication::desktop()->width() < 300 ) |
485 | messa = i18n("Show topmost todo prios in What's N.:"); | 490 | messa = i18n("Show topmost todo prios in What's N.:"); |
486 | QLabel *prioLabel = new QLabel(messa, prioBox); | 491 | QLabel *prioLabel = new QLabel(messa, prioBox); |
487 | mPrioSpin = new QSpinBox(0,5,1,prioBox); | 492 | mPrioSpin = new QSpinBox(0,5,1,prioBox); |
488 | if ( QApplication::desktop()->width() < 300 ) | 493 | if ( QApplication::desktop()->width() < 300 ) |
489 | mPrioSpin->setFixedWidth( 40 ); | 494 | mPrioSpin->setFixedWidth( 40 ); |
490 | 495 | ||
491 | // KPrefsDialogWidBool *bcc = | 496 | // KPrefsDialogWidBool *bcc = |
492 | // addWidBool(i18n("Send copy to owner when mailing events"), | 497 | // addWidBool(i18n("Send copy to owner when mailing events"), |
493 | // &(KOPrefs::instance()->mBcc),topFrame); | 498 | // &(KOPrefs::instance()->mBcc),topFrame); |
494 | // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); | 499 | // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); |
495 | 500 | ||
496 | 501 | ||
497 | // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); | 502 | // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); |
498 | //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); | 503 | //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); |
499 | 504 | ||
500 | // addWidBool(i18n("Enable automatic saving of calendar"), | 505 | // addWidBool(i18n("Enable automatic saving of calendar"), |
501 | // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); | 506 | // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); |
502 | 507 | ||
503 | QHBox *intervalBox = new QHBox(topFrame); | 508 | QHBox *intervalBox = new QHBox(topFrame); |
504 | // intervalBox->setSpacing(spacingHint()); | 509 | // intervalBox->setSpacing(spacingHint()); |
505 | topLayout->addMultiCellWidget(intervalBox,6,6,0,1); | 510 | topLayout->addMultiCellWidget(intervalBox,6,6,0,1); |
506 | QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); | 511 | QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); |
507 | mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); | 512 | mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); |
508 | autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); | 513 | autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); |
509 | /* | 514 | /* |
510 | QHBox * agendasize = new QHBox ( topFrame ); | 515 | QHBox * agendasize = new QHBox ( topFrame ); |
511 | 516 | ||
512 | new QLabel (i18n("AllDayAgenda Height:"), agendasize ); | 517 | new QLabel (i18n("AllDayAgenda Height:"), agendasize ); |
513 | 518 | ||
514 | 519 | ||
515 | mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); | 520 | mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); |
516 | topLayout->addMultiCellWidget(agendasize,7,7,0,1); | 521 | topLayout->addMultiCellWidget(agendasize,7,7,0,1); |
517 | */ | 522 | */ |
518 | KPrefsDialogWidBool *verticalScreen = | 523 | KPrefsDialogWidBool *verticalScreen = |
519 | addWidBool(i18n("Show vertical screen (Needs restart)"), | 524 | addWidBool(i18n("Show vertical screen (Needs restart)"), |
520 | &(KOPrefs::instance()->mVerticalScreen),topFrame); | 525 | &(KOPrefs::instance()->mVerticalScreen),topFrame); |
521 | //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); | 526 | //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); |
522 | topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1); | 527 | topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1); |
523 | 528 | ||
524 | KPrefsDialogWidBool *ask = | 529 | KPrefsDialogWidBool *ask = |
525 | addWidBool(i18n("Ask for quit when closing KO/Pi"), | 530 | addWidBool(i18n("Ask for quit when closing KO/Pi"), |
526 | &(KOPrefs::instance()->mAskForQuit),topFrame); | 531 | &(KOPrefs::instance()->mAskForQuit),topFrame); |
527 | topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1); | 532 | topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1); |
528 | 533 | ||
529 | 534 | ||
530 | /* | 535 | /* |
531 | KPrefsDialogWidBool *confirmCheck = | 536 | KPrefsDialogWidBool *confirmCheck = |
532 | addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), | 537 | addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), |
533 | topFrame); | 538 | topFrame); |
534 | topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); | 539 | topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); |
535 | 540 | ||
536 | 541 | ||
537 | mEnableGroupScheduling = | 542 | mEnableGroupScheduling = |
538 | addWidBool(i18n("Enable group scheduling"), | 543 | addWidBool(i18n("Enable group scheduling"), |
539 | &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); | 544 | &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); |
540 | topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); | 545 | topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); |
541 | connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), | 546 | connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), |
542 | SLOT(warningGroupScheduling())); | 547 | SLOT(warningGroupScheduling())); |
543 | 548 | ||
544 | mEnableProjectView = | 549 | mEnableProjectView = |
545 | addWidBool(i18n("Enable project view"), | 550 | addWidBool(i18n("Enable project view"), |
546 | &(KOPrefs::instance()->mEnableProjectView),topFrame); | 551 | &(KOPrefs::instance()->mEnableProjectView),topFrame); |
547 | topLayout->addWidget(mEnableProjectView->checkBox(),9,0); | 552 | topLayout->addWidget(mEnableProjectView->checkBox(),9,0); |
548 | connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), | 553 | connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), |
549 | SLOT(warningProjectView())); | 554 | SLOT(warningProjectView())); |
550 | 555 | ||
551 | // Can't be disabled anymore | 556 | // Can't be disabled anymore |
552 | mEnableGroupScheduling->checkBox()->hide(); | 557 | mEnableGroupScheduling->checkBox()->hide(); |
553 | 558 | ||
554 | // Disable setting, because this feature now becomes stable | 559 | // Disable setting, because this feature now becomes stable |
555 | mEnableProjectView->checkBox()->hide(); | 560 | mEnableProjectView->checkBox()->hide(); |
556 | 561 | ||
557 | KPrefsWidRadios *defaultFormatGroup = | 562 | KPrefsWidRadios *defaultFormatGroup = |
558 | addWidRadios(i18n("Default Calendar Format"), | 563 | addWidRadios(i18n("Default Calendar Format"), |
559 | &(KOPrefs::instance()->mDefaultFormat),topFrame); | 564 | &(KOPrefs::instance()->mDefaultFormat),topFrame); |
560 | defaultFormatGroup->addRadio(i18n("vCalendar")); | 565 | defaultFormatGroup->addRadio(i18n("vCalendar")); |
561 | defaultFormatGroup->addRadio(i18n("iCalendar")); | 566 | defaultFormatGroup->addRadio(i18n("iCalendar")); |
562 | 567 | ||
563 | topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); | 568 | topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); |
564 | 569 | ||
565 | // Default format unconditionally is iCalendar | 570 | // Default format unconditionally is iCalendar |
566 | defaultFormatGroup->groupBox()->hide(); | 571 | defaultFormatGroup->groupBox()->hide(); |
567 | 572 | ||
568 | KPrefsWidRadios *mailClientGroup = | 573 | KPrefsWidRadios *mailClientGroup = |
569 | addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), | 574 | addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), |
570 | topFrame); | 575 | topFrame); |
571 | mailClientGroup->addRadio(i18n("KMail")); | 576 | mailClientGroup->addRadio(i18n("KMail")); |
572 | mailClientGroup->addRadio(i18n("Sendmail")); | 577 | mailClientGroup->addRadio(i18n("Sendmail")); |
573 | topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); | 578 | topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); |
574 | 579 | ||
575 | KPrefsDialogWidBool *htmlsave = | 580 | KPrefsDialogWidBool *htmlsave = |
576 | addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), | 581 | addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), |
577 | topFrame); | 582 | topFrame); |
578 | topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); | 583 | topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); |
579 | 584 | ||
580 | KPrefsWidRadios *destinationGroup = | 585 | KPrefsWidRadios *destinationGroup = |
581 | addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), | 586 | addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), |
582 | topFrame); | 587 | topFrame); |
583 | destinationGroup->addRadio(i18n("be added to the standard resource")); | 588 | destinationGroup->addRadio(i18n("be added to the standard resource")); |
584 | destinationGroup->addRadio(i18n("be asked which resource to use")); | 589 | destinationGroup->addRadio(i18n("be asked which resource to use")); |
585 | topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); | 590 | topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); |
586 | 591 | ||
587 | topLayout->setRowStretch(14,1); | 592 | topLayout->setRowStretch(14,1); |
588 | */ | 593 | */ |
diff --git a/kmicromail/koprefsdialog.h b/kmicromail/koprefsdialog.h index 615574b..a0416ae 100644 --- a/kmicromail/koprefsdialog.h +++ b/kmicromail/koprefsdialog.h | |||
@@ -1,179 +1,180 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KOPREFSDIALOG_H | 23 | #ifndef _KOPREFSDIALOG_H |
24 | #define _KOPREFSDIALOG_H | 24 | #define _KOPREFSDIALOG_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdict.h> | 27 | #include <qdict.h> |
28 | #include <qcolor.h> | 28 | #include <qcolor.h> |
29 | #include <qlistview.h> | 29 | #include <qlistview.h> |
30 | 30 | ||
31 | #include <kdialogbase.h> | 31 | #include <kdialogbase.h> |
32 | 32 | ||
33 | #include <libkdepim/kprefsdialog.h> | 33 | #include <libkdepim/kprefsdialog.h> |
34 | #include <libkdepim/kdateedit.h> | 34 | #include <libkdepim/kdateedit.h> |
35 | #include <kcmconfigs/kdepimconfigwidget.h> | 35 | #include <kcmconfigs/kdepimconfigwidget.h> |
36 | 36 | ||
37 | class KColorButton; | 37 | class KColorButton; |
38 | class QSpinBox; | 38 | class QSpinBox; |
39 | class QSlider; | 39 | class QSlider; |
40 | class KURLRequester; | 40 | class KURLRequester; |
41 | class QComboBox; | 41 | class QComboBox; |
42 | class QLineEdit; | 42 | class QLineEdit; |
43 | class QStringList; | 43 | class QStringList; |
44 | 44 | ||
45 | /** Dialog to change the korganizer configuration. | 45 | /** Dialog to change the korganizer configuration. |
46 | */ | 46 | */ |
47 | class KOPrefsDialog : public KPrefsDialog | 47 | class KOPrefsDialog : public KPrefsDialog |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | /** Initialize dialog and pages */ | 51 | /** Initialize dialog and pages */ |
52 | KOPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); | 52 | KOPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); |
53 | ~KOPrefsDialog(); | 53 | ~KOPrefsDialog(); |
54 | 54 | ||
55 | protected: | 55 | protected: |
56 | void usrReadConfig(); | 56 | void usrReadConfig(); |
57 | void usrWriteConfig(); | 57 | void usrWriteConfig(); |
58 | 58 | ||
59 | void setupMainTab(); | 59 | void setupMainTab(); |
60 | void setupGlobalTab(); | 60 | void setupGlobalTab(); |
61 | void setupMailTab(); | 61 | void setupMailTab(); |
62 | void setupFontsTab(); | 62 | void setupFontsTab(); |
63 | private: | 63 | private: |
64 | KDEPIMConfigWidget* kdelibcfg; | 64 | KDEPIMConfigWidget* kdelibcfg; |
65 | QLineEdit *mNameEdit; | 65 | QLineEdit *mNameEdit; |
66 | QLineEdit *mCodecEdit; | ||
66 | QLineEdit *mEmailEdit; | 67 | QLineEdit *mEmailEdit; |
67 | QLabel *mNameLabel; | 68 | QLabel *mNameLabel; |
68 | QLabel *mEmailLabel; | 69 | QLabel *mEmailLabel; |
69 | #if 0 | 70 | #if 0 |
70 | /* | 71 | /* |
71 | public slots: | 72 | public slots: |
72 | void showPrinterTab(); | 73 | void showPrinterTab(); |
73 | 74 | ||
74 | 75 | ||
75 | void updateCategories(); | 76 | void updateCategories(); |
76 | void showSyncPage(); | 77 | void showSyncPage(); |
77 | protected slots: | 78 | protected slots: |
78 | void selectSoundFile(); | 79 | void selectSoundFile(); |
79 | void setCategoryColor(); | 80 | void setCategoryColor(); |
80 | void updateCategoryColor(); | 81 | void updateCategoryColor(); |
81 | void updateTimezoneOffset( int ); | 82 | void updateTimezoneOffset( int ); |
82 | 83 | ||
83 | 84 | ||
84 | void warningExperimental(bool on); | 85 | void warningExperimental(bool on); |
85 | void warningGroupScheduling(); | 86 | void warningGroupScheduling(); |
86 | void warningProjectView(); | 87 | void warningProjectView(); |
87 | 88 | ||
88 | void toggleEmailSettings(bool); | 89 | void toggleEmailSettings(bool); |
89 | 90 | ||
90 | //additional emails | 91 | //additional emails |
91 | void addItem(); | 92 | void addItem(); |
92 | void removeItem(); | 93 | void removeItem(); |
93 | void updateItem(); | 94 | void updateItem(); |
94 | void updateInput(); | 95 | void updateInput(); |
95 | */ | 96 | */ |
96 | protected: | 97 | protected: |
97 | void usrReadConfig(); | 98 | void usrReadConfig(); |
98 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
99 | 100 | ||
100 | void setupMainTab(); | 101 | void setupMainTab(); |
101 | void setupTimeTab(); | 102 | void setupTimeTab(); |
102 | void setupTimeZoneTab(); | 103 | void setupTimeZoneTab(); |
103 | void setupLocaleTab(); | 104 | void setupLocaleTab(); |
104 | void setupLocaleDateTab(); | 105 | void setupLocaleDateTab(); |
105 | void setupFontsTab(); | 106 | void setupFontsTab(); |
106 | void setupColorsTab(); | 107 | void setupColorsTab(); |
107 | void setupViewsTab(); | 108 | void setupViewsTab(); |
108 | void setupDisplayTab(); | 109 | void setupDisplayTab(); |
109 | void setupPrinterTab(); | 110 | void setupPrinterTab(); |
110 | void setupGroupSchedulingTab(); | 111 | void setupGroupSchedulingTab(); |
111 | void setupGroupAutomationTab(); | 112 | void setupGroupAutomationTab(); |
112 | void setupSyncTab(); | 113 | void setupSyncTab(); |
113 | void setupSyncAlgTab(); | 114 | void setupSyncAlgTab(); |
114 | 115 | ||
115 | void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0); | 116 | void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0); |
116 | 117 | ||
117 | 118 | ||
118 | private: | 119 | private: |
119 | KPrefsWidBool *mEnableGroupScheduling; | 120 | KPrefsWidBool *mEnableGroupScheduling; |
120 | KPrefsWidBool *mEnableProjectView; | 121 | KPrefsWidBool *mEnableProjectView; |
121 | 122 | ||
122 | QFrame *mPrinterTab; | 123 | QFrame *mPrinterTab; |
123 | 124 | ||
124 | QLineEdit *nameEdit; | 125 | QLineEdit *nameEdit; |
125 | QLineEdit *emailEdit; | 126 | QLineEdit *emailEdit; |
126 | 127 | ||
127 | QComboBox *timeCombo; | 128 | QComboBox *timeCombo; |
128 | QComboBox *tzCombo; | 129 | QComboBox *tzCombo; |
129 | 130 | ||
130 | // widgets holding preferences data | 131 | // widgets holding preferences data |
131 | QLineEdit *mNameEdit; | 132 | QLineEdit *mNameEdit; |
132 | QLineEdit *mEmailEdit; | 133 | QLineEdit *mEmailEdit; |
133 | QLabel *mNameLabel; | 134 | QLabel *mNameLabel; |
134 | QLabel *mEmailLabel; | 135 | QLabel *mEmailLabel; |
135 | QLineEdit *mAdditionalEdit; | 136 | QLineEdit *mAdditionalEdit; |
136 | QSpinBox *mAutoSaveIntervalSpin; | 137 | QSpinBox *mAutoSaveIntervalSpin; |
137 | QSpinBox *mPrioSpin; | 138 | QSpinBox *mPrioSpin; |
138 | // QListView *mAMails; | 139 | // QListView *mAMails; |
139 | QLineEdit *aEmailsEdit; | 140 | QLineEdit *aEmailsEdit; |
140 | 141 | ||
141 | QComboBox *mTimeZoneCombo; | 142 | QComboBox *mTimeZoneCombo; |
142 | QStringList tzonenames; | 143 | QStringList tzonenames; |
143 | QSpinBox *mStartTimeSpin; | 144 | QSpinBox *mStartTimeSpin; |
144 | QSpinBox *mDefaultDurationSpin; | 145 | QSpinBox *mDefaultDurationSpin; |
145 | QComboBox *mAlarmTimeCombo; | 146 | QComboBox *mAlarmTimeCombo; |
146 | 147 | ||
147 | QComboBox *mCategoryCombo; | 148 | QComboBox *mCategoryCombo; |
148 | KColorButton *mCategoryButton; | 149 | KColorButton *mCategoryButton; |
149 | QDict<QColor> mCategoryDict; | 150 | QDict<QColor> mCategoryDict; |
150 | 151 | ||
151 | QSlider *mHourSizeSlider; | 152 | QSlider *mHourSizeSlider; |
152 | 153 | ||
153 | QSpinBox *mNextXDaysSpin; | 154 | QSpinBox *mNextXDaysSpin; |
154 | QSpinBox *mWhatsNextSpin; | 155 | QSpinBox *mWhatsNextSpin; |
155 | 156 | ||
156 | QLineEdit * mRemoteIPEdit; | 157 | QLineEdit * mRemoteIPEdit; |
157 | QLineEdit * mRemoteUser; | 158 | QLineEdit * mRemoteUser; |
158 | QLineEdit * mRemotePassWd; | 159 | QLineEdit * mRemotePassWd; |
159 | QLineEdit * mRemoteFile; | 160 | QLineEdit * mRemoteFile; |
160 | QLineEdit * mLocalTempFile; | 161 | QLineEdit * mLocalTempFile; |
161 | QWidget* mSetupSyncAlgTab; | 162 | QWidget* mSetupSyncAlgTab; |
162 | QLineEdit * mUserDateFormatLong; | 163 | QLineEdit * mUserDateFormatLong; |
163 | QLineEdit * mUserDateFormatShort; | 164 | QLineEdit * mUserDateFormatShort; |
164 | 165 | ||
165 | QSpinBox *mTimezoneOffsetSpin; | 166 | QSpinBox *mTimezoneOffsetSpin; |
166 | QSpinBox *mDaylightsavingStart; | 167 | QSpinBox *mDaylightsavingStart; |
167 | QSpinBox *mDaylightsavingEnd; | 168 | QSpinBox *mDaylightsavingEnd; |
168 | KDateEdit* mStartDateSavingEdit; | 169 | KDateEdit* mStartDateSavingEdit; |
169 | KDateEdit* mEndDateSavingEdit; | 170 | KDateEdit* mEndDateSavingEdit; |
170 | QSpinBox * mAlarmPlayBeeps; | 171 | QSpinBox * mAlarmPlayBeeps; |
171 | QSpinBox * mAlarmSuspendTime; | 172 | QSpinBox * mAlarmSuspendTime; |
172 | QSpinBox * mAlarmSuspendCount; | 173 | QSpinBox * mAlarmSuspendCount; |
173 | QSpinBox * mAlarmBeepInterval; | 174 | QSpinBox * mAlarmBeepInterval; |
174 | 175 | ||
175 | QLineEdit * mDefaultAlarmFile; | 176 | QLineEdit * mDefaultAlarmFile; |
176 | #endif | 177 | #endif |
177 | }; | 178 | }; |
178 | 179 | ||
179 | #endif | 180 | #endif |
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c index dbaeb68..b2ab0f7 100644 --- a/kmicromail/libetpan/mime/mailmime_decode.c +++ b/kmicromail/libetpan/mime/mailmime_decode.c | |||
@@ -1,544 +1,559 @@ | |||
1 | /* | 1 | /* |
2 | * libEtPan! -- a mail stuff library | 2 | * libEtPan! -- a mail stuff library |
3 | * | 3 | * |
4 | * Copyright (C) 2001, 2002 - DINH Viet Hoa | 4 | * Copyright (C) 2001, 2002 - DINH Viet Hoa |
5 | * All rights reserved. | 5 | * All rights reserved. |
6 | * | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. |
15 | * 3. Neither the name of the libEtPan! project nor the names of its | 15 | * 3. Neither the name of the libEtPan! project nor the names of its |
16 | * contributors may be used to endorse or promote products derived | 16 | * contributors may be used to endorse or promote products derived |
17 | * from this software without specific prior written permission. | 17 | * from this software without specific prior written permission. |
18 | * | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * $Id$ | 33 | * $Id$ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | /* | 36 | /* |
37 | RFC 2047 : MIME (Multipurpose Internet Mail Extensions) Part Three: | 37 | RFC 2047 : MIME (Multipurpose Internet Mail Extensions) Part Three: |
38 | Message Header Extensions for Non-ASCII Text | 38 | Message Header Extensions for Non-ASCII Text |
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "mailmime_decode.h" | 41 | #include "mailmime_decode.h" |
42 | 42 | ||
43 | #include <ctype.h> | 43 | #include <ctype.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/mman.h> | 45 | #include <sys/mman.h> |
46 | #include <string.h> | 46 | #include <string.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | 48 | ||
49 | #include "mailmime_content.h" | 49 | #include "mailmime_content.h" |
50 | 50 | ||
51 | #include "charconv.h" | 51 | #include "charconv.h" |
52 | #include "mmapstring.h" | 52 | #include "mmapstring.h" |
53 | #include "mailimf.h" | 53 | #include "mailimf.h" |
54 | 54 | ||
55 | #ifndef TRUE | 55 | #ifndef TRUE |
56 | #define TRUE 1 | 56 | #define TRUE 1 |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #ifndef FALSE | 59 | #ifndef FALSE |
60 | #define FALSE 0 | 60 | #define FALSE 0 |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | static int mailmime_charset_parse(const char * message, size_t length, | 63 | static int mailmime_charset_parse(const char * message, size_t length, |
64 | size_t * index, char ** charset); | 64 | size_t * index, char ** charset); |
65 | 65 | ||
66 | enum { | 66 | enum { |
67 | MAILMIME_ENCODING_B, | 67 | MAILMIME_ENCODING_B, |
68 | MAILMIME_ENCODING_Q | 68 | MAILMIME_ENCODING_Q |
69 | }; | 69 | }; |
70 | 70 | ||
71 | static int mailmime_encoding_parse(const char * message, size_t length, | 71 | static int mailmime_encoding_parse(const char * message, size_t length, |
72 | size_t * index, int * result); | 72 | size_t * index, int * result); |
73 | 73 | ||
74 | static int mailmime_etoken_parse(const char * message, size_t length, | 74 | static int mailmime_etoken_parse(const char * message, size_t length, |
75 | size_t * index, char ** result); | 75 | size_t * index, char ** result); |
76 | 76 | ||
77 | static int | 77 | static int |
78 | mailmime_non_encoded_word_parse(const char * message, size_t length, | 78 | mailmime_non_encoded_word_parse(const char * message, size_t length, |
79 | size_t * index, | 79 | size_t * index, |
80 | char ** result); | 80 | char ** result); |
81 | 81 | ||
82 | static int | 82 | static int |
83 | mailmime_encoded_word_parse(const char * message, size_t length, | 83 | mailmime_encoded_word_parse(const char * message, size_t length, |
84 | size_t * index, | 84 | size_t * index, |
85 | struct mailmime_encoded_word ** result); | 85 | struct mailmime_encoded_word ** result); |
86 | 86 | ||
87 | 87 | ||
88 | enum { | 88 | enum { |
89 | TYPE_ERROR, | 89 | TYPE_ERROR, |
90 | TYPE_WORD, | 90 | TYPE_WORD, |
91 | TYPE_ENCODED_WORD, | 91 | TYPE_ENCODED_WORD, |
92 | }; | 92 | }; |
93 | 93 | ||
94 | int mailmime_encoded_phrase_parse(const char * default_fromcode, | 94 | int mailmime_encoded_phrase_parse(const char * default_fromcode, |
95 | const char * message, size_t length, | 95 | const char * message, size_t length, |
96 | size_t * index, const char * tocode, | 96 | size_t * index, const char * tocode, |
97 | char ** result) | 97 | char ** result) |
98 | { | 98 | { |
99 | MMAPString * gphrase; | 99 | MMAPString * gphrase; |
100 | struct mailmime_encoded_word * word; | 100 | struct mailmime_encoded_word * word; |
101 | int first; | 101 | int first; |
102 | size_t cur_token; | 102 | size_t cur_token; |
103 | int r; | 103 | int r; |
104 | int res; | 104 | int res; |
105 | char * str; | 105 | char * str; |
106 | char * wordutf8; | 106 | char * wordutf8; |
107 | int type; | 107 | int type; |
108 | 108 | ||
109 | cur_token = * index; | 109 | cur_token = * index; |
110 | 110 | ||
111 | gphrase = mmap_string_new(""); | 111 | gphrase = mmap_string_new(""); |
112 | if (gphrase == NULL) { | 112 | if (gphrase == NULL) { |
113 | res = MAILIMF_ERROR_MEMORY; | 113 | res = MAILIMF_ERROR_MEMORY; |
114 | goto err; | 114 | goto err; |
115 | } | 115 | } |
116 | 116 | ||
117 | first = TRUE; | 117 | first = TRUE; |
118 | 118 | ||
119 | type = TYPE_ERROR; /* XXX - removes a gcc warning */ | 119 | type = TYPE_ERROR; /* XXX - removes a gcc warning */ |
120 | // LUTZ add | ||
121 | int appendNewLine = FALSE; | ||
122 | while (1) { //while | ||
120 | 123 | ||
121 | while (1) { | 124 | r = mailmime_encoded_word_parse(message, length, &cur_token, &word); |
122 | 125 | if (r == MAILIMF_NO_ERROR) { | |
123 | r = mailmime_encoded_word_parse(message, length, &cur_token, &word); | 126 | if (!first) { |
124 | if (r == MAILIMF_NO_ERROR) { | 127 | if (type != TYPE_ENCODED_WORD) { |
125 | if (!first) { | 128 | if (mmap_string_append_c(gphrase, ' ') == NULL) { |
126 | if (type != TYPE_ENCODED_WORD) { | 129 | mailmime_encoded_word_free(word); |
127 | if (mmap_string_append_c(gphrase, ' ') == NULL) { | 130 | res = MAILIMF_ERROR_MEMORY; |
128 | mailmime_encoded_word_free(word); | 131 | goto free; |
129 | res = MAILIMF_ERROR_MEMORY; | 132 | } |
130 | goto free; | 133 | } |
131 | } | 134 | } |
132 | } | 135 | type = TYPE_ENCODED_WORD; |
133 | } | 136 | wordutf8 = NULL; |
134 | type = TYPE_ENCODED_WORD; | 137 | r = charconv(tocode, word->wd_charset, word->wd_text, |
135 | wordutf8 = NULL; | 138 | strlen(word->wd_text), &wordutf8); |
136 | r = charconv(tocode, word->wd_charset, word->wd_text, | 139 | switch (r) { |
137 | strlen(word->wd_text), &wordutf8); | 140 | case MAIL_CHARCONV_ERROR_MEMORY: |
138 | switch (r) { | 141 | mailmime_encoded_word_free(word); |
139 | case MAIL_CHARCONV_ERROR_MEMORY: | 142 | res = MAILIMF_ERROR_MEMORY; |
140 | mailmime_encoded_word_free(word); | 143 | goto free; |
141 | res = MAILIMF_ERROR_MEMORY; | 144 | |
142 | goto free; | 145 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: |
143 | 146 | case MAIL_CHARCONV_ERROR_CONV: | |
144 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: | 147 | mailmime_encoded_word_free(word); |
145 | case MAIL_CHARCONV_ERROR_CONV: | 148 | res = MAILIMF_ERROR_PARSE; |
146 | mailmime_encoded_word_free(word); | 149 | goto free; |
147 | res = MAILIMF_ERROR_PARSE; | 150 | } |
148 | goto free; | ||
149 | } | ||
150 | 151 | ||
151 | if (wordutf8 != NULL) { | 152 | if (wordutf8 != NULL) { |
152 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 153 | if (mmap_string_append(gphrase, wordutf8) == NULL) { |
154 | mailmime_encoded_word_free(word); | ||
155 | free(wordutf8); | ||
156 | res = MAILIMF_ERROR_MEMORY; | ||
157 | goto free; | ||
158 | } | ||
159 | free(wordutf8); | ||
160 | } | ||
153 | mailmime_encoded_word_free(word); | 161 | mailmime_encoded_word_free(word); |
154 | free(wordutf8); | 162 | first = FALSE; |
155 | res = MAILIMF_ERROR_MEMORY; | 163 | } |
164 | else if (r == MAILIMF_ERROR_PARSE) { | ||
165 | /* do nothing */ | ||
166 | } | ||
167 | else { | ||
168 | res = r; | ||
156 | goto free; | 169 | goto free; |
157 | } | ||
158 | free(wordutf8); | ||
159 | } | 170 | } |
160 | mailmime_encoded_word_free(word); | ||
161 | first = FALSE; | ||
162 | } | ||
163 | else if (r == MAILIMF_ERROR_PARSE) { | ||
164 | /* do nothing */ | ||
165 | } | ||
166 | else { | ||
167 | res = r; | ||
168 | goto free; | ||
169 | } | ||
170 | |||
171 | if (r == MAILIMF_ERROR_PARSE) { | ||
172 | char * raw_word; | ||
173 | 171 | ||
174 | r = mailmime_non_encoded_word_parse(message, length, | 172 | if (r == MAILIMF_ERROR_PARSE) { |
175 | &cur_token, &raw_word); | 173 | char * raw_word; |
176 | if (r == MAILIMF_NO_ERROR) { | 174 | |
177 | if (!first) { | 175 | r = mailmime_non_encoded_word_parse(message, length, |
178 | if (mmap_string_append_c(gphrase, ' ') == NULL) { | 176 | &cur_token, &raw_word); |
179 | free(raw_word); | 177 | if (r == MAILIMF_NO_ERROR) { |
180 | res = MAILIMF_ERROR_MEMORY; | 178 | if (!first) { |
181 | goto free; | 179 | if (mmap_string_append_c(gphrase, ' ') == NULL) { |
182 | } | 180 | free(raw_word); |
183 | } | 181 | res = MAILIMF_ERROR_MEMORY; |
184 | type = TYPE_WORD; | 182 | goto free; |
183 | } | ||
184 | } | ||
185 | type = TYPE_WORD; | ||
185 | 186 | ||
186 | wordutf8 = NULL; | 187 | wordutf8 = NULL; |
187 | r = charconv(tocode, default_fromcode, raw_word, | 188 | r = charconv(tocode, default_fromcode, raw_word, |
188 | strlen(raw_word), &wordutf8); | 189 | strlen(raw_word), &wordutf8); |
189 | 190 | ||
190 | switch (r) { | 191 | switch (r) { |
191 | case MAIL_CHARCONV_ERROR_MEMORY: | 192 | case MAIL_CHARCONV_ERROR_MEMORY: |
192 | free(raw_word); | 193 | free(raw_word); |
193 | res = MAILIMF_ERROR_MEMORY; | 194 | res = MAILIMF_ERROR_MEMORY; |
194 | goto free; | 195 | goto free; |
195 | 196 | ||
196 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: | 197 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: |
197 | case MAIL_CHARCONV_ERROR_CONV: | 198 | case MAIL_CHARCONV_ERROR_CONV: |
198 | free(raw_word); | 199 | free(raw_word); |
199 | res = MAILIMF_ERROR_PARSE; | 200 | res = MAILIMF_ERROR_PARSE; |
200 | goto free; | 201 | goto free; |
201 | } | 202 | } |
202 | 203 | // LUTZ add | |
203 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 204 | if ( appendNewLine ) { |
204 | free(wordutf8); | 205 | appendNewLine = FALSE; |
205 | free(raw_word); | 206 | if (mmap_string_append(gphrase, "\n") == NULL) { |
206 | res = MAILIMF_ERROR_MEMORY; | 207 | free(wordutf8); |
207 | goto free; | 208 | free(raw_word); |
208 | } | 209 | res = MAILIMF_ERROR_MEMORY; |
209 | // LUTZ fix | 210 | goto free; |
210 | free(wordutf8); | 211 | } |
211 | free(raw_word); | 212 | } |
212 | first = FALSE; | 213 | //fprintf(stderr,"append *%s* \n",wordutf8 ); |
214 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | ||
215 | free(wordutf8); | ||
216 | free(raw_word); | ||
217 | res = MAILIMF_ERROR_MEMORY; | ||
218 | goto free; | ||
219 | } | ||
220 | // LUTZ fix | ||
221 | free(wordutf8); | ||
222 | free(raw_word); | ||
223 | first = FALSE; | ||
224 | } | ||
225 | else if (r == MAILIMF_ERROR_PARSE) { | ||
226 | // LUTZ add | ||
227 | if ( cur_token >= length ) | ||
228 | break; | ||
229 | ++cur_token; | ||
230 | appendNewLine = TRUE; | ||
231 | } | ||
232 | else { | ||
233 | res = r; | ||
234 | goto free; | ||
235 | } | ||
213 | } | 236 | } |
214 | else if (r == MAILIMF_ERROR_PARSE) { | ||
215 | break; | ||
216 | } | ||
217 | else { | ||
218 | res = r; | ||
219 | goto free; | ||
220 | } | ||
221 | } | ||
222 | } | 237 | } |
223 | 238 | ||
224 | if (first) { | 239 | if (first) { |
225 | res = MAILIMF_ERROR_PARSE; | 240 | res = MAILIMF_ERROR_PARSE; |
226 | goto free; | 241 | goto free; |
227 | } | 242 | } |
228 | 243 | ||
229 | str = strdup(gphrase->str); | 244 | str = strdup(gphrase->str); |
230 | if (str == NULL) { | 245 | if (str == NULL) { |
231 | res = MAILIMF_ERROR_MEMORY; | 246 | res = MAILIMF_ERROR_MEMORY; |
232 | goto free; | 247 | goto free; |
233 | } | 248 | } |
234 | mmap_string_free(gphrase); | 249 | mmap_string_free(gphrase); |
235 | 250 | ||
236 | * result = str; | 251 | * result = str; |
237 | * index = cur_token; | 252 | * index = cur_token; |
238 | 253 | ||
239 | return MAILIMF_NO_ERROR; | 254 | return MAILIMF_NO_ERROR; |
240 | 255 | ||
241 | free: | 256 | free: |
242 | mmap_string_free(gphrase); | 257 | mmap_string_free(gphrase); |
243 | err: | 258 | err: |
244 | return res; | 259 | return res; |
245 | } | 260 | } |
246 | 261 | ||
247 | static int | 262 | static int |
248 | mailmime_non_encoded_word_parse(const char * message, size_t length, | 263 | mailmime_non_encoded_word_parse(const char * message, size_t length, |
249 | size_t * index, | 264 | size_t * index, |
250 | char ** result) | 265 | char ** result) |
251 | { | 266 | { |
252 | int end; | 267 | int end; |
253 | size_t cur_token; | 268 | size_t cur_token; |
254 | int res; | 269 | int res; |
255 | char * text; | 270 | char * text; |
256 | int r; | 271 | int r; |
257 | size_t begin; | 272 | size_t begin; |
258 | 273 | ||
259 | cur_token = * index; | 274 | cur_token = * index; |
260 | 275 | ||
261 | r = mailimf_fws_parse(message, length, &cur_token); | 276 | r = mailimf_fws_parse(message, length, &cur_token); |
262 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { | 277 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { |
263 | res = r; | 278 | res = r; |
264 | goto err; | 279 | goto err; |
265 | } | 280 | } |
266 | 281 | ||
267 | begin = cur_token; | 282 | begin = cur_token; |
268 | 283 | ||
269 | end = FALSE; | 284 | end = FALSE; |
270 | while (1) { | 285 | while (1) { |
271 | if (cur_token >= length) | 286 | if (cur_token >= length) |
272 | break; | 287 | break; |
273 | 288 | ||
274 | switch (message[cur_token]) { | 289 | switch (message[cur_token]) { |
275 | case ' ': | 290 | case ' ': |
276 | case '\t': | 291 | case '\t': |
277 | case '\r': | 292 | case '\r': |
278 | case '\n': | 293 | case '\n': |
279 | end = TRUE; | 294 | end = TRUE; |
280 | break; | 295 | break; |
281 | } | 296 | } |
282 | 297 | ||
283 | if (end) | 298 | if (end) |
284 | break; | 299 | break; |
285 | 300 | ||
286 | cur_token ++; | 301 | cur_token ++; |
287 | } | 302 | } |
288 | 303 | ||
289 | if (cur_token - begin == 0) { | 304 | if (cur_token - begin == 0) { |
290 | res = MAILIMF_ERROR_PARSE; | 305 | res = MAILIMF_ERROR_PARSE; |
291 | goto err; | 306 | goto err; |
292 | } | 307 | } |
293 | 308 | ||
294 | text = malloc(cur_token - begin + 1); | 309 | text = malloc(cur_token - begin + 1); |
295 | if (text == NULL) { | 310 | if (text == NULL) { |
296 | res = MAILIMF_ERROR_MEMORY; | 311 | res = MAILIMF_ERROR_MEMORY; |
297 | goto err; | 312 | goto err; |
298 | } | 313 | } |
299 | 314 | ||
300 | memcpy(text, message + begin, cur_token - begin); | 315 | memcpy(text, message + begin, cur_token - begin); |
301 | text[cur_token - begin] = '\0'; | 316 | text[cur_token - begin] = '\0'; |
302 | 317 | ||
303 | * index = cur_token; | 318 | * index = cur_token; |
304 | * result = text; | 319 | * result = text; |
305 | 320 | ||
306 | return MAILIMF_NO_ERROR; | 321 | return MAILIMF_NO_ERROR; |
307 | 322 | ||
308 | err: | 323 | err: |
309 | return res; | 324 | return res; |
310 | } | 325 | } |
311 | 326 | ||
312 | static int mailmime_encoded_word_parse(const char * message, size_t length, | 327 | static int mailmime_encoded_word_parse(const char * message, size_t length, |
313 | size_t * index, | 328 | size_t * index, |
314 | struct mailmime_encoded_word ** result) | 329 | struct mailmime_encoded_word ** result) |
315 | { | 330 | { |
316 | size_t cur_token; | 331 | size_t cur_token; |
317 | char * charset; | 332 | char * charset; |
318 | int encoding; | 333 | int encoding; |
319 | char * text; | 334 | char * text; |
320 | size_t end_encoding; | 335 | size_t end_encoding; |
321 | char * decoded; | 336 | char * decoded; |
322 | size_t decoded_len; | 337 | size_t decoded_len; |
323 | struct mailmime_encoded_word * ew; | 338 | struct mailmime_encoded_word * ew; |
324 | int r; | 339 | int r; |
325 | int res; | 340 | int res; |
326 | int opening_quote; | 341 | int opening_quote; |
327 | int end; | 342 | int end; |
328 | 343 | ||
329 | cur_token = * index; | 344 | cur_token = * index; |
330 | 345 | ||
331 | r = mailimf_fws_parse(message, length, &cur_token); | 346 | r = mailimf_fws_parse(message, length, &cur_token); |
332 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { | 347 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { |
333 | res = r; | 348 | res = r; |
334 | goto err; | 349 | goto err; |
335 | } | 350 | } |
336 | 351 | ||
337 | opening_quote = FALSE; | 352 | opening_quote = FALSE; |
338 | r = mailimf_char_parse(message, length, &cur_token, '\"'); | 353 | r = mailimf_char_parse(message, length, &cur_token, '\"'); |
339 | if (r == MAILIMF_NO_ERROR) { | 354 | if (r == MAILIMF_NO_ERROR) { |
340 | opening_quote = TRUE; | 355 | opening_quote = TRUE; |
341 | } | 356 | } |
342 | else if (r == MAILIMF_ERROR_PARSE) { | 357 | else if (r == MAILIMF_ERROR_PARSE) { |
343 | /* do nothing */ | 358 | /* do nothing */ |
344 | } | 359 | } |
345 | else { | 360 | else { |
346 | res = r; | 361 | res = r; |
347 | goto err; | 362 | goto err; |
348 | } | 363 | } |
349 | 364 | ||
350 | r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "=?"); | 365 | r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "=?"); |
351 | if (r != MAILIMF_NO_ERROR) { | 366 | if (r != MAILIMF_NO_ERROR) { |
352 | res = r; | 367 | res = r; |
353 | goto err; | 368 | goto err; |
354 | } | 369 | } |
355 | 370 | ||
356 | r = mailmime_charset_parse(message, length, &cur_token, &charset); | 371 | r = mailmime_charset_parse(message, length, &cur_token, &charset); |
357 | if (r != MAILIMF_NO_ERROR) { | 372 | if (r != MAILIMF_NO_ERROR) { |
358 | res = r; | 373 | res = r; |
359 | goto err; | 374 | goto err; |
360 | } | 375 | } |
361 | 376 | ||
362 | r = mailimf_char_parse(message, length, &cur_token, '?'); | 377 | r = mailimf_char_parse(message, length, &cur_token, '?'); |
363 | if (r != MAILIMF_NO_ERROR) { | 378 | if (r != MAILIMF_NO_ERROR) { |
364 | res = r; | 379 | res = r; |
365 | goto free_charset; | 380 | goto free_charset; |
366 | } | 381 | } |
367 | 382 | ||
368 | r = mailmime_encoding_parse(message, length, &cur_token, &encoding); | 383 | r = mailmime_encoding_parse(message, length, &cur_token, &encoding); |
369 | if (r != MAILIMF_NO_ERROR) { | 384 | if (r != MAILIMF_NO_ERROR) { |
370 | res = r; | 385 | res = r; |
371 | goto free_charset; | 386 | goto free_charset; |
372 | } | 387 | } |
373 | 388 | ||
374 | r = mailimf_char_parse(message, length, &cur_token, '?'); | 389 | r = mailimf_char_parse(message, length, &cur_token, '?'); |
375 | if (r != MAILIMF_NO_ERROR) { | 390 | if (r != MAILIMF_NO_ERROR) { |
376 | res = r; | 391 | res = r; |
377 | goto free_charset; | 392 | goto free_charset; |
378 | } | 393 | } |
379 | 394 | ||
380 | end = FALSE; | 395 | end = FALSE; |
381 | end_encoding = cur_token; | 396 | end_encoding = cur_token; |
382 | while (1) { | 397 | while (1) { |
383 | if (end_encoding >= length) | 398 | if (end_encoding >= length) |
384 | break; | 399 | break; |
385 | 400 | ||
386 | switch (message[end_encoding]) { | 401 | switch (message[end_encoding]) { |
387 | case '?': | 402 | case '?': |
388 | #if 0 | 403 | #if 0 |
389 | case ' ': | 404 | case ' ': |
390 | #endif | 405 | #endif |
391 | end = TRUE; | 406 | end = TRUE; |
392 | break; | 407 | break; |
393 | } | 408 | } |
394 | 409 | ||
395 | if (end) | 410 | if (end) |
396 | break; | 411 | break; |
397 | 412 | ||
398 | end_encoding ++; | 413 | end_encoding ++; |
399 | } | 414 | } |
400 | 415 | ||
401 | decoded_len = 0; | 416 | decoded_len = 0; |
402 | decoded = NULL; | 417 | decoded = NULL; |
403 | switch (encoding) { | 418 | switch (encoding) { |
404 | case MAILMIME_ENCODING_B: | 419 | case MAILMIME_ENCODING_B: |
405 | r = mailmime_base64_body_parse(message, end_encoding, | 420 | r = mailmime_base64_body_parse(message, end_encoding, |
406 | &cur_token, &decoded, | 421 | &cur_token, &decoded, |
407 | &decoded_len); | 422 | &decoded_len); |
408 | 423 | ||
409 | if (r != MAILIMF_NO_ERROR) { | 424 | if (r != MAILIMF_NO_ERROR) { |
410 | res = r; | 425 | res = r; |
411 | goto free_charset; | 426 | goto free_charset; |
412 | } | 427 | } |
413 | break; | 428 | break; |
414 | case MAILMIME_ENCODING_Q: | 429 | case MAILMIME_ENCODING_Q: |
415 | r = mailmime_quoted_printable_body_parse(message, end_encoding, | 430 | r = mailmime_quoted_printable_body_parse(message, end_encoding, |
416 | &cur_token, &decoded, | 431 | &cur_token, &decoded, |
417 | &decoded_len, TRUE); | 432 | &decoded_len, TRUE); |
418 | 433 | ||
419 | if (r != MAILIMF_NO_ERROR) { | 434 | if (r != MAILIMF_NO_ERROR) { |
420 | res = r; | 435 | res = r; |
421 | goto free_charset; | 436 | goto free_charset; |
422 | } | 437 | } |
423 | 438 | ||
424 | break; | 439 | break; |
425 | } | 440 | } |
426 | 441 | ||
427 | text = malloc(decoded_len + 1); | 442 | text = malloc(decoded_len + 1); |
428 | if (text == NULL) { | 443 | if (text == NULL) { |
429 | res = MAILIMF_ERROR_MEMORY; | 444 | res = MAILIMF_ERROR_MEMORY; |
430 | goto free_charset; | 445 | goto free_charset; |
431 | } | 446 | } |
432 | 447 | ||
433 | if (decoded_len > 0) | 448 | if (decoded_len > 0) |
434 | memcpy(text, decoded, decoded_len); | 449 | memcpy(text, decoded, decoded_len); |
435 | text[decoded_len] = '\0'; | 450 | text[decoded_len] = '\0'; |
436 | 451 | ||
437 | mailmime_decoded_part_free(decoded); | 452 | mailmime_decoded_part_free(decoded); |
438 | 453 | ||
439 | r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "?="); | 454 | r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "?="); |
440 | if (r != MAILIMF_NO_ERROR) { | 455 | if (r != MAILIMF_NO_ERROR) { |
441 | res = r; | 456 | res = r; |
442 | goto free_encoded_text; | 457 | goto free_encoded_text; |
443 | } | 458 | } |
444 | 459 | ||
445 | if (opening_quote) { | 460 | if (opening_quote) { |
446 | r = mailimf_char_parse(message, length, &cur_token, '\"'); | 461 | r = mailimf_char_parse(message, length, &cur_token, '\"'); |
447 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { | 462 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { |
448 | res = r; | 463 | res = r; |
449 | goto free_encoded_text; | 464 | goto free_encoded_text; |
450 | } | 465 | } |
451 | } | 466 | } |
452 | 467 | ||
453 | ew = mailmime_encoded_word_new(charset, text); | 468 | ew = mailmime_encoded_word_new(charset, text); |
454 | if (ew == NULL) { | 469 | if (ew == NULL) { |
455 | res = MAILIMF_ERROR_MEMORY; | 470 | res = MAILIMF_ERROR_MEMORY; |
456 | goto free_encoded_text; | 471 | goto free_encoded_text; |
457 | } | 472 | } |
458 | 473 | ||
459 | * result = ew; | 474 | * result = ew; |
460 | * index = cur_token; | 475 | * index = cur_token; |
461 | 476 | ||
462 | return MAILIMF_NO_ERROR; | 477 | return MAILIMF_NO_ERROR; |
463 | 478 | ||
464 | free_encoded_text: | 479 | free_encoded_text: |
465 | mailmime_encoded_text_free(text); | 480 | mailmime_encoded_text_free(text); |
466 | free_charset: | 481 | free_charset: |
467 | mailmime_charset_free(charset); | 482 | mailmime_charset_free(charset); |
468 | err: | 483 | err: |
469 | return res; | 484 | return res; |
470 | } | 485 | } |
471 | 486 | ||
472 | static int mailmime_charset_parse(const char * message, size_t length, | 487 | static int mailmime_charset_parse(const char * message, size_t length, |
473 | size_t * index, char ** charset) | 488 | size_t * index, char ** charset) |
474 | { | 489 | { |
475 | return mailmime_etoken_parse(message, length, index, charset); | 490 | return mailmime_etoken_parse(message, length, index, charset); |
476 | } | 491 | } |
477 | 492 | ||
478 | static int mailmime_encoding_parse(const char * message, size_t length, | 493 | static int mailmime_encoding_parse(const char * message, size_t length, |
479 | size_t * index, int * result) | 494 | size_t * index, int * result) |
480 | { | 495 | { |
481 | size_t cur_token; | 496 | size_t cur_token; |
482 | int encoding; | 497 | int encoding; |
483 | 498 | ||
484 | cur_token = * index; | 499 | cur_token = * index; |
485 | 500 | ||
486 | if (cur_token >= length) | 501 | if (cur_token >= length) |
487 | return MAILIMF_ERROR_PARSE; | 502 | return MAILIMF_ERROR_PARSE; |
488 | 503 | ||
489 | switch ((char) toupper((unsigned char) message[cur_token])) { | 504 | switch ((char) toupper((unsigned char) message[cur_token])) { |
490 | case 'Q': | 505 | case 'Q': |
491 | encoding = MAILMIME_ENCODING_Q; | 506 | encoding = MAILMIME_ENCODING_Q; |
492 | break; | 507 | break; |
493 | case 'B': | 508 | case 'B': |
494 | encoding = MAILMIME_ENCODING_B; | 509 | encoding = MAILMIME_ENCODING_B; |
495 | break; | 510 | break; |
496 | default: | 511 | default: |
497 | return MAILIMF_ERROR_INVAL; | 512 | return MAILIMF_ERROR_INVAL; |
498 | } | 513 | } |
499 | 514 | ||
500 | cur_token ++; | 515 | cur_token ++; |
501 | 516 | ||
502 | * result = encoding; | 517 | * result = encoding; |
503 | * index = cur_token; | 518 | * index = cur_token; |
504 | 519 | ||
505 | return MAILIMF_NO_ERROR; | 520 | return MAILIMF_NO_ERROR; |
506 | } | 521 | } |
507 | 522 | ||
508 | int is_etoken_char(char ch) | 523 | int is_etoken_char(char ch) |
509 | { | 524 | { |
510 | unsigned char uch = ch; | 525 | unsigned char uch = ch; |
511 | 526 | ||
512 | if (uch < 31) | 527 | if (uch < 31) |
513 | return FALSE; | 528 | return FALSE; |
514 | 529 | ||
515 | switch (uch) { | 530 | switch (uch) { |
516 | case ' ': | 531 | case ' ': |
517 | case '(': | 532 | case '(': |
518 | case ')': | 533 | case ')': |
519 | case '<': | 534 | case '<': |
520 | case '>': | 535 | case '>': |
521 | case '@': | 536 | case '@': |
522 | case ',': | 537 | case ',': |
523 | case ';': | 538 | case ';': |
524 | case ':': | 539 | case ':': |
525 | case '"': | 540 | case '"': |
526 | case '/': | 541 | case '/': |
527 | case '[': | 542 | case '[': |
528 | case ']': | 543 | case ']': |
529 | case '?': | 544 | case '?': |
530 | case '.': | 545 | case '.': |
531 | case '=': | 546 | case '=': |
532 | return FALSE; | 547 | return FALSE; |
533 | } | 548 | } |
534 | 549 | ||
535 | return TRUE; | 550 | return TRUE; |
536 | } | 551 | } |
537 | 552 | ||
538 | static int mailmime_etoken_parse(const char * message, size_t length, | 553 | static int mailmime_etoken_parse(const char * message, size_t length, |
539 | size_t * index, char ** result) | 554 | size_t * index, char ** result) |
540 | { | 555 | { |
541 | return mailimf_custom_string_parse(message, length, | 556 | return mailimf_custom_string_parse(message, length, |
542 | index, result, | 557 | index, result, |
543 | is_etoken_char); | 558 | is_etoken_char); |
544 | } | 559 | } |
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 8ee112c..ed5c898 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,278 +1,279 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
3 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <klocale.h> | 14 | #include <klocale.h> |
15 | #include <kdecore/kstandarddirs.h> | 15 | #include <kdecore/kstandarddirs.h> |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | #include <libetpan/mailmime_content.h> | 19 | #include <libetpan/mailmime_content.h> |
20 | #include <libetpan/mailmime.h> | 20 | #include <libetpan/mailmime.h> |
21 | 21 | ||
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
24 | { | 24 | { |
25 | return new IMAPwrapper(a); | 25 | return new IMAPwrapper(a); |
26 | } | 26 | } |
27 | 27 | ||
28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
29 | { | 29 | { |
30 | return new POP3wrapper(a); | 30 | return new POP3wrapper(a); |
31 | } | 31 | } |
32 | 32 | ||
33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
34 | { | 34 | { |
35 | return new NNTPwrapper(a); | 35 | return new NNTPwrapper(a); |
36 | } | 36 | } |
37 | 37 | ||
38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
39 | { | 39 | { |
40 | return new MHwrapper(a,name); | 40 | return new MHwrapper(a,name); |
41 | } | 41 | } |
42 | 42 | ||
43 | AbstractMail* AbstractMail::getWrapper(Account*a) | 43 | AbstractMail* AbstractMail::getWrapper(Account*a) |
44 | { | 44 | { |
45 | if (!a) return 0; | 45 | if (!a) return 0; |
46 | switch (a->getType()) { | 46 | switch (a->getType()) { |
47 | case MAILLIB::A_IMAP: | 47 | case MAILLIB::A_IMAP: |
48 | return new IMAPwrapper((IMAPaccount*)a); | 48 | return new IMAPwrapper((IMAPaccount*)a); |
49 | break; | 49 | break; |
50 | case MAILLIB::A_POP3: | 50 | case MAILLIB::A_POP3: |
51 | return new POP3wrapper((POP3account*)a); | 51 | return new POP3wrapper((POP3account*)a); |
52 | break; | 52 | break; |
53 | case MAILLIB::A_NNTP: | 53 | case MAILLIB::A_NNTP: |
54 | return new NNTPwrapper((NNTPaccount*)a); | 54 | return new NNTPwrapper((NNTPaccount*)a); |
55 | break; | 55 | break; |
56 | default: | 56 | default: |
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 61 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
62 | { | 62 | { |
63 | // odebug << "Decode string start" << oendl; | 63 | // odebug << "Decode string start" << oendl; |
64 | char*result_text; | 64 | char*result_text; |
65 | size_t index = 0; | 65 | size_t index = 0; |
66 | /* reset for recursive use! */ | 66 | /* reset for recursive use! */ |
67 | size_t target_length = 0; | 67 | size_t target_length = 0; |
68 | result_text = 0; | 68 | result_text = 0; |
69 | int mimetype = MAILMIME_MECHANISM_7BIT; | 69 | int mimetype = MAILMIME_MECHANISM_7BIT; |
70 | if (enc.lower()=="quoted-printable") { | 70 | if (enc.lower()=="quoted-printable") { |
71 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 71 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
72 | } else if (enc.lower()=="base64") { | 72 | } else if (enc.lower()=="base64") { |
73 | mimetype = MAILMIME_MECHANISM_BASE64; | 73 | mimetype = MAILMIME_MECHANISM_BASE64; |
74 | } else if (enc.lower()=="8bit") { | 74 | } else if (enc.lower()=="8bit") { |
75 | mimetype = MAILMIME_MECHANISM_8BIT; | 75 | mimetype = MAILMIME_MECHANISM_8BIT; |
76 | } else if (enc.lower()=="binary") { | 76 | } else if (enc.lower()=="binary") { |
77 | mimetype = MAILMIME_MECHANISM_BINARY; | 77 | mimetype = MAILMIME_MECHANISM_BINARY; |
78 | } | 78 | } |
79 | |||
80 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 79 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
81 | &result_text,&target_length); | 80 | &result_text,&target_length); |
82 | 81 | ||
83 | encodedString* result = new encodedString(); | 82 | encodedString* result = new encodedString(); |
84 | if (err == MAILIMF_NO_ERROR) { | 83 | if (err == MAILIMF_NO_ERROR) { |
85 | result->setContent(result_text,target_length); | 84 | result->setContent(result_text,target_length); |
86 | } | 85 | } |
87 | //odebug << "Decode string finished" << oendl; | 86 | //odebug << "Decode string finished" << oendl; |
88 | return result; | 87 | return result; |
89 | } | 88 | } |
90 | 89 | ||
91 | QString AbstractMail::convert_String(const char*text) | 90 | QString AbstractMail::convert_String(const char*text) |
92 | { | 91 | { |
93 | size_t index = 0; | 92 | size_t index = 0; |
94 | char*res = 0; | 93 | char*res = 0; |
95 | int err = MAILIMF_NO_ERROR; | 94 | int err = MAILIMF_NO_ERROR; |
96 | 95 | ||
97 | QString result(text); | 96 | QString result(text); |
98 | 97 | //qDebug("convert_String %s ", text); | |
98 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | ||
99 | // text, strlen(text),&index, "iso-8859-1",&res); | ||
99 | err = mailmime_encoded_phrase_parse("iso-8859-1", | 100 | err = mailmime_encoded_phrase_parse("iso-8859-1", |
100 | text, strlen(text),&index, "iso-8859-1",&res); | 101 | text, strlen(text),&index, "utf-8",&res); |
101 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 102 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
102 | result = QString(res); | 103 | result = QString::fromUtf8(res); |
103 | } | 104 | } |
104 | //qDebug("convert_String:%s ",result.latin1() ); | 105 | //qDebug("convert_String:%s ",result.latin1() ); |
105 | if (res) free(res); | 106 | if (res) free(res); |
106 | return result; | 107 | return result; |
107 | } | 108 | } |
108 | 109 | ||
109 | /* cp & paste from launcher */ | 110 | /* cp & paste from launcher */ |
110 | QString AbstractMail::gen_attachment_id() | 111 | QString AbstractMail::gen_attachment_id() |
111 | { | 112 | { |
112 | QFile file( "/proc/sys/kernel/random/uuid" ); | 113 | QFile file( "/proc/sys/kernel/random/uuid" ); |
113 | if (!file.open(IO_ReadOnly ) ) | 114 | if (!file.open(IO_ReadOnly ) ) |
114 | return QString::null; | 115 | return QString::null; |
115 | 116 | ||
116 | QTextStream stream(&file); | 117 | QTextStream stream(&file); |
117 | 118 | ||
118 | return "{" + stream.read().stripWhiteSpace() + "}"; | 119 | return "{" + stream.read().stripWhiteSpace() + "}"; |
119 | } | 120 | } |
120 | 121 | ||
121 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 122 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
122 | { | 123 | { |
123 | return 0; | 124 | return 0; |
124 | } | 125 | } |
125 | 126 | ||
126 | QString AbstractMail::defaultLocalfolder() | 127 | QString AbstractMail::defaultLocalfolder() |
127 | { | 128 | { |
128 | // QString f = getenv( "HOME" ); | 129 | // QString f = getenv( "HOME" ); |
129 | QString f = locateLocal( "data", "kopiemail/localmail"); | 130 | QString f = locateLocal( "data", "kopiemail/localmail"); |
130 | // f += "/Applications/opiemail/localmail"; | 131 | // f += "/Applications/opiemail/localmail"; |
131 | return f; | 132 | return f; |
132 | } | 133 | } |
133 | 134 | ||
134 | QString AbstractMail::draftFolder() | 135 | QString AbstractMail::draftFolder() |
135 | { | 136 | { |
136 | return QString("Drafts"); | 137 | return QString("Drafts"); |
137 | } | 138 | } |
138 | 139 | ||
139 | /* temporary - will be removed when implemented in all classes */ | 140 | /* temporary - will be removed when implemented in all classes */ |
140 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
141 | { | 142 | { |
142 | } | 143 | } |
143 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
144 | { | 145 | { |
145 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
146 | // this is currently re-implemented in pop3wrapper and imapwrapper | 147 | // this is currently re-implemented in pop3wrapper and imapwrapper |
147 | int iii = 0; | 148 | int iii = 0; |
148 | int count = target.count(); | 149 | int count = target.count(); |
149 | QProgressBar wid ( count ); | 150 | QProgressBar wid ( count ); |
150 | wid.setCaption( i18n("Deleting ...")); | 151 | wid.setCaption( i18n("Deleting ...")); |
151 | wid.show(); | 152 | wid.show(); |
152 | while (iii < count ) { | 153 | while (iii < count ) { |
153 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 154 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
154 | wid.setProgress( iii ); | 155 | wid.setProgress( iii ); |
155 | wid.raise(); | 156 | wid.raise(); |
156 | qApp->processEvents(); | 157 | qApp->processEvents(); |
157 | RecMailP mail = (*target.at( iii )); | 158 | RecMailP mail = (*target.at( iii )); |
158 | deleteMail(mail); | 159 | deleteMail(mail); |
159 | ++iii; | 160 | ++iii; |
160 | } | 161 | } |
161 | } | 162 | } |
162 | 163 | ||
163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | 164 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) |
164 | { | 165 | { |
165 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | 166 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); |
166 | // get local folder | 167 | // get local folder |
167 | Account * acc = getAccount(); | 168 | Account * acc = getAccount(); |
168 | if ( !acc ) return; | 169 | if ( !acc ) return; |
169 | QString lfName = acc->getLocalFolder(); | 170 | QString lfName = acc->getLocalFolder(); |
170 | if ( lfName.isEmpty() ) | 171 | if ( lfName.isEmpty() ) |
171 | lfName = acc->getAccountName(); | 172 | lfName = acc->getAccountName(); |
172 | // create local folder | 173 | // create local folder |
173 | if ( !targetMail->createMbox(lfName)) | 174 | if ( !targetMail->createMbox(lfName)) |
174 | { | 175 | { |
175 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 176 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
176 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | 177 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); |
177 | return; | 178 | return; |
178 | } | 179 | } |
179 | QValueList<RecMailP> t; | 180 | QValueList<RecMailP> t; |
180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | 181 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); |
181 | if ( t.count() == 0 ) { | 182 | if ( t.count() == 0 ) { |
182 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); | 183 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); |
183 | Global::statusMessage(i18n("There are no new messages")); | 184 | Global::statusMessage(i18n("There are no new messages")); |
184 | return; | 185 | return; |
185 | } | 186 | } |
186 | QValueList<RecMailP> e; | 187 | QValueList<RecMailP> e; |
187 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | 188 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); |
188 | //qDebug("target has mails %d ", e.count()); | 189 | //qDebug("target has mails %d ", e.count()); |
189 | QValueList<RecMailP> n; | 190 | QValueList<RecMailP> n; |
190 | int iii = 0; | 191 | int iii = 0; |
191 | int count = t.count(); | 192 | int count = t.count(); |
192 | while (iii < count ) { | 193 | while (iii < count ) { |
193 | RecMailP r = (*t.at( iii )); | 194 | RecMailP r = (*t.at( iii )); |
194 | bool found = false; | 195 | bool found = false; |
195 | int jjj = 0; | 196 | int jjj = 0; |
196 | int countE = e.count(); | 197 | int countE = e.count(); |
197 | while (jjj < countE ) { | 198 | while (jjj < countE ) { |
198 | RecMailP re = (*e.at( jjj )); | 199 | RecMailP re = (*e.at( jjj )); |
199 | if ( re->isEqual(r) ) { | 200 | if ( re->isEqual(r) ) { |
200 | found = true; | 201 | found = true; |
201 | break; | 202 | break; |
202 | } | 203 | } |
203 | ++jjj; | 204 | ++jjj; |
204 | } | 205 | } |
205 | if ( !found ) { | 206 | if ( !found ) { |
206 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); | 207 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); |
207 | n.append( r ); | 208 | n.append( r ); |
208 | } | 209 | } |
209 | ++iii; | 210 | ++iii; |
210 | } | 211 | } |
211 | qDebug("Downloaded %d messages ",n.count() ); | 212 | qDebug("Downloaded %d messages ",n.count() ); |
212 | if ( n.count() == 0 ) { | 213 | if ( n.count() == 0 ) { |
213 | Global::statusMessage(i18n("There are no new messages")); | 214 | Global::statusMessage(i18n("There are no new messages")); |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | 217 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); |
217 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); | 218 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); |
218 | 219 | ||
219 | #if 0 | 220 | #if 0 |
220 | QValueList<RecMailP> t; | 221 | QValueList<RecMailP> t; |
221 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 222 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
222 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 223 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
223 | #endif | 224 | #endif |
224 | 225 | ||
225 | } | 226 | } |
226 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 227 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
227 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 228 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
228 | { | 229 | { |
229 | QValueList<RecMailP> t; | 230 | QValueList<RecMailP> t; |
230 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 231 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
231 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 232 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
232 | 233 | ||
233 | } | 234 | } |
234 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 235 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
235 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 236 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
236 | { | 237 | { |
237 | encodedString*st = 0; | 238 | encodedString*st = 0; |
238 | int iii = 0; | 239 | int iii = 0; |
239 | int count = t.count(); | 240 | int count = t.count(); |
240 | if ( count == 0 ) | 241 | if ( count == 0 ) |
241 | return; | 242 | return; |
242 | // wel, processevents is qite strange, we need a widget for getting | 243 | // wel, processevents is qite strange, we need a widget for getting |
243 | // Global::statusMessage(i18n("Copy2 message %1").arg(iii)); displaye | 244 | // Global::statusMessage(i18n("Copy2 message %1").arg(iii)); displaye |
244 | 245 | ||
245 | QProgressBar wid ( count ); | 246 | QProgressBar wid ( count ); |
246 | wid.setCaption( i18n("Copying...")); | 247 | wid.setCaption( i18n("Copying...")); |
247 | wid.show(); | 248 | wid.show(); |
248 | while (iii < count ) { | 249 | while (iii < count ) { |
249 | Global::statusMessage(i18n("Copy message %1 of %2").arg(iii).arg(count)); | 250 | Global::statusMessage(i18n("Copy message %1 of %2").arg(iii).arg(count)); |
250 | wid.setProgress( iii ); | 251 | wid.setProgress( iii ); |
251 | wid.raise(); | 252 | wid.raise(); |
252 | qApp->processEvents(); | 253 | qApp->processEvents(); |
253 | RecMailP r = (*t.at( iii )); | 254 | RecMailP r = (*t.at( iii )); |
254 | st = fetchRawBody(r); | 255 | st = fetchRawBody(r); |
255 | if (st) { | 256 | if (st) { |
256 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 257 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
257 | delete st; | 258 | delete st; |
258 | } | 259 | } |
259 | ++iii; | 260 | ++iii; |
260 | } | 261 | } |
261 | if (moveit) { | 262 | if (moveit) { |
262 | deleteMailList( t ); | 263 | deleteMailList( t ); |
263 | //deleteAllMail(fromFolder); | 264 | //deleteAllMail(fromFolder); |
264 | } | 265 | } |
265 | } | 266 | } |
266 | 267 | ||
267 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 268 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
268 | { | 269 | { |
269 | encodedString*st = 0; | 270 | encodedString*st = 0; |
270 | st = fetchRawBody(mail); | 271 | st = fetchRawBody(mail); |
271 | if (st) { | 272 | if (st) { |
272 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 273 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
273 | delete st; | 274 | delete st; |
274 | } | 275 | } |
275 | if (moveit) { | 276 | if (moveit) { |
276 | deleteMail(mail); | 277 | deleteMail(mail); |
277 | } | 278 | } |
278 | } | 279 | } |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index d89a5f9..49227dd 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,530 +1,544 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | 9 | ||
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | bodyCache.clear(); | 15 | bodyCache.clear(); |
16 | m_storage = 0; | 16 | m_storage = 0; |
17 | m_folder = 0; | 17 | m_folder = 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
21 | { | 21 | { |
22 | if (m_folder) { | 22 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
24 | } | 24 | } |
25 | if (m_storage) { | 25 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
27 | } | 27 | } |
28 | cleanMimeCache(); | 28 | cleanMimeCache(); |
29 | } | 29 | } |
30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) | 30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 31 | { |
32 | 32 | ||
33 | QDate da (date->dt_year,date->dt_month, date->dt_day ); | 33 | QDate da (date->dt_year,date->dt_month, date->dt_day ); |
34 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); | 34 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); |
35 | QDateTime dt ( da ,ti ); | 35 | QDateTime dt ( da ,ti ); |
36 | int addsec = -date->dt_zone*36; | 36 | int addsec = -date->dt_zone*36; |
37 | //qDebug("adsec1 %d ",addsec ); | 37 | //qDebug("adsec1 %d ",addsec ); |
38 | dt = dt.addSecs( addsec ); | 38 | dt = dt.addSecs( addsec ); |
39 | int off = KGlobal::locale()->localTimeOffset( dt ); | 39 | int off = KGlobal::locale()->localTimeOffset( dt ); |
40 | //qDebug("adsec2 %d ",off*60 ); | 40 | //qDebug("adsec2 %d ",off*60 ); |
41 | 41 | ||
42 | dt = dt.addSecs( off*60 ); | 42 | dt = dt.addSecs( off*60 ); |
43 | return dt; | 43 | return dt; |
44 | #if 0 | 44 | #if 0 |
45 | QString ret; | 45 | QString ret; |
46 | if ( dt.date() == QDate::currentDate () ) | 46 | if ( dt.date() == QDate::currentDate () ) |
47 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 47 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
48 | 48 | ||
49 | else { | 49 | else { |
50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
51 | } | 51 | } |
52 | #endif | 52 | #endif |
53 | #if 0 | 53 | #if 0 |
54 | if ( off < 0 ) | 54 | if ( off < 0 ) |
55 | ret += " -"; | 55 | ret += " -"; |
56 | else | 56 | else |
57 | ret += " +"; | 57 | ret += " +"; |
58 | ret += QString::number( off / 60 ); | 58 | ret += QString::number( off / 60 ); |
59 | ret += "h"; | 59 | ret += "h"; |
60 | #endif | 60 | #endif |
61 | #if 0 | 61 | #if 0 |
62 | char tmp[23]; | 62 | char tmp[23]; |
63 | 63 | ||
64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
68 | 68 | ||
69 | 69 | ||
70 | return QString( tmp ); | 70 | return QString( tmp ); |
71 | #endif | 71 | #endif |
72 | //return ret; | 72 | //return ret; |
73 | } | 73 | } |
74 | 74 | ||
75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
76 | { | 76 | { |
77 | if (!mime) { | 77 | if (!mime) { |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | mailmime_field*field = 0; | 80 | mailmime_field*field = 0; |
81 | mailmime_single_fields fields; | 81 | mailmime_single_fields fields; |
82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
83 | if (mime->mm_mime_fields != NULL) { | 83 | if (mime->mm_mime_fields != NULL) { |
84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
85 | mime->mm_content_type); | 85 | mime->mm_content_type); |
86 | } | 86 | } |
87 | 87 | ||
88 | mailmime_content*type = fields.fld_content; | 88 | mailmime_content*type = fields.fld_content; |
89 | clistcell*current; | 89 | clistcell*current; |
90 | if (!type) { | 90 | if (!type) { |
91 | target->setType("text"); | 91 | target->setType("text"); |
92 | target->setSubtype("plain"); | 92 | target->setSubtype("plain"); |
93 | } else { | 93 | } else { |
94 | target->setSubtype(type->ct_subtype); | 94 | target->setSubtype(type->ct_subtype); |
95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
96 | case MAILMIME_DISCRETE_TYPE_TEXT: | 96 | case MAILMIME_DISCRETE_TYPE_TEXT: |
97 | target->setType("text"); | 97 | target->setType("text"); |
98 | break; | 98 | break; |
99 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 99 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
100 | target->setType("image"); | 100 | target->setType("image"); |
101 | break; | 101 | break; |
102 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 102 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
103 | target->setType("audio"); | 103 | target->setType("audio"); |
104 | break; | 104 | break; |
105 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 105 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
106 | target->setType("video"); | 106 | target->setType("video"); |
107 | break; | 107 | break; |
108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
109 | target->setType("application"); | 109 | target->setType("application"); |
110 | break; | 110 | break; |
111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
112 | default: | 112 | default: |
113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
115 | } | 115 | } |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | if (type->ct_parameters) { | 118 | if (type->ct_parameters) { |
119 | fillParameters(target,type->ct_parameters); | 119 | fillParameters(target,type->ct_parameters); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
124 | field = (mailmime_field*)current->data; | 124 | field = (mailmime_field*)current->data; |
125 | switch(field->fld_type) { | 125 | switch(field->fld_type) { |
126 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 126 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
128 | break; | 128 | break; |
129 | case MAILMIME_FIELD_ID: | 129 | case MAILMIME_FIELD_ID: |
130 | target->setIdentifier(field->fld_data.fld_id); | 130 | target->setIdentifier(field->fld_data.fld_id); |
131 | break; | 131 | break; |
132 | case MAILMIME_FIELD_DESCRIPTION: | 132 | case MAILMIME_FIELD_DESCRIPTION: |
133 | target->setDescription(field->fld_data.fld_description); | 133 | target->setDescription(field->fld_data.fld_description); |
134 | break; | 134 | break; |
135 | default: | 135 | default: |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) | 142 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
143 | { | 143 | { |
144 | if (!parameters) {return;} | 144 | if (!parameters) {return;} |
145 | clistcell*current=0; | 145 | clistcell*current=0; |
146 | mailmime_parameter*param; | 146 | mailmime_parameter*param; |
147 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 147 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
148 | param = (mailmime_parameter*)current->data; | 148 | param = (mailmime_parameter*)current->data; |
149 | if (param) { | 149 | if (param) { |
150 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 150 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 155 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
156 | { | 156 | { |
157 | QString enc="7bit"; | 157 | QString enc="7bit"; |
158 | if (!aEnc) return enc; | 158 | if (!aEnc) return enc; |
159 | switch(aEnc->enc_type) { | 159 | switch(aEnc->enc_type) { |
160 | case MAILMIME_MECHANISM_7BIT: | 160 | case MAILMIME_MECHANISM_7BIT: |
161 | enc = "7bit"; | 161 | enc = "7bit"; |
162 | break; | 162 | break; |
163 | case MAILMIME_MECHANISM_8BIT: | 163 | case MAILMIME_MECHANISM_8BIT: |
164 | enc = "8bit"; | 164 | enc = "8bit"; |
165 | break; | 165 | break; |
166 | case MAILMIME_MECHANISM_BINARY: | 166 | case MAILMIME_MECHANISM_BINARY: |
167 | enc = "binary"; | 167 | enc = "binary"; |
168 | break; | 168 | break; |
169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
170 | enc = "quoted-printable"; | 170 | enc = "quoted-printable"; |
171 | break; | 171 | break; |
172 | case MAILMIME_MECHANISM_BASE64: | 172 | case MAILMIME_MECHANISM_BASE64: |
173 | enc = "base64"; | 173 | enc = "base64"; |
174 | break; | 174 | break; |
175 | case MAILMIME_MECHANISM_TOKEN: | 175 | case MAILMIME_MECHANISM_TOKEN: |
176 | default: | 176 | default: |
177 | if (aEnc->enc_token) { | 177 | if (aEnc->enc_token) { |
178 | enc = QString(aEnc->enc_token); | 178 | enc = QString(aEnc->enc_token); |
179 | } | 179 | } |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | return enc; | 182 | return enc; |
183 | } | 183 | } |
184 | 184 | ||
185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
186 | { | 186 | { |
187 | if (current_rec >= 10) { | 187 | if (current_rec >= 10) { |
188 | ; // odebug << "too deep recursion!" << oendl; | 188 | ; // odebug << "too deep recursion!" << oendl; |
189 | } | 189 | } |
190 | if (!message || !mime) { | 190 | if (!message || !mime) { |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | int r; | 193 | int r; |
194 | char*data = 0; | 194 | char*data = 0; |
195 | size_t len; | 195 | size_t len; |
196 | clistiter * cur = 0; | 196 | clistiter * cur = 0; |
197 | QString b; | 197 | QString b; |
198 | RecPartP part = new RecPart(); | 198 | RecPartP part = new RecPart(); |
199 | 199 | ||
200 | switch (mime->mm_type) { | 200 | switch (mime->mm_type) { |
201 | case MAILMIME_SINGLE: | 201 | case MAILMIME_SINGLE: |
202 | { | 202 | { |
203 | QValueList<int>countlist = recList; | 203 | QValueList<int>countlist = recList; |
204 | countlist.append(current_count); | 204 | countlist.append(current_count); |
205 | r = mailmessage_fetch_section(message,mime,&data,&len); | 205 | r = mailmessage_fetch_section(message,mime,&data,&len); |
206 | part->setSize(len); | 206 | part->setSize(len); |
207 | part->setPositionlist(countlist); | 207 | part->setPositionlist(countlist); |
208 | b = gen_attachment_id(); | 208 | b = gen_attachment_id(); |
209 | part->setIdentifier(b); | 209 | part->setIdentifier(b); |
210 | fillSingleBody(part,message,mime); | 210 | fillSingleBody(part,message,mime); |
211 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 211 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
212 | encodedString*rs = new encodedString(); | 212 | encodedString*rs = new encodedString(); |
213 | rs->setContent(data,len); | 213 | rs->setContent(data,len); |
214 | encodedString*res = decode_String(rs,part->Encoding()); | 214 | encodedString*res = decode_String(rs,part->Encoding()); |
215 | if (countlist.count()>2) { | 215 | if (countlist.count()>2) { |
216 | bodyCache[b]=rs; | 216 | bodyCache[b]=rs; |
217 | target->addPart(part); | 217 | target->addPart(part); |
218 | } else { | 218 | } else { |
219 | delete rs; | 219 | delete rs; |
220 | } | 220 | } |
221 | b = QString(res->Content()); | 221 | b = QString(res->Content()); |
222 | delete res; | 222 | delete res; |
223 | size_t index = 0; | ||
224 | char*resu = 0; | ||
225 | int err = MAILIMF_NO_ERROR; | ||
226 | QString charset = part->searchParamter( "charset"); | ||
227 | qDebug("CHARSET %s ",charset.latin1() ); | ||
228 | if ( !charset.isEmpty() ) { | ||
229 | err = mailmime_encoded_phrase_parse(charset.latin1(), | ||
230 | b.latin1(), b.length(),&index, "utf-8",&resu); | ||
231 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { | ||
232 | //qDebug("res %d %s ", index, resu); | ||
233 | b = QString::fromUtf8(resu); | ||
234 | } | ||
235 | if (resu) free(resu); | ||
236 | } | ||
223 | target->setBodytext(b); | 237 | target->setBodytext(b); |
224 | target->setDescription(part); | 238 | target->setDescription(part); |
225 | } else { | 239 | } else { |
226 | bodyCache[b]=new encodedString(data,len); | 240 | bodyCache[b]=new encodedString(data,len); |
227 | target->addPart(part); | 241 | target->addPart(part); |
228 | } | 242 | } |
229 | } | 243 | } |
230 | break; | 244 | break; |
231 | case MAILMIME_MULTIPLE: | 245 | case MAILMIME_MULTIPLE: |
232 | { | 246 | { |
233 | unsigned int ccount = 1; | 247 | unsigned int ccount = 1; |
234 | mailmime*cbody=0; | 248 | mailmime*cbody=0; |
235 | QValueList<int>countlist = recList; | 249 | QValueList<int>countlist = recList; |
236 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 250 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
237 | cbody = (mailmime*)clist_content(cur); | 251 | cbody = (mailmime*)clist_content(cur); |
238 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 252 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
239 | RecPartP targetPart = new RecPart(); | 253 | RecPartP targetPart = new RecPart(); |
240 | targetPart->setType("multipart"); | 254 | targetPart->setType("multipart"); |
241 | countlist.append(current_count); | 255 | countlist.append(current_count); |
242 | targetPart->setPositionlist(countlist); | 256 | targetPart->setPositionlist(countlist); |
243 | target->addPart(targetPart); | 257 | target->addPart(targetPart); |
244 | } | 258 | } |
245 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 259 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
246 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 260 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
247 | countlist = recList; | 261 | countlist = recList; |
248 | } | 262 | } |
249 | ++ccount; | 263 | ++ccount; |
250 | } | 264 | } |
251 | } | 265 | } |
252 | break; | 266 | break; |
253 | case MAILMIME_MESSAGE: | 267 | case MAILMIME_MESSAGE: |
254 | { | 268 | { |
255 | QValueList<int>countlist = recList; | 269 | QValueList<int>countlist = recList; |
256 | countlist.append(current_count); | 270 | countlist.append(current_count); |
257 | /* the own header is always at recursion 0 - we don't need that */ | 271 | /* the own header is always at recursion 0 - we don't need that */ |
258 | if (current_rec > 0) { | 272 | if (current_rec > 0) { |
259 | part->setPositionlist(countlist); | 273 | part->setPositionlist(countlist); |
260 | r = mailmessage_fetch_section(message,mime,&data,&len); | 274 | r = mailmessage_fetch_section(message,mime,&data,&len); |
261 | part->setSize(len); | 275 | part->setSize(len); |
262 | part->setPositionlist(countlist); | 276 | part->setPositionlist(countlist); |
263 | b = gen_attachment_id(); | 277 | b = gen_attachment_id(); |
264 | part->setIdentifier(b); | 278 | part->setIdentifier(b); |
265 | part->setType("message"); | 279 | part->setType("message"); |
266 | part->setSubtype("rfc822"); | 280 | part->setSubtype("rfc822"); |
267 | bodyCache[b]=new encodedString(data,len); | 281 | bodyCache[b]=new encodedString(data,len); |
268 | target->addPart(part); | 282 | target->addPart(part); |
269 | } | 283 | } |
270 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 284 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
271 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 285 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
272 | } | 286 | } |
273 | } | 287 | } |
274 | break; | 288 | break; |
275 | } | 289 | } |
276 | } | 290 | } |
277 | 291 | ||
278 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 292 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
279 | { | 293 | { |
280 | int err = MAILIMF_NO_ERROR; | 294 | int err = MAILIMF_NO_ERROR; |
281 | //mailmime_single_fields fields; | 295 | //mailmime_single_fields fields; |
282 | /* is bound to msg and will be freed there */ | 296 | /* is bound to msg and will be freed there */ |
283 | mailmime * mime=0; | 297 | mailmime * mime=0; |
284 | RecBodyP body = new RecBody(); | 298 | RecBodyP body = new RecBody(); |
285 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 299 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
286 | err = mailmessage_get_bodystructure(msg,&mime); | 300 | err = mailmessage_get_bodystructure(msg,&mime); |
287 | QValueList<int>recList; | 301 | QValueList<int>recList; |
288 | traverseBody(body,msg,mime,recList); | 302 | traverseBody(body,msg,mime,recList); |
289 | return body; | 303 | return body; |
290 | } | 304 | } |
291 | 305 | ||
292 | 306 | ||
293 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 307 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
294 | { | 308 | { |
295 | QString result( "" ); | 309 | QString result( "" ); |
296 | 310 | ||
297 | bool first = true; | 311 | bool first = true; |
298 | if (list == 0) return result; | 312 | if (list == 0) return result; |
299 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 313 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
300 | mailimf_address *addr = (mailimf_address *) current->data; | 314 | mailimf_address *addr = (mailimf_address *) current->data; |
301 | 315 | ||
302 | if ( !first ) { | 316 | if ( !first ) { |
303 | result.append( "," ); | 317 | result.append( "," ); |
304 | } else { | 318 | } else { |
305 | first = false; | 319 | first = false; |
306 | } | 320 | } |
307 | 321 | ||
308 | switch ( addr->ad_type ) { | 322 | switch ( addr->ad_type ) { |
309 | case MAILIMF_ADDRESS_MAILBOX: | 323 | case MAILIMF_ADDRESS_MAILBOX: |
310 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 324 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
311 | break; | 325 | break; |
312 | case MAILIMF_ADDRESS_GROUP: | 326 | case MAILIMF_ADDRESS_GROUP: |
313 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 327 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
314 | break; | 328 | break; |
315 | default: | 329 | default: |
316 | ; // odebug << "Generic: unkown mailimf address type" << oendl; | 330 | ; // odebug << "Generic: unkown mailimf address type" << oendl; |
317 | break; | 331 | break; |
318 | } | 332 | } |
319 | } | 333 | } |
320 | 334 | ||
321 | return result; | 335 | return result; |
322 | } | 336 | } |
323 | 337 | ||
324 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 338 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
325 | { | 339 | { |
326 | QString result( "" ); | 340 | QString result( "" ); |
327 | 341 | ||
328 | result.append( group->grp_display_name ); | 342 | result.append( group->grp_display_name ); |
329 | result.append( ": " ); | 343 | result.append( ": " ); |
330 | 344 | ||
331 | if ( group->grp_mb_list != NULL ) { | 345 | if ( group->grp_mb_list != NULL ) { |
332 | result.append( parseMailboxList( group->grp_mb_list ) ); | 346 | result.append( parseMailboxList( group->grp_mb_list ) ); |
333 | } | 347 | } |
334 | 348 | ||
335 | result.append( ";" ); | 349 | result.append( ";" ); |
336 | 350 | ||
337 | return result; | 351 | return result; |
338 | } | 352 | } |
339 | 353 | ||
340 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 354 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
341 | { | 355 | { |
342 | QString result( "" ); | 356 | QString result( "" ); |
343 | 357 | ||
344 | if ( box->mb_display_name == NULL ) { | 358 | if ( box->mb_display_name == NULL ) { |
345 | result.append( box->mb_addr_spec ); | 359 | result.append( box->mb_addr_spec ); |
346 | } else { | 360 | } else { |
347 | result.append( convert_String(box->mb_display_name).latin1() ); | 361 | result.append( convert_String(box->mb_display_name) ); |
348 | result.append( " <" ); | 362 | result.append( " <" ); |
349 | result.append( box->mb_addr_spec ); | 363 | result.append( box->mb_addr_spec ); |
350 | result.append( ">" ); | 364 | result.append( ">" ); |
351 | } | 365 | } |
352 | 366 | ||
353 | return result; | 367 | return result; |
354 | } | 368 | } |
355 | 369 | ||
356 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 370 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
357 | { | 371 | { |
358 | QString result( "" ); | 372 | QString result( "" ); |
359 | 373 | ||
360 | bool first = true; | 374 | bool first = true; |
361 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 375 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
362 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 376 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
363 | 377 | ||
364 | if ( !first ) { | 378 | if ( !first ) { |
365 | result.append( "," ); | 379 | result.append( "," ); |
366 | } else { | 380 | } else { |
367 | first = false; | 381 | first = false; |
368 | } | 382 | } |
369 | 383 | ||
370 | result.append( parseMailbox( box ) ); | 384 | result.append( parseMailbox( box ) ); |
371 | } | 385 | } |
372 | 386 | ||
373 | return result; | 387 | return result; |
374 | } | 388 | } |
375 | 389 | ||
376 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) | 390 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
377 | { | 391 | { |
378 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 392 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
379 | if (it==bodyCache.end()) return new encodedString(); | 393 | if (it==bodyCache.end()) return new encodedString(); |
380 | encodedString*t = decode_String(it.data(),part->Encoding()); | 394 | encodedString*t = decode_String(it.data(),part->Encoding()); |
381 | return t; | 395 | return t; |
382 | } | 396 | } |
383 | 397 | ||
384 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) | 398 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
385 | { | 399 | { |
386 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 400 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
387 | if (it==bodyCache.end()) return new encodedString(); | 401 | if (it==bodyCache.end()) return new encodedString(); |
388 | encodedString*t = it.data(); | 402 | encodedString*t = it.data(); |
389 | return t; | 403 | return t; |
390 | } | 404 | } |
391 | 405 | ||
392 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 406 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
393 | { | 407 | { |
394 | encodedString*t = fetchDecodedPart(mail,part); | 408 | encodedString*t = fetchDecodedPart(mail,part); |
395 | QString text=t->Content(); | 409 | QString text=t->Content(); |
396 | delete t; | 410 | delete t; |
397 | return text; | 411 | return text; |
398 | } | 412 | } |
399 | 413 | ||
400 | void Genericwrapper::cleanMimeCache() | 414 | void Genericwrapper::cleanMimeCache() |
401 | { | 415 | { |
402 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 416 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
403 | for (;it!=bodyCache.end();++it) { | 417 | for (;it!=bodyCache.end();++it) { |
404 | encodedString*t = it.data(); | 418 | encodedString*t = it.data(); |
405 | //it.setValue(0); | 419 | //it.setValue(0); |
406 | if (t) delete t; | 420 | if (t) delete t; |
407 | } | 421 | } |
408 | bodyCache.clear(); | 422 | bodyCache.clear(); |
409 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; | 423 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; |
410 | } | 424 | } |
411 | 425 | ||
412 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 426 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
413 | { | 427 | { |
414 | QStringList res; | 428 | QStringList res; |
415 | if (!in_replies || !in_replies->mid_list) return res; | 429 | if (!in_replies || !in_replies->mid_list) return res; |
416 | clistiter * current = 0; | 430 | clistiter * current = 0; |
417 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 431 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
418 | QString h((char*)current->data); | 432 | QString h((char*)current->data); |
419 | while (h.length()>0 && h[0]=='<') { | 433 | while (h.length()>0 && h[0]=='<') { |
420 | h.remove(0,1); | 434 | h.remove(0,1); |
421 | } | 435 | } |
422 | while (h.length()>0 && h[h.length()-1]=='>') { | 436 | while (h.length()>0 && h[h.length()-1]=='>') { |
423 | h.remove(h.length()-1,1); | 437 | h.remove(h.length()-1,1); |
424 | } | 438 | } |
425 | if (h.length()>0) { | 439 | if (h.length()>0) { |
426 | res.append(h); | 440 | res.append(h); |
427 | } | 441 | } |
428 | } | 442 | } |
429 | return res; | 443 | return res; |
430 | } | 444 | } |
431 | 445 | ||
432 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) | 446 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) |
433 | { | 447 | { |
434 | int r; | 448 | int r; |
435 | mailmessage_list * env_list = 0; | 449 | mailmessage_list * env_list = 0; |
436 | r = mailsession_get_messages_list(session,&env_list); | 450 | r = mailsession_get_messages_list(session,&env_list); |
437 | if (r != MAIL_NO_ERROR) { | 451 | if (r != MAIL_NO_ERROR) { |
438 | ; // odebug << "Error message list" << oendl; | 452 | ; // odebug << "Error message list" << oendl; |
439 | return; | 453 | return; |
440 | } | 454 | } |
441 | r = mailsession_get_envelopes_list(session, env_list); | 455 | r = mailsession_get_envelopes_list(session, env_list); |
442 | if (r != MAIL_NO_ERROR) { | 456 | if (r != MAIL_NO_ERROR) { |
443 | ; // odebug << "Error filling message list" << oendl; | 457 | ; // odebug << "Error filling message list" << oendl; |
444 | if (env_list) { | 458 | if (env_list) { |
445 | mailmessage_list_free(env_list); | 459 | mailmessage_list_free(env_list); |
446 | } | 460 | } |
447 | return; | 461 | return; |
448 | } | 462 | } |
449 | mailimf_references * refs = 0; | 463 | mailimf_references * refs = 0; |
450 | mailimf_in_reply_to * in_replies = 0; | 464 | mailimf_in_reply_to * in_replies = 0; |
451 | uint32_t i = 0; | 465 | uint32_t i = 0; |
452 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 466 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
453 | mailmessage * msg; | 467 | mailmessage * msg; |
454 | QBitArray mFlags(7); | 468 | QBitArray mFlags(7); |
455 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 469 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
456 | if (msg->msg_fields == NULL) { | 470 | if (msg->msg_fields == NULL) { |
457 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; | 471 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; |
458 | continue; | 472 | continue; |
459 | } | 473 | } |
460 | RecMailP mail = new RecMail(); | 474 | RecMailP mail = new RecMail(); |
461 | mail->setWrapper(this); | 475 | mail->setWrapper(this); |
462 | mail_flags * flag_result = 0; | 476 | mail_flags * flag_result = 0; |
463 | r = mailmessage_get_flags(msg,&flag_result); | 477 | r = mailmessage_get_flags(msg,&flag_result); |
464 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 478 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
465 | mFlags.setBit(FLAG_SEEN); | 479 | mFlags.setBit(FLAG_SEEN); |
466 | } | 480 | } |
467 | mailimf_single_fields single_fields; | 481 | mailimf_single_fields single_fields; |
468 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 482 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
469 | mail->setMsgsize(msg->msg_size); | 483 | mail->setMsgsize(msg->msg_size); |
470 | mail->setFlags(mFlags); | 484 | mail->setFlags(mFlags); |
471 | mail->setMbox(mailbox); | 485 | mail->setMbox(mailbox); |
472 | mail->setNumber(msg->msg_index); | 486 | mail->setNumber(msg->msg_index); |
473 | if (single_fields.fld_subject) | 487 | if (single_fields.fld_subject) |
474 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 488 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
475 | if (single_fields.fld_from) | 489 | if (single_fields.fld_from) |
476 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 490 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
477 | if (!mbox_as_to) { | 491 | if (!mbox_as_to) { |
478 | if (single_fields.fld_to) | 492 | if (single_fields.fld_to) |
479 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 493 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
480 | } else { | 494 | } else { |
481 | mail->setTo(mailbox); | 495 | mail->setTo(mailbox); |
482 | } | 496 | } |
483 | if (single_fields.fld_cc) | 497 | if (single_fields.fld_cc) |
484 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 498 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
485 | if (single_fields.fld_bcc) | 499 | if (single_fields.fld_bcc) |
486 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 500 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
487 | if (single_fields.fld_orig_date) { | 501 | if (single_fields.fld_orig_date) { |
488 | QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); | 502 | QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); |
489 | QString ret; | 503 | QString ret; |
490 | if ( dt.date() == QDate::currentDate () ) | 504 | if ( dt.date() == QDate::currentDate () ) |
491 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 505 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
492 | else { | 506 | else { |
493 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 507 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
494 | } | 508 | } |
495 | mail->setDate( ret ); | 509 | mail->setDate( ret ); |
496 | char tmp[20]; | 510 | char tmp[20]; |
497 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 511 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
498 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 512 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
499 | //qDebug(" iso %s ", tmp); | 513 | //qDebug(" iso %s ", tmp); |
500 | mail->setIsoDate( QString( tmp ) ); | 514 | mail->setIsoDate( QString( tmp ) ); |
501 | } | 515 | } |
502 | // crashes when accessing pop3 account? | 516 | // crashes when accessing pop3 account? |
503 | if (single_fields.fld_message_id) { | 517 | if (single_fields.fld_message_id) { |
504 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 518 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
505 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 519 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
506 | } | 520 | } |
507 | if (single_fields.fld_reply_to) { | 521 | if (single_fields.fld_reply_to) { |
508 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 522 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
509 | if (t.count()>0) { | 523 | if (t.count()>0) { |
510 | mail->setReplyto(t[0]); | 524 | mail->setReplyto(t[0]); |
511 | } | 525 | } |
512 | } | 526 | } |
513 | #if 0 | 527 | #if 0 |
514 | refs = single_fields.fld_references; | 528 | refs = single_fields.fld_references; |
515 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 529 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
516 | char * text = (char*)refs->mid_list->first->data; | 530 | char * text = (char*)refs->mid_list->first->data; |
517 | mail->setReplyto(QString(text)); | 531 | mail->setReplyto(QString(text)); |
518 | } | 532 | } |
519 | #endif | 533 | #endif |
520 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 534 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
521 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 535 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
522 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 536 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
523 | } | 537 | } |
524 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) | 538 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) |
525 | target.append(mail); | 539 | target.append(mail); |
526 | } | 540 | } |
527 | if (env_list) { | 541 | if (env_list) { |
528 | mailmessage_list_free(env_list); | 542 | mailmessage_list_free(env_list); |
529 | } | 543 | } |
530 | } | 544 | } |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index d90a8d2..eb2b47d 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -371,768 +371,787 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
371 | 371 | ||
372 | /* | 372 | /* |
373 | * second stage - get the other then inbox folders | 373 | * second stage - get the other then inbox folders |
374 | */ | 374 | */ |
375 | mask = "*" ; | 375 | mask = "*" ; |
376 | path = account->getPrefix().latin1(); | 376 | path = account->getPrefix().latin1(); |
377 | if (!path) path = ""; | 377 | if (!path) path = ""; |
378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
379 | if ( err == MAILIMAP_NO_ERROR ) { | 379 | if ( err == MAILIMAP_NO_ERROR ) { |
380 | current = result->first; | 380 | current = result->first; |
381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
382 | no_inferiors = false; | 382 | no_inferiors = false; |
383 | list = (mailimap_mailbox_list *) current->data; | 383 | list = (mailimap_mailbox_list *) current->data; |
384 | // it is better use the deep copy mechanism of qt itself | 384 | // it is better use the deep copy mechanism of qt itself |
385 | // instead of using strdup! | 385 | // instead of using strdup! |
386 | temp = list->mb_name; | 386 | temp = list->mb_name; |
387 | if (temp.lower()=="inbox") | 387 | if (temp.lower()=="inbox") |
388 | continue; | 388 | continue; |
389 | if (temp.lower()==account->getPrefix().lower()) | 389 | if (temp.lower()==account->getPrefix().lower()) |
390 | continue; | 390 | continue; |
391 | if ( (bflags = list->mb_flag) ) { | 391 | if ( (bflags = list->mb_flag) ) { |
392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
396 | no_inferiors = true; | 396 | no_inferiors = true; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | } | 399 | } |
400 | del = list->mb_delimiter; | 400 | del = list->mb_delimiter; |
401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
402 | } | 402 | } |
403 | } else { | 403 | } else { |
404 | qDebug("error fetching folders "); | 404 | qDebug("error fetching folders "); |
405 | 405 | ||
406 | } | 406 | } |
407 | if (result) mailimap_list_result_free( result ); | 407 | if (result) mailimap_list_result_free( result ); |
408 | return folders; | 408 | return folders; |
409 | } | 409 | } |
410 | 410 | ||
411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
412 | { | 412 | { |
413 | RecMail * m = 0; | 413 | RecMail * m = 0; |
414 | mailimap_msg_att_item *item=0; | 414 | mailimap_msg_att_item *item=0; |
415 | clistcell *current,*c,*cf; | 415 | clistcell *current,*c,*cf; |
416 | mailimap_msg_att_dynamic*flist; | 416 | mailimap_msg_att_dynamic*flist; |
417 | mailimap_flag_fetch*cflag; | 417 | mailimap_flag_fetch*cflag; |
418 | int size; | 418 | int size; |
419 | QBitArray mFlags(7); | 419 | QBitArray mFlags(7); |
420 | QStringList addresslist; | 420 | QStringList addresslist; |
421 | 421 | ||
422 | if (!m_att) { | 422 | if (!m_att) { |
423 | return m; | 423 | return m; |
424 | } | 424 | } |
425 | m = new RecMail(); | 425 | m = new RecMail(); |
426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
427 | current = c; | 427 | current = c; |
428 | size = 0; | 428 | size = 0; |
429 | item = (mailimap_msg_att_item*)current->data; | 429 | item = (mailimap_msg_att_item*)current->data; |
430 | if ( !item ) | 430 | if ( !item ) |
431 | continue; | 431 | continue; |
432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
434 | if (!flist || !flist->att_list) { | 434 | if (!flist || !flist->att_list) { |
435 | continue; | 435 | continue; |
436 | } | 436 | } |
437 | cf = flist->att_list->first; | 437 | cf = flist->att_list->first; |
438 | if( ! cf ) | 438 | if( ! cf ) |
439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
440 | cflag = (mailimap_flag_fetch*)cf->data; | 440 | cflag = (mailimap_flag_fetch*)cf->data; |
441 | if( ! cflag ) | 441 | if( ! cflag ) |
442 | qDebug("imap:not cflag "); | 442 | qDebug("imap:not cflag "); |
443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
444 | switch (cflag->fl_flag->fl_type) { | 444 | switch (cflag->fl_flag->fl_type) { |
445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
446 | mFlags.setBit(FLAG_ANSWERED); | 446 | mFlags.setBit(FLAG_ANSWERED); |
447 | break; | 447 | break; |
448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
449 | mFlags.setBit(FLAG_FLAGGED); | 449 | mFlags.setBit(FLAG_FLAGGED); |
450 | break; | 450 | break; |
451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
452 | mFlags.setBit(FLAG_DELETED); | 452 | mFlags.setBit(FLAG_DELETED); |
453 | break; | 453 | break; |
454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
455 | mFlags.setBit(FLAG_SEEN); | 455 | mFlags.setBit(FLAG_SEEN); |
456 | break; | 456 | break; |
457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
458 | mFlags.setBit(FLAG_DRAFT); | 458 | mFlags.setBit(FLAG_DRAFT); |
459 | break; | 459 | break; |
460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
461 | break; | 461 | break; |
462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
463 | break; | 463 | break; |
464 | default: | 464 | default: |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
468 | mFlags.setBit(FLAG_RECENT); | 468 | mFlags.setBit(FLAG_RECENT); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | continue; | 471 | continue; |
472 | } | 472 | } |
473 | if ( item->att_data.att_static == NULL ) | 473 | if ( item->att_data.att_static == NULL ) |
474 | continue; | 474 | continue; |
475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
477 | if ( head == NULL ) | 477 | if ( head == NULL ) |
478 | continue; | 478 | continue; |
479 | if ( head->env_date != NULL ) { | 479 | if ( head->env_date != NULL ) { |
480 | m->setDate(head->env_date); | 480 | m->setDate(head->env_date); |
481 | //struct mailimf_date_time result; | 481 | //struct mailimf_date_time result; |
482 | struct mailimf_date_time* date;// = &result; | 482 | struct mailimf_date_time* date;// = &result; |
483 | struct mailimf_date_time **re = &date; | 483 | struct mailimf_date_time **re = &date; |
484 | size_t length = m->getDate().length(); | 484 | size_t length = m->getDate().length(); |
485 | size_t index = 0; | 485 | size_t index = 0; |
486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
487 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 487 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
488 | QString ret; | 488 | QString ret; |
489 | if ( dt.date() == QDate::currentDate () ) | 489 | if ( dt.date() == QDate::currentDate () ) |
490 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 490 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
491 | else { | 491 | else { |
492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
493 | } | 493 | } |
494 | m->setDate( ret ); | 494 | m->setDate( ret ); |
495 | char tmp[20]; | 495 | char tmp[20]; |
496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
499 | m->setIsoDate( QString( tmp ) ); | 499 | m->setIsoDate( QString( tmp ) ); |
500 | mailimf_date_time_free ( date ); | 500 | mailimf_date_time_free ( date ); |
501 | } else { | 501 | } else { |
502 | m->setIsoDate(head->env_date); | 502 | m->setIsoDate(head->env_date); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | if ( head->env_subject != NULL ) | 505 | if ( head->env_subject != NULL ) |
506 | m->setSubject(convert_String((const char*)head->env_subject)); | 506 | m->setSubject(convert_String((const char*)head->env_subject)); |
507 | //m->setSubject(head->env_subject); | 507 | //m->setSubject(head->env_subject); |
508 | if (head->env_from!=NULL) { | 508 | if (head->env_from!=NULL) { |
509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
510 | if (addresslist.count()) { | 510 | if (addresslist.count()) { |
511 | m->setFrom(addresslist.first()); | 511 | m->setFrom(addresslist.first()); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | if (head->env_to!=NULL) { | 514 | if (head->env_to!=NULL) { |
515 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 515 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
516 | m->setTo(addresslist); | 516 | m->setTo(addresslist); |
517 | } | 517 | } |
518 | if (head->env_cc!=NULL) { | 518 | if (head->env_cc!=NULL) { |
519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
520 | m->setCC(addresslist); | 520 | m->setCC(addresslist); |
521 | } | 521 | } |
522 | if (head->env_bcc!=NULL) { | 522 | if (head->env_bcc!=NULL) { |
523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
524 | m->setBcc(addresslist); | 524 | m->setBcc(addresslist); |
525 | } | 525 | } |
526 | /* reply to address, eg. email. */ | 526 | /* reply to address, eg. email. */ |
527 | if (head->env_reply_to!=NULL) { | 527 | if (head->env_reply_to!=NULL) { |
528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
529 | if (addresslist.count()) { | 529 | if (addresslist.count()) { |
530 | m->setReplyto(addresslist.first()); | 530 | m->setReplyto(addresslist.first()); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | if (head->env_in_reply_to!=NULL) { | 533 | if (head->env_in_reply_to!=NULL) { |
534 | QString h(head->env_in_reply_to); | 534 | QString h(head->env_in_reply_to); |
535 | while (h.length()>0 && h[0]=='<') { | 535 | while (h.length()>0 && h[0]=='<') { |
536 | h.remove(0,1); | 536 | h.remove(0,1); |
537 | } | 537 | } |
538 | while (h.length()>0 && h[h.length()-1]=='>') { | 538 | while (h.length()>0 && h[h.length()-1]=='>') { |
539 | h.remove(h.length()-1,1); | 539 | h.remove(h.length()-1,1); |
540 | } | 540 | } |
541 | if (h.length()>0) { | 541 | if (h.length()>0) { |
542 | m->setInreply(QStringList(h)); | 542 | m->setInreply(QStringList(h)); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | if (head->env_message_id != NULL) { | 545 | if (head->env_message_id != NULL) { |
546 | m->setMsgid(QString(head->env_message_id)); | 546 | m->setMsgid(QString(head->env_message_id)); |
547 | } | 547 | } |
548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
549 | #if 0 | 549 | #if 0 |
550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
552 | qDebug("time %s ",da.toString().latin1() ); | 552 | qDebug("time %s ",da.toString().latin1() ); |
553 | #endif | 553 | #endif |
554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
555 | size = item->att_data.att_static->att_data.att_rfc822_size; | 555 | size = item->att_data.att_static->att_data.att_rfc822_size; |
556 | } | 556 | } |
557 | } | 557 | } |
558 | /* msg is already deleted */ | 558 | /* msg is already deleted */ |
559 | if (mFlags.testBit(FLAG_DELETED) && m) { | 559 | if (mFlags.testBit(FLAG_DELETED) && m) { |
560 | delete m; | 560 | delete m; |
561 | m = 0; | 561 | m = 0; |
562 | } | 562 | } |
563 | if (m) { | 563 | if (m) { |
564 | m->setFlags(mFlags); | 564 | m->setFlags(mFlags); |
565 | m->setMsgsize(size); | 565 | m->setMsgsize(size); |
566 | } | 566 | } |
567 | return m; | 567 | return m; |
568 | } | 568 | } |
569 | 569 | ||
570 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 570 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
571 | { | 571 | { |
572 | RecBodyP body = new RecBody(); | 572 | RecBodyP body = new RecBody(); |
573 | const char *mb; | 573 | const char *mb; |
574 | int err = MAILIMAP_NO_ERROR; | 574 | int err = MAILIMAP_NO_ERROR; |
575 | clist *result = 0; | 575 | clist *result = 0; |
576 | clistcell *current; | 576 | clistcell *current; |
577 | mailimap_fetch_att *fetchAtt = 0; | 577 | mailimap_fetch_att *fetchAtt = 0; |
578 | mailimap_fetch_type *fetchType = 0; | 578 | mailimap_fetch_type *fetchType = 0; |
579 | mailimap_set *set = 0; | 579 | mailimap_set *set = 0; |
580 | mailimap_body*body_desc = 0; | 580 | mailimap_body*body_desc = 0; |
581 | 581 | ||
582 | mb = mail->getMbox().latin1(); | 582 | mb = mail->getMbox().latin1(); |
583 | 583 | ||
584 | login(); | 584 | login(); |
585 | if (!m_imap) { | 585 | if (!m_imap) { |
586 | return body; | 586 | return body; |
587 | } | 587 | } |
588 | err = selectMbox(mail->getMbox()); | 588 | err = selectMbox(mail->getMbox()); |
589 | if ( err != MAILIMAP_NO_ERROR ) { | 589 | if ( err != MAILIMAP_NO_ERROR ) { |
590 | return body; | 590 | return body; |
591 | } | 591 | } |
592 | 592 | ||
593 | /* the range has to start at 1!!! not with 0!!!! */ | 593 | /* the range has to start at 1!!! not with 0!!!! */ |
594 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 594 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
595 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 595 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
596 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 596 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
597 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 597 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
598 | mailimap_set_free( set ); | 598 | mailimap_set_free( set ); |
599 | mailimap_fetch_type_free( fetchType ); | 599 | mailimap_fetch_type_free( fetchType ); |
600 | 600 | ||
601 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 601 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
602 | mailimap_msg_att * msg_att; | 602 | mailimap_msg_att * msg_att; |
603 | msg_att = (mailimap_msg_att*)current->data; | 603 | msg_att = (mailimap_msg_att*)current->data; |
604 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 604 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
605 | QValueList<int> path; | 605 | QValueList<int> path; |
606 | body_desc = item->att_data.att_static->att_data.att_body; | 606 | body_desc = item->att_data.att_static->att_data.att_body; |
607 | traverseBody(mail,body_desc,body,0,path); | 607 | traverseBody(mail,body_desc,body,0,path); |
608 | } else { | 608 | } else { |
609 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 609 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
610 | } | 610 | } |
611 | if (result) mailimap_fetch_list_free(result); | 611 | if (result) mailimap_fetch_list_free(result); |
612 | return body; | 612 | return body; |
613 | } | 613 | } |
614 | 614 | ||
615 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 615 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
616 | { | 616 | { |
617 | QStringList l; | 617 | QStringList l; |
618 | QString from; | 618 | QString from; |
619 | bool named_from; | 619 | bool named_from; |
620 | clistcell *current = NULL; | 620 | clistcell *current = NULL; |
621 | mailimap_address * current_address=NULL; | 621 | mailimap_address * current_address=NULL; |
622 | if (!list) { | 622 | if (!list) { |
623 | return l; | 623 | return l; |
624 | } | 624 | } |
625 | unsigned int count = 0; | 625 | unsigned int count = 0; |
626 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 626 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
627 | from = ""; | 627 | from = ""; |
628 | named_from = false; | 628 | named_from = false; |
629 | current_address=(mailimap_address*)current->data; | 629 | current_address=(mailimap_address*)current->data; |
630 | if (current_address->ad_personal_name){ | 630 | if (current_address->ad_personal_name){ |
631 | from+=convert_String((const char*)current_address->ad_personal_name); | 631 | from+=convert_String((const char*)current_address->ad_personal_name); |
632 | from+=" "; | 632 | from+=" "; |
633 | named_from = true; | 633 | named_from = true; |
634 | } | 634 | } |
635 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 635 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
636 | from+="<"; | 636 | from+="<"; |
637 | } | 637 | } |
638 | if (current_address->ad_mailbox_name) { | 638 | if (current_address->ad_mailbox_name) { |
639 | from+=QString(current_address->ad_mailbox_name); | 639 | from+=QString(current_address->ad_mailbox_name); |
640 | from+="@"; | 640 | from+="@"; |
641 | } | 641 | } |
642 | if (current_address->ad_host_name) { | 642 | if (current_address->ad_host_name) { |
643 | from+=QString(current_address->ad_host_name); | 643 | from+=QString(current_address->ad_host_name); |
644 | } | 644 | } |
645 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 645 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
646 | from+=">"; | 646 | from+=">"; |
647 | } | 647 | } |
648 | l.append(QString(from)); | 648 | l.append(QString(from)); |
649 | if (++count > 99) { | 649 | if (++count > 99) { |
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | } | 652 | } |
653 | return l; | 653 | return l; |
654 | } | 654 | } |
655 | 655 | ||
656 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 656 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
657 | { | 657 | { |
658 | encodedString*res=new encodedString; | 658 | encodedString*res=new encodedString; |
659 | int err; | 659 | int err; |
660 | mailimap_fetch_type *fetchType; | 660 | mailimap_fetch_type *fetchType; |
661 | mailimap_set *set; | 661 | mailimap_set *set; |
662 | clistcell*current,*cur; | 662 | clistcell*current,*cur; |
663 | mailimap_section_part * section_part = 0; | 663 | mailimap_section_part * section_part = 0; |
664 | mailimap_section_spec * section_spec = 0; | 664 | mailimap_section_spec * section_spec = 0; |
665 | mailimap_section * section = 0; | 665 | mailimap_section * section = 0; |
666 | mailimap_fetch_att * fetch_att = 0; | 666 | mailimap_fetch_att * fetch_att = 0; |
667 | 667 | ||
668 | login(); | 668 | login(); |
669 | if (!m_imap) { | 669 | if (!m_imap) { |
670 | return res; | 670 | return res; |
671 | } | 671 | } |
672 | if (!internal_call) { | 672 | if (!internal_call) { |
673 | err = selectMbox(mail->getMbox()); | 673 | err = selectMbox(mail->getMbox()); |
674 | if ( err != MAILIMAP_NO_ERROR ) { | 674 | if ( err != MAILIMAP_NO_ERROR ) { |
675 | return res; | 675 | return res; |
676 | } | 676 | } |
677 | } | 677 | } |
678 | set = mailimap_set_new_single(mail->getNumber()); | 678 | set = mailimap_set_new_single(mail->getNumber()); |
679 | 679 | ||
680 | clist*id_list = 0; | 680 | clist*id_list = 0; |
681 | 681 | ||
682 | /* if path == empty then its a request for the whole rfc822 mail and generates | 682 | /* if path == empty then its a request for the whole rfc822 mail and generates |
683 | a "fetch <id> (body[])" statement on imap server */ | 683 | a "fetch <id> (body[])" statement on imap server */ |
684 | if (path.count()>0 ) { | 684 | if (path.count()>0 ) { |
685 | id_list = clist_new(); | 685 | id_list = clist_new(); |
686 | for (unsigned j=0; j < path.count();++j) { | 686 | for (unsigned j=0; j < path.count();++j) { |
687 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 687 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
688 | *p_id = path[j]; | 688 | *p_id = path[j]; |
689 | clist_append(id_list,p_id); | 689 | clist_append(id_list,p_id); |
690 | } | 690 | } |
691 | section_part = mailimap_section_part_new(id_list); | 691 | section_part = mailimap_section_part_new(id_list); |
692 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 692 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
693 | } | 693 | } |
694 | 694 | ||
695 | section = mailimap_section_new(section_spec); | 695 | section = mailimap_section_new(section_spec); |
696 | fetch_att = mailimap_fetch_att_new_body_section(section); | 696 | fetch_att = mailimap_fetch_att_new_body_section(section); |
697 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 697 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
698 | 698 | ||
699 | clist*result = 0; | 699 | clist*result = 0; |
700 | 700 | ||
701 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 701 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
702 | mailimap_set_free( set ); | 702 | mailimap_set_free( set ); |
703 | mailimap_fetch_type_free( fetchType ); | 703 | mailimap_fetch_type_free( fetchType ); |
704 | 704 | ||
705 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 705 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
706 | mailimap_msg_att * msg_att; | 706 | mailimap_msg_att * msg_att; |
707 | msg_att = (mailimap_msg_att*)current->data; | 707 | msg_att = (mailimap_msg_att*)current->data; |
708 | mailimap_msg_att_item*msg_att_item; | 708 | mailimap_msg_att_item*msg_att_item; |
709 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 709 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
710 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 710 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
711 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 711 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
712 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 712 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
713 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 713 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
714 | /* detach - we take over the content */ | 714 | /* detach - we take over the content */ |
715 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 715 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
716 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 716 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | } | 719 | } |
720 | } else { | 720 | } else { |
721 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 721 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
722 | } | 722 | } |
723 | if (result) mailimap_fetch_list_free(result); | 723 | if (result) mailimap_fetch_list_free(result); |
724 | return res; | 724 | return res; |
725 | } | 725 | } |
726 | 726 | ||
727 | /* current_recursion is for recursive calls. | 727 | /* current_recursion is for recursive calls. |
728 | current_count means the position inside the internal loop! */ | 728 | current_count means the position inside the internal loop! */ |
729 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 729 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
730 | int current_recursion,QValueList<int>recList,int current_count) | 730 | int current_recursion,QValueList<int>recList,int current_count) |
731 | { | 731 | { |
732 | if (!body || current_recursion>=10) { | 732 | if (!body || current_recursion>=10) { |
733 | return; | 733 | return; |
734 | } | 734 | } |
735 | switch (body->bd_type) { | 735 | switch (body->bd_type) { |
736 | case MAILIMAP_BODY_1PART: | 736 | case MAILIMAP_BODY_1PART: |
737 | { | 737 | { |
738 | QValueList<int>countlist = recList; | 738 | QValueList<int>countlist = recList; |
739 | countlist.append(current_count); | 739 | countlist.append(current_count); |
740 | RecPartP currentPart = new RecPart(); | 740 | RecPartP currentPart = new RecPart(); |
741 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 741 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
742 | QString id(""); | 742 | QString id(""); |
743 | currentPart->setPositionlist(countlist); | 743 | currentPart->setPositionlist(countlist); |
744 | for (unsigned int j = 0; j < countlist.count();++j) { | 744 | for (unsigned int j = 0; j < countlist.count();++j) { |
745 | id+=(j>0?" ":""); | 745 | id+=(j>0?" ":""); |
746 | id+=QString("%1").arg(countlist[j]); | 746 | id+=QString("%1").arg(countlist[j]); |
747 | } | 747 | } |
748 | //odebug << "ID = " << id.latin1() << "" << oendl; | 748 | //odebug << "ID = " << id.latin1() << "" << oendl; |
749 | currentPart->setIdentifier(id); | 749 | currentPart->setIdentifier(id); |
750 | fillSinglePart(currentPart,part1); | 750 | fillSinglePart(currentPart,part1); |
751 | /* important: Check for is NULL 'cause a body can be empty! | 751 | /* important: Check for is NULL 'cause a body can be empty! |
752 | And we put it only into the mail if it is the FIRST part */ | 752 | And we put it only into the mail if it is the FIRST part */ |
753 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 753 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
754 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 754 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
755 | |||
756 | size_t index = 0; | ||
757 | char*res = 0; | ||
758 | int err = MAILIMF_NO_ERROR; | ||
759 | |||
760 | QString charset = currentPart->searchParamter( "charset"); | ||
761 | qDebug("CHARSET %s ",charset.latin1() ); | ||
762 | //if ( false ) { | ||
763 | if ( !charset.isEmpty() ) { | ||
764 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | ||
765 | // text, strlen(text),&index, "iso-8859-1",&res); | ||
766 | err = mailmime_encoded_phrase_parse(charset.latin1(), | ||
767 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); | ||
768 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | ||
769 | //qDebug("res %d %s ", index, res); | ||
770 | body_text = QString::fromUtf8(res); | ||
771 | } | ||
772 | if (res) free(res); | ||
773 | } | ||
755 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); | 774 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); |
756 | target_body->setDescription(currentPart); | 775 | target_body->setDescription(currentPart); |
757 | target_body->setBodytext(body_text); | 776 | target_body->setBodytext(body_text); |
758 | if (countlist.count()>1) { | 777 | if (countlist.count()>1) { |
759 | target_body->addPart(currentPart); | 778 | target_body->addPart(currentPart); |
760 | } | 779 | } |
761 | } else { | 780 | } else { |
762 | target_body->addPart(currentPart); | 781 | target_body->addPart(currentPart); |
763 | } | 782 | } |
764 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 783 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
765 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 784 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
766 | } | 785 | } |
767 | } | 786 | } |
768 | break; | 787 | break; |
769 | case MAILIMAP_BODY_MPART: | 788 | case MAILIMAP_BODY_MPART: |
770 | { | 789 | { |
771 | QValueList<int>countlist = recList; | 790 | QValueList<int>countlist = recList; |
772 | clistcell*current=0; | 791 | clistcell*current=0; |
773 | mailimap_body*current_body=0; | 792 | mailimap_body*current_body=0; |
774 | unsigned int ccount = 1; | 793 | unsigned int ccount = 1; |
775 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 794 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
776 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 795 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
777 | current_body = (mailimap_body*)current->data; | 796 | current_body = (mailimap_body*)current->data; |
778 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 797 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
779 | RecPartP targetPart = new RecPart(); | 798 | RecPartP targetPart = new RecPart(); |
780 | targetPart->setType("multipart"); | 799 | targetPart->setType("multipart"); |
781 | fillMultiPart(targetPart,mailDescription); | 800 | fillMultiPart(targetPart,mailDescription); |
782 | countlist.append(current_count); | 801 | countlist.append(current_count); |
783 | targetPart->setPositionlist(countlist); | 802 | targetPart->setPositionlist(countlist); |
784 | target_body->addPart(targetPart); | 803 | target_body->addPart(targetPart); |
785 | QString id(""); | 804 | QString id(""); |
786 | for (unsigned int j = 0; j < countlist.count();++j) { | 805 | for (unsigned int j = 0; j < countlist.count();++j) { |
787 | id+=(j>0?" ":""); | 806 | id+=(j>0?" ":""); |
788 | id+=QString("%1").arg(countlist[j]); | 807 | id+=QString("%1").arg(countlist[j]); |
789 | } | 808 | } |
790 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 809 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
791 | } | 810 | } |
792 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 811 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
793 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 812 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
794 | countlist = recList; | 813 | countlist = recList; |
795 | } | 814 | } |
796 | ++ccount; | 815 | ++ccount; |
797 | } | 816 | } |
798 | } | 817 | } |
799 | break; | 818 | break; |
800 | default: | 819 | default: |
801 | break; | 820 | break; |
802 | } | 821 | } |
803 | } | 822 | } |
804 | 823 | ||
805 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 824 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
806 | { | 825 | { |
807 | if (!Description) { | 826 | if (!Description) { |
808 | return; | 827 | return; |
809 | } | 828 | } |
810 | switch (Description->bd_type) { | 829 | switch (Description->bd_type) { |
811 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 830 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
812 | target_part->setType("text"); | 831 | target_part->setType("text"); |
813 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 832 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
814 | break; | 833 | break; |
815 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 834 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
816 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 835 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
817 | break; | 836 | break; |
818 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 837 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
819 | target_part->setType("message"); | 838 | target_part->setType("message"); |
820 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 839 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
821 | break; | 840 | break; |
822 | default: | 841 | default: |
823 | break; | 842 | break; |
824 | } | 843 | } |
825 | } | 844 | } |
826 | 845 | ||
827 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 846 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
828 | { | 847 | { |
829 | if (!which) { | 848 | if (!which) { |
830 | return; | 849 | return; |
831 | } | 850 | } |
832 | QString sub; | 851 | QString sub; |
833 | sub = which->bd_media_text; | 852 | sub = which->bd_media_text; |
834 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 853 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
835 | target_part->setSubtype(sub.lower()); | 854 | target_part->setSubtype(sub.lower()); |
836 | target_part->setLines(which->bd_lines); | 855 | target_part->setLines(which->bd_lines); |
837 | fillBodyFields(target_part,which->bd_fields); | 856 | fillBodyFields(target_part,which->bd_fields); |
838 | } | 857 | } |
839 | 858 | ||
840 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 859 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
841 | { | 860 | { |
842 | if (!which) { | 861 | if (!which) { |
843 | return; | 862 | return; |
844 | } | 863 | } |
845 | target_part->setSubtype("rfc822"); | 864 | target_part->setSubtype("rfc822"); |
846 | //odebug << "Message part" << oendl; | 865 | //odebug << "Message part" << oendl; |
847 | /* we set this type to text/plain */ | 866 | /* we set this type to text/plain */ |
848 | target_part->setLines(which->bd_lines); | 867 | target_part->setLines(which->bd_lines); |
849 | fillBodyFields(target_part,which->bd_fields); | 868 | fillBodyFields(target_part,which->bd_fields); |
850 | } | 869 | } |
851 | 870 | ||
852 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 871 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
853 | { | 872 | { |
854 | if (!which) return; | 873 | if (!which) return; |
855 | QString sub = which->bd_media_subtype; | 874 | QString sub = which->bd_media_subtype; |
856 | target_part->setSubtype(sub.lower()); | 875 | target_part->setSubtype(sub.lower()); |
857 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 876 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
858 | clistcell*cur = 0; | 877 | clistcell*cur = 0; |
859 | mailimap_single_body_fld_param*param=0; | 878 | mailimap_single_body_fld_param*param=0; |
860 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 879 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
861 | param = (mailimap_single_body_fld_param*)cur->data; | 880 | param = (mailimap_single_body_fld_param*)cur->data; |
862 | if (param) { | 881 | if (param) { |
863 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 882 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
864 | } | 883 | } |
865 | } | 884 | } |
866 | } | 885 | } |
867 | } | 886 | } |
868 | 887 | ||
869 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 888 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
870 | { | 889 | { |
871 | if (!which) { | 890 | if (!which) { |
872 | return; | 891 | return; |
873 | } | 892 | } |
874 | QString type,sub; | 893 | QString type,sub; |
875 | switch (which->bd_media_basic->med_type) { | 894 | switch (which->bd_media_basic->med_type) { |
876 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 895 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
877 | type = "application"; | 896 | type = "application"; |
878 | break; | 897 | break; |
879 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 898 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
880 | type = "audio"; | 899 | type = "audio"; |
881 | break; | 900 | break; |
882 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 901 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
883 | type = "image"; | 902 | type = "image"; |
884 | break; | 903 | break; |
885 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 904 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
886 | type = "message"; | 905 | type = "message"; |
887 | break; | 906 | break; |
888 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 907 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
889 | type = "video"; | 908 | type = "video"; |
890 | break; | 909 | break; |
891 | case MAILIMAP_MEDIA_BASIC_OTHER: | 910 | case MAILIMAP_MEDIA_BASIC_OTHER: |
892 | default: | 911 | default: |
893 | if (which->bd_media_basic->med_basic_type) { | 912 | if (which->bd_media_basic->med_basic_type) { |
894 | type = which->bd_media_basic->med_basic_type; | 913 | type = which->bd_media_basic->med_basic_type; |
895 | } else { | 914 | } else { |
896 | type = ""; | 915 | type = ""; |
897 | } | 916 | } |
898 | break; | 917 | break; |
899 | } | 918 | } |
900 | if (which->bd_media_basic->med_subtype) { | 919 | if (which->bd_media_basic->med_subtype) { |
901 | sub = which->bd_media_basic->med_subtype; | 920 | sub = which->bd_media_basic->med_subtype; |
902 | } else { | 921 | } else { |
903 | sub = ""; | 922 | sub = ""; |
904 | } | 923 | } |
905 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 924 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
906 | target_part->setType(type.lower()); | 925 | target_part->setType(type.lower()); |
907 | target_part->setSubtype(sub.lower()); | 926 | target_part->setSubtype(sub.lower()); |
908 | fillBodyFields(target_part,which->bd_fields); | 927 | fillBodyFields(target_part,which->bd_fields); |
909 | } | 928 | } |
910 | 929 | ||
911 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 930 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
912 | { | 931 | { |
913 | if (!which) return; | 932 | if (!which) return; |
914 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 933 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
915 | clistcell*cur; | 934 | clistcell*cur; |
916 | mailimap_single_body_fld_param*param=0; | 935 | mailimap_single_body_fld_param*param=0; |
917 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 936 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
918 | param = (mailimap_single_body_fld_param*)cur->data; | 937 | param = (mailimap_single_body_fld_param*)cur->data; |
919 | if (param) { | 938 | if (param) { |
920 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 939 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
921 | } | 940 | } |
922 | } | 941 | } |
923 | } | 942 | } |
924 | mailimap_body_fld_enc*enc = which->bd_encoding; | 943 | mailimap_body_fld_enc*enc = which->bd_encoding; |
925 | QString encoding(""); | 944 | QString encoding(""); |
926 | switch (enc->enc_type) { | 945 | switch (enc->enc_type) { |
927 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 946 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
928 | encoding = "7bit"; | 947 | encoding = "7bit"; |
929 | break; | 948 | break; |
930 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 949 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
931 | encoding = "8bit"; | 950 | encoding = "8bit"; |
932 | break; | 951 | break; |
933 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 952 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
934 | encoding="binary"; | 953 | encoding="binary"; |
935 | break; | 954 | break; |
936 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 955 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
937 | encoding="base64"; | 956 | encoding="base64"; |
938 | break; | 957 | break; |
939 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 958 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
940 | encoding="quoted-printable"; | 959 | encoding="quoted-printable"; |
941 | break; | 960 | break; |
942 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 961 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
943 | default: | 962 | default: |
944 | if (enc->enc_value) { | 963 | if (enc->enc_value) { |
945 | char*t=enc->enc_value; | 964 | char*t=enc->enc_value; |
946 | encoding=QString(enc->enc_value); | 965 | encoding=QString(enc->enc_value); |
947 | enc->enc_value=0L; | 966 | enc->enc_value=0L; |
948 | free(t); | 967 | free(t); |
949 | } | 968 | } |
950 | } | 969 | } |
951 | if (which->bd_description) { | 970 | if (which->bd_description) { |
952 | target_part->setDescription(QString(which->bd_description)); | 971 | target_part->setDescription(QString(which->bd_description)); |
953 | } | 972 | } |
954 | target_part->setEncoding(encoding); | 973 | target_part->setEncoding(encoding); |
955 | target_part->setSize(which->bd_size); | 974 | target_part->setSize(which->bd_size); |
956 | } | 975 | } |
957 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 976 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
958 | { | 977 | { |
959 | //#if 0 | 978 | //#if 0 |
960 | mailimap_flag_list*flist; | 979 | mailimap_flag_list*flist; |
961 | mailimap_set *set; | 980 | mailimap_set *set; |
962 | mailimap_store_att_flags * store_flags; | 981 | mailimap_store_att_flags * store_flags; |
963 | int err; | 982 | int err; |
964 | login(); | 983 | login(); |
965 | //#endif | 984 | //#endif |
966 | if (!m_imap) { | 985 | if (!m_imap) { |
967 | return; | 986 | return; |
968 | } | 987 | } |
969 | int iii = 0; | 988 | int iii = 0; |
970 | int count = target.count(); | 989 | int count = target.count(); |
971 | // qDebug("imap remove count %d ", count); | 990 | // qDebug("imap remove count %d ", count); |
972 | 991 | ||
973 | 992 | ||
974 | mMax = count; | 993 | mMax = count; |
975 | progress( i18n("Delete")); | 994 | progress( i18n("Delete")); |
976 | 995 | ||
977 | QProgressBar wid ( count ); | 996 | QProgressBar wid ( count ); |
978 | wid.setCaption( i18n("Deleting ...")); | 997 | wid.setCaption( i18n("Deleting ...")); |
979 | wid.show(); | 998 | wid.show(); |
980 | while (iii < count ) { | 999 | while (iii < count ) { |
981 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 1000 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
982 | wid.setProgress( iii ); | 1001 | wid.setProgress( iii ); |
983 | wid.raise(); | 1002 | wid.raise(); |
984 | qApp->processEvents(); | 1003 | qApp->processEvents(); |
985 | RecMailP mail = (*target.at( iii )); | 1004 | RecMailP mail = (*target.at( iii )); |
986 | //#if 0 | 1005 | //#if 0 |
987 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 1006 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
988 | err = selectMbox(mail->getMbox()); | 1007 | err = selectMbox(mail->getMbox()); |
989 | if ( err != MAILIMAP_NO_ERROR ) { | 1008 | if ( err != MAILIMAP_NO_ERROR ) { |
990 | return; | 1009 | return; |
991 | } | 1010 | } |
992 | flist = mailimap_flag_list_new_empty(); | 1011 | flist = mailimap_flag_list_new_empty(); |
993 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1012 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
994 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1013 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
995 | set = mailimap_set_new_single(mail->getNumber()); | 1014 | set = mailimap_set_new_single(mail->getNumber()); |
996 | err = mailimap_store(m_imap,set,store_flags); | 1015 | err = mailimap_store(m_imap,set,store_flags); |
997 | mailimap_set_free( set ); | 1016 | mailimap_set_free( set ); |
998 | mailimap_store_att_flags_free(store_flags); | 1017 | mailimap_store_att_flags_free(store_flags); |
999 | 1018 | ||
1000 | if (err != MAILIMAP_NO_ERROR) { | 1019 | if (err != MAILIMAP_NO_ERROR) { |
1001 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1020 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1002 | return; | 1021 | return; |
1003 | } | 1022 | } |
1004 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1023 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1005 | /* should we realy do that at this moment? */ | 1024 | /* should we realy do that at this moment? */ |
1006 | 1025 | ||
1007 | // err = mailimap_expunge(m_imap); | 1026 | // err = mailimap_expunge(m_imap); |
1008 | //if (err != MAILIMAP_NO_ERROR) { | 1027 | //if (err != MAILIMAP_NO_ERROR) { |
1009 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1028 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1010 | // } | 1029 | // } |
1011 | //#endif | 1030 | //#endif |
1012 | //deleteMail( mail); | 1031 | //deleteMail( mail); |
1013 | ++iii; | 1032 | ++iii; |
1014 | } | 1033 | } |
1015 | //qDebug("Deleting imap mails... "); | 1034 | //qDebug("Deleting imap mails... "); |
1016 | err = mailimap_expunge(m_imap); | 1035 | err = mailimap_expunge(m_imap); |
1017 | if (err != MAILIMAP_NO_ERROR) { | 1036 | if (err != MAILIMAP_NO_ERROR) { |
1018 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1037 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1019 | } | 1038 | } |
1020 | } | 1039 | } |
1021 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1040 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1022 | { | 1041 | { |
1023 | mailimap_flag_list*flist; | 1042 | mailimap_flag_list*flist; |
1024 | mailimap_set *set; | 1043 | mailimap_set *set; |
1025 | mailimap_store_att_flags * store_flags; | 1044 | mailimap_store_att_flags * store_flags; |
1026 | int err; | 1045 | int err; |
1027 | login(); | 1046 | login(); |
1028 | if (!m_imap) { | 1047 | if (!m_imap) { |
1029 | return; | 1048 | return; |
1030 | } | 1049 | } |
1031 | err = selectMbox(mail->getMbox()); | 1050 | err = selectMbox(mail->getMbox()); |
1032 | if ( err != MAILIMAP_NO_ERROR ) { | 1051 | if ( err != MAILIMAP_NO_ERROR ) { |
1033 | return; | 1052 | return; |
1034 | } | 1053 | } |
1035 | flist = mailimap_flag_list_new_empty(); | 1054 | flist = mailimap_flag_list_new_empty(); |
1036 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1055 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1037 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1056 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1038 | set = mailimap_set_new_single(mail->getNumber()); | 1057 | set = mailimap_set_new_single(mail->getNumber()); |
1039 | err = mailimap_store(m_imap,set,store_flags); | 1058 | err = mailimap_store(m_imap,set,store_flags); |
1040 | mailimap_set_free( set ); | 1059 | mailimap_set_free( set ); |
1041 | mailimap_store_att_flags_free(store_flags); | 1060 | mailimap_store_att_flags_free(store_flags); |
1042 | 1061 | ||
1043 | if (err != MAILIMAP_NO_ERROR) { | 1062 | if (err != MAILIMAP_NO_ERROR) { |
1044 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1063 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1045 | return; | 1064 | return; |
1046 | } | 1065 | } |
1047 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1066 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1048 | /* should we realy do that at this moment? */ | 1067 | /* should we realy do that at this moment? */ |
1049 | 1068 | ||
1050 | err = mailimap_expunge(m_imap); | 1069 | err = mailimap_expunge(m_imap); |
1051 | if (err != MAILIMAP_NO_ERROR) { | 1070 | if (err != MAILIMAP_NO_ERROR) { |
1052 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1071 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1053 | } | 1072 | } |
1054 | //qDebug("IMAPwrapper::deleteMail 2"); | 1073 | //qDebug("IMAPwrapper::deleteMail 2"); |
1055 | 1074 | ||
1056 | } | 1075 | } |
1057 | 1076 | ||
1058 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1077 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1059 | { | 1078 | { |
1060 | mailimap_flag_list*flist; | 1079 | mailimap_flag_list*flist; |
1061 | mailimap_set *set; | 1080 | mailimap_set *set; |
1062 | mailimap_store_att_flags * store_flags; | 1081 | mailimap_store_att_flags * store_flags; |
1063 | int err; | 1082 | int err; |
1064 | login(); | 1083 | login(); |
1065 | if (!m_imap) { | 1084 | if (!m_imap) { |
1066 | return; | 1085 | return; |
1067 | } | 1086 | } |
1068 | err = selectMbox(mail->getMbox()); | 1087 | err = selectMbox(mail->getMbox()); |
1069 | if ( err != MAILIMAP_NO_ERROR ) { | 1088 | if ( err != MAILIMAP_NO_ERROR ) { |
1070 | return; | 1089 | return; |
1071 | } | 1090 | } |
1072 | flist = mailimap_flag_list_new_empty(); | 1091 | flist = mailimap_flag_list_new_empty(); |
1073 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1092 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1074 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1093 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1075 | set = mailimap_set_new_single(mail->getNumber()); | 1094 | set = mailimap_set_new_single(mail->getNumber()); |
1076 | err = mailimap_store(m_imap,set,store_flags); | 1095 | err = mailimap_store(m_imap,set,store_flags); |
1077 | mailimap_set_free( set ); | 1096 | mailimap_set_free( set ); |
1078 | mailimap_store_att_flags_free(store_flags); | 1097 | mailimap_store_att_flags_free(store_flags); |
1079 | 1098 | ||
1080 | if (err != MAILIMAP_NO_ERROR) { | 1099 | if (err != MAILIMAP_NO_ERROR) { |
1081 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1100 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1082 | return; | 1101 | return; |
1083 | } | 1102 | } |
1084 | } | 1103 | } |
1085 | 1104 | ||
1086 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1105 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1087 | { | 1106 | { |
1088 | QString body(""); | 1107 | QString body(""); |
1089 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1108 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1090 | encodedString*r = decode_String(res,enc); | 1109 | encodedString*r = decode_String(res,enc); |
1091 | delete res; | 1110 | delete res; |
1092 | if (r) { | 1111 | if (r) { |
1093 | if (r->Length()>0) { | 1112 | if (r->Length()>0) { |
1094 | body = r->Content(); | 1113 | body = r->Content(); |
1095 | } | 1114 | } |
1096 | delete r; | 1115 | delete r; |
1097 | } | 1116 | } |
1098 | return body; | 1117 | return body; |
1099 | } | 1118 | } |
1100 | 1119 | ||
1101 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1120 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1102 | { | 1121 | { |
1103 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1122 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1104 | } | 1123 | } |
1105 | 1124 | ||
1106 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1125 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1107 | { | 1126 | { |
1108 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1127 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1109 | encodedString*r = decode_String(res,part->Encoding()); | 1128 | encodedString*r = decode_String(res,part->Encoding()); |
1110 | delete res; | 1129 | delete res; |
1111 | return r; | 1130 | return r; |
1112 | } | 1131 | } |
1113 | 1132 | ||
1114 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1133 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1115 | { | 1134 | { |
1116 | return fetchRawPart(mail,part->Positionlist(),false); | 1135 | return fetchRawPart(mail,part->Positionlist(),false); |
1117 | } | 1136 | } |
1118 | 1137 | ||
1119 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1138 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1120 | { | 1139 | { |
1121 | login(); | 1140 | login(); |
1122 | if (!m_imap) { | 1141 | if (!m_imap) { |
1123 | return 0; | 1142 | return 0; |
1124 | } | 1143 | } |
1125 | mailimap_flag_list*flist; | 1144 | mailimap_flag_list*flist; |
1126 | mailimap_set *set; | 1145 | mailimap_set *set; |
1127 | mailimap_store_att_flags * store_flags; | 1146 | mailimap_store_att_flags * store_flags; |
1128 | int err = selectMbox(folder->getName()); | 1147 | int err = selectMbox(folder->getName()); |
1129 | if ( err != MAILIMAP_NO_ERROR ) { | 1148 | if ( err != MAILIMAP_NO_ERROR ) { |
1130 | return 0; | 1149 | return 0; |
1131 | } | 1150 | } |
1132 | 1151 | ||
1133 | int last = m_imap->imap_selection_info->sel_exists; | 1152 | int last = m_imap->imap_selection_info->sel_exists; |
1134 | if (last == 0) { | 1153 | if (last == 0) { |
1135 | Global::statusMessage(i18n("Mailbox has no mails!")); | 1154 | Global::statusMessage(i18n("Mailbox has no mails!")); |
1136 | return 0; | 1155 | return 0; |
1137 | } | 1156 | } |
1138 | flist = mailimap_flag_list_new_empty(); | 1157 | flist = mailimap_flag_list_new_empty(); |
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp index 0cdbae4..87f8c8a 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.cpp +++ b/kmicromail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,339 +1,340 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <klocale.h> | 7 | #include <klocale.h> |
8 | 8 | ||
9 | 9 | ||
10 | #include <qpe/global.h> | 10 | #include <qpe/global.h> |
11 | 11 | ||
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
13 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 14 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
15 | { | 15 | { |
16 | QDir dir(MBOXPath); | 16 | QDir dir(MBOXPath); |
17 | if (!dir.exists()) { | 17 | if (!dir.exists()) { |
18 | dir.mkdir(MBOXPath); | 18 | dir.mkdir(MBOXPath); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 | ||
22 | MBOXwrapper::~MBOXwrapper() | 22 | MBOXwrapper::~MBOXwrapper() |
23 | { | 23 | { |
24 | } | 24 | } |
25 | 25 | ||
26 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 26 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) |
27 | { | 27 | { |
28 | mailstorage*storage = mailstorage_new(NULL); | 28 | mailstorage*storage = mailstorage_new(NULL); |
29 | QString p = MBOXPath+"/"; | 29 | QString p = MBOXPath+"/"; |
30 | p+=mailbox; | 30 | p+=mailbox; |
31 | 31 | ||
32 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 32 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
33 | mailfolder*folder; | 33 | mailfolder*folder; |
34 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 34 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
35 | r = mailfolder_connect(folder); | 35 | r = mailfolder_connect(folder); |
36 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
37 | //odebug << "Error initializing mbox" << oendl; | 37 | //odebug << "Error initializing mbox" << oendl; |
38 | mailfolder_free(folder); | 38 | mailfolder_free(folder); |
39 | mailstorage_free(storage); | 39 | mailstorage_free(storage); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | 42 | ||
43 | parseList(target,folder->fld_session,mailbox); | 43 | parseList(target,folder->fld_session,mailbox); |
44 | 44 | ||
45 | mailfolder_disconnect(folder); | 45 | mailfolder_disconnect(folder); |
46 | mailfolder_free(folder); | 46 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 47 | mailstorage_free(storage); |
48 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 48 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
49 | } | 49 | } |
50 | 50 | ||
51 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 51 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
52 | { | 52 | { |
53 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 53 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
54 | QDir dir(MBOXPath); | 54 | QDir dir(MBOXPath); |
55 | if (!dir.exists()) return folders; | 55 | if (!dir.exists()) return folders; |
56 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 56 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
57 | QStringList entries = dir.entryList(); | 57 | QStringList entries = dir.entryList(); |
58 | QStringList::ConstIterator it = entries.begin(); | 58 | QStringList::ConstIterator it = entries.begin(); |
59 | for (;it!=entries.end();++it) { | 59 | for (;it!=entries.end();++it) { |
60 | FolderP inb=new Folder(*it,"/"); | 60 | FolderP inb=new Folder(*it,"/"); |
61 | folders->append(inb); | 61 | folders->append(inb); |
62 | } | 62 | } |
63 | return folders; | 63 | return folders; |
64 | } | 64 | } |
65 | 65 | ||
66 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 66 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
67 | { | 67 | { |
68 | mailstorage*storage = mailstorage_new(NULL); | 68 | mailstorage*storage = mailstorage_new(NULL); |
69 | QString p = MBOXPath+"/"; | 69 | QString p = MBOXPath+"/"; |
70 | p+=mail->getMbox(); | 70 | p+=mail->getMbox(); |
71 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 71 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
72 | mailfolder*folder; | 72 | mailfolder*folder; |
73 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 73 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
74 | r = mailfolder_connect(folder); | 74 | r = mailfolder_connect(folder); |
75 | if (r != MAIL_NO_ERROR) { | 75 | if (r != MAIL_NO_ERROR) { |
76 | ; // << "Error initializing mbox" << oendl; | 76 | ; // << "Error initializing mbox" << oendl; |
77 | mailfolder_free(folder); | 77 | mailfolder_free(folder); |
78 | mailstorage_free(storage); | 78 | mailstorage_free(storage); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); | 81 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); |
82 | if (r != MAIL_NO_ERROR) { | 82 | if (r != MAIL_NO_ERROR) { |
83 | ; // << "error deleting mail" << oendl; | 83 | ; // << "error deleting mail" << oendl; |
84 | } | 84 | } |
85 | mailfolder_free(folder); | 85 | mailfolder_free(folder); |
86 | mailstorage_free(storage); | 86 | mailstorage_free(storage); |
87 | } | 87 | } |
88 | 88 | ||
89 | void MBOXwrapper::answeredMail(const RecMailP&) | 89 | void MBOXwrapper::answeredMail(const RecMailP&) |
90 | { | 90 | { |
91 | } | 91 | } |
92 | 92 | ||
93 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) | 93 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) |
94 | { | 94 | { |
95 | RecBodyP body = new RecBody(); | 95 | RecBodyP body = new RecBody(); |
96 | mailstorage*storage = mailstorage_new(NULL); | 96 | mailstorage*storage = mailstorage_new(NULL); |
97 | QString p = MBOXPath+"/"; | 97 | QString p = MBOXPath+"/"; |
98 | p+=mail->getMbox(); | 98 | p+=mail->getMbox(); |
99 | mailmessage * msg; | 99 | mailmessage * msg; |
100 | char*data=0; | 100 | char*data=0; |
101 | size_t size; | 101 | size_t size; |
102 | 102 | ||
103 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 103 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
104 | mailfolder*folder; | 104 | mailfolder*folder; |
105 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 105 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
106 | r = mailfolder_connect(folder); | 106 | r = mailfolder_connect(folder); |
107 | if (r != MAIL_NO_ERROR) { | 107 | if (r != MAIL_NO_ERROR) { |
108 | ; // << "Error initializing mbox" << oendl; | 108 | ; // << "Error initializing mbox" << oendl; |
109 | mailfolder_free(folder); | 109 | mailfolder_free(folder); |
110 | mailstorage_free(storage); | 110 | mailstorage_free(storage); |
111 | return body; | 111 | return body; |
112 | } | 112 | } |
113 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 113 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
114 | if (r != MAIL_NO_ERROR) { | 114 | if (r != MAIL_NO_ERROR) { |
115 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; | 115 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; |
116 | mailfolder_free(folder); | 116 | mailfolder_free(folder); |
117 | mailstorage_free(storage); | 117 | mailstorage_free(storage); |
118 | return body; | 118 | return body; |
119 | } | 119 | } |
120 | r = mailmessage_fetch(msg,&data,&size); | 120 | r = mailmessage_fetch(msg,&data,&size); |
121 | if (r != MAIL_NO_ERROR) { | 121 | if (r != MAIL_NO_ERROR) { |
122 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; | 122 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; |
123 | mailfolder_free(folder); | 123 | mailfolder_free(folder); |
124 | mailstorage_free(storage); | 124 | mailstorage_free(storage); |
125 | mailmessage_free(msg); | 125 | mailmessage_free(msg); |
126 | return body; | 126 | return body; |
127 | } | 127 | } |
128 | qDebug("MBOXwrapper::fetchBody "); | ||
128 | body = parseMail(msg); | 129 | body = parseMail(msg); |
129 | mailmessage_fetch_result_free(msg,data); | 130 | mailmessage_fetch_result_free(msg,data); |
130 | mailfolder_free(folder); | 131 | mailfolder_free(folder); |
131 | mailstorage_free(storage); | 132 | mailstorage_free(storage); |
132 | 133 | ||
133 | return body; | 134 | return body; |
134 | } | 135 | } |
135 | 136 | ||
136 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 137 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
137 | { | 138 | { |
138 | ; // << "MBOX " << current << " von " << maximum << "" << oendl; | 139 | ; // << "MBOX " << current << " von " << maximum << "" << oendl; |
139 | } | 140 | } |
140 | 141 | ||
141 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) | 142 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
142 | { | 143 | { |
143 | QString p = MBOXPath+"/"; | 144 | QString p = MBOXPath+"/"; |
144 | p+=folder; | 145 | p+=folder; |
145 | QFileInfo fi(p); | 146 | QFileInfo fi(p); |
146 | if (fi.exists()) { | 147 | if (fi.exists()) { |
147 | Global::statusMessage(i18n("Mailbox exists.")); | 148 | Global::statusMessage(i18n("Mailbox exists.")); |
148 | return 0; | 149 | return 0; |
149 | } | 150 | } |
150 | mailmbox_folder*f = 0; | 151 | mailmbox_folder*f = 0; |
151 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 152 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
152 | Global::statusMessage(i18n("Error init folder")); | 153 | Global::statusMessage(i18n("Error init folder")); |
153 | return 0; | 154 | return 0; |
154 | } | 155 | } |
155 | if (f) mailmbox_done(f); | 156 | if (f) mailmbox_done(f); |
156 | return 1; | 157 | return 1; |
157 | } | 158 | } |
158 | 159 | ||
159 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 160 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
160 | { | 161 | { |
161 | QString p = MBOXPath+"/"; | 162 | QString p = MBOXPath+"/"; |
162 | p+=folder; | 163 | p+=folder; |
163 | mailmbox_folder*f = 0; | 164 | mailmbox_folder*f = 0; |
164 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 165 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
165 | if (r != MAIL_NO_ERROR) { | 166 | if (r != MAIL_NO_ERROR) { |
166 | Global::statusMessage(i18n("Error init folder")); | 167 | Global::statusMessage(i18n("Error init folder")); |
167 | return; | 168 | return; |
168 | } | 169 | } |
169 | r = mailmbox_append_message(f,msg,length); | 170 | r = mailmbox_append_message(f,msg,length); |
170 | if (r != MAIL_NO_ERROR) { | 171 | if (r != MAIL_NO_ERROR) { |
171 | Global::statusMessage(i18n("Error writing to message folder")); | 172 | Global::statusMessage(i18n("Error writing to message folder")); |
172 | } | 173 | } |
173 | mailmbox_done(f); | 174 | mailmbox_done(f); |
174 | } | 175 | } |
175 | 176 | ||
176 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | 177 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) |
177 | { | 178 | { |
178 | RecBody body; | 179 | RecBody body; |
179 | mailstorage*storage = mailstorage_new(NULL); | 180 | mailstorage*storage = mailstorage_new(NULL); |
180 | QString p = MBOXPath+"/"; | 181 | QString p = MBOXPath+"/"; |
181 | p+=mail->getMbox(); | 182 | p+=mail->getMbox(); |
182 | mailmessage * msg; | 183 | mailmessage * msg; |
183 | char*data=0; | 184 | char*data=0; |
184 | size_t size; | 185 | size_t size; |
185 | 186 | ||
186 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 187 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
187 | mailfolder*folder; | 188 | mailfolder*folder; |
188 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 189 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
189 | r = mailfolder_connect(folder); | 190 | r = mailfolder_connect(folder); |
190 | if (r != MAIL_NO_ERROR) { | 191 | if (r != MAIL_NO_ERROR) { |
191 | Global::statusMessage(i18n("Error initializing mbox")); | 192 | Global::statusMessage(i18n("Error initializing mbox")); |
192 | mailfolder_free(folder); | 193 | mailfolder_free(folder); |
193 | mailstorage_free(storage); | 194 | mailstorage_free(storage); |
194 | return 0; | 195 | return 0; |
195 | } | 196 | } |
196 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 197 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
197 | if (r != MAIL_NO_ERROR) { | 198 | if (r != MAIL_NO_ERROR) { |
198 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 199 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
199 | mailfolder_free(folder); | 200 | mailfolder_free(folder); |
200 | mailstorage_free(storage); | 201 | mailstorage_free(storage); |
201 | return 0; | 202 | return 0; |
202 | } | 203 | } |
203 | r = mailmessage_fetch(msg,&data,&size); | 204 | r = mailmessage_fetch(msg,&data,&size); |
204 | if (r != MAIL_NO_ERROR) { | 205 | if (r != MAIL_NO_ERROR) { |
205 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 206 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
206 | mailfolder_free(folder); | 207 | mailfolder_free(folder); |
207 | mailstorage_free(storage); | 208 | mailstorage_free(storage); |
208 | mailmessage_free(msg); | 209 | mailmessage_free(msg); |
209 | return 0; | 210 | return 0; |
210 | } | 211 | } |
211 | encodedString*result = new encodedString(data,size); | 212 | encodedString*result = new encodedString(data,size); |
212 | 213 | ||
213 | mailfolder_free(folder); | 214 | mailfolder_free(folder); |
214 | mailstorage_free(storage); | 215 | mailstorage_free(storage); |
215 | mailmessage_free(msg); | 216 | mailmessage_free(msg); |
216 | return result; | 217 | return result; |
217 | } | 218 | } |
218 | 219 | ||
219 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 220 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
220 | { | 221 | { |
221 | QString p = MBOXPath+"/"; | 222 | QString p = MBOXPath+"/"; |
222 | p+=mailbox; | 223 | p+=mailbox; |
223 | mailmbox_folder*f = 0; | 224 | mailmbox_folder*f = 0; |
224 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
225 | if (r != MAIL_NO_ERROR) { | 226 | if (r != MAIL_NO_ERROR) { |
226 | ; // << "Error init folder" << oendl; | 227 | ; // << "Error init folder" << oendl; |
227 | return; | 228 | return; |
228 | } | 229 | } |
229 | deleteMails(f,target); | 230 | deleteMails(f,target); |
230 | mailmbox_done(f); | 231 | mailmbox_done(f); |
231 | } | 232 | } |
232 | 233 | ||
233 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) | 234 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) |
234 | { | 235 | { |
235 | if (!f) return; | 236 | if (!f) return; |
236 | int r; | 237 | int r; |
237 | QValueList<RecMailP>::ConstIterator it; | 238 | QValueList<RecMailP>::ConstIterator it; |
238 | for (it=target.begin(); it != target.end();++it) { | 239 | for (it=target.begin(); it != target.end();++it) { |
239 | r = mailmbox_delete_msg(f,(*it)->getNumber()); | 240 | r = mailmbox_delete_msg(f,(*it)->getNumber()); |
240 | if (r!=MAILMBOX_NO_ERROR) { | 241 | if (r!=MAILMBOX_NO_ERROR) { |
241 | ; // << "error delete mail" << oendl; | 242 | ; // << "error delete mail" << oendl; |
242 | } | 243 | } |
243 | } | 244 | } |
244 | r = mailmbox_expunge(f); | 245 | r = mailmbox_expunge(f); |
245 | if (r != MAILMBOX_NO_ERROR) { | 246 | if (r != MAILMBOX_NO_ERROR) { |
246 | ; // << "error expunge mailbox" << oendl; | 247 | ; // << "error expunge mailbox" << oendl; |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) | 251 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) |
251 | { | 252 | { |
252 | if (!tfolder) return 0; | 253 | if (!tfolder) return 0; |
253 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 254 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
254 | int res = 1; | 255 | int res = 1; |
255 | 256 | ||
256 | mailfolder*folder = 0; | 257 | mailfolder*folder = 0; |
257 | mailmessage_list*l=0; | 258 | mailmessage_list*l=0; |
258 | mailstorage*storage = mailstorage_new(NULL); | 259 | mailstorage*storage = mailstorage_new(NULL); |
259 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 260 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
260 | if (r != MAIL_NO_ERROR) { | 261 | if (r != MAIL_NO_ERROR) { |
261 | Global::statusMessage(i18n("Error initializing mbox")); | 262 | Global::statusMessage(i18n("Error initializing mbox")); |
262 | res = 0; | 263 | res = 0; |
263 | } | 264 | } |
264 | if (res) { | 265 | if (res) { |
265 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 266 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
266 | r = mailfolder_connect(folder); | 267 | r = mailfolder_connect(folder); |
267 | if (r != MAIL_NO_ERROR) { | 268 | if (r != MAIL_NO_ERROR) { |
268 | Global::statusMessage(i18n("Error initializing mbox")); | 269 | Global::statusMessage(i18n("Error initializing mbox")); |
269 | res = 0; | 270 | res = 0; |
270 | } | 271 | } |
271 | } | 272 | } |
272 | if (res) { | 273 | if (res) { |
273 | r = mailsession_get_messages_list(folder->fld_session,&l); | 274 | r = mailsession_get_messages_list(folder->fld_session,&l); |
274 | if (r != MAIL_NO_ERROR) { | 275 | if (r != MAIL_NO_ERROR) { |
275 | ; // << "Error message list" << oendl; | 276 | ; // << "Error message list" << oendl; |
276 | res=0; | 277 | res=0; |
277 | } | 278 | } |
278 | } | 279 | } |
279 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 280 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
280 | r = mailsession_remove_message(folder->fld_session,i+1); | 281 | r = mailsession_remove_message(folder->fld_session,i+1); |
281 | if (r != MAIL_NO_ERROR) { | 282 | if (r != MAIL_NO_ERROR) { |
282 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); | 283 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
283 | res = 0; | 284 | res = 0; |
284 | break; | 285 | break; |
285 | } | 286 | } |
286 | } | 287 | } |
287 | if (l) mailmessage_list_free(l); | 288 | if (l) mailmessage_list_free(l); |
288 | if (folder) mailfolder_free(folder); | 289 | if (folder) mailfolder_free(folder); |
289 | if (storage) mailstorage_free(storage); | 290 | if (storage) mailstorage_free(storage); |
290 | return res; | 291 | return res; |
291 | } | 292 | } |
292 | 293 | ||
293 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) | 294 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) |
294 | { | 295 | { |
295 | if (!tfolder) return 0; | 296 | if (!tfolder) return 0; |
296 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 297 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
297 | QFile fi(p); | 298 | QFile fi(p); |
298 | if (!fi.exists()) { | 299 | if (!fi.exists()) { |
299 | Global::statusMessage(i18n("Mailbox doesn't exist.")); | 300 | Global::statusMessage(i18n("Mailbox doesn't exist.")); |
300 | return 0; | 301 | return 0; |
301 | } | 302 | } |
302 | if (!fi.remove()) { | 303 | if (!fi.remove()) { |
303 | Global::statusMessage(i18n("Error deleting Mailbox.")); | 304 | Global::statusMessage(i18n("Error deleting Mailbox.")); |
304 | return 0; | 305 | return 0; |
305 | } | 306 | } |
306 | return 1; | 307 | return 1; |
307 | } | 308 | } |
308 | 309 | ||
309 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 310 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
310 | { | 311 | { |
311 | mailfolder*folder = 0; | 312 | mailfolder*folder = 0; |
312 | mailstorage*storage = mailstorage_new(NULL); | 313 | mailstorage*storage = mailstorage_new(NULL); |
313 | target_stat.message_count = 0; | 314 | target_stat.message_count = 0; |
314 | target_stat.message_unseen = 0; | 315 | target_stat.message_unseen = 0; |
315 | target_stat.message_recent = 0; | 316 | target_stat.message_recent = 0; |
316 | QString p = MBOXPath+"/"+mailbox; | 317 | QString p = MBOXPath+"/"+mailbox; |
317 | QFile fi(p); | 318 | QFile fi(p); |
318 | if (!fi.exists()) { | 319 | if (!fi.exists()) { |
319 | Global::statusMessage(i18n("Mailbox doesn't exist.")); | 320 | Global::statusMessage(i18n("Mailbox doesn't exist.")); |
320 | return; | 321 | return; |
321 | } | 322 | } |
322 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 323 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
323 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 324 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
324 | r = mailfolder_connect(folder); | 325 | r = mailfolder_connect(folder); |
325 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 326 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
326 | &target_stat.message_recent,&target_stat.message_unseen); | 327 | &target_stat.message_recent,&target_stat.message_unseen); |
327 | if (folder) mailfolder_free(folder); | 328 | if (folder) mailfolder_free(folder); |
328 | if (storage) mailstorage_free(storage); | 329 | if (storage) mailstorage_free(storage); |
329 | } | 330 | } |
330 | 331 | ||
331 | MAILLIB::ATYPE MBOXwrapper::getType()const | 332 | MAILLIB::ATYPE MBOXwrapper::getType()const |
332 | { | 333 | { |
333 | return MAILLIB::A_MBOX; | 334 | return MAILLIB::A_MBOX; |
334 | } | 335 | } |
335 | 336 | ||
336 | const QString&MBOXwrapper::getName()const | 337 | const QString&MBOXwrapper::getName()const |
337 | { | 338 | { |
338 | return MBOXName; | 339 | return MBOXName; |
339 | } | 340 | } |
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index 90b5d23..982d7a6 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,450 +1,451 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "mhwrapper.h" | 2 | #include "mhwrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <klocale.h> | 10 | #include <klocale.h> |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | 13 | ||
14 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
15 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 15 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
16 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 16 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
17 | { | 17 | { |
18 | if (MHPath.length()>0) { | 18 | if (MHPath.length()>0) { |
19 | if (MHPath[MHPath.length()-1]=='/') { | 19 | if (MHPath[MHPath.length()-1]=='/') { |
20 | MHPath=MHPath.left(MHPath.length()-1); | 20 | MHPath=MHPath.left(MHPath.length()-1); |
21 | } | 21 | } |
22 | //odebug << MHPath << oendl; | 22 | //odebug << MHPath << oendl; |
23 | QDir dir(MHPath); | 23 | QDir dir(MHPath); |
24 | if (!dir.exists()) { | 24 | if (!dir.exists()) { |
25 | dir.mkdir(MHPath); | 25 | dir.mkdir(MHPath); |
26 | } | 26 | } |
27 | init_storage(); | 27 | init_storage(); |
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | void MHwrapper::init_storage() | 31 | void MHwrapper::init_storage() |
32 | { | 32 | { |
33 | int r; | 33 | int r; |
34 | QString pre = MHPath; | 34 | QString pre = MHPath; |
35 | if (!m_storage) { | 35 | if (!m_storage) { |
36 | m_storage = mailstorage_new(NULL); | 36 | m_storage = mailstorage_new(NULL); |
37 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 37 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
38 | if (r != MAIL_NO_ERROR) { | 38 | if (r != MAIL_NO_ERROR) { |
39 | qDebug(" error init storage "); | 39 | qDebug(" error init storage "); |
40 | mailstorage_free(m_storage); | 40 | mailstorage_free(m_storage); |
41 | m_storage = 0; | 41 | m_storage = 0; |
42 | return; | 42 | return; |
43 | } | 43 | } |
44 | } | 44 | } |
45 | r = mailstorage_connect(m_storage); | 45 | r = mailstorage_connect(m_storage); |
46 | if (r!=MAIL_NO_ERROR) { | 46 | if (r!=MAIL_NO_ERROR) { |
47 | qDebug("error connecting storage "); | 47 | qDebug("error connecting storage "); |
48 | mailstorage_free(m_storage); | 48 | mailstorage_free(m_storage); |
49 | m_storage = 0; | 49 | m_storage = 0; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | void MHwrapper::clean_storage() | 53 | void MHwrapper::clean_storage() |
54 | { | 54 | { |
55 | if (m_storage) { | 55 | if (m_storage) { |
56 | mailstorage_disconnect(m_storage); | 56 | mailstorage_disconnect(m_storage); |
57 | mailstorage_free(m_storage); | 57 | mailstorage_free(m_storage); |
58 | m_storage = 0; | 58 | m_storage = 0; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | MHwrapper::~MHwrapper() | 62 | MHwrapper::~MHwrapper() |
63 | { | 63 | { |
64 | clean_storage(); | 64 | clean_storage(); |
65 | } | 65 | } |
66 | 66 | ||
67 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 67 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
68 | { | 68 | { |
69 | init_storage(); | 69 | init_storage(); |
70 | if (!m_storage) { | 70 | if (!m_storage) { |
71 | return; | 71 | return; |
72 | } | 72 | } |
73 | QString f = buildPath(mailbox); | 73 | QString f = buildPath(mailbox); |
74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
75 | if (r!=MAIL_NO_ERROR) { | 75 | if (r!=MAIL_NO_ERROR) { |
76 | qDebug("listMessages: error selecting folder! "); | 76 | qDebug("listMessages: error selecting folder! "); |
77 | return; | 77 | return; |
78 | } | 78 | } |
79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
80 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 80 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
81 | } | 81 | } |
82 | 82 | ||
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
84 | { | 84 | { |
85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
86 | /* this is needed! */ | 86 | /* this is needed! */ |
87 | if (m_storage) mailstorage_disconnect(m_storage); | 87 | if (m_storage) mailstorage_disconnect(m_storage); |
88 | init_storage(); | 88 | init_storage(); |
89 | if (!m_storage) { | 89 | if (!m_storage) { |
90 | return folders; | 90 | return folders; |
91 | } | 91 | } |
92 | mail_list*flist = 0; | 92 | mail_list*flist = 0; |
93 | clistcell*current=0; | 93 | clistcell*current=0; |
94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
95 | if (r != MAIL_NO_ERROR || !flist) { | 95 | if (r != MAIL_NO_ERROR || !flist) { |
96 | qDebug("error getting folder list "); | 96 | qDebug("error getting folder list "); |
97 | return folders; | 97 | return folders; |
98 | } | 98 | } |
99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
100 | QString t = (char*)current->data; | 100 | QString t = (char*)current->data; |
101 | t.replace(0,MHPath.length(),""); | 101 | t.replace(0,MHPath.length(),""); |
102 | folders->append(new MHFolder(t,MHPath)); | 102 | folders->append(new MHFolder(t,MHPath)); |
103 | } | 103 | } |
104 | mail_list_free(flist); | 104 | mail_list_free(flist); |
105 | return folders; | 105 | return folders; |
106 | } | 106 | } |
107 | 107 | ||
108 | void MHwrapper::deleteMail(const RecMailP&mail) | 108 | void MHwrapper::deleteMail(const RecMailP&mail) |
109 | { | 109 | { |
110 | init_storage(); | 110 | init_storage(); |
111 | if (!m_storage) { | 111 | if (!m_storage) { |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
115 | if (r!=MAIL_NO_ERROR) { | 115 | if (r!=MAIL_NO_ERROR) { |
116 | qDebug("error selecting folder! "); | 116 | qDebug("error selecting folder! "); |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 119 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
120 | if (r != MAIL_NO_ERROR) { | 120 | if (r != MAIL_NO_ERROR) { |
121 | qDebug("error deleting mail "); | 121 | qDebug("error deleting mail "); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | void MHwrapper::answeredMail(const RecMailP&) | 125 | void MHwrapper::answeredMail(const RecMailP&) |
126 | { | 126 | { |
127 | } | 127 | } |
128 | 128 | ||
129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
130 | { | 130 | { |
131 | qDebug("MHwrapper::fetchBody "); | ||
131 | RecBodyP body = new RecBody(); | 132 | RecBodyP body = new RecBody(); |
132 | init_storage(); | 133 | init_storage(); |
133 | if (!m_storage) { | 134 | if (!m_storage) { |
134 | return body; | 135 | return body; |
135 | } | 136 | } |
136 | mailmessage * msg; | 137 | mailmessage * msg; |
137 | char*data=0; | 138 | char*data=0; |
138 | 139 | ||
139 | /* mail should hold the complete path! */ | 140 | /* mail should hold the complete path! */ |
140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 141 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
141 | if (r != MAIL_NO_ERROR) { | 142 | if (r != MAIL_NO_ERROR) { |
142 | return body; | 143 | return body; |
143 | } | 144 | } |
144 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 145 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
145 | if (r != MAIL_NO_ERROR) { | 146 | if (r != MAIL_NO_ERROR) { |
146 | qDebug("Error fetching mail "); | 147 | qDebug("Error fetching mail "); |
147 | 148 | ||
148 | return body; | 149 | return body; |
149 | } | 150 | } |
150 | body = parseMail(msg); | 151 | body = parseMail(msg); |
151 | mailmessage_fetch_result_free(msg,data); | 152 | mailmessage_fetch_result_free(msg,data); |
152 | return body; | 153 | return body; |
153 | } | 154 | } |
154 | 155 | ||
155 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 156 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
156 | { | 157 | { |
157 | qDebug("MBox Progress %d of %d",current,maximum ); | 158 | qDebug("MBox Progress %d of %d",current,maximum ); |
158 | //odebug << "MH " << current << " von " << maximum << "" << oendl; | 159 | //odebug << "MH " << current << " von " << maximum << "" << oendl; |
159 | } | 160 | } |
160 | 161 | ||
161 | QString MHwrapper::buildPath(const QString&p) | 162 | QString MHwrapper::buildPath(const QString&p) |
162 | { | 163 | { |
163 | QString f=""; | 164 | QString f=""; |
164 | if (p.length()==0||p=="/") | 165 | if (p.length()==0||p=="/") |
165 | return MHPath; | 166 | return MHPath; |
166 | if (!p.startsWith(MHPath)) { | 167 | if (!p.startsWith(MHPath)) { |
167 | f+=MHPath; | 168 | f+=MHPath; |
168 | } | 169 | } |
169 | if (!p.startsWith("/")) { | 170 | if (!p.startsWith("/")) { |
170 | f+="/"; | 171 | f+="/"; |
171 | } | 172 | } |
172 | f+=p; | 173 | f+=p; |
173 | return f; | 174 | return f; |
174 | } | 175 | } |
175 | 176 | ||
176 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) | 177 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
177 | { | 178 | { |
178 | init_storage(); | 179 | init_storage(); |
179 | if (!m_storage) { | 180 | if (!m_storage) { |
180 | return 0; | 181 | return 0; |
181 | } | 182 | } |
182 | QString f; | 183 | QString f; |
183 | if (!pfolder) { | 184 | if (!pfolder) { |
184 | // toplevel folder | 185 | // toplevel folder |
185 | f = buildPath(folder); | 186 | f = buildPath(folder); |
186 | } else { | 187 | } else { |
187 | f = pfolder->getName(); | 188 | f = pfolder->getName(); |
188 | f+="/"; | 189 | f+="/"; |
189 | f+=folder; | 190 | f+=folder; |
190 | } | 191 | } |
191 | 192 | ||
192 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 193 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
193 | if (r != MAIL_NO_ERROR) { | 194 | if (r != MAIL_NO_ERROR) { |
194 | qDebug("error creating folder "); | 195 | qDebug("error creating folder "); |
195 | return 0; | 196 | return 0; |
196 | } | 197 | } |
197 | return 1; | 198 | return 1; |
198 | } | 199 | } |
199 | 200 | ||
200 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 201 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
201 | { | 202 | { |
202 | init_storage(); | 203 | init_storage(); |
203 | if (!m_storage) { | 204 | if (!m_storage) { |
204 | return; | 205 | return; |
205 | } | 206 | } |
206 | QString f = buildPath(Folder); | 207 | QString f = buildPath(Folder); |
207 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 208 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
208 | if (r!=MAIL_NO_ERROR) { | 209 | if (r!=MAIL_NO_ERROR) { |
209 | qDebug("error selecting folder! "); | 210 | qDebug("error selecting folder! "); |
210 | return; | 211 | return; |
211 | } | 212 | } |
212 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 213 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
213 | if (r!=MAIL_NO_ERROR) { | 214 | if (r!=MAIL_NO_ERROR) { |
214 | qDebug("error storing mail "); | 215 | qDebug("error storing mail "); |
215 | } | 216 | } |
216 | return; | 217 | return; |
217 | } | 218 | } |
218 | 219 | ||
219 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 220 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
220 | { | 221 | { |
221 | encodedString*result = 0; | 222 | encodedString*result = 0; |
222 | init_storage(); | 223 | init_storage(); |
223 | if (!m_storage) { | 224 | if (!m_storage) { |
224 | return result; | 225 | return result; |
225 | } | 226 | } |
226 | mailmessage * msg = 0; | 227 | mailmessage * msg = 0; |
227 | char*data=0; | 228 | char*data=0; |
228 | size_t size; | 229 | size_t size; |
229 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 230 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
230 | if (r!=MAIL_NO_ERROR) { | 231 | if (r!=MAIL_NO_ERROR) { |
231 | qDebug("error selecting folder! "); | 232 | qDebug("error selecting folder! "); |
232 | return result; | 233 | return result; |
233 | } | 234 | } |
234 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 235 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
235 | if (r != MAIL_NO_ERROR) { | 236 | if (r != MAIL_NO_ERROR) { |
236 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 237 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
237 | return 0; | 238 | return 0; |
238 | } | 239 | } |
239 | r = mailmessage_fetch(msg,&data,&size); | 240 | r = mailmessage_fetch(msg,&data,&size); |
240 | if (r != MAIL_NO_ERROR) { | 241 | if (r != MAIL_NO_ERROR) { |
241 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 242 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
242 | if (msg) mailmessage_free(msg); | 243 | if (msg) mailmessage_free(msg); |
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | result = new encodedString(data,size); | 246 | result = new encodedString(data,size); |
246 | if (msg) mailmessage_free(msg); | 247 | if (msg) mailmessage_free(msg); |
247 | return result; | 248 | return result; |
248 | } | 249 | } |
249 | 250 | ||
250 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 251 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
251 | { | 252 | { |
252 | QString f = buildPath(mailbox); | 253 | QString f = buildPath(mailbox); |
253 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 254 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
254 | if (r!=MAIL_NO_ERROR) { | 255 | if (r!=MAIL_NO_ERROR) { |
255 | qDebug("deleteMails: error selecting folder! "); | 256 | qDebug("deleteMails: error selecting folder! "); |
256 | return; | 257 | return; |
257 | } | 258 | } |
258 | QValueList<RecMailP>::ConstIterator it; | 259 | QValueList<RecMailP>::ConstIterator it; |
259 | for (it=target.begin(); it!=target.end();++it) { | 260 | for (it=target.begin(); it!=target.end();++it) { |
260 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 261 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
261 | if (r != MAIL_NO_ERROR) { | 262 | if (r != MAIL_NO_ERROR) { |
262 | qDebug("error deleting mail "); | 263 | qDebug("error deleting mail "); |
263 | break; | 264 | break; |
264 | } | 265 | } |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||
268 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 269 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
269 | { | 270 | { |
270 | init_storage(); | 271 | init_storage(); |
271 | if (!m_storage) { | 272 | if (!m_storage) { |
272 | return 0; | 273 | return 0; |
273 | } | 274 | } |
274 | int res = 1; | 275 | int res = 1; |
275 | if (!tfolder) return 0; | 276 | if (!tfolder) return 0; |
276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 277 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
277 | if (r!=MAIL_NO_ERROR) { | 278 | if (r!=MAIL_NO_ERROR) { |
278 | qDebug("error selecting folder! "); | 279 | qDebug("error selecting folder! "); |
279 | return 0; | 280 | return 0; |
280 | } | 281 | } |
281 | mailmessage_list*l=0; | 282 | mailmessage_list*l=0; |
282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 283 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
283 | if (r != MAIL_NO_ERROR) { | 284 | if (r != MAIL_NO_ERROR) { |
284 | qDebug("Error message list "); | 285 | qDebug("Error message list "); |
285 | res = 0; | 286 | res = 0; |
286 | } | 287 | } |
287 | unsigned j = 0; | 288 | unsigned j = 0; |
288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 289 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
289 | mailmessage * msg; | 290 | mailmessage * msg; |
290 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 291 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
291 | j = msg->msg_index; | 292 | j = msg->msg_index; |
292 | r = mailsession_remove_message(m_storage->sto_session,j); | 293 | r = mailsession_remove_message(m_storage->sto_session,j); |
293 | if (r != MAIL_NO_ERROR) { | 294 | if (r != MAIL_NO_ERROR) { |
294 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); | 295 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
295 | res = 0; | 296 | res = 0; |
296 | break; | 297 | break; |
297 | } | 298 | } |
298 | } | 299 | } |
299 | if (l) mailmessage_list_free(l); | 300 | if (l) mailmessage_list_free(l); |
300 | return res; | 301 | return res; |
301 | } | 302 | } |
302 | bool MHwrapper::rmDir(QString folder) // absolute path! | 303 | bool MHwrapper::rmDir(QString folder) // absolute path! |
303 | { | 304 | { |
304 | QDir dir ( folder ); | 305 | QDir dir ( folder ); |
305 | if ( !dir.exists() ) | 306 | if ( !dir.exists() ) |
306 | return false; | 307 | return false; |
307 | int i; | 308 | int i; |
308 | // qDebug("rmdir %s ",folder.latin1()); | 309 | // qDebug("rmdir %s ",folder.latin1()); |
309 | QStringList list = dir.entryList(QDir::Dirs|QDir::Files|QDir::NoSymLinks|QDir::Hidden ); | 310 | QStringList list = dir.entryList(QDir::Dirs|QDir::Files|QDir::NoSymLinks|QDir::Hidden ); |
310 | for (i=0; i<list.count(); i++ ) { | 311 | for (i=0; i<list.count(); i++ ) { |
311 | bool result = true; | 312 | bool result = true; |
312 | QString entry = folder+"/"+ list[i] ; | 313 | QString entry = folder+"/"+ list[i] ; |
313 | //qDebug("entry %s ",entry.latin1() ); | 314 | //qDebug("entry %s ",entry.latin1() ); |
314 | 315 | ||
315 | QFileInfo fi ( entry ); | 316 | QFileInfo fi ( entry ); |
316 | if ( fi.isFile() ) { | 317 | if ( fi.isFile() ) { |
317 | //qDebug("file %s ",entry.latin1() ); | 318 | //qDebug("file %s ",entry.latin1() ); |
318 | result = QFile::remove ( entry ) ; | 319 | result = QFile::remove ( entry ) ; |
319 | } else { | 320 | } else { |
320 | //qDebug("dir %s ",entry.latin1()); | 321 | //qDebug("dir %s ",entry.latin1()); |
321 | if ( list[i] != "." && list[i] != ".." ) | 322 | if ( list[i] != "." && list[i] != ".." ) |
322 | result = rmDir( entry ); | 323 | result = rmDir( entry ); |
323 | } | 324 | } |
324 | if ( ! result ) | 325 | if ( ! result ) |
325 | return false; | 326 | return false; |
326 | } | 327 | } |
327 | //qDebug("removing... "); | 328 | //qDebug("removing... "); |
328 | return QDir::root().rmdir ( folder, true ); | 329 | return QDir::root().rmdir ( folder, true ); |
329 | } | 330 | } |
330 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 331 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
331 | { | 332 | { |
332 | init_storage(); | 333 | init_storage(); |
333 | if (!m_storage) { | 334 | if (!m_storage) { |
334 | return 0; | 335 | return 0; |
335 | } | 336 | } |
336 | if (!tfolder) return 0; | 337 | if (!tfolder) return 0; |
337 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 338 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
338 | 339 | ||
339 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 340 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
340 | 341 | ||
341 | if (r != MAIL_NO_ERROR) { | 342 | if (r != MAIL_NO_ERROR) { |
342 | qDebug("error deleting mail box "); | 343 | qDebug("error deleting mail box "); |
343 | return 0; | 344 | return 0; |
344 | } | 345 | } |
345 | //qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() ); | 346 | //qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() ); |
346 | if ( !rmDir( tfolder->getName() )) { | 347 | if ( !rmDir( tfolder->getName() )) { |
347 | qDebug("error deleteing folder %s ",tfolder->getName().latin1()); | 348 | qDebug("error deleteing folder %s ",tfolder->getName().latin1()); |
348 | } | 349 | } |
349 | else | 350 | else |
350 | qDebug("mail box deleted %s ", tfolder->getName().latin1()); | 351 | qDebug("mail box deleted %s ", tfolder->getName().latin1()); |
351 | return 1; | 352 | return 1; |
352 | } | 353 | } |
353 | 354 | ||
354 | 355 | ||
355 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 356 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
356 | { | 357 | { |
357 | init_storage(); | 358 | init_storage(); |
358 | if (!m_storage) { | 359 | if (!m_storage) { |
359 | return; | 360 | return; |
360 | } | 361 | } |
361 | target_stat.message_count = 0; | 362 | target_stat.message_count = 0; |
362 | target_stat.message_unseen = 0; | 363 | target_stat.message_unseen = 0; |
363 | target_stat.message_recent = 0; | 364 | target_stat.message_recent = 0; |
364 | QString f = buildPath(mailbox); | 365 | QString f = buildPath(mailbox); |
365 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 366 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
366 | &target_stat.message_recent,&target_stat.message_unseen); | 367 | &target_stat.message_recent,&target_stat.message_unseen); |
367 | if (r != MAIL_NO_ERROR) { | 368 | if (r != MAIL_NO_ERROR) { |
368 | Global::statusMessage(i18n("Error retrieving status")); | 369 | Global::statusMessage(i18n("Error retrieving status")); |
369 | } | 370 | } |
370 | } | 371 | } |
371 | 372 | ||
372 | MAILLIB::ATYPE MHwrapper::getType()const | 373 | MAILLIB::ATYPE MHwrapper::getType()const |
373 | { | 374 | { |
374 | return MAILLIB::A_MH; | 375 | return MAILLIB::A_MH; |
375 | } | 376 | } |
376 | 377 | ||
377 | const QString&MHwrapper::getName()const | 378 | const QString&MHwrapper::getName()const |
378 | { | 379 | { |
379 | return MHName; | 380 | return MHName; |
380 | } | 381 | } |
381 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 382 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
382 | { | 383 | { |
383 | init_storage(); | 384 | init_storage(); |
384 | if (!m_storage) { | 385 | if (!m_storage) { |
385 | return; | 386 | return; |
386 | } | 387 | } |
387 | if (targetWrapper != this) { | 388 | if (targetWrapper != this) { |
388 | qDebug("Using generic "); | 389 | qDebug("Using generic "); |
389 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 390 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
390 | return; | 391 | return; |
391 | } | 392 | } |
392 | qDebug("Using internal routines for move/copy "); | 393 | qDebug("Using internal routines for move/copy "); |
393 | QString tf = buildPath(targetFolder); | 394 | QString tf = buildPath(targetFolder); |
394 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 395 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
395 | if (r != MAIL_NO_ERROR) { | 396 | if (r != MAIL_NO_ERROR) { |
396 | qDebug("Error selecting source mailbox "); | 397 | qDebug("Error selecting source mailbox "); |
397 | return; | 398 | return; |
398 | } | 399 | } |
399 | if (moveit) { | 400 | if (moveit) { |
400 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 401 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
401 | } else { | 402 | } else { |
402 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 403 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
403 | } | 404 | } |
404 | if (r != MAIL_NO_ERROR) { | 405 | if (r != MAIL_NO_ERROR) { |
405 | qDebug("Error copy/moving mail internal "); | 406 | qDebug("Error copy/moving mail internal "); |
406 | } | 407 | } |
407 | } | 408 | } |
408 | 409 | ||
409 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 410 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
410 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 411 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
411 | { | 412 | { |
412 | init_storage(); | 413 | init_storage(); |
413 | if (!m_storage) { | 414 | if (!m_storage) { |
414 | return; | 415 | return; |
415 | } | 416 | } |
416 | if (targetWrapper != this) { | 417 | if (targetWrapper != this) { |
417 | qDebug("Using generic "); | 418 | qDebug("Using generic "); |
418 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 419 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
419 | return; | 420 | return; |
420 | } | 421 | } |
421 | if (!fromFolder) return; | 422 | if (!fromFolder) return; |
422 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 423 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
423 | if (r!=MAIL_NO_ERROR) { | 424 | if (r!=MAIL_NO_ERROR) { |
424 | qDebug("error selecting source folder! "); | 425 | qDebug("error selecting source folder! "); |
425 | return; | 426 | return; |
426 | } | 427 | } |
427 | QString tf = buildPath(targetFolder); | 428 | QString tf = buildPath(targetFolder); |
428 | mailmessage_list*l=0; | 429 | mailmessage_list*l=0; |
429 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 430 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
430 | if (r != MAIL_NO_ERROR) { | 431 | if (r != MAIL_NO_ERROR) { |
431 | qDebug("Error message list "); | 432 | qDebug("Error message list "); |
432 | } | 433 | } |
433 | unsigned j = 0; | 434 | unsigned j = 0; |
434 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 435 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
435 | mailmessage * msg; | 436 | mailmessage * msg; |
436 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 437 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
437 | j = msg->msg_index; | 438 | j = msg->msg_index; |
438 | if (moveit) { | 439 | if (moveit) { |
439 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 440 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
440 | } else { | 441 | } else { |
441 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 442 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
442 | } | 443 | } |
443 | if (r != MAIL_NO_ERROR) { | 444 | if (r != MAIL_NO_ERROR) { |
444 | qDebug("Error copy/moving mail interna "); | 445 | qDebug("Error copy/moving mail interna "); |
445 | 446 | ||
446 | break; | 447 | break; |
447 | } | 448 | } |
448 | } | 449 | } |
449 | if (l) mailmessage_list_free(l); | 450 | if (l) mailmessage_list_free(l); |
450 | } | 451 | } |
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index 5ef5b6a..484a635 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp | |||
@@ -1,146 +1,146 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include "mailistviewitem.h" | 2 | #include "mailistviewitem.h" |
3 | #include <libmailwrapper/abstractmail.h> | 3 | #include <libmailwrapper/abstractmail.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <kiconloader.h> | 5 | #include <kiconloader.h> |
6 | //#include <qpe/resource.h> | 6 | //#include <qpe/resource.h> |
7 | 7 | ||
8 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 8 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
9 | :QListViewItem(parent,item),mail_data() | 9 | :QListViewItem(parent,item),mail_data() |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | void MailListViewItem::showEntry() | 13 | void MailListViewItem::showEntry() |
14 | { | 14 | { |
15 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { | 15 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { |
16 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); | 16 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); |
17 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { | 17 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { |
18 | /* I think it looks nicer if there are not such a log of icons but only on mails | 18 | /* I think it looks nicer if there are not such a log of icons but only on mails |
19 | replied or new - Alwin*/ | 19 | replied or new - Alwin*/ |
20 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); | 20 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); |
21 | } else { | 21 | } else { |
22 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); | 22 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); |
23 | } | 23 | } |
24 | double s = mail_data->Msgsize(); | 24 | double s = mail_data->Msgsize(); |
25 | int w = 0; | 25 | int w = 0; |
26 | s/=1024; | 26 | s/=1024; |
27 | if (s>999.0) { | 27 | if (s>999.0) { |
28 | s/=1024.0; | 28 | s/=1024.0; |
29 | ++w; | 29 | ++w; |
30 | } | 30 | } |
31 | QString fsort; | 31 | QString fsort; |
32 | fsort.sprintf( "%.2f", s ); | 32 | fsort.sprintf( "%.2f", s ); |
33 | QString fsize = QString::number( s, 'f', 2 ); | 33 | QString fsize = QString::number( s, 'f', 2 ); |
34 | // 1.23 | 34 | // 1.23 |
35 | // 11.23 | 35 | // 11.23 |
36 | // 111.23 | 36 | // 111.23 |
37 | // 999.23 maxlen | 37 | // 999.23 maxlen |
38 | switch(fsize.length() ) { | 38 | switch(fsize.length() ) { |
39 | case 4: | 39 | case 4: |
40 | fsort = "00" + fsize ; | 40 | fsort = "00" + fsize ; |
41 | break; | 41 | break; |
42 | case 5: | 42 | case 5: |
43 | fsort = "0" + fsize ; | 43 | fsort = "0" + fsize ; |
44 | break; | 44 | break; |
45 | default: | 45 | default: |
46 | fsort = fsize ; | 46 | fsort = fsize ; |
47 | break; | 47 | break; |
48 | 48 | ||
49 | } | 49 | } |
50 | if ( w == 0 ) { | 50 | if ( w == 0 ) { |
51 | setText(3, fsize + "kB" ); | 51 | setText(3, fsize + "kB" ); |
52 | mKeyMap.insert(3, "k" + fsort); | 52 | mKeyMap.insert(3, "k" + fsort); |
53 | //setText(3, "kB" + fsort ); // test only | 53 | //setText(3, "kB" + fsort ); // test only |
54 | } else { | 54 | } else { |
55 | //setText(3, fsize + "MB"); | 55 | //setText(3, fsize + "MB"); |
56 | mKeyMap.insert(3, "M" +fsort ); | 56 | mKeyMap.insert(3, "M" +fsort ); |
57 | } | 57 | } |
58 | setText(1,QString::fromUtf8( mail_data->getSubject().latin1())); | 58 | setText(1,mail_data->getSubject()); |
59 | setText(2,QString::fromUtf8( mail_data->getFrom().latin1())); | 59 | setText(2,mail_data->getFrom()); |
60 | #if 0 | 60 | #if 0 |
61 | QString date = mail_data->getDate(); | 61 | QString date = mail_data->getDate(); |
62 | 62 | ||
63 | int kom = date.find( ",")+2; | 63 | int kom = date.find( ",")+2; |
64 | if ( kom == 1 ) | 64 | if ( kom == 1 ) |
65 | kom = 0; | 65 | kom = 0; |
66 | if ( date.mid(kom,1) == " ") | 66 | if ( date.mid(kom,1) == " ") |
67 | ++kom; | 67 | ++kom; |
68 | if ( date.mid(kom+1,1) == " " ) | 68 | if ( date.mid(kom+1,1) == " " ) |
69 | date = "0" + date.mid( kom ); | 69 | date = "0" + date.mid( kom ); |
70 | else if ( kom ) | 70 | else if ( kom ) |
71 | date = date.mid( kom ); | 71 | date = date.mid( kom ); |
72 | if ( kom || date.mid(2,1 ) == " ") { | 72 | if ( kom || date.mid(2,1 ) == " ") { |
73 | QString mon = date.mid(3,3); | 73 | QString mon = date.mid(3,3); |
74 | QString so = 00; | 74 | QString so = 00; |
75 | if ( mon == "Jan" ) | 75 | if ( mon == "Jan" ) |
76 | so = "01"; | 76 | so = "01"; |
77 | else if ( mon == "Feb" ) | 77 | else if ( mon == "Feb" ) |
78 | so = "02"; | 78 | so = "02"; |
79 | else if ( mon == "Mar" ) | 79 | else if ( mon == "Mar" ) |
80 | so = "03"; | 80 | so = "03"; |
81 | else if ( mon == "Apr" ) | 81 | else if ( mon == "Apr" ) |
82 | so = "04"; | 82 | so = "04"; |
83 | else if ( mon == "May" ) | 83 | else if ( mon == "May" ) |
84 | so = "05"; | 84 | so = "05"; |
85 | else if ( mon == "Jun" ) | 85 | else if ( mon == "Jun" ) |
86 | so = "06"; | 86 | so = "06"; |
87 | else if ( mon == "Jul" ) | 87 | else if ( mon == "Jul" ) |
88 | so = "07"; | 88 | so = "07"; |
89 | else if ( mon == "Aug" ) | 89 | else if ( mon == "Aug" ) |
90 | so = "08"; | 90 | so = "08"; |
91 | else if ( mon == "Sep" ) | 91 | else if ( mon == "Sep" ) |
92 | so = "09"; | 92 | so = "09"; |
93 | else if ( mon == "Oct" ) | 93 | else if ( mon == "Oct" ) |
94 | so = "10"; | 94 | so = "10"; |
95 | else if ( mon == "Nov" ) | 95 | else if ( mon == "Nov" ) |
96 | so = "11"; | 96 | so = "11"; |
97 | else if ( mon == "Dec" ) | 97 | else if ( mon == "Dec" ) |
98 | so = "12"; | 98 | so = "12"; |
99 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); | 99 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); |
100 | } | 100 | } |
101 | //qDebug("insert Date %s ", date.latin1()); | 101 | //qDebug("insert Date %s ", date.latin1()); |
102 | // if ( date.left(1) != "1" || date.left(1) != "2" ) | 102 | // if ( date.left(1) != "1" || date.left(1) != "2" ) |
103 | // date = date.mid(5); | 103 | // date = date.mid(5); |
104 | mKeyMap.insert(4,date); | 104 | mKeyMap.insert(4,date); |
105 | #endif | 105 | #endif |
106 | mKeyMap.insert(4,mail_data->getIsoDate()); | 106 | mKeyMap.insert(4,mail_data->getIsoDate()); |
107 | setText(4,mail_data->getDate()); | 107 | setText(4,mail_data->getDate()); |
108 | } | 108 | } |
109 | 109 | ||
110 | void MailListViewItem::storeData(const RecMailP&data) | 110 | void MailListViewItem::storeData(const RecMailP&data) |
111 | { | 111 | { |
112 | mail_data = data; | 112 | mail_data = data; |
113 | } | 113 | } |
114 | void MailListViewItem::setSortKey(int column,const QString &key) | 114 | void MailListViewItem::setSortKey(int column,const QString &key) |
115 | { | 115 | { |
116 | mKeyMap.insert(column,key); | 116 | mKeyMap.insert(column,key); |
117 | } | 117 | } |
118 | QString MailListViewItem::key(int column, bool) const | 118 | QString MailListViewItem::key(int column, bool) const |
119 | { | 119 | { |
120 | // to make is fast, we use here special cases | 120 | // to make is fast, we use here special cases |
121 | if ( column == 3 || column == 4 ) { | 121 | if ( column == 3 || column == 4 ) { |
122 | return *mKeyMap.find(column); | 122 | return *mKeyMap.find(column); |
123 | } | 123 | } |
124 | if ( column == 1 ) { | 124 | if ( column == 1 ) { |
125 | if ( text(1).left(4).lower() == "re: " ) | 125 | if ( text(1).left(4).lower() == "re: " ) |
126 | return text(1).mid(4); | 126 | return text(1).mid(4); |
127 | 127 | ||
128 | } | 128 | } |
129 | return text(column); | 129 | return text(column); |
130 | /* | 130 | /* |
131 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 131 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
132 | if (it == mKeyMap.end()) return text(column); | 132 | if (it == mKeyMap.end()) return text(column); |
133 | else return *it; | 133 | else return *it; |
134 | */ | 134 | */ |
135 | } | 135 | } |
136 | 136 | ||
137 | const RecMailP& MailListViewItem::data()const | 137 | const RecMailP& MailListViewItem::data()const |
138 | { | 138 | { |
139 | return mail_data; | 139 | return mail_data; |
140 | } | 140 | } |
141 | 141 | ||
142 | MAILLIB::ATYPE MailListViewItem::wrapperType() | 142 | MAILLIB::ATYPE MailListViewItem::wrapperType() |
143 | { | 143 | { |
144 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; | 144 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; |
145 | return mail_data->Wrapper()->getType(); | 145 | return mail_data->Wrapper()->getType(); |
146 | } | 146 | } |
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 98eb9a5..3013931 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp | |||
@@ -1,312 +1,353 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qvbox.h> | 4 | #include <qvbox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qtimer.h> | 6 | #include <qtimer.h> |
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | //#include <kdialog.h> | 8 | //#include <kdialog.h> |
9 | #include <kiconloader.h> | 9 | #include <kiconloader.h> |
10 | #include <kapplication.h> | 10 | #include <kapplication.h> |
11 | 11 | ||
12 | #ifdef DESKTOP_VERSION | 12 | #ifdef DESKTOP_VERSION |
13 | #include <qapplication.h> | 13 | #include <qapplication.h> |
14 | #include <qstatusbar.h> | 14 | #include <qstatusbar.h> |
15 | #include <kabc/stdaddressbook.h> | ||
15 | extern QStatusBar* globalSstatusBarMainWindow; | 16 | extern QStatusBar* globalSstatusBarMainWindow; |
16 | #else | 17 | #else |
17 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
18 | #endif | 19 | #endif |
19 | #include "defines.h" | 20 | #include "defines.h" |
20 | #include "mainwindow.h" | 21 | #include "mainwindow.h" |
21 | #include <KDGanttMinimizeSplitter.h> | 22 | #include <KDGanttMinimizeSplitter.h> |
22 | 23 | ||
23 | #include <kabc/stdaddressbook.h> | 24 | #include "koprefs.h" |
24 | 25 | ||
25 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 26 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
26 | : QMainWindow( parent, name ) //, flags ) | 27 | : QMainWindow( parent, name ) //, flags ) |
27 | { | 28 | { |
28 | #ifdef DESKTOP_VERSION | 29 | #ifdef DESKTOP_VERSION |
29 | globalSstatusBarMainWindow = statusBar(); | 30 | globalSstatusBarMainWindow = statusBar(); |
30 | #endif | 31 | #endif |
31 | setCaption( i18n( "KOpieMail/Pi" ) ); | 32 | setCaption( i18n( "KOpieMail/Pi" ) ); |
32 | setToolBarsMovable( false ); | 33 | setToolBarsMovable( false ); |
33 | //KABC::StdAddressBook::self(); | 34 | //KABC::StdAddressBook::self(); |
34 | toolBar = new QToolBar( this ); | 35 | toolBar = new QToolBar( this ); |
35 | menuBar = new QPEMenuBar( toolBar ); | 36 | menuBar = new QPEMenuBar( toolBar ); |
36 | mailMenu = new QPopupMenu( menuBar ); | 37 | mailMenu = new QPopupMenu( menuBar ); |
37 | menuBar->insertItem( i18n( "Mail" ), mailMenu ); | 38 | menuBar->insertItem( i18n( "Mail" ), mailMenu ); |
38 | settingsMenu = new QPopupMenu( menuBar ); | 39 | settingsMenu = new QPopupMenu( menuBar ); |
39 | menuBar->insertItem( i18n( "Settings" ), settingsMenu ); | 40 | menuBar->insertItem( i18n( "Settings" ), settingsMenu ); |
40 | 41 | ||
41 | addToolBar( toolBar ); | 42 | addToolBar( toolBar ); |
42 | toolBar->setHorizontalStretchable( true ); | 43 | toolBar->setHorizontalStretchable( true ); |
43 | QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), | 44 | QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), |
44 | 0, 0, this ); | 45 | 0, 0, this ); |
45 | connect(getMail, SIGNAL( activated() ), | 46 | connect(getMail, SIGNAL( activated() ), |
46 | SLOT( slotGetAllMail() ) ); | 47 | SLOT( slotGetAllMail() ) ); |
47 | getMail->addTo( mailMenu ); | 48 | getMail->addTo( mailMenu ); |
48 | 49 | ||
49 | getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), | 50 | getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), |
50 | 0, 0, this ); | 51 | 0, 0, this ); |
51 | getMail->addTo( toolBar ); | 52 | getMail->addTo( toolBar ); |
52 | getMail->addTo( mailMenu ); | 53 | getMail->addTo( mailMenu ); |
53 | connect(getMail, SIGNAL( activated() ), | 54 | connect(getMail, SIGNAL( activated() ), |
54 | SLOT( slotGetMail() ) ); | 55 | SLOT( slotGetMail() ) ); |
55 | 56 | ||
56 | composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), | 57 | composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), |
57 | 0, 0, this ); | 58 | 0, 0, this ); |
58 | composeMail->addTo( toolBar ); | 59 | composeMail->addTo( toolBar ); |
59 | composeMail->addTo( mailMenu ); | 60 | composeMail->addTo( mailMenu ); |
60 | 61 | ||
61 | sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , | 62 | sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , |
62 | 0, 0, this ); | 63 | 0, 0, this ); |
63 | sendQueued->addTo( toolBar ); | 64 | sendQueued->addTo( toolBar ); |
64 | sendQueued->addTo( mailMenu ); | 65 | sendQueued->addTo( mailMenu ); |
65 | 66 | ||
66 | /* | 67 | /* |
67 | syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, | 68 | syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, |
68 | 0, 0, this ); | 69 | 0, 0, this ); |
69 | syncFolders->addTo( toolBar ); | 70 | syncFolders->addTo( toolBar ); |
70 | syncFolders->addTo( mailMenu ); | 71 | syncFolders->addTo( mailMenu ); |
71 | */ | 72 | */ |
72 | 73 | ||
73 | showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , | 74 | showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , |
74 | 0, 0, this, 0, true ); | 75 | 0, 0, this, 0, true ); |
75 | showFolders->addTo( toolBar ); | 76 | showFolders->addTo( toolBar ); |
76 | showFolders->addTo( mailMenu ); | 77 | showFolders->addTo( mailMenu ); |
77 | showFolders->setOn( true ); | 78 | showFolders->setOn( true ); |
78 | connect(showFolders, SIGNAL( toggled(bool) ), | 79 | connect(showFolders, SIGNAL( toggled(bool) ), |
79 | SLOT( slotShowFolders(bool) ) ); | 80 | SLOT( slotShowFolders(bool) ) ); |
80 | 81 | ||
81 | /* | 82 | /* |
82 | searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), | 83 | searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), |
83 | 0, 0, this ); | 84 | 0, 0, this ); |
84 | searchMails->addTo( toolBar ); | 85 | searchMails->addTo( toolBar ); |
85 | searchMails->addTo( mailMenu ); | 86 | searchMails->addTo( mailMenu ); |
86 | */ | 87 | */ |
87 | 88 | ||
88 | deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); | 89 | deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); |
89 | deleteMails->addTo( toolBar ); | 90 | deleteMails->addTo( toolBar ); |
90 | deleteMails->addTo( mailMenu ); | 91 | deleteMails->addTo( mailMenu ); |
91 | connect( deleteMails, SIGNAL( activated() ), | 92 | connect( deleteMails, SIGNAL( activated() ), |
92 | SLOT( slotDeleteMail() ) ); | 93 | SLOT( slotDeleteMail() ) ); |
93 | 94 | ||
94 | editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , | 95 | editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , |
95 | 0, 0, this ); | 96 | 0, 0, this ); |
96 | editSettings->addTo( settingsMenu ); | 97 | editSettings->addTo( settingsMenu ); |
97 | connect( editSettings, SIGNAL( activated() ), | 98 | connect( editSettings, SIGNAL( activated() ), |
98 | SLOT( slotEditSettings() ) ); | 99 | SLOT( slotEditSettings() ) ); |
99 | editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , | 100 | editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , |
100 | 0, 0, this ); | 101 | 0, 0, this ); |
101 | editAccounts->addTo( settingsMenu ); | 102 | editAccounts->addTo( settingsMenu ); |
102 | 103 | codecMenu = new QPopupMenu( menuBar ); | |
104 | codecMenu->insertItem( "Western (iso-8859-1)",0,0); | ||
105 | codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); | ||
106 | codecMenu->insertItem( "Western (iso-8859-15)",2,2); | ||
107 | codecMenu->insertItem( "Chinese (big-5)",3,3); | ||
108 | codecMenu->insertItem( "Unicode (utf-8)",4,4); | ||
109 | codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); | ||
110 | settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); | ||
103 | //setCentralWidget( view ); | 111 | //setCentralWidget( view ); |
104 | 112 | ||
105 | QVBox* wrapperBox = new QVBox( this ); | 113 | QVBox* wrapperBox = new QVBox( this ); |
106 | setCentralWidget( wrapperBox ); | 114 | setCentralWidget( wrapperBox ); |
107 | 115 | ||
108 | // QWidget *view = new QWidget( wrapperBox ); | 116 | // QWidget *view = new QWidget( wrapperBox ); |
109 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); | 117 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); |
110 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); | 118 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); |
111 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); | 119 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); |
112 | 120 | ||
113 | folderView = new AccountView( split ); | 121 | folderView = new AccountView( split ); |
114 | folderView->header()->hide(); | 122 | folderView->header()->hide(); |
115 | folderView->setRootIsDecorated( false ); | 123 | folderView->setRootIsDecorated( false ); |
116 | folderView->addColumn( i18n( "Mailbox" ) ); | 124 | folderView->addColumn( i18n( "Mailbox" ) ); |
117 | 125 | ||
118 | //layout->addWidget( folderView ); | 126 | //layout->addWidget( folderView ); |
119 | 127 | ||
120 | mailView = new QListView( split ); | 128 | mailView = new QListView( split ); |
121 | mailView->addColumn( i18n( " " ) ); | 129 | mailView->addColumn( i18n( " " ) ); |
122 | mailView->addColumn( i18n( "Subject" ),QListView::Manual ); | 130 | mailView->addColumn( i18n( "Subject" ),QListView::Manual ); |
123 | mailView->addColumn( i18n( "Sender" ),QListView::Manual ); | 131 | mailView->addColumn( i18n( "Sender" ),QListView::Manual ); |
124 | mailView->addColumn( i18n( "Size" ),QListView::Manual); | 132 | mailView->addColumn( i18n( "Size" ),QListView::Manual); |
125 | mailView->addColumn( i18n( "Date" ),QListView::Manual); | 133 | mailView->addColumn( i18n( "Date" ),QListView::Manual); |
126 | mailView->setAllColumnsShowFocus(true); | 134 | mailView->setAllColumnsShowFocus(true); |
127 | //mailView->setSorting(-1); | 135 | //mailView->setSorting(-1); |
128 | mailView->setRootIsDecorated( false ); | 136 | mailView->setRootIsDecorated( false ); |
129 | statusWidget = new StatusWidget( wrapperBox ); | 137 | statusWidget = new StatusWidget( wrapperBox ); |
130 | statusWidget->hide(); | 138 | statusWidget->hide(); |
131 | 139 | ||
132 | //layout->addWidget( mailView ); | 140 | //layout->addWidget( mailView ); |
133 | //layout->setStretchFactor( folderView, 1 ); | 141 | //layout->setStretchFactor( folderView, 1 ); |
134 | //layout->setStretchFactor( mailView, 2 ); | 142 | //layout->setStretchFactor( mailView, 2 ); |
135 | 143 | ||
136 | slotAdjustLayout(); | 144 | slotAdjustLayout(); |
137 | #ifndef DESKTOP_VERSION | 145 | #ifndef DESKTOP_VERSION |
138 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 146 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
139 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 147 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
140 | #endif | 148 | #endif |
141 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, | 149 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, |
142 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 150 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
143 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, | 151 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, |
144 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 152 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
145 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 153 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
146 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 154 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
147 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 155 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
148 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 156 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
149 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 157 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
150 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 158 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
151 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 159 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
152 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 160 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
153 | //mailView->setMultiSelection ( true ); | 161 | //mailView->setMultiSelection ( true ); |
154 | mailView->setSelectionMode( QListView::Extended ); | 162 | mailView->setSelectionMode( QListView::Extended ); |
155 | QValueList<int> list; | 163 | QValueList<int> list; |
156 | int fw = 100; | 164 | int fw = 100; |
157 | if ( QApplication::desktop()->width() > 320 ) | 165 | if ( QApplication::desktop()->width() > 320 ) |
158 | fw = 50; | 166 | fw = 50; |
159 | list.append( fw ); | 167 | list.append( fw ); |
160 | list.append( 100 ); | 168 | list.append( 100 ); |
161 | split->setSizes( list ); | 169 | split->setSizes( list ); |
162 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 170 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
163 | mailView->setShowSortIndicator ( true ); | 171 | mailView->setShowSortIndicator ( true ); |
164 | QLabel *spacer = new QLabel( toolBar ); | 172 | QLabel *spacer = new QLabel( toolBar ); |
165 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 173 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
166 | toolBar->setStretchableWidget( spacer ); | 174 | toolBar->setStretchableWidget( spacer ); |
167 | 175 | ||
168 | QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); | 176 | QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
169 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 177 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
170 | if ( QApplication::desktop()->width() > 320 ) | 178 | if ( QApplication::desktop()->width() > 320 ) |
171 | closeMail->addTo(toolBar); | 179 | closeMail->addTo(toolBar); |
172 | closeMail->addTo(mailMenu); | 180 | closeMail->addTo(mailMenu); |
173 | 181 | ||
174 | 182 | ||
175 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); | 183 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); |
176 | menuBar->insertItem( i18n( "Help" ), helpMenu ); | 184 | menuBar->insertItem( i18n( "Help" ), helpMenu ); |
177 | QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); | 185 | QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); |
178 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); | 186 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); |
179 | li->addTo(helpMenu); | 187 | li->addTo(helpMenu); |
180 | li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); | 188 | li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); |
181 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); | 189 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); |
182 | li->addTo(helpMenu); | 190 | li->addTo(helpMenu); |
183 | li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); | 191 | li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); |
184 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); | 192 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); |
185 | li->addTo(helpMenu); | 193 | li->addTo(helpMenu); |
194 | connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); | ||
195 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | ||
186 | #ifdef DESKTOP_VERSION | 196 | #ifdef DESKTOP_VERSION |
187 | resize ( 640, 480 ); | 197 | resize ( 640, 480 ); |
188 | #endif | 198 | #endif |
189 | } | 199 | } |
190 | 200 | ||
191 | MainWindow::~MainWindow() | 201 | MainWindow::~MainWindow() |
192 | { | 202 | { |
193 | } | 203 | } |
194 | 204 | ||
205 | void MainWindow::slotSetCodec( int codec ) | ||
206 | { | ||
207 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); | ||
208 | //qDebug("codec %d ", codec); | ||
209 | KOPrefs::instance()->mCurrentCodec = codec; | ||
210 | KOPrefs::instance()->isDirty = true; | ||
211 | QString name; | ||
212 | switch ( codec ) { | ||
213 | case 0: | ||
214 | name = "iso-8859-1"; | ||
215 | break; | ||
216 | case 1: | ||
217 | name = "iso-8859-5"; | ||
218 | break; | ||
219 | case 2: | ||
220 | name = "iso-8859-15"; | ||
221 | break; | ||
222 | case 3: | ||
223 | name = "big-5"; | ||
224 | break; | ||
225 | case 4: | ||
226 | name = "utf-8"; | ||
227 | break; | ||
228 | case 5: | ||
229 | name = KOPrefs::instance()->mSendCodec.lower(); | ||
230 | break; | ||
231 | } | ||
232 | KOPrefs::instance()->mCurrentCodeName = name ; | ||
233 | codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); | ||
234 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); | ||
235 | } | ||
195 | void MainWindow::showLicence() | 236 | void MainWindow::showLicence() |
196 | { | 237 | { |
197 | KApplication::showLicence(); | 238 | KApplication::showLicence(); |
198 | } | 239 | } |
199 | void MainWindow::showAbout() | 240 | void MainWindow::showAbout() |
200 | { | 241 | { |
201 | QString version; | 242 | QString version; |
202 | #include <../version> | 243 | #include <../version> |
203 | 244 | ||
204 | QString cap = "About KOpieMail/Pi"; | 245 | QString cap = "About KOpieMail/Pi"; |
205 | QString text =i18n("KOpieMail/Platform-independent\n") + | 246 | QString text =i18n("KOpieMail/Platform-independent\n") + |
206 | "(OM/Pi) " + version + " - " | 247 | "(OM/Pi) " + version + " - " |
207 | 248 | ||
208 | #ifdef DESKTOP_VERSION | 249 | #ifdef DESKTOP_VERSION |
209 | "Desktop Edition\n" | 250 | "Desktop Edition\n" |
210 | #else | 251 | #else |
211 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" | 252 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" |
212 | #endif | 253 | #endif |
213 | "www.pi-sync.net\n\n" | 254 | "www.pi-sync.net\n\n" |
214 | 255 | ||
215 | 256 | ||
216 | 257 | ||
217 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" | 258 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" |
218 | "KOpieMail/Pi is based on Opie Mail\n" | 259 | "KOpieMail/Pi is based on Opie Mail\n" |
219 | "Copyright (c) Rajko Albrecht and the Opie team\n" | 260 | "Copyright (c) Rajko Albrecht and the Opie team\n" |
220 | "KOpieMail/Pi is licensed under the GPL\n" | 261 | "KOpieMail/Pi is licensed under the GPL\n" |
221 | "\n" | 262 | "\n" |
222 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" | 263 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" |
223 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" | 264 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" |
224 | "libEtPan has its own licence - see LibEtPan licence\n"; | 265 | "libEtPan has its own licence - see LibEtPan licence\n"; |
225 | 266 | ||
226 | KApplication::showText( cap, text ); | 267 | KApplication::showText( cap, text ); |
227 | } | 268 | } |
228 | void MainWindow::showEtpanLicence() | 269 | void MainWindow::showEtpanLicence() |
229 | { | 270 | { |
230 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); | 271 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); |
231 | 272 | ||
232 | } | 273 | } |
233 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 274 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
234 | { | 275 | { |
235 | qDebug("appMessage implemented by subclass"); | 276 | qDebug("appMessage implemented by subclass"); |
236 | } | 277 | } |
237 | 278 | ||
238 | void MainWindow::slotAdjustLayout() { | 279 | void MainWindow::slotAdjustLayout() { |
239 | 280 | ||
240 | /* | 281 | /* |
241 | QWidget *d = QApplication::desktop(); | 282 | QWidget *d = QApplication::desktop(); |
242 | 283 | ||
243 | if ( d->width() < d->height() ) { | 284 | if ( d->width() < d->height() ) { |
244 | layout->setDirection( QBoxLayout::TopToBottom ); | 285 | layout->setDirection( QBoxLayout::TopToBottom ); |
245 | } else { | 286 | } else { |
246 | layout->setDirection( QBoxLayout::LeftToRight ); | 287 | layout->setDirection( QBoxLayout::LeftToRight ); |
247 | } | 288 | } |
248 | */ | 289 | */ |
249 | } | 290 | } |
250 | 291 | ||
251 | void MainWindow::slotAdjustColumns() | 292 | void MainWindow::slotAdjustColumns() |
252 | { | 293 | { |
253 | bool hidden = folderView->isHidden(); | 294 | bool hidden = folderView->isHidden(); |
254 | if ( hidden ) folderView->show(); | 295 | if ( hidden ) folderView->show(); |
255 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 296 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
256 | if ( hidden ) folderView->hide(); | 297 | if ( hidden ) folderView->hide(); |
257 | 298 | ||
258 | mailView->setColumnWidth( 0, 10 ); | 299 | mailView->setColumnWidth( 0, 10 ); |
259 | mailView->setColumnWidth( 1, 100 ); | 300 | mailView->setColumnWidth( 1, 100 ); |
260 | mailView->setColumnWidth( 2, 100 ); | 301 | mailView->setColumnWidth( 2, 100 ); |
261 | mailView->setColumnWidth( 3, 50 ); | 302 | mailView->setColumnWidth( 3, 50 ); |
262 | mailView->setColumnWidth( 4, 120 ); | 303 | mailView->setColumnWidth( 4, 120 ); |
263 | } | 304 | } |
264 | 305 | ||
265 | void MainWindow::slotEditSettings() | 306 | void MainWindow::slotEditSettings() |
266 | { | 307 | { |
267 | } | 308 | } |
268 | 309 | ||
269 | void MainWindow::slotShowFolders( bool ) | 310 | void MainWindow::slotShowFolders( bool ) |
270 | { | 311 | { |
271 | qDebug("not implemented: "); | 312 | qDebug("not implemented: "); |
272 | } | 313 | } |
273 | 314 | ||
274 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 315 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
275 | { | 316 | { |
276 | qDebug("not implemented: "); | 317 | qDebug("not implemented: "); |
277 | } | 318 | } |
278 | 319 | ||
279 | void MainWindow::mailLeftClicked(QListViewItem * ) | 320 | void MainWindow::mailLeftClicked(QListViewItem * ) |
280 | { | 321 | { |
281 | qDebug("not implemented: "); | 322 | qDebug("not implemented: "); |
282 | } | 323 | } |
283 | 324 | ||
284 | void MainWindow::displayMail() | 325 | void MainWindow::displayMail() |
285 | { | 326 | { |
286 | qDebug("not implemented: "); | 327 | qDebug("not implemented: "); |
287 | } | 328 | } |
288 | 329 | ||
289 | void MainWindow::slotDeleteMail() | 330 | void MainWindow::slotDeleteMail() |
290 | { | 331 | { |
291 | qDebug("not implemented: "); | 332 | qDebug("not implemented: "); |
292 | } | 333 | } |
293 | 334 | ||
294 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 335 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
295 | { | 336 | { |
296 | qDebug("not implemented: "); | 337 | qDebug("not implemented: "); |
297 | } | 338 | } |
298 | 339 | ||
299 | void MainWindow::slotSendQueued() | 340 | void MainWindow::slotSendQueued() |
300 | { | 341 | { |
301 | qDebug("not implemented: "); | 342 | qDebug("not implemented: "); |
302 | } | 343 | } |
303 | 344 | ||
304 | void MainWindow::slotEditAccounts() | 345 | void MainWindow::slotEditAccounts() |
305 | { | 346 | { |
306 | qDebug("not implemented: "); | 347 | qDebug("not implemented: "); |
307 | } | 348 | } |
308 | 349 | ||
309 | void MainWindow::slotComposeMail() | 350 | void MainWindow::slotComposeMail() |
310 | { | 351 | { |
311 | qDebug("not implemented: "); | 352 | qDebug("not implemented: "); |
312 | } | 353 | } |
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h index f5ab69b..d0a5caf 100644 --- a/kmicromail/mainwindow.h +++ b/kmicromail/mainwindow.h | |||
@@ -1,68 +1,69 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #ifndef MAINWINDOW_H | 3 | #ifndef MAINWINDOW_H |
4 | #define MAINWINDOW_H | 4 | #define MAINWINDOW_H |
5 | 5 | ||
6 | #include <qmainwindow.h> | 6 | #include <qmainwindow.h> |
7 | #include <qlistview.h> | 7 | #include <qlistview.h> |
8 | #include <qaction.h> | 8 | #include <qaction.h> |
9 | 9 | ||
10 | #include <qtoolbar.h> | 10 | #include <qtoolbar.h> |
11 | #ifdef DESKTOP_VERSION | 11 | #ifdef DESKTOP_VERSION |
12 | #include <qmenubar.h> | 12 | #include <qmenubar.h> |
13 | #define QPEMenuBar QMenuBar | 13 | #define QPEMenuBar QMenuBar |
14 | #else | 14 | #else |
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #include "accountview.h" | 18 | #include "accountview.h" |
19 | #include "statuswidget.h" | 19 | #include "statuswidget.h" |
20 | 20 | ||
21 | #include <libmailwrapper/mailtypes.h> | 21 | #include <libmailwrapper/mailtypes.h> |
22 | #include <opie2/osmartpointer.h> | 22 | #include <opie2/osmartpointer.h> |
23 | 23 | ||
24 | class RecMail; | 24 | class RecMail; |
25 | 25 | ||
26 | class MainWindow : public QMainWindow | 26 | class MainWindow : public QMainWindow |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 31 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
32 | virtual ~MainWindow(); | 32 | virtual ~MainWindow(); |
33 | 33 | ||
34 | public slots: | 34 | public slots: |
35 | virtual void slotAdjustColumns(); | 35 | virtual void slotAdjustColumns(); |
36 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 36 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
37 | virtual void slotComposeMail(); | 37 | virtual void slotComposeMail(); |
38 | 38 | ||
39 | protected slots: | 39 | protected slots: |
40 | virtual void slotSendQueued(); | 40 | virtual void slotSendQueued(); |
41 | virtual void slotEditAccounts(); | 41 | virtual void slotEditAccounts(); |
42 | virtual void slotShowFolders( bool show ); | 42 | virtual void slotShowFolders( bool show ); |
43 | virtual void refreshMailView(const QValueList<RecMailP>&); | 43 | virtual void refreshMailView(const QValueList<RecMailP>&); |
44 | virtual void displayMail(); | 44 | virtual void displayMail(); |
45 | virtual void slotGetMail() = 0; | 45 | virtual void slotGetMail() = 0; |
46 | virtual void slotGetAllMail() = 0; | 46 | virtual void slotGetAllMail() = 0; |
47 | virtual void slotDeleteMail(); | 47 | virtual void slotDeleteMail(); |
48 | virtual void slotSetCodec(int); | ||
48 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 49 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
49 | virtual void slotAdjustLayout(); | 50 | virtual void slotAdjustLayout(); |
50 | virtual void slotEditSettings(); | 51 | virtual void slotEditSettings(); |
51 | virtual void mailLeftClicked( QListViewItem * ); | 52 | virtual void mailLeftClicked( QListViewItem * ); |
52 | void showLicence(); | 53 | void showLicence(); |
53 | void showAbout(); | 54 | void showAbout(); |
54 | void showEtpanLicence(); | 55 | void showEtpanLicence(); |
55 | 56 | ||
56 | protected: | 57 | protected: |
57 | QToolBar *toolBar; | 58 | QToolBar *toolBar; |
58 | StatusWidget *statusWidget; | 59 | StatusWidget *statusWidget; |
59 | QPEMenuBar *menuBar; | 60 | QPEMenuBar *menuBar; |
60 | QPopupMenu *mailMenu, *settingsMenu; | 61 | QPopupMenu *mailMenu, *settingsMenu, *codecMenu; |
61 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, | 62 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
62 | *editSettings, *editAccounts, *syncFolders; | 63 | *editSettings, *editAccounts, *syncFolders; |
63 | AccountView *folderView; | 64 | AccountView *folderView; |
64 | QListView *mailView; | 65 | QListView *mailView; |
65 | //QBoxLayout *layout; | 66 | //QBoxLayout *layout; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | #endif | 69 | #endif |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index af5376f..18a5600 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,542 +1,544 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | #include "koprefsdialog.h" | 4 | #include "koprefsdialog.h" |
5 | #include <kapplication.h> | 5 | #include <kapplication.h> |
6 | #include <libkdepim/externalapphandler.h> | 6 | #include <libkdepim/externalapphandler.h> |
7 | #include <libkdepim/kpimglobalprefs.h> | 7 | #include <libkdepim/kpimglobalprefs.h> |
8 | #ifdef MINIKDE_KDIALOG_H | 8 | #ifdef MINIKDE_KDIALOG_H |
9 | #undef MINIKDE_KDIALOG_H | 9 | #undef MINIKDE_KDIALOG_H |
10 | #endif | 10 | #endif |
11 | #include "settingsdialog.h" | 11 | #include "settingsdialog.h" |
12 | #include "opiemail.h" | 12 | #include "opiemail.h" |
13 | #include "editaccounts.h" | 13 | #include "editaccounts.h" |
14 | #include "composemail.h" | 14 | #include "composemail.h" |
15 | #include "mailistviewitem.h" | 15 | #include "mailistviewitem.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | #include "selectstore.h" | 17 | #include "selectstore.h" |
18 | #include "selectsmtp.h" | 18 | #include "selectsmtp.h" |
19 | #include "accountitem.h" | 19 | #include "accountitem.h" |
20 | #include "klocale.h" | 20 | #include "klocale.h" |
21 | 21 | ||
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | 27 | ||
28 | #ifdef DESKTOP_VERSION | 28 | #ifdef DESKTOP_VERSION |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #else | 30 | #else |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <libmailwrapper/smtpwrapper.h> | 33 | #include <libmailwrapper/smtpwrapper.h> |
34 | #include <libmailwrapper/mailtypes.h> | 34 | #include <libmailwrapper/mailtypes.h> |
35 | #include <libmailwrapper/abstractmail.h> | 35 | #include <libmailwrapper/abstractmail.h> |
36 | #include "koprefs.h" | ||
36 | 37 | ||
37 | //using namespace Opie::Core; | 38 | //using namespace Opie::Core; |
38 | 39 | ||
39 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 40 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
40 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 41 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
41 | { | 42 | { |
42 | settings = new Settings(); | 43 | settings = new Settings(); |
43 | 44 | ||
44 | setIcon(SmallIcon( "kmicromail" ) ); | 45 | setIcon(SmallIcon( "kmicromail" ) ); |
45 | folderView->populate( settings->getAccounts() ); | 46 | folderView->populate( settings->getAccounts() ); |
46 | 47 | ||
47 | } | 48 | } |
48 | 49 | ||
49 | OpieMail::~OpieMail() | 50 | OpieMail::~OpieMail() |
50 | { | 51 | { |
51 | if (settings) delete settings; | 52 | if (settings) delete settings; |
52 | } | 53 | } |
53 | 54 | ||
54 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 55 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
55 | { | 56 | { |
56 | 57 | ||
57 | } | 58 | } |
58 | #include <stdlib.h> | 59 | #include <stdlib.h> |
59 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 60 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
60 | { | 61 | { |
61 | // copied from old mail2 | 62 | // copied from old mail2 |
62 | static int ii = 0; | 63 | static int ii = 0; |
63 | //qDebug("QCOP CALL ############################# %d ", ii); | 64 | //qDebug("QCOP CALL ############################# %d ", ii); |
64 | //QString mess ( msg ); | 65 | //QString mess ( msg ); |
65 | //qDebug("Message = %s ",mess.latin1()); | 66 | //qDebug("Message = %s ",mess.latin1()); |
66 | ++ii; | 67 | ++ii; |
67 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 68 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
68 | 69 | ||
69 | mPendingEmail = QString::null; | 70 | mPendingEmail = QString::null; |
70 | mPendingName = QString::null; | 71 | mPendingName = QString::null; |
71 | if (msg == "writeMail(QString,QString)") | 72 | if (msg == "writeMail(QString,QString)") |
72 | { | 73 | { |
73 | //qDebug("writeMail(QString,QString) "); | 74 | //qDebug("writeMail(QString,QString) "); |
74 | QDataStream stream(data,IO_ReadOnly); | 75 | QDataStream stream(data,IO_ReadOnly); |
75 | stream >> mPendingName >> mPendingEmail; | 76 | stream >> mPendingName >> mPendingEmail; |
76 | // removing the whitespaces at beginning and end is needed! | 77 | // removing the whitespaces at beginning and end is needed! |
77 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 78 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
78 | } | 79 | } |
79 | else if (msg == "newMail()") | 80 | else if (msg == "newMail()") |
80 | { | 81 | { |
81 | //qDebug("slotComposeMail() "); | 82 | //qDebug("slotComposeMail() "); |
82 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 83 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
83 | // and a QCOP call does not like a processevents in his execution | 84 | // and a QCOP call does not like a processevents in his execution |
84 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 85 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
85 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 86 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
86 | // slotComposeMail(); | 87 | // slotComposeMail(); |
87 | } | 88 | } |
88 | else if (msg == "newMail(QString)") | 89 | else if (msg == "newMail(QString)") |
89 | { | 90 | { |
90 | //qDebug(" newMail(QString)"); | 91 | //qDebug(" newMail(QString)"); |
91 | QDataStream stream(data,IO_ReadOnly); | 92 | QDataStream stream(data,IO_ReadOnly); |
92 | stream >> mPendingName; | 93 | stream >> mPendingName; |
93 | // the format is | 94 | // the format is |
94 | // NAME <EMAIL>:SUBJECT | 95 | // NAME <EMAIL>:SUBJECT |
95 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
96 | } else { | 97 | } else { |
97 | mPendingData = data; | 98 | mPendingData = data; |
98 | mPendingMessage = msg; | 99 | mPendingMessage = msg; |
99 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 100 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
100 | } | 101 | } |
101 | 102 | ||
102 | //qDebug("END OpieMail::message "); | 103 | //qDebug("END OpieMail::message "); |
103 | } | 104 | } |
104 | void OpieMail::slotExtAppHandler() | 105 | void OpieMail::slotExtAppHandler() |
105 | { | 106 | { |
106 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 107 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
107 | } | 108 | } |
108 | void OpieMail::slotwriteMail2(const QString& namemail ) | 109 | void OpieMail::slotwriteMail2(const QString& namemail ) |
109 | { | 110 | { |
110 | //qDebug("OpieMail::slotwriteMail2 "); | 111 | //qDebug("OpieMail::slotwriteMail2 "); |
111 | //qApp->processEvents(); | 112 | //qApp->processEvents(); |
112 | ComposeMail compose( settings, this, 0, true ); | 113 | ComposeMail compose( settings, this, 0, true ); |
113 | if ( !namemail.isEmpty() ) { | 114 | if ( !namemail.isEmpty() ) { |
114 | QString to = namemail; | 115 | QString to = namemail; |
115 | if ( namemail.find( " <") > 1 ) { | 116 | if ( namemail.find( " <") > 1 ) { |
116 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 117 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
117 | } else | 118 | } else |
118 | if ( namemail.find( "<") > 1 ) { | 119 | if ( namemail.find( "<") > 1 ) { |
119 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 120 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
120 | } | 121 | } |
121 | int sub = to.find( ">:"); | 122 | int sub = to.find( ">:"); |
122 | if ( sub > 0 ) { | 123 | if ( sub > 0 ) { |
123 | compose.setTo( to.left(sub+1) ); | 124 | compose.setTo( to.left(sub+1) ); |
124 | compose.setSubject( to.mid(sub+2) ); | 125 | compose.setSubject( to.mid(sub+2) ); |
125 | } else | 126 | } else |
126 | compose.setTo( to ); | 127 | compose.setTo( to ); |
127 | } | 128 | } |
128 | compose.slotAdjustColumns(); | 129 | compose.slotAdjustColumns(); |
129 | #ifndef DESKTOP_VERSION | 130 | #ifndef DESKTOP_VERSION |
130 | compose.showMaximized(); | 131 | compose.showMaximized(); |
131 | #endif | 132 | #endif |
132 | compose.exec(); | 133 | compose.exec(); |
133 | raise(); | 134 | raise(); |
134 | //qDebug("retttich "); | 135 | //qDebug("retttich "); |
135 | } | 136 | } |
136 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 137 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
137 | { | 138 | { |
138 | // qDebug("OpieMail::slotwriteMail "); | 139 | // qDebug("OpieMail::slotwriteMail "); |
139 | ComposeMail compose( settings, this, 0, true ); | 140 | ComposeMail compose( settings, this, 0, true ); |
140 | if (!email.isEmpty()) | 141 | if (!email.isEmpty()) |
141 | { | 142 | { |
142 | if (!name.isEmpty()) | 143 | if (!name.isEmpty()) |
143 | { | 144 | { |
144 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 145 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
145 | } | 146 | } |
146 | else | 147 | else |
147 | { | 148 | { |
148 | compose.setTo(email); | 149 | compose.setTo(email); |
149 | } | 150 | } |
150 | } | 151 | } |
151 | compose.slotAdjustColumns(); | 152 | compose.slotAdjustColumns(); |
152 | #ifndef DESKTOP_VERSION | 153 | #ifndef DESKTOP_VERSION |
153 | compose.showMaximized(); | 154 | compose.showMaximized(); |
154 | #endif | 155 | #endif |
155 | compose.exec(); | 156 | compose.exec(); |
156 | raise(); | 157 | raise(); |
157 | } | 158 | } |
158 | 159 | ||
159 | void OpieMail::slotComposeMail() | 160 | void OpieMail::slotComposeMail() |
160 | { | 161 | { |
161 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 162 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
162 | slotwriteMail2( QString () ); | 163 | slotwriteMail2( QString () ); |
163 | else { | 164 | else { |
164 | if ( mPendingEmail == QString::null ) | 165 | if ( mPendingEmail == QString::null ) |
165 | slotwriteMail2( mPendingName ); | 166 | slotwriteMail2( mPendingName ); |
166 | else | 167 | else |
167 | slotwriteMail( mPendingName, mPendingEmail ); | 168 | slotwriteMail( mPendingName, mPendingEmail ); |
168 | } | 169 | } |
169 | //slotwriteMail(0l,0l); | 170 | //slotwriteMail(0l,0l); |
170 | } | 171 | } |
171 | 172 | ||
172 | void OpieMail::slotSendQueued() | 173 | void OpieMail::slotSendQueued() |
173 | { | 174 | { |
174 | SMTPaccount *smtp = 0; | 175 | SMTPaccount *smtp = 0; |
175 | 176 | ||
176 | QList<Account> list = settings->getAccounts(); | 177 | QList<Account> list = settings->getAccounts(); |
177 | QList<SMTPaccount> smtpList; | 178 | QList<SMTPaccount> smtpList; |
178 | smtpList.setAutoDelete(false); | 179 | smtpList.setAutoDelete(false); |
179 | Account *it; | 180 | Account *it; |
180 | for ( it = list.first(); it; it = list.next() ) | 181 | for ( it = list.first(); it; it = list.next() ) |
181 | { | 182 | { |
182 | if ( it->getType() == MAILLIB::A_SMTP ) | 183 | if ( it->getType() == MAILLIB::A_SMTP ) |
183 | { | 184 | { |
184 | smtp = static_cast<SMTPaccount *>(it); | 185 | smtp = static_cast<SMTPaccount *>(it); |
185 | smtpList.append(smtp); | 186 | smtpList.append(smtp); |
186 | } | 187 | } |
187 | } | 188 | } |
188 | if (smtpList.count()==0) | 189 | if (smtpList.count()==0) |
189 | { | 190 | { |
190 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
194 | return; | 195 | return; |
195 | if (smtpList.count()==1) | 196 | if (smtpList.count()==1) |
196 | { | 197 | { |
197 | smtp = smtpList.at(0); | 198 | smtp = smtpList.at(0); |
198 | } | 199 | } |
199 | else | 200 | else |
200 | { | 201 | { |
201 | smtp = 0; | 202 | smtp = 0; |
202 | selectsmtp selsmtp; | 203 | selectsmtp selsmtp; |
203 | selsmtp.setSelectionlist(&smtpList); | 204 | selsmtp.setSelectionlist(&smtpList); |
204 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
205 | selsmtp.showMaximized(); | 206 | selsmtp.showMaximized(); |
206 | #endif | 207 | #endif |
207 | if ( selsmtp.exec() == QDialog::Accepted ) | 208 | if ( selsmtp.exec() == QDialog::Accepted ) |
208 | { | 209 | { |
209 | smtp = selsmtp.selected_smtp(); | 210 | smtp = selsmtp.selected_smtp(); |
210 | } | 211 | } |
211 | } | 212 | } |
212 | if (smtp) | 213 | if (smtp) |
213 | { | 214 | { |
214 | 215 | ||
215 | Global::statusMessage("Sending mails...!"); | 216 | Global::statusMessage("Sending mails...!"); |
216 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
217 | if ( wrap->flushOutbox() ) | 218 | if ( wrap->flushOutbox() ) |
218 | { | 219 | { |
219 | Global::statusMessage("Mails sent!"); | 220 | Global::statusMessage("Mails sent!"); |
220 | } | 221 | } |
221 | delete wrap; | 222 | delete wrap; |
222 | } | 223 | } |
223 | // pending refresh list view, if outgoing is displayed | 224 | // pending refresh list view, if outgoing is displayed |
224 | } | 225 | } |
225 | 226 | ||
226 | void OpieMail::slotSearchMails() | 227 | void OpieMail::slotSearchMails() |
227 | { | 228 | { |
228 | qDebug("OpieMail::slotSearchMails():not implemented "); | 229 | qDebug("OpieMail::slotSearchMails():not implemented "); |
229 | } | 230 | } |
230 | 231 | ||
231 | void OpieMail::slotEditSettings() | 232 | void OpieMail::slotEditSettings() |
232 | { | 233 | { |
233 | 234 | ||
234 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
235 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
236 | settingsDialog.showMaximized(); | 237 | settingsDialog.showMaximized(); |
237 | #endif | 238 | #endif |
238 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
239 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | ||
240 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
241 | } | 243 | } |
242 | 244 | ||
243 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
244 | { | 246 | { |
245 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
246 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
247 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
248 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
249 | #endif | 251 | #endif |
250 | eaDialog.exec(); | 252 | eaDialog.exec(); |
251 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
252 | settings = new Settings(); | 254 | settings = new Settings(); |
253 | 255 | ||
254 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
255 | } | 257 | } |
256 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
257 | { | 259 | { |
258 | 260 | ||
259 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
260 | if (!item) return; | 262 | if (!item) return; |
261 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
262 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
263 | 265 | ||
264 | QString rtext; | 266 | QString rtext; |
265 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
266 | .arg( QString::fromUtf8( mail->getFrom().latin1())) | 268 | .arg( mail->getFrom()) |
267 | .arg( QString::fromUtf8( mail->getDate().latin1() )); | 269 | .arg( mail->getDate()); |
268 | 270 | ||
269 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); | 271 | QString text = body->Bodytext(); |
270 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
271 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
272 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
273 | { | 275 | { |
274 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
275 | } | 277 | } |
276 | rtext += "\n"; | 278 | rtext += "\n"; |
277 | 279 | ||
278 | QString prefix; | 280 | QString prefix; |
279 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
280 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
281 | 283 | ||
282 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
283 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
284 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
285 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); | 287 | composer.setTo( mail->getFrom()); |
286 | } else { | 288 | } else { |
287 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); | 289 | composer.setTo( mail->Replyto()); |
288 | } | 290 | } |
289 | composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); | 291 | composer.setSubject( prefix + mail->getSubject()); |
290 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
291 | composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); | 293 | composer.setInReplyTo( mail->Msgid()); |
292 | 294 | ||
293 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
294 | { | 296 | { |
295 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
296 | } | 298 | } |
297 | delete settings; | 299 | delete settings; |
298 | 300 | ||
299 | } | 301 | } |
300 | void OpieMail::displayMail() | 302 | void OpieMail::displayMail() |
301 | { | 303 | { |
302 | QListViewItem*item = mailView->currentItem(); | 304 | QListViewItem*item = mailView->currentItem(); |
303 | if (!item) return; | 305 | if (!item) return; |
304 | RecMailP mail = ((MailListViewItem*)item)->data(); | 306 | RecMailP mail = ((MailListViewItem*)item)->data(); |
305 | RecBodyP body = folderView->fetchBody(mail); | 307 | RecBodyP body = folderView->fetchBody(mail); |
306 | ViewMail readMail( this,"", Qt::WType_Modal ); | 308 | ViewMail readMail( this,"", Qt::WType_Modal ); |
307 | readMail.setBody( body ); | 309 | readMail.setBody( body ); |
308 | readMail.setMail( mail ); | 310 | readMail.setMail( mail ); |
309 | #ifndef DESKTOP_VERSION | 311 | #ifndef DESKTOP_VERSION |
310 | readMail.showMaximized(); | 312 | readMail.showMaximized(); |
311 | #else | 313 | #else |
312 | readMail.resize( 640, 480); | 314 | readMail.resize( 640, 480); |
313 | #endif | 315 | #endif |
314 | readMail.exec(); | 316 | readMail.exec(); |
315 | 317 | ||
316 | if ( readMail.deleted ) | 318 | if ( readMail.deleted ) |
317 | { | 319 | { |
318 | folderView->refreshCurrent(); | 320 | folderView->refreshCurrent(); |
319 | } | 321 | } |
320 | else | 322 | else |
321 | { | 323 | { |
322 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 324 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
323 | } | 325 | } |
324 | } | 326 | } |
325 | void OpieMail::slotGetAllMail() | 327 | void OpieMail::slotGetAllMail() |
326 | { | 328 | { |
327 | QListViewItem * item = folderView->firstChild(); | 329 | QListViewItem * item = folderView->firstChild(); |
328 | while ( item ){ | 330 | while ( item ){ |
329 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
330 | item = item->nextSibling (); | 332 | item = item->nextSibling (); |
331 | } | 333 | } |
332 | } | 334 | } |
333 | void OpieMail::slotGetMail() | 335 | void OpieMail::slotGetMail() |
334 | { | 336 | { |
335 | QListViewItem * item = folderView->currentItem(); | 337 | QListViewItem * item = folderView->currentItem(); |
336 | if ( ! item ) return; | 338 | if ( ! item ) return; |
337 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 339 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
338 | } | 340 | } |
339 | void OpieMail::slotDeleteMail() | 341 | void OpieMail::slotDeleteMail() |
340 | { | 342 | { |
341 | if (!mailView->currentItem()) return; | 343 | if (!mailView->currentItem()) return; |
342 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 344 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
343 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 345 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
344 | { | 346 | { |
345 | mail->Wrapper()->deleteMail( mail ); | 347 | mail->Wrapper()->deleteMail( mail ); |
346 | folderView->refreshCurrent(); | 348 | folderView->refreshCurrent(); |
347 | } | 349 | } |
348 | } | 350 | } |
349 | void OpieMail::slotDeleteAllMail() | 351 | void OpieMail::slotDeleteAllMail() |
350 | { | 352 | { |
351 | 353 | ||
352 | QValueList<RecMailP> t; | 354 | QValueList<RecMailP> t; |
353 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 355 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
354 | { | 356 | { |
355 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 357 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
356 | while ( item ) { | 358 | while ( item ) { |
357 | if ( item->isSelected() ) { | 359 | if ( item->isSelected() ) { |
358 | t.append( item->data() ); | 360 | t.append( item->data() ); |
359 | } | 361 | } |
360 | item = (MailListViewItem*)item->nextSibling(); | 362 | item = (MailListViewItem*)item->nextSibling(); |
361 | } | 363 | } |
362 | } | 364 | } |
363 | else | 365 | else |
364 | return; | 366 | return; |
365 | if ( t.count() == 0 ) | 367 | if ( t.count() == 0 ) |
366 | return; | 368 | return; |
367 | RecMailP mail = t.first(); | 369 | RecMailP mail = t.first(); |
368 | mail->Wrapper()->deleteMailList(t); | 370 | mail->Wrapper()->deleteMailList(t); |
369 | folderView->refreshCurrent(); | 371 | folderView->refreshCurrent(); |
370 | 372 | ||
371 | 373 | ||
372 | } | 374 | } |
373 | void OpieMail::clearSelection() | 375 | void OpieMail::clearSelection() |
374 | { | 376 | { |
375 | mailView->clearSelection(); | 377 | mailView->clearSelection(); |
376 | 378 | ||
377 | } | 379 | } |
378 | 380 | ||
379 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 381 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
380 | { | 382 | { |
381 | if (!mailView->currentItem()) return; | 383 | if (!mailView->currentItem()) return; |
382 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 384 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
383 | /* just the RIGHT button - or hold on pda */ | 385 | /* just the RIGHT button - or hold on pda */ |
384 | if (button!=2) {return;} | 386 | if (button!=2) {return;} |
385 | if (!item) return; | 387 | if (!item) return; |
386 | QPopupMenu *m = new QPopupMenu(0); | 388 | QPopupMenu *m = new QPopupMenu(0); |
387 | if (m) | 389 | if (m) |
388 | { | 390 | { |
389 | if (mailtype==MAILLIB::A_NNTP) { | 391 | if (mailtype==MAILLIB::A_NNTP) { |
390 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 392 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
391 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 393 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
392 | m->insertSeparator(); | 394 | m->insertSeparator(); |
393 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 395 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
394 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 396 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
395 | } else { | 397 | } else { |
396 | if (folderView->currentisDraft()) { | 398 | if (folderView->currentisDraft()) { |
397 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 399 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
398 | } | 400 | } |
399 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 401 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
400 | m->insertSeparator(); | 402 | m->insertSeparator(); |
401 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 403 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
402 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 404 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
403 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 405 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
404 | m->insertSeparator(); | 406 | m->insertSeparator(); |
405 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 407 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
406 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 408 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
407 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 409 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
408 | } | 410 | } |
409 | m->setFocus(); | 411 | m->setFocus(); |
410 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 412 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
411 | delete m; | 413 | delete m; |
412 | } | 414 | } |
413 | } | 415 | } |
414 | 416 | ||
415 | void OpieMail::slotShowFolders( bool show ) | 417 | void OpieMail::slotShowFolders( bool show ) |
416 | { | 418 | { |
417 | if ( show && folderView->isHidden() ) | 419 | if ( show && folderView->isHidden() ) |
418 | { | 420 | { |
419 | folderView->show(); | 421 | folderView->show(); |
420 | } | 422 | } |
421 | else if ( !show && !folderView->isHidden() ) | 423 | else if ( !show && !folderView->isHidden() ) |
422 | { | 424 | { |
423 | folderView->hide(); | 425 | folderView->hide(); |
424 | } | 426 | } |
425 | } | 427 | } |
426 | 428 | ||
427 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 429 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
428 | { | 430 | { |
429 | MailListViewItem*item = 0; | 431 | MailListViewItem*item = 0; |
430 | mailView->clear(); | 432 | mailView->clear(); |
431 | 433 | ||
432 | QValueList<RecMailP>::ConstIterator it; | 434 | QValueList<RecMailP>::ConstIterator it; |
433 | for (it = list.begin(); it != list.end();++it) | 435 | for (it = list.begin(); it != list.end();++it) |
434 | { | 436 | { |
435 | item = new MailListViewItem(mailView,item); | 437 | item = new MailListViewItem(mailView,item); |
436 | item->storeData((*it)); | 438 | item->storeData((*it)); |
437 | item->showEntry(); | 439 | item->showEntry(); |
438 | } | 440 | } |
439 | mailView->setSorting ( 4, false ); | 441 | mailView->setSorting ( 4, false ); |
440 | } | 442 | } |
441 | 443 | ||
442 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 444 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
443 | { | 445 | { |
444 | mailView->clearSelection(); | 446 | mailView->clearSelection(); |
445 | /* just LEFT button - or tap with stylus on pda */ | 447 | /* just LEFT button - or tap with stylus on pda */ |
446 | //if (button!=1) return; | 448 | //if (button!=1) return; |
447 | if (!item) return; | 449 | if (!item) return; |
448 | if (folderView->currentisDraft()) { | 450 | if (folderView->currentisDraft()) { |
449 | reEditMail(); | 451 | reEditMail(); |
450 | } else { | 452 | } else { |
451 | displayMail(); | 453 | displayMail(); |
452 | } | 454 | } |
453 | } | 455 | } |
454 | 456 | ||
455 | void OpieMail::slotMoveCopyMail() | 457 | void OpieMail::slotMoveCopyMail() |
456 | { | 458 | { |
457 | if (!mailView->currentItem()) return; | 459 | if (!mailView->currentItem()) return; |
458 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 460 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
459 | AbstractMail*targetMail = 0; | 461 | AbstractMail*targetMail = 0; |
460 | QString targetFolder = ""; | 462 | QString targetFolder = ""; |
461 | Selectstore sels; | 463 | Selectstore sels; |
462 | folderView->setupFolderselect(&sels); | 464 | folderView->setupFolderselect(&sels); |
463 | if (!sels.exec()) return; | 465 | if (!sels.exec()) return; |
464 | targetMail = sels.currentMail(); | 466 | targetMail = sels.currentMail(); |
465 | targetFolder = sels.currentFolder(); | 467 | targetFolder = sels.currentFolder(); |
466 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 468 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
467 | targetFolder.isEmpty()) | 469 | targetFolder.isEmpty()) |
468 | { | 470 | { |
469 | return; | 471 | return; |
470 | } | 472 | } |
471 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 473 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
472 | { | 474 | { |
473 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 475 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
474 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 476 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
475 | return; | 477 | return; |
476 | } | 478 | } |
477 | sels.hide(); | 479 | sels.hide(); |
478 | qApp->processEvents(); | 480 | qApp->processEvents(); |
479 | // qDebug("hiding sels "); | 481 | // qDebug("hiding sels "); |
480 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 482 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
481 | folderView->refreshCurrent(); | 483 | folderView->refreshCurrent(); |
482 | } | 484 | } |
483 | 485 | ||
484 | void OpieMail::slotMoveCopyAllMail() | 486 | void OpieMail::slotMoveCopyAllMail() |
485 | { | 487 | { |
486 | 488 | ||
487 | if (!mailView->currentItem()) return; | 489 | if (!mailView->currentItem()) return; |
488 | QValueList<RecMailP> t; | 490 | QValueList<RecMailP> t; |
489 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 491 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
490 | { | 492 | { |
491 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 493 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
492 | while ( item ) { | 494 | while ( item ) { |
493 | if ( item->isSelected() ) { | 495 | if ( item->isSelected() ) { |
494 | t.append( item->data() ); | 496 | t.append( item->data() ); |
495 | } | 497 | } |
496 | item = (MailListViewItem*)item->nextSibling(); | 498 | item = (MailListViewItem*)item->nextSibling(); |
497 | } | 499 | } |
498 | } | 500 | } |
499 | // else | 501 | // else |
500 | // return; | 502 | // return; |
501 | if ( t.count() == 0 ) | 503 | if ( t.count() == 0 ) |
502 | return; | 504 | return; |
503 | RecMailP mail = t.first(); | 505 | RecMailP mail = t.first(); |
504 | AbstractMail*targetMail = 0; | 506 | AbstractMail*targetMail = 0; |
505 | QString targetFolder = ""; | 507 | QString targetFolder = ""; |
506 | Selectstore sels; | 508 | Selectstore sels; |
507 | folderView->setupFolderselect(&sels); | 509 | folderView->setupFolderselect(&sels); |
508 | if (!sels.exec()) return; | 510 | if (!sels.exec()) return; |
509 | targetMail = sels.currentMail(); | 511 | targetMail = sels.currentMail(); |
510 | targetFolder = sels.currentFolder(); | 512 | targetFolder = sels.currentFolder(); |
511 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 513 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
512 | targetFolder.isEmpty()) | 514 | targetFolder.isEmpty()) |
513 | { | 515 | { |
514 | return; | 516 | return; |
515 | } | 517 | } |
516 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 518 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
517 | { | 519 | { |
518 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 520 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
519 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 521 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
520 | return; | 522 | return; |
521 | } | 523 | } |
522 | sels.hide(); | 524 | sels.hide(); |
523 | qApp->processEvents(); | 525 | qApp->processEvents(); |
524 | //qDebug("hiding sels "); | 526 | //qDebug("hiding sels "); |
525 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 527 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
526 | folderView->refreshCurrent(); | 528 | folderView->refreshCurrent(); |
527 | } | 529 | } |
528 | 530 | ||
529 | void OpieMail::reEditMail() | 531 | void OpieMail::reEditMail() |
530 | { | 532 | { |
531 | if (!mailView->currentItem()) return; | 533 | if (!mailView->currentItem()) return; |
532 | 534 | ||
533 | ComposeMail compose( settings, this, 0, true ); | 535 | ComposeMail compose( settings, this, 0, true ); |
534 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 536 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
535 | compose.slotAdjustColumns(); | 537 | compose.slotAdjustColumns(); |
536 | #ifndef DESKTOP_VERSION | 538 | #ifndef DESKTOP_VERSION |
537 | compose.showMaximized(); | 539 | compose.showMaximized(); |
538 | #else | 540 | #else |
539 | compose.resize(640,480); | 541 | compose.resize(640,480); |
540 | #endif | 542 | #endif |
541 | compose.exec(); | 543 | compose.exec(); |
542 | } | 544 | } |
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 2093678..4883231 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -1,531 +1,531 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | 3 | ||
4 | 4 | ||
5 | #include <kfiledialog.h> | 5 | #include <kfiledialog.h> |
6 | #include "koprefs.h" | 6 | #include "koprefs.h" |
7 | #include <klocale.h> | 7 | #include <klocale.h> |
8 | #include <kglobal.h> | 8 | #include <kglobal.h> |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | 10 | ||
11 | #ifdef MINIKDE_KDIALOG_H | 11 | #ifdef MINIKDE_KDIALOG_H |
12 | #undef MINIKDE_KDIALOG_H | 12 | #undef MINIKDE_KDIALOG_H |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | #include "composemail.h" | 15 | #include "composemail.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | 17 | ||
18 | #include <libmailwrapper/settings.h> | 18 | #include <libmailwrapper/settings.h> |
19 | #include <libmailwrapper/abstractmail.h> | 19 | #include <libmailwrapper/abstractmail.h> |
20 | #include <libmailwrapper/mailtypes.h> | 20 | #include <libmailwrapper/mailtypes.h> |
21 | 21 | ||
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qtextbrowser.h> | 27 | #include <qtextbrowser.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | 34 | ||
35 | //using namespace Opie::Ui; | 35 | //using namespace Opie::Ui; |
36 | //using namespace Opie::Core; | 36 | //using namespace Opie::Core; |
37 | 37 | ||
38 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 38 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
39 | const QString&fsize,int num,const QValueList<int>&path) | 39 | const QString&fsize,int num,const QValueList<int>&path) |
40 | : QListViewItem(parent,after),_partNum(num) | 40 | : QListViewItem(parent,after),_partNum(num) |
41 | { | 41 | { |
42 | _path=path; | 42 | _path=path; |
43 | setText(0, mime); | 43 | setText(0, mime); |
44 | setText(1, desc); | 44 | setText(1, desc); |
45 | setText(2, file); | 45 | setText(2, file); |
46 | setText(3, fsize); | 46 | setText(3, fsize); |
47 | } | 47 | } |
48 | 48 | ||
49 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 49 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
50 | const QString&fsize,int num,const QValueList<int>&path) | 50 | const QString&fsize,int num,const QValueList<int>&path) |
51 | : QListViewItem(parent,after),_partNum(num) | 51 | : QListViewItem(parent,after),_partNum(num) |
52 | { | 52 | { |
53 | _path=path; | 53 | _path=path; |
54 | setText(0, mime); | 54 | setText(0, mime); |
55 | setText(1, desc); | 55 | setText(1, desc); |
56 | setText(2, file); | 56 | setText(2, file); |
57 | setText(3, fsize); | 57 | setText(3, fsize); |
58 | } | 58 | } |
59 | 59 | ||
60 | bool AttachItem::isParentof(const QValueList<int>&path) | 60 | bool AttachItem::isParentof(const QValueList<int>&path) |
61 | { | 61 | { |
62 | /* if not set, then no parent */ | 62 | /* if not set, then no parent */ |
63 | if (path.count()==0||_path.count()==0) return false; | 63 | if (path.count()==0||_path.count()==0) return false; |
64 | /* the parent must have one digit less then a child */ | 64 | /* the parent must have one digit less then a child */ |
65 | if (path.count()!=_path.count()+1) return false; | 65 | if (path.count()!=_path.count()+1) return false; |
66 | for (unsigned int i=0; i < _path.count();++i) | 66 | for (unsigned int i=0; i < _path.count();++i) |
67 | { | 67 | { |
68 | if (_path[i]!=path[i]) return false; | 68 | if (_path[i]!=path[i]) return false; |
69 | } | 69 | } |
70 | return true; | 70 | return true; |
71 | } | 71 | } |
72 | 72 | ||
73 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 73 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
74 | { | 74 | { |
75 | QListViewItemIterator it( attachments ); | 75 | QListViewItemIterator it( attachments ); |
76 | for ( ; it.current(); ++it ) | 76 | for ( ; it.current(); ++it ) |
77 | { | 77 | { |
78 | AttachItem*ati = (AttachItem*)it.current(); | 78 | AttachItem*ati = (AttachItem*)it.current(); |
79 | if (ati->isParentof(path)) return ati; | 79 | if (ati->isParentof(path)) return ati; |
80 | } | 80 | } |
81 | return 0; | 81 | return 0; |
82 | } | 82 | } |
83 | 83 | ||
84 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 84 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
85 | { | 85 | { |
86 | if (!parent) return 0; | 86 | if (!parent) return 0; |
87 | AttachItem* item = (AttachItem*)parent->firstChild(); | 87 | AttachItem* item = (AttachItem*)parent->firstChild(); |
88 | if (!item) return item; | 88 | if (!item) return item; |
89 | AttachItem*temp=0; | 89 | AttachItem*temp=0; |
90 | while( (temp=(AttachItem*)item->nextSibling())) | 90 | while( (temp=(AttachItem*)item->nextSibling())) |
91 | { | 91 | { |
92 | item = temp; | 92 | item = temp; |
93 | } | 93 | } |
94 | return item; | 94 | return item; |
95 | } | 95 | } |
96 | 96 | ||
97 | void ViewMail::setBody(const RecBodyP&body ) | 97 | void ViewMail::setBody(const RecBodyP&body ) |
98 | { | 98 | { |
99 | 99 | ||
100 | m_body = body; | 100 | m_body = body; |
101 | m_mail[2] = QString::fromUtf8( body->Bodytext().latin1() ); | 101 | m_mail[2] = body->Bodytext(); |
102 | // qDebug("********text %s ",m_mail[2].latin1() ); | 102 | // qDebug("********text %s ",m_mail[2].latin1() ); |
103 | attachbutton->setEnabled(body->Parts().count()>0); | 103 | attachbutton->setEnabled(body->Parts().count()>0); |
104 | attachments->setEnabled(body->Parts().count()>0); | 104 | attachments->setEnabled(body->Parts().count()>0); |
105 | if (body->Parts().count()==0) | 105 | if (body->Parts().count()==0) |
106 | { | 106 | { |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | AttachItem * curItem=0; | 109 | AttachItem * curItem=0; |
110 | AttachItem * parentItem = 0; | 110 | AttachItem * parentItem = 0; |
111 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 111 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
112 | QString desc,fsize; | 112 | QString desc,fsize; |
113 | double s = body->Description()->Size(); | 113 | double s = body->Description()->Size(); |
114 | int w; | 114 | int w; |
115 | w=0; | 115 | w=0; |
116 | 116 | ||
117 | while (s>1024) | 117 | while (s>1024) |
118 | { | 118 | { |
119 | s/=1024; | 119 | s/=1024; |
120 | ++w; | 120 | ++w; |
121 | if (w>=2) break; | 121 | if (w>=2) break; |
122 | } | 122 | } |
123 | 123 | ||
124 | QString q=""; | 124 | QString q=""; |
125 | switch(w) | 125 | switch(w) |
126 | { | 126 | { |
127 | case 1: | 127 | case 1: |
128 | q="k"; | 128 | q="k"; |
129 | break; | 129 | break; |
130 | case 2: | 130 | case 2: |
131 | q="M"; | 131 | q="M"; |
132 | break; | 132 | break; |
133 | default: | 133 | default: |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | 136 | ||
137 | { | 137 | { |
138 | /* I did not found a method to make a CONTENT reset on a QTextStream | 138 | /* I did not found a method to make a CONTENT reset on a QTextStream |
139 | so I use this construct that the stream will re-constructed in each | 139 | so I use this construct that the stream will re-constructed in each |
140 | loop. To let it work, the textstream is packed into a own area of | 140 | loop. To let it work, the textstream is packed into a own area of |
141 | code is it will be destructed after finishing its small job. | 141 | code is it will be destructed after finishing its small job. |
142 | */ | 142 | */ |
143 | QTextOStream o(&fsize); | 143 | QTextOStream o(&fsize); |
144 | if (w>0) o.precision(2); else o.precision(0); | 144 | if (w>0) o.precision(2); else o.precision(0); |
145 | o.setf(QTextStream::fixed); | 145 | o.setf(QTextStream::fixed); |
146 | o << s << " " << q << "Byte"; | 146 | o << s << " " << q << "Byte"; |
147 | } | 147 | } |
148 | 148 | ||
149 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 149 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
150 | QString filename = ""; | 150 | QString filename = ""; |
151 | 151 | ||
152 | for (unsigned int i = 0; i < body->Parts().count();++i) | 152 | for (unsigned int i = 0; i < body->Parts().count();++i) |
153 | { | 153 | { |
154 | filename = ""; | 154 | filename = ""; |
155 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 155 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
156 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 156 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
157 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 157 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
158 | { | 158 | { |
159 | if (it.key().lower()=="name") | 159 | if (it.key().lower()=="name") |
160 | { | 160 | { |
161 | filename=it.data(); | 161 | filename=it.data(); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | s = body->Parts()[i]->Size(); | 164 | s = body->Parts()[i]->Size(); |
165 | w = 0; | 165 | w = 0; |
166 | while (s>1024) | 166 | while (s>1024) |
167 | { | 167 | { |
168 | s/=1024; | 168 | s/=1024; |
169 | ++w; | 169 | ++w; |
170 | if (w>=2) break; | 170 | if (w>=2) break; |
171 | } | 171 | } |
172 | switch(w) | 172 | switch(w) |
173 | { | 173 | { |
174 | case 1: | 174 | case 1: |
175 | q="k"; | 175 | q="k"; |
176 | break; | 176 | break; |
177 | case 2: | 177 | case 2: |
178 | q="M"; | 178 | q="M"; |
179 | break; | 179 | break; |
180 | default: | 180 | default: |
181 | q=""; | 181 | q=""; |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | QTextOStream o(&fsize); | 184 | QTextOStream o(&fsize); |
185 | if (w>0) o.precision(2); else o.precision(0); | 185 | if (w>0) o.precision(2); else o.precision(0); |
186 | o.setf(QTextStream::fixed); | 186 | o.setf(QTextStream::fixed); |
187 | o << s << " " << q << "Byte"; | 187 | o << s << " " << q << "Byte"; |
188 | desc = body->Parts()[i]->Description(); | 188 | desc = body->Parts()[i]->Description(); |
189 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 189 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
190 | if (parentItem) | 190 | if (parentItem) |
191 | { | 191 | { |
192 | AttachItem*temp = lastChild(parentItem); | 192 | AttachItem*temp = lastChild(parentItem); |
193 | if (temp) curItem = temp; | 193 | if (temp) curItem = temp; |
194 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 194 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
195 | attachments->setRootIsDecorated(true); | 195 | attachments->setRootIsDecorated(true); |
196 | curItem = parentItem; | 196 | curItem = parentItem; |
197 | } | 197 | } |
198 | else | 198 | else |
199 | { | 199 | { |
200 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 200 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void ViewMail::slotShowHtml( bool state ) | 206 | void ViewMail::slotShowHtml( bool state ) |
207 | { | 207 | { |
208 | m_showHtml = state; | 208 | m_showHtml = state; |
209 | setText(); | 209 | setText(); |
210 | } | 210 | } |
211 | 211 | ||
212 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 212 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
213 | { | 213 | { |
214 | if (!item ) | 214 | if (!item ) |
215 | return; | 215 | return; |
216 | 216 | ||
217 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 217 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
218 | { | 218 | { |
219 | setText(); | 219 | setText(); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | QPopupMenu *menu = new QPopupMenu(); | 222 | QPopupMenu *menu = new QPopupMenu(); |
223 | int ret=0; | 223 | int ret=0; |
224 | 224 | ||
225 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 225 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
226 | { | 226 | { |
227 | menu->insertItem( i18n( "Show Text" ), 1 ); | 227 | menu->insertItem( i18n( "Show Text" ), 1 ); |
228 | } | 228 | } |
229 | if (item->text(0).left(6)=="image/") { | 229 | if (item->text(0).left(6)=="image/") { |
230 | menu->insertItem(i18n("Display image preview"),2); | 230 | menu->insertItem(i18n("Display image preview"),2); |
231 | } | 231 | } |
232 | menu->insertItem( i18n( "Save Attachment" ), 0 ); | 232 | menu->insertItem( i18n( "Save Attachment" ), 0 ); |
233 | menu->insertSeparator(1); | 233 | menu->insertSeparator(1); |
234 | 234 | ||
235 | ret = menu->exec( point, 0 ); | 235 | ret = menu->exec( point, 0 ); |
236 | 236 | ||
237 | switch(ret) | 237 | switch(ret) |
238 | { | 238 | { |
239 | case 0: | 239 | case 0: |
240 | { | 240 | { |
241 | //MimeTypes types; | 241 | //MimeTypes types; |
242 | //types.insert( "all", "*" ); | 242 | //types.insert( "all", "*" ); |
243 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 243 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
244 | 244 | ||
245 | if( !str.isEmpty() ) | 245 | if( !str.isEmpty() ) |
246 | { | 246 | { |
247 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 247 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
248 | if (content) | 248 | if (content) |
249 | { | 249 | { |
250 | QFile output(str); | 250 | QFile output(str); |
251 | output.open(IO_WriteOnly); | 251 | output.open(IO_WriteOnly); |
252 | output.writeBlock(content->Content(),content->Length()); | 252 | output.writeBlock(content->Content(),content->Length()); |
253 | output.close(); | 253 | output.close(); |
254 | delete content; | 254 | delete content; |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | break ; | 258 | break ; |
259 | 259 | ||
260 | case 2: | 260 | case 2: |
261 | { | 261 | { |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | 263 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); |
264 | #else | 264 | #else |
265 | QString tmpfile = "/tmp/opiemail-image"; | 265 | QString tmpfile = "/tmp/opiemail-image"; |
266 | #endif | 266 | #endif |
267 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 267 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
268 | if (content) { | 268 | if (content) { |
269 | QFile output(tmpfile); | 269 | QFile output(tmpfile); |
270 | output.open(IO_WriteOnly); | 270 | output.open(IO_WriteOnly); |
271 | output.writeBlock(content->Content(),content->Length()); | 271 | output.writeBlock(content->Content(),content->Length()); |
272 | output.close(); | 272 | output.close(); |
273 | delete content; | 273 | delete content; |
274 | MailImageDlg iview(""); | 274 | MailImageDlg iview(""); |
275 | iview.setName(tmpfile); | 275 | iview.setName(tmpfile); |
276 | KApplication::execDialog(&iview); | 276 | KApplication::execDialog(&iview); |
277 | output.remove(); | 277 | output.remove(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | break; | 280 | break; |
281 | case 1: | 281 | case 1: |
282 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 282 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
283 | { | 283 | { |
284 | setText(); | 284 | setText(); |
285 | } | 285 | } |
286 | else | 286 | else |
287 | { | 287 | { |
288 | if ( m_recMail->Wrapper() != 0l ) | 288 | if ( m_recMail->Wrapper() != 0l ) |
289 | { // make sure that there is a wrapper , even after delete or simular actions | 289 | { // make sure that there is a wrapper , even after delete or simular actions |
290 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 290 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | delete menu; | 295 | delete menu; |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void ViewMail::setMail(const RecMailP&mail ) | 299 | void ViewMail::setMail(const RecMailP&mail ) |
300 | { | 300 | { |
301 | 301 | ||
302 | m_recMail = mail; | 302 | m_recMail = mail; |
303 | 303 | ||
304 | m_mail[0] = QString::fromUtf8( mail->getFrom().latin1() ); | 304 | m_mail[0] = mail->getFrom(); |
305 | m_mail[1] = QString::fromUtf8( mail->getSubject().latin1() ); | 305 | m_mail[1] = mail->getSubject(); |
306 | m_mail[3] = QString::fromUtf8( mail->getDate().latin1() ); | 306 | m_mail[3] = mail->getDate(); |
307 | m_mail[4] = QString::fromUtf8( mail->Msgid().latin1() ); | 307 | m_mail[4] = mail->Msgid(); |
308 | 308 | ||
309 | m_mail2[0] = mail->To(); | 309 | m_mail2[0] = mail->To(); |
310 | m_mail2[1] = mail->CC(); | 310 | m_mail2[1] = mail->CC(); |
311 | m_mail2[2] = mail->Bcc(); | 311 | m_mail2[2] = mail->Bcc(); |
312 | 312 | ||
313 | setText(); | 313 | setText(); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | 317 | ||
318 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 318 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
319 | : ViewMailBase(parent, name, fl), _inLoop(false) | 319 | : ViewMailBase(parent, name, fl), _inLoop(false) |
320 | { | 320 | { |
321 | m_gotBody = false; | 321 | m_gotBody = false; |
322 | deleted = false; | 322 | deleted = false; |
323 | 323 | ||
324 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 324 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
325 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 325 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
326 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 326 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
327 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 327 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
328 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 328 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
329 | 329 | ||
330 | attachments->setEnabled(m_gotBody); | 330 | attachments->setEnabled(m_gotBody); |
331 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 331 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
332 | 332 | ||
333 | readConfig(); | 333 | readConfig(); |
334 | attachments->setSorting(-1); | 334 | attachments->setSorting(-1); |
335 | } | 335 | } |
336 | 336 | ||
337 | void ViewMail::readConfig() | 337 | void ViewMail::readConfig() |
338 | { | 338 | { |
339 | 339 | ||
340 | setFont ( KOPrefs::instance()->mReadFont ); | 340 | setFont ( KOPrefs::instance()->mReadFont ); |
341 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 341 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
342 | showHtml->setOn( m_showHtml ); | 342 | showHtml->setOn( m_showHtml ); |
343 | } | 343 | } |
344 | 344 | ||
345 | void ViewMail::setText() | 345 | void ViewMail::setText() |
346 | { | 346 | { |
347 | 347 | ||
348 | QString toString; | 348 | QString toString; |
349 | QString ccString; | 349 | QString ccString; |
350 | QString bccString; | 350 | QString bccString; |
351 | 351 | ||
352 | 352 | ||
353 | toString = QString::fromUtf8(m_mail2[0].join(",").latin1()); | 353 | toString = m_mail2[0].join(","); |
354 | ccString = QString::fromUtf8(m_mail2[1].join(",").latin1()); | 354 | ccString = m_mail2[1].join(","); |
355 | bccString = QString::fromUtf8(m_mail2[2].join(",").latin1()); | 355 | bccString = m_mail2[2].join(","); |
356 | 356 | ||
357 | 357 | ||
358 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); | 358 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); |
359 | 359 | ||
360 | m_mailHtml = "<html><body>" | 360 | m_mailHtml = "<html><body>" |
361 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 361 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
362 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 362 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
363 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 363 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
364 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 364 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
365 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 365 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
366 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 366 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
367 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + | 367 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + |
368 | "</td></tr></table><font>"; | 368 | "</td></tr></table><font>"; |
369 | 369 | ||
370 | if ( !m_showHtml ) | 370 | if ( !m_showHtml ) |
371 | { | 371 | { |
372 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 372 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
373 | } | 373 | } |
374 | else | 374 | else |
375 | { | 375 | { |
376 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 376 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
377 | } | 377 | } |
378 | // remove later in favor of a real handling | 378 | // remove later in favor of a real handling |
379 | m_gotBody = true; | 379 | m_gotBody = true; |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | ViewMail::~ViewMail() | 383 | ViewMail::~ViewMail() |
384 | { | 384 | { |
385 | m_recMail->Wrapper()->cleanMimeCache(); | 385 | m_recMail->Wrapper()->cleanMimeCache(); |
386 | hide(); | 386 | hide(); |
387 | } | 387 | } |
388 | 388 | ||
389 | void ViewMail::hide() | 389 | void ViewMail::hide() |
390 | { | 390 | { |
391 | QWidget::hide(); | 391 | QWidget::hide(); |
392 | 392 | ||
393 | if (_inLoop) | 393 | if (_inLoop) |
394 | { | 394 | { |
395 | _inLoop = false; | 395 | _inLoop = false; |
396 | qApp->exit_loop(); | 396 | qApp->exit_loop(); |
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | } | 400 | } |
401 | 401 | ||
402 | void ViewMail::exec() | 402 | void ViewMail::exec() |
403 | { | 403 | { |
404 | show(); | 404 | show(); |
405 | 405 | ||
406 | if (!_inLoop) | 406 | if (!_inLoop) |
407 | { | 407 | { |
408 | _inLoop = true; | 408 | _inLoop = true; |
409 | qApp->enter_loop(); | 409 | qApp->enter_loop(); |
410 | } | 410 | } |
411 | 411 | ||
412 | } | 412 | } |
413 | 413 | ||
414 | QString ViewMail::deHtml(const QString &string) | 414 | QString ViewMail::deHtml(const QString &string) |
415 | { | 415 | { |
416 | QString string_ = string; | 416 | QString string_ = string; |
417 | string_.replace(QRegExp("&"), "&"); | 417 | string_.replace(QRegExp("&"), "&"); |
418 | string_.replace(QRegExp("<"), "<"); | 418 | string_.replace(QRegExp("<"), "<"); |
419 | string_.replace(QRegExp(">"), ">"); | 419 | string_.replace(QRegExp(">"), ">"); |
420 | string_.replace(QRegExp("\\n"), "<br>"); | 420 | string_.replace(QRegExp("\\n"), "<br>"); |
421 | return string_; | 421 | return string_; |
422 | } | 422 | } |
423 | 423 | ||
424 | void ViewMail::slotReply() | 424 | void ViewMail::slotReply() |
425 | { | 425 | { |
426 | if (!m_gotBody) | 426 | if (!m_gotBody) |
427 | { | 427 | { |
428 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); | 428 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); |
429 | return; | 429 | return; |
430 | } | 430 | } |
431 | 431 | ||
432 | QString rtext; | 432 | QString rtext; |
433 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 433 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
434 | .arg( m_mail[0] ) | 434 | .arg( m_mail[0] ) |
435 | .arg( m_mail[3] ); | 435 | .arg( m_mail[3] ); |
436 | 436 | ||
437 | QString text = m_mail[2]; | 437 | QString text = m_mail[2]; |
438 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 438 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
439 | QStringList::Iterator it; | 439 | QStringList::Iterator it; |
440 | for (it = lines.begin(); it != lines.end(); it++) | 440 | for (it = lines.begin(); it != lines.end(); it++) |
441 | { | 441 | { |
442 | rtext += "> " + *it + "\n"; | 442 | rtext += "> " + *it + "\n"; |
443 | } | 443 | } |
444 | rtext += "\n"; | 444 | rtext += "\n"; |
445 | 445 | ||
446 | QString prefix; | 446 | QString prefix; |
447 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 447 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
448 | else prefix = "Re: "; // no i18n on purpose | 448 | else prefix = "Re: "; // no i18n on purpose |
449 | 449 | ||
450 | Settings *settings = new Settings(); | 450 | Settings *settings = new Settings(); |
451 | ComposeMail composer( settings ,this, 0, true); | 451 | ComposeMail composer( settings ,this, 0, true); |
452 | if (m_recMail->Replyto().isEmpty()) { | 452 | if (m_recMail->Replyto().isEmpty()) { |
453 | composer.setTo( QString::fromUtf8( m_recMail->getFrom().latin1())); | 453 | composer.setTo(m_recMail->getFrom()); |
454 | } else { | 454 | } else { |
455 | composer.setTo( QString::fromUtf8( m_recMail->Replyto().latin1())); | 455 | composer.setTo(m_recMail->Replyto()); |
456 | } | 456 | } |
457 | composer.setSubject( prefix + m_mail[1] ); | 457 | composer.setSubject( prefix + m_mail[1] ); |
458 | composer.setMessage( rtext ); | 458 | composer.setMessage( rtext ); |
459 | composer.setInReplyTo(m_recMail->Msgid()); | 459 | composer.setInReplyTo(m_recMail->Msgid()); |
460 | 460 | ||
461 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 461 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
462 | { | 462 | { |
463 | m_recMail->Wrapper()->answeredMail(m_recMail); | 463 | m_recMail->Wrapper()->answeredMail(m_recMail); |
464 | } | 464 | } |
465 | delete settings; | 465 | delete settings; |
466 | } | 466 | } |
467 | 467 | ||
468 | void ViewMail::slotForward() | 468 | void ViewMail::slotForward() |
469 | { | 469 | { |
470 | if (!m_gotBody) | 470 | if (!m_gotBody) |
471 | { | 471 | { |
472 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); | 472 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); |
473 | return; | 473 | return; |
474 | } | 474 | } |
475 | 475 | ||
476 | QString ftext; | 476 | QString ftext; |
477 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 477 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
478 | .arg( m_mail[0] ); | 478 | .arg( m_mail[0] ); |
479 | if (!m_mail[3].isNull()) | 479 | if (!m_mail[3].isNull()) |
480 | ftext += QString("Date: %1\n") | 480 | ftext += QString("Date: %1\n") |
481 | .arg( m_mail[3] ); | 481 | .arg( m_mail[3] ); |
482 | if (!m_mail[0].isNull()) | 482 | if (!m_mail[0].isNull()) |
483 | ftext += QString("From: %1\n") | 483 | ftext += QString("From: %1\n") |
484 | .arg( m_mail[0] ); | 484 | .arg( m_mail[0] ); |
485 | if (!m_mail[1].isNull()) | 485 | if (!m_mail[1].isNull()) |
486 | ftext += QString("Subject: %1\n") | 486 | ftext += QString("Subject: %1\n") |
487 | .arg( m_mail[1] ); | 487 | .arg( m_mail[1] ); |
488 | 488 | ||
489 | ftext += QString("\n%1\n") | 489 | ftext += QString("\n%1\n") |
490 | .arg( m_mail[2]); | 490 | .arg( m_mail[2]); |
491 | 491 | ||
492 | ftext += QString("----- End forwarded message -----\n"); | 492 | ftext += QString("----- End forwarded message -----\n"); |
493 | 493 | ||
494 | Settings *settings = new Settings(); | 494 | Settings *settings = new Settings(); |
495 | ComposeMail composer( settings ,this, 0, true); | 495 | ComposeMail composer( settings ,this, 0, true); |
496 | composer.setSubject( "Fwd: " + m_mail[1] ); | 496 | composer.setSubject( "Fwd: " + m_mail[1] ); |
497 | composer.setMessage( ftext ); | 497 | composer.setMessage( ftext ); |
498 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 498 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
499 | { | 499 | { |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | void ViewMail::slotDeleteMail( ) | 503 | void ViewMail::slotDeleteMail( ) |
504 | { | 504 | { |
505 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 505 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
506 | { | 506 | { |
507 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 507 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
508 | hide(); | 508 | hide(); |
509 | deleted = true; | 509 | deleted = true; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 513 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
514 | : QDialog(parent,name,modal) | 514 | : QDialog(parent,name,modal) |
515 | { | 515 | { |
516 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 516 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
517 | dlglayout->setSpacing(2); | 517 | dlglayout->setSpacing(2); |
518 | dlglayout->setMargin(1); | 518 | dlglayout->setMargin(1); |
519 | //m_imageview = new Opie::MM::OImageScrollView(this); | 519 | //m_imageview = new Opie::MM::OImageScrollView(this); |
520 | //dlglayout->addWidget(m_imageview); | 520 | //dlglayout->addWidget(m_imageview); |
521 | } | 521 | } |
522 | 522 | ||
523 | MailImageDlg::~MailImageDlg() | 523 | MailImageDlg::~MailImageDlg() |
524 | { | 524 | { |
525 | } | 525 | } |
526 | 526 | ||
527 | void MailImageDlg::setName(const QString&fname) | 527 | void MailImageDlg::setName(const QString&fname) |
528 | { | 528 | { |
529 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 529 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
530 | // m_imageview->setImage(fname); | 530 | // m_imageview->setImage(fname); |
531 | } | 531 | } |