use of org.openintents.openpgp.util.OpenPgpServiceConnection.OnBound in project k-9 by k9mail.
the class OpenPgpApiManager method setupCryptoProvider.
private void setupCryptoProvider() {
if (TextUtils.isEmpty(openPgpProvider)) {
setOpenPgpProviderState(OpenPgpProviderState.UNCONFIGURED);
return;
}
boolean providerIsBound = openPgpServiceConnection != null && openPgpServiceConnection.isBound();
if (providerIsBound) {
refreshConnection();
return;
}
if (openPgpServiceConnection != null) {
// We'll just wait for OnBound.onBound() to be called.
return;
}
setOpenPgpProviderState(OpenPgpProviderState.UNINITIALIZED);
openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProvider, new OnBound() {
@Override
public void onBound(IOpenPgpService2 service) {
openPgpApi = new OpenPgpApi(context, service);
refreshConnection();
}
@Override
public void onError(Exception e) {
Timber.e(e, "error connecting to crypto provider!");
setOpenPgpProviderState(OpenPgpProviderState.ERROR);
callbackOpenPgpProviderError(OpenPgpProviderError.ConnectionFailed);
}
});
refreshConnection();
}
use of org.openintents.openpgp.util.OpenPgpServiceConnection.OnBound in project k-9 by k9mail.
the class RecipientPresenter method setupCryptoProvider.
private void setupCryptoProvider() {
String openPgpProvider = K9.getOpenPgpProvider();
if (TextUtils.isEmpty(openPgpProvider)) {
openPgpProvider = null;
}
boolean providerIsBound = openPgpServiceConnection != null && openPgpServiceConnection.isBound();
boolean isSameProvider = openPgpProvider != null && openPgpProvider.equals(this.openPgpProvider);
if (isSameProvider && providerIsBound) {
cryptoProviderBindOrCheckPermission();
return;
}
if (providerIsBound) {
openPgpServiceConnection.unbindFromService();
openPgpServiceConnection = null;
}
this.openPgpProvider = openPgpProvider;
if (openPgpProvider == null) {
cryptoProviderState = CryptoProviderState.UNCONFIGURED;
return;
}
cryptoProviderState = CryptoProviderState.UNINITIALIZED;
openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProvider, new OnBound() {
@Override
public void onBound(IOpenPgpService2 service) {
cryptoProviderBindOrCheckPermission();
}
@Override
public void onError(Exception e) {
onCryptoProviderError(e);
}
});
cryptoProviderBindOrCheckPermission();
recipientMvpView.setCryptoProvider(openPgpProvider);
}
use of org.openintents.openpgp.util.OpenPgpServiceConnection.OnBound in project k-9 by k9mail.
the class MessageCryptoHelper method connectToCryptoProviderService.
private void connectToCryptoProviderService() {
openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProvider, new OnBound() {
@Override
public void onBound(IOpenPgpService2 service) {
openPgpApi = openPgpApiFactory.createOpenPgpApi(context, service);
nextStep();
}
@Override
public void onError(Exception e) {
// TODO actually handle (hand to ui, offer retry?)
Timber.e(e, "Couldn't connect to OpenPgpService");
}
});
openPgpServiceConnection.bindToService();
}
Aggregations