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/net/mail/accountitem.cpp | |
parent | 225b92ec28bbe3a9368e8534323a3c335432e447 (diff) | |
download | opie-dcf152e23f7cc85fe2e46521e07b64e2288efdda.zip opie-dcf152e23f7cc85fe2e46521e07b64e2288efdda.tar.gz opie-dcf152e23f7cc85fe2e46521e07b64e2288efdda.tar.bz2 |
beginning of nntp stuff
Diffstat (limited to 'noncore/net/mail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 190 |
1 files changed, 190 insertions, 0 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 | |||
@@ -206,12 +206,202 @@ void POP3folderItem::contextMenuSelected(int which) | |||
206 | default: | 206 | default: |
207 | break; | 207 | break; |
208 | } | 208 | } |
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 ) |
215 | : AccountViewItem( parent ) | 405 | : AccountViewItem( parent ) |
216 | { | 406 | { |
217 | account = a; | 407 | account = a; |