Diffstat (limited to 'kmicromail/libmailwrapper/nntpwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp index f5d7f16..93cd2b5 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.cpp +++ b/kmicromail/libmailwrapper/nntpwrapper.cpp | |||
@@ -96,100 +96,91 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
96 | free(message); | 96 | free(message); |
97 | 97 | ||
98 | return body; | 98 | return body; |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) | 102 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) |
103 | { | 103 | { |
104 | login(); | 104 | login(); |
105 | if (!m_nntp) | 105 | if (!m_nntp) |
106 | return; | 106 | return; |
107 | uint32_t res_messages,res_recent,res_unseen; | 107 | uint32_t res_messages,res_recent,res_unseen; |
108 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 108 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
109 | parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); | 109 | parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); |
110 | } | 110 | } |
111 | 111 | ||
112 | void NNTPwrapper::login() | 112 | void NNTPwrapper::login() |
113 | { | 113 | { |
114 | if (account->getOffline()) | 114 | if (account->getOffline()) |
115 | return; | 115 | return; |
116 | /* we'll hold the line */ | 116 | /* we'll hold the line */ |
117 | if ( m_nntp != NULL ) | 117 | if ( m_nntp != NULL ) |
118 | return; | 118 | return; |
119 | 119 | ||
120 | const char *server, *user, *pass; | 120 | QString server; |
121 | QString User,Pass; | 121 | QString User,Pass; |
122 | uint16_t port; | 122 | uint16_t port; |
123 | int err = NEWSNNTP_NO_ERROR; | 123 | int err = NEWSNNTP_NO_ERROR; |
124 | 124 | ||
125 | server = account->getServer().latin1(); | 125 | server = account->getServer(); |
126 | port = account->getPort().toUInt(); | 126 | port = account->getPort().toUInt(); |
127 | 127 | ||
128 | user = pass = 0; | ||
129 | |||
130 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
131 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
132 | login.show(); | 130 | login.show(); |
133 | if ( QDialog::Accepted == login.exec() ) { | 131 | if ( QDialog::Accepted == login.exec() ) { |
134 | // ok | 132 | // ok |
135 | User = login.getUser().latin1(); | 133 | User = login.getUser(); |
136 | Pass = login.getPassword().latin1(); | 134 | Pass = login.getPassword(); |
137 | } else { | 135 | } else { |
138 | // cancel | 136 | // cancel |
139 | ; // << "NNTP: Login canceled" << oendl; | 137 | ; // << "NNTP: Login canceled" << oendl; |
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | } else { | 140 | } else { |
143 | User = account->getUser().latin1(); | 141 | User = account->getUser(); |
144 | Pass = account->getPassword().latin1(); | 142 | Pass = account->getPassword(); |
145 | } | 143 | } |
146 | 144 | ||
147 | if (User.isEmpty()) { | ||
148 | user=0; | ||
149 | pass = 0; | ||
150 | } else { | ||
151 | user=User.latin1(); | ||
152 | pass=Pass.latin1(); | ||
153 | } | ||
154 | // bool ssl = account->getSSL(); | 145 | // bool ssl = account->getSSL(); |
155 | 146 | ||
156 | m_nntp=mailstorage_new(NULL); | 147 | m_nntp=mailstorage_new(NULL); |
157 | 148 | ||
158 | int conntypeset = account->ConnectionType(); | 149 | int conntypeset = account->ConnectionType(); |
159 | int conntype = 0; | 150 | int conntype = 0; |
160 | if ( conntypeset == 3 ) { | 151 | if ( conntypeset == 3 ) { |
161 | conntype = CONNECTION_TYPE_COMMAND; | 152 | conntype = CONNECTION_TYPE_COMMAND; |
162 | } else if ( conntypeset == 2 ) { | 153 | } else if ( conntypeset == 2 ) { |
163 | conntype = CONNECTION_TYPE_TLS; | 154 | conntype = CONNECTION_TYPE_TLS; |
164 | } else if ( conntypeset == 1 ) { | 155 | } else if ( conntypeset == 1 ) { |
165 | conntype = CONNECTION_TYPE_STARTTLS; | 156 | conntype = CONNECTION_TYPE_STARTTLS; |
166 | } else if ( conntypeset == 0 ) { | 157 | } else if ( conntypeset == 0 ) { |
167 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 158 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
168 | } | 159 | } |
169 | 160 | ||
170 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 161 | nntp_mailstorage_init(m_nntp,(char*)server.latin1(), port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
171 | (char*)user,(char*)pass,0,0,0); | 162 | (char*)User.latin1(),(char*)Pass.latin1(),0,0,0); |
172 | 163 | ||
173 | err = mailstorage_connect( m_nntp ); | 164 | err = mailstorage_connect( m_nntp ); |
174 | 165 | ||
175 | if (err != NEWSNNTP_NO_ERROR) { | 166 | if (err != NEWSNNTP_NO_ERROR) { |
176 | ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 167 | ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
177 | // Global::statusMessage(tr("Error initializing folder")); | 168 | // Global::statusMessage(tr("Error initializing folder")); |
178 | mailstorage_free(m_nntp); | 169 | mailstorage_free(m_nntp); |
179 | m_nntp = 0; | 170 | m_nntp = 0; |
180 | 171 | ||
181 | } else { | 172 | } else { |
182 | mailsession * session = m_nntp->sto_session; | 173 | mailsession * session = m_nntp->sto_session; |
183 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 174 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
184 | news->nntp_progr_fun = &nntp_progress; | 175 | news->nntp_progr_fun = &nntp_progress; |
185 | } | 176 | } |
186 | 177 | ||
187 | } | 178 | } |
188 | 179 | ||
189 | void NNTPwrapper::logout() | 180 | void NNTPwrapper::logout() |
190 | { | 181 | { |
191 | int err = NEWSNNTP_NO_ERROR; | 182 | int err = NEWSNNTP_NO_ERROR; |
192 | if ( m_nntp == NULL ) | 183 | if ( m_nntp == NULL ) |
193 | return; | 184 | return; |
194 | mailstorage_free(m_nntp); | 185 | mailstorage_free(m_nntp); |
195 | m_nntp = 0; | 186 | m_nntp = 0; |