Refactor internal classes

This commit is contained in:
Andrea Cavalli 2021-04-07 19:48:10 +02:00
parent bf35a740d0
commit 69e8e744cf
21 changed files with 83 additions and 32 deletions

View File

@ -1,6 +1,6 @@
package it.tdlight.common;
import it.tdlight.jni.NativeLog;
import it.tdlight.tdnative.NativeLog;
import it.tdlight.jni.TdApi;
import java.util.function.Consumer;

View File

@ -1,4 +1,7 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.ReactiveTelegramClient;
import it.tdlight.common.TelegramClient;
public abstract class CommonClientManager {

View File

@ -1,4 +1,7 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.ExceptionHandler;
import it.tdlight.common.ResultHandler;
public class Handler {
private final ResultHandler resultHandler;

View File

@ -1,5 +1,10 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.ClientEventsHandler;
import it.tdlight.common.ExceptionHandler;
import it.tdlight.common.ResultHandler;
import it.tdlight.common.TelegramClient;
import it.tdlight.common.UpdatesHandler;
import it.tdlight.jni.TdApi;
import it.tdlight.jni.TdApi.Error;
import it.tdlight.jni.TdApi.Function;

View File

@ -1,5 +1,7 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.ClientEventsHandler;
import it.tdlight.common.Init;
import it.tdlight.jni.TdApi;
import it.tdlight.jni.TdApi.Object;
import java.util.ArrayList;

View File

@ -1,5 +1,9 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.ClientEventsHandler;
import it.tdlight.common.ExceptionHandler;
import it.tdlight.common.ReactiveItem;
import it.tdlight.common.ReactiveTelegramClient;
import it.tdlight.jni.TdApi;
import it.tdlight.jni.TdApi.Error;
import it.tdlight.jni.TdApi.Function;

View File

@ -1,4 +1,7 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.ExceptionHandler;
import it.tdlight.common.UpdatesHandler;
public class MultiHandler {
private final UpdatesHandler updatesHandler;

View File

@ -1,6 +1,6 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.jni.NativeClient;
import it.tdlight.tdnative.NativeClient;
import it.tdlight.jni.TdApi;
import it.tdlight.jni.TdApi.Function;

View File

@ -1,5 +1,6 @@
package it.tdlight.common;
package it.tdlight.common.internal;
import it.tdlight.common.EventsHandler;
import it.tdlight.common.utils.IntSwapper;
import it.tdlight.jni.TdApi;
import it.tdlight.jni.TdApi.Object;

View File

@ -25,7 +25,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.ConcurrentHashMap;
import java.lang.reflect.InvocationTargetException;
import it.tdlight.jni.ObjectsUtils;
import it.tdlight.tdnative.ObjectsUtils;
/**
* The class to load the libraries needed to run Tdlib

View File

@ -1,12 +0,0 @@
package it.tdlight.jni;
public class NativeClient {
protected static native int createNativeClient();
protected static native void nativeClientSend(int nativeClientId, long eventId, TdApi.Function function);
protected static native int nativeClientReceive(int[] clientIds, long[] eventIds, TdApi.Object[] events, double timeout);
protected static native TdApi.Object nativeClientExecute(TdApi.Function function);
}

View File

@ -1,6 +1,6 @@
package it.tdlight.tdlib;
import it.tdlight.common.CommonClientManager;
import it.tdlight.common.internal.CommonClientManager;
import it.tdlight.common.ReactiveTelegramClient;
import it.tdlight.common.TelegramClient;

View File

@ -0,0 +1,7 @@
package it.tdlight.tdlib;
/**
* This class is used to avoid jigsaw errors about empty exports
*/
@Deprecated
public class DummyClass {}

View File

@ -1,6 +1,6 @@
package it.tdlight.tdlight;
import it.tdlight.common.CommonClientManager;
import it.tdlight.common.internal.CommonClientManager;
import it.tdlight.common.ReactiveTelegramClient;
import it.tdlight.common.TelegramClient;

View File

@ -0,0 +1,7 @@
package it.tdlight.tdlight;
/**
* This class is used to avoid jigsaw errors about empty exports
*/
@Deprecated
public class DummyClass {}

View File

@ -0,0 +1,15 @@
package it.tdlight.tdnative;
import it.tdlight.jni.TdApi.Function;
import it.tdlight.jni.TdApi.Object;
public class NativeClient {
protected static native int createNativeClient();
protected static native void nativeClientSend(int nativeClientId, long eventId, Function function);
protected static native int nativeClientReceive(int[] clientIds, long[] eventIds, Object[] events, double timeout);
protected static native Object nativeClientExecute(Function function);
}

View File

@ -1,5 +1,7 @@
package it.tdlight.jni;
package it.tdlight.tdnative;
import it.tdlight.jni.TdApi.SetLogStream;
import it.tdlight.jni.TdApi.SetLogVerbosityLevel;
import java.util.function.Consumer;
/**
@ -15,7 +17,7 @@ public class NativeLog {
* Sets file path for writing TDLib internal log. By default TDLib writes logs to the System.err.
* Use this method to write the log to a file instead.
*
* @deprecated As of TDLib 1.4.0 in favor of {@link TdApi.SetLogStream}, to be removed in the future.
* @deprecated As of TDLib 1.4.0 in favor of {@link SetLogStream}, to be removed in the future.
* @param filePath Path to a file for writing TDLib internal log. Use an empty path to
* switch back to logging to the System.err.
* @return whether opening the log file succeeded.
@ -26,7 +28,7 @@ public class NativeLog {
/**
* Changes the maximum size of TDLib log file.
*
* @deprecated As of TDLib 1.4.0 in favor of {@link TdApi.SetLogStream}, to be removed in the future.
* @deprecated As of TDLib 1.4.0 in favor of {@link SetLogStream}, to be removed in the future.
* @param maxFileSize The maximum size of the file to where the internal TDLib log is written
* before the file will be auto-rotated. Must be positive. Defaults to 10 MB.
*/
@ -36,7 +38,7 @@ public class NativeLog {
/**
* Changes TDLib log verbosity.
*
* @deprecated As of TDLib 1.4.0 in favor of {@link TdApi.SetLogVerbosityLevel}, to be removed in the future.
* @deprecated As of TDLib 1.4.0 in favor of {@link SetLogVerbosityLevel}, to be removed in the future.
* @param verbosityLevel New value of log verbosity level. Must be non-negative.
* Value 0 corresponds to fatal errors,
* value 1 corresponds to java.util.logging.Level.SEVERE,

View File

@ -1,4 +1,4 @@
package it.tdlight.jni;
package it.tdlight.tdnative;
public class ObjectsUtils {
/**

View File

@ -0,0 +1,11 @@
module tdlight.java {
requires tdlight.api;
requires org.reactivestreams;
requires it.unimi.dsi.fastutil;
requires org.slf4j;
exports it.tdlight.tdlight;
exports it.tdlight.tdlib;
exports it.tdlight.common;
exports it.tdlight.common.utils;
exports it.tdlight.common.internal;
}

View File

@ -169,7 +169,7 @@
<release>11</release>
<useIncrementalCompilation>false</useIncrementalCompilation>
<excludes>
<exclude>it/tdlight/tdlight/**</exclude>
<exclude>it/tdlight/tdlight/ClientManager.java</exclude>
</excludes>
</configuration>
</plugin>

View File

@ -169,7 +169,7 @@
<release>11</release>
<useIncrementalCompilation>false</useIncrementalCompilation>
<excludes>
<exclude>it/tdlight/tdlib/**</exclude>
<exclude>it/tdlight/tdlib/ClientManager.java</exclude>
</excludes>
</configuration>
</plugin>