File: Settings.java

package info (click to toggle)
jftp 1.52+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,852 kB
  • ctags: 2,972
  • sloc: java: 22,890; xml: 186; sh: 26; makefile: 19
file content (676 lines) | stat: -rwxr-xr-x 23,096 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package net.sf.jftp.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import java.util.Properties;


public class Settings
{
    private static Properties p = new Properties();
    public static final String propertyFilename = System.getProperty("user.home") +
                                                  File.separator +
                                                  ".jftp/jftp.properties".replace('/',
                                                                                  File.separatorChar);

    public static boolean IS_JAVA_1_6 = true;
    

    public static String sshHostKeyVerificationFile = System.getProperty("user.home") +
                                                      File.separator + ".jftp" +
                                                      File.separator +
                                                      ".ssh_hostfile";
    public static final String defaultWidth = "840";
    public static final String defaultHeight = "640";
    public static final String defaultX = "20";
    public static final String defaultY = "20";
    public static int maxConnections = 3;
    public static boolean enableResuming = false; // overridden by JFtp
    public static boolean enableUploadResuming = false;
    public static boolean noUploadResumingQuestion = true;
    public static boolean askToResume = true;
    public static boolean reconnect = true;
    public static int uiRefresh = 500;
    public static int logFlushInterval = 2000; // obsolete
    public static boolean useLogFlusher = false; // obsolete
    public static int ftpTransferThreadPause = 2000;
    public static int smallSize = 0; //100000;
    public static int smallSizeUp = 0; //50000;
    public static boolean autoUpdate = false;
    public static boolean shortProgress = true;
    private static String defaultFtpPasvMode = "true";
    private static String defaultEnableDebug = "false";
    private static String enableMultiThreading = "true";
    private static String enableSmbMultiThreading = "true";
    private static String enableSftpMultiThreading = "true";
    private static String noUploadMultiThreading = "false";
    private static String storePasswords = "false";
    
    public static boolean newTableGui = getUseJTableLayout();
    public static boolean useFixedTableWidths = true;

    
    // 1: manual, 2: onclick, 0: off
    public static int runtimeCommands = 2;
    public static boolean askToRun = true;

    // currently changed by remotedir on-the-fly
    public static boolean showDateNoSize = false;
    public static boolean showLocalDateNoSize = false;

    // hides some messages like MODE, Type etc.
    public static boolean hideStatus = false;

    public static boolean showNewlineOption = false;

    // for DataConnection - lower means less buffer, more updates in the downloadmanager
    // i recommend to use values greater than 2048 bytes
    public static int bufferSize = 8192;

    // sends NOOPs to ensure that buffers are empty
    public static boolean safeMode = false;

    // enables some delays 
    public static boolean enableFtpDelays = false;

    // title of the app
    public static final String title = "JFtp - The Java Network Browser";

    // overridden title for insomniac client
    public static final String insomniacTitle = ">>> Insomniac client BETA 1 <<< Based on JFtp ";

    // override ui with the insomniac client configuration
    public static boolean isInsomniacClient = false;
    public static int refreshDelay = 250;
    public static boolean useDefaultDir = true;

    // may the windows be resized?
    public static boolean resize = true;
    public static boolean showFileSize = true;
    public static boolean sortDir = true;
    public static final int visibleFileRows = 15;
    public static int scrollSpeed = 9;
    public static int numFiles = 9;
    public static final int connectionTimeout = 30000;
    public static final int testTimeout = 5000;
    public static int statusMessageAfterMillis = 1000;
    public static final String defaultDir = "<default>";
    public static final String defaultWorkDir = System.getProperty("user.home");
    public static final String userHomeDir = System.getProperty("user.home");
    public static final String appHomeDir = userHomeDir +
                                            "/.jftp/".replace('/',
                                                              File.separatorChar);
    public static final String greeting = "Have a lot of fun...";
    public static final String bookmarks = appHomeDir +
                                           "bookmarks.txt".replace('/',
                                                                   File.separatorChar);

    public static final String ls_out = appHomeDir+".ls_out".replace('/', File.separatorChar);
                                 
    public static final String login_def = appHomeDir +
                                           ".login_default".replace('/',
                                                                    File.separatorChar);
    public static final String login = appHomeDir +
                                       ".login".replace('/', File.separatorChar);

