|
@@ -48,7 +48,6 @@ import java.security.UnrecoverableKeyException;
|
|
import java.security.cert.CertificateException;
|
|
import java.security.cert.CertificateException;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
-import javax.inject.Singleton;
|
|
|
|
import javax.net.ssl.KeyManagerFactory;
|
|
import javax.net.ssl.KeyManagerFactory;
|
|
import javax.net.ssl.X509KeyManager;
|
|
import javax.net.ssl.X509KeyManager;
|
|
|
|
|
|
@@ -76,13 +75,11 @@ public class RestModule {
|
|
private static final String TAG = "RestModule";
|
|
private static final String TAG = "RestModule";
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
NcApi provideNcApi(Retrofit retrofit) {
|
|
NcApi provideNcApi(Retrofit retrofit) {
|
|
return retrofit.create(NcApi.class);
|
|
return retrofit.create(NcApi.class);
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
Proxy provideProxy(AppPreferences appPreferences) {
|
|
Proxy provideProxy(AppPreferences appPreferences) {
|
|
if (!TextUtils.isEmpty(appPreferences.getProxyType()) && !"No proxy".equals(appPreferences.getProxyType())
|
|
if (!TextUtils.isEmpty(appPreferences.getProxyType()) && !"No proxy".equals(appPreferences.getProxyType())
|
|
&& !TextUtils.isEmpty(appPreferences.getProxyHost())) {
|
|
&& !TextUtils.isEmpty(appPreferences.getProxyHost())) {
|
|
@@ -102,7 +99,6 @@ public class RestModule {
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
Retrofit provideRetrofit(OkHttpClient httpClient) {
|
|
Retrofit provideRetrofit(OkHttpClient httpClient) {
|
|
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
|
|
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
|
|
.client(httpClient)
|
|
.client(httpClient)
|
|
@@ -114,13 +110,11 @@ public class RestModule {
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
MagicTrustManager provideMagicTrustManager() {
|
|
MagicTrustManager provideMagicTrustManager() {
|
|
return new MagicTrustManager();
|
|
return new MagicTrustManager();
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
MagicKeyManager provideKeyManager(AppPreferences appPreferences, UserUtils userUtils) {
|
|
MagicKeyManager provideKeyManager(AppPreferences appPreferences, UserUtils userUtils) {
|
|
KeyStore keyStore = null;
|
|
KeyStore keyStore = null;
|
|
try {
|
|
try {
|
|
@@ -146,27 +140,23 @@ public class RestModule {
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
SSLSocketFactoryCompat provideSslSocketFactoryCompat(MagicKeyManager keyManager, MagicTrustManager
|
|
SSLSocketFactoryCompat provideSslSocketFactoryCompat(MagicKeyManager keyManager, MagicTrustManager
|
|
magicTrustManager) {
|
|
magicTrustManager) {
|
|
return new SSLSocketFactoryCompat(keyManager, magicTrustManager);
|
|
return new SSLSocketFactoryCompat(keyManager, magicTrustManager);
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
CookieManager provideCookieManager() {
|
|
CookieManager provideCookieManager() {
|
|
return new CookieManager();
|
|
return new CookieManager();
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
Cache provideCache() {
|
|
Cache provideCache() {
|
|
int cacheSize = 128 * 1024 * 1024; // 128 MB
|
|
int cacheSize = 128 * 1024 * 1024; // 128 MB
|
|
return new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(), cacheSize);
|
|
return new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(), cacheSize);
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
Dispatcher provideDispatcher() {
|
|
Dispatcher provideDispatcher() {
|
|
Dispatcher dispatcher = new Dispatcher();
|
|
Dispatcher dispatcher = new Dispatcher();
|
|
dispatcher.setMaxRequestsPerHost(100);
|
|
dispatcher.setMaxRequestsPerHost(100);
|
|
@@ -175,7 +165,6 @@ public class RestModule {
|
|
}
|
|
}
|
|
|
|
|
|
@Provides
|
|
@Provides
|
|
- @Singleton
|
|
|
|
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences,
|
|
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences,
|
|
MagicTrustManager magicTrustManager,
|
|
MagicTrustManager magicTrustManager,
|
|
SSLSocketFactoryCompat sslSocketFactoryCompat, Cache cache,
|
|
SSLSocketFactoryCompat sslSocketFactoryCompat, Cache cache,
|