Search in sources :

Example 6 with IDatabaseListener

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

the class CDatabaseConfiguration method setUser.

/**
 * Changes the user name that is used to connect to the database.
 *
 * @param user The new user name.
 *
 * @throws IllegalArgumentException Thrown if the given user name is invalid.
 */
public void setUser(final String user) {
    Preconditions.checkNotNull(user, "IE00692: Database user can not be null");
    if (user.equals(getUser())) {
        return;
    }
    m_user = user;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedUser(m_database, user);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Example 7 with IDatabaseListener

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

the class CDatabaseContent method delete.

@Override
public void delete(final INaviModule module) throws CouldntDeleteException {
    Preconditions.checkNotNull(module, "IE00670: Module can not be null");
    Preconditions.checkArgument(m_database.isConnected(), "IE00671: Database must be connected before you can delete modules");
    Preconditions.checkArgument(m_database.isLoaded(), "IE00672: Database must be loaded before you can delete modules");
    Preconditions.checkArgument(m_modules.contains(module), "IE00673: Module does not belong to this database");
    m_provider.deleteModule(module);
    m_modules.remove(module);
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.deletedModule(m_database, module);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    removeDeletedModuleFromNamespaces(module);
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Example 8 with IDatabaseListener

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

the class CDatabaseContent method refreshRawModules.

@Override
public void refreshRawModules() throws CouldntLoadDataException {
    Preconditions.checkArgument(m_database.isConnected(), "IE00687: Not connected to the database");
    Preconditions.checkArgument(m_database.isLoaded(), "IE00688: Raw modules were not loaded previously");
    final List<INaviRawModule> oldModules = m_rawModules;
    final List<INaviRawModule> refreshedModules = m_provider.loadRawModules();
    m_rawModules.clear();
    m_rawModules.addAll(refreshedModules);
    final List<INaviModule> newModules = initializeRawModules(m_modules, refreshedModules);
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedRawModules(m_database, oldModules, refreshedModules);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    for (final INaviModule naviModule : newModules) {
        for (final IDatabaseListener listener : m_listeners) {
            try {
                listener.addedModule(m_database, naviModule);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
    }
}
Also used : INaviRawModule(com.google.security.zynamics.binnavi.disassembly.INaviRawModule) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Example 9 with IDatabaseListener

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

the class CDatabaseConfiguration method setName.

/**
 * Changes the database name.
 *
 * @param name The new database name.
 */
public void setName(final String name) {
    Preconditions.checkNotNull(name, "IE00159: Database name can not be null");
    if (name.equals(m_name)) {
        return;
    }
    m_name = name;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedName(m_database, name);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Example 10 with IDatabaseListener

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

the class CDatabaseConfiguration method setHost.

/**
 * Changes the database host.
 *
 * @param host The new host value.
 */
public void setHost(final String host) {
    Preconditions.checkNotNull(host, "IE00040: Database host can not be null");
    if (host.equals(m_host)) {
        return;
    }
    m_host = host;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedHost(m_database, host);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Aggregations

IDatabaseListener (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)15 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)8 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)5 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)3 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)3 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)3 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)3 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)3 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)3 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)3 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)3 SQLException (java.sql.SQLException)3 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)2 INaviRawModule (com.google.security.zynamics.binnavi.disassembly.INaviRawModule)2 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)1 PostgreSQLNotificationProvider (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.PostgreSQLNotificationProvider)1 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)1 DebuggerTemplateManager (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager)1