    //*** The new files that I have created
    public static final String last_cons = appHomeDir +
                                           ".last_cons".replace('/',
                                                                File.separatorChar);
    public static final String login_def_sftp = appHomeDir +
                                                ".last_cons_sftp".replace('/',
                                                                          File.separatorChar);
    public static final String login_def_smb = appHomeDir +
                                               ".last_cons_smb".replace('/',
                                                                        File.separatorChar);
    public static final String login_def_nfs = appHomeDir +
                                               ".last_cons_nfs".replace('/',
                                                                        File.separatorChar);

    //***
    //*** added in version 1.44
    public static final String adv_settings = appHomeDir +
                                              ".adv_settings".replace('/',
                                                                      File.separatorChar);

    //***
    public static final String readme = "docs/readme";
    public static final String changelog = "docs/CHANGELOG";
    public static final String todo = "docs/TODO";
    public static final String nfsinfo = "docs/doc/nfsinfo";
    
    
    public static String iconImage;
    public static String hostImage;   
    public static String closeImage;
    public static String infoImage;  
    public static String listImage;  
 
    public static String rmdirImage;  
    public static String mkdirImage;   
    public static String refreshImage;
    public static String refreshImage2; 
    public static String cdImage; 
    public static String cmdImage;   
    public static String downloadImage;
    public static String uploadImage;
    public static String fileImage;
    public static String dirImage; 
    public static String codeFileImage;
    public static String textFileImage;
    public static String execFileImage;
    public static String audioFileImage;
    public static String videoFileImage;
    public static String htmlFileImage;
    public static String zipFileImage;
    public static String imageFileImage;
    public static String presentationFileImage;
    public static String spreadsheetFileImage;
    public static String bookFileImage;  
    public static String copyImage;   
    public static String openImage;
    public static String sftpImage;
    public static String nfsImage;
    public static String linkImage;
    public static String typeImage;
    public static String deleteImage; 
    public static String deleteImage2; 
    public static String clearImage; 
    public static String clearImage2; 
    public static String resumeImage;
    public static String resumeImage2;
    public static String pauseImage;
    public static String pauseImage2;
    public static String saveImage;
    public static String cdUpImage;
    public static String nextRSSImage;
    public static String helpImage;
    

    public static String background = "images/back.jpg";
    
    //set to false if you want it to run as an applet
    public static boolean isStandalone = true;
    
    
    public static String hiddenPassword = "<%hidden%>";

    public static Object setProperty(String key, String value)
    {
        return p.setProperty(key, value);
    }

    public static String getProperty(String key) {
    	return ""+p.getProperty(key);
    }
    
    public static Object setProperty(String key, int value)
    {
        return p.setProperty(key, Integer.toString(value));
    }

    public static Object setProperty(String key, boolean value)
    {
        String val = "false";

        if(value)
        {
            val = "true";
        }

        return p.setProperty(key, val);
    }

    public static void save()
    {
        try
        {
            new File(System.getProperty("user.home") + File.separator +
                     ".jftp").mkdir();
            p.store(new FileOutputStream(propertyFilename), "jftp.properties");
        }
        catch(Exception e)
        {
            System.out.println("Cannot save properties...");

            //e.printStackTrace();
        }
    }

