Diffstat (limited to 'kmicromail/libmailwrapper/nntpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp index 93cd2b5..b328ecd 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.cpp +++ b/kmicromail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,18 +1,20 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "nntpwrapper.h" | 2 | #include "nntpwrapper.h" |
3 | #include "logindialog.h" | 3 | #include "logindialog.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | //Added by qt3to4: | ||
8 | #include <Q3ValueList> | ||
7 | 9 | ||
8 | #include <stdlib.h> | 10 | #include <stdlib.h> |
9 | 11 | ||
10 | #include <libetpan/libetpan.h> | 12 | #include <libetpan/libetpan.h> |
11 | 13 | ||
12 | 14 | ||
13 | 15 | ||
14 | #define HARD_MSG_SIZE_LIMIT 5242880 | 16 | #define HARD_MSG_SIZE_LIMIT 5242880 |
15 | 17 | ||
16 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
17 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 19 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
18 | : Genericwrapper() { | 20 | : Genericwrapper() { |
@@ -51,32 +53,32 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
51 | ; // << "Message to large: " << mail->Msgsize() << "" << oendl; | 53 | ; // << "Message to large: " << mail->Msgsize() << "" << oendl; |
52 | return body; | 54 | return body; |
53 | } | 55 | } |
54 | 56 | ||
55 | QFile msg_cache(msgTempName); | 57 | QFile msg_cache(msgTempName); |
56 | 58 | ||
57 | cleanMimeCache(); | 59 | cleanMimeCache(); |
58 | 60 | ||
59 | if (mail->getNumber()!=last_msg_id) { | 61 | if (mail->getNumber()!=last_msg_id) { |
60 | if (msg_cache.exists()) { | 62 | if (msg_cache.exists()) { |
61 | msg_cache.remove(); | 63 | msg_cache.remove(); |
62 | } | 64 | } |
63 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 65 | msg_cache.open(QIODevice::ReadWrite|QIODevice::Truncate); |
64 | last_msg_id = mail->getNumber(); | 66 | last_msg_id = mail->getNumber(); |
65 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 67 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
66 | err = mailmessage_fetch(mailmsg,&message,&length); | 68 | err = mailmessage_fetch(mailmsg,&message,&length); |
67 | msg_cache.writeBlock(message,length); | 69 | msg_cache.writeBlock(message,length); |
68 | } else { | 70 | } else { |
69 | QString msg=""; | 71 | QString msg=""; |
70 | msg_cache.open(IO_ReadOnly); | 72 | msg_cache.open(QIODevice::ReadOnly); |
71 | message = new char[4096]; | 73 | message = new char[4096]; |
72 | memset(message,0,4096); | 74 | memset(message,0,4096); |
73 | while (msg_cache.readBlock(message,4095)>0) { | 75 | while (msg_cache.readBlock(message,4095)>0) { |
74 | msg+=message; | 76 | msg+=message; |
75 | memset(message,0,4096); | 77 | memset(message,0,4096); |
76 | } | 78 | } |
77 | delete message; | 79 | delete message; |
78 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 80 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
79 | memset(message,0,msg.length()+1); | 81 | memset(message,0,msg.length()+1); |
80 | memcpy(message,msg.latin1(),msg.length()); | 82 | memcpy(message,msg.latin1(),msg.length()); |
81 | /* transform to libetpan stuff */ | 83 | /* transform to libetpan stuff */ |
82 | mailmsg = mailmessage_new(); | 84 | mailmsg = mailmessage_new(); |
@@ -90,25 +92,25 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
90 | body = parseMail(mailmsg); | 92 | body = parseMail(mailmsg); |
91 | 93 | ||
92 | /* clean up */ | 94 | /* clean up */ |
93 | if (mailmsg) | 95 | if (mailmsg) |
94 | mailmessage_free(mailmsg); | 96 | mailmessage_free(mailmsg); |
95 | if (message) | 97 | if (message) |
96 | free(message); | 98 | free(message); |
97 | 99 | ||
98 | return body; | 100 | return body; |
99 | } | 101 | } |
100 | 102 | ||
101 | 103 | ||
102 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) | 104 | void NNTPwrapper::listMessages(const QString & which, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) |
103 | { | 105 | { |
104 | login(); | 106 | login(); |
105 | if (!m_nntp) | 107 | if (!m_nntp) |
106 | return; | 108 | return; |
107 | uint32_t res_messages,res_recent,res_unseen; | 109 | 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); | 110 | 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); | 111 | parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); |
110 | } | 112 | } |
111 | 113 | ||
112 | void NNTPwrapper::login() | 114 | void NNTPwrapper::login() |
113 | { | 115 | { |
114 | if (account->getOffline()) | 116 | if (account->getOffline()) |
@@ -177,27 +179,27 @@ void NNTPwrapper::login() | |||
177 | 179 | ||
178 | } | 180 | } |
179 | 181 | ||
180 | void NNTPwrapper::logout() | 182 | void NNTPwrapper::logout() |
181 | { | 183 | { |
182 | int err = NEWSNNTP_NO_ERROR; | 184 | int err = NEWSNNTP_NO_ERROR; |
183 | if ( m_nntp == NULL ) | 185 | if ( m_nntp == NULL ) |
184 | return; | 186 | return; |
185 | mailstorage_free(m_nntp); | 187 | mailstorage_free(m_nntp); |
186 | m_nntp = 0; | 188 | m_nntp = 0; |
187 | } | 189 | } |
188 | 190 | ||
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 191 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
190 | 192 | ||
191 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 193 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<Opie::Core::OSmartPointer<Folder> >(); |
192 | QStringList groups; | 194 | QStringList groups; |
193 | if (account) { | 195 | if (account) { |
194 | groups = account->getGroups(); | 196 | groups = account->getGroups(); |
195 | } | 197 | } |
196 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
197 | folders->append(new Folder((*it),".")); | 199 | folders->append(new Folder((*it),".")); |
198 | } | 200 | } |
199 | return folders; | 201 | return folders; |
200 | } | 202 | } |
201 | 203 | ||
202 | /* we made this method in raw nntp access of etpan and not via generic interface | 204 | /* we made this method in raw nntp access of etpan and not via generic interface |
203 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 205 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |