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.config;
017:
018: import java.io.File;
019: import java.io.FileInputStream;
020: import java.io.FileOutputStream;
021:
022: import java.util.Properties;
023:
024: public class Settings {
025: private static Properties p = new Properties();
026: public static final String propertyFilename = System
027: .getProperty("user.home")
028: + File.separator
029: + ".jftp/jftp.properties".replace('/', File.separatorChar);
030:
031: public static boolean IS_JAVA_1_6 = false;
032:
033: public static String sshHostKeyVerificationFile = System
034: .getProperty("user.home")
035: + File.separator
036: + ".jftp"
037: + File.separator
038: + ".ssh_hostfile";
039: public static final String defaultWidth = "840";
040: public static final String defaultHeight = "640";
041: public static final String defaultX = "20";
042: public static final String defaultY = "20";
043: public static int maxConnections = 3;
044: public static boolean enableResuming = false; // overridden by JFtp
045: public static boolean enableUploadResuming = false;
046: public static boolean noUploadResumingQuestion = true;
047: public static boolean askToResume = true;
048: public static boolean reconnect = true;
049: public static int uiRefresh = 500;
050: public static int logFlushInterval = 2000; // obsolete
051: public static boolean useLogFlusher = false; // obsolete
052: public static int ftpTransferThreadPause = 2000;
053: public static int smallSize = 0; //100000;
054: public static int smallSizeUp = 0; //50000;
055: public static boolean autoUpdate = false;
056: public static boolean shortProgress = true;
057: private static String defaultFtpPasvMode = "true";
058: private static String defaultEnableDebug = "false";
059: private static String enableMultiThreading = "true";
060: private static String enableSmbMultiThreading = "true";
061: private static String enableSftpMultiThreading = "true";
062: private static String noUploadMultiThreading = "false";
063: private static String storePasswords = "false";
064:
065: public static boolean newTableGui = getUseJTableLayout();
066: public static boolean useFixedTableWidths = true;
067: public static boolean enableWebDav = false;
068:
069: // 1: manual, 2: onclick, 0: off
070: public static int runtimeCommands = 2;
071: public static boolean askToRun = true;
072:
073: // currently changed by remotedir on-the-fly
074: public static boolean showDateNoSize = false;
075: public static boolean showLocalDateNoSize = false;
076:
077: // hides some messages like MODE, Type etc.
078: public static boolean hideStatus = false;
079:
080: public static boolean showNewlineOption = false;
081:
082: // for DataConnection - lower means less buffer, more updates in the downloadmanager
083: // i recommend to use values greater than 2048 bytes
084: public static int bufferSize = 8192;
085:
086: // sends NOOPs to ensure that buffers are empty
087: public static boolean safeMode = false;
088:
089: // enables some delays
090: public static boolean enableFtpDelays = false;
091:
092: // title of the app
093: public static final String title = "JFtp - The Java Network Browser";
094:
095: // overridden title for insomniac client
096: public static final String insomniacTitle = ">>> Insomniac client BETA 1 <<< Based on JFtp ";
097:
098: // override ui with the insomniac client configuration
099: public static boolean isInsomniacClient = false;
100: public static int refreshDelay = 250;
101: public static boolean useDefaultDir = true;
102:
103: // may the windows be resized?
104: public static boolean resize = true;
105: public static boolean showFileSize = true;
106: public static boolean sortDir = true;
107: public static final int visibleFileRows = 15;
108: public static int scrollSpeed = 9;
109: public static int numFiles = 9;
110: public static final int connectionTimeout = 30000;
111: public static final int testTimeout = 5000;
112: public static int statusMessageAfterMillis = 1000;
113: public static final String defaultDir = "<default>";
114: public static final String defaultWorkDir = System
115: .getProperty("user.home");
116: public static final String userHomeDir = System
117: .getProperty("user.home");
118: public static final String appHomeDir = userHomeDir
119: + "/.jftp/".replace('/', File.separatorChar);
120: public static final String greeting = "Have a lot of fun...";
121: public static final String bookmarks = appHomeDir
122: + "bookmarks.txt".replace('/', File.separatorChar);
123:
124: public static final String ls_out = appHomeDir
125: + ".ls_out".replace('/', File.separatorChar);
126:
127: public static final String login_def = appHomeDir
128: + ".login_default".replace('/', File.separatorChar);
129: public static final String login = appHomeDir
130: + ".login".replace('/', File.separatorChar);
131:
132: //*** The new files that I have created
133: public static final String last_cons = appHomeDir
134: + ".last_cons".replace('/', File.separatorChar);
135: public static final String login_def_sftp = appHomeDir
136: + ".last_cons_sftp".replace('/', File.separatorChar);
137: public static final String login_def_smb = appHomeDir
138: + ".last_cons_smb".replace('/', File.separatorChar);
139: public static final String login_def_nfs = appHomeDir
140: + ".last_cons_nfs".replace('/', File.separatorChar);
141:
142: //***
143: //*** added in version 1.44
144: public static final String adv_settings = appHomeDir
145: + ".adv_settings".replace('/', File.separatorChar);
146:
147: //***
148: public static final String readme = "docs/readme";
149: public static final String changelog = "docs/CHANGELOG";
150: public static final String todo = "docs/TODO";
151: public static final String nfsinfo = "docs/doc/nfsinfo";
152:
153: public static String iconImage;
154: public static String hostImage;
155: public static String closeImage;
156: public static String infoImage;
157: public static String listImage;
158:
159: public static String rmdirImage;
160: public static String mkdirImage;
161: public static String refreshImage;
162: public static String refreshImage2;
163: public static String cdImage;
164: public static String cmdImage;
165: public static String downloadImage;
166: public static String uploadImage;
167: public static String fileImage;
168: public static String dirImage;
169: public static String codeFileImage;
170: public static String textFileImage;
171: public static String execFileImage;
172: public static String audioFileImage;
173: public static String videoFileImage;
174: public static String htmlFileImage;
175: public static String zipFileImage;
176: public static String imageFileImage;
177: public static String presentationFileImage;
178: public static String spreadsheetFileImage;
179: public static String bookFileImage;
180: public static String copyImage;
181: public static String openImage;
182: public static String sftpImage;
183: public static String nfsImage;
184: public static String webdavImage;
185: public static String linkImage;
186: public static String typeImage;
187: public static String deleteImage;
188: public static String deleteImage2;
189: public static String clearImage;
190: public static String clearImage2;
191: public static String resumeImage;
192: public static String resumeImage2;
193: public static String pauseImage;
194: public static String pauseImage2;
195: public static String saveImage;
196: public static String cdUpImage;
197: public static String nextRSSImage;
198: public static String helpImage;
199:
200: public static String background = "images/back.jpg";
201:
202: public static boolean isStandalone = true;
203: public static String hiddenPassword = "<%hidden%>";
204:
205: public static Object setProperty(String key, String value) {
206: return p.setProperty(key, value);
207: }
208:
209: public static String getProperty(String key) {
210: return "" + p.getProperty(key);
211: }
212:
213: public static Object setProperty(String key, int value) {
214: return p.setProperty(key, Integer.toString(value));
215: }
216:
217: public static Object setProperty(String key, boolean value) {
218: String val = "false";
219:
220: if (value) {
221: val = "true";
222: }
223:
224: return p.setProperty(key, val);
225: }
226:
227: public static void save() {
228: try {
229: new File(System.getProperty("user.home") + File.separator
230: + ".jftp").mkdir();
231: p.store(new FileOutputStream(propertyFilename),
232: "jftp.properties");
233: } catch (Exception e) {
234: System.out.println("Cannot save properties...");
235:
236: //e.printStackTrace();
237: }
238: }
239:
240: public static boolean getHideLocalDotNames() {
241: String what = p.getProperty("jftp.hideHiddenDotNames", "false");
242:
243: if (what.trim().equals("false")) {
244: return false;
245: } else {
246: return true;
247: }
248: }
249:
250: public static int getMaxConnections() {
251: return maxConnections;
252: }
253:
254: public static String getSocksProxyHost() {
255: String what = p.getProperty("jftp.socksProxyHost", "");
256:
257: return what;
258: }
259:
260: public static boolean getUseJTableLayout() {
261: String what = p.getProperty("jftp.useJTableLayout", "true");
262:
263: if (what.trim().equals("false")) {
264: return false;
265: } else {
266: return true;
267: }
268: }
269:
270: public static String getSocksProxyPort() {
271: String what = p.getProperty("jftp.socksProxyPort", "");
272:
273: return what;
274: }
275:
276: public static boolean getUseBackground() {
277: String what = p.getProperty("jftp.useBackground", "true");
278:
279: if (what.trim().equals("false")) {
280: return false;
281: } else {
282: return true;
283: }
284: }
285:
286: public static boolean getEnableSshKeys() {
287: String what = p.getProperty("jftp.useSshKeyVerification",
288: "false");
289:
290: if (what.trim().equals("false")) {
291: return false;
292: } else {
293: return true;
294: }
295: }
296:
297: public static boolean getEnableResuming() {
298: String what = p.getProperty("jftp.enableResuming", "true");
299:
300: if (what.trim().equals("false")) {
301: return false;
302: } else {
303: return true;
304: }
305: }
306:
307: public static boolean getEnableDebug() {
308: String what = p.getProperty("jftp.enableDebug",
309: defaultEnableDebug);
310:
311: if (what.trim().equals("false")) {
312: return false;
313: } else {
314: return true;
315: }
316: }
317:
318: public static boolean getDisableLog() {
319: String what = p.getProperty("jftp.disableLog", "false");
320:
321: if (what.trim().equals("false")) {
322: return false;
323: } else {
324: return true;
325: }
326: }
327:
328: public static boolean getEnableStatusAnimation() {
329: String what = p.getProperty("jftp.gui.enableStatusAnimation",
330: "false");
331:
332: if (what.trim().equals("false")) {
333: return false;
334: } else {
335: return true;
336: }
337: }
338:
339: public static boolean getAskToDelete() {
340: String what = p.getProperty("jftp.gui.askToDelete", "true");
341:
342: if (what.trim().equals("false")) {
343: return false;
344: } else {
345: return true;
346: }
347: }
348:
349: public static String getLookAndFeel() {
350: return p.getProperty("jftp.gui.look", null);
351: }
352:
353: public static boolean getUseNewIcons() {
354: String what = p.getProperty("jftp.gui.look.newIcons", "true");
355:
356: if (what.trim().equals("false")) {
357: return false;
358: } else {
359: return true;
360: }
361: }
362:
363: public static boolean getEnableMultiThreading() {
364: String what = p.getProperty("jftp.enableMultiThreading",
365: enableMultiThreading);
366:
367: if (what.trim().equals("false")) {
368: return false;
369: } else {
370: return true;
371: }
372: }
373:
374: public static boolean getEnableSmbMultiThreading() {
375: String what = p.getProperty("jftp.enableSmbMultiThreading",
376: enableSmbMultiThreading);
377:
378: if (what.trim().equals("false")) {
379: return false;
380: } else {
381: return true;
382: }
383: }
384:
385: public static boolean getEnableSftpMultiThreading() {
386: String what = p.getProperty("jftp.enableSftpMultiThreading",
387: enableSftpMultiThreading);
388:
389: if (what.trim().equals("false")) {
390: return false;
391: } else {
392: return true;
393: }
394: }
395:
396: public static boolean getNoUploadMultiThreading() {
397: String what = p.getProperty("jftp.noUploadMultiThreading",
398: noUploadMultiThreading);
399:
400: if (what.trim().equals("false")) {
401: return false;
402: } else {
403: return true;
404: }
405: }
406:
407: public static boolean getFtpPasvMode() {
408: String what = p.getProperty("jftp.ftpPasvMode",
409: defaultFtpPasvMode);
410:
411: if (what.trim().equals("false")) {
412: return false;
413: } else {
414: return true;
415: }
416: }
417:
418: public static boolean getUseDefaultDir() {
419: String what = p.getProperty("jftp.useDefaultDir", "true");
420:
421: if (what.trim().equals("false")) {
422: return false;
423: } else {
424: return true;
425: }
426: }
427:
428: public static boolean getEnableRSS() {
429: String what = p.getProperty("jftp.enableRSS", "false");
430:
431: if (what.trim().equals("false")) {
432: return false;
433: } else {
434: return true;
435: }
436: }
437:
438: public static String getRSSFeed() {
439: String what = p.getProperty("jftp.customRSSFeed",
440: "http://slashdot.org/rss/slashdot.rss");
441:
442: return what;
443: }
444:
445: public static java.awt.Dimension getWindowSize() {
446: int width = Integer.parseInt(p.getProperty("jftp.window.width",
447: defaultWidth));
448: int height = Integer.parseInt(p.getProperty(
449: "jftp.window.height", defaultHeight));
450:
451: return new java.awt.Dimension(width, height);
452: }
453:
454: public static java.awt.Point getWindowLocation() {
455: int x = Integer.parseInt(p.getProperty("jftp.window.x",
456: defaultX));
457: int y = Integer.parseInt(p.getProperty("jftp.window.y",
458: defaultY));
459:
460: return new java.awt.Point(x, y);
461: }
462:
463: public static int getSocketTimeout() {
464: return 3000;
465: }
466:
467: public static boolean getStorePasswords() {
468: String what = p.getProperty("jftp.security.storePasswords",
469: storePasswords);
470:
471: if (what.trim().equals("false")) {
472: return false;
473: } else {
474: return true;
475: }
476: }
477:
478: static {
479: try {
480: p.load(new FileInputStream(propertyFilename));
481: } catch (Exception e) {
482: System.out
483: .println("no property file loaded, using defaults... ("
484: + e + ")");
485: }
486:
487: if (!getUseNewIcons()) {
488: iconImage = "images/org/javalobby/icons/20x20/ComputerIn.gif";
489: hostImage = "images/org/javalobby/icons/20x20/ComputerIn.gif";
490: closeImage = "images/org/javalobby/icons/20x20/Error.gif";
491: infoImage = "images/org/javalobby/icons/20x20/Inform.gif";
492: listImage = "images/org/javalobby/icons/20x20/List.gif";
493: deleteImage = "images/org/javalobby/icons/16x16/DeleteDocument.gif";
494: deleteImage2 = "images/org/javalobby/icons/16x16/DeleteDocument.gif";
495: rmdirImage = "images/org/javalobby/icons/16x16/DeleteFolder.gif";
496: mkdirImage = "images/org/javalobby/icons/16x16/NewFolder.gif";
497: refreshImage = "images/org/javalobby/icons/16x16/Undo.gif";
498: refreshImage2 = "images/org/javalobby/icons/16x16/Undo.gif";
499: cdImage = "images/org/javalobby/icons/16x16/Open.gif";
500: cmdImage = "images/org/javalobby/icons/16x16/ExecuteProject.gif";
501: downloadImage = "images/org/javalobby/icons/16x16/Left.gif";
502: uploadImage = "images/org/javalobby/icons/16x16/Right.gif";
503: fileImage = "images/org/javalobby/icons/16x16/Document.gif";
504: dirImage = "images/org/javalobby/icons/16x16/Folder.gif";
505: codeFileImage = "images/org/javalobby/icons/16x16/List.gif";
506: textFileImage = "images/org/javalobby/icons/16x16/DocumentDraw.gif";
507: execFileImage = "images/org/javalobby/icons/16x16/ExecuteProject.gif";
508: audioFileImage = "images/org/javalobby/icons/16x16/cd.gif";
509: videoFileImage = "images/org/javalobby/icons/16x16/CameraFlash.gif";
510: htmlFileImage = "images/org/javalobby/icons/16x16/World2.gif";
511: zipFileImage = "images/org/javalobby/icons/16x16/DataStore.gif";
512: imageFileImage = "images/org/javalobby/icons/16x16/Camera.gif";
513: presentationFileImage = "images/org/javalobby/icons/16x16/DocumentDiagram.gif";
514: spreadsheetFileImage = "images/org/javalobby/icons/16x16/DatePicker.gif";
515: bookFileImage = "images/org/javalobby/icons/16x16/Book.gif";
516: copyImage = "images/org/javalobby/icons/16x16/Copy.gif";
517: openImage = "images/org/javalobby/icons/16x16/World2.gif";
518: sftpImage = "images/org/javalobby/icons/16x16/NewEnvelope.gif";
519: nfsImage = "images/org/javalobby/icons/16x16/TrafficGreen.gif";
520: webdavImage = "images/org/javalobby/icons/16x16/DataStore.gif";
521: linkImage = "images/org/javalobby/icons/16x16/Right.gif";
522: typeImage = "images/org/javalobby/icons/20x20/Type.gif";
523: clearImage = "images/org/javalobby/icons/16x16/Undo.gif";
524: resumeImage = "images/org/javalobby/icons/16x16/GreenCircle.gif";
525: pauseImage = "images/org/javalobby/icons/16x16/RedCircle.gif";
526: clearImage2 = "images/org/javalobby/icons/16x16/Undo.gif";
527: resumeImage2 = "images/org/javalobby/icons/16x16/GreenCircle.gif";
528: pauseImage2 = "images/org/javalobby/icons/16x16/RedCircle.gif";
529: saveImage = "images/org/javalobby/icons/16x16/Save.gif";
530: cdUpImage = "images/org/javalobby/icons/16x16/Exit.gif";
531: nextRSSImage = "images/org/javalobby/icons/16x16/Forward.gif";
532: helpImage = "images/silk/help.png";
533: } else {
534: iconImage = "images/silk/server_add.png";
535: hostImage = "images/silk/server_add.png";
536: closeImage = "images/silk/cancel.png";
537: infoImage = "images/silk/information.png";
538: listImage = "images/silk/page_white_text.png";
539:
540: rmdirImage = "images/silk/folder_delete.png";
541: mkdirImage = "images/silk/folder_add.png";
542: refreshImage = "images/silk/control_repeat.png";
543: refreshImage2 = "images/silk/control_repeat_blue.png";
544: cdImage = "images/silk/folder_explore.png";
545: cmdImage = "images/silk/application_xp_terminal.png";
546: downloadImage = "images/silk/arrow_left.png";
547: uploadImage = "images/silk/arrow_right.png";
548: fileImage = "images/silk/page_white.png";
549: dirImage = "images/silk/folder.png";
550: codeFileImage = "images/silk/page_white_wrench.png";
551: textFileImage = "images/silk/page_white_text.png";
552: execFileImage = "images/silk/cog.png";
553: audioFileImage = "images/silk/ipod.png";
554: videoFileImage = "images/silk/camera.png";
555: htmlFileImage = "images/silk/html.png";
556: zipFileImage = "images/silk/page_white_zip.png";
557: imageFileImage = "images/silk/image.png";
558: presentationFileImage = "images/silk/page_white_powerpoint.png";
559: spreadsheetFileImage = "images/silk/page_excel.png";
560: bookFileImage = "images/silk/book.png";
561: copyImage = "images/silk/disk_multiple.png";
562: openImage = "images/silk/drive_web.png";
563: sftpImage = "images/silk/drive_link.png";
564: nfsImage = "images/silk/drive_network.png";
565: webdavImage = "images/silk/house_go.png";
566: linkImage = "images/silk/arrow_right.png";
567: typeImage = "images/silk/email_go.png";
568: deleteImage = "images/silk/control_stop.png";
569: deleteImage2 = "images/silk/control_stop_blue.png";
570: clearImage = "images/silk/control_eject.png";
571: clearImage2 = "images/silk/control_eject_blue.png";
572: resumeImage = "images/silk/control_play.png";
573: resumeImage2 = "images/silk/control_play_blue.png";
574: pauseImage = "images/silk/control_pause.png";
575: pauseImage2 = "images/silk/control_pause_blue.png";
576: saveImage = "images/silk/disk.png";
577: cdUpImage = "images/silk/arrow_up.png";
578: nextRSSImage = "images/silk/rss_go.png";
579: helpImage = "images/silk/help.png";
580: }
581:
582: }
583:
584: }
|