private static void configureFilesystems() { // Configure the SMB subsystem (backed by jCIFS) to maintain compatibility with SMB servers that // don't support // NTLM v2 authentication such as Samba 3.0.x, which still is widely used and comes // pre-installed on // Mac OS X Leopard. // Since jCIFS 1.3.0, the default is to use NTLM v2 authentication and extended security. SMBProtocolProvider.setLmCompatibility( MuConfiguration.getVariable( MuConfiguration.SMB_LM_COMPATIBILITY, MuConfiguration.DEFAULT_SMB_LM_COMPATIBILITY)); SMBProtocolProvider.setExtendedSecurity( MuConfiguration.getVariable( MuConfiguration.SMB_USE_EXTENDED_SECURITY, MuConfiguration.DEFAULT_SMB_USE_EXTENDED_SECURITY)); // Use the FTP configuration option that controls whether to force the display of hidden files, // or leave it for // the servers to decide whether to show them. FTPProtocolProvider.setForceHiddenFilesListing( MuConfiguration.getVariable( MuConfiguration.LIST_HIDDEN_FILES, MuConfiguration.DEFAULT_LIST_HIDDEN_FILES)); // Register the application-specific 'bookmark' protocol. FileFactory.registerProtocol( BookmarkProtocolProvider.BOOKMARK, new com.mucommander.bookmark.file.BookmarkProtocolProvider()); }
/** * Method used to migrate commands that used to be defined in the configuration but were moved to * <code>commands.xml</code>. * * @param useName name of the <code>use custom command</code> configuration variable. * @param commandName name of the <code>custom command</code> configuration variable. */ private static void migrateCommand(String useName, String commandName, String alias) { String command; if (MuConfiguration.getBooleanVariable(useName) && (command = MuConfiguration.getVariable(commandName)) != null) { try { CommandManager.registerCommand(new Command(alias, command, Command.SYSTEM_COMMAND)); } catch (CommandException e) { // Ignore this: the command didn't work in the first place, we might as well get rid of it. } MuConfiguration.removeVariable(useName); MuConfiguration.removeVariable(commandName); } }
public SendMailJob( ProgressDialog progressDialog, MainFrame mainFrame, FileSet filesToSend, String recipientString, String mailSubject, String mailBody) { super(progressDialog, mainFrame, filesToSend); this.boundary = "mucommander" + System.currentTimeMillis(); this.recipientString = recipientString; this.mailSubject = mailSubject; this.mailBody = mailBody + "\n\n" + "Sent by muCommander - http://www.mucommander.com\n"; this.mailServer = MuConfiguration.getVariable(MuConfiguration.SMTP_SERVER); this.fromName = MuConfiguration.getVariable(MuConfiguration.MAIL_SENDER_NAME); this.fromAddress = MuConfiguration.getVariable(MuConfiguration.MAIL_SENDER_ADDRESS); this.errorDialogTitle = Translator.get("email_dialog.error_title"); }
private void openConnection() throws IOException { this.socket = new Socket( mailServer, MuConfiguration.getVariable( MuConfiguration.SMTP_PORT, MuConfiguration.DEFAULT_SMTP_PORT)); this.in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8")); this.out = socket.getOutputStream(); this.out64 = new Base64OutputStream(out, true); this.connectedToMailServer = true; }
/** Returns true if mail preferences have been set. */ public static boolean mailPreferencesSet() { return MuConfiguration.isVariableSet(MuConfiguration.SMTP_SERVER) && MuConfiguration.isVariableSet(MuConfiguration.MAIL_SENDER_NAME) && MuConfiguration.isVariableSet(MuConfiguration.MAIL_SENDER_ADDRESS); }
/** * Sets the new log level to be used by all <code>java.util.logging</code> loggers, and persists * it in the application preferences. * * @param level the new log level to be used by all <code>java.util.logging</code> loggers. */ public static void setLogLevel(Level level) { MuConfiguration.setVariable(MuConfiguration.LOG_LEVEL, level.getName()); updateLogLevel(level); }
/** * Returns the current log level used by all <code>java.util.logging</code> loggers. * * @return the current log level used by all <code>java.util.logging</code> loggers. */ public static Level getLogLevel() { return Level.parse( MuConfiguration.getVariable(MuConfiguration.LOG_LEVEL, MuConfiguration.DEFAULT_LOG_LEVEL)); }
/** * Main method used to startup muCommander. * * @param args command line arguments. * @throws IOException if an unrecoverable error occurred during startup */ public static void main(String args[]) throws IOException { try { int i; // Index in the command line arguments. // Initialises fields. // Whether or not to ignore warnings when booting. boolean fatalWarnings = false; verbose = true; // - Command line parsing ------------------------------------- // ------------------------------------------------------------ for (i = 0; i < args.length; i++) { // Print version. if (args[i].equals("-v") || args[i].equals("--version")) printVersion(); // Print help. else if (args[i].equals("-h") || args[i].equals("--help")) printUsage(); // Associations handling. else if (args[i].equals("-a") || args[i].equals("--assoc")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { com.mucommander.command.CommandManager.setAssociationFile(args[++i]); } catch (Exception e) { printError("Could not set association files", e, fatalWarnings); } } // Custom commands handling. else if (args[i].equals("-f") || args[i].equals("--commands")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { com.mucommander.command.CommandManager.setCommandFile(args[++i]); } catch (Exception e) { printError("Could not set commands file", e, fatalWarnings); } } // Bookmarks handling. else if (args[i].equals("-b") || args[i].equals("--bookmarks")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { com.mucommander.bookmark.BookmarkManager.setBookmarksFile(args[++i]); } catch (Exception e) { printError("Could not set bookmarks file", e, fatalWarnings); } } // Configuration handling. else if (args[i].equals("-c") || args[i].equals("--configuration")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { MuConfiguration.setConfigurationFile(args[++i]); } catch (Exception e) { printError("Could not set configuration file", e, fatalWarnings); } } // Shell history. else if (args[i].equals("-s") || args[i].equals("--shell-history")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { ShellHistoryManager.setHistoryFile(args[++i]); } catch (Exception e) { printError("Could not set shell history file", e, fatalWarnings); } } // Keymap file. else if (args[i].equals("-k") || args[i].equals("--keymap")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { com.mucommander.ui.action.ActionKeymapIO.setActionsFile(args[++i]); } catch (Exception e) { printError("Could not set keymap file", e, fatalWarnings); } } // Toolbar file. else if (args[i].equals("-t") || args[i].equals("--toolbar")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { ToolBarIO.setDescriptionFile(args[++i]); } catch (Exception e) { printError("Could not set keymap file", e, fatalWarnings); } } // Commandbar file. else if (args[i].equals("-C") || args[i].equals("--commandbar")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { CommandBarIO.setDescriptionFile(args[++i]); } catch (Exception e) { printError("Could not set commandbar description file", e, fatalWarnings); } } // Credentials file. else if (args[i].equals("-U") || args[i].equals("--credentials")) { if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true); try { com.mucommander.auth.CredentialsManager.setCredentialsFile(args[++i]); } catch (Exception e) { printError("Could not set credentials file", e, fatalWarnings); } } // Preference folder. else if ((args[i].equals("-p") || args[i].equals("--preferences"))) { if (i >= args.length - 1) printError("Missing FOLDER parameter to " + args[i], null, true); try { PlatformManager.setPreferencesFolder(args[++i]); } catch (Exception e) { printError("Could not set preferences folder", e, fatalWarnings); } } // Extensions folder. else if ((args[i].equals("-e") || args[i].equals("--extensions"))) { if (i >= args.length - 1) printError("Missing FOLDER parameter to " + args[i], null, true); try { ExtensionManager.setExtensionsFolder(args[++i]); } catch (Exception e) { printError("Could not set extensions folder", e, fatalWarnings); } } // Ignore warnings. else if (args[i].equals("-i") || args[i].equals("--ignore-warnings")) fatalWarnings = false; // Fail on warnings. else if (args[i].equals("-w") || args[i].equals("--fail-on-warnings")) fatalWarnings = true; // Silent mode. else if (args[i].equals("-S") || args[i].equals("--silent")) verbose = false; // Verbose mode. else if (args[i].equals("-V") || args[i].equals("--verbose")) verbose = true; // Illegal argument. else break; } // - Configuration init --------------------------------------- // ------------------------------------------------------------ // Ensure that a graphics environment is available, exit otherwise. checkHeadless(); // Attempts to guess whether this is the first time muCommander is booted or not. boolean isFirstBoot; try { isFirstBoot = !MuConfiguration.getConfigurationFile().exists(); } catch (IOException e) { isFirstBoot = true; } // Configuration needs to be loaded before any sort of GUI creation is performed : under Mac // OS X, if we're // to use the metal look, we need to know about it right about now. try { MuConfiguration.read(); } catch (Exception e) { printFileError("Could not load configuration", e, fatalWarnings); } // - Logging configuration ------------------------------------ // ------------------------------------------------------------ configureLogging(); // - MAC OS X specific init ----------------------------------- // ------------------------------------------------------------ // If muCommander is running under Mac OS X (how lucky!), add some glue for the main menu bar // and other OS X // specifics. if (OsFamilies.MAC_OS_X.isCurrent()) { // Use reflection to create an OSXIntegration instance so that ClassLoader // doesn't throw an NoClassDefFoundException under platforms other than Mac OS X try { Class<?> osxIntegrationClass = Class.forName("com.mucommander.ui.macosx.OSXIntegration"); Constructor<?> constructor = osxIntegrationClass.getConstructor(new Class[] {}); constructor.newInstance(); } catch (Exception e) { AppLogger.fine("Exception thrown while initializing Mac OS X integration", e); } } // - muCommander boot ----------------------------------------- // ------------------------------------------------------------ // Adds all extensions to the classpath. try { ExtensionManager.addExtensionsToClasspath(); } catch (Exception e) { AppLogger.fine("Failed to add extensions to the classpath", e); } // This the property is supposed to have the java.net package use the proxy defined in the // system settings // to establish HTTP connections. This property is supported only under Java 1.5 and up. // Note that Mac OS X already uses the system HTTP proxy, with or without this property being // set. System.setProperty("java.net.useSystemProxies", "true"); // Shows the splash screen, if enabled in the preferences useSplash = MuConfiguration.getVariable( MuConfiguration.SHOW_SPLASH_SCREEN, MuConfiguration.DEFAULT_SHOW_SPLASH_SCREEN); if (useSplash) { splashScreen = new SplashScreen(RuntimeConstants.VERSION, "Loading preferences..."); } boolean showSetup; showSetup = MuConfiguration.getVariable(MuConfiguration.THEME_TYPE) == null; // Traps VM shutdown Runtime.getRuntime().addShutdownHook(new ShutdownHook()); // Configure filesystems configureFilesystems(); // Initializes the desktop. try { com.mucommander.desktop.DesktopManager.init(isFirstBoot); } catch (Exception e) { printError("Could not initialize desktop", e, true); } // Loads dictionary printStartupMessage("Loading dictionary..."); try { com.mucommander.text.Translator.loadDictionaryFile(); } catch (Exception e) { printError("Could not load dictionary", e, true); } // Loads custom commands printStartupMessage("Loading file associations..."); try { com.mucommander.command.CommandManager.loadCommands(); } catch (Exception e) { printFileError("Could not load custom commands", e, fatalWarnings); } // Migrates the custom editor and custom viewer if necessary. migrateCommand("viewer.use_custom", "viewer.custom_command", CommandManager.VIEWER_ALIAS); migrateCommand("editor.use_custom", "editor.custom_command", CommandManager.EDITOR_ALIAS); try { CommandManager.writeCommands(); } catch (Exception e) { System.out.println("###############################"); AppLogger.fine("Caught exception", e); // There's really nothing we can do about this... } try { com.mucommander.command.CommandManager.loadAssociations(); } catch (Exception e) { printFileError("Could not load custom associations", e, fatalWarnings); } // Loads bookmarks printStartupMessage("Loading bookmarks..."); try { com.mucommander.bookmark.BookmarkManager.loadBookmarks(); } catch (Exception e) { printFileError("Could not load bookmarks", e, fatalWarnings); } // Loads credentials printStartupMessage("Loading credentials..."); try { com.mucommander.auth.CredentialsManager.loadCredentials(); } catch (Exception e) { printFileError("Could not load credentials", e, fatalWarnings); } // Loads shell history printStartupMessage("Loading shell history..."); try { ShellHistoryManager.loadHistory(); } catch (Exception e) { printFileError("Could not load shell history", e, fatalWarnings); } // Inits CustomDateFormat to make sure that its ConfigurationListener is added // before FileTable, so CustomDateFormat gets notified of date format changes first com.mucommander.text.CustomDateFormat.init(); // Initialize file icons printStartupMessage("Loading icons..."); // Initialize the SwingFileIconProvider from the main thread, see method Javadoc for an // explanation on why we do this now SwingFileIconProvider.forceInit(); // The math.max(1.0f, ...) part is to workaround a bug which cause(d) this value to be set to // 0.0 in the configuration file. com.mucommander.ui.icon.FileIcons.setScaleFactor( Math.max( 1.0f, MuConfiguration.getVariable( MuConfiguration.TABLE_ICON_SCALE, MuConfiguration.DEFAULT_TABLE_ICON_SCALE))); com.mucommander.ui.icon.FileIcons.setSystemIconsPolicy( MuConfiguration.getVariable( MuConfiguration.USE_SYSTEM_FILE_ICONS, MuConfiguration.DEFAULT_USE_SYSTEM_FILE_ICONS)); // Register actions printStartupMessage("Registering actions..."); ActionManager.registerActions(); // Loads the ActionKeymap file printStartupMessage("Loading actions shortcuts..."); try { com.mucommander.ui.action.ActionKeymapIO.loadActionKeymap(); } catch (Exception e) { printFileError("Could not load actions shortcuts", e, fatalWarnings); } // Loads the ToolBar's description file printStartupMessage("Loading toolbar description..."); try { ToolBarIO.loadDescriptionFile(); } catch (Exception e) { printFileError("Could not load toolbar description", e, fatalWarnings); } // Loads the CommandBar's description file printStartupMessage("Loading command bar description..."); try { CommandBarIO.loadCommandBar(); } catch (Exception e) { printFileError("Could not load commandbar description", e, fatalWarnings); } // Loads the themes. printStartupMessage("Loading theme..."); com.mucommander.ui.theme.ThemeManager.loadCurrentTheme(); // Starts Bonjour services discovery (only if enabled in prefs) printStartupMessage("Starting Bonjour services discovery..."); com.mucommander.bonjour.BonjourDirectory.setActive( MuConfiguration.getVariable( MuConfiguration.ENABLE_BONJOUR_DISCOVERY, MuConfiguration.DEFAULT_ENABLE_BONJOUR_DISCOVERY)); // Creates the initial main frame using any initial path specified by the command line. printStartupMessage("Initializing window..."); for (; i < args.length; i += 2) { if (i < args.length - 1) WindowManager.createNewMainFrame(args[i], args[i + 1]); else WindowManager.createNewMainFrame(args[i], null); } // If no initial path was specified, start a default main window. if (WindowManager.getCurrentMainFrame() == null) WindowManager.createNewMainFrame(); // Done launching, wake up threads waiting for the application being launched. // Important: this must be done before disposing the splash screen, as this would otherwise // create a deadlock // if the AWT event thread were waiting in #waitUntilLaunched . synchronized (LAUNCH_LOCK) { isLaunching = false; LAUNCH_LOCK.notifyAll(); } // Enable system notifications, only after MainFrame is created as SystemTrayNotifier needs to // retrieve // a MainFrame instance if (MuConfiguration.getVariable( MuConfiguration.ENABLE_SYSTEM_NOTIFICATIONS, MuConfiguration.DEFAULT_ENABLE_SYSTEM_NOTIFICATIONS)) { printStartupMessage("Enabling system notifications..."); if (com.mucommander.ui.notifier.AbstractNotifier.isAvailable()) com.mucommander.ui.notifier.AbstractNotifier.getNotifier().setEnabled(true); } // Dispose splash screen. if (splashScreen != null) splashScreen.dispose(); // Check for newer version unless it was disabled if (MuConfiguration.getVariable( MuConfiguration.CHECK_FOR_UPDATE, MuConfiguration.DEFAULT_CHECK_FOR_UPDATE)) new CheckVersionDialog(WindowManager.getCurrentMainFrame(), false); // If no theme is configured in the preferences, ask for an initial theme. if (showSetup) new InitialSetupDialog(WindowManager.getCurrentMainFrame()).showDialog(); } catch (Throwable t) { // Startup failed, dispose the splash screen if (splashScreen != null) splashScreen.dispose(); AppLogger.severe("Startup failed", t); // Display an error dialog with a proper message and error details InformationDialog.showErrorDialog(null, null, Translator.get("startup_error"), null, t); // Quit the application WindowManager.quit(); } }