-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index da7065f..b890725 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,113 +1,115 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~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!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int 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 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | qApp->processEvents(); | ||
51 | return; | ||
50 | //qDebug("imap progress %d of %d ",current,maximum ); | 52 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 53 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 54 | //qApp->processEvents() |
53 | static unsigned int last = 0; | 55 | static unsigned int last = 0; |
54 | if ( last != current ) | 56 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 57 | IMAPwrapper::progress(); |
56 | last = current; | 58 | last = current; |
57 | } | 59 | } |
58 | void IMAPwrapper::progress( QString m ) | 60 | void IMAPwrapper::progress( QString m ) |
59 | { | 61 | { |
60 | 62 | ||
61 | static QString mProgrMess; | 63 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 64 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 65 | mProgrMess = m; |
64 | mCurrent = 1; | 66 | mCurrent = 1; |
65 | return; | 67 | return; |
66 | } | 68 | } |
67 | QString mess; | 69 | QString mess; |
68 | //qDebug("progress "); | 70 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 71 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 72 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 73 | Global::statusMessage(mess); |
72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 74 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
73 | qApp->processEvents(); | 75 | qApp->processEvents(); |
74 | } | 76 | } |
75 | bool IMAPwrapper::start_tls(bool force_tls) | 77 | bool IMAPwrapper::start_tls(bool force_tls) |
76 | { | 78 | { |
77 | int err; | 79 | int err; |
78 | bool try_tls = force_tls; | 80 | bool try_tls = force_tls; |
79 | mailimap_capability_data * cap_data = 0; | 81 | mailimap_capability_data * cap_data = 0; |
80 | 82 | ||
81 | err = mailimap_capability(m_imap,&cap_data); | 83 | err = mailimap_capability(m_imap,&cap_data); |
82 | if (err != MAILIMAP_NO_ERROR) { | 84 | if (err != MAILIMAP_NO_ERROR) { |
83 | Global::statusMessage("error getting capabilities!"); | 85 | Global::statusMessage("error getting capabilities!"); |
84 | return false; | 86 | return false; |
85 | } | 87 | } |
86 | clistiter * cur; | 88 | clistiter * cur; |
87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 89 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
88 | struct mailimap_capability * cap; | 90 | struct mailimap_capability * cap; |
89 | cap = (struct mailimap_capability *)clist_content(cur); | 91 | cap = (struct mailimap_capability *)clist_content(cur); |
90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 92 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 93 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
92 | try_tls = true; | 94 | try_tls = true; |
93 | break; | 95 | break; |
94 | } | 96 | } |
95 | } | 97 | } |
96 | } | 98 | } |
97 | if (cap_data) { | 99 | if (cap_data) { |
98 | mailimap_capability_data_free(cap_data); | 100 | mailimap_capability_data_free(cap_data); |
99 | } | 101 | } |
100 | if (try_tls) { | 102 | if (try_tls) { |
101 | err = mailimap_starttls(m_imap); | 103 | err = mailimap_starttls(m_imap); |
102 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 104 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
103 | Global::statusMessage(i18n("Server has no TLS support!")); | 105 | Global::statusMessage(i18n("Server has no TLS support!")); |
104 | try_tls = false; | 106 | try_tls = false; |
105 | } else { | 107 | } else { |
106 | mailstream_low * low; | 108 | mailstream_low * low; |
107 | mailstream_low * new_low; | 109 | mailstream_low * new_low; |
108 | low = mailstream_get_low(m_imap->imap_stream); | 110 | low = mailstream_get_low(m_imap->imap_stream); |
109 | if (!low) { | 111 | if (!low) { |
110 | try_tls = false; | 112 | try_tls = false; |
111 | } else { | 113 | } else { |
112 | int fd = mailstream_low_get_fd(low); | 114 | int fd = mailstream_low_get_fd(low); |
113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 115 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |