Search in sources :

Example 1 with CDatabaseManager

use of com.google.security.zynamics.binnavi.Database.CDatabaseManager in project binnavi by google.

the class StandAlone method getPluginInterface.

// ! Returns the BinNavi plugin interface.
/**
   * Returns the plugin interface that can be used from stand-alone scripts.
   *
   * @return The plugin interface that can be used from stand-alone scripts.
   */
public static synchronized PluginInterface getPluginInterface() {
    try {
        ConfigManager.instance().read();
    } catch (final FileReadException exception) {
        NaviLogger.severe("Error: could not read config file.");
    }
    final CDatabaseManager manager = CDatabaseManager.instance();
    final PluginRegistry registry = new PluginRegistry();
    if (pluginInterface == null) {
        pluginInterface = PluginInterface.instance("", /* start path */
        manager, registry);
    }
    return pluginInterface;
}
Also used : PluginRegistry(com.google.security.zynamics.binnavi.Plugins.PluginRegistry) CDatabaseManager(com.google.security.zynamics.binnavi.Database.CDatabaseManager) FileReadException(com.google.security.zynamics.binnavi.config.FileReadException)

Example 2 with CDatabaseManager

use of com.google.security.zynamics.binnavi.Database.CDatabaseManager in project binnavi by google.

the class CMain method prepareDatabaseConnections.

/**
   * Loads all database connections that are loaded automatically on startup.
   */
private static void prepareDatabaseConnections() {
    NaviLogger.info("Initializing database connections");
    // Read database information from the configuration file.
    final CDatabaseManager manager = CDatabaseManager.instance();
    for (final DatabaseConfigItem database : ConfigManager.instance().getDatabases()) {
        manager.addDatabase(new CDatabase(database.getDescription(), database.getDriver(), database.getHost(), database.getName(), database.getUser(), database.getPassword(), database.getIdentity(), database.isSavePassword(), database.isAutoConnect()));
    }
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) DatabaseConfigItem(com.google.security.zynamics.binnavi.config.DatabaseConfigItem) CDatabaseManager(com.google.security.zynamics.binnavi.Database.CDatabaseManager)

Example 3 with CDatabaseManager

use of com.google.security.zynamics.binnavi.Database.CDatabaseManager in project binnavi by google.

the class CMain method main.

/**
   * Program entry function.
   *
   * @param args Command line parameters that were passed to the program.
   */
public static void main(final String[] args) {
    // ATTENTION: IF YOU'RE NOT READING THE CONFIG FILE FIRST YOU'RE PROBABLY DOING SOMETHING WRONG.
    CSettingsDirectoryCreator.createSettingsDirectory();
    final boolean firstStart = !CConfigurationFileCreator.setupConfigurationFile();
    BuildVersionInformation.loadBuildVersionInformation();
    // ESCA-JAVA0266:
    // ATTENTION: DO NOT MOVE THE LINE BELOW ABOVE THE CONFIG FILE STUFF
    // Don't remove this line, it actually works from inside JAR files
    System.out.printf("Starting %s%n", Constants.PROJECT_NAME_VERSION_BUILD);
    CGraphPanelExtender.extend();
    GuiInitializer.initialize();
    if (firstStart) {
        final CDatabase newDatabase = new CDatabase("Click and configure me", "org.postgresql.Driver", "localhost", "new_database", "user", "password", "identity", false, false);
        CDatabaseManager.instance().addDatabase(newDatabase);
    }
    prepareDatabaseConnections();
    final PluginRegistry pluginRegistry = new PluginRegistry();
    final String startPath = FileUtils.findLocalRootPath(CMain.class);
    Constants.startPath = startPath;
    NaviLogger.info("Defaulting startup path to %s", startPath);
    final CDatabaseManager databaseManager = CDatabaseManager.instance();
    final PluginInterface pluginInterface = PluginInterface.instance(startPath, databaseManager, pluginRegistry);
    final CProjectMainFrame window = new CProjectMainFrame(databaseManager, ConfigManager.instance(), firstStart);
    pluginInterface.setMainWindow(new MainWindow(window));
    pluginInterface.reloadPlugins();
    final CommandlineOptions options = CommandlineParser.parseCommandLine(args);
    if (options.getBatchPlugin() != null) {
        CBatchPluginExecuter.execute(options.getBatchPlugin(), pluginRegistry);
    }
    window.setVisible(true);
    GuiHelper.applyWindowFix(window);
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) PluginRegistry(com.google.security.zynamics.binnavi.Plugins.PluginRegistry) PluginInterface(com.google.security.zynamics.binnavi.API.plugins.PluginInterface) MainWindow(com.google.security.zynamics.binnavi.API.gui.MainWindow) CDatabaseManager(com.google.security.zynamics.binnavi.Database.CDatabaseManager) CProjectMainFrame(com.google.security.zynamics.binnavi.Gui.MainWindow.CProjectMainFrame) CommandlineOptions(com.google.security.zynamics.binnavi.Startup.CommandlineOptions)

Aggregations

CDatabaseManager (com.google.security.zynamics.binnavi.Database.CDatabaseManager)3 CDatabase (com.google.security.zynamics.binnavi.Database.CDatabase)2 PluginRegistry (com.google.security.zynamics.binnavi.Plugins.PluginRegistry)2 MainWindow (com.google.security.zynamics.binnavi.API.gui.MainWindow)1 PluginInterface (com.google.security.zynamics.binnavi.API.plugins.PluginInterface)1 CProjectMainFrame (com.google.security.zynamics.binnavi.Gui.MainWindow.CProjectMainFrame)1 CommandlineOptions (com.google.security.zynamics.binnavi.Startup.CommandlineOptions)1 DatabaseConfigItem (com.google.security.zynamics.binnavi.config.DatabaseConfigItem)1 FileReadException (com.google.security.zynamics.binnavi.config.FileReadException)1