use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.
the class CDatabaseSortingHandler method drop.
@Override
public void drop(final DNDTree target, final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
final IDatabase draggedDatabase = ((CDatabaseNode) draggedNode).getObject();
final IDatabase parentDatabase = ((CDatabaseNode) parentNode).getObject();
int pnIndex = 0;
for (final IDatabase database : m_manager) {
if (database == parentDatabase) {
break;
}
pnIndex++;
}
m_manager.moveDatabase(draggedDatabase, pnIndex + 1);
}
use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.
the class ConfigManager method saveSettings.
/**
* Stores all relevant settings in the config file object and saves the config file to the disk.
*
* @param parent Parent window used for dialogs.
*/
public void saveSettings(final JFrame parent) {
final Point location = parent.getLocation();
final GeneralSettingsConfigItem.LastOpenWindowConfigItem window = generalSettings.getLastOpenWindow();
window.setTop((int) location.getY());
window.setLeft((int) location.getX());
window.setHeight(parent.getHeight());
window.setWidth(parent.getWidth());
generalSettings.setMaximizeWindow((parent.getExtendedState() == Frame.ICONIFIED) || (parent.getExtendedState() == Frame.MAXIMIZED_BOTH));
databases.clear();
for (final IDatabase database : CDatabaseManager.instance()) {
final DatabaseConfigItem databaseConfig = new DatabaseConfigItem();
databaseConfig.setAutoConnect(database.getConfiguration().isAutoConnect());
databaseConfig.setDescription(database.getConfiguration().getDescription());
databaseConfig.setDriver(database.getConfiguration().getDriver());
databaseConfig.setPassword(database.getConfiguration().isSavePassword() ? database.getConfiguration().getPassword() : "");
databaseConfig.setSavePassword(database.getConfiguration().isSavePassword());
databaseConfig.setHost(database.getConfiguration().getHost());
databaseConfig.setName(database.getConfiguration().getName());
databaseConfig.setUser(database.getConfiguration().getUser());
databaseConfig.setIdentity(database.getConfiguration().getIdentity());
databases.add(databaseConfig);
}
try {
write();
} catch (final FileWriteException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00150: " + "Could not write configuration file";
final String innerDescription = CUtilityFunctions.createDescription("The configuration file where the settings are stored could not be written.", new String[] { "There was a problem writing the file. Please see the stacktrace for more " + "information." }, new String[] { "The active configuration was not saved and will be lost." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
}
}
use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.
the class DatabaseManagerTest method testLifecycle.
@Test
public void testLifecycle() {
final MockDatabaseManagerListener listener = new MockDatabaseManagerListener();
final DatabaseManager manager = new DatabaseManager(CDatabaseManager.instance());
manager.addListener(listener);
manager.addDatabase("Description", "Driver", "Host", "Name", "User", "Password", "identity", true, false);
final IDatabase internalDatabase = CDatabaseManager.instance().iterator().next();
assertEquals("Description", internalDatabase.getConfiguration().getDescription());
assertEquals("Driver", internalDatabase.getConfiguration().getDriver());
assertEquals("User", internalDatabase.getConfiguration().getUser());
assertEquals("Password", internalDatabase.getConfiguration().getPassword());
assertTrue(internalDatabase.getConfiguration().isSavePassword());
assertFalse(internalDatabase.getConfiguration().isAutoConnect());
assertEquals(1, manager.getDatabases().size());
assertEquals("addedDatabase;", listener.events);
assertEquals("Database Manager ['Description']", manager.toString());
final Database database = manager.getDatabases().get(0);
manager.removeDatabase(database);
assertEquals(0, manager.getDatabases().size());
assertEquals("addedDatabase;removedDatabase;", listener.events);
manager.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase in project binnavi by google.
the class CGraphInliner method getFunctionToInline.
/**
* Determines the function to inline with consideration of function forwarding.
*
* @param parent Parent window used for dialogs.
* @param viewContainer Contains the function to inline.
* @param function The function to be inlined.
* @param forwarderModuleId Module ID of the module the function is forwarded to.
* @param forwarderAddress Address of the function the function is forwarded to. This argument can
* be null.
*
* @return The function to be inlined.
*/
private static INaviFunction getFunctionToInline(final JFrame parent, final IViewContainer viewContainer, final INaviFunction function, final int forwarderModuleId, final IAddress forwarderAddress) {
if (forwarderAddress == null) {
return function;
} else {
final IDatabase database = viewContainer.getDatabase();
final INaviModule module = database.getContent().getModule(forwarderModuleId);
if (!viewContainer.containsModule(module)) {
CMessageBox.showInformation(parent, String.format("You are trying to inline an external function into a module view. " + "This is not possible.\n" + "To inline external functions it is necessary to create projects."));
return null;
}
if (!module.isLoaded()) {
try {
module.load();
} catch (final CouldntLoadDataException | LoadCancelledException e) {
CUtilityFunctions.logException(e);
return null;
}
}
return module.getContent().getFunctionContainer().getFunction(forwarderAddress);
}
}
Aggregations