summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/editaccounts.cpp36
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp35
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h2
3 files changed, 40 insertions, 33 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index b8aad11..28d531b 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,578 +1,576 @@
1 1
2#include "defines.h" 2#include "defines.h"
3#include "editaccounts.h" 3#include "editaccounts.h"
4 4
5/* OPIE */ 5/* OPIE */
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7 7
8/* QT */ 8/* QT */
9#include <qt.h> 9#include <qt.h>
10#include <qstringlist.h> 10#include <qstringlist.h>
11 11
12#include <libmailwrapper/nntpwrapper.h> 12#include <libmailwrapper/nntpwrapper.h>
13 13
14#include <libetpan/nntpdriver.h>
15
16AccountListItem::AccountListItem( QListView *parent, Account *a) 14AccountListItem::AccountListItem( QListView *parent, Account *a)
17 : QListViewItem( parent ) 15 : QListViewItem( parent )
18{ 16{
19 account = a; 17 account = a;
20 setText( 0, account->getAccountName() ); 18 setText( 0, account->getAccountName() );
21 setText( 1, account->getType() ); 19 setText( 1, account->getType() );
22} 20}
23 21
24EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 22EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
25 : EditAccountsUI( parent, name, modal, flags ) 23 : EditAccountsUI( parent, name, modal, flags )
26{ 24{
27 qDebug( "New Account Configuration Widget" ); 25 qDebug( "New Account Configuration Widget" );
28 settings = s; 26 settings = s;
29 27
30 mailList->addColumn( tr( "Account" ) ); 28 mailList->addColumn( tr( "Account" ) );
31 mailList->addColumn( tr( "Type" ) ); 29 mailList->addColumn( tr( "Type" ) );
32 30
33 newsList->addColumn( tr( "Account" ) ); 31 newsList->addColumn( tr( "Account" ) );
34 32
35 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 33 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
36 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 34 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
37 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 35 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
38 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 36 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
39 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 37 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
40 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 38 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
41 39
42 slotFillLists(); 40 slotFillLists();
43} 41}
44 42
45void EditAccounts::slotFillLists() 43void EditAccounts::slotFillLists()
46{ 44{
47 mailList->clear(); 45 mailList->clear();
48 newsList->clear(); 46 newsList->clear();
49 47
50 QList<Account> accounts = settings->getAccounts(); 48 QList<Account> accounts = settings->getAccounts();
51 Account *it; 49 Account *it;
52 for ( it = accounts.first(); it; it = accounts.next() ) 50 for ( it = accounts.first(); it; it = accounts.next() )
53 { 51 {
54 if ( it->getType().compare( "NNTP" ) == 0 ) 52 if ( it->getType().compare( "NNTP" ) == 0 )
55 { 53 {
56 (void) new AccountListItem( newsList, it ); 54 (void) new AccountListItem( newsList, it );
57 } 55 }
58 else 56 else
59 { 57 {
60 (void) new AccountListItem( mailList, it ); 58 (void) new AccountListItem( mailList, it );
61 } 59 }
62 } 60 }
63} 61}
64 62
65void EditAccounts::slotNewMail() 63void EditAccounts::slotNewMail()
66{ 64{
67 qDebug( "New Mail Account" ); 65 qDebug( "New Mail Account" );
68 QString *selection = new QString(); 66 QString *selection = new QString();
69 SelectMailType selType( selection, this, 0, true ); 67 SelectMailType selType( selection, this, 0, true );
70 selType.show(); 68 selType.show();
71 if ( QDialog::Accepted == selType.exec() ) 69 if ( QDialog::Accepted == selType.exec() )
72 { 70 {
73 slotNewAccount( *selection ); 71 slotNewAccount( *selection );
74 } 72 }
75} 73}
76 74
77void EditAccounts::slotNewAccount( const QString &type ) 75void EditAccounts::slotNewAccount( const QString &type )
78{ 76{
79 if ( type.compare( "IMAP" ) == 0 ) 77 if ( type.compare( "IMAP" ) == 0 )
80 { 78 {
81 qDebug( "-> config IMAP" ); 79 qDebug( "-> config IMAP" );
82 IMAPaccount *account = new IMAPaccount(); 80 IMAPaccount *account = new IMAPaccount();
83 IMAPconfig imap( account, this, 0, true ); 81 IMAPconfig imap( account, this, 0, true );
84 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) 82 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
85 { 83 {
86 settings->addAccount( account ); 84 settings->addAccount( account );
87 account->save(); 85 account->save();
88 slotFillLists(); 86 slotFillLists();
89 } 87 }
90 else 88 else
91 { 89 {
92 account->remove(); 90 account->remove();
93 } 91 }
94 } 92 }
95 else if ( type.compare( "POP3" ) == 0 ) 93 else if ( type.compare( "POP3" ) == 0 )
96 { 94 {
97 qDebug( "-> config POP3" ); 95 qDebug( "-> config POP3" );
98 POP3account *account = new POP3account(); 96 POP3account *account = new POP3account();
99 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 97 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
100 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) 98 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
101 { 99 {
102 settings->addAccount( account ); 100 settings->addAccount( account );
103 account->save(); 101 account->save();
104 slotFillLists(); 102 slotFillLists();
105 } 103 }
106 else 104 else
107 { 105 {
108 account->remove(); 106 account->remove();
109 } 107 }
110 } 108 }
111 else if ( type.compare( "SMTP" ) == 0 ) 109 else if ( type.compare( "SMTP" ) == 0 )
112 { 110 {
113 qDebug( "-> config SMTP" ); 111 qDebug( "-> config SMTP" );
114 SMTPaccount *account = new SMTPaccount(); 112 SMTPaccount *account = new SMTPaccount();
115 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 113 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
116 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) 114 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
117 { 115 {
118 settings->addAccount( account ); 116 settings->addAccount( account );
119 account->save(); 117 account->save();
120 slotFillLists(); 118 slotFillLists();
121 119
122 } 120 }
123 else 121 else
124 { 122 {
125 account->remove(); 123 account->remove();
126 } 124 }
127 } 125 }
128 else if ( type.compare( "NNTP" ) == 0 ) 126 else if ( type.compare( "NNTP" ) == 0 )
129 { 127 {
130 qDebug( "-> config NNTP" ); 128 qDebug( "-> config NNTP" );
131 NNTPaccount *account = new NNTPaccount(); 129 NNTPaccount *account = new NNTPaccount();
132 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 130 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
133 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) 131 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
134 { 132 {
135 settings->addAccount( account ); 133 settings->addAccount( account );
136 account->save(); 134 account->save();
137 slotFillLists(); 135 slotFillLists();
138 } 136 }
139 else 137 else
140 { 138 {
141 account->remove(); 139 account->remove();
142 } 140 }
143 } 141 }
144} 142}
145 143
146void EditAccounts::slotEditAccount( Account *account ) 144void EditAccounts::slotEditAccount( Account *account )
147{ 145{
148 if ( account->getType().compare( "IMAP" ) == 0 ) 146 if ( account->getType().compare( "IMAP" ) == 0 )
149 { 147 {
150 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 148 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
151 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 149 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
152 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) 150 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
153 { 151 {
154 slotFillLists(); 152 slotFillLists();
155 } 153 }
156 } 154 }
157 else if ( account->getType().compare( "POP3" ) == 0 ) 155 else if ( account->getType().compare( "POP3" ) == 0 )
158 { 156 {
159 POP3account *pop3Acc = static_cast<POP3account *>(account); 157 POP3account *pop3Acc = static_cast<POP3account *>(account);
160 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 158 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
161 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) 159 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
162 { 160 {
163 slotFillLists(); 161 slotFillLists();
164 } 162 }
165 } 163 }
166 else if ( account->getType().compare( "SMTP" ) == 0 ) 164 else if ( account->getType().compare( "SMTP" ) == 0 )
167 { 165 {
168 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 166 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
169 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 167 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
170 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) 168 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
171 { 169 {
172 slotFillLists(); 170 slotFillLists();
173 } 171 }
174 } 172 }
175 else if ( account->getType().compare( "NNTP" ) == 0 ) 173 else if ( account->getType().compare( "NNTP" ) == 0 )
176 { 174 {
177 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 175 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
178 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 176 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
179 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) 177 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
180 { 178 {
181 slotFillLists(); 179 slotFillLists();
182 } 180 }
183 } 181 }
184} 182}
185 183
186void EditAccounts::slotDeleteAccount( Account *account ) 184void EditAccounts::slotDeleteAccount( Account *account )
187{ 185{
188 if ( QMessageBox::information( this, tr( "Question" ), 186 if ( QMessageBox::information( this, tr( "Question" ),
189 tr( "<p>Do you really want to delete the selected Account?</p>" ), 187 tr( "<p>Do you really want to delete the selected Account?</p>" ),
190 tr( "Yes" ), tr( "No" ) ) == 0 ) 188 tr( "Yes" ), tr( "No" ) ) == 0 )
191 { 189 {
192 settings->delAccount( account ); 190 settings->delAccount( account );
193 slotFillLists(); 191 slotFillLists();
194 } 192 }
195} 193}
196 194
197void EditAccounts::slotEditMail() 195void EditAccounts::slotEditMail()
198{ 196{
199 qDebug( "Edit Mail Account" ); 197 qDebug( "Edit Mail Account" );
200 if ( !mailList->currentItem() ) 198 if ( !mailList->currentItem() )
201 { 199 {
202 QMessageBox::information( this, tr( "Error" ), 200 QMessageBox::information( this, tr( "Error" ),
203 tr( "<p>Please select an account.</p>" ), 201 tr( "<p>Please select an account.</p>" ),
204 tr( "Ok" ) ); 202 tr( "Ok" ) );
205 return; 203 return;
206 } 204 }
207 205
208 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 206 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
209 slotEditAccount( a ); 207 slotEditAccount( a );
210} 208}
211 209
212void EditAccounts::slotDeleteMail() 210void EditAccounts::slotDeleteMail()
213{ 211{
214 if ( !mailList->currentItem() ) 212 if ( !mailList->currentItem() )
215 { 213 {
216 QMessageBox::information( this, tr( "Error" ), 214 QMessageBox::information( this, tr( "Error" ),
217 tr( "<p>Please select an account.</p>" ), 215 tr( "<p>Please select an account.</p>" ),
218 tr( "Ok" ) ); 216 tr( "Ok" ) );
219 return; 217 return;
220 } 218 }
221 219
222 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 220 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
223 slotDeleteAccount( a ); 221 slotDeleteAccount( a );
224} 222}
225 223
226void EditAccounts::slotNewNews() 224void EditAccounts::slotNewNews()
227{ 225{
228 qDebug( "New News Account" ); 226 qDebug( "New News Account" );
229 slotNewAccount( "NNTP" ); 227 slotNewAccount( "NNTP" );
230} 228}
231 229
232void EditAccounts::slotEditNews() 230void EditAccounts::slotEditNews()
233{ 231{
234 qDebug( "Edit News Account" ); 232 qDebug( "Edit News Account" );
235 if ( !newsList->currentItem() ) 233 if ( !newsList->currentItem() )
236 { 234 {
237 QMessageBox::information( this, tr( "Error" ), 235 QMessageBox::information( this, tr( "Error" ),
238 tr( "<p>Please select an account.</p>" ), 236 tr( "<p>Please select an account.</p>" ),
239 tr( "Ok" ) ); 237 tr( "Ok" ) );
240 return; 238 return;
241 } 239 }
242 240
243 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 241 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
244 slotEditAccount( a ); 242 slotEditAccount( a );
245} 243}
246 244
247void EditAccounts::slotDeleteNews() 245void EditAccounts::slotDeleteNews()
248{ 246{
249 qDebug( "Delete News Account" ); 247 qDebug( "Delete News Account" );
250 if ( !newsList->currentItem() ) 248 if ( !newsList->currentItem() )
251 { 249 {
252 QMessageBox::information( this, tr( "Error" ), 250 QMessageBox::information( this, tr( "Error" ),
253 tr( "<p>Please select an account.</p>" ), 251 tr( "<p>Please select an account.</p>" ),
254 tr( "Ok" ) ); 252 tr( "Ok" ) );
255 return; 253 return;
256 } 254 }
257 255
258 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 256 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
259 slotDeleteAccount( a ); 257 slotDeleteAccount( a );
260} 258}
261 259
262void EditAccounts::slotAdjustColumns() 260void EditAccounts::slotAdjustColumns()
263{ 261{
264 int currPage = configTab->currentPageIndex(); 262 int currPage = configTab->currentPageIndex();
265 263
266 configTab->showPage( mailTab ); 264 configTab->showPage( mailTab );
267 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 265 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
268 mailList->setColumnWidth( 1, 50 ); 266 mailList->setColumnWidth( 1, 50 );
269 267
270 configTab->showPage( newsTab ); 268 configTab->showPage( newsTab );
271 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 269 newsList->setColumnWidth( 0, newsList->visibleWidth() );
272 270
273 configTab->setCurrentPage( currPage ); 271 configTab->setCurrentPage( currPage );
274} 272}
275 273
276void EditAccounts::accept() 274void EditAccounts::accept()
277{ 275{
278 settings->saveAccounts(); 276 settings->saveAccounts();
279 277
280 QDialog::accept(); 278 QDialog::accept();
281} 279}
282 280
283/** 281/**
284 * SelectMailType 282 * SelectMailType
285 */ 283 */
286 284
287SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 285SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
288 : SelectMailTypeUI( parent, name, modal, flags ) 286 : SelectMailTypeUI( parent, name, modal, flags )
289{ 287{
290 selected = selection; 288 selected = selection;
291 selected->replace( 0, selected->length(), typeBox->currentText() ); 289 selected->replace( 0, selected->length(), typeBox->currentText() );
292 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); 290 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
293} 291}
294 292
295void SelectMailType::slotSelection( const QString &sel ) 293void SelectMailType::slotSelection( const QString &sel )
296{ 294{
297 selected->replace( 0, selected->length(), sel ); 295 selected->replace( 0, selected->length(), sel );
298} 296}
299 297
300/** 298/**
301 * IMAPconfig 299 * IMAPconfig
302 */ 300 */
303 301
304IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 302IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
305 : IMAPconfigUI( parent, name, modal, flags ) 303 : IMAPconfigUI( parent, name, modal, flags )
306{ 304{
307 data = account; 305 data = account;
308 306
309 fillValues(); 307 fillValues();
310 308
311 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 309 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
312 ComboBox1->insertItem( "Only if available", 0 ); 310 ComboBox1->insertItem( "Only if available", 0 );
313 ComboBox1->insertItem( "Always, Negotiated", 1 ); 311 ComboBox1->insertItem( "Always, Negotiated", 1 );
314 ComboBox1->insertItem( "Connect on secure port", 2 ); 312 ComboBox1->insertItem( "Connect on secure port", 2 );
315 ComboBox1->insertItem( "Run command instead", 3 ); 313 ComboBox1->insertItem( "Run command instead", 3 );
316 CommandEdit->hide(); 314 CommandEdit->hide();
317 ComboBox1->setCurrentItem( data->ConnectionType() ); 315 ComboBox1->setCurrentItem( data->ConnectionType() );
318} 316}
319 317
320void IMAPconfig::slotConnectionToggle( int index ) 318void IMAPconfig::slotConnectionToggle( int index )
321{ 319{
322 if ( index == 2 ) 320 if ( index == 2 )
323 { 321 {
324 portLine->setText( IMAP_SSL_PORT ); 322 portLine->setText( IMAP_SSL_PORT );
325 } 323 }
326 else if ( index == 3 ) 324 else if ( index == 3 )
327 { 325 {
328 portLine->setText( IMAP_PORT ); 326 portLine->setText( IMAP_PORT );
329 CommandEdit->show(); 327 CommandEdit->show();
330 } 328 }
331 else 329 else
332 { 330 {
333 portLine->setText( IMAP_PORT ); 331 portLine->setText( IMAP_PORT );
334 } 332 }
335} 333}
336 334
337void IMAPconfig::fillValues() 335void IMAPconfig::fillValues()
338{ 336{
339 accountLine->setText( data->getAccountName() ); 337 accountLine->setText( data->getAccountName() );
340 serverLine->setText( data->getServer() ); 338 serverLine->setText( data->getServer() );
341 portLine->setText( data->getPort() ); 339 portLine->setText( data->getPort() );
342 ComboBox1->setCurrentItem( data->ConnectionType() ); 340 ComboBox1->setCurrentItem( data->ConnectionType() );
343 userLine->setText( data->getUser() ); 341 userLine->setText( data->getUser() );
344 passLine->setText( data->getPassword() ); 342 passLine->setText( data->getPassword() );
345 prefixLine->setText(data->getPrefix()); 343 prefixLine->setText(data->getPrefix());
346} 344}
347 345
348void IMAPconfig::accept() 346void IMAPconfig::accept()
349{ 347{
350 data->setAccountName( accountLine->text() ); 348 data->setAccountName( accountLine->text() );
351 data->setServer( serverLine->text() ); 349 data->setServer( serverLine->text() );
352 data->setPort( portLine->text() ); 350 data->setPort( portLine->text() );
353 data->setConnectionType( ComboBox1->currentItem() ); 351 data->setConnectionType( ComboBox1->currentItem() );
354 data->setUser( userLine->text() ); 352 data->setUser( userLine->text() );
355 data->setPassword( passLine->text() ); 353 data->setPassword( passLine->text() );
356 data->setPrefix(prefixLine->text()); 354 data->setPrefix(prefixLine->text());
357 355
358 QDialog::accept(); 356 QDialog::accept();
359} 357}
360 358
361/** 359/**
362 * POP3config 360 * POP3config
363 */ 361 */
364 362
365POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 363POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
366 : POP3configUI( parent, name, modal, flags ) 364 : POP3configUI( parent, name, modal, flags )
367{ 365{
368 data = account; 366 data = account;
369 fillValues(); 367 fillValues();
370 368
371 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 369 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
372 ComboBox1->insertItem( "Only if available", 0 ); 370 ComboBox1->insertItem( "Only if available", 0 );
373 ComboBox1->insertItem( "Always, Negotiated", 1 ); 371 ComboBox1->insertItem( "Always, Negotiated", 1 );
374 ComboBox1->insertItem( "Connect on secure port", 2 ); 372 ComboBox1->insertItem( "Connect on secure port", 2 );
375 ComboBox1->insertItem( "Run command instead", 3 ); 373 ComboBox1->insertItem( "Run command instead", 3 );
376 CommandEdit->hide(); 374 CommandEdit->hide();
377 ComboBox1->setCurrentItem( data->ConnectionType() ); 375 ComboBox1->setCurrentItem( data->ConnectionType() );
378} 376}
379 377
380void POP3config::slotConnectionToggle( int index ) 378void POP3config::slotConnectionToggle( int index )
381{ 379{
382 // 2 is ssl connection 380 // 2 is ssl connection
383 if ( index == 2 ) 381 if ( index == 2 )
384 { 382 {
385 portLine->setText( POP3_SSL_PORT ); 383 portLine->setText( POP3_SSL_PORT );
386 } 384 }
387 else if ( index == 3 ) 385 else if ( index == 3 )
388 { 386 {
389 portLine->setText( POP3_PORT ); 387 portLine->setText( POP3_PORT );
390 CommandEdit->show(); 388 CommandEdit->show();
391 } 389 }
392 else 390 else
393 { 391 {
394 portLine->setText( POP3_PORT ); 392 portLine->setText( POP3_PORT );
395 } 393 }
396} 394}
397 395
398void POP3config::fillValues() 396void POP3config::fillValues()
399{ 397{
400 accountLine->setText( data->getAccountName() ); 398 accountLine->setText( data->getAccountName() );
401 serverLine->setText( data->getServer() ); 399 serverLine->setText( data->getServer() );
402 portLine->setText( data->getPort() ); 400 portLine->setText( data->getPort() );
403 ComboBox1->setCurrentItem( data->ConnectionType() ); 401 ComboBox1->setCurrentItem( data->ConnectionType() );
404 userLine->setText( data->getUser() ); 402 userLine->setText( data->getUser() );
405 passLine->setText( data->getPassword() ); 403 passLine->setText( data->getPassword() );
406} 404}
407 405
408void POP3config::accept() 406void POP3config::accept()
409{ 407{
410 data->setAccountName( accountLine->text() ); 408 data->setAccountName( accountLine->text() );
411 data->setServer( serverLine->text() ); 409 data->setServer( serverLine->text() );
412 data->setPort( portLine->text() ); 410 data->setPort( portLine->text() );
413 data->setConnectionType( ComboBox1->currentItem() ); 411 data->setConnectionType( ComboBox1->currentItem() );
414 data->setUser( userLine->text() ); 412 data->setUser( userLine->text() );
415 data->setPassword( passLine->text() ); 413 data->setPassword( passLine->text() );
416 414
417 QDialog::accept(); 415 QDialog::accept();
418} 416}
419 417
420/** 418/**
421 * SMTPconfig 419 * SMTPconfig
422 */ 420 */
423 421
424SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 422SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
425 : SMTPconfigUI( parent, name, modal, flags ) 423 : SMTPconfigUI( parent, name, modal, flags )
426{ 424{
427 data = account; 425 data = account;
428 426
429 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 427 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
430 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 428 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
431 429
432 fillValues(); 430 fillValues();
433 431
434 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 432 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
435 ComboBox1->insertItem( "Only if available", 0 ); 433 ComboBox1->insertItem( "Only if available", 0 );
436 ComboBox1->insertItem( "Always, Negotiated", 1 ); 434 ComboBox1->insertItem( "Always, Negotiated", 1 );
437 ComboBox1->insertItem( "Connect on secure port", 2 ); 435 ComboBox1->insertItem( "Connect on secure port", 2 );
438 ComboBox1->insertItem( "Run command instead", 3 ); 436 ComboBox1->insertItem( "Run command instead", 3 );
439 CommandEdit->hide(); 437 CommandEdit->hide();
440 ComboBox1->setCurrentItem( data->ConnectionType() ); 438 ComboBox1->setCurrentItem( data->ConnectionType() );
441} 439}
442 440
443void SMTPconfig::slotConnectionToggle( int index ) 441void SMTPconfig::slotConnectionToggle( int index )
444{ 442{
445 // 2 is ssl connection 443 // 2 is ssl connection
446 if ( index == 2 ) 444 if ( index == 2 )
447 { 445 {
448 portLine->setText( SMTP_SSL_PORT ); 446 portLine->setText( SMTP_SSL_PORT );
449 } 447 }
450 else if ( index == 3 ) 448 else if ( index == 3 )
451 { 449 {
452 portLine->setText( SMTP_PORT ); 450 portLine->setText( SMTP_PORT );
453 CommandEdit->show(); 451 CommandEdit->show();
454 } 452 }
455 else 453 else
456 { 454 {
457 portLine->setText( SMTP_PORT ); 455 portLine->setText( SMTP_PORT );
458 } 456 }
459} 457}
460 458
461void SMTPconfig::fillValues() 459void SMTPconfig::fillValues()
462{ 460{
463 accountLine->setText( data->getAccountName() ); 461 accountLine->setText( data->getAccountName() );
464 serverLine->setText( data->getServer() ); 462 serverLine->setText( data->getServer() );
465 portLine->setText( data->getPort() ); 463 portLine->setText( data->getPort() );
466 ComboBox1->setCurrentItem( data->ConnectionType() ); 464 ComboBox1->setCurrentItem( data->ConnectionType() );
467 loginBox->setChecked( data->getLogin() ); 465 loginBox->setChecked( data->getLogin() );
468 userLine->setText( data->getUser() ); 466 userLine->setText( data->getUser() );
469 passLine->setText( data->getPassword() ); 467 passLine->setText( data->getPassword() );
470} 468}
471 469
472void SMTPconfig::accept() 470void SMTPconfig::accept()
473{ 471{
474 data->setAccountName( accountLine->text() ); 472 data->setAccountName( accountLine->text() );
475 data->setServer( serverLine->text() ); 473 data->setServer( serverLine->text() );
476 data->setPort( portLine->text() ); 474 data->setPort( portLine->text() );
477 data->setConnectionType( ComboBox1->currentItem() ); 475 data->setConnectionType( ComboBox1->currentItem() );
478 data->setLogin( loginBox->isChecked() ); 476 data->setLogin( loginBox->isChecked() );
479 data->setUser( userLine->text() ); 477 data->setUser( userLine->text() );
480 data->setPassword( passLine->text() ); 478 data->setPassword( passLine->text() );
481 479
482 QDialog::accept(); 480 QDialog::accept();
483} 481}
484 482
485/** 483/**
486 * NNTPconfig 484 * NNTPconfig
487 */ 485 */
488 486
489NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 487NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
490 : NNTPconfigUI( parent, name, modal, flags ) 488 : NNTPconfigUI( parent, name, modal, flags )
491{ 489{
492 data = account; 490 data = account;
493 491
494 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 492 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
495 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 493 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
496 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 494 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
497 fillValues(); 495 fillValues();
498 496
499 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 497 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
500} 498}
501 499
502void NNTPconfig::slotGetNG() { 500void NNTPconfig::slotGetNG() {
503 save(); 501 save();
504 data->save(); 502 data->save();
505 NNTPwrapper* tmp = new NNTPwrapper( data ); 503 NNTPwrapper* tmp = new NNTPwrapper( data );
506 clist* list = tmp->listAllNewsgroups(); 504 QStringList list = tmp->listAllNewsgroups();
507 505
508 clistcell *current; 506 ListViewGroups->clear();
509 newsnntp_group_description *group; 507
510 508 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
511 // FIXME - test if not empty 509 QCheckListItem *item;
512 current = list->first; 510 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
513 for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { 511 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
514 group = ( newsnntp_group_description* ) current->data; 512 item->setOn( true );
515 // qDebug( group->grp_name ); 513 }
516 514 }
517 QCheckListItem *item;
518 item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox );
519 if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) {
520 item->setOn( true );
521 }
522 }
523} 515}
524 516
525void NNTPconfig::slotSSL( bool enabled ) 517void NNTPconfig::slotSSL( bool enabled )
526{ 518{
527 if ( enabled ) 519 if ( enabled )
528 { 520 {
529 portLine->setText( NNTP_SSL_PORT ); 521 portLine->setText( NNTP_SSL_PORT );
530 } 522 }
531 else 523 else
532 { 524 {
533 portLine->setText( NNTP_PORT ); 525 portLine->setText( NNTP_PORT );
534 } 526 }
535} 527}
536 528
537void NNTPconfig::fillValues() 529void NNTPconfig::fillValues()
538{ 530{
539 accountLine->setText( data->getAccountName() ); 531 accountLine->setText( data->getAccountName() );
540 serverLine->setText( data->getServer() ); 532 serverLine->setText( data->getServer() );
541 portLine->setText( data->getPort() ); 533 portLine->setText( data->getPort() );
542 sslBox->setChecked( data->getSSL() ); 534 sslBox->setChecked( data->getSSL() );
543 loginBox->setChecked( data->getLogin() ); 535 loginBox->setChecked( data->getLogin() );
544 userLine->setText( data->getUser() ); 536 userLine->setText( data->getUser() );
545 passLine->setText( data->getPassword() ); 537 passLine->setText( data->getPassword() );
546 subscribedGroups = data->getGroups(); 538 subscribedGroups = data->getGroups();
539 /* don't forget that - you will overwrite values if user clicks cancel! */
540 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
541 QCheckListItem *item;
542 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
543 item->setOn( true );
544 }
547} 545}
548 546
549void NNTPconfig::save() 547void NNTPconfig::save()
550{ 548{
551 data->setAccountName( accountLine->text() ); 549 data->setAccountName( accountLine->text() );
552 data->setServer( serverLine->text() ); 550 data->setServer( serverLine->text() );
553 data->setPort( portLine->text() ); 551 data->setPort( portLine->text() );
554 data->setSSL( sslBox->isChecked() ); 552 data->setSSL( sslBox->isChecked() );
555 data->setLogin( loginBox->isChecked() ); 553 data->setLogin( loginBox->isChecked() );
556 data->setUser( userLine->text() ); 554 data->setUser( userLine->text() );
557 data->setPassword( passLine->text() ); 555 data->setPassword( passLine->text() );
558 556
559 QListViewItemIterator list_it( ListViewGroups ); 557 QListViewItemIterator list_it( ListViewGroups );
560 558
561 QStringList groupList; 559 QStringList groupList;
562 for ( ; list_it.current(); ++list_it ) { 560 for ( ; list_it.current(); ++list_it ) {
563 561
564 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 562 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
565 qDebug(list_it.current()->text(0) ); 563 qDebug(list_it.current()->text(0) );
566 groupList.append( list_it.current()->text(0) ); 564 groupList.append( list_it.current()->text(0) );
567 } 565 }
568 566
569 } 567 }
570 data->setGroups( groupList ); 568 data->setGroups( groupList );
571} 569}
572 570
573void NNTPconfig::accept() 571void NNTPconfig::accept()
574{ 572{
575 save(); 573 save();
576 QDialog::accept(); 574 QDialog::accept();
577} 575}
578 576
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index 798879d..a766a59 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -1,262 +1,271 @@
1#include "nntpwrapper.h" 1#include "nntpwrapper.h"
2#include "logindialog.h" 2#include "logindialog.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5#include <qfile.h> 5#include <qfile.h>
6 6
7#include <stdlib.h> 7#include <stdlib.h>
8 8
9#include <libetpan/libetpan.h> 9#include <libetpan/libetpan.h>
10 10
11 11
12#define HARD_MSG_SIZE_LIMIT 5242880 12#define HARD_MSG_SIZE_LIMIT 5242880
13 13
14NNTPwrapper::NNTPwrapper( NNTPaccount *a ) 14NNTPwrapper::NNTPwrapper( NNTPaccount *a )
15: Genericwrapper() { 15: Genericwrapper() {
16 account = a; 16 account = a;
17 m_nntp = NULL; 17 m_nntp = NULL;
18 msgTempName = a->getFileName()+"_msg_cache"; 18 msgTempName = a->getFileName()+"_msg_cache";
19 last_msg_id = 0; 19 last_msg_id = 0;
20} 20}
21 21
22NNTPwrapper::~NNTPwrapper() { 22NNTPwrapper::~NNTPwrapper() {
23 logout(); 23 logout();
24 QFile msg_cache(msgTempName); 24 QFile msg_cache(msgTempName);
25 if (msg_cache.exists()) { 25 if (msg_cache.exists()) {
26 msg_cache.remove(); 26 msg_cache.remove();
27 } 27 }
28} 28}
29 29
30void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { 30void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) {
31 qDebug( "NNTP: %i of %i", current, maximum ); 31 qDebug( "NNTP: %i of %i", current, maximum );
32} 32}
33 33
34 34
35RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { 35RecBody NNTPwrapper::fetchBody( const RecMail &mail ) {
36 int err = NEWSNNTP_NO_ERROR; 36 int err = NEWSNNTP_NO_ERROR;
37 char *message = 0; 37 char *message = 0;
38 size_t length = 0; 38 size_t length = 0;
39 39
40 login(); 40 login();
41 if ( !m_nntp ) { 41 if ( !m_nntp ) {
42 return RecBody(); 42 return RecBody();
43 } 43 }
44 44
45 RecBody body; 45 RecBody body;
46 mailmessage * mailmsg; 46 mailmessage * mailmsg;
47 if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { 47 if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
48 qDebug("Message to large: %i",mail.Msgsize()); 48 qDebug("Message to large: %i",mail.Msgsize());
49 return body; 49 return body;
50 } 50 }
51 51
52 QFile msg_cache(msgTempName); 52 QFile msg_cache(msgTempName);
53 53
54 cleanMimeCache(); 54 cleanMimeCache();
55 55
56 if (mail.getNumber()!=last_msg_id) { 56 if (mail.getNumber()!=last_msg_id) {
57 if (msg_cache.exists()) { 57 if (msg_cache.exists()) {
58 msg_cache.remove(); 58 msg_cache.remove();
59 } 59 }
60 msg_cache.open(IO_ReadWrite|IO_Truncate); 60 msg_cache.open(IO_ReadWrite|IO_Truncate);
61 last_msg_id = mail.getNumber(); 61 last_msg_id = mail.getNumber();
62 err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); 62 err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg);
63 err = mailmessage_fetch(mailmsg,&message,&length); 63 err = mailmessage_fetch(mailmsg,&message,&length);
64 msg_cache.writeBlock(message,length); 64 msg_cache.writeBlock(message,length);
65 } else { 65 } else {
66 QString msg=""; 66 QString msg="";
67 msg_cache.open(IO_ReadOnly); 67 msg_cache.open(IO_ReadOnly);
68 message = new char[4096]; 68 message = new char[4096];
69 memset(message,0,4096); 69 memset(message,0,4096);
70 while (msg_cache.readBlock(message,4095)>0) { 70 while (msg_cache.readBlock(message,4095)>0) {
71 msg+=message; 71 msg+=message;
72 memset(message,0,4096); 72 memset(message,0,4096);
73 } 73 }
74 delete message; 74 delete message;
75 message = (char*)malloc(msg.length()+1*sizeof(char)); 75 message = (char*)malloc(msg.length()+1*sizeof(char));
76 memset(message,0,msg.length()+1); 76 memset(message,0,msg.length()+1);
77 memcpy(message,msg.latin1(),msg.length()); 77 memcpy(message,msg.latin1(),msg.length());
78 /* transform to libetpan stuff */ 78 /* transform to libetpan stuff */
79 mailmsg = mailmessage_new(); 79 mailmsg = mailmessage_new();
80 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 80 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
81 generic_message_t * msg_data; 81 generic_message_t * msg_data;
82 msg_data = (generic_message_t *)mailmsg->msg_data; 82 msg_data = (generic_message_t *)mailmsg->msg_data;
83 msg_data->msg_fetched = 1; 83 msg_data->msg_fetched = 1;
84 msg_data->msg_message = message; 84 msg_data->msg_message = message;
85 msg_data->msg_length = strlen(message); 85 msg_data->msg_length = strlen(message);
86 } 86 }
87 body = parseMail(mailmsg); 87 body = parseMail(mailmsg);
88 88
89 /* clean up */ 89 /* clean up */
90 if (mailmsg) 90 if (mailmsg)
91 mailmessage_free(mailmsg); 91 mailmessage_free(mailmsg);
92 if (message) 92 if (message)
93 free(message); 93 free(message);
94 94
95 return body; 95 return body;
96} 96}
97 97
98 98
99void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target ) 99void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target )
100{ 100{
101 login(); 101 login();
102 if (!m_nntp) 102 if (!m_nntp)
103 return; 103 return;
104 uint32_t res_messages,res_recent,res_unseen; 104 uint32_t res_messages,res_recent,res_unseen;
105 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); 105 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen);
106 parseList(target,m_nntp->sto_session,which); 106 parseList(target,m_nntp->sto_session,which);
107} 107}
108 108
109void NNTPwrapper::login() 109void NNTPwrapper::login()
110{ 110{
111 if (account->getOffline()) 111 if (account->getOffline())
112 return; 112 return;
113 /* we'll hold the line */ 113 /* we'll hold the line */
114 if ( m_nntp != NULL ) 114 if ( m_nntp != NULL )
115 return; 115 return;
116 116
117 const char *server, *user, *pass; 117 const char *server, *user, *pass;
118 QString User,Pass; 118 QString User,Pass;
119 uint16_t port; 119 uint16_t port;
120 int err = NEWSNNTP_NO_ERROR; 120 int err = NEWSNNTP_NO_ERROR;
121 121
122 server = account->getServer().latin1(); 122 server = account->getServer().latin1();
123 port = account->getPort().toUInt(); 123 port = account->getPort().toUInt();
124 124
125 user = pass = 0; 125 user = pass = 0;
126 126
127 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { 127 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) {
128 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 128 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
129 login.show(); 129 login.show();
130 if ( QDialog::Accepted == login.exec() ) { 130 if ( QDialog::Accepted == login.exec() ) {
131 // ok 131 // ok
132 User = login.getUser().latin1(); 132 User = login.getUser().latin1();
133 Pass = login.getPassword().latin1(); 133 Pass = login.getPassword().latin1();
134 } else { 134 } else {
135 // cancel 135 // cancel
136 qDebug( "NNTP: Login canceled" ); 136 qDebug( "NNTP: Login canceled" );
137 return; 137 return;
138 } 138 }
139 } else { 139 } else {
140 User = account->getUser().latin1(); 140 User = account->getUser().latin1();
141 Pass = account->getPassword().latin1(); 141 Pass = account->getPassword().latin1();
142 } 142 }
143 143
144 if (User.isEmpty()) { 144 if (User.isEmpty()) {
145 user=0; 145 user=0;
146 pass = 0; 146 pass = 0;
147 } else { 147 } else {
148 user=User.latin1(); 148 user=User.latin1();
149 pass=Pass.latin1(); 149 pass=Pass.latin1();
150 } 150 }
151 // bool ssl = account->getSSL(); 151 // bool ssl = account->getSSL();
152 152
153 m_nntp=mailstorage_new(NULL); 153 m_nntp=mailstorage_new(NULL);
154 154
155 int conntypeset = account->ConnectionType(); 155 int conntypeset = account->ConnectionType();
156 int conntype = 0; 156 int conntype = 0;
157 if ( conntypeset == 3 ) { 157 if ( conntypeset == 3 ) {
158 conntype = CONNECTION_TYPE_COMMAND; 158 conntype = CONNECTION_TYPE_COMMAND;
159 } else if ( conntypeset == 2 ) { 159 } else if ( conntypeset == 2 ) {
160 conntype = CONNECTION_TYPE_TLS; 160 conntype = CONNECTION_TYPE_TLS;
161 } else if ( conntypeset == 1 ) { 161 } else if ( conntypeset == 1 ) {
162 conntype = CONNECTION_TYPE_STARTTLS; 162 conntype = CONNECTION_TYPE_STARTTLS;
163 } else if ( conntypeset == 0 ) { 163 } else if ( conntypeset == 0 ) {
164 conntype = CONNECTION_TYPE_TRY_STARTTLS; 164 conntype = CONNECTION_TYPE_TRY_STARTTLS;
165 } 165 }
166 166
167 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, 167 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN,
168 (char*)user,(char*)pass,0,0,0); 168 (char*)user,(char*)pass,0,0,0);
169 169
170 err = mailstorage_connect( m_nntp ); 170 err = mailstorage_connect( m_nntp );
171 171
172 if (err != NEWSNNTP_NO_ERROR) { 172 if (err != NEWSNNTP_NO_ERROR) {
173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); 173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
174 // Global::statusMessage(tr("Error initializing folder")); 174 // Global::statusMessage(tr("Error initializing folder"));
175 mailstorage_free(m_nntp); 175 mailstorage_free(m_nntp);
176 m_nntp = 0; 176 m_nntp = 0;
177 177
178 } 178 }
179 179
180} 180}
181 181
182void NNTPwrapper::logout() 182void NNTPwrapper::logout()
183{ 183{
184 int err = NEWSNNTP_NO_ERROR; 184 int err = NEWSNNTP_NO_ERROR;
185 if ( m_nntp == NULL ) 185 if ( m_nntp == NULL )
186 return; 186 return;
187 mailstorage_free(m_nntp); 187 mailstorage_free(m_nntp);
188 m_nntp = 0; 188 m_nntp = 0;
189} 189}
190 190
191QList<Folder>* NNTPwrapper::listFolders() { 191QList<Folder>* NNTPwrapper::listFolders() {
192 192
193 QList<Folder> * folders = new QList<Folder>(); 193 QList<Folder> * folders = new QList<Folder>();
194 folders->setAutoDelete( false ); 194 folders->setAutoDelete( false );
195 QStringList groups; 195 QStringList groups;
196 if (account) { 196 if (account) {
197 groups = account->getGroups(); 197 groups = account->getGroups();
198 } 198 }
199 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { 199 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) {
200 folders->append(new Folder((*it),".")); 200 folders->append(new Folder((*it),"."));
201 } 201 }
202 return folders; 202 return folders;
203} 203}
204 204
205 clist * NNTPwrapper::listAllNewsgroups() { 205QStringList NNTPwrapper::listAllNewsgroups() {
206 login(); 206 login();
207 QStringList res;
207 clist *result = 0; 208 clist *result = 0;
208 clistcell *current; 209 clistcell *current = 0;
209 newsnntp_group_description *list; 210 newsnntp_group_description *group;
210 if ( m_nntp ) { 211
211 mailsession * session = m_nntp->sto_session; 212 if ( m_nntp ) {
212 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; 213 mailsession * session = m_nntp->sto_session;
213 int err = newsnntp_list_newsgroups(news, NULL, &result); 214 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session;
214 215 int err = newsnntp_list_newsgroups(news, NULL, &result);
215 if ( err == NEWSNNTP_NO_ERROR ) { 216 if ( err == NEWSNNTP_NO_ERROR && result) {
216 return result; 217 for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) {
217 } 218 group = ( newsnntp_group_description* ) current->data;
218 } 219 if (!group||!group->grp_name||strlen(group->grp_name)==0) continue;
220 res.append(group->grp_name);
221 }
222 }
223 }
224 if (result) {
225 clist_free(result);
226 }
227 return res;
219} 228}
220 229
221void NNTPwrapper::answeredMail(const RecMail&) {} 230void NNTPwrapper::answeredMail(const RecMail&) {}
222 231
223void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { 232void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) {
224 login(); 233 login();
225 target_stat.message_count = 0; 234 target_stat.message_count = 0;
226 target_stat.message_unseen = 0; 235 target_stat.message_unseen = 0;
227 target_stat.message_recent = 0; 236 target_stat.message_recent = 0;
228 if (!m_nntp) 237 if (!m_nntp)
229 return; 238 return;
230 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, 239 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count,
231 &target_stat.message_recent,&target_stat.message_unseen); 240 &target_stat.message_recent,&target_stat.message_unseen);
232} 241}
233 242
234 243
235encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { 244encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) {
236 char*target=0; 245 char*target=0;
237 size_t length=0; 246 size_t length=0;
238 encodedString*res = 0; 247 encodedString*res = 0;
239 mailmessage * mailmsg = 0; 248 mailmessage * mailmsg = 0;
240 int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); 249 int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg);
241 err = mailmessage_fetch(mailmsg,&target,&length); 250 err = mailmessage_fetch(mailmsg,&target,&length);
242 if (mailmsg) 251 if (mailmsg)
243 mailmessage_free(mailmsg); 252 mailmessage_free(mailmsg);
244 if (target) { 253 if (target) {
245 res = new encodedString(target,length); 254 res = new encodedString(target,length);
246 } 255 }
247 return res; 256 return res;
248} 257}
249 258
250const QString&NNTPwrapper::getType()const { 259const QString&NNTPwrapper::getType()const {
251 return account->getType(); 260 return account->getType();
252} 261}
253 262
254const QString&NNTPwrapper::getName()const{ 263const QString&NNTPwrapper::getName()const{
255 return account->getAccountName(); 264 return account->getAccountName();
256} 265}
257 266
258void NNTPwrapper::deleteMail(const RecMail&mail) { 267void NNTPwrapper::deleteMail(const RecMail&mail) {
259} 268}
260 269
261int NNTPwrapper::deleteAllMail(const Folder*) { 270int NNTPwrapper::deleteAllMail(const Folder*) {
262} 271}
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index e8e2cf4..4d03754 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -1,48 +1,48 @@
1#ifndef __NNTPWRAPPER 1#ifndef __NNTPWRAPPER
2#define __NNTPWRAPPER 2#define __NNTPWRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "genericwrapper.h" 5#include "genericwrapper.h"
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class encodedString; 9class encodedString;
10struct mailstorage; 10struct mailstorage;
11struct mailfolder; 11struct mailfolder;
12 12
13class NNTPwrapper : public Genericwrapper 13class NNTPwrapper : public Genericwrapper
14{ 14{
15 15
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 NNTPwrapper( NNTPaccount *a ); 19 NNTPwrapper( NNTPaccount *a );
20 virtual ~NNTPwrapper(); 20 virtual ~NNTPwrapper();
21 21
22 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
24 /* should only get the subscribed one */ 24 /* should only get the subscribed one */
25 virtual QList<Folder>* listFolders(); 25 virtual QList<Folder>* listFolders();
26 /* mailbox will be ignored */ 26 /* mailbox will be ignored */
27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
28 clist * listAllNewsgroups(); 28 QStringList listAllNewsgroups();
29 virtual void deleteMail(const RecMail&mail); 29 virtual void deleteMail(const RecMail&mail);
30 virtual void answeredMail(const RecMail&mail); 30 virtual void answeredMail(const RecMail&mail);
31 virtual int deleteAllMail(const Folder*); 31 virtual int deleteAllMail(const Folder*);
32 32
33 virtual RecBody fetchBody( const RecMail &mail ); 33 virtual RecBody fetchBody( const RecMail &mail );
34 virtual encodedString* fetchRawBody(const RecMail&mail); 34 virtual encodedString* fetchRawBody(const RecMail&mail);
35 virtual void logout(); 35 virtual void logout();
36 virtual const QString&getType()const; 36 virtual const QString&getType()const;
37 virtual const QString&getName()const; 37 virtual const QString&getName()const;
38 static void nntp_progress( size_t current, size_t maximum ); 38 static void nntp_progress( size_t current, size_t maximum );
39 39
40protected: 40protected:
41 void login(); 41 void login();
42 NNTPaccount *account; 42 NNTPaccount *account;
43 mailstorage* m_nntp; 43 mailstorage* m_nntp;
44 44
45 45
46}; 46};
47 47
48#endif 48#endif