author | harlekin <harlekin> | 2004-02-29 21:55:06 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-02-29 21:55:06 (UTC) |
commit | dcf152e23f7cc85fe2e46521e07b64e2288efdda (patch) (unidiff) | |
tree | 8aac8095aed8dc9a9efab7005b8f1c53cce82536 /noncore | |
parent | 225b92ec28bbe3a9368e8534323a3c335432e447 (diff) | |
download | opie-dcf152e23f7cc85fe2e46521e07b64e2288efdda.zip opie-dcf152e23f7cc85fe2e46521e07b64e2288efdda.tar.gz opie-dcf152e23f7cc85fe2e46521e07b64e2288efdda.tar.bz2 |
beginning of nntp stuff
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 190 | ||||
-rw-r--r-- | noncore/net/mail/accountitem.h | 40 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/libmailwrapper.pro | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 241 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.h | 48 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/nntpconfigui.ui | 103 |
10 files changed, 637 insertions, 7 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index c8f6ec4..32a96ff 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -209,6 +209,196 @@ void POP3folderItem::contextMenuSelected(int which) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | /** | 211 | /** |
212 | * NNTP Account stuff | ||
213 | */ | ||
214 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | ||
215 | : AccountViewItem( parent ) | ||
216 | { | ||
217 | account = a; | ||
218 | wrapper = AbstractMail::getWrapper( account ); | ||
219 | //FIXME | ||
220 | SETPIX(PIXMAP_POP3FOLDER); | ||
221 | #if 0 | ||
222 | if (!account->getOffline()) | ||
223 | { | ||
224 | setPixmap( 0, ); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | setPixmap( 0, PIXMAP_OFFLINE ); | ||
229 | } | ||
230 | #endif | ||
231 | setText( 0, account->getAccountName() ); | ||
232 | setOpen( true ); | ||
233 | } | ||
234 | |||
235 | NNTPviewItem::~NNTPviewItem() | ||
236 | { | ||
237 | delete wrapper; | ||
238 | } | ||
239 | |||
240 | AbstractMail *NNTPviewItem::getWrapper() | ||
241 | { | ||
242 | return wrapper; | ||
243 | } | ||
244 | |||
245 | void NNTPviewItem::refresh( QList<RecMail> & ) | ||
246 | { | ||
247 | refresh(); | ||
248 | } | ||
249 | |||
250 | void NNTPviewItem::refresh() | ||
251 | { | ||
252 | if (account->getOffline()) return; | ||
253 | QList<Folder> *folders = wrapper->listFolders(); | ||
254 | QListViewItem *child = firstChild(); | ||
255 | while ( child ) | ||
256 | { | ||
257 | QListViewItem *tmp = child; | ||
258 | child = child->nextSibling(); | ||
259 | delete tmp; | ||
260 | } | ||
261 | Folder *it; | ||
262 | QListViewItem*item = 0; | ||
263 | for ( it = folders->first(); it; it = folders->next() ) | ||
264 | { | ||
265 | item = new NNTPfolderItem( it, this , item ); | ||
266 | item->setSelectable(it->may_select()); | ||
267 | } | ||
268 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
269 | folders->setAutoDelete(false); | ||
270 | delete folders; | ||
271 | } | ||
272 | |||
273 | RecBody NNTPviewItem::fetchBody( const RecMail &mail ) | ||
274 | { | ||
275 | qDebug( "NNTP fetchBody" ); | ||
276 | return wrapper->fetchBody( mail ); | ||
277 | } | ||
278 | |||
279 | QPopupMenu * NNTPviewItem::getContextMenu() | ||
280 | { | ||
281 | QPopupMenu *m = new QPopupMenu(0); | ||
282 | if (m) | ||
283 | { | ||
284 | if (!account->getOffline()) | ||
285 | { | ||
286 | m->insertItem(QObject::tr("Disconnect",contextName),0); | ||
287 | m->insertItem(QObject::tr("Set offline",contextName),1); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | m->insertItem(QObject::tr("Set online",contextName),1); | ||
292 | } | ||
293 | } | ||
294 | return m; | ||
295 | } | ||
296 | |||
297 | void NNTPviewItem::disconnect() | ||
298 | { | ||
299 | QListViewItem *child = firstChild(); | ||
300 | while ( child ) | ||
301 | { | ||
302 | QListViewItem *tmp = child; | ||
303 | child = child->nextSibling(); | ||
304 | delete tmp; | ||
305 | } | ||
306 | wrapper->logout(); | ||
307 | } | ||
308 | |||
309 | void NNTPviewItem::setOnOffline() | ||
310 | { | ||
311 | if (!account->getOffline()) | ||
312 | { | ||
313 | disconnect(); | ||
314 | } | ||
315 | account->setOffline(!account->getOffline()); | ||
316 | account->save(); | ||
317 | //FIXME | ||
318 | SETPIX(PIXMAP_POP3FOLDER); | ||
319 | refresh(); | ||
320 | } | ||
321 | |||
322 | void NNTPviewItem::contextMenuSelected(int which) | ||
323 | { | ||
324 | switch (which) | ||
325 | { | ||
326 | case 0: | ||
327 | disconnect(); | ||
328 | break; | ||
329 | case 1: | ||
330 | setOnOffline(); | ||
331 | break; | ||
332 | } | ||
333 | } | ||
334 | |||
335 | NNTPfolderItem::~NNTPfolderItem() | ||
336 | {} | ||
337 | |||
338 | NNTPfolderItem::NNTPfolderItem( Folder *folderInit, NNTPviewItem *parent , QListViewItem*after ) | ||
339 | : AccountViewItem( parent,after ) | ||
340 | { | ||
341 | folder = folderInit; | ||
342 | nntp = parent; | ||
343 | if (folder->getDisplayName().lower()!="inbox") | ||
344 | { | ||
345 | setPixmap( 0, PIXMAP_POP3FOLDER ); | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
350 | } | ||
351 | setText( 0, folder->getDisplayName() ); | ||
352 | } | ||
353 | |||
354 | void NNTPfolderItem::refresh(QList<RecMail>&target) | ||
355 | { | ||
356 | if (folder->may_select()) | ||
357 | nntp->getWrapper()->listMessages( folder->getName(),target ); | ||
358 | } | ||
359 | |||
360 | RecBody NNTPfolderItem::fetchBody(const RecMail&aMail) | ||
361 | { | ||
362 | return nntp->getWrapper()->fetchBody(aMail); | ||
363 | } | ||
364 | |||
365 | QPopupMenu * NNTPfolderItem::getContextMenu() | ||
366 | { | ||
367 | QPopupMenu *m = new QPopupMenu(0); | ||
368 | if (m) | ||
369 | { | ||
370 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | ||
371 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),1); | ||
372 | } | ||
373 | return m; | ||
374 | } | ||
375 | |||
376 | void NNTPfolderItem::downloadMails() | ||
377 | { | ||
378 | AccountView*bl = nntp->accountView(); | ||
379 | if (!bl) return; | ||
380 | bl->downloadMails(folder,nntp->getWrapper()); | ||
381 | } | ||
382 | |||
383 | void NNTPfolderItem::contextMenuSelected(int which) | ||
384 | { | ||
385 | AccountView * view = (AccountView*)listView(); | ||
386 | switch (which) | ||
387 | { | ||
388 | case 0: | ||
389 | /* must be 'cause pop3 lists are cached */ | ||
390 | nntp->getWrapper()->logout(); | ||
391 | view->refreshCurrent(); | ||
392 | break; | ||
393 | case 1: | ||
394 | downloadMails(); | ||
395 | break; | ||
396 | default: | ||
397 | break; | ||
398 | } | ||
399 | } | ||
400 | |||
401 | /** | ||
212 | * IMAP Account stuff | 402 | * IMAP Account stuff |
213 | */ | 403 | */ |
214 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 404 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index 99208b6..a138c9b 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h | |||
@@ -11,6 +11,7 @@ class QPopupMenu; | |||
11 | class Selectstore; | 11 | class Selectstore; |
12 | class AccountView; | 12 | class AccountView; |
13 | class POP3account; | 13 | class POP3account; |
14 | class NNTPaccount; | ||
14 | class IMAPaccount; | 15 | class IMAPaccount; |
15 | class AbstractMail; | 16 | class AbstractMail; |
16 | class Folder; | 17 | class Folder; |
@@ -76,6 +77,45 @@ protected: | |||
76 | POP3viewItem *pop3; | 77 | POP3viewItem *pop3; |
77 | }; | 78 | }; |
78 | 79 | ||
80 | |||
81 | class NNTPviewItem : public AccountViewItem | ||
82 | { | ||
83 | |||
84 | public: | ||
85 | NNTPviewItem( NNTPaccount *a, AccountView *parent ); | ||
86 | virtual ~NNTPviewItem(); | ||
87 | virtual void refresh( QList<RecMail> &target ); | ||
88 | virtual RecBody fetchBody( const RecMail &mail ); | ||
89 | AbstractMail *getWrapper(); | ||
90 | virtual QPopupMenu * getContextMenu(); | ||
91 | virtual void contextMenuSelected(int); | ||
92 | |||
93 | protected: | ||
94 | NNTPaccount *account; | ||
95 | virtual void refresh(); | ||
96 | AbstractMail *wrapper; | ||
97 | void disconnect(); | ||
98 | void setOnOffline(); | ||
99 | }; | ||
100 | |||
101 | class NNTPfolderItem : public AccountViewItem | ||
102 | { | ||
103 | |||
104 | public: | ||
105 | NNTPfolderItem( Folder *folder, NNTPviewItem *parent , QListViewItem*after ); | ||
106 | virtual ~NNTPfolderItem(); | ||
107 | virtual void refresh(QList<RecMail>&); | ||
108 | virtual RecBody fetchBody(const RecMail&); | ||
109 | virtual QPopupMenu * getContextMenu(); | ||
110 | virtual void contextMenuSelected(int); | ||
111 | |||
112 | protected: | ||
113 | void downloadMails(); | ||
114 | NNTPviewItem *nntp; | ||
115 | }; | ||
116 | |||
117 | |||
118 | |||
79 | class IMAPviewItem : public AccountViewItem | 119 | class IMAPviewItem : public AccountViewItem |
80 | { | 120 | { |
81 | friend class IMAPfolderItem; | 121 | friend class IMAPfolderItem; |
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 2ddf834..c2185f2 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -75,6 +75,13 @@ void AccountView::populate( QList<Account> list ) | |||
75 | /* must not be hold 'cause it isn't required */ | 75 | /* must not be hold 'cause it isn't required */ |
76 | (void) new POP3viewItem( pop3, this ); | 76 | (void) new POP3viewItem( pop3, this ); |
77 | } | 77 | } |
78 | else if ( it->getType().compare( "NNTP" ) == 0 ) | ||
79 | { | ||
80 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | ||
81 | qDebug( "added NNTP " + nntp->getAccountName() ); | ||
82 | /* must not be hold 'cause it isn't required */ | ||
83 | (void) new NNTPviewItem( nntp, this ); | ||
84 | } | ||
78 | } | 85 | } |
79 | } | 86 | } |
80 | 87 | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 592cd5e..741a8e1 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "nntpwrapper.h" | ||
4 | #include "mhwrapper.h" | 5 | #include "mhwrapper.h" |
5 | #include "mboxwrapper.h" | 6 | #include "mboxwrapper.h" |
6 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
@@ -22,6 +23,11 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a) | |||
22 | return new POP3wrapper(a); | 23 | return new POP3wrapper(a); |
23 | } | 24 | } |
24 | 25 | ||
26 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | ||
27 | { | ||
28 | return new NNTPwrapper(a); | ||
29 | } | ||
30 | |||
25 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 31 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
26 | { | 32 | { |
27 | return new MHwrapper(a,name); | 33 | return new MHwrapper(a,name); |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index f93bab4..b6e1538 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -49,6 +49,7 @@ public: | |||
49 | 49 | ||
50 | static AbstractMail* getWrapper(IMAPaccount *a); | 50 | static AbstractMail* getWrapper(IMAPaccount *a); |
51 | static AbstractMail* getWrapper(POP3account *a); | 51 | static AbstractMail* getWrapper(POP3account *a); |
52 | static AbstractMail* getWrapper(NNTPaccount *a); | ||
52 | /* mbox only! */ | 53 | /* mbox only! */ |
53 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 54 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
54 | 55 | ||
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro index 71f6cca..8ea04a4 100644 --- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro +++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro | |||
@@ -13,7 +13,8 @@ HEADERS = mailwrapper.h \ | |||
13 | logindialog.h \ | 13 | logindialog.h \ |
14 | sendmailprogress.h \ | 14 | sendmailprogress.h \ |
15 | statusmail.h \ | 15 | statusmail.h \ |
16 | mhwrapper.h | 16 | mhwrapper.h \ |
17 | nntpwrapper.h | ||
17 | 18 | ||
18 | SOURCES = imapwrapper.cpp \ | 19 | SOURCES = imapwrapper.cpp \ |
19 | mailwrapper.cpp \ | 20 | mailwrapper.cpp \ |
@@ -27,7 +28,8 @@ SOURCES = imapwrapper.cpp \ | |||
27 | logindialog.cpp \ | 28 | logindialog.cpp \ |
28 | sendmailprogress.cpp \ | 29 | sendmailprogress.cpp \ |
29 | statusmail.cpp \ | 30 | statusmail.cpp \ |
30 | mhwrapper.cpp | 31 | mhwrapper.cpp \ |
32 | nntpwrapper.cpp | ||
31 | 33 | ||
32 | INTERFACES = logindialogui.ui \ | 34 | INTERFACES = logindialogui.ui \ |
33 | sendmailprogressui.ui | 35 | sendmailprogressui.ui |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp new file mode 100644 index 0000000..e73a890 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -0,0 +1,241 @@ | |||
1 | #include "nntpwrapper.h" | ||
2 | #include "logindialog.h" | ||
3 | #include "mailtypes.h" | ||
4 | |||
5 | #include <qfile.h> | ||
6 | |||
7 | #include <stdlib.h> | ||
8 | |||
9 | #include <libetpan/libetpan.h> | ||
10 | #include <libetpan/nntpdriver.h> | ||
11 | |||
12 | |||
13 | |||
14 | #define HARD_MSG_SIZE_LIMIT 5242880 | ||
15 | |||
16 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | ||
17 | : Genericwrapper() { | ||
18 | account = a; | ||
19 | m_nntp = NULL; | ||
20 | msgTempName = a->getFileName()+"_msg_cache"; | ||
21 | last_msg_id = 0; | ||
22 | } | ||
23 | |||
24 | NNTPwrapper::~NNTPwrapper() { | ||
25 | logout(); | ||
26 | QFile msg_cache(msgTempName); | ||
27 | if (msg_cache.exists()) { | ||
28 | msg_cache.remove(); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | ||
33 | qDebug( "NNTP: %i of %i", current, maximum ); | ||
34 | } | ||
35 | |||
36 | |||
37 | RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | ||
38 | int err = NEWSNNTP_NO_ERROR; | ||
39 | char *message = 0; | ||
40 | size_t length = 0; | ||
41 | |||
42 | login(); | ||
43 | if ( !m_nntp ) { | ||
44 | return RecBody(); | ||
45 | } | ||
46 | |||
47 | RecBody body; | ||
48 | mailmessage * mailmsg; | ||
49 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | ||
50 | qDebug("Message to large: %i",mail.Msgsize()); | ||
51 | return body; | ||
52 | } | ||
53 | |||
54 | QFile msg_cache(msgTempName); | ||
55 | |||
56 | cleanMimeCache(); | ||
57 | |||
58 | if (mail.getNumber()!=last_msg_id) { | ||
59 | if (msg_cache.exists()) { | ||
60 | msg_cache.remove(); | ||
61 | } | ||
62 | msg_cache.open(IO_ReadWrite|IO_Truncate); | ||
63 | last_msg_id = mail.getNumber(); | ||
64 | err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | ||
65 | err = mailmessage_fetch(mailmsg,&message,&length); | ||
66 | msg_cache.writeBlock(message,length); | ||
67 | } else { | ||
68 | QString msg=""; | ||
69 | msg_cache.open(IO_ReadOnly); | ||
70 | message = new char[4096]; | ||
71 | memset(message,0,4096); | ||
72 | while (msg_cache.readBlock(message,4095)>0) { | ||
73 | msg+=message; | ||
74 | memset(message,0,4096); | ||
75 | } | ||
76 | delete message; | ||
77 | message = (char*)malloc(msg.length()+1*sizeof(char)); | ||
78 | memset(message,0,msg.length()+1); | ||
79 | memcpy(message,msg.latin1(),msg.length()); | ||
80 | /* transform to libetpan stuff */ | ||
81 | mailmsg = mailmessage_new(); | ||
82 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | ||
83 | generic_message_t * msg_data; | ||
84 | msg_data = (generic_message_t *)mailmsg->msg_data; | ||
85 | msg_data->msg_fetched = 1; | ||
86 | msg_data->msg_message = message; | ||
87 | msg_data->msg_length = strlen(message); | ||
88 | } | ||
89 | body = parseMail(mailmsg); | ||
90 | |||
91 | /* clean up */ | ||
92 | if (mailmsg) | ||
93 | mailmessage_free(mailmsg); | ||
94 | if (message) | ||
95 | free(message); | ||
96 | |||
97 | return body; | ||
98 | } | ||
99 | |||
100 | |||
101 | void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) | ||
102 | { | ||
103 | login(); | ||
104 | if (!m_nntp) | ||
105 | return; | ||
106 | uint32_t res_messages,res_recent,res_unseen; | ||
107 | mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | ||
108 | parseList(target,m_nntp->sto_session,"INBOX"); | ||
109 | } | ||
110 | |||
111 | void NNTPwrapper::login() | ||
112 | { | ||
113 | if (account->getOffline()) | ||
114 | return; | ||
115 | /* we'll hold the line */ | ||
116 | if ( m_nntp != NULL ) | ||
117 | return; | ||
118 | |||
119 | const char *server, *user, *pass; | ||
120 | uint16_t port; | ||
121 | int err = NEWSNNTP_NO_ERROR; | ||
122 | |||
123 | server = account->getServer().latin1(); | ||
124 | port = account->getPort().toUInt(); | ||
125 | |||
126 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | ||
127 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | ||
128 | login.show(); | ||
129 | if ( QDialog::Accepted == login.exec() ) { | ||
130 | // ok | ||
131 | user = login.getUser().latin1(); | ||
132 | pass = login.getPassword().latin1(); | ||
133 | } else { | ||
134 | // cancel | ||
135 | qDebug( "NNTP: Login canceled" ); | ||
136 | return; | ||
137 | } | ||
138 | } else { | ||
139 | user = account->getUser().latin1(); | ||
140 | pass = account->getPassword().latin1(); | ||
141 | } | ||
142 | |||
143 | // bool ssl = account->getSSL(); | ||
144 | |||
145 | m_nntp=mailstorage_new(NULL); | ||
146 | |||
147 | int conntypeset = account->ConnectionType(); | ||
148 | int conntype = 0; | ||
149 | if ( conntypeset == 3 ) { | ||
150 | conntype = CONNECTION_TYPE_COMMAND; | ||
151 | } else if ( conntypeset == 2 ) { | ||
152 | conntype = CONNECTION_TYPE_TLS; | ||
153 | } else if ( conntypeset == 1 ) { | ||
154 | conntype = CONNECTION_TYPE_STARTTLS; | ||
155 | } else if ( conntypeset == 0 ) { | ||
156 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | ||
157 | } | ||
158 | |||
159 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, conntype, NNTP_AUTH_TYPE_PLAIN, | ||
160 | (char*)user,(char*)pass,0,0,0); | ||
161 | |||
162 | err = mailstorage_connect(m_nntp); | ||
163 | |||
164 | if (err != NEWSNNTP_NO_ERROR) { | ||
165 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | ||
166 | // Global::statusMessage(tr("Error initializing folder")); | ||
167 | mailstorage_free(m_nntp); | ||
168 | m_nntp = 0; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | void NNTPwrapper::logout() | ||
173 | { | ||
174 | int err = NEWSNNTP_NO_ERROR; | ||
175 | if ( m_nntp == NULL ) | ||
176 | return; | ||
177 | mailstorage_free(m_nntp); | ||
178 | m_nntp = 0; | ||
179 | } | ||
180 | |||
181 | QList<Folder>* NNTPwrapper::listFolders() { | ||
182 | QList<Folder> * folders = new QList<Folder>(); | ||
183 | folders->setAutoDelete( false ); | ||
184 | clist *result = 0; | ||
185 | |||
186 | // int err = | ||
187 | // if ( err == _NO_ERROR ) { | ||
188 | // current = result->first; | ||
189 | // for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | ||
190 | |||
191 | |||
192 | // Folder*inb=new Folder("INBOX","/"); | ||
193 | |||
194 | |||
195 | // folders->append(inb); | ||
196 | return folders; | ||
197 | } | ||
198 | |||
199 | |||
200 | void NNTPwrapper::answeredMail(const RecMail&) {} | ||
201 | |||
202 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { | ||
203 | login(); | ||
204 | target_stat.message_count = 0; | ||
205 | target_stat.message_unseen = 0; | ||
206 | target_stat.message_recent = 0; | ||
207 | if (!m_nntp) | ||
208 | return; | ||
209 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, | ||
210 | &target_stat.message_recent,&target_stat.message_unseen); | ||
211 | } | ||
212 | |||
213 | |||
214 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { | ||
215 | char*target=0; | ||
216 | size_t length=0; | ||
217 | encodedString*res = 0; | ||
218 | mailmessage * mailmsg = 0; | ||
219 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | ||
220 | err = mailmessage_fetch(mailmsg,&target,&length); | ||
221 | if (mailmsg) | ||
222 | mailmessage_free(mailmsg); | ||
223 | if (target) { | ||
224 | res = new encodedString(target,length); | ||
225 | } | ||
226 | return res; | ||
227 | } | ||
228 | |||
229 | const QString&NNTPwrapper::getType()const { | ||
230 | return account->getType(); | ||
231 | } | ||
232 | |||
233 | const QString&NNTPwrapper::getName()const{ | ||
234 | return account->getAccountName(); | ||
235 | } | ||
236 | |||
237 | void NNTPwrapper::deleteMail(const RecMail&mail) { | ||
238 | } | ||
239 | |||
240 | int NNTPwrapper::deleteAllMail(const Folder*) { | ||
241 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h new file mode 100644 index 0000000..e47e68f --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef __NNTPWRAPPER | ||
2 | #define __NNTPWRAPPER | ||
3 | |||
4 | #include "mailwrapper.h" | ||
5 | #include "genericwrapper.h" | ||
6 | #include <qstring.h> | ||
7 | #include <libetpan/clist.h> | ||
8 | |||
9 | class encodedString; | ||
10 | struct mailstorage; | ||
11 | struct mailfolder; | ||
12 | |||
13 | class NNTPwrapper : public Genericwrapper | ||
14 | { | ||
15 | |||
16 | Q_OBJECT | ||
17 | |||
18 | public: | ||
19 | NNTPwrapper( NNTPaccount *a ); | ||
20 | virtual ~NNTPwrapper(); | ||
21 | |||
22 | /* mailbox will be ignored */ | ||
23 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | ||
24 | /* should only get the subscribed one */ | ||
25 | virtual QList<Folder>* listFolders(); | ||
26 | /* mailbox will be ignored */ | ||
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
28 | |||
29 | virtual void deleteMail(const RecMail&mail); | ||
30 | virtual void answeredMail(const RecMail&mail); | ||
31 | virtual int deleteAllMail(const Folder*); | ||
32 | |||
33 | virtual RecBody fetchBody( const RecMail &mail ); | ||
34 | virtual encodedString* fetchRawBody(const RecMail&mail); | ||
35 | virtual void logout(); | ||
36 | virtual const QString&getType()const; | ||
37 | virtual const QString&getName()const; | ||
38 | static void nntp_progress( size_t current, size_t maximum ); | ||
39 | |||
40 | protected: | ||
41 | void login(); | ||
42 | NNTPaccount *account; | ||
43 | mailstorage* m_nntp; | ||
44 | |||
45 | |||
46 | }; | ||
47 | |||
48 | #endif | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 14c2059..6fab401 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qstring.h> | 8 | //#include <qstring.h> |
9 | 9 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 10 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 11 | #define HARD_MSG_SIZE_LIMIT 5242880 |
diff --git a/noncore/net/mail/nntpconfigui.ui b/noncore/net/mail/nntpconfigui.ui index cc439f4..7769804 100644 --- a/noncore/net/mail/nntpconfigui.ui +++ b/noncore/net/mail/nntpconfigui.ui | |||
@@ -11,8 +11,8 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>228</width> | 14 | <width>413</width> |
15 | <height>320</height> | 15 | <height>520</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
@@ -25,10 +25,41 @@ | |||
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <vbox> | ||
29 | <property stdset="1"> | ||
30 | <name>margin</name> | ||
31 | <number>3</number> | ||
32 | </property> | ||
33 | <property stdset="1"> | ||
34 | <name>spacing</name> | ||
35 | <number>3</number> | ||
36 | </property> | ||
37 | <widget> | ||
38 | <class>QTabWidget</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>TabWidget2</cstring> | ||
42 | </property> | ||
43 | <property> | ||
44 | <name>layoutMargin</name> | ||
45 | </property> | ||
46 | <property> | ||
47 | <name>layoutSpacing</name> | ||
48 | </property> | ||
49 | <widget> | ||
50 | <class>QWidget</class> | ||
51 | <property stdset="1"> | ||
52 | <name>name</name> | ||
53 | <cstring>tab</cstring> | ||
54 | </property> | ||
55 | <attribute> | ||
56 | <name>title</name> | ||
57 | <string>Account</string> | ||
58 | </attribute> | ||
28 | <grid> | 59 | <grid> |
29 | <property stdset="1"> | 60 | <property stdset="1"> |
30 | <name>margin</name> | 61 | <name>margin</name> |
31 | <number>4</number> | 62 | <number>3</number> |
32 | </property> | 63 | </property> |
33 | <property stdset="1"> | 64 | <property stdset="1"> |
34 | <name>spacing</name> | 65 | <name>spacing</name> |
@@ -138,7 +169,7 @@ | |||
138 | <string>Use SSL</string> | 169 | <string>Use SSL</string> |
139 | </property> | 170 | </property> |
140 | </widget> | 171 | </widget> |
141 | <widget row="5" column="0" rowspan="1" colspan="2" > | 172 | <widget row="5" column="0" rowspan="2" colspan="2" > |
142 | <class>Line</class> | 173 | <class>Line</class> |
143 | <property stdset="1"> | 174 | <property stdset="1"> |
144 | <name>name</name> | 175 | <name>name</name> |
@@ -245,6 +276,70 @@ | |||
245 | </widget> | 276 | </widget> |
246 | </grid> | 277 | </grid> |
247 | </widget> | 278 | </widget> |
279 | <widget> | ||
280 | <class>QWidget</class> | ||
281 | <property stdset="1"> | ||
282 | <name>name</name> | ||
283 | <cstring>tab</cstring> | ||
284 | </property> | ||
285 | <attribute> | ||
286 | <name>title</name> | ||
287 | <string>Groups</string> | ||
288 | </attribute> | ||
289 | <vbox> | ||
290 | <property stdset="1"> | ||
291 | <name>margin</name> | ||
292 | <number>3</number> | ||
293 | </property> | ||
294 | <property stdset="1"> | ||
295 | <name>spacing</name> | ||
296 | <number>3</number> | ||
297 | </property> | ||
298 | <widget> | ||
299 | <class>QListView</class> | ||
300 | <property stdset="1"> | ||
301 | <name>name</name> | ||
302 | <cstring>ListViewGroups</cstring> | ||
303 | </property> | ||
304 | </widget> | ||
305 | <widget> | ||
306 | <class>QPushButton</class> | ||
307 | <property stdset="1"> | ||
308 | <name>name</name> | ||
309 | <cstring>GetNGButton</cstring> | ||
310 | </property> | ||
311 | <property stdset="1"> | ||
312 | <name>text</name> | ||
313 | <string>Get newsgroup list from server</string> | ||
314 | </property> | ||
315 | </widget> | ||
316 | </vbox> | ||
317 | </widget> | ||
318 | </widget> | ||
319 | </vbox> | ||
320 | </widget> | ||
321 | <customwidgets> | ||
322 | <customwidget> | ||
323 | <class>QListView</class> | ||
324 | <header location="global">qlistview.h</header> | ||
325 | <sizehint> | ||
326 | <width>-1</width> | ||
327 | <height>-1</height> | ||
328 | </sizehint> | ||
329 | <container>0</container> | ||
330 | <sizepolicy> | ||
331 | <hordata>5</hordata> | ||
332 | <verdata>5</verdata> | ||
333 | </sizepolicy> | ||
334 | <pixmap>image0</pixmap> | ||
335 | </customwidget> | ||
336 | </customwidgets> | ||
337 | <images> | ||
338 | <image> | ||
339 | <name>image0</name> | ||
340 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> | ||
341 | </image> | ||
342 | </images> | ||
248 | <tabstops> | 343 | <tabstops> |
249 | <tabstop>accountLine</tabstop> | 344 | <tabstop>accountLine</tabstop> |
250 | <tabstop>serverLine</tabstop> | 345 | <tabstop>serverLine</tabstop> |