summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp19
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h2
2 files changed, 17 insertions, 4 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
@@ -189,53 +189,66 @@ void NNTPwrapper::logout()
189} 189}
190 190
191QList<Folder>* NNTPwrapper::listFolders() { 191QList<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
205QStringList 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 */
211QStringList 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
230void NNTPwrapper::answeredMail(const RecMail&) {} 243void NNTPwrapper::answeredMail(const RecMail&) {}
231 244
232void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { 245void 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}
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index 4d03754..d51c955 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -12,33 +12,33 @@ struct mailfolder;
12 12
13class NNTPwrapper : public Genericwrapper 13class NNTPwrapper : public Genericwrapper
14{ 14{
15 15
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 NNTPwrapper( NNTPaccount *a ); 19 NNTPwrapper( NNTPaccount *a );
20 virtual ~NNTPwrapper(); 20 virtual ~NNTPwrapper();
21 21
22 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
24 /* should only get the subscribed one */ 24 /* should only get the subscribed one */
25 virtual QList<Folder>* listFolders(); 25 virtual QList<Folder>* listFolders();
26 /* mailbox will be ignored */ 26 /* mailbox will be ignored */
27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
28 QStringList listAllNewsgroups(); 28 QStringList listAllNewsgroups(const QString&mask = QString::null);
29 virtual void deleteMail(const RecMail&mail); 29 virtual void deleteMail(const RecMail&mail);
30 virtual void answeredMail(const RecMail&mail); 30 virtual void answeredMail(const RecMail&mail);
31 virtual int deleteAllMail(const Folder*); 31 virtual int deleteAllMail(const Folder*);
32 32
33 virtual RecBody fetchBody( const RecMail &mail ); 33 virtual RecBody fetchBody( const RecMail &mail );
34 virtual encodedString* fetchRawBody(const RecMail&mail); 34 virtual encodedString* fetchRawBody(const RecMail&mail);
35 virtual void logout(); 35 virtual void logout();
36 virtual const QString&getType()const; 36 virtual const QString&getType()const;
37 virtual const QString&getName()const; 37 virtual const QString&getName()const;
38 static void nntp_progress( size_t current, size_t maximum ); 38 static void nntp_progress( size_t current, size_t maximum );
39 39
40protected: 40protected:
41 void login(); 41 void login();
42 NNTPaccount *account; 42 NNTPaccount *account;
43 mailstorage* m_nntp; 43 mailstorage* m_nntp;
44 44