| Line | Hits | Source |
|---|---|---|
| 1 | /******************************************************************************* | |
| 2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
| 3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
| 4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
| 5 | ||
| 6 | * This program is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU General Public License | |
| 8 | * as published by the Free Software Foundation; either version 2 | |
| 9 | * of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | 0 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | 0 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | 0 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | *******************************************************************************/ | |
| 20 | 0 | |
| 21 | 0 | package ui.util; |
| 22 | 0 | |
| 23 | 0 | import java.util.Date; |
| 24 | import java.util.Timer; | |
| 25 | 0 | import java.util.TimerTask; |
| 26 | 0 | |
| 27 | import org.apache.log4j.Logger; | |
| 28 | 0 | |
| 29 | import ui.Messages; | |
| 30 | import base.ConfigurationManager; | |
| 31 | 0 | |
| 32 | 0 | public class LogoutDaemon { |
| 33 | 0 | |
| 34 | 0 | private static final transient Logger logger = Logger |
| 35 | 0 | .getLogger(LogoutDaemon.class.getName()); |
| 36 | 0 | |
| 37 | 0 | private int seconds = 60; |
| 38 | 0 | |
| 39 | private Timer timer; | |
| 40 | 0 | |
| 41 | 0 | public LogoutDaemon(int seconds) { |
| 42 | 0 | this.seconds = seconds; |
| 43 | 0 | timer = new Timer(); |
| 44 | 0 | int scheduleTime = ConfigurationManager.getInstance() |
| 45 | 0 | .getLogoutScheduleRate() * 1000; |
| 46 | 0 | logger.debug("Logout Schedule Time :" + scheduleTime / 1000 + Messages.getString("common.unit.second")); //$NON-NLS-1$ //$NON-NLS-2$ |
| 47 | 0 | timer.scheduleAtFixedRate(new LogoutTask(), 0, ConfigurationManager |
| 48 | 0 | .getInstance().getLogoutScheduleRate() * 1000); |
| 49 | 0 | } |
| 50 | 0 | |
| 51 | class LogoutTask extends TimerTask { | |
| 52 | public void run() { | |
| 53 | Date currentDate = new Date(); | |
| 54 | if (ConfigurationManager.getInstance().getLastSeenUserWorking() | |
| 55 | .getTime() | |
| 56 | + seconds * 1000 < currentDate.getTime() | |
| 57 | && !ConfigurationManager.getInstance() | |
| 58 | .getServerLoginDialog().isVisible() | |
| 59 | && ConfigurationManager.getInstance().isPasswordProtect()) { | |
| 60 | logger.debug(Messages.getString("message.logoutsuccess")); //$NON-NLS-1$ | |
| 61 | ConfigurationManager.getInstance().getServerLoginDialog() | |
| 62 | .setVisible(true); | |
| 63 | } | |
| 64 | } | |
| 65 | } | |
| 66 | ||
| 67 | 0 | public static void main(String args[]) { |
| 68 | 0 | new LogoutDaemon(5); |
| 69 | 0 | System.out.format("Task scheduled.%n"); //$NON-NLS-1$ |
| 70 | 0 | } |
| 71 | 0 | |
| 72 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |