Diffstat (limited to 'kmicromail/libmailwrapper/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index f430121..8d2f778 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -117,29 +117,29 @@ void POP3wrapper::login() | |||
117 | /* we'll hold the line */ | 117 | /* we'll hold the line */ |
118 | if ( m_pop3 != NULL ) | 118 | if ( m_pop3 != NULL ) |
119 | return; | 119 | return; |
120 | 120 | ||
121 | QString server,user, pass; | 121 | QString server,user, pass; |
122 | uint16_t port; | 122 | uint16_t port; |
123 | int err = MAILPOP3_NO_ERROR; | 123 | int err = MAILPOP3_NO_ERROR; |
124 | 124 | ||
125 | server = account->getServer().latin1(); | 125 | server = account->getServer().latin1(); |
126 | port = account->getPort().toUInt(); | 126 | port = account->getPort().toUInt(); |
127 | 127 | ||
128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
129 | qApp->processEvents(); | ||
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 130 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 131 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 132 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 133 | // ok |
133 | qDebug("ok "); | ||
134 | user = login.getUser(); | 134 | user = login.getUser(); |
135 | pass = login.getPassword(); | 135 | pass = login.getPassword(); |
136 | } else { | 136 | } else { |
137 | // cancel | 137 | // cancel |
138 | ; // odebug << "POP3: Login canceled" << oendl; | 138 | ; // odebug << "POP3: Login canceled" << oendl; |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | } else { | 141 | } else { |
142 | user = account->getUser(); | 142 | user = account->getUser(); |
143 | pass = account->getPassword(); | 143 | pass = account->getPassword(); |
144 | } | 144 | } |
145 | // bool ssl = account->getSSL(); | 145 | // bool ssl = account->getSSL(); |
@@ -156,25 +156,25 @@ void POP3wrapper::login() | |||
156 | } else if ( conntypeset == 0 ) { | 156 | } else if ( conntypeset == 0 ) { |
157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
158 | } | 158 | } |
159 | 159 | ||
160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
161 | 161 | ||
162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); | 163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); |
164 | 164 | ||
165 | err = mailstorage_connect(m_pop3); | 165 | err = mailstorage_connect(m_pop3); |
166 | if (err != MAIL_NO_ERROR) { | 166 | if (err != MAIL_NO_ERROR) { |
167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
168 | Global::statusMessage(tr("Error initializing folder")); | 168 | Global::statusMessage(tr("Error %1 initializing folder").arg( err )); |
169 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 170 | m_pop3 = 0; |
171 | } else { | 171 | } else { |
172 | mailsession * session = m_pop3->sto_session; | 172 | mailsession * session = m_pop3->sto_session; |
173 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 173 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
174 | if (mail) { | 174 | if (mail) { |
175 | mail->pop3_progr_fun = &pop3_progress; | 175 | mail->pop3_progr_fun = &pop3_progress; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void POP3wrapper::logout() | 180 | void POP3wrapper::logout() |
@@ -191,42 +191,29 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | |||
191 | FolderP inb=new Folder("INBOX","/"); | 191 | FolderP inb=new Folder("INBOX","/"); |
192 | folders->append(inb); | 192 | folders->append(inb); |
193 | return folders; | 193 | return folders; |
194 | } | 194 | } |
195 | 195 | ||
196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) | 196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) |
197 | { | 197 | { |
198 | login(); | 198 | login(); |
199 | if (!m_pop3) | 199 | if (!m_pop3) |
200 | return; | 200 | return; |
201 | int iii = 0; | 201 | int iii = 0; |
202 | int count = target.count(); | 202 | int count = target.count(); |
203 | QProgressBar bar( count,0 ); | 203 | QWidget wid; |
204 | bar.setCaption (("Removing mails - close to abort!") ); | 204 | wid.show(); |
205 | int w = 300; | ||
206 | if ( QApplication::desktop()->width() < 320 ) | ||
207 | w = 220; | ||
208 | int h = bar.sizeHint().height() ; | ||
209 | int dw = QApplication::desktop()->width(); | ||
210 | int dh = QApplication::desktop()->height(); | ||
211 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
212 | bar.show(); | ||
213 | int modulo = (count/10)+1; | ||
214 | int incCounter = 0; | ||
215 | while (iii < count ) { | 205 | while (iii < count ) { |
216 | if ( ! bar.isVisible() ) | 206 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
217 | return ; | 207 | wid.raise(); |
218 | if ( incCounter % modulo == 0 ) | ||
219 | bar.setProgress( incCounter ); | ||
220 | ++incCounter; | ||
221 | qApp->processEvents(); | 208 | qApp->processEvents(); |
222 | //qDebug("delete "); | 209 | //qDebug("delete "); |
223 | RecMailP mail = (*target.at( iii )); | 210 | RecMailP mail = (*target.at( iii )); |
224 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 211 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
225 | if (err != MAIL_NO_ERROR) { | 212 | if (err != MAIL_NO_ERROR) { |
226 | Global::statusMessage(tr("Error deleting mail")); | 213 | Global::statusMessage(tr("Error deleting mail")); |
227 | } | 214 | } |
228 | ++iii; | 215 | ++iii; |
229 | } | 216 | } |
230 | } | 217 | } |
231 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 218 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
232 | login(); | 219 | login(); |
@@ -243,43 +230,31 @@ void POP3wrapper::answeredMail(const RecMailP&) {} | |||
243 | int POP3wrapper::deleteAllMail(const FolderP&) { | 230 | int POP3wrapper::deleteAllMail(const FolderP&) { |
244 | login(); | 231 | login(); |
245 | if (!m_pop3) | 232 | if (!m_pop3) |
246 | return 0; | 233 | return 0; |
247 | int res = 1; | 234 | int res = 1; |
248 | 235 | ||
249 | uint32_t result = 0; | 236 | uint32_t result = 0; |
250 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 237 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
251 | if (err != MAIL_NO_ERROR) { | 238 | if (err != MAIL_NO_ERROR) { |
252 | Global::statusMessage(tr("Error getting folder info")); | 239 | Global::statusMessage(tr("Error getting folder info")); |
253 | return 0; | 240 | return 0; |
254 | } | 241 | } |
255 | QProgressBar bar( result,0 ); | 242 | QWidget wid; |
256 | bar.setCaption (("Deleting mails - close to abort!") ); | 243 | wid.show(); |
257 | int w = 300; | 244 | for (unsigned int i = 0; i < result; ++i) { |
258 | if ( QApplication::desktop()->width() < 320 ) | 245 | Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); |
259 | w = 220; | 246 | wid.raise(); |
260 | int h = bar.sizeHint().height() ; | ||
261 | int dw = QApplication::desktop()->width(); | ||
262 | int dh = QApplication::desktop()->height(); | ||
263 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
264 | bar.show(); | ||
265 | int modulo = (result/10)+1; | ||
266 | int incCounter = 0; | ||
267 | for (unsigned int i = 0; i < result; ++i) { | ||
268 | if ( ! bar.isVisible() ) | ||
269 | return 0; | ||
270 | if ( incCounter % modulo == 0 ) | ||
271 | bar.setProgress( incCounter ); | ||
272 | ++incCounter; | ||
273 | qApp->processEvents(); | 247 | qApp->processEvents(); |
248 | |||
274 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 249 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
275 | if (err != MAIL_NO_ERROR) { | 250 | if (err != MAIL_NO_ERROR) { |
276 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 251 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
277 | res=0; | 252 | res=0; |
278 | } | 253 | } |
279 | break; | 254 | break; |
280 | } | 255 | } |
281 | return res; | 256 | return res; |
282 | } | 257 | } |
283 | 258 | ||
284 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 259 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
285 | login(); | 260 | login(); |