summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/editaccounts.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp2
2 files changed, 8 insertions, 5 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 215380d..b8aad11 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -456,120 +456,123 @@ void SMTPconfig::slotConnectionToggle( int index )
456 { 456 {
457 portLine->setText( SMTP_PORT ); 457 portLine->setText( SMTP_PORT );
458 } 458 }
459} 459}
460 460
461void SMTPconfig::fillValues() 461void SMTPconfig::fillValues()
462{ 462{
463 accountLine->setText( data->getAccountName() ); 463 accountLine->setText( data->getAccountName() );
464 serverLine->setText( data->getServer() ); 464 serverLine->setText( data->getServer() );
465 portLine->setText( data->getPort() ); 465 portLine->setText( data->getPort() );
466 ComboBox1->setCurrentItem( data->ConnectionType() ); 466 ComboBox1->setCurrentItem( data->ConnectionType() );
467 loginBox->setChecked( data->getLogin() ); 467 loginBox->setChecked( data->getLogin() );
468 userLine->setText( data->getUser() ); 468 userLine->setText( data->getUser() );
469 passLine->setText( data->getPassword() ); 469 passLine->setText( data->getPassword() );
470} 470}
471 471
472void SMTPconfig::accept() 472void SMTPconfig::accept()
473{ 473{
474 data->setAccountName( accountLine->text() ); 474 data->setAccountName( accountLine->text() );
475 data->setServer( serverLine->text() ); 475 data->setServer( serverLine->text() );
476 data->setPort( portLine->text() ); 476 data->setPort( portLine->text() );
477 data->setConnectionType( ComboBox1->currentItem() ); 477 data->setConnectionType( ComboBox1->currentItem() );
478 data->setLogin( loginBox->isChecked() ); 478 data->setLogin( loginBox->isChecked() );
479 data->setUser( userLine->text() ); 479 data->setUser( userLine->text() );
480 data->setPassword( passLine->text() ); 480 data->setPassword( passLine->text() );
481 481
482 QDialog::accept(); 482 QDialog::accept();
483} 483}
484 484
485/** 485/**
486 * NNTPconfig 486 * NNTPconfig
487 */ 487 */
488 488
489NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 489NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
490 : NNTPconfigUI( parent, name, modal, flags ) 490 : NNTPconfigUI( parent, name, modal, flags )
491{ 491{
492 data = account; 492 data = account;
493 493
494 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 494 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
495 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 495 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
496 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 496 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
497 fillValues(); 497 fillValues();
498 498
499 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 499 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
500} 500}
501 501
502void NNTPconfig::slotGetNG() { 502void NNTPconfig::slotGetNG() {
503 save(); 503 save();
504 data->save(); 504 data->save();
505 NNTPwrapper* tmp = new NNTPwrapper( data ); 505 NNTPwrapper* tmp = new NNTPwrapper( data );
506 clist* list = tmp->listAllNewsgroups(); 506 clist* list = tmp->listAllNewsgroups();
507 507
508 clistcell *current; 508 clistcell *current;
509 newsnntp_group_description *group; 509 newsnntp_group_description *group;
510 510
511 // FIXME - test if not empty 511 // FIXME - test if not empty
512 current = list->first; 512 current = list->first;
513 for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { 513 for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) {
514 group = ( newsnntp_group_description* ) current->data; 514 group = ( newsnntp_group_description* ) current->data;
515 // qDebug( group->grp_name ); 515 // qDebug( group->grp_name );
516 516
517 QCheckListItem *item; 517 QCheckListItem *item;
518 item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox ); 518 item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox );
519 if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) { 519 if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) {
520 item->setSelected( true ); 520 item->setOn( true );
521 } 521 }
522 } 522 }
523} 523}
524 524
525void NNTPconfig::slotSSL( bool enabled ) 525void NNTPconfig::slotSSL( bool enabled )
526{ 526{
527 if ( enabled ) 527 if ( enabled )
528 { 528 {
529 portLine->setText( NNTP_SSL_PORT ); 529 portLine->setText( NNTP_SSL_PORT );
530 } 530 }
531 else 531 else
532 { 532 {
533 portLine->setText( NNTP_PORT ); 533 portLine->setText( NNTP_PORT );
534 } 534 }
535} 535}
536 536
537void NNTPconfig::fillValues() 537void NNTPconfig::fillValues()
538{ 538{
539 accountLine->setText( data->getAccountName() ); 539 accountLine->setText( data->getAccountName() );
540 serverLine->setText( data->getServer() ); 540 serverLine->setText( data->getServer() );
541 portLine->setText( data->getPort() ); 541 portLine->setText( data->getPort() );
542 sslBox->setChecked( data->getSSL() ); 542 sslBox->setChecked( data->getSSL() );
543 loginBox->setChecked( data->getLogin() ); 543 loginBox->setChecked( data->getLogin() );
544 userLine->setText( data->getUser() ); 544 userLine->setText( data->getUser() );
545 passLine->setText( data->getPassword() ); 545 passLine->setText( data->getPassword() );
546 subscribedGroups = data->getGroups(); 546 subscribedGroups = data->getGroups();
547} 547}
548 548
549void NNTPconfig::save() 549void NNTPconfig::save()
550{ 550{
551 data->setAccountName( accountLine->text() ); 551 data->setAccountName( accountLine->text() );
552 data->setServer( serverLine->text() ); 552 data->setServer( serverLine->text() );
553 data->setPort( portLine->text() ); 553 data->setPort( portLine->text() );
554 data->setSSL( sslBox->isChecked() ); 554 data->setSSL( sslBox->isChecked() );
555 data->setLogin( loginBox->isChecked() ); 555 data->setLogin( loginBox->isChecked() );
556 data->setUser( userLine->text() ); 556 data->setUser( userLine->text() );
557 data->setPassword( passLine->text() ); 557 data->setPassword( passLine->text() );
558 558
559 QListViewItemIterator list_it( ListViewGroups ); 559 QListViewItemIterator list_it( ListViewGroups );
560 for ( ; list_it.current(); ++list_it ) { 560
561 QStringList groupList; 561 QStringList groupList;
562 if ( list_it.current()->isSelected() ) { 562 for ( ; list_it.current(); ++list_it ) {
563
564 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
563 qDebug(list_it.current()->text(0) ); 565 qDebug(list_it.current()->text(0) );
564 groupList.append( list_it.current()->text(0) ); 566 groupList.append( list_it.current()->text(0) );
565 } 567 }
566 data->setGroups( groupList ); 568
567 } 569 }
570 data->setGroups( groupList );
568} 571}
569 572
570void NNTPconfig::accept() 573void NNTPconfig::accept()
571{ 574{
572 save(); 575 save();
573 QDialog::accept(); 576 QDialog::accept();
574} 577}
575 578
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index 2d6f9a3..ecdf848 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -63,129 +63,129 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) {
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 &, QList<RecMail> &target ) 99void NNTPwrapper::listMessages(const QString &, 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,"INBOX",&res_messages,&res_recent,&res_unseen); 105 mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
106 parseList(target,m_nntp->sto_session,"INBOX"); 106 parseList(target,m_nntp->sto_session,"INBOX");
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() ) { 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() {