    public static boolean getHideLocalDotNames() {
        String what = p.getProperty("jftp.hideHiddenDotNames", "false");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    public static int getMaxConnections()
    {
        return maxConnections;
    }

    public static String getSocksProxyHost()
    {
        String what = p.getProperty("jftp.socksProxyHost", "");

        return what;
    }

    public static boolean getUseJTableLayout()
    {
        String what = p.getProperty("jftp.useJTableLayout", "true");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    public static String getSocksProxyPort()
    {
        String what = p.getProperty("jftp.socksProxyPort", "");

        return what;
    }

    public static boolean getUseBackground()
    {
        String what = p.getProperty("jftp.useBackground", "true");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableSshKeys()
    {
        String what = p.getProperty("jftp.useSshKeyVerification", "false");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableResuming()
    {
        String what = p.getProperty("jftp.enableResuming", "true");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableDebug()
    {
        String what = p.getProperty("jftp.enableDebug", defaultEnableDebug);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getDisableLog()
    {
        String what = p.getProperty("jftp.disableLog", "false");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableStatusAnimation()
    {
        String what = p.getProperty("jftp.gui.enableStatusAnimation", "false");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getAskToDelete()
    {
        String what = p.getProperty("jftp.gui.askToDelete", "true");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static String getLookAndFeel()
    {
        return p.getProperty("jftp.gui.look", null);
    }
    
    public static boolean getUseNewIcons()
    {
        String what = p.getProperty("jftp.gui.look.newIcons", "true");
        
        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableMultiThreading()
    {
        String what = p.getProperty("jftp.enableMultiThreading",
                                    enableMultiThreading);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableSmbMultiThreading()
    {
        String what = p.getProperty("jftp.enableSmbMultiThreading",
                                    enableSmbMultiThreading);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableSftpMultiThreading()
    {
        String what = p.getProperty("jftp.enableSftpMultiThreading",
                                    enableSftpMultiThreading);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getNoUploadMultiThreading()
    {
        String what = p.getProperty("jftp.noUploadMultiThreading",
                                    noUploadMultiThreading);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getFtpPasvMode()
    {
        String what = p.getProperty("jftp.ftpPasvMode", defaultFtpPasvMode);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getUseDefaultDir()
    {
        String what = p.getProperty("jftp.useDefaultDir", "true");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static boolean getEnableRSS()
    {
        String what = p.getProperty("jftp.enableRSS", "false");

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public static String getRSSFeed()
    {
        String what = p.getProperty("jftp.customRSSFeed",
                                    "http://slashdot.org/rss/slashdot.rss");

        return what;
    }

    public static java.awt.Dimension getWindowSize()
    {
        int width = Integer.parseInt(p.getProperty("jftp.window.width",
                                                   defaultWidth));
        int height = Integer.parseInt(p.getProperty("jftp.window.height",
                                                    defaultHeight));

        return new java.awt.Dimension(width, height);
    }

    public static java.awt.Point getWindowLocation()
    {
        int x = Integer.parseInt(p.getProperty("jftp.window.x", defaultX));
        int y = Integer.parseInt(p.getProperty("jftp.window.y", defaultY));

        return new java.awt.Point(x, y);
    }

    public static int getSocketTimeout()
    {
        return 3000;
    }

    public static boolean getStorePasswords()
    {
        String what = p.getProperty("jftp.security.storePasswords",
                                    storePasswords);

        if(what.trim().equals("false"))
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    static
    {
        try
        {
            p.load(new FileInputStream(propertyFilename));
        }
        catch(Exception e)
        {
            System.out.println("no property file loaded, using defaults... (" +
                               e + ")");
        }
        
        if(!getUseNewIcons()) {
        	iconImage = "images/org/javalobby/icons/20x20/ComputerIn.gif";
        	hostImage = "images/org/javalobby/icons/20x20/ComputerIn.gif";
        	closeImage = "images/org/javalobby/icons/20x20/Error.gif";
        	infoImage = "images/org/javalobby/icons/20x20/Inform.gif";
        	listImage = "images/org/javalobby/icons/20x20/List.gif";
        	deleteImage = "images/org/javalobby/icons/16x16/DeleteDocument.gif";
        	deleteImage2 = "images/org/javalobby/icons/16x16/DeleteDocument.gif";
        	rmdirImage = "images/org/javalobby/icons/16x16/DeleteFolder.gif";
        	mkdirImage = "images/org/javalobby/icons/16x16/NewFolder.gif";
        	refreshImage = "images/org/javalobby/icons/16x16/Undo.gif";
        	refreshImage2 = "images/org/javalobby/icons/16x16/Undo.gif";
        	cdImage = "images/org/javalobby/icons/16x16/Open.gif";
        	cmdImage = "images/org/javalobby/icons/16x16/ExecuteProject.gif";
        	downloadImage = "images/org/javalobby/icons/16x16/Left.gif";
        	uploadImage = "images/org/javalobby/icons/16x16/Right.gif";
        	fileImage = "images/org/javalobby/icons/16x16/Document.gif";
        	dirImage = "images/org/javalobby/icons/16x16/Folder.gif";
        	codeFileImage = "images/org/javalobby/icons/16x16/List.gif";
        	textFileImage = "images/org/javalobby/icons/16x16/DocumentDraw.gif";
        	execFileImage = "images/org/javalobby/icons/16x16/ExecuteProject.gif";
        	audioFileImage = "images/org/javalobby/icons/16x16/cd.gif";
        	videoFileImage = "images/org/javalobby/icons/16x16/CameraFlash.gif";
        	htmlFileImage = "images/org/javalobby/icons/16x16/World2.gif";
        	zipFileImage = "images/org/javalobby/icons/16x16/DataStore.gif";
        	imageFileImage = "images/org/javalobby/icons/16x16/Camera.gif";
        	presentationFileImage = "images/org/javalobby/icons/16x16/DocumentDiagram.gif";
        	spreadsheetFileImage = "images/org/javalobby/icons/16x16/DatePicker.gif";
        	bookFileImage = "images/org/javalobby/icons/16x16/Book.gif";
        	copyImage = "images/org/javalobby/icons/16x16/Copy.gif";
        	openImage = "images/org/javalobby/icons/16x16/World2.gif";
        	sftpImage = "images/org/javalobby/icons/16x16/NewEnvelope.gif";
        	nfsImage = "images/org/javalobby/icons/16x16/TrafficGreen.gif";
        	linkImage = "images/org/javalobby/icons/16x16/Right.gif";
        	typeImage = "images/org/javalobby/icons/20x20/Type.gif";
        	clearImage = "images/org/javalobby/icons/16x16/Undo.gif";
        	resumeImage = "images/org/javalobby/icons/16x16/GreenCircle.gif";
        	pauseImage = "images/org/javalobby/icons/16x16/RedCircle.gif";
        	clearImage2 = "images/org/javalobby/icons/16x16/Undo.gif";
        	resumeImage2 = "images/org/javalobby/icons/16x16/GreenCircle.gif";
        	pauseImage2 = "images/org/javalobby/icons/16x16/RedCircle.gif";
        	saveImage = "images/org/javalobby/icons/16x16/Save.gif";
        	cdUpImage = "images/org/javalobby/icons/16x16/Exit.gif";
        	nextRSSImage = "images/org/javalobby/icons/16x16/Forward.gif";
        	helpImage = "images/current/help.png";
        }
        else {  
        	iconImage = "images/current/server_add.png";
        	hostImage = "images/current/server_add.png";   
        	closeImage = "images/current/cancel.png";
        	infoImage = "images/current/information.png";  
        	listImage = "images/current/page_white_text.png";  

        	rmdirImage = "images/current/folder_delete.png";  
        	mkdirImage = "images/current/folder_add.png";   
        	refreshImage = "images/current/control_repeat.png";
        	refreshImage2 = "images/current/control_repeat_blue.png"; 
        	cdImage = "images/current/folder_explore.png"; 
        	cmdImage = "images/current/application_xp_terminal.png";   
        	downloadImage = "images/current/arrow_left.png";
        	uploadImage = "images/current/arrow_right.png";
        	fileImage = "images/current/page_white.png";
        	dirImage = "images/current/folder.png"; 
        	codeFileImage = "images/current/page_white_wrench.png";
        	textFileImage = "images/current/page_white_text.png";
        	execFileImage = "images/current/cog.png";
        	audioFileImage = "images/current/ipod.png";
        	videoFileImage = "images/current/camera.png";
        	htmlFileImage = "images/current/html.png";
        	zipFileImage = "images/current/page_white_zip.png";
        	imageFileImage = "images/current/image.png";
        	presentationFileImage = "images/current/page_white_powerpoint.png";
        	spreadsheetFileImage = "images/current/page_excel.png";
        	bookFileImage = "images/current/book.png";  
        	copyImage = "images/current/disk_multiple.png";   
        	openImage = "images/current/drive_web.png";
        	sftpImage = "images/current/drive_link.png";
        	nfsImage = "images/current/drive_network.png";
        	linkImage = "images/current/arrow_right.png";
        	typeImage = "images/current/email_go.png";
        	deleteImage = "images/current/control_stop.png"; 
        	deleteImage2 = "images/current/control_stop_blue.png"; 
        	clearImage = "images/current/control_eject.png"; 
        	clearImage2 = "images/current/control_eject_blue.png"; 
        	resumeImage = "images/current/control_play.png";
        	resumeImage2 = "images/current/control_play_blue.png";
        	pauseImage = "images/current/control_pause.png";
        	pauseImage2 = "images/current/control_pause_blue.png";
        	saveImage = "images/current/disk.png";
        	cdUpImage = "images/current/arrow_up.png";
        	nextRSSImage = "images/current/rss_go.png";
        	helpImage = "images/current/help.png";
        }

    }

}