1 16 package net.sf.jftp.config; 17 18 import java.io.File ; 19 import java.io.FileInputStream ; 20 import java.io.FileOutputStream ; 21 22 import java.util.Properties ; 23 24 25 public class Settings 26 { 27 private static Properties p = new Properties (); 28 public static final String propertyFilename = System.getProperty("user.home") + 29 File.separator + 30 ".jftp/jftp.properties".replace('/', 31 File.separatorChar); 32 33 public static boolean IS_JAVA_1_6 = false; 34 35 36 public static String sshHostKeyVerificationFile = System.getProperty("user.home") + 37 File.separator + ".jftp" + 38 File.separator + 39 ".ssh_hostfile"; 40 public static final String defaultWidth = "840"; 41 public static final String defaultHeight = "640"; 42 public static final String defaultX = "20"; 43 public static final String defaultY = "20"; 44 public static int maxConnections = 3; 45 public static boolean enableResuming = false; public static boolean enableUploadResuming = false; 47 public static boolean noUploadResumingQuestion = true; 48 public static boolean askToResume = true; 49 public static boolean reconnect = true; 50 public static int uiRefresh = 500; 51 public static int logFlushInterval = 2000; public static boolean useLogFlusher = false; public static int ftpTransferThreadPause = 2000; 54 public static int smallSize = 0; public static int smallSizeUp = 0; public static boolean autoUpdate = false; 57 public static boolean shortProgress = true; 58 private static String defaultFtpPasvMode = "true"; 59 private static String defaultEnableDebug = "false"; 60 private static String enableMultiThreading = "true"; 61 private static String enableSmbMultiThreading = "true"; 62 private static String enableSftpMultiThreading = "true"; 63 private static String noUploadMultiThreading = "false"; 64 private static String storePasswords = "false"; 65 66 public static boolean newTableGui = getUseJTableLayout(); 67 public static boolean useFixedTableWidths = true; 68 public static boolean enableWebDav = false; 69 70 71 public static int runtimeCommands = 2; 73 public static boolean askToRun = true; 74 75 public static boolean showDateNoSize = false; 77 public static boolean showLocalDateNoSize = false; 78 79 public static boolean hideStatus = false; 81 82 public static boolean showNewlineOption = false; 83 84 public static int bufferSize = 8192; 87 88 public static boolean safeMode = false; 90 91 public static boolean enableFtpDelays = false; 93 94 public static final String title = "JFtp - The Java Network Browser"; 96 97 public static final String insomniacTitle = ">>> Insomniac client BETA 1 <<< Based on JFtp "; 99 100 public static boolean isInsomniacClient = false; 102 public static int refreshDelay = 250; 103 public static boolean useDefaultDir = true; 104 105 public static boolean resize = true; 107 public static boolean showFileSize = true; 108 public static boolean sortDir = true; 109 public static final int visibleFileRows = 15; 110 public static int scrollSpeed = 9; 111 public static int numFiles = 9; 112 public static final int connectionTimeout = 30000; 113 public static final int testTimeout = 5000; 114 public static int statusMessageAfterMillis = 1000; 115 public static final String defaultDir = "<default>"; 116 public static final String defaultWorkDir = System.getProperty("user.home"); 117 public static final String userHomeDir = System.getProperty("user.home"); 118 public static final String appHomeDir = userHomeDir + 119 "/.jftp/".replace('/', 120 File.separatorChar); 121 public static final String greeting = "Have a lot of fun..."; 122 public static final String bookmarks = appHomeDir + 123 "bookmarks.txt".replace('/', 124 File.separatorChar); 125 126 public static final String ls_out = appHomeDir+".ls_out".replace('/', File.separatorChar); 127 128 public static final String login_def = appHomeDir + 129 ".login_default".replace('/', 130 File.separatorChar); 131 public static final String login = appHomeDir + 132 ".login".replace('/', File.separatorChar); 133 134 public static final String last_cons = appHomeDir + 136 ".last_cons".replace('/', 137 File.separatorChar); 138 public static final String login_def_sftp = appHomeDir + 139 ".last_cons_sftp".replace('/', 140 File.separatorChar); 141 public static final String login_def_smb = appHomeDir + 142 ".last_cons_smb".replace('/', 143 File.separatorChar); 144 public static final String login_def_nfs = appHomeDir + 145 ".last_cons_nfs".replace('/', 146 File.separatorChar); 147 148 public static final String adv_settings = appHomeDir + 151 ".adv_settings".replace('/', 152 File.separatorChar); 153 154 public static final String readme = "docs/readme"; 156 public static final String changelog = "docs/CHANGELOG"; 157 public static final String todo = "docs/TODO"; 158 public static final String nfsinfo = "docs/doc/nfsinfo"; 159 160 161 public static String iconImage; 162 public static String hostImage; 163 public static String closeImage; 164 public static String infoImage; 165 public static String listImage; 166 167 public static String rmdirImage; 168 public static String mkdirImage; 169 public static String refreshImage; 170 public static String refreshImage2; 171 public static String cdImage; 172 public static String cmdImage; 173 public static String downloadImage; 174 public static String uploadImage; 175 public static String fileImage; 176 public static String dirImage; 177 public static String codeFileImage; 178 public static String textFileImage; 179 public static String execFileImage; 180 public static String audioFileImage; 181 public static String videoFileImage; 182 public static String htmlFileImage; 183 public static String zipFileImage; 184 public static String imageFileImage; 185 public static String presentationFileImage; 186 public static String spreadsheetFileImage; 187 public static String bookFileImage; 188 public static String copyImage; 189 public static String openImage; 190 public static String sftpImage; 191 public static String nfsImage; 192 public static String webdavImage; 193 public static String linkImage; 194 public static String typeImage; 195 public static String deleteImage; 196 public static String deleteImage2; 197 public static String clearImage; 198 public static String clearImage2; 199 public static String resumeImage; 200 public static String resumeImage2; 201 public static String pauseImage; 202 public static String pauseImage2; 203 public static String saveImage; 204 public static String cdUpImage; 205 public static String nextRSSImage; 206 public static String helpImage; 207 208 209 public static String background = "images/back.jpg"; 210 211 public static boolean isStandalone = true; 212 public static String hiddenPassword = "<%hidden%>"; 213 214 public static Object setProperty(String key, String value) 215 { 216 return p.setProperty(key, value); 217 } 218 219 public static String getProperty(String key) { 220 return ""+p.getProperty(key); 221 } 222 223 public static Object setProperty(String key, int value) 224 { 225 return p.setProperty(key, Integer.toString(value)); 226 } 227 228 public static Object setProperty(String key, boolean value) 229 { 230 String val = "false"; 231 232 if(value) 233 { 234 val = "true"; 235 } 236 237 return p.setProperty(key, val); 238 } 239 240 public static void save() 241 { 242 try 243 { 244 new File (System.getProperty("user.home") + File.separator + 245 ".jftp").mkdir(); 246 p.store(new FileOutputStream (propertyFilename), "jftp.properties"); 247 } 248 catch(Exception e) 249 { 250 System.out.println("Cannot save properties..."); 251 252 } 254 } 255 256 public static boolean getHideLocalDotNames() { 257 String what = p.getProperty("jftp.hideHiddenDotNames", "false"); 258 259 if(what.trim().equals("false")) 260 { 261 return false; 262 } 263 else 264 { 265 return true; 266 } 267 } 268 269 public static int getMaxConnections() 270 { 271 return maxConnections; 272 } 273 274 public static String getSocksProxyHost() 275 { 276 String what = p.getProperty("jftp.socksProxyHost", ""); 277 278 return what; 279 } 280 281 public static boolean getUseJTableLayout() 282 { 283 String what = p.getProperty("jftp.useJTableLayout", "true"); 284 285 if(what.trim().equals("false")) 286 { 287 return false; 288 } 289 else 290 { 291 return true; 292 } 293 } 294 295 public static String getSocksProxyPort() 296 { 297 String what = p.getProperty("jftp.socksProxyPort", ""); 298 299 return what; 300 } 301 302 public static boolean getUseBackground() 303 { 304 String what = p.getProperty("jftp.useBackground", "true"); 305 306 if(what.trim().equals("false")) 307 { 308 return false; 309 } 310 else 311 { 312 return true; 313 } 314 } 315 316 public static boolean getEnableSshKeys() 317 { 318 String what = p.getProperty("jftp.useSshKeyVerification", "false"); 319 320 if(what.trim().equals("false")) 321 { 322 return false; 323 } 324 else 325 { 326 return true; 327 } 328 } 329 330 public static boolean getEnableResuming() 331 { 332 String what = p.getProperty("jftp.enableResuming", "true"); 333 334 if(what.trim().equals("false")) 335 { 336 return false; 337 } 338 else 339 { 340 return true; 341 } 342 } 343 344 public static boolean getEnableDebug() 345 { 346 String what = p.getProperty("jftp.enableDebug", defaultEnableDebug); 347 348 if(what.trim().equals("false")) 349 { 350 return false; 351 } 352 else 353 { 354 return true; 355 } 356 } 357 358 public static boolean getDisableLog() 359 { 360 String what = p.getProperty("jftp.disableLog", "false"); 361 362 if(what.trim().equals("false")) 363 { 364 return false; 365 } 366 else 367 { 368 return true; 369 } 370 } 371 372 public static boolean getEnableStatusAnimation() 373 { 374 String what = p.getProperty("jftp.gui.enableStatusAnimation", "false"); 375 376 if(what.trim().equals("false")) 377 { 378 return false; 379 } 380 else 381 { 382 return true; 383 } 384 } 385 386 public static boolean getAskToDelete() 387 { 388 String what = p.getProperty("jftp.gui.askToDelete", "true"); 389 390 if(what.trim().equals("false")) 391 { 392 return false; 393 } 394 else 395 { 396 return true; 397 } 398 } 399 400 public static String getLookAndFeel() 401 { 402 return p.getProperty("jftp.gui.look", null); 403 } 404 405 public static boolean getUseNewIcons() 406 { 407 String what = p.getProperty("jftp.gui.look.newIcons", "true"); 408 409 if(what.trim().equals("false")) 410 { 411 return false; 412 } 413 else 414 { 415 return true; 416 } 417 } 418 419 public static boolean getEnableMultiThreading() 420 { 421 String what = p.getProperty("jftp.enableMultiThreading", 422 enableMultiThreading); 423 424 if(what.trim().equals("false")) 425 { 426 return false; 427 } 428 else 429 { 430 return true; 431 } 432 } 433 434 public static boolean getEnableSmbMultiThreading() 435 { 436 String what = p.getProperty("jftp.enableSmbMultiThreading", 437 enableSmbMultiThreading); 438 439 if(what.trim().equals("false")) 440 { 441 return false; 442 } 443 else 444 { 445 return true; 446 } 447 } 448 449 public static boolean getEnableSftpMultiThreading() 450 { 451 String what = p.getProperty("jftp.enableSftpMultiThreading", 452 enableSftpMultiThreading); 453 454 if(what.trim().equals("false")) 455 { 456 return false; 457 } 458 else 459 { 460 return true; 461 } 462 } 463 464 public static boolean getNoUploadMultiThreading() 465 { 466 String what = p.getProperty("jftp.noUploadMultiThreading", 467 noUploadMultiThreading); 468 469 if(what.trim().equals("false")) 470 { 471 return false; 472 } 473 else 474 { 475 return true; 476 } 477 } 478 479 public static boolean getFtpPasvMode() 480 { 481 String what = p.getProperty("jftp.ftpPasvMode", defaultFtpPasvMode); 482 483 if(what.trim().equals("false")) 484 { 485 return false; 486 } 487 else 488 { 489 return true; 490 } 491 } 492 493 public static boolean getUseDefaultDir() 494 { 495 String what = p.getProperty("jftp.useDefaultDir", "true"); 496 497 if(what.trim().equals("false")) 498 { 499 return false; 500 } 501 else 502 { 503 return true; 504 } 505 } 506 507 public static boolean getEnableRSS() 508 { 509 String what = p.getProperty("jftp.enableRSS", "false"); 510 511 if(what.trim().equals("false")) 512 { 513 return false; 514 } 515 else 516 { 517 return true; 518 } 519 } 520 521 public static String getRSSFeed() 522 { 523 String what = p.getProperty("jftp.customRSSFeed", 524 "http://slashdot.org/rss/slashdot.rss"); 525 526 return what; 527 } 528 529 public static java.awt.Dimension getWindowSize() 530 { 531 int width = Integer.parseInt(p.getProperty("jftp.window.width", 532 defaultWidth)); 533 int height = Integer.parseInt(p.getProperty("jftp.window.height", 534 defaultHeight)); 535 536 return new java.awt.Dimension (width, height); 537 } 538 539 public static java.awt.Point getWindowLocation() 540 { 541 int x = Integer.parseInt(p.getProperty("jftp.window.x", defaultX)); 542 int y = Integer.parseInt(p.getProperty("jftp.window.y", defaultY)); 543 544 return new java.awt.Point (x, y); 545 } 546 547 public static int getSocketTimeout() 548 { 549 return 3000; 550 } 551 552 public static boolean getStorePasswords() 553 { 554 String what = p.getProperty("jftp.security.storePasswords", 555 storePasswords); 556 557 if(what.trim().equals("false")) 558 { 559 return false; 560 } 561 else 562 { 563 return true; 564 } 565 } 566 567 static 568 { 569 try 570 { 571 p.load(new FileInputStream (propertyFilename)); 572 } 573 catch(Exception e) 574 { 575 System.out.println("no property file loaded, using defaults... (" + 576 e + ")"); 577 } 578 579 if(!getUseNewIcons()) { 580 iconImage = "images/org/javalobby/icons/20x20/ComputerIn.gif"; 581 hostImage = "images/org/javalobby/icons/20x20/ComputerIn.gif"; 582 closeImage = "images/org/javalobby/icons/20x20/Error.gif"; 583 infoImage = "images/org/javalobby/icons/20x20/Inform.gif"; 584 listImage = "images/org/javalobby/icons/20x20/List.gif"; 585 deleteImage = "images/org/javalobby/icons/16x16/DeleteDocument.gif"; 586 deleteImage2 = "images/org/javalobby/icons/16x16/DeleteDocument.gif"; 587 rmdirImage = "images/org/javalobby/icons/16x16/DeleteFolder.gif"; 588 mkdirImage = "images/org/javalobby/icons/16x16/NewFolder.gif"; 589 refreshImage = "images/org/javalobby/icons/16x16/Undo.gif"; 590 refreshImage2 = "images/org/javalobby/icons/16x16/Undo.gif"; 591 cdImage = "images/org/javalobby/icons/16x16/Open.gif"; 592 cmdImage = "images/org/javalobby/icons/16x16/ExecuteProject.gif"; 593 downloadImage = "images/org/javalobby/icons/16x16/Left.gif"; 594 uploadImage = "images/org/javalobby/icons/16x16/Right.gif"; 595 fileImage = "images/org/javalobby/icons/16x16/Document.gif"; 596 dirImage = "images/org/javalobby/icons/16x16/Folder.gif"; 597 codeFileImage = "images/org/javalobby/icons/16x16/List.gif"; 598 textFileImage = "images/org/javalobby/icons/16x16/DocumentDraw.gif"; 599 execFileImage = "images/org/javalobby/icons/16x16/ExecuteProject.gif"; 600 audioFileImage = "images/org/javalobby/icons/16x16/cd.gif"; 601 videoFileImage = "images/org/javalobby/icons/16x16/CameraFlash.gif"; 602 htmlFileImage = "images/org/javalobby/icons/16x16/World2.gif"; 603 zipFileImage = "images/org/javalobby/icons/16x16/DataStore.gif"; 604 imageFileImage = "images/org/javalobby/icons/16x16/Camera.gif"; 605 presentationFileImage = "images/org/javalobby/icons/16x16/DocumentDiagram.gif"; 606 spreadsheetFileImage = "images/org/javalobby/icons/16x16/DatePicker.gif"; 607 bookFileImage = "images/org/javalobby/icons/16x16/Book.gif"; 608 copyImage = "images/org/javalobby/icons/16x16/Copy.gif"; 609 openImage = "images/org/javalobby/icons/16x16/World2.gif"; 610 sftpImage = "images/org/javalobby/icons/16x16/NewEnvelope.gif"; 611 nfsImage = "images/org/javalobby/icons/16x16/TrafficGreen.gif"; 612 webdavImage = "images/org/javalobby/icons/16x16/DataStore.gif"; 613 linkImage = "images/org/javalobby/icons/16x16/Right.gif"; 614 typeImage = "images/org/javalobby/icons/20x20/Type.gif"; 615 clearImage = "images/org/javalobby/icons/16x16/Undo.gif"; 616 resumeImage = "images/org/javalobby/icons/16x16/GreenCircle.gif"; 617 pauseImage = "images/org/javalobby/icons/16x16/RedCircle.gif"; 618 clearImage2 = "images/org/javalobby/icons/16x16/Undo.gif"; 619 resumeImage2 = "images/org/javalobby/icons/16x16/GreenCircle.gif"; 620 pauseImage2 = "images/org/javalobby/icons/16x16/RedCircle.gif"; 621 saveImage = "images/org/javalobby/icons/16x16/Save.gif"; 622 cdUpImage = "images/org/javalobby/icons/16x16/Exit.gif"; 623 nextRSSImage = "images/org/javalobby/icons/16x16/Forward.gif"; 624 helpImage = "images/silk/help.png"; 625 } 626 else { 627 iconImage = "images/silk/server_add.png"; 628 hostImage = "images/silk/server_add.png"; 629 closeImage = "images/silk/cancel.png"; 630 infoImage = "images/silk/information.png"; 631 listImage = "images/silk/page_white_text.png"; 632 633 rmdirImage = "images/silk/folder_delete.png"; 634 mkdirImage = "images/silk/folder_add.png"; 635 refreshImage = "images/silk/control_repeat.png"; 636 refreshImage2 = "images/silk/control_repeat_blue.png"; 637 cdImage = "images/silk/folder_explore.png"; 638 cmdImage = "images/silk/application_xp_terminal.png"; 639 downloadImage = "images/silk/arrow_left.png"; 640 uploadImage = "images/silk/arrow_right.png"; 641 fileImage = "images/silk/page_white.png"; 642 dirImage = "images/silk/folder.png"; 643 codeFileImage = "images/silk/page_white_wrench.png"; 644 textFileImage = "images/silk/page_white_text.png"; 645 execFileImage = "images/silk/cog.png"; 646 audioFileImage = "images/silk/ipod.png"; 647 videoFileImage = "images/silk/camera.png"; 648 htmlFileImage = "images/silk/html.png"; 649 zipFileImage = "images/silk/page_white_zip.png"; 650 imageFileImage = "images/silk/image.png"; 651 presentationFileImage = "images/silk/page_white_powerpoint.png"; 652 spreadsheetFileImage = "images/silk/page_excel.png"; 653 bookFileImage = "images/silk/book.png"; 654 copyImage = "images/silk/disk_multiple.png"; 655 openImage = "images/silk/drive_web.png"; 656 sftpImage = "images/silk/drive_link.png"; 657 nfsImage = "images/silk/drive_network.png"; 658 webdavImage = "images/silk/house_go.png"; 659 linkImage = "images/silk/arrow_right.png"; 660 typeImage = "images/silk/email_go.png"; 661 deleteImage = "images/silk/control_stop.png"; 662 deleteImage2 = "images/silk/control_stop_blue.png"; 663 clearImage = "images/silk/control_eject.png"; 664 clearImage2 = "images/silk/control_eject_blue.png"; 665 resumeImage = "images/silk/control_play.png"; 666 resumeImage2 = "images/silk/control_play_blue.png"; 667 pauseImage = "images/silk/control_pause.png"; 668 pauseImage2 = "images/silk/control_pause_blue.png"; 669 saveImage = "images/silk/disk.png"; 670 cdUpImage = "images/silk/arrow_up.png"; 671 nextRSSImage = "images/silk/rss_go.png"; 672 helpImage = "images/silk/help.png"; 673 } 674 675 } 676 677 } 678 | Popular Tags |