Update API
This commit is contained in:
parent
60bb85f93a
commit
7f0f820262
@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.tdlight</groupId>
|
<groupId>it.tdlight</groupId>
|
||||||
<artifactId>tdlight-java-bom</artifactId>
|
<artifactId>tdlight-java-bom</artifactId>
|
||||||
<version>2.8.5.3</version>
|
<version>2.8.5.5</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
package it.tdlight.client;
|
|
||||||
|
|
||||||
import it.tdlight.common.ExceptionHandler;
|
|
||||||
import it.tdlight.common.TelegramClient;
|
|
||||||
import it.tdlight.jni.TdApi;
|
|
||||||
import it.tdlight.jni.TdApi.AuthorizationStateWaitEncryptionKey;
|
|
||||||
import it.tdlight.jni.TdApi.CheckDatabaseEncryptionKey;
|
|
||||||
import it.tdlight.jni.TdApi.UpdateAuthorizationState;
|
|
||||||
|
|
||||||
final class AuthorizationStateWaitEncryptionKeyHandler implements GenericUpdateHandler<UpdateAuthorizationState> {
|
|
||||||
|
|
||||||
private final TelegramClient client;
|
|
||||||
private final ExceptionHandler exceptionHandler;
|
|
||||||
|
|
||||||
public AuthorizationStateWaitEncryptionKeyHandler(TelegramClient client, ExceptionHandler exceptionHandler) {
|
|
||||||
this.client = client;
|
|
||||||
this.exceptionHandler = exceptionHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(UpdateAuthorizationState update) {
|
|
||||||
if (update.authorizationState.getConstructor() == AuthorizationStateWaitEncryptionKey.CONSTRUCTOR) {
|
|
||||||
client.send(new CheckDatabaseEncryptionKey(), ok -> {
|
|
||||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
|
||||||
throw new TelegramError((TdApi.Error) ok);
|
|
||||||
}
|
|
||||||
}, exceptionHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ import it.tdlight.common.TelegramClient;
|
|||||||
import it.tdlight.jni.TdApi;
|
import it.tdlight.jni.TdApi;
|
||||||
import it.tdlight.jni.TdApi.AuthorizationStateWaitTdlibParameters;
|
import it.tdlight.jni.TdApi.AuthorizationStateWaitTdlibParameters;
|
||||||
import it.tdlight.jni.TdApi.SetTdlibParameters;
|
import it.tdlight.jni.TdApi.SetTdlibParameters;
|
||||||
import it.tdlight.jni.TdApi.TdlibParameters;
|
|
||||||
import it.tdlight.jni.TdApi.UpdateAuthorizationState;
|
import it.tdlight.jni.TdApi.UpdateAuthorizationState;
|
||||||
|
|
||||||
final class AuthorizationStateWaitTdlibParametersHandler implements GenericUpdateHandler<UpdateAuthorizationState> {
|
final class AuthorizationStateWaitTdlibParametersHandler implements GenericUpdateHandler<UpdateAuthorizationState> {
|
||||||
@ -25,7 +24,7 @@ final class AuthorizationStateWaitTdlibParametersHandler implements GenericUpdat
|
|||||||
@Override
|
@Override
|
||||||
public void onUpdate(UpdateAuthorizationState update) {
|
public void onUpdate(UpdateAuthorizationState update) {
|
||||||
if (update.authorizationState.getConstructor() == AuthorizationStateWaitTdlibParameters.CONSTRUCTOR) {
|
if (update.authorizationState.getConstructor() == AuthorizationStateWaitTdlibParameters.CONSTRUCTOR) {
|
||||||
TdlibParameters params = new TdlibParameters();
|
TdApi.SetTdlibParameters params = new TdApi.SetTdlibParameters();
|
||||||
params.useTestDc = settings.isUsingTestDatacenter();
|
params.useTestDc = settings.isUsingTestDatacenter();
|
||||||
params.databaseDirectory = settings.getDatabaseDirectoryPath().toString();
|
params.databaseDirectory = settings.getDatabaseDirectoryPath().toString();
|
||||||
params.filesDirectory = settings.getDownloadedFilesDirectoryPath().toString();
|
params.filesDirectory = settings.getDownloadedFilesDirectoryPath().toString();
|
||||||
@ -41,7 +40,8 @@ final class AuthorizationStateWaitTdlibParametersHandler implements GenericUpdat
|
|||||||
params.applicationVersion = settings.getApplicationVersion();
|
params.applicationVersion = settings.getApplicationVersion();
|
||||||
params.enableStorageOptimizer = settings.isStorageOptimizerEnabled();
|
params.enableStorageOptimizer = settings.isStorageOptimizerEnabled();
|
||||||
params.ignoreFileNames = settings.isIgnoreFileNames();
|
params.ignoreFileNames = settings.isIgnoreFileNames();
|
||||||
client.send(new SetTdlibParameters(params), ok -> {
|
params.databaseEncryptionKey = null;
|
||||||
|
client.send(params, ok -> {
|
||||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||||
throw new TelegramError((TdApi.Error) ok);
|
throw new TelegramError((TdApi.Error) ok);
|
||||||
}
|
}
|
||||||
|
@ -70,9 +70,6 @@ public final class SimpleTelegramClient implements Authenticable {
|
|||||||
this.addUpdateHandler(TdApi.UpdateAuthorizationState.class,
|
this.addUpdateHandler(TdApi.UpdateAuthorizationState.class,
|
||||||
new AuthorizationStateWaitTdlibParametersHandler(client, settings, this::handleDefaultException)
|
new AuthorizationStateWaitTdlibParametersHandler(client, settings, this::handleDefaultException)
|
||||||
);
|
);
|
||||||
this.addUpdateHandler(TdApi.UpdateAuthorizationState.class,
|
|
||||||
new AuthorizationStateWaitEncryptionKeyHandler(client, this::handleDefaultException)
|
|
||||||
);
|
|
||||||
this.addUpdateHandler(TdApi.UpdateAuthorizationState.class,
|
this.addUpdateHandler(TdApi.UpdateAuthorizationState.class,
|
||||||
new AuthorizationStateWaitAuthenticationDataHandler(client, this, this::handleDefaultException)
|
new AuthorizationStateWaitAuthenticationDataHandler(client, this, this::handleDefaultException)
|
||||||
);
|
);
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.reactivestreams</groupId>
|
<groupId>org.reactivestreams</groupId>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user