1 package net.suberic.pooka; 2 import net.suberic.pooka.gui.*; 3 import net.suberic.util.VariableBundle; 4 import net.suberic.pooka.resource.*; 5 6 import java.awt.*; 7 import javax.swing.*; 8 import javax.help.*; 9 import java.util.logging.*; 10 11 public class Pooka { 12 13 14 public static PookaManager sManager; 15 16 29 static public void main(String argv[]) { 30 sManager = new PookaManager(); 31 sStartupManager = new StartupManager(sManager); 32 sStartupManager.runPooka(argv); 33 } 34 public static StartupManager sStartupManager = null; 35 36 39 public static void loadInitialResources() { 40 try { 41 ClassLoader cl = new Pooka().getClass().getClassLoader(); 42 java.net.URL url; 43 if (cl == null) { 44 url = ClassLoader.getSystemResource("net/suberic/pooka/Pookarc"); 45 } else { 46 url = cl.getResource("net/suberic/pooka/Pookarc"); 47 } 48 49 if (url == null) { 50 url = new Pooka().getClass().getResource("/net/suberic/pooka/Pookarc"); 52 } 53 54 java.io.InputStream is = url.openStream(); 55 VariableBundle resources = new net.suberic.util.VariableBundle(is, "net.suberic.pooka.Pooka"); 56 sManager.setResources(resources); 57 } catch (Exception e) { 58 System.err.println("caught exception loading system resources: " + e); 59 e.printStackTrace(); 60 System.exit(-1); 61 } 62 } 63 64 65 68 public static void loadResources(boolean pUseLocalFiles, boolean pUseHttp) { 69 if (sManager == null || sManager.getResources() == null) { 70 System.err.println("Error starting up Pooka: No system resource files found."); 71 System.exit(-1); 72 } 73 74 try { 75 net.suberic.util.VariableBundle pookaDefaultBundle = sManager.getResources(); 76 ResourceManager resourceManager = null; 77 78 if (! pUseLocalFiles || pookaDefaultBundle.getProperty("Pooka.useLocalFiles", "true").equalsIgnoreCase("false")) { 79 resourceManager = new DisklessResourceManager(); 80 } else { 81 resourceManager = new FileResourceManager(); 82 } 83 84 sManager.setResourceManager(resourceManager); 85 86 if (sManager.getLocalrc() == null) { 88 String localrc = new String (System.getProperty("user.home") + System.getProperty("file.separator") + ".pookarc"); 89 sManager.setLocalrc(localrc); 90 } 91 sManager.setResources(sManager.getResourceManager().createVariableBundle(sManager.getLocalrc(), pookaDefaultBundle)); 92 } catch (Exception e) { 93 System.err.println("caught exception: " + e); 94 e.printStackTrace(); 95 } 96 97 if (pUseHttp || sManager.getResources().getProperty("Pooka.httpConfig", "false").equalsIgnoreCase("true")) { 98 net.suberic.pooka.gui.LoadHttpConfigPooka configPooka = new net.suberic.pooka.gui.LoadHttpConfigPooka(); 99 configPooka.start(); 100 } 101 } 102 103 106 public static void exitPooka(int exitValue, Object pSource) { 107 final int fExitValue = exitValue; 108 final Object fSource = pSource; 109 Runnable runMe = new Runnable () { 110 public void run() { 111 sStartupManager.stopMainPookaWindow(fSource); 112 System.exit(fExitValue); 113 } 114 }; 115 116 if (Pooka.getMainPanel() != null) 117 Pooka.getMainPanel().setCursor(java.awt.Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 118 119 Thread shutdownThread = new Thread (runMe); 120 shutdownThread.start(); 121 } 122 123 127 static public String getProperty(String propName, String defVal) { 128 return (getResources().getProperty(propName, defVal)); 129 } 130 131 135 static public String getProperty(String propName) { 136 return (getResources().getProperty(propName)); 137 } 138 139 143 static public void setProperty(String propName, String propValue) { 144 getResources().setProperty(propName, propValue); 145 } 146 147 150 static public net.suberic.util.VariableBundle getResources() { 151 return sManager.getResources(); 152 } 153 156 static public void setResources(net.suberic.util.VariableBundle pResources) { 157 sManager.setResources(pResources); 158 } 159 160 161 165 static public boolean isDebug() { 166 if (getResources().getProperty("Pooka.debug", "true").equals("true")) 167 return true; 168 else if (Logger.getLogger("Pooka.debug").isLoggable(Level.FINE)) 169 return true; 170 else 171 return false; 172 } 173 174 177 static public DateFormatter getDateFormatter() { 178 return sManager.getDateFormatter(); 179 } 180 181 186 static public javax.activation.CommandMap getMailcap() { 187 return sManager.getMailcap(); 188 } 189 190 194 static public javax.activation.MimetypesFileTypeMap getMimeTypesMap() { 195 return sManager.getMimeTypesMap(); 196 } 197 198 201 static public javax.mail.Session getDefaultSession() { 202 return sManager.getDefaultSession(); 203 } 204 205 208 static public javax.mail.Authenticator getDefaultAuthenticator() { return sManager.getDefaultAuthenticator(); } 209 210 211 216 static public net.suberic.pooka.thread.FolderTracker getFolderTracker() { 217 return sManager.getFolderTracker(); 218 } 219 220 223 static public MainPanel getMainPanel() { 224 return sManager.getMainPanel(); 225 } 226 227 231 static public StoreManager getStoreManager() { 232 return sManager.getStoreManager(); 233 } 234 235 240 static public SearchTermManager getSearchManager() { 241 return sManager.getSearchManager(); 242 } 243 244 250 static public PookaUIFactory getUIFactory() { 251 return sManager.getUIFactory(); 252 } 253 254 258 static public net.suberic.util.thread.ActionThread getSearchThread() { 259 return sManager.getSearchThread(); 260 } 261 262 266 static public AddressBookManager getAddressBookManager() { 267 return sManager.getAddressBookManager(); 268 } 269 270 273 static public NetworkConnectionManager getConnectionManager() { 274 return sManager.getConnectionManager(); 275 } 276 277 281 static public OutgoingMailServerManager getOutgoingMailManager() { 282 return sManager.getOutgoingMailManager(); 283 } 284 285 289 public static PookaEncryptionManager getCryptoManager() { 290 return sManager.getCryptoManager(); 291 } 292 293 296 static public HelpBroker getHelpBroker() { 297 return sManager.getHelpBroker(); 298 } 299 300 303 static public ResourceManager getResourceManager() { 304 return sManager.getResourceManager(); 305 } 306 307 310 static public net.suberic.pooka.ssl.PookaTrustManager getTrustManager() { 311 return sManager.getTrustManager(); 312 } 313 314 317 static public void setTrustManager(net.suberic.pooka.ssl.PookaTrustManager pTrustManager) { 318 sManager.setTrustManager(pTrustManager); 319 } 320 321 324 static public PookaLogManager getLogManager() { 325 return sManager.getLogManager(); 326 } 327 328 331 static public PookaManager getPookaManager() { 332 return sManager; 333 } 334 335 } 336 337 338 | Popular Tags |