1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.util;
21
22 import javax.swing.KeyStroke;
23 import javax.swing.UIManager;
24
25 import java.awt.event.InputEvent;
26 import java.awt.event.KeyEvent;
27 import java.beans.PropertyChangeListener;
28 import java.io.File;
29
30 import org.xnap.util.prefs.IntValidator;
31 import org.xnap.util.prefs.StringValidator;
32
33 /***
34 * Provides access to the global settings.
35 *
36 * <p>This class makes use of the singleton pattern.
37 *
38 * <p>If you hack around, make sure all pathes are returned with a trailing
39 * file separator and all values are initialized to something other than
40 * null.
41 *
42 * <p>Most important, keep all preferences sorted alphabetically everywhere.
43 */
44 public class Preferences extends AbstractPreferences
45 implements PreferencesProvider, TablePreferencesProvider {
46
47
48
49 /***
50 * The name of the references file that was used by XNap 1.x.
51 */
52 public static final String XNAP1_FILENAME = "xnap.properties";
53
54 /***
55 * The name of the references file that was used by XNap 2.x.
56 */
57 public static final String XNAP2_FILENAME = "xnap2.properties";
58
59 /***
60 * The name of the current preferences file.
61 */
62 public static final String XNAP3_FILENAME = "xnap3.properties";
63
64 /***
65 * The current version of the preferences file. Increase this, if keys
66 * are renamed or removed.
67 */
68 public static final int PREFS_VERSION = 17;
69
70 public static final String DEFAULT_THEME
71 = "org.xnap.gui.theme.DefaultTheme";
72
73
74
75 private static Preferences singleton = null;
76
77
78
79 private Preferences(String filename)
80 {
81 super(filename, PREFS_VERSION, "xnap");
82 }
83
84
85
86 /***
87 * Returns the preferences. This should be called at an early stage.
88 */
89 public static Preferences getInstance()
90 {
91 if (singleton == null) {
92 synchronized (Preferences.class) {
93 if (singleton == null) {
94 String f = FileHelper.getHomeDir() + XNAP3_FILENAME;
95 singleton = new Preferences(f);
96 }
97 }
98 }
99
100 return singleton;
101 }
102
103 /***
104 * Sets the preferences from the default preferences file.
105 */
106 public void read()
107 {
108 if (prefsFile.exists()) {
109 super.read();
110 }
111 else {
112 File f = new File(FileHelper.getHomeDir() + XNAP2_FILENAME);
113 if (f.exists()) {
114 super.read(f);
115 }
116 else {
117 f = new File(FileHelper.getHomeDir() + XNAP1_FILENAME);
118 if (f.exists()) {
119 super.read(f);
120 }
121 }
122 }
123
124 defaults();
125 }
126
127 /***
128 * Converts preferences from <code>oldVersion</code>.
129 */
130 public void convert(int oldVersion)
131 {
132 if (oldVersion <= 1) {
133 set("lastLaunchVersion", "1.0");
134 }
135
136 if (oldVersion <= 2) {
137 renameProperty("xnap.autofetchnaptigator",
138 "xnap.plugin.nap.autoFetchNaptigator");
139 renameProperty("xnap.autoversioncheck", "xnap.autoVersionCheck");
140 renameProperty("xnap.clientinfo", "xnap.plugin.nap.clientInfo");
141 renameProperty("xnap.delincompletefiles",
142 "xnap.delIncompleteFiles");
143 renameProperty("xnap.downloaddir", "xnap.downloadDir");
144 renameProperty("xnap.filterresults", "xnap.filterResults");
145 renameProperty("xnap.http.proxy.host", "xnap.httpProxyHost");
146 renameProperty("xnap.http.proxy.port", "xnap.httpProxyPort");
147 renameProperty("xnap.incompletedir", "xnap.incompleteDir");
148 renameProperty("xnap.lastupdatecheck", "xnap.lastUpdateCheck");
149 renameProperty("xnap.linktype", "xnap.linkType");
150 renameProperty("xnap.localport", "xnap.plugin.nap.localPort");
151 renameProperty("xnap.lookandfeel", "xnap.lookAndFeel");
152 renameProperty("xnap.maxautoconnectservers",
153 "xnap.plugin.nap.maxAutoconnectServers");
154 renameProperty("xnap.maxconsolelines", "xnap.maxConsoleLines");
155 renameProperty("xnap.maxdownloads", "xnap.maxDownloads");
156 renameProperty("xnap.maxsearchresults", "xnap.maxSearchResults");
157 renameProperty("xnap.maxsearchservers",
158 "xnap.plugin.nap.maxSearchServers");
159 renameProperty("xnap.maxuploads", "xnap.maxUploads");
160 renameProperty("xnap.mp3playercmd", "xnap.mp3PlayerCmd");
161 renameProperty("xnap.mp3playertype", "xnap.mp3PlayerType");
162 renameProperty("xnap.gift.daemon", "xnap.plugin.gift.daemon");
163 renameProperty("xnap.gift.host", "xnap.plugin.gift.host");
164 renameProperty("xnap.gift.port", "xnap.plugin.gift.port");
165 renameProperty("xnap.removeduplicateresults",
166 "xnap.removeDuplicateResults");
167 renameProperty("xnap.search.bitrate", "xnap.searchBitrate");
168 renameProperty("xnap.search.compare", "xnap.searchCompare");
169 renameProperty("xnap.search.mediatype", "xnap.searchMediaType");
170 renameProperty("xnap.showclosedialog", "xnap.showCloseDialog");
171 renameProperty("xnap.showicons", "xnap.showIcons");
172 renameProperty("xnap.showsplash", "xnap.showSplash");
173 renameProperty("xnap.socksproxyhost", "xnap.socksProxyHost");
174 renameProperty("xnap.socksproxyport", "xnap.socksProxyPort");
175 renameProperty("xnap.uploaddirs", "xnap.uploadDirs");
176 renameProperty("xnap.useautoconnector",
177 "xnap.plugin.nap.useAutoconnector");
178 renameProperty("xnap.usehttpproxy", "xnap.useHttpProxy");
179 removeProperty("xnap.uselimewire");
180 renameProperty("xnap.useopenfileaction", "xnap.useOpenFileAction");
181 renameProperty("xnap.usesingleport",
182 "xnap.plugin.nap.useSinglePort");
183 renameProperty("xnap.useSocksProxy", "xnap.useSocksProxy");
184 renameProperty("xnap.window.height", "xnap.windowHeight");
185 renameProperty("xnap.window.width", "xnap.windowWidth");
186 renameProperty("xnap.window.x", "xnap.windowX");
187 renameProperty("xnap.window.y", "xnap.windowY");
188
189
190
191
192
193 }
194
195 if (oldVersion <= 3) {
196 if (getDownloadThrottle() > 0) {
197 setThrottleDownloads(true);
198 }
199 if (getUploadThrottle() > 0) {
200 setThrottleUploads(true);
201 }
202 }
203
204 if (oldVersion <= 4) {
205 renameProperty("xnap.useOpenFileAction", "xnap.fileLauncherType");
206 if (!SystemHelper.isWindowsOS && getBoolean("fileLauncherType")) {
207 setFileLauncherCmd("kfmclient");
208 setFileLauncherType("kfmclient");
209 }
210 else {
211 setFileLauncherCmd("");
212 setFileLauncherType(SystemHelper.getNativeLauncherType());
213 }
214 }
215
216 if (oldVersion <= 5) {
217 removeProperty("maintainSortOrder");
218 set("channelTableColumns", "0;1;2");
219 set("downloadTableColumns", "0;1;2;4;5;6");
220 set("libraryTableColumns", "0;3;4;6");
221 set("searchTableColumns", "0;2;3;5;6;10");
222 set("uploadTableColumns", "0;1;2;4;5;6");
223
224 }
225
226 if (oldVersion <= 6) {
227 set("progressRunningColor", 11513855);
228 set("progressFinishedColor", 65280);
229 }
230
231 if (oldVersion <= 7) {
232 setLimitDownloads(getMaxDownloads() > 0);
233 setLimitUploads(getMaxUploads() > 0);
234 }
235
236 if (oldVersion <= 8) {
237
238
239 removeProperty("lastLaunchVer");
240 }
241
242 if (oldVersion <= 9) {
243 setDownloadRetryInterval(120);
244 }
245
246 if (oldVersion <= 10) {
247 set("updaterInterval", "3600");
248 }
249
250 if (oldVersion <= 11) {
251 set("browseTableColumns", "icon;filesize;availability");
252 set("channelTableColumns", "channel;userCount;topic");
253 set("downloadTableColumns",
254 "icon;queuePos;filesize;peer;status;segments;progress;timeLeft");
255 set("hotlistTableColumns", "name;status");
256 set("libraryTableColumns", "filename;type;size;modified");
257 set("searchTableColumns",
258 "icon;filesize;peer;availability");
259 set("uploadTableColumns",
260 "icon;queuePos;filesize;peer;status;progress;timeLeft");
261 set("userTableColumns", "name;fileCount;linkSpeed");
262 }
263
264 if (oldVersion <= 12) {
265 renameProperty("xnap.mp3PlayerCmd", "xnap.playerCommand");
266 renameProperty("xnap.mp3PlayerType", "xnap.playerType");
267 }
268
269 if (oldVersion <= 13) {
270 removeProperty("xnap.autoJoinChannels");
271 removeProperty("xnap.maxSearchResults");
272 set("enabledPlugins", "");
273 set("libraryTreeNodes",
274 "downloads;incompletes;home;root;library;shares");
275 set("useTabbedPane", "true");
276 }
277
278 if (oldVersion <= 14) {
279 removeProperty("lastLaunchReleaseNr");
280 }
281
282 if (oldVersion <= 15) {
283 set("theme", DEFAULT_THEME);
284 }
285
286 if (oldVersion <= 16) {
287
288 set("lookAndFeel", getDefaultLookAndFeel());
289 }
290
291 if (oldVersion <= 17) {
292 set("enabledPlugins", getEnabledPlugins() + ";News");
293 }
294 }
295
296 /***
297 * Sets the defaults. Preferences that are already set are not overwritten.
298 */
299 public void defaults()
300 {
301 setDefault("AudioDownloadDir", "");
302 setDefault("alwaysAutoDownload", "true");
303 setDefault("appendServerNameToChatUser", "false");
304 setDefault("autoClearTransfers", "false");
305 setDefault("autoClearTransfersInterval", "300");
306 setDefault("autoComplete", "false");
307 setDefault("autoVersionCheck", "true");
308 setDefault("autoDownlodMaxSearches", "12");
309 setDefault("autoDownlodSearchInterval", "900",
310 new IntValidator(600));
311 setDefault("autoSourcesListManagement", "true");
312 setDefault("beepOnChatMessage", "false");
313 setDefault("blinkOnChannelJoin", "true");
314 setDefault("browseTableColumns", "icon;filesize;availability");
315 setDefault("buildSearchTreeOnStartup", "false");
316 setDefault("captureLauncherOutput", "false");
317 setDefault("channelTableColumns", "channel;userCount;topic");
318 setDefault("chatBackgroundColor", "16777215");
319 setDefault("chatErrorColor", "255");
320 setDefault("chatFont", "Monospaced;0;12");
321 setDefault("chatAwayMessage", "I'm away, please try again later.");
322 setDefault("chatIgnoreMessage", "I'm ignoring you, please stop sending"
323 + " messages.");
324 setDefault("chatInfoColor", "51455");
325 setDefault("chatMessageColor", "0");
326 setDefault("chatUserColor", "16711680");
327 setDefault("chatVerticalDividerLocation", "400");
328 setDefault("chatGlobalVerticalDividerLocation", "200");
329 setDefault("consoleFont", "Monospaced;1;12");
330 setDefault("consoleForegroundColor", "51455");
331 setDefault("consoleBackgroundColor", "0");
332 setDefault("consoleBackgroundColor", "0");
333 setDefault("correctivePixels", "0");
334 setDefault("debugLogFile", FileHelper.getHomeDir() + "debug.log");
335 setDefault("defaultCompletionMode", "Dropdown List");
336 setDefault("defaultThemeFont", "Dialog;0;12");
337 setDefault("delIncompleteFiles", "true");
338 setDefault("DocumentsDownloadDir", "");
339 setDefault("downloadDir",
340 FileHelper.directory(System.getProperty("user.home")));
341 setDefault("downloadMaxTries", "60");
342 setDefault("downloadRetryInterval", "300",
343 new IntValidator(60));
344 setDefault("downloadTableColumns",
345 "icon;queuePos;filesize;peer;status;segments;progress;timeLeft");
346 setDefault("downloadThrottle", "0", new IntValidator(0));
347 setDefault("doubleFilterMediaType", "true");
348 setDefault("emacsCycleBackwardShortcut",
349 toString(KeyStroke.getKeyStroke(KeyEvent.VK_R,
350 InputEvent.CTRL_MASK)));
351 setDefault("emacsCycleForwardShortcut",
352 toString(KeyStroke.getKeyStroke(KeyEvent.VK_T,
353 InputEvent.CTRL_MASK)));
354 setDefault("email", "anonymous@universe", StringValidator.EMAIL);
355 setDefault("enabledPlugins", "News");
356 setDefault("errorDialogDetailsVisible", "false");
357 setDefault("errorDialogHeight", "275");
358 setDefault("errorDialogWidth", "475");
359 setDefault("faqURL", "http://xnap.sourceforge.net/faq.php");
360 setDefault("feedbackEmail", "");
361 setDefault("feedbackName", "");
362 setDefault("feedbackURL", "http://xnap.sourceforge.net/feedback.php");
363 setDefault("fileLauncherCmd", "");
364 setDefault("fileLauncherType", SystemHelper.getNativeLauncherType());
365 setDefault("filteredDownloadTableColumns",
366 "icon;queuePos;filesize;peer;status;progress;timeLeft");
367 setDefault("filteredUploadTableColumns",
368 "icon;queuePos;filesize;peer;status;progress;timeLeft");
369 setDefault("filterResults", "false");
370 setDefault("focusOnAllEvents", "true");
371 setDefault("helpDialogHeight", "480");
372 setDefault("helpDialogWidth", "640");
373 setDefault("hotlistDividerLocation", "540");
374 setDefault("hotlistTableColumns", "name;status");
375 setDefault("httpProxyHost", "");
376 setDefault("httpProxyPort", "0");
377 setDefault("iconTheme", "org.xnap.gui.theme.DefaultIconTheme");
378 setDefault("ImagesDownloadDir", "");
379 setDefault("incompleteDir", "");
380 setDefault("jarIncludePath", "/usr/share/java");
381 setDefault("language", "");
382 setDefault("lastLaunchVersion", "-1");
383 setDefault("lastUpdateCheck", "0");
384 setDefault("libraryDirs", "");
385 setDefault("libraryFileDeleteShortcut",
386 toString(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)));
387 setDefault("libraryFileRenameShortcut",
388 toString(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)));
389 setDefault("libraryHorizontalDividerLocation", "220");
390 setDefault("libraryRefreshShortcut",
391 toString(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)));
392 setDefault("libraryTableColumns", "filename;type;size;modified");
393 setDefault("libraryVerticalDividerLocation", "200");
394 setDefault("libraryTreeNodes",
395 "downloads;incompletes;home;root;library;shares");
396 setDefault("limitDownloads", "false");
397 setDefault("limitDownloadAttempts", "false");
398 setDefault("limitUploads", "true");
399 setDefault("limitDownloadsPerUser", "true");
400 setDefault("limitUploadsPerUser", "true");
401 setDefault("linkType", "0");
402 setDefault("logTransfersToFile", "false");
403 setDefault("lookAndFeel", getDefaultLookAndFeel());
404 setDefault("manuallyCompleteShortcut",
405 toString(KeyStroke.getKeyStroke(KeyEvent.VK_T,
406 InputEvent.CTRL_MASK)));
407 setDefault("maxDownloads", "20", new IntValidator(0));
408 setDefault("maxDownloadsPerUser", "3", new IntValidator(0));
409 setDefault("maxConsoleLines", "100", new IntValidator(1));
410 setDefault("maxOpenWithCommands", "5");
411 setDefault("maxSwarmedConnects", "1");
412 setDefault("maxUploads", "5", new IntValidator(0));
413 setDefault("maxUploadsPerUser", "1", new IntValidator(0));
414 setDefault("mediaDownloadDirsTableColumns", "mediatype;downloaddir");
415 setDefault("minimumShares", "0");
416 setDefault("minimumSharesMessage", "Sorry, you are not allowed to"
417 + " download since you do not share enough.");
418 setDefault("openWithCommands", "");
419 setDefault("password", StringHelper.randomString(8),
420 StringValidator.REGULAR_STRING);
421 setDefault("playerCommand", "");
422 setDefault("playerType", "other");
423 setDefault("preferencesDialogShortcut",
424 toString(SystemHelper.getMenuShortcut(KeyEvent.VK_P)));
425 setDefault("prefsWindowHeight", "550");
426 setDefault("prefsWindowWidth", "700");
427 setDefault("problemReportURL",
428 "http://xnap.sourceforge.net/problem_report.php");
429 setDefault("progressRunningColor", "11513855");
430 setDefault("progressFinishedColor", "65280");
431 setDefault("rememberFeedback", "true");
432 setDefault("removeDuplicateResults", "true");
433 setDefault("requerySearchShortcut",
434 toString(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)));
435 setDefault("searchBitrate", "0");
436 setDefault("searchCompare", "0");
437 setDefault("searchDividerLocation", "200");
438 setDefault("searchHorizontalDividerLocation", "150");
439 setDefault("searchHistorySize", "30");
440 setDefault("searchMediaType", "0");
441 setDefault("searchTableColumns",
442 "icon;filesize;peer;availability");
443 setDefault("searchTableSortedColumn", "-11");
444 setDefault("seenStartupWizard", "false");
445 setDefault("sendChatAwayMessage", "false");
446 setDefault("sendChatIgnoreMessage", "true");
447 setDefault("sendMinimumSharesMessage", "false");
448 setDefault("PrintServerNotificationsInChatWindow", "false");
449 setDefault("SoftwareDownloadDir", "");
450 setDefault("shareFullPath", "true");
451 setDefault("shortcutTableColumns", "Action;Shortcut");
452 setDefault("showAdvancedSearchOptions", "false");
453 setDefault("showChatMsgTime", "true");
454 setDefault("showChatPanel", "true");
455 setDefault("showCloseDialog", "true");
456 setDefault("showCmdlToolbar", "false");
457 setDefault("showCopyDialog", "true");
458 setDefault("showDeleteDownloadsDialog", "true");
459 setDefault("showDeleteFilesDialog", "true");
460 setDefault("showErrorDialog", "true");
461 setDefault("showIcons", "true");
462 setDefault("showLibraryPanel", "true");
463 setDefault("showMainToolbar", "true");
464 setDefault("showMoveDialog", "true");
465 setDefault("showSearchLibraryOnDownloadDialog", "true");
466 setDefault("showSearchOptions", "true");
467 setDefault("showSplash", "true");
468 setDefault("showToolTips", !SystemHelper.hasMacOSXToolTipsBug() + "");
469 setDefault("socksProxyHost", "");
470 setDefault("socksProxyPort", "0");
471 setDefault("theme", DEFAULT_THEME);
472 setDefault("transferDividerLocation", "220");
473 setDefault("transferLogFile", FileHelper.getHomeDir() + "transfer.log");
474 setDefault("throttleDownloads", "false");
475 setDefault("throttleUploads", "false");
476 setDefault("updatePluginsOnStartup", "false");
477 setDefault("updaterInterval", "600", new IntValidator(60));
478 setDefault("updateURL",
479 "http://xnap.sourceforge.net/updates/LATEST_VERSION.txt");
480 setDefault("uploadDirs", "");
481 setDefault("uploadTableColumns",
482 "icon;queuePos;filesize;peer;status;progress;timeLeft");
483 setDefault("uploadThrottle", "0", new IntValidator(0));
484 setDefault("useEmacsKeyBindings", "false");
485 setDefault("username", StringHelper.randomString(8),
486 StringValidator.REGULAR_STRING);
487 setDefault("useHttpProxy", "false");
488 setDefault("userTableColumns", "name;fileCount;linkSpeed");
489 setDefault("useMinimumShares", "false");
490 setDefault("useSmallTransferIcons", "false");
491 setDefault("useSocksProxy", "false");
492 setDefault("useTabbedPane", "true");
493 setDefault("useTabbedTransferPane", "false");
494 setDefault("useSubMenuForPluginMenus", "true");
495 setDefault("VideoDownloadDir", "");
496 setDefault("windowHeight", "540");
497 setDefault("windowWidth", "720");
498 setDefault("windowX", "0");
499 setDefault("windowY", "0");
500 setDefault("xnapJarURL", "http://xnap.sourceforge.net/redirect.php");
501 }
502
503 /***
504 * Add a listener for a table preferences.
505 */
506 public void addTableListener(String table, PropertyChangeListener l)
507 {
508 addPropertyChangeListener(table + "TableColumns", l);
509 addPropertyChangeListener(table + "TableMaintainSortOrder", l);
510 }
511
512 public boolean getAlwaysAutoDownload() {
513 return getBoolean("alwaysAutoDownload");
514 }
515
516 public void setAlwaysAutoDownload(boolean newValue) {
517 set("alwaysAutoDownload", newValue);
518 }
519
520 public boolean getAppendServerNameToChatUser(){
521 return getBoolean("appendServerNameToChatUser");
522 }
523
524 public void setAppendServerNameToChatUser(boolean newValue) {
525 set("appendServerNameToChatUser", newValue);
526 }
527
528 public boolean getAutoClearTransfers() {
529 return getBoolean("autoClearTransfers");
530 }
531
532 public void setAutoClearTransfers(boolean newValue) {
533 set("autoClearTransfers", newValue);
534 }
535
536 public int getAutoClearTransfersInterval() {
537 return getInt("autoClearTransfersInterval");
538 }
539
540 public void setAutoClearTransfersInterval(int newValue) {
541 set("autoClearTransfersInterval", newValue);
542 }
543
544 public boolean getAutoComplete() {
545 return getBoolean("autoComplete");
546 }
547
548 public void setAutoComplete(boolean newValue) {
549 set("autoComplete", newValue);
550 }
551
552 public int getAutoDownloadMaxSearches() {
553 return getInt("autoDownlodMaxSearches");
554 }
555
556 public void setAutoDownloadMaxSearches(int newValue) {
557 set("autoDownlodMaxSearches", newValue);
558 }
559
560 public int getAutoDownloadSearchInterval() {
561 return getInt("autoDownlodSearchInterval");
562 }
563
564 public void setAutoDownloadSearchInterval(int newValue) {
565 set("autoDownlodSearchInterval", newValue);
566 }
567
568 public boolean getAutoVersionCheck() {
569 return getBoolean("autoVersionCheck");
570 }
571
572 public void setAutoVersionCheck(boolean newValue) {
573 set("autoVersionCheck", newValue);
574 }
575
576 public boolean getBeepOnChatMessage() {
577 return getBoolean("beepOnChatMessage");
578 }
579
580 public void setBeepOnChatMessage(boolean newValue) {
581 set("beepOnChatMessage", newValue);
582 }
583
584 public boolean getBlinkOnChannelJoin() {
585 return getBoolean("blinkOnChannelJoin");
586 }
587
588 public void setBlinkOnChannelJoin(boolean newValue) {
589 set("blinkOnChannelJoin", newValue);
590 }
591
592 public boolean getBuildSearchTreeOnStartup() {
593 return getBoolean("buildSearchTreeOnStartup");
594 }
595
596 public void setBuildSearchTreeOnStartup(boolean newValue) {
597 set("buildSearchTreeOnStartup", newValue);
598 }
599
600 public boolean getCaptureLauncherOutput() {
601 return getBoolean("captureLauncherOutput");
602 }
603
604 public void setCaptureLauncherOutput(boolean newValue) {
605 set("captureLauncherOutput", newValue);
606 }
607
608 public String getChatAwayMessage() {
609 return get("chatAwayMessage");
610 }
611
612 public void setChatAwayMessage(String newValue) {
613 set("chatAwayMessage", newValue);
614 }
615
616 public String getChatIgnoreMessage() {
617 return get("chatIgnoreMessage");
618 }
619
620 public void setChatIgnoreMessage(String newValue) {
621 set("chatIgnoreMessage", newValue);
622 }
623
624 public int getChatGlobalVerticalDividerLocation() {
625 return getInt("chatGlobalVerticalDividerLocation");
626 }
627
628 public void setChatGlobalVerticalDividerLocation(int newValue) {
629 set("chatGlobalVerticalDividerLocation", newValue);
630 }
631
632 public int getChatVerticalDividerLocation() {
633 return getInt("chatVerticalDividerLocation");
634 }
635
636 public void setChatVerticalDividerLocation(int newValue) {
637 set("chatVerticalDividerLocation", newValue);
638 }
639
640 public int getCorrectivePixels() {
641 return getInt("correctivePixels");
642 }
643
644 public void setCorrectivePixels(int newValue) {
645 set("correctivePixels", newValue);
646 }
647
648 public String getDebugLogFile() {
649 return get("debugLogFile");
650 }
651
652 public void setDebugLogFile(String newValue) {
653 set("debugLogFile", newValue);
654 }
655
656 public String getDefaultCompletionMode() {
657 return get("defaultCompletionMode");
658 }
659
660 public void setDefaultCompletionMode(String newValue) {
661 set("defaultCompletionMode", newValue);
662 }
663
664 /***
665 * Returns the default look and feel.
666 */
667 public String getDefaultLookAndFeel() {
668 String systemLAF = UIManager.getSystemLookAndFeelClassName();
669 String crossLAF = UIManager.getCrossPlatformLookAndFeelClassName();
670 boolean fallback = SystemHelper.hasMacOSXToolTipsBug();
671
672
673 boolean hasNoSystemLAF
674 = (crossLAF != null && crossLAF.equals(systemLAF));
675
676 return (fallback)
677 ? crossLAF
678 : (hasNoSystemLAF)
679 ? "com.incors.plaf.kunststoff.KunststoffLookAndFeel"
680 : systemLAF;
681 }
682
683 public String getDefaultViewer(String extension) {
684 return get("defaultViewer." + extension);
685 }
686
687 public void setDefaultViewer(String extension, String viewerName) {
688 set("defaultViewer." + extension, viewerName);
689 }
690
691 public boolean getDelIncompleteFiles() {
692 return getBoolean("delIncompleteFiles");
693 }
694
695 public void setDelIncompleteFiles(boolean newValue) {
696 set("delIncompleteFiles", newValue);
697 }
698
699 public String getDownloadDir() {
700 return FileHelper.directory(get("downloadDir"));
701 }
702
703 public void setDownloadDir(String newValue) {
704 set("downloadDir", FileHelper.directory(newValue));
705 }
706
707 public String getMediaTypeDownloadDir(String type) {
708 String dir = get(type + "DownloadDir");
709 if (dir.length() > 0) {
710 return FileHelper.directory(dir);
711 }
712 else {
713 return dir;
714 }
715 }
716
717 public void setMediaTypeDownloadDir(String type, String newValue) {
718 set(type + "DownloadDir", newValue);
719 }
720
721 public int getDownloadMaxTries() {
722 return getInt("downloadMaxTries");
723 }
724
725 public int getDownloadRetryInterval() {
726 return getInt("downloadRetryInterval");
727 }
728
729 public void setDownloadRetryInterval(int newValue) {
730 set("downloadRetryInterval", newValue);
731 }
732
733 public int getDownloadThrottle() {
734 return getInt("downloadThrottle");
735 }
736
737 public void setDownloadThrottle(int newValue) {
738 set("downloadThrottle", newValue);
739 }
740
741 public String getEmail() {
742 return get("email");
743 }
744
745 public void setEmail(String newValue) {
746 set("email", newValue);
747 }
748
749 public String[] getEnabledPlugins() {
750 return getArray("enabledPlugins");
751 }
752
753 public void setEnabledPlugins(String[] newValue) {
754 set("enabledPlugins", newValue);
755 }
756
757 public String getFaqURL() {
758 return get("faqURL");
759 }
760
761 public String getFeedbackEmail() {
762 return get("feedbackEmail");
763 }
764
765 public void setFeedbackEmail(String newValue) {
766 set("feedbackEmail", newValue);
767 }
768
769 public String getFeedbackName() {
770 return get("feedbackName");
771 }
772
773 public void setFeedbackName(String newValue) {
774 set("feedbackName", newValue);
775 }
776
777 public String getFeeedbackURL() {
778 return get("feedbackURL");
779 }
780
781 public String getFileLauncherCmd() {
782 return get("fileLauncherCmd");
783 }
784
785 public void setFileLauncherCmd(String newValue) {
786 set("fileLauncherCmd", newValue);
787 }
788
789 public String getFileLauncherType() {
790 return get("fileLauncherType");
791 }
792
793 public void setFileLauncherType(String newValue) {
794 set("fileLauncherType", newValue);
795 }
796
797 public boolean getFilterResults() {
798 return getBoolean("filterResults");
799 }
800
801 public void setFilterResults(boolean newValue) {
802 set("filterResults", newValue);
803 }
804
805 public boolean getFocusOnAllEvents() {
806 return getBoolean("focusOnAllEvents");
807 }
808
809 public void setFocusOnAllEvents(boolean newValue) {
810 set("focusOnAllEvents", newValue);
811 }
812
813 public int getHelpDialogHeight() {
814 return getInt("helpDialogHeight");
815 }
816
817 public void setHelpDialogHeight(int newValue) {
818 set("helpDialogHeight", newValue);
819 }
820
821 public int getHelpDialogWidth() {
822 return getInt("helpDialogWidth");
823 }
824
825 public void setHelpDialogWidth(int newValue) {
826 set("helpDialogWidth", newValue);
827 }
828
829 public int getHotlistDividerLocation() {
830 return getInt("hotlistDividerLocation");
831 }
832
833 public void setHotlistDividerLocation(int newValue) {
834 set("hotlistDividerLocation", newValue);
835 }
836
837 public String getHttpProxyHost() {
838 return get("httpProxyHost");
839 }
840
841 public void setHttpProxyHost(String newValue) {
842 set("httpProxyHost", newValue);
843 }
844
845 public int getHttpProxyPort() {
846 return getInt("httpProxyPort");
847 }
848
849 public void setHttpProxyPort(int newValue) {
850 set("httpProxyPort", newValue);
851 }
852
853 public String getIconTheme() {
854 return get("iconTheme");
855 }
856
857 public void setIconTheme(String newValue) {
858 set("iconTheme", newValue);
859 }
860
861 public String getIncompleteDir() {
862 return FileHelper.directory(get("incompleteDir"));
863 }
864
865 public void setIncompleteDir(String newValue) {
866 set("incompleteDir", newValue);
867 }
868
869 public String[] getJarIncludePath()
870 {
871 return getArray("jarIncludePath");
872 }
873
874 public void setJarIncludePath(String[] newValue)
875 {
876 set("jarIncludePath", newValue);
877 }
878
879 public String getLanguage() {
880 return get("language");
881 }
882
883 public void setLanguage(String newValue) {
884 set("language", newValue);
885 }
886
887 public boolean getLimitDownloads() {
888 return getBoolean("limitDownloads");
889 }
890
891 public void setLimitDownloads(boolean newValue) {
892 set("limitDownloads", newValue);
893 }
894
895 public boolean getLimitUploads() {
896 return getBoolean("limitUploads");
897 }
898
899 public void setLimitUploads(boolean newValue) {
900 set("limitUploads", newValue);
901 }
902
903 public boolean getLimitDownloadsPerUser() {
904 return getBoolean("limitDownloadsPerUser");
905 }
906
907 public void setLimitDownloadsPerUser(boolean newValue) {
908 set("limitDownloadsPerUser", newValue);
909 }
910
911 public boolean getLimitUploadsPerUser() {
912 return getBoolean("limitUploadsPerUser");
913 }
914
915 public void setLimitUploadsPerUser(boolean newValue) {
916 set("limitUploadsPerUser", newValue);
917 }
918
919 public int getLinkSpeed() {
920 return getInt("linkSpeed");
921 }
922
923 public void setLinkSpeed(int newValue) {
924 set("linkSpeed", newValue);
925 }
926
927 public boolean getLogTransfersToFile() {
928 return getBoolean("logTransfersToFile");
929 }
930
931 public void setLogTransfersToFile(boolean newValue) {
932 set("logTransfersToFile", newValue);
933 }
934
935 public String getPassword() {
936 return get("password");
937 }
938
939 public void setPassword(String newValue) {
940 set("password", newValue);
941 }
942
943 public String getPlayerCommand() {
944 return get("playerCommand");
945 }
946
947 public void setPlayerCommand(String newValue) {
948 set("playerCommand", newValue);
949 }
950
951 public String getPlayerType() {
952 return get("playerType");
953 }
954
955 public void setPlayerType(String newValue) {
956 set("playerType", newValue);
957 }
958
959 public String getLastLaunchVersion() {
960 return get("lastLaunchVersion");
961 }
962
963 public void setLastLaunchVersion(String newValue) {
964 set("lastLaunchVersion", newValue);
965 }
966
967 public long getLastUpdateCheck() {
968 return getLong("lastUpdateCheck");
969 }
970
971 public void setLastUpdateCheck(long newValue) {
972 set("lastUpdateCheck", newValue);
973 }
974
975 public String[] getLibraryDirs() {
976 return getArray("libraryDirs");
977 }
978
979 public void setLibraryDirs(String[] newValue) {
980 set("libraryDirs", newValue);
981 }
982
983 public int getLibraryHorizontalDividerLocation() {
984 return getInt("libraryHorizontalDividerLocation");
985 }
986
987 public void setLibraryHorizontalDividerLocation(int newValue) {
988 set("libraryHorizontalDividerLocation", newValue);
989 }
990
991 public String getLibraryTreeNodes() {
992 return get("libraryTreeNodes");
993 }
994
995 public String[] getLibraryTreeNodesArray() {
996 return StringHelper.toArray(getLibraryTreeNodes(), ARRAY_SEPARATOR);
997 }
998
999 public void setLibraryTreeNodes(String newValue) {
1000 set("libraryTreeNodes", newValue);
1001 }
1002
1003 public int getLibraryVerticalDividerLocation() {
1004 return getInt("libraryVerticalDividerLocation");
1005 }
1006
1007 public void setLibraryVerticalDividerLocation(int newValue) {
1008 set("libraryVerticalDividerLocation", newValue);
1009 }
1010
1011 public String getLookAndFeel() {
1012 return get("lookAndFeel");
1013 }
1014
1015 public void setLookAndFeel(String newValue) {
1016 set("lookAndFeel", newValue);
1017 }
1018
1019 public boolean getSeenStartupWizard() {
1020 return getBoolean("seenStartupWizard");
1021 }
1022
1023 public void setSeenStartupWizard(boolean newValue) {
1024 set("seenStartupWizard", newValue);
1025 }
1026
1027 public boolean getSendChatAwayMessage() {
1028 return getBoolean("sendChatAwayMessage");
1029 }
1030
1031 public void setSendChatAwayMessage(boolean newValue) {
1032 set("sendChatAwayMessage", newValue);
1033 }
1034
1035 public boolean getSendChatIgnoreMessage() {
1036 return getBoolean("sendChatIgnoreMessage");
1037 }
1038
1039 public void setSendChatIgnoreMessage(boolean newValue) {
1040 set("sendChatIgnoreMessage", newValue);
1041 }
1042
1043 public boolean getPrintServerNotificationsInChatWindow() {
1044 return getBoolean("PrintServerNotificationsInChatWindow");
1045 }
1046
1047 public void setPrintServerNotificationsInChatWindow(boolean newValue) {
1048 set("PrintServerNotificationsInChatWindow", newValue);
1049 }
1050
1051 public boolean getShareFullPath() {
1052 return getBoolean("shareFullPath");
1053 }
1054
1055 public void setShareFullPath(boolean newValue) {
1056 set("shareFullPath", newValue);
1057 }
1058
1059 public KeyStroke getShortcut(String key) {
1060 return getKeyStroke(key + "Shortcut");
1061 }
1062
1063 public void setShortcut(String key, KeyStroke newValue) {
1064 set(key + "Shortcut", newValue);
1065 }
1066
1067 public boolean shouldCheckForUpdate(int days) {
1068 return (System.currentTimeMillis()
1069 - getLastUpdateCheck() > days * 24 * 60 * 60 * 1000);
1070 }
1071
1072 public boolean getShowSearchOptions() {
1073 return getBoolean("showSearchOptions");
1074 }
1075
1076 public void setShowSearchOptions(boolean newValue) {
1077 set("showSearchOptions", newValue);
1078 }
1079
1080 public boolean getShowChatMsgTime() {
1081 return getBoolean("showChatMsgTime");
1082 }
1083
1084 public void setShowChatMsgTime(boolean newValue) {
1085 set("showChatMsgTime", newValue);
1086 }
1087
1088 /***
1089 * @deprecated
1090 */
1091 public boolean getShowDialog(String dialogName) {
1092 return getBoolean("show" + dialogName + "Dialog");
1093 }
1094
1095 /***
1096 * @deprecated
1097 */
1098 public void setShowDialog(String dialogName, boolean newValue) {
1099 set("show" + dialogName + "Dialog", newValue);
1100 }
1101
1102 public boolean getShowIcons() {
1103 return getBoolean("showIcons");
1104 }
1105
1106 public void setShowIcons(boolean newValue) {
1107 set("showIcons", newValue);
1108 }
1109
1110 public boolean getShowSplash() {
1111 return getBoolean("showSplash");
1112 }
1113
1114 public void setShowSplash(boolean newValue) {
1115 set("showSplash", newValue);
1116 }
1117
1118 public boolean getShowToolTips() {
1119 return getBoolean("showToolTips");
1120 }
1121
1122 public void setShowToolTips(boolean newValue) {
1123 set("showToolTips", newValue);
1124 }
1125
1126 public int getMaxDownloads() {
1127 return getInt("maxDownloads");
1128 }
1129
1130 public void setMaxDownloads(int newValue) {
1131 set("maxDownloads", newValue);
1132 }
1133
1134 public int getMaxDownloadsPerUser() {
1135 return getInt("maxDownloadsPerUser");
1136 }
1137
1138 public void setMaxDownloadsPerUser(int newValue) {
1139 set("maxDownloadsPerUser", newValue);
1140 }
1141
1142 public int getMaxConsoleLines() {
1143 return getInt("maxConsoleLines");
1144 }
1145
1146 public void setMaxConsoleLines(int newValue) {
1147 set("maxConsoleLines", newValue);
1148 }
1149
1150 public int getMaxOpenWithCommands() {
1151 return getInt("maxOpenWithCommands");
1152 }
1153
1154 public void setMaxOpenWithCommands(int newValue) {
1155 set("maxOpenWithCommands", newValue);
1156 }
1157
1158 public int getMaxUploads() {
1159 return getInt("maxUploads");
1160 }
1161
1162 public void setMaxUploads(int newValue) {
1163 set("maxUploads", newValue);
1164 }
1165
1166 public int getMaxUploadsPerUser() {
1167 return getInt("maxUploadsPerUser");
1168 }
1169
1170 public void setMaxUploadsPerUser(int newValue) {
1171 set("maxUploadsPerUser", newValue);
1172 }
1173
1174 public int getMaxSwarmedConnects() {
1175 return getInt("maxSwarmedConnects");
1176 }
1177
1178 public int getMinimumShares() {
1179 return getInt("minimumShares");
1180 }
1181
1182 public void setMinimumShares(int newValue) {
1183 set("minimumShares", newValue);
1184 }
1185
1186 public String getMinimumSharesMessage() {
1187 return get("minimumSharesMessage");
1188 }
1189
1190 public void setMinimumSharesMessage(String newValue) {
1191 set("minimumSharesMessage", newValue);
1192 }
1193
1194 public void setLimitDownloadAttempts(boolean newValue) {
1195 set("limitDownloadAttempts", newValue);
1196 }
1197
1198 public boolean getLimitDownloadAttempts() {
1199 return getBoolean("limitDownloadAttempts");
1200 }
1201
1202 public String[] getOpenWithCommands() {
1203 return getArray("openWithCommands");
1204 }
1205
1206 public void setOpenWithCommands(String[] newValue) {
1207 set("openWithCommands", newValue);
1208 }
1209
1210 public int getPrefsWindowHeight() {
1211 return getInt("prefsWindowHeight");
1212 }
1213
1214 public void setPrefsWindowHeight(int newValue) {
1215 set("prefsWindowHeight", newValue);
1216 }
1217
1218 public int getPrefsWindowWidth() {
1219 return getInt("prefsWindowWidth");
1220 }
1221
1222 public void setPrefsWindowWidth(int newValue) {
1223 set("prefsWindowWidth", newValue);
1224 }
1225
1226 public String getProblemReportURL() {
1227 return get("problemReportURL");
1228 }
1229
1230 public boolean getRememberFeedback() {
1231 return getBoolean("rememberFeedback");
1232 }
1233
1234 public boolean getRemoveDuplicateResults() {
1235 return getBoolean("removeDuplicateResults");
1236 }
1237
1238 public void setRemoveDuplicateResults(boolean newValue) {
1239 set("removeDuplicateResults", newValue);
1240 }
1241
1242 public int getSearchBitrate() {
1243 return getInt("searchBitrate");
1244 }
1245
1246 public void setSearchBitrate(int newValue) {
1247 set("searchBitrate", newValue);
1248 }
1249
1250 public int getSearchCompare() {
1251 return getInt("searchCompare");
1252 }
1253
1254 public void setSearchCompare(int newValue) {
1255 set("searchCompare", newValue);
1256 }
1257
1258 public int getSearchDividerLocation() {
1259 return getInt("searchDividerLocation");
1260 }
1261
1262 public void setSearchDividerLocation(int newValue) {
1263 set("searchDividerLocation", newValue);
1264 }
1265
1266 public int getSearchHistorySize() {
1267 return getInt("searchHistorySize");
1268 }
1269
1270 public void setSearchHistorySize(int newValue) {
1271 set("searchHistorySize", newValue);
1272 }
1273
1274 public int getSearchMediaType() {
1275 return getInt("searchMediaType");
1276 }
1277
1278 public void setSearchMediaType(int newValue) {
1279 set("searchMediaType", newValue);
1280 }
1281
1282 public String getSearchResultOpenAction() {
1283 return get("searchResultOpenAction");
1284 }
1285
1286 public boolean getSendMinimumSharesMessage() {
1287 return getBoolean("sendMinimumSharesMessage");
1288 }
1289
1290 public void setSendMinimumSharesMessage(boolean newValue) {
1291 set("sendMinimumSharesMessage", newValue);
1292 }
1293
1294 public String getSocksProxyHost() {
1295 return get("socksProxyHost");
1296 }
1297
1298 public void setSocksProxyHost(String newValue) {
1299 set("socksProxyHost", newValue);
1300 }
1301
1302 public int getSocksProxyPort() {
1303 return getInt("socksProxyPort");
1304 }
1305
1306 public void setSocksProxyPort(int newValue) {
1307 set("socksProxyPort", newValue);
1308 }
1309
1310 public String getTheme() {
1311 return get("theme");
1312 }
1313
1314 public void setTheme(String newValue) {
1315 set("theme", newValue);
1316 }
1317
1318 public int getTransferDividerLocation() {
1319 return getInt("transferDividerLocation");
1320 }
1321
1322 public void setTransferDividerLocation(int newValue) {
1323 set("transferDividerLocation", newValue);
1324 }
1325
1326 public String getTransferLogFile() {
1327 return get("transferLogFile");
1328 }
1329
1330 public void setTransferLogFile(String newValue) {
1331 set("transferLogFile", newValue);
1332 }
1333
1334 public boolean getUpdatePluginsOnStartup() {
1335 return getBoolean("updatePluginsOnStartup");
1336 }
1337
1338 public void setUpdatePluginsOnStartup(boolean newValue) {
1339 set("updatePluginsOnStartup", newValue);
1340 }
1341
1342 public int getUpdaterInterval()
1343 {
1344 return getInt("updaterInterval");
1345 }
1346
1347 public String getUpdateURL() {
1348 return get("updateURL");
1349 }
1350
1351 public String[] getUploadDirs()
1352 {
1353 return getArray("uploadDirs");
1354 }
1355
1356 public void setUploadDirs(String[] newValue)
1357 {
1358 set("uploadDirs", newValue);
1359 }
1360
1361 public int getUploadThrottle() {
1362 return getInt("uploadThrottle");
1363 }
1364
1365 public void setUploadThrottle(int newValue) {
1366 set("uploadThrottle", newValue);
1367 }
1368
1369 public boolean getUseEmacsKeyBindings() {
1370 return getBoolean("useEmacsKeyBindings");
1371 }
1372
1373 public void setUseEmacsKeyBindings(boolean newValue) {
1374 set("useEmacsKeyBindings", newValue);
1375 }
1376
1377 public String getUsername() {
1378 return get("username");
1379 }
1380
1381 public void setUsername(String newValue) {
1382 set("username", newValue);
1383 }
1384
1385 public boolean getUseHttpProxy() {
1386 return getBoolean("useHttpProxy");
1387 }
1388
1389 public void setUseHttpProxy(boolean newValue) {
1390 set("useHttpProxy", newValue);
1391 }
1392
1393 public boolean getUseMinimumShares() {
1394 return getBoolean("useMinimumShares");
1395 }
1396
1397 public void setUseMinimumShares(boolean newValue) {
1398 set("useMinimumShares", newValue);
1399 }
1400
1401 public boolean getUseSmallTransferIcons() {
1402 return getBoolean("useSmallTransferIcons");
1403 }
1404
1405 public boolean getUseSocksProxy() {
1406 return getBoolean("useSocksProxy");
1407 }
1408
1409 public void setUseSocksProxy(boolean newValue) {
1410 set("useSocksProxy", newValue);
1411 }
1412
1413 public boolean getUseSubMenuForPluginMenus() {
1414 return getBoolean("useSubMenuForPluginMenus");
1415 }
1416
1417 public void setUseSubMenuForPluginMenus(boolean newValue) {
1418 set("useSubMenuForPluginMenus", newValue);
1419 }
1420
1421 public boolean getUseTabbedPane() {
1422 return getBoolean("useTabbedPane");
1423 }
1424
1425 public void setUseTabbedPane(boolean newValue) {
1426 set("useTabbedPane", newValue);
1427 }
1428
1429 public boolean getUseTabbedTransferPane() {
1430 return getBoolean("useTabbedTransferPane");
1431 }
1432
1433 public void setUseTabbedTransferPane(boolean newValue) {
1434 set("useTabbedTransferPane", newValue);
1435 }
1436
1437 public String[] getTableColumns(String table) {
1438 return getArray(table + "TableColumns");
1439 }
1440
1441 public void setTableColumns(String table, String[] newValue) {
1442 set(table + "TableColumns", newValue);
1443 }
1444
1445 public int[] getTableColumnWidths(String table) {
1446 return getIntArray(table + "TableColumnWidths");
1447 }
1448
1449 public void setTableColumnWidths(String table, int[] widths) {
1450 set(table + "TableColumnWidths", widths);
1451 }
1452
1453 public boolean getTableMaintainSortOrder(String table) {
1454 return getBoolean(table + "TableMaintainSortOrder");
1455 }
1456
1457 public void setTableMaintainSortOrder(String table, boolean newValue) {
1458 set(table + "TableMaintainSortOrder", newValue);
1459 }
1460
1461 public int getTableSortedColumn(String table) {
1462 return getInt(table + "TableSortedColumn");
1463 }
1464
1465 public void setTableSortedColumn(String table, int newValue) {
1466 set(table + "TableSortedColumn", newValue);
1467 }
1468
1469 public boolean getThrottleDownloads() {
1470 return getBoolean("throttleDownloads");
1471 }
1472
1473 public void setThrottleDownloads(boolean newValue) {
1474 set("throttleDownloads", newValue);
1475 }
1476
1477 public boolean getThrottleUploads() {
1478 return getBoolean("throttleUploads");
1479 }
1480
1481 public void setThrottleUploads(boolean newValue) {
1482 set("throttleUploads", newValue);
1483 }
1484
1485 public int getWindowHeight() {
1486 return getInt("windowHeight");
1487 }
1488
1489 public void setWindowHeight(int newValue) {
1490 set("windowHeight", newValue);
1491 }
1492
1493 public int getWindowWidth() {
1494 return getInt("windowWidth");
1495 }
1496
1497 public void setWindowWidth(int newValue) {
1498 set("windowWidth", newValue);
1499 }
1500
1501 public int getWindowX() {
1502 return getInt("windowX");
1503 }
1504
1505 public void setWindowX(int newValue) {
1506 set("windowX", newValue);
1507 }
1508
1509 public int getWindowY() {
1510 return getInt("windowY");
1511 }
1512
1513 public void setWindowY(int newValue) {
1514 set("windowY", newValue);
1515 }
1516
1517 public String getXNapJarURL() {
1518 return get("xnapJarURL");
1519 }
1520
1521 }