author | alwin <alwin> | 2004-03-07 01:42:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-07 01:42:07 (UTC) |
commit | 9b3af0c792777462126317a0335d2c355b4d8b13 (patch) (unidiff) | |
tree | 5d6a7c478fff7d3931cbe5d28cf2d0e87d44b8ce /noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |
parent | 5bc69a9731634c55b9a01b9de6909201f422893b (diff) | |
download | opie-9b3af0c792777462126317a0335d2c355b4d8b13.zip opie-9b3af0c792777462126317a0335d2c355b4d8b13.tar.gz opie-9b3af0c792777462126317a0335d2c355b4d8b13.tar.bz2 |
-resolved that not all newsgroups where listed
-resolved a memory leak
-newsgroups list enhanced for usage with wildcards
Diffstat (limited to 'noncore/net/mail/libmailwrapper/nntpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index a766a59..5a8c224 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -181,69 +181,82 @@ void NNTPwrapper::login() | |||
181 | 181 | ||
182 | void NNTPwrapper::logout() | 182 | void NNTPwrapper::logout() |
183 | { | 183 | { |
184 | int err = NEWSNNTP_NO_ERROR; | 184 | int err = NEWSNNTP_NO_ERROR; |
185 | if ( m_nntp == NULL ) | 185 | if ( m_nntp == NULL ) |
186 | return; | 186 | return; |
187 | mailstorage_free(m_nntp); | 187 | mailstorage_free(m_nntp); |
188 | m_nntp = 0; | 188 | m_nntp = 0; |
189 | } | 189 | } |
190 | 190 | ||
191 | QList<Folder>* NNTPwrapper::listFolders() { | 191 | QList<Folder>* NNTPwrapper::listFolders() { |
192 | 192 | ||
193 | QList<Folder> * folders = new QList<Folder>(); | 193 | QList<Folder> * folders = new QList<Folder>(); |
194 | folders->setAutoDelete( false ); | 194 | folders->setAutoDelete( false ); |
195 | QStringList groups; | 195 | QStringList groups; |
196 | if (account) { | 196 | if (account) { |
197 | groups = account->getGroups(); | 197 | groups = account->getGroups(); |
198 | } | 198 | } |
199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
200 | folders->append(new Folder((*it),".")); | 200 | folders->append(new Folder((*it),".")); |
201 | } | 201 | } |
202 | return folders; | 202 | return folders; |
203 | } | 203 | } |
204 | 204 | ||
205 | QStringList NNTPwrapper::listAllNewsgroups() { | 205 | /* we made this method in raw nntp access of etpan and not via generic interface |
206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | ||
207 | * copy that stuff into its own structures and we must copy it into useable c++ | ||
208 | * structures for our frontend. this would not make sense, so it is better to reimplement | ||
209 | * the stuff from generic interface of etpan but copy it direct to qt classes. | ||
210 | */ | ||
211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | ||
206 | login(); | 212 | login(); |
207 | QStringList res; | 213 | QStringList res; |
208 | clist *result = 0; | 214 | clist *result = 0; |
209 | clistcell *current = 0; | 215 | clistcell *current = 0; |
210 | newsnntp_group_description *group; | 216 | newsnntp_group_description *group; |
211 | 217 | ||
212 | if ( m_nntp ) { | 218 | if ( m_nntp ) { |
213 | mailsession * session = m_nntp->sto_session; | 219 | mailsession * session = m_nntp->sto_session; |
214 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 220 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
215 | int err = newsnntp_list_newsgroups(news, NULL, &result); | 221 | int err = NEWSNNTP_NO_ERROR; |
222 | if (mask.isEmpty()) { | ||
223 | err = newsnntp_list(news, &result); | ||
224 | } else { | ||
225 | /* taken from generic wrapper of etpan */ | ||
226 | QString nmask = mask+".*"; | ||
227 | err = newsnntp_list_active(news, nmask.latin1(), &result); | ||
228 | } | ||
216 | if ( err == NEWSNNTP_NO_ERROR && result) { | 229 | if ( err == NEWSNNTP_NO_ERROR && result) { |
217 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { | 230 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { |
218 | group = ( newsnntp_group_description* ) current->data; | 231 | group = ( newsnntp_group_description* ) current->data; |
219 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; | 232 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; |
220 | res.append(group->grp_name); | 233 | res.append(group->grp_name); |
221 | } | 234 | } |
222 | } | 235 | } |
223 | } | 236 | } |
224 | if (result) { | 237 | if (result) { |
225 | clist_free(result); | 238 | newsnntp_list_free(result); |
226 | } | 239 | } |
227 | return res; | 240 | return res; |
228 | } | 241 | } |
229 | 242 | ||
230 | void NNTPwrapper::answeredMail(const RecMail&) {} | 243 | void NNTPwrapper::answeredMail(const RecMail&) {} |
231 | 244 | ||
232 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { | 245 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { |
233 | login(); | 246 | login(); |
234 | target_stat.message_count = 0; | 247 | target_stat.message_count = 0; |
235 | target_stat.message_unseen = 0; | 248 | target_stat.message_unseen = 0; |
236 | target_stat.message_recent = 0; | 249 | target_stat.message_recent = 0; |
237 | if (!m_nntp) | 250 | if (!m_nntp) |
238 | return; | 251 | return; |
239 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, | 252 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, |
240 | &target_stat.message_recent,&target_stat.message_unseen); | 253 | &target_stat.message_recent,&target_stat.message_unseen); |
241 | } | 254 | } |
242 | 255 | ||
243 | 256 | ||
244 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { | 257 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { |
245 | char*target=0; | 258 | char*target=0; |
246 | size_t length=0; | 259 | size_t length=0; |
247 | encodedString*res = 0; | 260 | encodedString*res = 0; |
248 | mailmessage * mailmsg = 0; | 261 | mailmessage * mailmsg = 0; |
249 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 262 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); |