author | zecke <zecke> | 2004-03-14 13:22:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 13:22:42 (UTC) |
commit | 0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44 (patch) (unidiff) | |
tree | f6a68afa76a9be4099c3de7a286caeadd250c966 /noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |
parent | d9d68663164078b8dbdbfe70d291291b9fd5aacf (diff) | |
download | opie-0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44.zip opie-0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44.tar.gz opie-0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44.tar.bz2 |
Convert net to ODP and QtAUX
Diffstat (limited to 'noncore/net/mail/libmailwrapper/nntpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index c0b3eec..9de958d 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,37 +1,38 @@ | |||
1 | #include "nntpwrapper.h" | 1 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 2 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
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 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 15 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
15 | : Genericwrapper() { | 16 | : Genericwrapper() { |
16 | account = a; | 17 | account = a; |
17 | m_nntp = NULL; | 18 | m_nntp = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 19 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 20 | last_msg_id = 0; |
20 | } | 21 | } |
21 | 22 | ||
22 | NNTPwrapper::~NNTPwrapper() { | 23 | NNTPwrapper::~NNTPwrapper() { |
23 | logout(); | 24 | logout(); |
24 | QFile msg_cache(msgTempName); | 25 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 26 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 27 | msg_cache.remove(); |
27 | } | 28 | } |
28 | } | 29 | } |
29 | 30 | ||
30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
31 | qDebug( "NNTP: %i of %i", current, maximum ); | 32 | qDebug( "NNTP: %i of %i", current, maximum ); |
32 | } | 33 | } |
33 | 34 | ||
34 | 35 | ||
35 | RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { | 36 | RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { |
36 | int err = NEWSNNTP_NO_ERROR; | 37 | int err = NEWSNNTP_NO_ERROR; |
37 | char *message = 0; | 38 | char *message = 0; |
@@ -75,49 +76,49 @@ RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
75 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 76 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
76 | memset(message,0,msg.length()+1); | 77 | memset(message,0,msg.length()+1); |
77 | memcpy(message,msg.latin1(),msg.length()); | 78 | memcpy(message,msg.latin1(),msg.length()); |
78 | /* transform to libetpan stuff */ | 79 | /* transform to libetpan stuff */ |
79 | mailmsg = mailmessage_new(); | 80 | mailmsg = mailmessage_new(); |
80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
81 | generic_message_t * msg_data; | 82 | generic_message_t * msg_data; |
82 | msg_data = (generic_message_t *)mailmsg->msg_data; | 83 | msg_data = (generic_message_t *)mailmsg->msg_data; |
83 | msg_data->msg_fetched = 1; | 84 | msg_data->msg_fetched = 1; |
84 | msg_data->msg_message = message; | 85 | msg_data->msg_message = message; |
85 | msg_data->msg_length = strlen(message); | 86 | msg_data->msg_length = strlen(message); |
86 | } | 87 | } |
87 | body = parseMail(mailmsg); | 88 | body = parseMail(mailmsg); |
88 | 89 | ||
89 | /* clean up */ | 90 | /* clean up */ |
90 | if (mailmsg) | 91 | if (mailmsg) |
91 | mailmessage_free(mailmsg); | 92 | mailmessage_free(mailmsg); |
92 | if (message) | 93 | if (message) |
93 | free(message); | 94 | free(message); |
94 | 95 | ||
95 | return body; | 96 | return body; |
96 | } | 97 | } |
97 | 98 | ||
98 | 99 | ||
99 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::OSmartPointer<RecMail> > &target ) | 100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
100 | { | 101 | { |
101 | login(); | 102 | login(); |
102 | if (!m_nntp) | 103 | if (!m_nntp) |
103 | return; | 104 | return; |
104 | uint32_t res_messages,res_recent,res_unseen; | 105 | uint32_t res_messages,res_recent,res_unseen; |
105 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 106 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
106 | parseList(target,m_nntp->sto_session,which,true); | 107 | parseList(target,m_nntp->sto_session,which,true); |
107 | } | 108 | } |
108 | 109 | ||
109 | void NNTPwrapper::login() | 110 | void NNTPwrapper::login() |
110 | { | 111 | { |
111 | if (account->getOffline()) | 112 | if (account->getOffline()) |
112 | return; | 113 | return; |
113 | /* we'll hold the line */ | 114 | /* we'll hold the line */ |
114 | if ( m_nntp != NULL ) | 115 | if ( m_nntp != NULL ) |
115 | return; | 116 | return; |
116 | 117 | ||
117 | const char *server, *user, *pass; | 118 | const char *server, *user, *pass; |
118 | QString User,Pass; | 119 | QString User,Pass; |
119 | uint16_t port; | 120 | uint16_t port; |
120 | int err = NEWSNNTP_NO_ERROR; | 121 | int err = NEWSNNTP_NO_ERROR; |
121 | 122 | ||
122 | server = account->getServer().latin1(); | 123 | server = account->getServer().latin1(); |
123 | port = account->getPort().toUInt(); | 124 | port = account->getPort().toUInt(); |
@@ -167,51 +168,51 @@ void NNTPwrapper::login() | |||
167 | 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, |
168 | (char*)user,(char*)pass,0,0,0); | 169 | (char*)user,(char*)pass,0,0,0); |
169 | 170 | ||
170 | err = mailstorage_connect( m_nntp ); | 171 | err = mailstorage_connect( m_nntp ); |
171 | 172 | ||
172 | if (err != NEWSNNTP_NO_ERROR) { | 173 | if (err != NEWSNNTP_NO_ERROR) { |
173 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 174 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
174 | // Global::statusMessage(tr("Error initializing folder")); | 175 | // Global::statusMessage(tr("Error initializing folder")); |
175 | mailstorage_free(m_nntp); | 176 | mailstorage_free(m_nntp); |
176 | m_nntp = 0; | 177 | m_nntp = 0; |
177 | 178 | ||
178 | } | 179 | } |
179 | 180 | ||
180 | } | 181 | } |
181 | 182 | ||
182 | void NNTPwrapper::logout() | 183 | void NNTPwrapper::logout() |
183 | { | 184 | { |
184 | int err = NEWSNNTP_NO_ERROR; | 185 | int err = NEWSNNTP_NO_ERROR; |
185 | if ( m_nntp == NULL ) | 186 | if ( m_nntp == NULL ) |
186 | return; | 187 | return; |
187 | mailstorage_free(m_nntp); | 188 | mailstorage_free(m_nntp); |
188 | m_nntp = 0; | 189 | m_nntp = 0; |
189 | } | 190 | } |
190 | 191 | ||
191 | QValueList<Opie::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 192 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
192 | 193 | ||
193 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); | 194 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
194 | QStringList groups; | 195 | QStringList groups; |
195 | if (account) { | 196 | if (account) { |
196 | groups = account->getGroups(); | 197 | groups = account->getGroups(); |
197 | } | 198 | } |
198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
199 | folders->append(new Folder((*it),".")); | 200 | folders->append(new Folder((*it),".")); |
200 | } | 201 | } |
201 | return folders; | 202 | return folders; |
202 | } | 203 | } |
203 | 204 | ||
204 | /* we made this method in raw nntp access of etpan and not via generic interface | 205 | /* we made this method in raw nntp access of etpan and not via generic interface |
205 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
206 | * copy that stuff into its own structures and we must copy it into useable c++ | 207 | * copy that stuff into its own structures and we must copy it into useable c++ |
207 | * structures for our frontend. this would not make sense, so it is better to reimplement | 208 | * structures for our frontend. this would not make sense, so it is better to reimplement |
208 | * the stuff from generic interface of etpan but copy it direct to qt classes. | 209 | * the stuff from generic interface of etpan but copy it direct to qt classes. |
209 | */ | 210 | */ |
210 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | 211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { |
211 | login(); | 212 | login(); |
212 | QStringList res; | 213 | QStringList res; |
213 | clist *result = 0; | 214 | clist *result = 0; |
214 | clistcell *current = 0; | 215 | clistcell *current = 0; |
215 | newsnntp_group_description *group; | 216 | newsnntp_group_description *group; |
216 | 217 | ||
217 | if ( m_nntp ) { | 218 | if ( m_nntp ) { |