001: /*
002: * This program is free software; you can redistribute it and/or
003: * modify it under the terms of the GNU General Public License
004: * as published by the Free Software Foundation; either version 2
005: * of the License, or (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU General Public License for more details.
011:
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package net.sf.jftp.system;
017:
018: import net.sf.jftp.JFtp;
019: import net.sf.jftp.config.Settings;
020: import net.sf.jftp.gui.*;
021: import net.sf.jftp.gui.base.LocalDir;
022: import net.sf.jftp.gui.base.RemoteDir;
023: import net.sf.jftp.util.*;
024:
025: public class UpdateDaemon implements Runnable {
026: private static int rem;
027: private static int loc;
028: private static int log;
029: private static int reg;
030: private static int cal;
031: private Thread runner = null;
032: private JFtp jftp;
033:
034: public UpdateDaemon(JFtp jftp) {
035: this .jftp = jftp;
036:
037: runner = new Thread(this );
038: runner.start();
039: }
040:
041: public static void updateRemoteDirGUI() {
042: //System.out.print("+");
043: reg++;
044: }
045:
046: public static void updateRemoteDir() {
047: //System.out.print("-");
048: rem++;
049: }
050:
051: public static void updateLocalDir() {
052: //System.out.print("#");
053: loc++;
054: }
055:
056: public static void updateLog() {
057: //System.out.print(".");
058: log++;
059: }
060:
061: public static void updateCall() {
062: cal++;
063: }
064:
065: public void run() {
066: while (true) {
067: try {
068: //System.out.print(":");
069: if (rem > 0) {
070: ((RemoteDir) jftp.remoteDir).fresh();
071:
072: //System.out.print("R");
073: rem = 0;
074: Thread.sleep(100);
075: }
076:
077: if (reg > 0) {
078: ((RemoteDir) jftp.remoteDir).gui(true);
079:
080: //System.out.print("r");
081: reg = 0;
082: Thread.sleep(100);
083: }
084:
085: if (loc > 0) {
086: ((LocalDir) jftp.localDir).fresh();
087:
088: //System.out.print("L");
089: loc = 0;
090: Thread.sleep(100);
091: }
092:
093: if (cal > 0) {
094: jftp.fireUpdate();
095: cal = 0;
096: Thread.sleep(100);
097: }
098:
099: if (log > 0) {
100: jftp.ensureLogging();
101:
102: //System.out.print("O");
103: log = 0;
104: Thread.sleep(500);
105: }
106:
107: Thread.sleep(Settings.uiRefresh);
108: } catch (Exception ex) {
109: ex.printStackTrace();
110: System.exit(1);
111: }
112: }
113: }
114: }
|