author | alwin <alwin> | 2004-03-05 13:15:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-05 13:15:15 (UTC) |
commit | 4a18103940564be8585af8121203561e16f0a32c (patch) (side-by-side diff) | |
tree | a3abb3b7b80674ddb956847e2ae7e1b42fa78301 | |
parent | 5af6bb27d2ba6a1d00fd0a6df0550d02164f87e6 (diff) | |
download | opie-4a18103940564be8585af8121203561e16f0a32c.zip opie-4a18103940564be8585af8121203561e16f0a32c.tar.gz opie-4a18103940564be8585af8121203561e16f0a32c.tar.bz2 |
could hold pointer to destructed content
connection problem fixed as quick hack, must done better or real.
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index c68964d..54e0ed4 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp @@ -72,136 +72,146 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { while (msg_cache.readBlock(message,4095)>0) { msg+=message; memset(message,0,4096); } delete message; message = (char*)malloc(msg.length()+1*sizeof(char)); memset(message,0,msg.length()+1); memcpy(message,msg.latin1(),msg.length()); /* transform to libetpan stuff */ mailmsg = mailmessage_new(); mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); generic_message_t * msg_data; msg_data = (generic_message_t *)mailmsg->msg_data; msg_data->msg_fetched = 1; msg_data->msg_message = message; msg_data->msg_length = strlen(message); } body = parseMail(mailmsg); /* clean up */ if (mailmsg) mailmessage_free(mailmsg); if (message) free(message); return body; } void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) { login(); if (!m_nntp) return; uint32_t res_messages,res_recent,res_unseen; mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); parseList(target,m_nntp->sto_session,"INBOX"); } void NNTPwrapper::login() { if (account->getOffline()) return; /* we'll hold the line */ if ( m_nntp != NULL ) return; const char *server, *user, *pass; + QString User,Pass; uint16_t port; int err = NEWSNNTP_NO_ERROR; server = account->getServer().latin1(); port = account->getPort().toUInt(); + user = pass = 0; + if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok - user = login.getUser().latin1(); - pass = login.getPassword().latin1(); + User = login.getUser().latin1(); + Pass = login.getPassword().latin1(); } else { // cancel qDebug( "NNTP: Login canceled" ); return; } } else { - user = account->getUser().latin1(); - pass = account->getPassword().latin1(); + User = account->getUser().latin1(); + Pass = account->getPassword().latin1(); } + if (User.isEmpty()) { + user=0; + pass = 0; + } else { + user=User.latin1(); + pass=Pass.latin1(); + } // bool ssl = account->getSSL(); m_nntp=mailstorage_new(NULL); int conntypeset = account->ConnectionType(); int conntype = 0; if ( conntypeset == 3 ) { conntype = CONNECTION_TYPE_COMMAND; } else if ( conntypeset == 2 ) { conntype = CONNECTION_TYPE_TLS; } else if ( conntypeset == 1 ) { conntype = CONNECTION_TYPE_STARTTLS; } else if ( conntypeset == 0 ) { conntype = CONNECTION_TYPE_TRY_STARTTLS; } - nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, conntype, NNTP_AUTH_TYPE_PLAIN, + nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, (char*)user,(char*)pass,0,0,0); err = mailstorage_connect( m_nntp ); if (err != NEWSNNTP_NO_ERROR) { qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); // Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_nntp); m_nntp = 0; } } void NNTPwrapper::logout() { int err = NEWSNNTP_NO_ERROR; if ( m_nntp == NULL ) return; mailstorage_free(m_nntp); m_nntp = 0; } QList<Folder>* NNTPwrapper::listFolders() { QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( false ); clist *result = 0; clistcell *current; newsnntp_group_description *list; login(); if ( m_nntp ) { mailsession * session = m_nntp->sto_session; newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; int err = newsnntp_list_newsgroups(news, NULL, &result); if ( err == NEWSNNTP_NO_ERROR ) { current = result->first; for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { list = ( newsnntp_group_description* ) current->data; qDebug( list->grp_name ); } // Folder*inb=new Folder("INBOX","/"); } |