mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Add method for unpairing to MailboxManager
This commit is contained in:
@@ -131,4 +131,18 @@ class MailboxManagerImpl implements MailboxManager {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unPair() throws DbException {
|
||||
MailboxProperties properties = db.transactionWithNullableResult(true,
|
||||
mailboxSettingsManager::getOwnMailboxProperties);
|
||||
try {
|
||||
api.wipeMailbox(properties);
|
||||
} catch (IOException | MailboxApi.ApiException e) {
|
||||
// We wipe on a best-effort basis.
|
||||
// If we can't do it, we still unpair.
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
db.transaction(false,
|
||||
mailboxSettingsManager::removeOwnMailboxProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,17 @@ class MailboxSettingsManagerImpl implements MailboxSettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOwnMailboxProperties(Transaction txn) throws DbException {
|
||||
Settings s = new Settings();
|
||||
s.put(SETTINGS_KEY_ONION, "");
|
||||
s.put(SETTINGS_KEY_TOKEN, "");
|
||||
settingsManager.mergeSettings(txn, s, SETTINGS_NAMESPACE);
|
||||
for (MailboxHook hook : hooks) {
|
||||
hook.mailboxUnpaired(txn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MailboxStatus getOwnMailboxStatus(Transaction txn)
|
||||
throws DbException {
|
||||
|
||||
Reference in New Issue
Block a user