Diffstat (limited to 'noncore/net/mail/libmailwrapper/nntpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index cfded43..5d5011a 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -8,66 +8,66 @@ | |||
8 | 8 | ||
9 | #include <libetpan/libetpan.h> | 9 | #include <libetpan/libetpan.h> |
10 | 10 | ||
11 | 11 | ||
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 12 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 13 | ||
14 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
15 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 15 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
16 | : Genericwrapper() { | 16 | : Genericwrapper() { |
17 | account = a; | 17 | account = a; |
18 | m_nntp = NULL; | 18 | m_nntp = NULL; |
19 | msgTempName = a->getFileName()+"_msg_cache"; | 19 | msgTempName = a->getFileName()+"_msg_cache"; |
20 | last_msg_id = 0; | 20 | last_msg_id = 0; |
21 | } | 21 | } |
22 | 22 | ||
23 | NNTPwrapper::~NNTPwrapper() { | 23 | NNTPwrapper::~NNTPwrapper() { |
24 | logout(); | 24 | logout(); |
25 | QFile msg_cache(msgTempName); | 25 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 26 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 27 | msg_cache.remove(); |
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
32 | qDebug( "NNTP: %i of %i", current, maximum ); | 32 | odebug << "NNTP: " << current << " of " << maximum << "" << oendl; |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | 36 | RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { |
37 | int err = NEWSNNTP_NO_ERROR; | 37 | int err = NEWSNNTP_NO_ERROR; |
38 | char *message = 0; | 38 | char *message = 0; |
39 | size_t length = 0; | 39 | size_t length = 0; |
40 | 40 | ||
41 | RecBodyP body = new RecBody(); | 41 | RecBodyP body = new RecBody(); |
42 | login(); | 42 | login(); |
43 | if ( !m_nntp ) { | 43 | if ( !m_nntp ) { |
44 | return body; | 44 | return body; |
45 | } | 45 | } |
46 | 46 | ||
47 | mailmessage * mailmsg; | 47 | mailmessage * mailmsg; |
48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
49 | qDebug("Message to large: %i",mail->Msgsize()); | 49 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; |
50 | return body; | 50 | return body; |
51 | } | 51 | } |
52 | 52 | ||
53 | QFile msg_cache(msgTempName); | 53 | QFile msg_cache(msgTempName); |
54 | 54 | ||
55 | cleanMimeCache(); | 55 | cleanMimeCache(); |
56 | 56 | ||
57 | if (mail->getNumber()!=last_msg_id) { | 57 | if (mail->getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 58 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 59 | msg_cache.remove(); |
60 | } | 60 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 61 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail->getNumber(); | 62 | last_msg_id = mail->getNumber(); |
63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
64 | err = mailmessage_fetch(mailmsg,&message,&length); | 64 | err = mailmessage_fetch(mailmsg,&message,&length); |
65 | msg_cache.writeBlock(message,length); | 65 | msg_cache.writeBlock(message,length); |
66 | } else { | 66 | } else { |
67 | QString msg=""; | 67 | QString msg=""; |
68 | msg_cache.open(IO_ReadOnly); | 68 | msg_cache.open(IO_ReadOnly); |
69 | message = new char[4096]; | 69 | message = new char[4096]; |
70 | memset(message,0,4096); | 70 | memset(message,0,4096); |
71 | while (msg_cache.readBlock(message,4095)>0) { | 71 | while (msg_cache.readBlock(message,4095)>0) { |
72 | msg+=message; | 72 | msg+=message; |
73 | memset(message,0,4096); | 73 | memset(message,0,4096); |
@@ -113,86 +113,86 @@ void NNTPwrapper::login() | |||
113 | return; | 113 | return; |
114 | /* we'll hold the line */ | 114 | /* we'll hold the line */ |
115 | if ( m_nntp != NULL ) | 115 | if ( m_nntp != NULL ) |
116 | return; | 116 | return; |
117 | 117 | ||
118 | const char *server, *user, *pass; | 118 | const char *server, *user, *pass; |
119 | QString User,Pass; | 119 | QString User,Pass; |
120 | uint16_t port; | 120 | uint16_t port; |
121 | int err = NEWSNNTP_NO_ERROR; | 121 | int err = NEWSNNTP_NO_ERROR; |
122 | 122 | ||
123 | server = account->getServer().latin1(); | 123 | server = account->getServer().latin1(); |
124 | port = account->getPort().toUInt(); | 124 | port = account->getPort().toUInt(); |
125 | 125 | ||
126 | user = pass = 0; | 126 | user = pass = 0; |
127 | 127 | ||
128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 130 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 131 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 132 | // ok |
133 | User = login.getUser().latin1(); | 133 | User = login.getUser().latin1(); |
134 | Pass = login.getPassword().latin1(); | 134 | Pass = login.getPassword().latin1(); |
135 | } else { | 135 | } else { |
136 | // cancel | 136 | // cancel |
137 | qDebug( "NNTP: Login canceled" ); | 137 | odebug << "NNTP: Login canceled" << oendl; |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | User = account->getUser().latin1(); | 141 | User = account->getUser().latin1(); |
142 | Pass = account->getPassword().latin1(); | 142 | Pass = account->getPassword().latin1(); |
143 | } | 143 | } |
144 | 144 | ||
145 | if (User.isEmpty()) { | 145 | if (User.isEmpty()) { |
146 | user=0; | 146 | user=0; |
147 | pass = 0; | 147 | pass = 0; |
148 | } else { | 148 | } else { |
149 | user=User.latin1(); | 149 | user=User.latin1(); |
150 | pass=Pass.latin1(); | 150 | pass=Pass.latin1(); |
151 | } | 151 | } |
152 | // bool ssl = account->getSSL(); | 152 | // bool ssl = account->getSSL(); |
153 | 153 | ||
154 | m_nntp=mailstorage_new(NULL); | 154 | m_nntp=mailstorage_new(NULL); |
155 | 155 | ||
156 | int conntypeset = account->ConnectionType(); | 156 | int conntypeset = account->ConnectionType(); |
157 | int conntype = 0; | 157 | int conntype = 0; |
158 | if ( conntypeset == 3 ) { | 158 | if ( conntypeset == 3 ) { |
159 | conntype = CONNECTION_TYPE_COMMAND; | 159 | conntype = CONNECTION_TYPE_COMMAND; |
160 | } else if ( conntypeset == 2 ) { | 160 | } else if ( conntypeset == 2 ) { |
161 | conntype = CONNECTION_TYPE_TLS; | 161 | conntype = CONNECTION_TYPE_TLS; |
162 | } else if ( conntypeset == 1 ) { | 162 | } else if ( conntypeset == 1 ) { |
163 | conntype = CONNECTION_TYPE_STARTTLS; | 163 | conntype = CONNECTION_TYPE_STARTTLS; |
164 | } else if ( conntypeset == 0 ) { | 164 | } else if ( conntypeset == 0 ) { |
165 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 165 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
166 | } | 166 | } |
167 | 167 | ||
168 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 168 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
169 | (char*)user,(char*)pass,0,0,0); | 169 | (char*)user,(char*)pass,0,0,0); |
170 | 170 | ||
171 | err = mailstorage_connect( m_nntp ); | 171 | err = mailstorage_connect( m_nntp ); |
172 | 172 | ||
173 | if (err != NEWSNNTP_NO_ERROR) { | 173 | if (err != NEWSNNTP_NO_ERROR) { |
174 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 174 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
175 | // Global::statusMessage(tr("Error initializing folder")); | 175 | // Global::statusMessage(tr("Error initializing folder")); |
176 | mailstorage_free(m_nntp); | 176 | mailstorage_free(m_nntp); |
177 | m_nntp = 0; | 177 | m_nntp = 0; |
178 | 178 | ||
179 | } else { | 179 | } else { |
180 | mailsession * session = m_nntp->sto_session; | 180 | mailsession * session = m_nntp->sto_session; |
181 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 181 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
182 | news->nntp_progr_fun = &nntp_progress; | 182 | news->nntp_progr_fun = &nntp_progress; |
183 | } | 183 | } |
184 | 184 | ||
185 | } | 185 | } |
186 | 186 | ||
187 | void NNTPwrapper::logout() | 187 | void NNTPwrapper::logout() |
188 | { | 188 | { |
189 | int err = NEWSNNTP_NO_ERROR; | 189 | int err = NEWSNNTP_NO_ERROR; |
190 | if ( m_nntp == NULL ) | 190 | if ( m_nntp == NULL ) |
191 | return; | 191 | return; |
192 | mailstorage_free(m_nntp); | 192 | mailstorage_free(m_nntp); |
193 | m_nntp = 0; | 193 | m_nntp = 0; |
194 | } | 194 | } |
195 | 195 | ||
196 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 196 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
197 | 197 | ||
198 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 198 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |