01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.gui.externaltools;
17:
18: import java.io.File;
19: import java.net.MalformedURLException;
20: import java.net.URL;
21:
22: import org.columba.core.base.OSInfo;
23:
24: /**
25: * Plugin for the aspell spell-checking package.
26: *
27: * @author fdietz
28: */
29: public class GPGPlugin extends AbstractExternalToolsPlugin {
30: protected static File defaultLinux = new File("/usr/bin/gpg");
31: protected static File defaultLocalLinux = new File(
32: "/usr/local/bin/gpg");
33:
34: /* GPG for windows is an executable-only download, fortunately there is
35: * a windows registry file included in the download and has this as the
36: * default installation path in it. While users will probably install GPG
37: * into many other places, this is atleast a best-guess start.
38: */
39: protected static File defaultWin = new File("C:\\GnuPG\\gpg.exe");
40: protected static URL websiteURL;
41:
42: static {
43: try {
44: websiteURL = new URL("http://www.gnupg.org/");
45: } catch (MalformedURLException mue) {
46: }
47:
48: //does not happen
49: }
50:
51: /**
52: * Construct the default GPG plugin.
53: */
54: public GPGPlugin() {
55: super ();
56: }
57:
58: public String getDescription() {
59: return "<html><body><p>GnuPG is a complete and free replacement for PGP.</p><p>Because it does not use the patented IDEA algorithm, it can be used without any restrictions. GnuPG is a RFC2440 (OpenPGP) compliant application.</p><p>GnuPG itself is a commandline tool without any graphical stuff. It is the real crypto engine which can be used directly from a command prompt, from shell scripts or by other programs. Therefore it can be considered as a backend for other applications.</p></body></html>";
60: }
61:
62: public URL getWebsite() {
63: return websiteURL;
64: }
65:
66: public File locate() {
67: /* If this is a unix-based system, check the 2 best-known areas for the
68: * gpg binary.
69: */
70: if (OSInfo.isLinux() || OSInfo.isSolaris()) {
71: if (defaultLinux.exists()) {
72: return defaultLinux;
73: } else if (defaultLocalLinux.exists()) {
74: return defaultLocalLinux;
75: }
76: }
77:
78: /* RIYAD: The Prefs API cannot be used to read the Window's registry,
79: * it is coded to use the registry (if available) as a backing store
80: * on in the SOFTWARE/JavaSoft/Prefs registry keys for HKEY_CURRENT_USER
81: * and HKEY_LOCAL_MACHINE paths. I have seen a few java apps that use
82: * the Windows registry and they all required a native lib to do it.
83: */
84: /* If this is windows, check the default installation location for the
85: * gpg.exe binary.
86: */
87: if (OSInfo.isWin32Platform() && defaultWin.exists()) {
88: return defaultWin;
89: }
90:
91: /* Couldn't find anything, so return null and let the wizard ask the
92: * user.
93: */
94: return null;
95: }
96: }
|