KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > jmail > base > FolderListener


1 package org.lucane.applications.jmail.base;
2
3 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * This file is part of JMail *
5  * Copyright (C) 2002-2003 Yvan Norsa <norsay@wanadoo.fr> *
6  * *
7  * JMail is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * any later version. *
11  * *
12  * JMail is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License along *
18  * with JMail; if not, write to the Free Software Foundation, Inc., *
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20  * *
21  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

22
23 import javax.mail.*;
24
25 /** Threaded listener to periodically check the mailbox
26  (works only on IMAP) */

27 final class FolderListener extends Thread JavaDoc
28 {
29     /** JMail's panel */
30     private MainPanel panel;
31     private int refreshInterval;
32     
33     /** Constructor
34      * @param panel JMail's panel
35      */

36     protected FolderListener(Profile profile, MainPanel panel)
37     {
38         this.panel = panel;
39         this.refreshInterval = profile.getRefreshInterval();
40     }
41     
42     /** Main loop */
43     public final void run()
44     {
45         Folder f = null;
46         
47         try
48         {
49             while(true)
50             {
51                 Thread.sleep(refreshInterval);
52                 
53                 f = panel.getCurrentFolder();
54                 
55                 if(f != null)
56                     if(f.isOpen())
57                         f.getMessageCount();
58             }
59         }
60         
61         catch(Exception JavaDoc e)
62         {
63             e.printStackTrace();
64         }
65     }
66 }
67
Popular Tags