summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp20
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
@@ -88,104 +88,114 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) {
88 } 88 }
89 body = parseMail(mailmsg); 89 body = parseMail(mailmsg);
90 90
91 /* clean up */ 91 /* clean up */
92 if (mailmsg) 92 if (mailmsg)
93 mailmessage_free(mailmsg); 93 mailmessage_free(mailmsg);
94 if (message) 94 if (message)
95 free(message); 95 free(message);
96 96
97 return body; 97 return body;
98} 98}
99 99
100 100
101void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) 101void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target )
102{ 102{
103 login(); 103 login();
104 if (!m_nntp) 104 if (!m_nntp)
105 return; 105 return;
106 uint32_t res_messages,res_recent,res_unseen; 106 uint32_t res_messages,res_recent,res_unseen;
107 mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 107 mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
108 parseList(target,m_nntp->sto_session,"INBOX"); 108 parseList(target,m_nntp->sto_session,"INBOX");
109} 109}
110 110
111void NNTPwrapper::login() 111void NNTPwrapper::login()
112{ 112{
113 if (account->getOffline()) 113 if (account->getOffline())
114 return; 114 return;
115 /* we'll hold the line */ 115 /* we'll hold the line */
116 if ( m_nntp != NULL ) 116 if ( m_nntp != NULL )
117 return; 117 return;
118 118
119 const char *server, *user, *pass; 119 const char *server, *user, *pass;
120 QString User,Pass;
120 uint16_t port; 121 uint16_t port;
121 int err = NEWSNNTP_NO_ERROR; 122 int err = NEWSNNTP_NO_ERROR;
122 123
123 server = account->getServer().latin1(); 124 server = account->getServer().latin1();
124 port = account->getPort().toUInt(); 125 port = account->getPort().toUInt();
125 126
127 user = pass = 0;
128
126 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 129 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
127 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
128 login.show(); 131 login.show();
129 if ( QDialog::Accepted == login.exec() ) { 132 if ( QDialog::Accepted == login.exec() ) {
130 // ok 133 // ok
131 user = login.getUser().latin1(); 134 User = login.getUser().latin1();
132 pass = login.getPassword().latin1(); 135 Pass = login.getPassword().latin1();
133 } else { 136 } else {
134 // cancel 137 // cancel
135 qDebug( "NNTP: Login canceled" ); 138 qDebug( "NNTP: Login canceled" );
136 return; 139 return;
137 } 140 }
138 } else { 141 } else {
139 user = account->getUser().latin1(); 142 User = account->getUser().latin1();
140 pass = account->getPassword().latin1(); 143 Pass = account->getPassword().latin1();
141 } 144 }
142 145
146 if (User.isEmpty()) {
147 user=0;
148 pass = 0;
149 } else {
150 user=User.latin1();
151 pass=Pass.latin1();
152 }
143 // bool ssl = account->getSSL(); 153 // bool ssl = account->getSSL();
144 154
145 m_nntp=mailstorage_new(NULL); 155 m_nntp=mailstorage_new(NULL);
146 156
147 int conntypeset = account->ConnectionType(); 157 int conntypeset = account->ConnectionType();
148 int conntype = 0; 158 int conntype = 0;
149 if ( conntypeset == 3 ) { 159 if ( conntypeset == 3 ) {
150 conntype = CONNECTION_TYPE_COMMAND; 160 conntype = CONNECTION_TYPE_COMMAND;
151 } else if ( conntypeset == 2 ) { 161 } else if ( conntypeset == 2 ) {
152 conntype = CONNECTION_TYPE_TLS; 162 conntype = CONNECTION_TYPE_TLS;
153 } else if ( conntypeset == 1 ) { 163 } else if ( conntypeset == 1 ) {
154 conntype = CONNECTION_TYPE_STARTTLS; 164 conntype = CONNECTION_TYPE_STARTTLS;
155 } else if ( conntypeset == 0 ) { 165 } else if ( conntypeset == 0 ) {
156 conntype = CONNECTION_TYPE_TRY_STARTTLS; 166 conntype = CONNECTION_TYPE_TRY_STARTTLS;
157 } 167 }
158 168
159 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, conntype, NNTP_AUTH_TYPE_PLAIN, 169 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN,
160 (char*)user,(char*)pass,0,0,0); 170 (char*)user,(char*)pass,0,0,0);
161 171
162 err = mailstorage_connect( m_nntp ); 172 err = mailstorage_connect( m_nntp );
163 173
164 if (err != NEWSNNTP_NO_ERROR) { 174 if (err != NEWSNNTP_NO_ERROR) {
165 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); 175 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
166 // Global::statusMessage(tr("Error initializing folder")); 176 // Global::statusMessage(tr("Error initializing folder"));
167 mailstorage_free(m_nntp); 177 mailstorage_free(m_nntp);
168 m_nntp = 0; 178 m_nntp = 0;
169 179
170 } 180 }
171 181
172} 182}
173 183
174void NNTPwrapper::logout() 184void NNTPwrapper::logout()
175{ 185{
176 int err = NEWSNNTP_NO_ERROR; 186 int err = NEWSNNTP_NO_ERROR;
177 if ( m_nntp == NULL ) 187 if ( m_nntp == NULL )
178 return; 188 return;
179 mailstorage_free(m_nntp); 189 mailstorage_free(m_nntp);
180 m_nntp = 0; 190 m_nntp = 0;
181} 191}
182 192
183QList<Folder>* NNTPwrapper::listFolders() { 193QList<Folder>* NNTPwrapper::listFolders() {
184 194
185 195
186 196
187 197
188 QList<Folder> * folders = new QList<Folder>(); 198 QList<Folder> * folders = new QList<Folder>();
189 folders->setAutoDelete( false ); 199 folders->setAutoDelete( false );
190 clist *result = 0; 200 clist *result = 0;
191 clistcell *current; 201 clistcell *current;