author | harlekin <harlekin> | 2004-01-10 00:32:04 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-01-10 00:32:04 (UTC) |
commit | 76cf4990cb4171a747ac31e9832f4ee694ced2cc (patch) (unidiff) | |
tree | ce97c1b6b6e9f832cc09a71fe3e8e87551bb01bd | |
parent | 241fb3509f6b62efda3c89f5bf9cec0dfba86b43 (diff) | |
download | opie-76cf4990cb4171a747ac31e9832f4ee694ced2cc.zip opie-76cf4990cb4171a747ac31e9832f4ee694ced2cc.tar.gz opie-76cf4990cb4171a747ac31e9832f4ee694ced2cc.tar.bz2 |
new connection setting stuff for imap too
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/imapconfigui.ui | 159 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 36 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 2 |
5 files changed, 129 insertions, 91 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 9fc97e8..1cb202e 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp | |||
@@ -141,285 +141,294 @@ void EditAccounts::slotEditAccount( Account *account ) | |||
141 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 141 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
142 | nntp.showMaximized(); | 142 | nntp.showMaximized(); |
143 | if ( QDialog::Accepted == nntp.exec() ) { | 143 | if ( QDialog::Accepted == nntp.exec() ) { |
144 | slotFillLists(); | 144 | slotFillLists(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | void EditAccounts::slotDeleteAccount( Account *account ) | 149 | void EditAccounts::slotDeleteAccount( Account *account ) |
150 | { | 150 | { |
151 | if ( QMessageBox::information( this, tr( "Question" ), | 151 | if ( QMessageBox::information( this, tr( "Question" ), |
152 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 152 | tr( "<p>Do you really want to delete the selected Account?</p>" ), |
153 | tr( "Yes" ), tr( "No" ) ) == 0 ) { | 153 | tr( "Yes" ), tr( "No" ) ) == 0 ) { |
154 | settings->delAccount( account ); | 154 | settings->delAccount( account ); |
155 | slotFillLists(); | 155 | slotFillLists(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | void EditAccounts::slotEditMail() | 159 | void EditAccounts::slotEditMail() |
160 | { | 160 | { |
161 | qDebug( "Edit Mail Account" ); | 161 | qDebug( "Edit Mail Account" ); |
162 | if ( !mailList->currentItem() ) { | 162 | if ( !mailList->currentItem() ) { |
163 | QMessageBox::information( this, tr( "Error" ), | 163 | QMessageBox::information( this, tr( "Error" ), |
164 | tr( "<p>Please select an account.</p>" ), | 164 | tr( "<p>Please select an account.</p>" ), |
165 | tr( "Ok" ) ); | 165 | tr( "Ok" ) ); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | 168 | ||
169 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 169 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
170 | slotEditAccount( a ); | 170 | slotEditAccount( a ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void EditAccounts::slotDeleteMail() | 173 | void EditAccounts::slotDeleteMail() |
174 | { | 174 | { |
175 | if ( !mailList->currentItem() ) { | 175 | if ( !mailList->currentItem() ) { |
176 | QMessageBox::information( this, tr( "Error" ), | 176 | QMessageBox::information( this, tr( "Error" ), |
177 | tr( "<p>Please select an account.</p>" ), | 177 | tr( "<p>Please select an account.</p>" ), |
178 | tr( "Ok" ) ); | 178 | tr( "Ok" ) ); |
179 | return; | 179 | return; |
180 | } | 180 | } |
181 | 181 | ||
182 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 182 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
183 | slotDeleteAccount( a ); | 183 | slotDeleteAccount( a ); |
184 | } | 184 | } |
185 | 185 | ||
186 | void EditAccounts::slotNewNews() | 186 | void EditAccounts::slotNewNews() |
187 | { | 187 | { |
188 | qDebug( "New News Account" ); | 188 | qDebug( "New News Account" ); |
189 | slotNewAccount( "NNTP" ); | 189 | slotNewAccount( "NNTP" ); |
190 | } | 190 | } |
191 | 191 | ||
192 | void EditAccounts::slotEditNews() | 192 | void EditAccounts::slotEditNews() |
193 | { | 193 | { |
194 | qDebug( "Edit News Account" ); | 194 | qDebug( "Edit News Account" ); |
195 | if ( !newsList->currentItem() ) { | 195 | if ( !newsList->currentItem() ) { |
196 | QMessageBox::information( this, tr( "Error" ), | 196 | QMessageBox::information( this, tr( "Error" ), |
197 | tr( "<p>Please select an account.</p>" ), | 197 | tr( "<p>Please select an account.</p>" ), |
198 | tr( "Ok" ) ); | 198 | tr( "Ok" ) ); |
199 | return; | 199 | return; |
200 | } | 200 | } |
201 | 201 | ||
202 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 202 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
203 | slotEditAccount( a ); | 203 | slotEditAccount( a ); |
204 | } | 204 | } |
205 | 205 | ||
206 | void EditAccounts::slotDeleteNews() | 206 | void EditAccounts::slotDeleteNews() |
207 | { | 207 | { |
208 | qDebug( "Delete News Account" ); | 208 | qDebug( "Delete News Account" ); |
209 | if ( !newsList->currentItem() ) { | 209 | if ( !newsList->currentItem() ) { |
210 | QMessageBox::information( this, tr( "Error" ), | 210 | QMessageBox::information( this, tr( "Error" ), |
211 | tr( "<p>Please select an account.</p>" ), | 211 | tr( "<p>Please select an account.</p>" ), |
212 | tr( "Ok" ) ); | 212 | tr( "Ok" ) ); |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 216 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
217 | slotDeleteAccount( a ); | 217 | slotDeleteAccount( a ); |
218 | } | 218 | } |
219 | 219 | ||
220 | void EditAccounts::slotAdjustColumns() | 220 | void EditAccounts::slotAdjustColumns() |
221 | { | 221 | { |
222 | int currPage = configTab->currentPageIndex(); | 222 | int currPage = configTab->currentPageIndex(); |
223 | 223 | ||
224 | configTab->showPage( mailTab ); | 224 | configTab->showPage( mailTab ); |
225 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 225 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
226 | mailList->setColumnWidth( 1, 50 ); | 226 | mailList->setColumnWidth( 1, 50 ); |
227 | 227 | ||
228 | configTab->showPage( newsTab ); | 228 | configTab->showPage( newsTab ); |
229 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 229 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
230 | 230 | ||
231 | configTab->setCurrentPage( currPage ); | 231 | configTab->setCurrentPage( currPage ); |
232 | } | 232 | } |
233 | 233 | ||
234 | void EditAccounts::accept() | 234 | void EditAccounts::accept() |
235 | { | 235 | { |
236 | settings->saveAccounts(); | 236 | settings->saveAccounts(); |
237 | 237 | ||
238 | QDialog::accept(); | 238 | QDialog::accept(); |
239 | } | 239 | } |
240 | 240 | ||
241 | /** | 241 | /** |
242 | * SelectMailType | 242 | * SelectMailType |
243 | */ | 243 | */ |
244 | 244 | ||
245 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 245 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
246 | : SelectMailTypeUI( parent, name, modal, flags ) | 246 | : SelectMailTypeUI( parent, name, modal, flags ) |
247 | { | 247 | { |
248 | selected = selection; | 248 | selected = selection; |
249 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 249 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
250 | connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); | 250 | connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void SelectMailType::slotSelection( const QString &sel ) | 253 | void SelectMailType::slotSelection( const QString &sel ) |
254 | { | 254 | { |
255 | selected->replace( 0, selected->length(), sel ); | 255 | selected->replace( 0, selected->length(), sel ); |
256 | } | 256 | } |
257 | 257 | ||
258 | /** | 258 | /** |
259 | * IMAPconfig | 259 | * IMAPconfig |
260 | */ | 260 | */ |
261 | 261 | ||
262 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 262 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
263 | : IMAPconfigUI( parent, name, modal, flags ) | 263 | : IMAPconfigUI( parent, name, modal, flags ) |
264 | { | 264 | { |
265 | data = account; | 265 | data = account; |
266 | 266 | ||
267 | fillValues(); | 267 | fillValues(); |
268 | 268 | ||
269 | connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); | 269 | connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); |
270 | ComboBox1->insertItem( "Only if available", 0 ); | ||
271 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | ||
272 | ComboBox1->insertItem( "Connect on secure port", 2 ); | ||
273 | ComboBox1->insertItem( "Run command instead", 3 ); | ||
274 | CommandEdit->hide(); | ||
275 | ComboBox1->setCurrentItem( data->ConnectionType() ); | ||
270 | } | 276 | } |
271 | 277 | ||
272 | void IMAPconfig::slotSSL( bool enabled ) | 278 | void IMAPconfig::slotConnectionToggle( int index ) |
273 | { | 279 | { |
274 | if ( enabled ) { | 280 | if ( index == 2 ) { |
275 | portLine->setText( IMAP_SSL_PORT ); | 281 | portLine->setText( IMAP_SSL_PORT ); |
282 | } else if ( index == 3 ) { | ||
283 | portLine->setText( IMAP_PORT ); | ||
284 | CommandEdit->show(); | ||
276 | } else { | 285 | } else { |
277 | portLine->setText( IMAP_PORT ); | 286 | portLine->setText( IMAP_PORT ); |
278 | } | 287 | } |
279 | } | 288 | } |
280 | 289 | ||
281 | void IMAPconfig::fillValues() | 290 | void IMAPconfig::fillValues() |
282 | { | 291 | { |
283 | accountLine->setText( data->getAccountName() ); | 292 | accountLine->setText( data->getAccountName() ); |
284 | serverLine->setText( data->getServer() ); | 293 | serverLine->setText( data->getServer() ); |
285 | portLine->setText( data->getPort() ); | 294 | portLine->setText( data->getPort() ); |
286 | sslBox->setChecked( data->getSSL() ); | 295 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
287 | userLine->setText( data->getUser() ); | 296 | userLine->setText( data->getUser() ); |
288 | passLine->setText( data->getPassword() ); | 297 | passLine->setText( data->getPassword() ); |
289 | prefixLine->setText(data->getPrefix()); | 298 | prefixLine->setText(data->getPrefix()); |
290 | } | 299 | } |
291 | 300 | ||
292 | void IMAPconfig::accept() | 301 | void IMAPconfig::accept() |
293 | { | 302 | { |
294 | data->setAccountName( accountLine->text() ); | 303 | data->setAccountName( accountLine->text() ); |
295 | data->setServer( serverLine->text() ); | 304 | data->setServer( serverLine->text() ); |
296 | data->setPort( portLine->text() ); | 305 | data->setPort( portLine->text() ); |
297 | data->setSSL( sslBox->isChecked() ); | 306 | data->setConnectionType( ComboBox1->currentItem() ); |
298 | data->setUser( userLine->text() ); | 307 | data->setUser( userLine->text() ); |
299 | data->setPassword( passLine->text() ); | 308 | data->setPassword( passLine->text() ); |
300 | data->setPrefix(prefixLine->text()); | 309 | data->setPrefix(prefixLine->text()); |
301 | 310 | ||
302 | QDialog::accept(); | 311 | QDialog::accept(); |
303 | } | 312 | } |
304 | 313 | ||
305 | /** | 314 | /** |
306 | * POP3config | 315 | * POP3config |
307 | */ | 316 | */ |
308 | 317 | ||
309 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 318 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
310 | : POP3configUI( parent, name, modal, flags ) | 319 | : POP3configUI( parent, name, modal, flags ) |
311 | { | 320 | { |
312 | data = account; | 321 | data = account; |
313 | fillValues(); | 322 | fillValues(); |
314 | 323 | ||
315 | connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); | 324 | connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); |
316 | ComboBox1->insertItem( "Only if available", 0 ); | 325 | ComboBox1->insertItem( "Only if available", 0 ); |
317 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 326 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
318 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 327 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
319 | ComboBox1->insertItem( "Run command instead", 3 ); | 328 | ComboBox1->insertItem( "Run command instead", 3 ); |
320 | CommandEdit->hide(); | 329 | CommandEdit->hide(); |
321 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 330 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
322 | } | 331 | } |
323 | 332 | ||
324 | void POP3config::slotConnectionToggle( int index ) | 333 | void POP3config::slotConnectionToggle( int index ) |
325 | { | 334 | { |
326 | // 2 is ssl connection | 335 | // 2 is ssl connection |
327 | if ( index == 2 ) { | 336 | if ( index == 2 ) { |
328 | portLine->setText( POP3_SSL_PORT ); | 337 | portLine->setText( POP3_SSL_PORT ); |
329 | } else if ( index == 3 ) { | 338 | } else if ( index == 3 ) { |
330 | portLine->setText( POP3_PORT ); | 339 | portLine->setText( POP3_PORT ); |
331 | CommandEdit->show(); | 340 | CommandEdit->show(); |
332 | } else { | 341 | } else { |
333 | portLine->setText( POP3_PORT ); | 342 | portLine->setText( POP3_PORT ); |
334 | } | 343 | } |
335 | } | 344 | } |
336 | 345 | ||
337 | void POP3config::fillValues() | 346 | void POP3config::fillValues() |
338 | { | 347 | { |
339 | accountLine->setText( data->getAccountName() ); | 348 | accountLine->setText( data->getAccountName() ); |
340 | serverLine->setText( data->getServer() ); | 349 | serverLine->setText( data->getServer() ); |
341 | portLine->setText( data->getPort() ); | 350 | portLine->setText( data->getPort() ); |
342 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 351 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
343 | userLine->setText( data->getUser() ); | 352 | userLine->setText( data->getUser() ); |
344 | passLine->setText( data->getPassword() ); | 353 | passLine->setText( data->getPassword() ); |
345 | } | 354 | } |
346 | 355 | ||
347 | void POP3config::accept() | 356 | void POP3config::accept() |
348 | { | 357 | { |
349 | data->setAccountName( accountLine->text() ); | 358 | data->setAccountName( accountLine->text() ); |
350 | data->setServer( serverLine->text() ); | 359 | data->setServer( serverLine->text() ); |
351 | data->setPort( portLine->text() ); | 360 | data->setPort( portLine->text() ); |
352 | data->setConnectionType( ComboBox1->currentItem() ); | 361 | data->setConnectionType( ComboBox1->currentItem() ); |
353 | data->setUser( userLine->text() ); | 362 | data->setUser( userLine->text() ); |
354 | data->setPassword( passLine->text() ); | 363 | data->setPassword( passLine->text() ); |
355 | 364 | ||
356 | QDialog::accept(); | 365 | QDialog::accept(); |
357 | } | 366 | } |
358 | 367 | ||
359 | /** | 368 | /** |
360 | * SMTPconfig | 369 | * SMTPconfig |
361 | */ | 370 | */ |
362 | 371 | ||
363 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 372 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
364 | : SMTPconfigUI( parent, name, modal, flags ) | 373 | : SMTPconfigUI( parent, name, modal, flags ) |
365 | { | 374 | { |
366 | data = account; | 375 | data = account; |
367 | 376 | ||
368 | connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); | 377 | connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); |
369 | connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); | 378 | connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); |
370 | 379 | ||
371 | fillValues(); | 380 | fillValues(); |
372 | 381 | ||
373 | connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); | 382 | connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); |
374 | ComboBox1->insertItem( "Only if available", 0 ); | 383 | ComboBox1->insertItem( "Only if available", 0 ); |
375 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 384 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
376 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 385 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
377 | ComboBox1->insertItem( "Run command instead", 3 ); | 386 | ComboBox1->insertItem( "Run command instead", 3 ); |
378 | CommandEdit->hide(); | 387 | CommandEdit->hide(); |
379 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 388 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
380 | } | 389 | } |
381 | 390 | ||
382 | void SMTPconfig::slotConnectionToggle( int index ) | 391 | void SMTPconfig::slotConnectionToggle( int index ) |
383 | { | 392 | { |
384 | // 2 is ssl connection | 393 | // 2 is ssl connection |
385 | if ( index == 2 ) { | 394 | if ( index == 2 ) { |
386 | portLine->setText( SMTP_SSL_PORT ); | 395 | portLine->setText( SMTP_SSL_PORT ); |
387 | } else if ( index == 3 ) { | 396 | } else if ( index == 3 ) { |
388 | portLine->setText( SMTP_PORT ); | 397 | portLine->setText( SMTP_PORT ); |
389 | CommandEdit->show(); | 398 | CommandEdit->show(); |
390 | } else { | 399 | } else { |
391 | portLine->setText( SMTP_PORT ); | 400 | portLine->setText( SMTP_PORT ); |
392 | } | 401 | } |
393 | } | 402 | } |
394 | 403 | ||
395 | void SMTPconfig::fillValues() | 404 | void SMTPconfig::fillValues() |
396 | { | 405 | { |
397 | accountLine->setText( data->getAccountName() ); | 406 | accountLine->setText( data->getAccountName() ); |
398 | serverLine->setText( data->getServer() ); | 407 | serverLine->setText( data->getServer() ); |
399 | portLine->setText( data->getPort() ); | 408 | portLine->setText( data->getPort() ); |
400 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 409 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
401 | loginBox->setChecked( data->getLogin() ); | 410 | loginBox->setChecked( data->getLogin() ); |
402 | userLine->setText( data->getUser() ); | 411 | userLine->setText( data->getUser() ); |
403 | passLine->setText( data->getPassword() ); | 412 | passLine->setText( data->getPassword() ); |
404 | } | 413 | } |
405 | 414 | ||
406 | void SMTPconfig::accept() | 415 | void SMTPconfig::accept() |
407 | { | 416 | { |
408 | data->setAccountName( accountLine->text() ); | 417 | data->setAccountName( accountLine->text() ); |
409 | data->setServer( serverLine->text() ); | 418 | data->setServer( serverLine->text() ); |
410 | data->setPort( portLine->text() ); | 419 | data->setPort( portLine->text() ); |
411 | data->setConnectionType( ComboBox1->currentItem() ); | 420 | data->setConnectionType( ComboBox1->currentItem() ); |
412 | data->setLogin( loginBox->isChecked() ); | 421 | data->setLogin( loginBox->isChecked() ); |
413 | data->setUser( userLine->text() ); | 422 | data->setUser( userLine->text() ); |
414 | data->setPassword( passLine->text() ); | 423 | data->setPassword( passLine->text() ); |
415 | 424 | ||
416 | QDialog::accept(); | 425 | QDialog::accept(); |
417 | } | 426 | } |
418 | 427 | ||
419 | /** | 428 | /** |
420 | * NNTPconfig | 429 | * NNTPconfig |
421 | */ | 430 | */ |
422 | 431 | ||
423 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 432 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
424 | : NNTPconfigUI( parent, name, modal, flags ) | 433 | : NNTPconfigUI( parent, name, modal, flags ) |
425 | { | 434 | { |
diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h index d51e299..d8e1219 100644 --- a/noncore/net/mail/editaccounts.h +++ b/noncore/net/mail/editaccounts.h | |||
@@ -1,147 +1,147 @@ | |||
1 | #ifndef EDITACCOUNTS_H | 1 | #ifndef EDITACCOUNTS_H |
2 | #define EDITACCOUNTS_H | 2 | #define EDITACCOUNTS_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | 6 | ||
7 | #include "editaccountsui.h" | 7 | #include "editaccountsui.h" |
8 | #include "selectmailtypeui.h" | 8 | #include "selectmailtypeui.h" |
9 | #include "imapconfigui.h" | 9 | #include "imapconfigui.h" |
10 | #include "pop3configui.h" | 10 | #include "pop3configui.h" |
11 | #include "smtpconfigui.h" | 11 | #include "smtpconfigui.h" |
12 | #include "nntpconfigui.h" | 12 | #include "nntpconfigui.h" |
13 | #include <libmailwrapper/settings.h> | 13 | #include <libmailwrapper/settings.h> |
14 | 14 | ||
15 | 15 | ||
16 | class AccountListItem : public QListViewItem | 16 | class AccountListItem : public QListViewItem |
17 | { | 17 | { |
18 | 18 | ||
19 | public: | 19 | public: |
20 | AccountListItem( QListView *parent, Account *a); | 20 | AccountListItem( QListView *parent, Account *a); |
21 | Account *getAccount() { return account; } | 21 | Account *getAccount() { return account; } |
22 | 22 | ||
23 | private: | 23 | private: |
24 | Account *account; | 24 | Account *account; |
25 | 25 | ||
26 | }; | 26 | }; |
27 | 27 | ||
28 | class EditAccounts : public EditAccountsUI | 28 | class EditAccounts : public EditAccountsUI |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); | 33 | EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); |
34 | 34 | ||
35 | public slots: | 35 | public slots: |
36 | void slotNewAccount( const QString &type ); | 36 | void slotNewAccount( const QString &type ); |
37 | void slotEditAccount( Account *account ); | 37 | void slotEditAccount( Account *account ); |
38 | void slotDeleteAccount( Account * account ); | 38 | void slotDeleteAccount( Account * account ); |
39 | void slotAdjustColumns(); | 39 | void slotAdjustColumns(); |
40 | 40 | ||
41 | protected slots: | 41 | protected slots: |
42 | void slotFillLists(); | 42 | void slotFillLists(); |
43 | void slotNewMail(); | 43 | void slotNewMail(); |
44 | void slotEditMail(); | 44 | void slotEditMail(); |
45 | void slotDeleteMail(); | 45 | void slotDeleteMail(); |
46 | void slotNewNews(); | 46 | void slotNewNews(); |
47 | void slotEditNews(); | 47 | void slotEditNews(); |
48 | void slotDeleteNews(); | 48 | void slotDeleteNews(); |
49 | void accept(); | 49 | void accept(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | Settings *settings; | 52 | Settings *settings; |
53 | 53 | ||
54 | }; | 54 | }; |
55 | 55 | ||
56 | class SelectMailType : public SelectMailTypeUI | 56 | class SelectMailType : public SelectMailTypeUI |
57 | { | 57 | { |
58 | Q_OBJECT | 58 | Q_OBJECT |
59 | 59 | ||
60 | public: | 60 | public: |
61 | SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); | 61 | SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); |
62 | 62 | ||
63 | private slots: | 63 | private slots: |
64 | void slotSelection( const QString &sel ); | 64 | void slotSelection( const QString &sel ); |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QString *selected; | 67 | QString *selected; |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | class IMAPconfig : public IMAPconfigUI | 71 | class IMAPconfig : public IMAPconfigUI |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
76 | IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); | 76 | IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); |
77 | 77 | ||
78 | public slots: | 78 | public slots: |
79 | void fillValues(); | 79 | void fillValues(); |
80 | 80 | ||
81 | protected slots: | 81 | protected slots: |
82 | void slotSSL( bool enabled ); | 82 | void slotConnectionToggle( int index ); |
83 | void accept(); | 83 | void accept(); |
84 | 84 | ||
85 | private: | 85 | private: |
86 | IMAPaccount *data; | 86 | IMAPaccount *data; |
87 | 87 | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | class POP3config : public POP3configUI | 90 | class POP3config : public POP3configUI |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | 93 | ||
94 | public: | 94 | public: |
95 | POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); | 95 | POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); |
96 | 96 | ||
97 | public slots: | 97 | public slots: |
98 | void fillValues(); | 98 | void fillValues(); |
99 | 99 | ||
100 | protected slots: | 100 | protected slots: |
101 | void slotConnectionToggle( int index ); | 101 | void slotConnectionToggle( int index ); |
102 | void accept(); | 102 | void accept(); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | POP3account *data; | 105 | POP3account *data; |
106 | 106 | ||
107 | }; | 107 | }; |
108 | 108 | ||
109 | class SMTPconfig : public SMTPconfigUI | 109 | class SMTPconfig : public SMTPconfigUI |
110 | { | 110 | { |
111 | Q_OBJECT | 111 | Q_OBJECT |
112 | 112 | ||
113 | public: | 113 | public: |
114 | SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); | 114 | SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); |
115 | 115 | ||
116 | public slots: | 116 | public slots: |
117 | void fillValues(); | 117 | void fillValues(); |
118 | 118 | ||
119 | protected slots: | 119 | protected slots: |
120 | void slotConnectionToggle( int index ); | 120 | void slotConnectionToggle( int index ); |
121 | void accept(); | 121 | void accept(); |
122 | 122 | ||
123 | private: | 123 | private: |
124 | SMTPaccount *data; | 124 | SMTPaccount *data; |
125 | 125 | ||
126 | }; | 126 | }; |
127 | 127 | ||
128 | class NNTPconfig : public NNTPconfigUI | 128 | class NNTPconfig : public NNTPconfigUI |
129 | { | 129 | { |
130 | Q_OBJECT | 130 | Q_OBJECT |
131 | 131 | ||
132 | public: | 132 | public: |
133 | NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); | 133 | NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); |
134 | 134 | ||
135 | public slots: | 135 | public slots: |
136 | void fillValues(); | 136 | void fillValues(); |
137 | 137 | ||
138 | protected slots: | 138 | protected slots: |
139 | void slotSSL( bool enabled ); | 139 | void slotSSL( bool enabled ); |
140 | void accept(); | 140 | void accept(); |
141 | 141 | ||
142 | private: | 142 | private: |
143 | NNTPaccount *data; | 143 | NNTPaccount *data; |
144 | 144 | ||
145 | }; | 145 | }; |
146 | 146 | ||
147 | #endif | 147 | #endif |
diff --git a/noncore/net/mail/imapconfigui.ui b/noncore/net/mail/imapconfigui.ui index ac0297f..a96c1a2 100644 --- a/noncore/net/mail/imapconfigui.ui +++ b/noncore/net/mail/imapconfigui.ui | |||
@@ -1,242 +1,259 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>IMAPconfigUI</class> | 2 | <class>IMAPconfigUI</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>IMAPconfigUI</cstring> | 7 | <cstring>IMAPconfigUI</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>228</width> | 14 | <width>425</width> |
15 | <height>320</height> | 15 | <height>428</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Configure IMAP</string> | 20 | <string>Configure IMAP</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <grid> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>3</number> | 31 | <number>3</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>2</number> | 35 | <number>3</number> |
36 | </property> | 36 | </property> |
37 | <widget row="6" column="0" > | ||
38 | <class>QLabel</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>userLabel</cstring> | ||
42 | </property> | ||
43 | <property stdset="1"> | ||
44 | <name>text</name> | ||
45 | <string>User</string> | ||
46 | </property> | ||
47 | </widget> | ||
48 | <widget row="4" column="1" > | ||
49 | <class>QCheckBox</class> | ||
50 | <property stdset="1"> | ||
51 | <name>name</name> | ||
52 | <cstring>sslBox</cstring> | ||
53 | </property> | ||
54 | <property stdset="1"> | ||
55 | <name>text</name> | ||
56 | <string>Use SSL</string> | ||
57 | </property> | ||
58 | </widget> | ||
59 | <widget row="2" column="1" > | 37 | <widget row="2" column="1" > |
60 | <class>QLineEdit</class> | 38 | <class>QLineEdit</class> |
61 | <property stdset="1"> | 39 | <property stdset="1"> |
62 | <name>name</name> | 40 | <name>name</name> |
63 | <cstring>serverLine</cstring> | 41 | <cstring>serverLine</cstring> |
64 | </property> | 42 | </property> |
65 | </widget> | 43 | </widget> |
66 | <widget row="6" column="1" > | ||
67 | <class>QLineEdit</class> | ||
68 | <property stdset="1"> | ||
69 | <name>name</name> | ||
70 | <cstring>userLine</cstring> | ||
71 | </property> | ||
72 | </widget> | ||
73 | <widget row="7" column="0" > | ||
74 | <class>QLabel</class> | ||
75 | <property stdset="1"> | ||
76 | <name>name</name> | ||
77 | <cstring>passLabel</cstring> | ||
78 | </property> | ||
79 | <property stdset="1"> | ||
80 | <name>text</name> | ||
81 | <string>Password</string> | ||
82 | </property> | ||
83 | </widget> | ||
84 | <widget row="3" column="0" > | 44 | <widget row="3" column="0" > |
85 | <class>QLabel</class> | 45 | <class>QLabel</class> |
86 | <property stdset="1"> | 46 | <property stdset="1"> |
87 | <name>name</name> | 47 | <name>name</name> |
88 | <cstring>portLabel</cstring> | 48 | <cstring>portLabel</cstring> |
89 | </property> | 49 | </property> |
90 | <property stdset="1"> | 50 | <property stdset="1"> |
91 | <name>text</name> | 51 | <name>text</name> |
92 | <string>Port</string> | 52 | <string>Port</string> |
93 | </property> | 53 | </property> |
94 | </widget> | 54 | </widget> |
95 | <widget row="2" column="0" > | 55 | <widget row="2" column="0" > |
96 | <class>QLabel</class> | 56 | <class>QLabel</class> |
97 | <property stdset="1"> | 57 | <property stdset="1"> |
98 | <name>name</name> | 58 | <name>name</name> |
99 | <cstring>serverLabel</cstring> | 59 | <cstring>serverLabel</cstring> |
100 | </property> | 60 | </property> |
101 | <property stdset="1"> | 61 | <property stdset="1"> |
102 | <name>text</name> | 62 | <name>text</name> |
103 | <string>Server</string> | 63 | <string>Server</string> |
104 | </property> | 64 | </property> |
105 | </widget> | 65 | </widget> |
106 | <widget row="3" column="1" > | 66 | <widget row="3" column="1" > |
107 | <class>QLineEdit</class> | 67 | <class>QLineEdit</class> |
108 | <property stdset="1"> | 68 | <property stdset="1"> |
109 | <name>name</name> | 69 | <name>name</name> |
110 | <cstring>portLine</cstring> | 70 | <cstring>portLine</cstring> |
111 | </property> | 71 | </property> |
112 | </widget> | 72 | </widget> |
113 | <widget row="7" column="1" > | 73 | <widget row="0" column="1" > |
114 | <class>QLineEdit</class> | 74 | <class>QLineEdit</class> |
115 | <property stdset="1"> | 75 | <property stdset="1"> |
116 | <name>name</name> | 76 | <name>name</name> |
117 | <cstring>passLine</cstring> | 77 | <cstring>accountLine</cstring> |
78 | </property> | ||
79 | <property> | ||
80 | <name>toolTip</name> | ||
81 | <string>Name of the Account</string> | ||
118 | </property> | 82 | </property> |
83 | </widget> | ||
84 | <widget row="0" column="0" > | ||
85 | <class>QLabel</class> | ||
119 | <property stdset="1"> | 86 | <property stdset="1"> |
120 | <name>echoMode</name> | 87 | <name>name</name> |
121 | <enum>Password</enum> | 88 | <cstring>accountLabel</cstring> |
89 | </property> | ||
90 | <property stdset="1"> | ||
91 | <name>text</name> | ||
92 | <string>Account</string> | ||
93 | </property> | ||
94 | </widget> | ||
95 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
96 | <class>Line</class> | ||
97 | <property stdset="1"> | ||
98 | <name>name</name> | ||
99 | <cstring>line1</cstring> | ||
100 | </property> | ||
101 | <property stdset="1"> | ||
102 | <name>orientation</name> | ||
103 | <enum>Horizontal</enum> | ||
122 | </property> | 104 | </property> |
123 | </widget> | 105 | </widget> |
124 | <spacer row="10" column="1" > | 106 | <spacer row="12" column="1" > |
125 | <property> | 107 | <property> |
126 | <name>name</name> | 108 | <name>name</name> |
127 | <cstring>spacer</cstring> | 109 | <cstring>spacer</cstring> |
128 | </property> | 110 | </property> |
129 | <property stdset="1"> | 111 | <property stdset="1"> |
130 | <name>orientation</name> | 112 | <name>orientation</name> |
131 | <enum>Vertical</enum> | 113 | <enum>Vertical</enum> |
132 | </property> | 114 | </property> |
133 | <property stdset="1"> | 115 | <property stdset="1"> |
134 | <name>sizeType</name> | 116 | <name>sizeType</name> |
135 | <enum>Expanding</enum> | 117 | <enum>Expanding</enum> |
136 | </property> | 118 | </property> |
137 | <property> | 119 | <property> |
138 | <name>sizeHint</name> | 120 | <name>sizeHint</name> |
139 | <size> | 121 | <size> |
140 | <width>20</width> | 122 | <width>20</width> |
141 | <height>20</height> | 123 | <height>20</height> |
142 | </size> | 124 | </size> |
143 | </property> | 125 | </property> |
144 | </spacer> | 126 | </spacer> |
145 | <widget row="0" column="1" > | 127 | <widget row="8" column="1" > |
146 | <class>QLineEdit</class> | 128 | <class>QLineEdit</class> |
147 | <property stdset="1"> | 129 | <property stdset="1"> |
148 | <name>name</name> | 130 | <name>name</name> |
149 | <cstring>accountLine</cstring> | 131 | <cstring>userLine</cstring> |
150 | </property> | ||
151 | <property> | ||
152 | <name>toolTip</name> | ||
153 | <string>Name of the Account</string> | ||
154 | </property> | 132 | </property> |
155 | </widget> | 133 | </widget> |
156 | <widget row="0" column="0" > | 134 | <widget row="9" column="1" > |
157 | <class>QLabel</class> | 135 | <class>QLineEdit</class> |
158 | <property stdset="1"> | 136 | <property stdset="1"> |
159 | <name>name</name> | 137 | <name>name</name> |
160 | <cstring>accountLabel</cstring> | 138 | <cstring>passLine</cstring> |
161 | </property> | 139 | </property> |
162 | <property stdset="1"> | 140 | <property stdset="1"> |
163 | <name>text</name> | 141 | <name>echoMode</name> |
164 | <string>Account</string> | 142 | <enum>Password</enum> |
165 | </property> | 143 | </property> |
166 | </widget> | 144 | </widget> |
167 | <widget row="1" column="0" rowspan="1" colspan="2" > | 145 | <widget row="11" column="0" > |
168 | <class>Line</class> | 146 | <class>QLabel</class> |
169 | <property stdset="1"> | 147 | <property stdset="1"> |
170 | <name>name</name> | 148 | <name>name</name> |
171 | <cstring>line1</cstring> | 149 | <cstring>prefixLabel</cstring> |
172 | </property> | 150 | </property> |
173 | <property stdset="1"> | 151 | <property stdset="1"> |
174 | <name>orientation</name> | 152 | <name>text</name> |
175 | <enum>Horizontal</enum> | 153 | <string>Prefix</string> |
176 | </property> | 154 | </property> |
177 | </widget> | 155 | </widget> |
178 | <widget row="9" column="1" > | 156 | <widget row="11" column="1" > |
179 | <class>QLineEdit</class> | 157 | <class>QLineEdit</class> |
180 | <property stdset="1"> | 158 | <property stdset="1"> |
181 | <name>name</name> | 159 | <name>name</name> |
182 | <cstring>prefixLine</cstring> | 160 | <cstring>prefixLine</cstring> |
183 | </property> | 161 | </property> |
184 | </widget> | 162 | </widget> |
185 | <widget row="9" column="0" > | 163 | <widget row="8" column="0" > |
186 | <class>QLabel</class> | 164 | <class>QLabel</class> |
187 | <property stdset="1"> | 165 | <property stdset="1"> |
188 | <name>name</name> | 166 | <name>name</name> |
189 | <cstring>prefixLabel</cstring> | 167 | <cstring>userLabel</cstring> |
190 | </property> | 168 | </property> |
191 | <property stdset="1"> | 169 | <property stdset="1"> |
192 | <name>text</name> | 170 | <name>text</name> |
193 | <string>Prefix</string> | 171 | <string>User</string> |
194 | </property> | 172 | </property> |
195 | </widget> | 173 | </widget> |
196 | <widget row="5" column="0" rowspan="1" colspan="2" > | 174 | <widget row="7" column="0" rowspan="1" colspan="2" > |
197 | <class>Line</class> | 175 | <class>Line</class> |
198 | <property stdset="1"> | 176 | <property stdset="1"> |
199 | <name>name</name> | 177 | <name>name</name> |
200 | <cstring>line2</cstring> | 178 | <cstring>line2</cstring> |
201 | </property> | 179 | </property> |
202 | <property stdset="1"> | 180 | <property stdset="1"> |
203 | <name>enabled</name> | 181 | <name>enabled</name> |
204 | <bool>true</bool> | 182 | <bool>true</bool> |
205 | </property> | 183 | </property> |
206 | <property stdset="1"> | 184 | <property stdset="1"> |
207 | <name>caption</name> | 185 | <name>caption</name> |
208 | <string></string> | 186 | <string></string> |
209 | </property> | 187 | </property> |
210 | <property stdset="1"> | 188 | <property stdset="1"> |
211 | <name>orientation</name> | 189 | <name>orientation</name> |
212 | <enum>Horizontal</enum> | 190 | <enum>Horizontal</enum> |
213 | </property> | 191 | </property> |
214 | <property> | 192 | <property> |
215 | <name>layoutMargin</name> | 193 | <name>layoutMargin</name> |
216 | </property> | 194 | </property> |
217 | <property> | 195 | <property> |
218 | <name>layoutSpacing</name> | 196 | <name>layoutSpacing</name> |
219 | </property> | 197 | </property> |
220 | </widget> | 198 | </widget> |
221 | <widget row="8" column="0" rowspan="1" colspan="2" > | 199 | <widget row="10" column="0" rowspan="1" colspan="2" > |
222 | <class>Line</class> | 200 | <class>Line</class> |
223 | <property stdset="1"> | 201 | <property stdset="1"> |
224 | <name>name</name> | 202 | <name>name</name> |
225 | <cstring>Line3</cstring> | 203 | <cstring>Line3</cstring> |
226 | </property> | 204 | </property> |
227 | <property stdset="1"> | 205 | <property stdset="1"> |
228 | <name>orientation</name> | 206 | <name>orientation</name> |
229 | <enum>Horizontal</enum> | 207 | <enum>Horizontal</enum> |
230 | </property> | 208 | </property> |
231 | </widget> | 209 | </widget> |
210 | <widget row="9" column="0" > | ||
211 | <class>QLabel</class> | ||
212 | <property stdset="1"> | ||
213 | <name>name</name> | ||
214 | <cstring>passLabel</cstring> | ||
215 | </property> | ||
216 | <property stdset="1"> | ||
217 | <name>text</name> | ||
218 | <string>Password</string> | ||
219 | </property> | ||
220 | </widget> | ||
221 | <widget row="6" column="0" rowspan="1" colspan="2" > | ||
222 | <class>QLineEdit</class> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>CommandEdit</cstring> | ||
226 | </property> | ||
227 | <property stdset="1"> | ||
228 | <name>text</name> | ||
229 | <string>ssh $SERVER exec</string> | ||
230 | </property> | ||
231 | </widget> | ||
232 | <widget row="5" column="0" rowspan="1" colspan="2" > | ||
233 | <class>QComboBox</class> | ||
234 | <property stdset="1"> | ||
235 | <name>name</name> | ||
236 | <cstring>ComboBox1</cstring> | ||
237 | </property> | ||
238 | </widget> | ||
239 | <widget row="4" column="0" rowspan="1" colspan="2" > | ||
240 | <class>QLabel</class> | ||
241 | <property stdset="1"> | ||
242 | <name>name</name> | ||
243 | <cstring>TextLabel1</cstring> | ||
244 | </property> | ||
245 | <property stdset="1"> | ||
246 | <name>text</name> | ||
247 | <string>Use secure sockets:</string> | ||
248 | </property> | ||
249 | </widget> | ||
232 | </grid> | 250 | </grid> |
233 | </widget> | 251 | </widget> |
234 | <tabstops> | 252 | <tabstops> |
235 | <tabstop>accountLine</tabstop> | 253 | <tabstop>accountLine</tabstop> |
236 | <tabstop>serverLine</tabstop> | 254 | <tabstop>serverLine</tabstop> |
237 | <tabstop>portLine</tabstop> | 255 | <tabstop>portLine</tabstop> |
238 | <tabstop>sslBox</tabstop> | ||
239 | <tabstop>userLine</tabstop> | 256 | <tabstop>userLine</tabstop> |
240 | <tabstop>passLine</tabstop> | 257 | <tabstop>passLine</tabstop> |
241 | </tabstops> | 258 | </tabstops> |
242 | </UI> | 259 | </UI> |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 4b633ea..1c22c26 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,212 +1,222 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | 4 | ||
5 | #include "imapwrapper.h" | 5 | #include "imapwrapper.h" |
6 | #include "mailtypes.h" | 6 | #include "mailtypes.h" |
7 | #include "logindialog.h" | 7 | #include "logindialog.h" |
8 | 8 | ||
9 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 9 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
10 | : AbstractMail() | 10 | : AbstractMail() |
11 | { | 11 | { |
12 | account = a; | 12 | account = a; |
13 | m_imap = 0; | 13 | m_imap = 0; |
14 | m_Lastmbox = ""; | 14 | m_Lastmbox = ""; |
15 | } | 15 | } |
16 | 16 | ||
17 | IMAPwrapper::~IMAPwrapper() | 17 | IMAPwrapper::~IMAPwrapper() |
18 | { | 18 | { |
19 | logout(); | 19 | logout(); |
20 | } | 20 | } |
21 | 21 | ||
22 | /* to avoid to often select statements in loops etc. | 22 | /* to avoid to often select statements in loops etc. |
23 | we trust that we are logged in and connection is established!*/ | 23 | we trust that we are logged in and connection is established!*/ |
24 | int IMAPwrapper::selectMbox(const QString&mbox) | 24 | int IMAPwrapper::selectMbox(const QString&mbox) |
25 | { | 25 | { |
26 | if (mbox == m_Lastmbox) { | 26 | if (mbox == m_Lastmbox) { |
27 | return MAILIMAP_NO_ERROR; | 27 | return MAILIMAP_NO_ERROR; |
28 | } | 28 | } |
29 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 29 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
30 | if ( err != MAILIMAP_NO_ERROR ) { | 30 | if ( err != MAILIMAP_NO_ERROR ) { |
31 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 31 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
32 | m_Lastmbox = ""; | 32 | m_Lastmbox = ""; |
33 | return err; | 33 | return err; |
34 | } | 34 | } |
35 | m_Lastmbox = mbox; | 35 | m_Lastmbox = mbox; |
36 | return err; | 36 | return err; |
37 | } | 37 | } |
38 | 38 | ||
39 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 39 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
40 | { | 40 | { |
41 | qDebug( "IMAP: %i of %i", current, maximum ); | 41 | qDebug( "IMAP: %i of %i", current, maximum ); |
42 | } | 42 | } |
43 | 43 | ||
44 | void IMAPwrapper::login() | 44 | void IMAPwrapper::login() |
45 | { | 45 | { |
46 | const char *server, *user, *pass; | 46 | const char *server, *user, *pass; |
47 | uint16_t port; | 47 | uint16_t port; |
48 | int err = MAILIMAP_NO_ERROR; | 48 | int err = MAILIMAP_NO_ERROR; |
49 | 49 | ||
50 | if (account->getOffline()) return; | 50 | if (account->getOffline()) return; |
51 | /* we are connected this moment */ | 51 | /* we are connected this moment */ |
52 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 52 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
53 | if (m_imap) { | 53 | if (m_imap) { |
54 | err = mailimap_noop(m_imap); | 54 | err = mailimap_noop(m_imap); |
55 | if (err!=MAILIMAP_NO_ERROR) { | 55 | if (err!=MAILIMAP_NO_ERROR) { |
56 | logout(); | 56 | logout(); |
57 | } else { | 57 | } else { |
58 | mailstream_flush(m_imap->imap_stream); | 58 | mailstream_flush(m_imap->imap_stream); |
59 | return; | 59 | return; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | server = account->getServer().latin1(); | 62 | server = account->getServer().latin1(); |
63 | port = account->getPort().toUInt(); | 63 | port = account->getPort().toUInt(); |
64 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 64 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
65 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 65 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
66 | login.show(); | 66 | login.show(); |
67 | if ( QDialog::Accepted == login.exec() ) { | 67 | if ( QDialog::Accepted == login.exec() ) { |
68 | // ok | 68 | // ok |
69 | user = login.getUser().latin1(); | 69 | user = login.getUser().latin1(); |
70 | pass = login.getPassword().latin1(); | 70 | pass = login.getPassword().latin1(); |
71 | } else { | 71 | } else { |
72 | // cancel | 72 | // cancel |
73 | qDebug( "IMAP: Login canceled" ); | 73 | qDebug( "IMAP: Login canceled" ); |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | } else { | 76 | } else { |
77 | user = account->getUser().latin1(); | 77 | user = account->getUser().latin1(); |
78 | pass = account->getPassword().latin1(); | 78 | pass = account->getPassword().latin1(); |
79 | } | 79 | } |
80 | 80 | ||
81 | m_imap = mailimap_new( 20, &imap_progress ); | 81 | m_imap = mailimap_new( 20, &imap_progress ); |
82 | 82 | ||
83 | |||
84 | |||
83 | /* connect */ | 85 | /* connect */ |
84 | if (account->getSSL()) { | 86 | |
87 | bool ssl = false; | ||
88 | |||
89 | if ( account->ConnectionType() == 2 ) { | ||
90 | ssl = true; | ||
91 | } | ||
92 | |||
93 | if ( ssl ) { | ||
94 | qDebug( "using ssl" ); | ||
85 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 95 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
86 | } else { | 96 | } else { |
87 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 97 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
88 | } | 98 | } |
89 | 99 | ||
90 | if ( err != MAILIMAP_NO_ERROR && | 100 | if ( err != MAILIMAP_NO_ERROR && |
91 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 101 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
92 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 102 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
93 | QString failure = ""; | 103 | QString failure = ""; |
94 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 104 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
95 | failure="Connection refused"; | 105 | failure="Connection refused"; |
96 | } else { | 106 | } else { |
97 | failure="Unknown failure"; | 107 | failure="Unknown failure"; |
98 | } | 108 | } |
99 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 109 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
100 | mailimap_free( m_imap ); | 110 | mailimap_free( m_imap ); |
101 | m_imap = 0; | 111 | m_imap = 0; |
102 | return; | 112 | return; |
103 | } | 113 | } |
104 | 114 | ||
105 | /* login */ | 115 | /* login */ |
106 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 116 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
107 | if ( err != MAILIMAP_NO_ERROR ) { | 117 | if ( err != MAILIMAP_NO_ERROR ) { |
108 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 118 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
109 | err = mailimap_close( m_imap ); | 119 | err = mailimap_close( m_imap ); |
110 | mailimap_free( m_imap ); | 120 | mailimap_free( m_imap ); |
111 | m_imap = 0; | 121 | m_imap = 0; |
112 | } | 122 | } |
113 | } | 123 | } |
114 | 124 | ||
115 | void IMAPwrapper::logout() | 125 | void IMAPwrapper::logout() |
116 | { | 126 | { |
117 | int err = MAILIMAP_NO_ERROR; | 127 | int err = MAILIMAP_NO_ERROR; |
118 | if (!m_imap) return; | 128 | if (!m_imap) return; |
119 | err = mailimap_logout( m_imap ); | 129 | err = mailimap_logout( m_imap ); |
120 | err = mailimap_close( m_imap ); | 130 | err = mailimap_close( m_imap ); |
121 | mailimap_free( m_imap ); | 131 | mailimap_free( m_imap ); |
122 | m_imap = 0; | 132 | m_imap = 0; |
123 | m_Lastmbox = ""; | 133 | m_Lastmbox = ""; |
124 | } | 134 | } |
125 | 135 | ||
126 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 136 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
127 | { | 137 | { |
128 | int err = MAILIMAP_NO_ERROR; | 138 | int err = MAILIMAP_NO_ERROR; |
129 | clist *result = 0; | 139 | clist *result = 0; |
130 | clistcell *current; | 140 | clistcell *current; |
131 | mailimap_fetch_type *fetchType = 0; | 141 | mailimap_fetch_type *fetchType = 0; |
132 | mailimap_set *set = 0; | 142 | mailimap_set *set = 0; |
133 | 143 | ||
134 | login(); | 144 | login(); |
135 | if (!m_imap) { | 145 | if (!m_imap) { |
136 | return; | 146 | return; |
137 | } | 147 | } |
138 | /* select mailbox READONLY for operations */ | 148 | /* select mailbox READONLY for operations */ |
139 | err = selectMbox(mailbox); | 149 | err = selectMbox(mailbox); |
140 | if ( err != MAILIMAP_NO_ERROR ) { | 150 | if ( err != MAILIMAP_NO_ERROR ) { |
141 | return; | 151 | return; |
142 | } | 152 | } |
143 | 153 | ||
144 | int last = m_imap->imap_selection_info->sel_exists; | 154 | int last = m_imap->imap_selection_info->sel_exists; |
145 | 155 | ||
146 | if (last == 0) { | 156 | if (last == 0) { |
147 | Global::statusMessage(tr("Mailbox has no mails")); | 157 | Global::statusMessage(tr("Mailbox has no mails")); |
148 | return; | 158 | return; |
149 | } else { | 159 | } else { |
150 | Global::statusMessage(tr("Mailbox has %1 mails").arg(last)); | 160 | Global::statusMessage(tr("Mailbox has %1 mails").arg(last)); |
151 | } | 161 | } |
152 | 162 | ||
153 | /* the range has to start at 1!!! not with 0!!!! */ | 163 | /* the range has to start at 1!!! not with 0!!!! */ |
154 | set = mailimap_set_new_interval( 1, last ); | 164 | set = mailimap_set_new_interval( 1, last ); |
155 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 165 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
156 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 166 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
157 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 167 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
158 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 168 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
159 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 169 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
160 | 170 | ||
161 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 171 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
162 | mailimap_set_free( set ); | 172 | mailimap_set_free( set ); |
163 | mailimap_fetch_type_free( fetchType ); | 173 | mailimap_fetch_type_free( fetchType ); |
164 | 174 | ||
165 | QString date,subject,from; | 175 | QString date,subject,from; |
166 | 176 | ||
167 | if ( err == MAILIMAP_NO_ERROR ) { | 177 | if ( err == MAILIMAP_NO_ERROR ) { |
168 | mailimap_msg_att * msg_att; | 178 | mailimap_msg_att * msg_att; |
169 | int i = 0; | 179 | int i = 0; |
170 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 180 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
171 | ++i; | 181 | ++i; |
172 | msg_att = (mailimap_msg_att*)current->data; | 182 | msg_att = (mailimap_msg_att*)current->data; |
173 | RecMail*m = parse_list_result(msg_att); | 183 | RecMail*m = parse_list_result(msg_att); |
174 | if (m) { | 184 | if (m) { |
175 | m->setNumber(i); | 185 | m->setNumber(i); |
176 | m->setMbox(mailbox); | 186 | m->setMbox(mailbox); |
177 | m->setWrapper(this); | 187 | m->setWrapper(this); |
178 | target.append(m); | 188 | target.append(m); |
179 | } | 189 | } |
180 | } | 190 | } |
181 | } else { | 191 | } else { |
182 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 192 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
183 | } | 193 | } |
184 | if (result) mailimap_fetch_list_free(result); | 194 | if (result) mailimap_fetch_list_free(result); |
185 | } | 195 | } |
186 | 196 | ||
187 | QList<Folder>* IMAPwrapper::listFolders() | 197 | QList<Folder>* IMAPwrapper::listFolders() |
188 | { | 198 | { |
189 | const char *path, *mask; | 199 | const char *path, *mask; |
190 | int err = MAILIMAP_NO_ERROR; | 200 | int err = MAILIMAP_NO_ERROR; |
191 | clist *result = 0; | 201 | clist *result = 0; |
192 | clistcell *current = 0; | 202 | clistcell *current = 0; |
193 | clistcell*cur_flag = 0; | 203 | clistcell*cur_flag = 0; |
194 | mailimap_mbx_list_flags*bflags = 0; | 204 | mailimap_mbx_list_flags*bflags = 0; |
195 | 205 | ||
196 | QList<Folder> * folders = new QList<Folder>(); | 206 | QList<Folder> * folders = new QList<Folder>(); |
197 | folders->setAutoDelete( false ); | 207 | folders->setAutoDelete( false ); |
198 | login(); | 208 | login(); |
199 | if (!m_imap) { | 209 | if (!m_imap) { |
200 | return folders; | 210 | return folders; |
201 | } | 211 | } |
202 | 212 | ||
203 | /* | 213 | /* |
204 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 214 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
205 | * We must not forget to filter them out in next loop! | 215 | * We must not forget to filter them out in next loop! |
206 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 216 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
207 | */ | 217 | */ |
208 | QString temp; | 218 | QString temp; |
209 | mask = "INBOX" ; | 219 | mask = "INBOX" ; |
210 | mailimap_mailbox_list *list; | 220 | mailimap_mailbox_list *list; |
211 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 221 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
212 | QString del; | 222 | QString del; |
@@ -244,568 +254,568 @@ QList<Folder>* IMAPwrapper::listFolders() | |||
244 | path = account->getPrefix().latin1(); | 254 | path = account->getPrefix().latin1(); |
245 | if (!path) path = ""; | 255 | if (!path) path = ""; |
246 | qDebug(path); | 256 | qDebug(path); |
247 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 257 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
248 | if ( err == MAILIMAP_NO_ERROR ) { | 258 | if ( err == MAILIMAP_NO_ERROR ) { |
249 | current = result->first; | 259 | current = result->first; |
250 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 260 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
251 | no_inferiors = false; | 261 | no_inferiors = false; |
252 | list = (mailimap_mailbox_list *) current->data; | 262 | list = (mailimap_mailbox_list *) current->data; |
253 | // it is better use the deep copy mechanism of qt itself | 263 | // it is better use the deep copy mechanism of qt itself |
254 | // instead of using strdup! | 264 | // instead of using strdup! |
255 | temp = list->mb_name; | 265 | temp = list->mb_name; |
256 | if (temp.lower()=="inbox") | 266 | if (temp.lower()=="inbox") |
257 | continue; | 267 | continue; |
258 | if (temp.lower()==account->getPrefix().lower()) | 268 | if (temp.lower()==account->getPrefix().lower()) |
259 | continue; | 269 | continue; |
260 | if ( (bflags = list->mb_flag) ) { | 270 | if ( (bflags = list->mb_flag) ) { |
261 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 271 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
262 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 272 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
263 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 273 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
264 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 274 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
265 | no_inferiors = true; | 275 | no_inferiors = true; |
266 | } | 276 | } |
267 | } | 277 | } |
268 | } | 278 | } |
269 | del = list->mb_delimiter; | 279 | del = list->mb_delimiter; |
270 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 280 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
271 | } | 281 | } |
272 | } else { | 282 | } else { |
273 | qDebug("error fetching folders %s",m_imap->imap_response); | 283 | qDebug("error fetching folders %s",m_imap->imap_response); |
274 | } | 284 | } |
275 | if (result) mailimap_list_result_free( result ); | 285 | if (result) mailimap_list_result_free( result ); |
276 | return folders; | 286 | return folders; |
277 | } | 287 | } |
278 | 288 | ||
279 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 289 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
280 | { | 290 | { |
281 | RecMail * m = 0; | 291 | RecMail * m = 0; |
282 | mailimap_msg_att_item *item=0; | 292 | mailimap_msg_att_item *item=0; |
283 | clistcell *current,*c,*cf; | 293 | clistcell *current,*c,*cf; |
284 | mailimap_msg_att_dynamic*flist; | 294 | mailimap_msg_att_dynamic*flist; |
285 | mailimap_flag_fetch*cflag; | 295 | mailimap_flag_fetch*cflag; |
286 | int size; | 296 | int size; |
287 | QBitArray mFlags(7); | 297 | QBitArray mFlags(7); |
288 | QStringList addresslist; | 298 | QStringList addresslist; |
289 | 299 | ||
290 | if (!m_att) { | 300 | if (!m_att) { |
291 | return m; | 301 | return m; |
292 | } | 302 | } |
293 | m = new RecMail(); | 303 | m = new RecMail(); |
294 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 304 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
295 | current = c; | 305 | current = c; |
296 | size = 0; | 306 | size = 0; |
297 | item = (mailimap_msg_att_item*)current->data; | 307 | item = (mailimap_msg_att_item*)current->data; |
298 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 308 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
299 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 309 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
300 | if (!flist->att_list) { | 310 | if (!flist->att_list) { |
301 | continue; | 311 | continue; |
302 | } | 312 | } |
303 | cf = flist->att_list->first; | 313 | cf = flist->att_list->first; |
304 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 314 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
305 | cflag = (mailimap_flag_fetch*)cf->data; | 315 | cflag = (mailimap_flag_fetch*)cf->data; |
306 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 316 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
307 | switch (cflag->fl_flag->fl_type) { | 317 | switch (cflag->fl_flag->fl_type) { |
308 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 318 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
309 | mFlags.setBit(FLAG_ANSWERED); | 319 | mFlags.setBit(FLAG_ANSWERED); |
310 | break; | 320 | break; |
311 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 321 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
312 | mFlags.setBit(FLAG_FLAGGED); | 322 | mFlags.setBit(FLAG_FLAGGED); |
313 | break; | 323 | break; |
314 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 324 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
315 | mFlags.setBit(FLAG_DELETED); | 325 | mFlags.setBit(FLAG_DELETED); |
316 | break; | 326 | break; |
317 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 327 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
318 | mFlags.setBit(FLAG_SEEN); | 328 | mFlags.setBit(FLAG_SEEN); |
319 | break; | 329 | break; |
320 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 330 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
321 | mFlags.setBit(FLAG_DRAFT); | 331 | mFlags.setBit(FLAG_DRAFT); |
322 | break; | 332 | break; |
323 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 333 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
324 | break; | 334 | break; |
325 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 335 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
326 | break; | 336 | break; |
327 | default: | 337 | default: |
328 | break; | 338 | break; |
329 | } | 339 | } |
330 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 340 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
331 | mFlags.setBit(FLAG_RECENT); | 341 | mFlags.setBit(FLAG_RECENT); |
332 | } | 342 | } |
333 | } | 343 | } |
334 | continue; | 344 | continue; |
335 | } | 345 | } |
336 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 346 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
337 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 347 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
338 | m->setDate(head->env_date); | 348 | m->setDate(head->env_date); |
339 | m->setSubject(convert_String((const char*)head->env_subject)); | 349 | m->setSubject(convert_String((const char*)head->env_subject)); |
340 | //m->setSubject(head->env_subject); | 350 | //m->setSubject(head->env_subject); |
341 | if (head->env_from!=NULL) { | 351 | if (head->env_from!=NULL) { |
342 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 352 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
343 | if (addresslist.count()) { | 353 | if (addresslist.count()) { |
344 | m->setFrom(addresslist.first()); | 354 | m->setFrom(addresslist.first()); |
345 | } | 355 | } |
346 | } | 356 | } |
347 | if (head->env_to!=NULL) { | 357 | if (head->env_to!=NULL) { |
348 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 358 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
349 | m->setTo(addresslist); | 359 | m->setTo(addresslist); |
350 | } | 360 | } |
351 | if (head->env_cc!=NULL) { | 361 | if (head->env_cc!=NULL) { |
352 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 362 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
353 | m->setCC(addresslist); | 363 | m->setCC(addresslist); |
354 | } | 364 | } |
355 | if (head->env_bcc!=NULL) { | 365 | if (head->env_bcc!=NULL) { |
356 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 366 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
357 | m->setBcc(addresslist); | 367 | m->setBcc(addresslist); |
358 | } | 368 | } |
359 | if (head->env_reply_to!=NULL) { | 369 | if (head->env_reply_to!=NULL) { |
360 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 370 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
361 | if (addresslist.count()) { | 371 | if (addresslist.count()) { |
362 | m->setReplyto(addresslist.first()); | 372 | m->setReplyto(addresslist.first()); |
363 | } | 373 | } |
364 | } | 374 | } |
365 | m->setMsgid(QString(head->env_message_id)); | 375 | m->setMsgid(QString(head->env_message_id)); |
366 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 376 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
367 | #if 0 | 377 | #if 0 |
368 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 378 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
369 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 379 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
370 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 380 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
371 | qDebug(da.toString()); | 381 | qDebug(da.toString()); |
372 | #endif | 382 | #endif |
373 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 383 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
374 | size = item->att_data.att_static->att_data.att_rfc822_size; | 384 | size = item->att_data.att_static->att_data.att_rfc822_size; |
375 | } | 385 | } |
376 | } | 386 | } |
377 | /* msg is already deleted */ | 387 | /* msg is already deleted */ |
378 | if (mFlags.testBit(FLAG_DELETED) && m) { | 388 | if (mFlags.testBit(FLAG_DELETED) && m) { |
379 | delete m; | 389 | delete m; |
380 | m = 0; | 390 | m = 0; |
381 | } | 391 | } |
382 | if (m) { | 392 | if (m) { |
383 | m->setFlags(mFlags); | 393 | m->setFlags(mFlags); |
384 | m->setMsgsize(size); | 394 | m->setMsgsize(size); |
385 | } | 395 | } |
386 | return m; | 396 | return m; |
387 | } | 397 | } |
388 | 398 | ||
389 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 399 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
390 | { | 400 | { |
391 | RecBody body; | 401 | RecBody body; |
392 | const char *mb; | 402 | const char *mb; |
393 | int err = MAILIMAP_NO_ERROR; | 403 | int err = MAILIMAP_NO_ERROR; |
394 | clist *result = 0; | 404 | clist *result = 0; |
395 | clistcell *current; | 405 | clistcell *current; |
396 | mailimap_fetch_att *fetchAtt = 0; | 406 | mailimap_fetch_att *fetchAtt = 0; |
397 | mailimap_fetch_type *fetchType = 0; | 407 | mailimap_fetch_type *fetchType = 0; |
398 | mailimap_set *set = 0; | 408 | mailimap_set *set = 0; |
399 | mailimap_body*body_desc = 0; | 409 | mailimap_body*body_desc = 0; |
400 | 410 | ||
401 | mb = mail.getMbox().latin1(); | 411 | mb = mail.getMbox().latin1(); |
402 | 412 | ||
403 | login(); | 413 | login(); |
404 | if (!m_imap) { | 414 | if (!m_imap) { |
405 | return body; | 415 | return body; |
406 | } | 416 | } |
407 | err = selectMbox(mail.getMbox()); | 417 | err = selectMbox(mail.getMbox()); |
408 | if ( err != MAILIMAP_NO_ERROR ) { | 418 | if ( err != MAILIMAP_NO_ERROR ) { |
409 | return body; | 419 | return body; |
410 | } | 420 | } |
411 | 421 | ||
412 | /* the range has to start at 1!!! not with 0!!!! */ | 422 | /* the range has to start at 1!!! not with 0!!!! */ |
413 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 423 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
414 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 424 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
415 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 425 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
416 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 426 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
417 | mailimap_set_free( set ); | 427 | mailimap_set_free( set ); |
418 | mailimap_fetch_type_free( fetchType ); | 428 | mailimap_fetch_type_free( fetchType ); |
419 | 429 | ||
420 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 430 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
421 | mailimap_msg_att * msg_att; | 431 | mailimap_msg_att * msg_att; |
422 | msg_att = (mailimap_msg_att*)current->data; | 432 | msg_att = (mailimap_msg_att*)current->data; |
423 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 433 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
424 | QValueList<int> path; | 434 | QValueList<int> path; |
425 | body_desc = item->att_data.att_static->att_data.att_body; | 435 | body_desc = item->att_data.att_static->att_data.att_body; |
426 | traverseBody(mail,body_desc,body,0,path); | 436 | traverseBody(mail,body_desc,body,0,path); |
427 | } else { | 437 | } else { |
428 | qDebug("error fetching body: %s",m_imap->imap_response); | 438 | qDebug("error fetching body: %s",m_imap->imap_response); |
429 | } | 439 | } |
430 | if (result) mailimap_fetch_list_free(result); | 440 | if (result) mailimap_fetch_list_free(result); |
431 | return body; | 441 | return body; |
432 | } | 442 | } |
433 | 443 | ||
434 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 444 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
435 | { | 445 | { |
436 | QStringList l; | 446 | QStringList l; |
437 | QString from; | 447 | QString from; |
438 | bool named_from; | 448 | bool named_from; |
439 | clistcell *current = NULL; | 449 | clistcell *current = NULL; |
440 | mailimap_address * current_address=NULL; | 450 | mailimap_address * current_address=NULL; |
441 | if (!list) { | 451 | if (!list) { |
442 | return l; | 452 | return l; |
443 | } | 453 | } |
444 | unsigned int count = 0; | 454 | unsigned int count = 0; |
445 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 455 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
446 | from = ""; | 456 | from = ""; |
447 | named_from = false; | 457 | named_from = false; |
448 | current_address=(mailimap_address*)current->data; | 458 | current_address=(mailimap_address*)current->data; |
449 | if (current_address->ad_personal_name){ | 459 | if (current_address->ad_personal_name){ |
450 | from+=convert_String((const char*)current_address->ad_personal_name); | 460 | from+=convert_String((const char*)current_address->ad_personal_name); |
451 | from+=" "; | 461 | from+=" "; |
452 | named_from = true; | 462 | named_from = true; |
453 | } | 463 | } |
454 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 464 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
455 | from+="<"; | 465 | from+="<"; |
456 | } | 466 | } |
457 | if (current_address->ad_mailbox_name) { | 467 | if (current_address->ad_mailbox_name) { |
458 | from+=QString(current_address->ad_mailbox_name); | 468 | from+=QString(current_address->ad_mailbox_name); |
459 | from+="@"; | 469 | from+="@"; |
460 | } | 470 | } |
461 | if (current_address->ad_host_name) { | 471 | if (current_address->ad_host_name) { |
462 | from+=QString(current_address->ad_host_name); | 472 | from+=QString(current_address->ad_host_name); |
463 | } | 473 | } |
464 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 474 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
465 | from+=">"; | 475 | from+=">"; |
466 | } | 476 | } |
467 | l.append(QString(from)); | 477 | l.append(QString(from)); |
468 | if (++count > 99) { | 478 | if (++count > 99) { |
469 | break; | 479 | break; |
470 | } | 480 | } |
471 | } | 481 | } |
472 | return l; | 482 | return l; |
473 | } | 483 | } |
474 | 484 | ||
475 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 485 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
476 | { | 486 | { |
477 | encodedString*res=new encodedString; | 487 | encodedString*res=new encodedString; |
478 | int err; | 488 | int err; |
479 | mailimap_fetch_type *fetchType; | 489 | mailimap_fetch_type *fetchType; |
480 | mailimap_set *set; | 490 | mailimap_set *set; |
481 | clistcell*current,*cur; | 491 | clistcell*current,*cur; |
482 | mailimap_section_part * section_part = 0; | 492 | mailimap_section_part * section_part = 0; |
483 | mailimap_section_spec * section_spec = 0; | 493 | mailimap_section_spec * section_spec = 0; |
484 | mailimap_section * section = 0; | 494 | mailimap_section * section = 0; |
485 | mailimap_fetch_att * fetch_att = 0; | 495 | mailimap_fetch_att * fetch_att = 0; |
486 | 496 | ||
487 | login(); | 497 | login(); |
488 | if (!m_imap) { | 498 | if (!m_imap) { |
489 | return res; | 499 | return res; |
490 | } | 500 | } |
491 | if (!internal_call) { | 501 | if (!internal_call) { |
492 | err = selectMbox(mail.getMbox()); | 502 | err = selectMbox(mail.getMbox()); |
493 | if ( err != MAILIMAP_NO_ERROR ) { | 503 | if ( err != MAILIMAP_NO_ERROR ) { |
494 | return res; | 504 | return res; |
495 | } | 505 | } |
496 | } | 506 | } |
497 | set = mailimap_set_new_single(mail.getNumber()); | 507 | set = mailimap_set_new_single(mail.getNumber()); |
498 | 508 | ||
499 | clist*id_list = 0; | 509 | clist*id_list = 0; |
500 | 510 | ||
501 | /* if path == empty then its a request for the whole rfc822 mail and generates | 511 | /* if path == empty then its a request for the whole rfc822 mail and generates |
502 | a "fetch <id> (body[])" statement on imap server */ | 512 | a "fetch <id> (body[])" statement on imap server */ |
503 | if (path.count()>0 ) { | 513 | if (path.count()>0 ) { |
504 | id_list = clist_new(); | 514 | id_list = clist_new(); |
505 | for (unsigned j=0; j < path.count();++j) { | 515 | for (unsigned j=0; j < path.count();++j) { |
506 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 516 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
507 | *p_id = path[j]; | 517 | *p_id = path[j]; |
508 | clist_append(id_list,p_id); | 518 | clist_append(id_list,p_id); |
509 | } | 519 | } |
510 | section_part = mailimap_section_part_new(id_list); | 520 | section_part = mailimap_section_part_new(id_list); |
511 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 521 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
512 | } | 522 | } |
513 | 523 | ||
514 | section = mailimap_section_new(section_spec); | 524 | section = mailimap_section_new(section_spec); |
515 | fetch_att = mailimap_fetch_att_new_body_section(section); | 525 | fetch_att = mailimap_fetch_att_new_body_section(section); |
516 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 526 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
517 | 527 | ||
518 | clist*result = 0; | 528 | clist*result = 0; |
519 | 529 | ||
520 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 530 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
521 | mailimap_set_free( set ); | 531 | mailimap_set_free( set ); |
522 | mailimap_fetch_type_free( fetchType ); | 532 | mailimap_fetch_type_free( fetchType ); |
523 | 533 | ||
524 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 534 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
525 | mailimap_msg_att * msg_att; | 535 | mailimap_msg_att * msg_att; |
526 | msg_att = (mailimap_msg_att*)current->data; | 536 | msg_att = (mailimap_msg_att*)current->data; |
527 | mailimap_msg_att_item*msg_att_item; | 537 | mailimap_msg_att_item*msg_att_item; |
528 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 538 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
529 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 539 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
530 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 540 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
531 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 541 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
532 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 542 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
533 | /* detach - we take over the content */ | 543 | /* detach - we take over the content */ |
534 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 544 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
535 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 545 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
536 | } | 546 | } |
537 | } | 547 | } |
538 | } | 548 | } |
539 | } else { | 549 | } else { |
540 | qDebug("error fetching text: %s",m_imap->imap_response); | 550 | qDebug("error fetching text: %s",m_imap->imap_response); |
541 | } | 551 | } |
542 | if (result) mailimap_fetch_list_free(result); | 552 | if (result) mailimap_fetch_list_free(result); |
543 | return res; | 553 | return res; |
544 | } | 554 | } |
545 | 555 | ||
546 | /* current_recursion is for recursive calls. | 556 | /* current_recursion is for recursive calls. |
547 | current_count means the position inside the internal loop! */ | 557 | current_count means the position inside the internal loop! */ |
548 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, | 558 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, |
549 | int current_recursion,QValueList<int>recList,int current_count) | 559 | int current_recursion,QValueList<int>recList,int current_count) |
550 | { | 560 | { |
551 | if (!body || current_recursion>=10) { | 561 | if (!body || current_recursion>=10) { |
552 | return; | 562 | return; |
553 | } | 563 | } |
554 | switch (body->bd_type) { | 564 | switch (body->bd_type) { |
555 | case MAILIMAP_BODY_1PART: | 565 | case MAILIMAP_BODY_1PART: |
556 | { | 566 | { |
557 | QValueList<int>countlist = recList; | 567 | QValueList<int>countlist = recList; |
558 | countlist.append(current_count); | 568 | countlist.append(current_count); |
559 | RecPart currentPart; | 569 | RecPart currentPart; |
560 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 570 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
561 | QString id(""); | 571 | QString id(""); |
562 | currentPart.setPositionlist(countlist); | 572 | currentPart.setPositionlist(countlist); |
563 | for (unsigned int j = 0; j < countlist.count();++j) { | 573 | for (unsigned int j = 0; j < countlist.count();++j) { |
564 | id+=(j>0?" ":""); | 574 | id+=(j>0?" ":""); |
565 | id+=QString("%1").arg(countlist[j]); | 575 | id+=QString("%1").arg(countlist[j]); |
566 | } | 576 | } |
567 | qDebug("ID = %s",id.latin1()); | 577 | qDebug("ID = %s",id.latin1()); |
568 | currentPart.setIdentifier(id); | 578 | currentPart.setIdentifier(id); |
569 | fillSinglePart(currentPart,part1); | 579 | fillSinglePart(currentPart,part1); |
570 | /* important: Check for is NULL 'cause a body can be empty! | 580 | /* important: Check for is NULL 'cause a body can be empty! |
571 | And we put it only into the mail if it is the FIRST part */ | 581 | And we put it only into the mail if it is the FIRST part */ |
572 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { | 582 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { |
573 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); | 583 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); |
574 | target_body.setDescription(currentPart); | 584 | target_body.setDescription(currentPart); |
575 | target_body.setBodytext(body_text); | 585 | target_body.setBodytext(body_text); |
576 | if (countlist.count()>1) { | 586 | if (countlist.count()>1) { |
577 | target_body.addPart(currentPart); | 587 | target_body.addPart(currentPart); |
578 | } | 588 | } |
579 | } else { | 589 | } else { |
580 | target_body.addPart(currentPart); | 590 | target_body.addPart(currentPart); |
581 | } | 591 | } |
582 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 592 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
583 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 593 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
584 | } | 594 | } |
585 | } | 595 | } |
586 | break; | 596 | break; |
587 | case MAILIMAP_BODY_MPART: | 597 | case MAILIMAP_BODY_MPART: |
588 | { | 598 | { |
589 | QValueList<int>countlist = recList; | 599 | QValueList<int>countlist = recList; |
590 | clistcell*current=0; | 600 | clistcell*current=0; |
591 | mailimap_body*current_body=0; | 601 | mailimap_body*current_body=0; |
592 | unsigned int ccount = 1; | 602 | unsigned int ccount = 1; |
593 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 603 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
594 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 604 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
595 | current_body = (mailimap_body*)current->data; | 605 | current_body = (mailimap_body*)current->data; |
596 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 606 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
597 | RecPart targetPart; | 607 | RecPart targetPart; |
598 | targetPart.setType("multipart"); | 608 | targetPart.setType("multipart"); |
599 | fillMultiPart(targetPart,mailDescription); | 609 | fillMultiPart(targetPart,mailDescription); |
600 | countlist.append(current_count); | 610 | countlist.append(current_count); |
601 | targetPart.setPositionlist(countlist); | 611 | targetPart.setPositionlist(countlist); |
602 | target_body.addPart(targetPart); | 612 | target_body.addPart(targetPart); |
603 | QString id(""); | 613 | QString id(""); |
604 | for (unsigned int j = 0; j < countlist.count();++j) { | 614 | for (unsigned int j = 0; j < countlist.count();++j) { |
605 | id+=(j>0?" ":""); | 615 | id+=(j>0?" ":""); |
606 | id+=QString("%1").arg(countlist[j]); | 616 | id+=QString("%1").arg(countlist[j]); |
607 | } | 617 | } |
608 | qDebug("ID(mpart) = %s",id.latin1()); | 618 | qDebug("ID(mpart) = %s",id.latin1()); |
609 | } | 619 | } |
610 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 620 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
611 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 621 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
612 | countlist = recList; | 622 | countlist = recList; |
613 | } | 623 | } |
614 | ++ccount; | 624 | ++ccount; |
615 | } | 625 | } |
616 | } | 626 | } |
617 | break; | 627 | break; |
618 | default: | 628 | default: |
619 | break; | 629 | break; |
620 | } | 630 | } |
621 | } | 631 | } |
622 | 632 | ||
623 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 633 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) |
624 | { | 634 | { |
625 | if (!Description) { | 635 | if (!Description) { |
626 | return; | 636 | return; |
627 | } | 637 | } |
628 | switch (Description->bd_type) { | 638 | switch (Description->bd_type) { |
629 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 639 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
630 | target_part.setType("text"); | 640 | target_part.setType("text"); |
631 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 641 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
632 | break; | 642 | break; |
633 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 643 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
634 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 644 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
635 | break; | 645 | break; |
636 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 646 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
637 | target_part.setType("message"); | 647 | target_part.setType("message"); |
638 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 648 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
639 | break; | 649 | break; |
640 | default: | 650 | default: |
641 | break; | 651 | break; |
642 | } | 652 | } |
643 | } | 653 | } |
644 | 654 | ||
645 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 655 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
646 | { | 656 | { |
647 | if (!which) { | 657 | if (!which) { |
648 | return; | 658 | return; |
649 | } | 659 | } |
650 | QString sub; | 660 | QString sub; |
651 | sub = which->bd_media_text; | 661 | sub = which->bd_media_text; |
652 | qDebug("Type= text/%s",which->bd_media_text); | 662 | qDebug("Type= text/%s",which->bd_media_text); |
653 | target_part.setSubtype(sub.lower()); | 663 | target_part.setSubtype(sub.lower()); |
654 | target_part.setLines(which->bd_lines); | 664 | target_part.setLines(which->bd_lines); |
655 | fillBodyFields(target_part,which->bd_fields); | 665 | fillBodyFields(target_part,which->bd_fields); |
656 | } | 666 | } |
657 | 667 | ||
658 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | 668 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) |
659 | { | 669 | { |
660 | if (!which) { | 670 | if (!which) { |
661 | return; | 671 | return; |
662 | } | 672 | } |
663 | target_part.setSubtype("rfc822"); | 673 | target_part.setSubtype("rfc822"); |
664 | qDebug("Message part"); | 674 | qDebug("Message part"); |
665 | /* we set this type to text/plain */ | 675 | /* we set this type to text/plain */ |
666 | target_part.setLines(which->bd_lines); | 676 | target_part.setLines(which->bd_lines); |
667 | fillBodyFields(target_part,which->bd_fields); | 677 | fillBodyFields(target_part,which->bd_fields); |
668 | } | 678 | } |
669 | 679 | ||
670 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) | 680 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) |
671 | { | 681 | { |
672 | if (!which) return; | 682 | if (!which) return; |
673 | QString sub = which->bd_media_subtype; | 683 | QString sub = which->bd_media_subtype; |
674 | target_part.setSubtype(sub.lower()); | 684 | target_part.setSubtype(sub.lower()); |
675 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 685 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
676 | clistcell*cur = 0; | 686 | clistcell*cur = 0; |
677 | mailimap_single_body_fld_param*param=0; | 687 | mailimap_single_body_fld_param*param=0; |
678 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 688 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
679 | param = (mailimap_single_body_fld_param*)cur->data; | 689 | param = (mailimap_single_body_fld_param*)cur->data; |
680 | if (param) { | 690 | if (param) { |
681 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 691 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
682 | } | 692 | } |
683 | } | 693 | } |
684 | } | 694 | } |
685 | } | 695 | } |
686 | 696 | ||
687 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 697 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
688 | { | 698 | { |
689 | if (!which) { | 699 | if (!which) { |
690 | return; | 700 | return; |
691 | } | 701 | } |
692 | QString type,sub; | 702 | QString type,sub; |
693 | switch (which->bd_media_basic->med_type) { | 703 | switch (which->bd_media_basic->med_type) { |
694 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 704 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
695 | type = "application"; | 705 | type = "application"; |
696 | break; | 706 | break; |
697 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 707 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
698 | type = "audio"; | 708 | type = "audio"; |
699 | break; | 709 | break; |
700 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 710 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
701 | type = "image"; | 711 | type = "image"; |
702 | break; | 712 | break; |
703 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 713 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
704 | type = "message"; | 714 | type = "message"; |
705 | break; | 715 | break; |
706 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 716 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
707 | type = "video"; | 717 | type = "video"; |
708 | break; | 718 | break; |
709 | case MAILIMAP_MEDIA_BASIC_OTHER: | 719 | case MAILIMAP_MEDIA_BASIC_OTHER: |
710 | default: | 720 | default: |
711 | if (which->bd_media_basic->med_basic_type) { | 721 | if (which->bd_media_basic->med_basic_type) { |
712 | type = which->bd_media_basic->med_basic_type; | 722 | type = which->bd_media_basic->med_basic_type; |
713 | } else { | 723 | } else { |
714 | type = ""; | 724 | type = ""; |
715 | } | 725 | } |
716 | break; | 726 | break; |
717 | } | 727 | } |
718 | if (which->bd_media_basic->med_subtype) { | 728 | if (which->bd_media_basic->med_subtype) { |
719 | sub = which->bd_media_basic->med_subtype; | 729 | sub = which->bd_media_basic->med_subtype; |
720 | } else { | 730 | } else { |
721 | sub = ""; | 731 | sub = ""; |
722 | } | 732 | } |
723 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); | 733 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); |
724 | target_part.setType(type.lower()); | 734 | target_part.setType(type.lower()); |
725 | target_part.setSubtype(sub.lower()); | 735 | target_part.setSubtype(sub.lower()); |
726 | fillBodyFields(target_part,which->bd_fields); | 736 | fillBodyFields(target_part,which->bd_fields); |
727 | } | 737 | } |
728 | 738 | ||
729 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | 739 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) |
730 | { | 740 | { |
731 | if (!which) return; | 741 | if (!which) return; |
732 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 742 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
733 | clistcell*cur; | 743 | clistcell*cur; |
734 | mailimap_single_body_fld_param*param=0; | 744 | mailimap_single_body_fld_param*param=0; |
735 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 745 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
736 | param = (mailimap_single_body_fld_param*)cur->data; | 746 | param = (mailimap_single_body_fld_param*)cur->data; |
737 | if (param) { | 747 | if (param) { |
738 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 748 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
739 | } | 749 | } |
740 | } | 750 | } |
741 | } | 751 | } |
742 | mailimap_body_fld_enc*enc = which->bd_encoding; | 752 | mailimap_body_fld_enc*enc = which->bd_encoding; |
743 | QString encoding(""); | 753 | QString encoding(""); |
744 | switch (enc->enc_type) { | 754 | switch (enc->enc_type) { |
745 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 755 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
746 | encoding = "7bit"; | 756 | encoding = "7bit"; |
747 | break; | 757 | break; |
748 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 758 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
749 | encoding = "8bit"; | 759 | encoding = "8bit"; |
750 | break; | 760 | break; |
751 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 761 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
752 | encoding="binary"; | 762 | encoding="binary"; |
753 | break; | 763 | break; |
754 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 764 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
755 | encoding="base64"; | 765 | encoding="base64"; |
756 | break; | 766 | break; |
757 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 767 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
758 | encoding="quoted-printable"; | 768 | encoding="quoted-printable"; |
759 | break; | 769 | break; |
760 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 770 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
761 | default: | 771 | default: |
762 | if (enc->enc_value) { | 772 | if (enc->enc_value) { |
763 | char*t=enc->enc_value; | 773 | char*t=enc->enc_value; |
764 | encoding=QString(enc->enc_value); | 774 | encoding=QString(enc->enc_value); |
765 | enc->enc_value=0L; | 775 | enc->enc_value=0L; |
766 | free(t); | 776 | free(t); |
767 | } | 777 | } |
768 | } | 778 | } |
769 | if (which->bd_description) { | 779 | if (which->bd_description) { |
770 | target_part.setDescription(QString(which->bd_description)); | 780 | target_part.setDescription(QString(which->bd_description)); |
771 | } | 781 | } |
772 | target_part.setEncoding(encoding); | 782 | target_part.setEncoding(encoding); |
773 | target_part.setSize(which->bd_size); | 783 | target_part.setSize(which->bd_size); |
774 | } | 784 | } |
775 | 785 | ||
776 | void IMAPwrapper::deleteMail(const RecMail&mail) | 786 | void IMAPwrapper::deleteMail(const RecMail&mail) |
777 | { | 787 | { |
778 | mailimap_flag_list*flist; | 788 | mailimap_flag_list*flist; |
779 | mailimap_set *set; | 789 | mailimap_set *set; |
780 | mailimap_store_att_flags * store_flags; | 790 | mailimap_store_att_flags * store_flags; |
781 | int err; | 791 | int err; |
782 | login(); | 792 | login(); |
783 | if (!m_imap) { | 793 | if (!m_imap) { |
784 | return; | 794 | return; |
785 | } | 795 | } |
786 | err = selectMbox(mail.getMbox()); | 796 | err = selectMbox(mail.getMbox()); |
787 | if ( err != MAILIMAP_NO_ERROR ) { | 797 | if ( err != MAILIMAP_NO_ERROR ) { |
788 | return; | 798 | return; |
789 | } | 799 | } |
790 | flist = mailimap_flag_list_new_empty(); | 800 | flist = mailimap_flag_list_new_empty(); |
791 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 801 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
792 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 802 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
793 | set = mailimap_set_new_single(mail.getNumber()); | 803 | set = mailimap_set_new_single(mail.getNumber()); |
794 | err = mailimap_store(m_imap,set,store_flags); | 804 | err = mailimap_store(m_imap,set,store_flags); |
795 | mailimap_set_free( set ); | 805 | mailimap_set_free( set ); |
796 | mailimap_store_att_flags_free(store_flags); | 806 | mailimap_store_att_flags_free(store_flags); |
797 | 807 | ||
798 | if (err != MAILIMAP_NO_ERROR) { | 808 | if (err != MAILIMAP_NO_ERROR) { |
799 | qDebug("error deleting mail: %s",m_imap->imap_response); | 809 | qDebug("error deleting mail: %s",m_imap->imap_response); |
800 | return; | 810 | return; |
801 | } | 811 | } |
802 | qDebug("deleting mail: %s",m_imap->imap_response); | 812 | qDebug("deleting mail: %s",m_imap->imap_response); |
803 | /* should we realy do that at this moment? */ | 813 | /* should we realy do that at this moment? */ |
804 | err = mailimap_expunge(m_imap); | 814 | err = mailimap_expunge(m_imap); |
805 | if (err != MAILIMAP_NO_ERROR) { | 815 | if (err != MAILIMAP_NO_ERROR) { |
806 | qDebug("error deleting mail: %s",m_imap->imap_response); | 816 | qDebug("error deleting mail: %s",m_imap->imap_response); |
807 | } | 817 | } |
808 | qDebug("Delete successfull %s",m_imap->imap_response); | 818 | qDebug("Delete successfull %s",m_imap->imap_response); |
809 | } | 819 | } |
810 | 820 | ||
811 | void IMAPwrapper::answeredMail(const RecMail&mail) | 821 | void IMAPwrapper::answeredMail(const RecMail&mail) |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 7b6a58d..3279f39 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -39,278 +39,280 @@ void Settings::addAccount( Account *account ) | |||
39 | { | 39 | { |
40 | accounts.append( account ); | 40 | accounts.append( account ); |
41 | } | 41 | } |
42 | 42 | ||
43 | void Settings::delAccount( Account *account ) | 43 | void Settings::delAccount( Account *account ) |
44 | { | 44 | { |
45 | accounts.remove( account ); | 45 | accounts.remove( account ); |
46 | account->remove(); | 46 | account->remove(); |
47 | } | 47 | } |
48 | 48 | ||
49 | void Settings::updateAccounts() | 49 | void Settings::updateAccounts() |
50 | { | 50 | { |
51 | accounts.clear(); | 51 | accounts.clear(); |
52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
53 | QStringList::Iterator it; | 53 | QStringList::Iterator it; |
54 | 54 | ||
55 | QStringList imap = dir.entryList( "imap-*" ); | 55 | QStringList imap = dir.entryList( "imap-*" ); |
56 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 56 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
57 | qDebug( "Added IMAP account" ); | 57 | qDebug( "Added IMAP account" ); |
58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
59 | accounts.append( account ); | 59 | accounts.append( account ); |
60 | } | 60 | } |
61 | 61 | ||
62 | QStringList pop3 = dir.entryList( "pop3-*" ); | 62 | QStringList pop3 = dir.entryList( "pop3-*" ); |
63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
64 | qDebug( "Added POP account" ); | 64 | qDebug( "Added POP account" ); |
65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
66 | accounts.append( account ); | 66 | accounts.append( account ); |
67 | } | 67 | } |
68 | 68 | ||
69 | QStringList smtp = dir.entryList( "smtp-*" ); | 69 | QStringList smtp = dir.entryList( "smtp-*" ); |
70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
71 | qDebug( "Added SMTP account" ); | 71 | qDebug( "Added SMTP account" ); |
72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
73 | accounts.append( account ); | 73 | accounts.append( account ); |
74 | } | 74 | } |
75 | 75 | ||
76 | QStringList nntp = dir.entryList( "nntp-*" ); | 76 | QStringList nntp = dir.entryList( "nntp-*" ); |
77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
78 | qDebug( "Added NNTP account" ); | 78 | qDebug( "Added NNTP account" ); |
79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
80 | accounts.append( account ); | 80 | accounts.append( account ); |
81 | } | 81 | } |
82 | 82 | ||
83 | readAccounts(); | 83 | readAccounts(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void Settings::saveAccounts() | 86 | void Settings::saveAccounts() |
87 | { | 87 | { |
88 | checkDirectory(); | 88 | checkDirectory(); |
89 | Account *it; | 89 | Account *it; |
90 | 90 | ||
91 | for ( it = accounts.first(); it; it = accounts.next() ) { | 91 | for ( it = accounts.first(); it; it = accounts.next() ) { |
92 | it->save(); | 92 | it->save(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void Settings::readAccounts() | 96 | void Settings::readAccounts() |
97 | { | 97 | { |
98 | checkDirectory(); | 98 | checkDirectory(); |
99 | Account *it; | 99 | Account *it; |
100 | 100 | ||
101 | for ( it = accounts.first(); it; it = accounts.next() ) { | 101 | for ( it = accounts.first(); it; it = accounts.next() ) { |
102 | it->read(); | 102 | it->read(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | Account::Account() | 106 | Account::Account() |
107 | { | 107 | { |
108 | accountName = "changeMe"; | 108 | accountName = "changeMe"; |
109 | type = "changeMe"; | 109 | type = "changeMe"; |
110 | ssl = false; | 110 | ssl = false; |
111 | connectionType = 1; | 111 | connectionType = 1; |
112 | } | 112 | } |
113 | 113 | ||
114 | void Account::remove() | 114 | void Account::remove() |
115 | { | 115 | { |
116 | QFile file( getFileName() ); | 116 | QFile file( getFileName() ); |
117 | file.remove(); | 117 | file.remove(); |
118 | } | 118 | } |
119 | 119 | ||
120 | IMAPaccount::IMAPaccount() | 120 | IMAPaccount::IMAPaccount() |
121 | : Account() | 121 | : Account() |
122 | { | 122 | { |
123 | file = IMAPaccount::getUniqueFileName(); | 123 | file = IMAPaccount::getUniqueFileName(); |
124 | accountName = "New IMAP Account"; | 124 | accountName = "New IMAP Account"; |
125 | ssl = false; | 125 | ssl = false; |
126 | connectionType = 1; | 126 | connectionType = 1; |
127 | type = "IMAP"; | 127 | type = "IMAP"; |
128 | port = IMAP_PORT; | 128 | port = IMAP_PORT; |
129 | } | 129 | } |
130 | 130 | ||
131 | IMAPaccount::IMAPaccount( QString filename ) | 131 | IMAPaccount::IMAPaccount( QString filename ) |
132 | : Account() | 132 | : Account() |
133 | { | 133 | { |
134 | file = filename; | 134 | file = filename; |
135 | accountName = "New IMAP Account"; | 135 | accountName = "New IMAP Account"; |
136 | ssl = false; | 136 | ssl = false; |
137 | connectionType = 1; | 137 | connectionType = 1; |
138 | type = "IMAP"; | 138 | type = "IMAP"; |
139 | port = IMAP_PORT; | 139 | port = IMAP_PORT; |
140 | } | 140 | } |
141 | 141 | ||
142 | QString IMAPaccount::getUniqueFileName() | 142 | QString IMAPaccount::getUniqueFileName() |
143 | { | 143 | { |
144 | int num = 0; | 144 | int num = 0; |
145 | QString unique; | 145 | QString unique; |
146 | 146 | ||
147 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 147 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
148 | 148 | ||
149 | QStringList imap = dir.entryList( "imap-*" ); | 149 | QStringList imap = dir.entryList( "imap-*" ); |
150 | do { | 150 | do { |
151 | unique.setNum( num++ ); | 151 | unique.setNum( num++ ); |
152 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 152 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
153 | 153 | ||
154 | return unique; | 154 | return unique; |
155 | } | 155 | } |
156 | 156 | ||
157 | void IMAPaccount::read() | 157 | void IMAPaccount::read() |
158 | { | 158 | { |
159 | Config *conf = new Config( getFileName(), Config::File ); | 159 | Config *conf = new Config( getFileName(), Config::File ); |
160 | conf->setGroup( "IMAP Account" ); | 160 | conf->setGroup( "IMAP Account" ); |
161 | accountName = conf->readEntry( "Account","" ); | 161 | accountName = conf->readEntry( "Account","" ); |
162 | if (accountName.isNull()) accountName = ""; | 162 | if (accountName.isNull()) accountName = ""; |
163 | server = conf->readEntry( "Server","" ); | 163 | server = conf->readEntry( "Server","" ); |
164 | if (server.isNull()) server=""; | 164 | if (server.isNull()) server=""; |
165 | port = conf->readEntry( "Port","" ); | 165 | port = conf->readEntry( "Port","" ); |
166 | if (port.isNull()) port="143"; | 166 | if (port.isNull()) port="143"; |
167 | connectionType = conf->readNumEntry( "ConnectionType" ); | ||
167 | ssl = conf->readBoolEntry( "SSL",false ); | 168 | ssl = conf->readBoolEntry( "SSL",false ); |
168 | user = conf->readEntry( "User","" ); | 169 | user = conf->readEntry( "User","" ); |
169 | if (user.isNull()) user = ""; | 170 | if (user.isNull()) user = ""; |
170 | password = conf->readEntryCrypt( "Password","" ); | 171 | password = conf->readEntryCrypt( "Password","" ); |
171 | if (password.isNull()) password = ""; | 172 | if (password.isNull()) password = ""; |
172 | prefix = conf->readEntry("MailPrefix",""); | 173 | prefix = conf->readEntry("MailPrefix",""); |
173 | if (prefix.isNull()) prefix = ""; | 174 | if (prefix.isNull()) prefix = ""; |
174 | offline = conf->readBoolEntry("Offline",false); | 175 | offline = conf->readBoolEntry("Offline",false); |
175 | delete conf; | 176 | delete conf; |
176 | } | 177 | } |
177 | 178 | ||
178 | void IMAPaccount::save() | 179 | void IMAPaccount::save() |
179 | { | 180 | { |
180 | qDebug( "saving " + getFileName() ); | 181 | qDebug( "saving " + getFileName() ); |
181 | Settings::checkDirectory(); | 182 | Settings::checkDirectory(); |
182 | 183 | ||
183 | Config *conf = new Config( getFileName(), Config::File ); | 184 | Config *conf = new Config( getFileName(), Config::File ); |
184 | conf->setGroup( "IMAP Account" ); | 185 | conf->setGroup( "IMAP Account" ); |
185 | conf->writeEntry( "Account", accountName ); | 186 | conf->writeEntry( "Account", accountName ); |
186 | conf->writeEntry( "Server", server ); | 187 | conf->writeEntry( "Server", server ); |
187 | conf->writeEntry( "Port", port ); | 188 | conf->writeEntry( "Port", port ); |
188 | conf->writeEntry( "SSL", ssl ); | 189 | conf->writeEntry( "SSL", ssl ); |
190 | conf->writeEntry( "ConnectionType", connectionType ); | ||
189 | conf->writeEntry( "User", user ); | 191 | conf->writeEntry( "User", user ); |
190 | conf->writeEntryCrypt( "Password", password ); | 192 | conf->writeEntryCrypt( "Password", password ); |
191 | conf->writeEntry( "MailPrefix",prefix); | 193 | conf->writeEntry( "MailPrefix",prefix); |
192 | conf->writeEntry( "Offline",offline); | 194 | conf->writeEntry( "Offline",offline); |
193 | conf->write(); | 195 | conf->write(); |
194 | delete conf; | 196 | delete conf; |
195 | } | 197 | } |
196 | 198 | ||
197 | 199 | ||
198 | QString IMAPaccount::getFileName() | 200 | QString IMAPaccount::getFileName() |
199 | { | 201 | { |
200 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 202 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
201 | } | 203 | } |
202 | 204 | ||
203 | POP3account::POP3account() | 205 | POP3account::POP3account() |
204 | : Account() | 206 | : Account() |
205 | { | 207 | { |
206 | file = POP3account::getUniqueFileName(); | 208 | file = POP3account::getUniqueFileName(); |
207 | accountName = "New POP3 Account"; | 209 | accountName = "New POP3 Account"; |
208 | ssl = false; | 210 | ssl = false; |
209 | connectionType = 1; | 211 | connectionType = 1; |
210 | type = "POP3"; | 212 | type = "POP3"; |
211 | port = POP3_PORT; | 213 | port = POP3_PORT; |
212 | } | 214 | } |
213 | 215 | ||
214 | POP3account::POP3account( QString filename ) | 216 | POP3account::POP3account( QString filename ) |
215 | : Account() | 217 | : Account() |
216 | { | 218 | { |
217 | file = filename; | 219 | file = filename; |
218 | accountName = "New POP3 Account"; | 220 | accountName = "New POP3 Account"; |
219 | ssl = false; | 221 | ssl = false; |
220 | connectionType = 1; | 222 | connectionType = 1; |
221 | type = "POP3"; | 223 | type = "POP3"; |
222 | port = POP3_PORT; | 224 | port = POP3_PORT; |
223 | } | 225 | } |
224 | 226 | ||
225 | QString POP3account::getUniqueFileName() | 227 | QString POP3account::getUniqueFileName() |
226 | { | 228 | { |
227 | int num = 0; | 229 | int num = 0; |
228 | QString unique; | 230 | QString unique; |
229 | 231 | ||
230 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 232 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
231 | 233 | ||
232 | QStringList imap = dir.entryList( "pop3-*" ); | 234 | QStringList imap = dir.entryList( "pop3-*" ); |
233 | do { | 235 | do { |
234 | unique.setNum( num++ ); | 236 | unique.setNum( num++ ); |
235 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 237 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
236 | 238 | ||
237 | return unique; | 239 | return unique; |
238 | } | 240 | } |
239 | 241 | ||
240 | void POP3account::read() | 242 | void POP3account::read() |
241 | { | 243 | { |
242 | Config *conf = new Config( getFileName(), Config::File ); | 244 | Config *conf = new Config( getFileName(), Config::File ); |
243 | conf->setGroup( "POP3 Account" ); | 245 | conf->setGroup( "POP3 Account" ); |
244 | accountName = conf->readEntry( "Account" ); | 246 | accountName = conf->readEntry( "Account" ); |
245 | server = conf->readEntry( "Server" ); | 247 | server = conf->readEntry( "Server" ); |
246 | port = conf->readEntry( "Port" ); | 248 | port = conf->readEntry( "Port" ); |
247 | ssl = conf->readBoolEntry( "SSL" ); | 249 | ssl = conf->readBoolEntry( "SSL" ); |
248 | connectionType = conf->readNumEntry( "ConnectionType" ); | 250 | connectionType = conf->readNumEntry( "ConnectionType" ); |
249 | user = conf->readEntry( "User" ); | 251 | user = conf->readEntry( "User" ); |
250 | password = conf->readEntryCrypt( "Password" ); | 252 | password = conf->readEntryCrypt( "Password" ); |
251 | offline = conf->readBoolEntry("Offline",false); | 253 | offline = conf->readBoolEntry("Offline",false); |
252 | delete conf; | 254 | delete conf; |
253 | } | 255 | } |
254 | 256 | ||
255 | void POP3account::save() | 257 | void POP3account::save() |
256 | { | 258 | { |
257 | qDebug( "saving " + getFileName() ); | 259 | qDebug( "saving " + getFileName() ); |
258 | Settings::checkDirectory(); | 260 | Settings::checkDirectory(); |
259 | 261 | ||
260 | Config *conf = new Config( getFileName(), Config::File ); | 262 | Config *conf = new Config( getFileName(), Config::File ); |
261 | conf->setGroup( "POP3 Account" ); | 263 | conf->setGroup( "POP3 Account" ); |
262 | conf->writeEntry( "Account", accountName ); | 264 | conf->writeEntry( "Account", accountName ); |
263 | conf->writeEntry( "Server", server ); | 265 | conf->writeEntry( "Server", server ); |
264 | conf->writeEntry( "Port", port ); | 266 | conf->writeEntry( "Port", port ); |
265 | conf->writeEntry( "SSL", ssl ); | 267 | conf->writeEntry( "SSL", ssl ); |
266 | conf->writeEntry( "ConnectionType", connectionType ); | 268 | conf->writeEntry( "ConnectionType", connectionType ); |
267 | conf->writeEntry( "User", user ); | 269 | conf->writeEntry( "User", user ); |
268 | conf->writeEntryCrypt( "Password", password ); | 270 | conf->writeEntryCrypt( "Password", password ); |
269 | conf->writeEntry( "Offline",offline); | 271 | conf->writeEntry( "Offline",offline); |
270 | conf->write(); | 272 | conf->write(); |
271 | delete conf; | 273 | delete conf; |
272 | } | 274 | } |
273 | 275 | ||
274 | 276 | ||
275 | QString POP3account::getFileName() | 277 | QString POP3account::getFileName() |
276 | { | 278 | { |
277 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 279 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
278 | } | 280 | } |
279 | 281 | ||
280 | SMTPaccount::SMTPaccount() | 282 | SMTPaccount::SMTPaccount() |
281 | : Account() | 283 | : Account() |
282 | { | 284 | { |
283 | file = SMTPaccount::getUniqueFileName(); | 285 | file = SMTPaccount::getUniqueFileName(); |
284 | accountName = "New SMTP Account"; | 286 | accountName = "New SMTP Account"; |
285 | ssl = false; | 287 | ssl = false; |
286 | connectionType = 1; | 288 | connectionType = 1; |
287 | login = false; | 289 | login = false; |
288 | useCC = false; | 290 | useCC = false; |
289 | useBCC = false; | 291 | useBCC = false; |
290 | useReply = false; | 292 | useReply = false; |
291 | type = "SMTP"; | 293 | type = "SMTP"; |
292 | port = SMTP_PORT; | 294 | port = SMTP_PORT; |
293 | } | 295 | } |
294 | 296 | ||
295 | SMTPaccount::SMTPaccount( QString filename ) | 297 | SMTPaccount::SMTPaccount( QString filename ) |
296 | : Account() | 298 | : Account() |
297 | { | 299 | { |
298 | file = filename; | 300 | file = filename; |
299 | accountName = "New SMTP Account"; | 301 | accountName = "New SMTP Account"; |
300 | ssl = false; | 302 | ssl = false; |
301 | connectionType = 1; | 303 | connectionType = 1; |
302 | login = false; | 304 | login = false; |
303 | type = "SMTP"; | 305 | type = "SMTP"; |
304 | port = SMTP_PORT; | 306 | port = SMTP_PORT; |
305 | } | 307 | } |
306 | 308 | ||
307 | QString SMTPaccount::getUniqueFileName() | 309 | QString SMTPaccount::getUniqueFileName() |
308 | { | 310 | { |
309 | int num = 0; | 311 | int num = 0; |
310 | QString unique; | 312 | QString unique; |
311 | 313 | ||
312 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 314 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
313 | 315 | ||
314 | QStringList imap = dir.entryList( "smtp-*" ); | 316 | QStringList imap = dir.entryList( "smtp-*" ); |
315 | do { | 317 | do { |
316 | unique.setNum( num++ ); | 318 | unique.setNum( num++ ); |