Fix compilation issues
This commit is contained in:
parent
94e7a682bd
commit
708cff9e05
@ -5,6 +5,7 @@ import it.tdlight.jni.TdApi.AuthorizationStateReady;
|
||||
import it.tdlight.jni.TdApi.GetMe;
|
||||
import it.tdlight.jni.TdApi.UpdateAuthorizationState;
|
||||
import it.tdlight.jni.TdApi.User;
|
||||
import it.tdlight.jni.TdApi.Error;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -36,15 +36,15 @@ final class AuthorizationStateWaitAuthenticationDataHandler implements GenericUp
|
||||
String botToken = authenticationData.getBotToken();
|
||||
TdApi.CheckAuthenticationBotToken response = new TdApi.CheckAuthenticationBotToken(botToken);
|
||||
client.send(response, ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
} else if (authenticationData.isQrCode()) {
|
||||
TdApi.RequestQrCodeAuthentication response = new TdApi.RequestQrCodeAuthentication();
|
||||
client.send(response, ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
} else {
|
||||
@ -53,8 +53,8 @@ final class AuthorizationStateWaitAuthenticationDataHandler implements GenericUp
|
||||
String phoneNumber = String.valueOf(authenticationData.getUserPhoneNumber());
|
||||
SetAuthenticationPhoneNumber response = new SetAuthenticationPhoneNumber(phoneNumber, phoneSettings);
|
||||
client.send(response, ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package it.tdlight.client;
|
||||
|
||||
import it.tdlight.common.ExceptionHandler;
|
||||
import it.tdlight.common.TelegramClient;
|
||||
import it.tdlight.jni.TdApi;
|
||||
import it.tdlight.jni.TdApi.AuthorizationStateWaitCode;
|
||||
import it.tdlight.jni.TdApi.CheckAuthenticationCode;
|
||||
import it.tdlight.jni.TdApi.UpdateAuthorizationState;
|
||||
@ -32,8 +33,8 @@ final class AuthorizationStateWaitCodeHandler implements GenericUpdateHandler<Up
|
||||
String code = clientInteraction.onParameterRequest(InputParameter.ASK_CODE, parameterInfo);
|
||||
CheckAuthenticationCode response = new CheckAuthenticationCode(code);
|
||||
client.send(response, ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -20,8 +21,8 @@ final class AuthorizationStateWaitEncryptionKeyHandler implements GenericUpdateH
|
||||
public void onUpdate(UpdateAuthorizationState update) {
|
||||
if (update.authorizationState.getConstructor() == AuthorizationStateWaitEncryptionKey.CONSTRUCTOR) {
|
||||
client.send(new CheckDatabaseEncryptionKey(), ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package it.tdlight.client;
|
||||
|
||||
import it.tdlight.common.ExceptionHandler;
|
||||
import it.tdlight.common.TelegramClient;
|
||||
import it.tdlight.jni.TdApi;
|
||||
import it.tdlight.jni.TdApi.AuthorizationStateWaitPassword;
|
||||
import it.tdlight.jni.TdApi.CheckAuthenticationPassword;
|
||||
import it.tdlight.jni.TdApi.UpdateAuthorizationState;
|
||||
@ -31,8 +32,8 @@ final class AuthorizationStateWaitPasswordHandler implements GenericUpdateHandle
|
||||
String password = clientInteraction.onParameterRequest(InputParameter.ASK_PASSWORD, parameterInfo);
|
||||
CheckAuthenticationPassword response = new CheckAuthenticationPassword(password);
|
||||
client.send(response, ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ final class AuthorizationStateWaitRegistrationHandler implements GenericUpdateHa
|
||||
}
|
||||
RegisterUser response = new RegisterUser(firstName, lastName);
|
||||
client.send(response, ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package it.tdlight.client;
|
||||
|
||||
import it.tdlight.common.ExceptionHandler;
|
||||
import it.tdlight.common.TelegramClient;
|
||||
import it.tdlight.jni.TdApi;
|
||||
import it.tdlight.jni.TdApi.AuthorizationStateWaitTdlibParameters;
|
||||
import it.tdlight.jni.TdApi.SetTdlibParameters;
|
||||
import it.tdlight.jni.TdApi.TdlibParameters;
|
||||
@ -41,8 +42,8 @@ final class AuthorizationStateWaitTdlibParametersHandler implements GenericUpdat
|
||||
params.enableStorageOptimizer = settings.isStorageOptimizerEnabled();
|
||||
params.ignoreFileNames = settings.isIgnoreFileNames();
|
||||
client.send(new SetTdlibParameters(params), ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
}, exceptionHandler);
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ final class CommandsHandler implements GenericUpdateHandler<UpdateNewMessage> {
|
||||
|
||||
for (CommandHandler handler : handlers) {
|
||||
client.send(new TdApi.GetChat(message.chatId), response -> {
|
||||
if (response.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) response);
|
||||
if (response.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) response);
|
||||
}
|
||||
handler.onCommand((Chat) response, message.sender, arguments);
|
||||
}, error -> logger.warn("Error when handling the command {}", commandName, error));
|
||||
|
@ -238,8 +238,8 @@ public final class SimpleTelegramClient implements Authenticable {
|
||||
*/
|
||||
public void sendClose() {
|
||||
client.send(new TdApi.Close(), ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -249,8 +249,8 @@ public final class SimpleTelegramClient implements Authenticable {
|
||||
*/
|
||||
public void closeAndWait() throws InterruptedException {
|
||||
client.send(new TdApi.Close(), ok -> {
|
||||
if (ok.getConstructor() == Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((Error) ok);
|
||||
if (ok.getConstructor() == TdApi.Error.CONSTRUCTOR) {
|
||||
throw new TelegramError((TdApi.Error) ok);
|
||||
}
|
||||
});
|
||||
this.waitForExit();
|
||||
|
@ -1,8 +1,10 @@
|
||||
package it.tdlight.common;
|
||||
|
||||
import it.tdlight.jni.TdApi;
|
||||
|
||||
public interface ClientEventsHandler {
|
||||
|
||||
int getClientId();
|
||||
|
||||
void handleEvents(boolean isClosed, long[] eventIds, Object[] events, int arrayOffset, int arrayLength);
|
||||
void handleEvents(boolean isClosed, long[] eventIds, TdApi.Object[] events, int arrayOffset, int arrayLength);
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package it.tdlight.common;
|
||||
|
||||
import it.tdlight.jni.TdApi;
|
||||
|
||||
public interface EventsHandler {
|
||||
|
||||
void handleClientEvents(int clientId,
|
||||
boolean isClosed,
|
||||
long[] clientEventIds,
|
||||
Object[] clientEvents,
|
||||
TdApi.Object[] clientEvents,
|
||||
int arrayOffset,
|
||||
int arrayLength);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package it.tdlight.common;
|
||||
|
||||
import it.tdlight.jni.TdApi;
|
||||
import it.tdlight.jni.TdApi.Object;
|
||||
|
||||
public interface TelegramClient {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package it.tdlight.common;
|
||||
|
||||
import it.tdlight.jni.TdApi;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -13,5 +14,5 @@ public interface UpdatesHandler {
|
||||
* @param object Updates of type {@link it.tdlight.jni.TdApi.Update} about new events, or {@link
|
||||
* it.tdlight.jni.TdApi.Error}.
|
||||
*/
|
||||
void onUpdates(List<Object> object);
|
||||
void onUpdates(List<TdApi.Object> object);
|
||||
}
|
@ -88,7 +88,8 @@ public final class InternalClient implements ClientEventsHandler, TelegramClient
|
||||
} catch (IllegalStateException ignored) {
|
||||
logger.trace(TG_MARKER, "Can't remove shutdown hook because the JVM is already shutting down");
|
||||
}
|
||||
handlers.forEach((eventId, handler) -> handleResponse(eventId, new Error(500, "Instance closed"), handler));
|
||||
handlers.forEach((eventId, handler) ->
|
||||
handleResponse(eventId, new TdApi.Error(500, "Instance closed"), handler));
|
||||
handlers.clear();
|
||||
logger.info(TG_MARKER, "Client closed {}", clientId);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user