summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
authorzautrix <zautrix>2005-08-22 18:52:57 (UTC)
committer zautrix <zautrix>2005-08-22 18:52:57 (UTC)
commitcb425b4c2d027d49f964368e94a52d3ba5e6aa31 (patch) (unidiff)
treeb867e4c565aab6965059306bac24dd3ab5ca3750 /kmicromail/libmailwrapper
parente011ace92e07174effca53b7dde20b9a5b695af0 (diff)
downloadkdepimpi-cb425b4c2d027d49f964368e94a52d3ba5e6aa31.zip
kdepimpi-cb425b4c2d027d49f964368e94a52d3ba5e6aa31.tar.gz
kdepimpi-cb425b4c2d027d49f964368e94a52d3ba5e6aa31.tar.bz2
ompi fixes
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 09e52b8..4f0c849 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -26,49 +26,48 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a )
26 26
27IMAPwrapper::~IMAPwrapper() 27IMAPwrapper::~IMAPwrapper()
28{ 28{
29 logout(); 29 logout();
30} 30}
31 31
32/* to avoid to often select statements in loops etc. 32/* to avoid to often select statements in loops etc.
33 we trust that we are logged in and connection is established!*/ 33 we trust that we are logged in and connection is established!*/
34int IMAPwrapper::selectMbox(const QString&mbox) 34int IMAPwrapper::selectMbox(const QString&mbox)
35{ 35{
36 if (mbox == m_Lastmbox) { 36 if (mbox == m_Lastmbox) {
37 return MAILIMAP_NO_ERROR; 37 return MAILIMAP_NO_ERROR;
38 } 38 }
39 int err = mailimap_select( m_imap, (char*)mbox.latin1()); 39 int err = mailimap_select( m_imap, (char*)mbox.latin1());
40 if ( err != MAILIMAP_NO_ERROR ) { 40 if ( err != MAILIMAP_NO_ERROR ) {
41 m_Lastmbox = ""; 41 m_Lastmbox = "";
42 return err; 42 return err;
43 } 43 }
44 m_Lastmbox = mbox; 44 m_Lastmbox = mbox;
45 return err; 45 return err;
46} 46}
47 47
48void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 48void IMAPwrapper::imap_progress( size_t current, size_t maximum )
49{ 49{
50 qApp->processEvents();
51 return; 50 return;
52 //qDebug("imap progress %d of %d ",current,maximum ); 51 //qDebug("imap progress %d of %d ",current,maximum );
53 //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); 52 //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum));
54 //qApp->processEvents() 53 //qApp->processEvents()
55 static unsigned int last = 0; 54 static unsigned int last = 0;
56 if ( last != current ) 55 if ( last != current )
57 IMAPwrapper::progress(); 56 IMAPwrapper::progress();
58 last = current; 57 last = current;
59} 58}
60void IMAPwrapper::progress( QString m ) 59void IMAPwrapper::progress( QString m )
61{ 60{
62 static QString mProgrMess; 61 static QString mProgrMess;
63 if ( m != QString::null ) { 62 if ( m != QString::null ) {
64 mProgrMess = m; 63 mProgrMess = m;
65 mCurrent = 1; 64 mCurrent = 1;
66 return; 65 return;
67 } 66 }
68 QString mess; 67 QString mess;
69 //qDebug("progress "); 68 //qDebug("progress ");
70 if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); 69 if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax);
71 else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); 70 else mess = mProgrMess +i18n(" message %1").arg( mCurrent++);
72 Global::statusMessage(mess); 71 Global::statusMessage(mess);
73 //qDebug("Progress %s %s", mess.latin1(), m.latin1()); 72 //qDebug("Progress %s %s", mess.latin1(), m.latin1());
74 qApp->processEvents(); 73 qApp->processEvents();
@@ -137,67 +136,66 @@ void IMAPwrapper::login(bool tryTLS) // = true)
137 if (err!=MAILIMAP_NO_ERROR) { 136 if (err!=MAILIMAP_NO_ERROR) {
138 logout(); 137 logout();
139 } else { 138 } else {
140 mailstream_flush(m_imap->imap_stream); 139 mailstream_flush(m_imap->imap_stream);
141 return; 140 return;
142 } 141 }
143 } 142 }
144 server = account->getServer(); 143 server = account->getServer();
145 port = account->getPort().toUInt(); 144 port = account->getPort().toUInt();
146 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 145 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
147 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 146 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
148 login.show(); 147 login.show();
149 if ( QDialog::Accepted == login.exec() ) { 148 if ( QDialog::Accepted == login.exec() ) {
150 // ok 149 // ok
151 user = login.getUser(); 150 user = login.getUser();
152 pass = login.getPassword(); 151 pass = login.getPassword();
153 } else { 152 } else {
154 // cancel 153 // cancel
155 return; 154 return;
156 } 155 }
157 } else { 156 } else {
158 user = account->getUser(); 157 user = account->getUser();
159 pass = account->getPassword(); 158 pass = account->getPassword();
160 } 159 }
161
162 m_imap = mailimap_new( 20, &imap_progress ); 160 m_imap = mailimap_new( 20, &imap_progress );
163 161
164 /* connect */ 162 /* connect */
165 bool ssl = false; 163 bool ssl = false;
166 bool try_tls = false; 164 bool try_tls = false;
167 bool force_tls = false; 165 bool force_tls = false;
168 166
169 if ( account->ConnectionType() == 2 ) { 167 if ( account->ConnectionType() == 2 ) {
170 ssl = true; 168 ssl = true;
171 } 169 }
172 if (account->ConnectionType()==1) { 170 if (account->ConnectionType()==1) {
173 force_tls = true; 171 force_tls = true;
174 } 172 }
175 173
176 if ( ssl ) { 174 if ( ssl ) {
177 qDebug("using ssl "); 175 //qDebug("using ssl ");
178 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); 176 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port );
179 qDebug("back "); 177 //qDebug("back ");
180 } else { 178 } else {
181 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); 179 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port );
182 } 180 }
183 181
184 if ( err != MAILIMAP_NO_ERROR && 182 if ( err != MAILIMAP_NO_ERROR &&
185 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 183 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
186 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 184 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
187 QString failure = ""; 185 QString failure = "";
188 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { 186 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
189 failure="Connection refused"; 187 failure="Connection refused";
190 } else { 188 } else {
191 failure="Unknown failure"; 189 failure="Unknown failure";
192 } 190 }
193 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); 191 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure));
194 mailimap_free( m_imap ); 192 mailimap_free( m_imap );
195 m_imap = 0; 193 m_imap = 0;
196 return; 194 return;
197 } 195 }
198 if ( tryTLS ) { 196 if ( tryTLS ) {
199 if (!ssl) { 197 if (!ssl) {
200 try_tls = start_tls(force_tls); 198 try_tls = start_tls(force_tls);
201 } 199 }
202 } 200 }
203 bool ok = true; 201 bool ok = true;