1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-22 16:56:16 +00:00

Added switch to output some encoding values.

This commit is contained in:
Fabian Schlenz 2016-09-18 11:33:27 +02:00
parent fa864f37b7
commit ef89185439
5 changed files with 25 additions and 0 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ data/
.idea .idea
src/main/main.iml src/main/main.iml
cache4.* cache4.*
src/test/test.iml

View File

@ -131,6 +131,8 @@ public class CommandLineController {
if (CommandLineOptions.val_test != null) { if (CommandLineOptions.val_test != null) {
if (CommandLineOptions.val_test == 1) { if (CommandLineOptions.val_test == 1) {
TestFeatures.test1(); TestFeatures.test1();
} else if (CommandLineOptions.val_test == 2) {
TestFeatures.test2(user, client);
} else { } else {
System.out.println("Unknown test " + CommandLineOptions.val_test); System.out.println("Unknown test " + CommandLineOptions.val_test);
} }

View File

@ -498,6 +498,17 @@ public class Database {
return result; return result;
} catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); }
} }
public String getEncoding() {
try {
ResultSet rs = stmt.executeQuery("PRAGMA encoding");
rs.next();
return rs.getString(1);
} catch (SQLException e) {
logger.debug("SQLException: {}", e);
return "unknown";
}
}
public LinkedList<Chat> getListOfChatsForExport() { public LinkedList<Chat> getListOfChatsForExport() {

View File

@ -1,12 +1,14 @@
package de.fabianonline.telegram_backup; package de.fabianonline.telegram_backup;
import com.github.badoualy.telegram.tl.api.*; import com.github.badoualy.telegram.tl.api.*;
import com.github.badoualy.telegram.api.TelegramClient;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.Statement; import java.sql.Statement;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset;
class TestFeatures { class TestFeatures {
public static void test1() { public static void test1() {
@ -51,4 +53,12 @@ class TestFeatures {
System.out.println("Success: " + success); System.out.println("Success: " + success);
System.out.println("Unsupported constructor: " + unsupported_constructor); System.out.println("Unsupported constructor: " + unsupported_constructor);
} }
public static void test2(UserManager user, TelegramClient client) {
// Prints system.encoding and default charset
System.out.println("Default Charset: " + Charset.defaultCharset());
System.out.println("file.encoding: " + System.getProperty("file.encoding"));
Database db = new Database(user, client, false);
System.out.println("Database encoding: " + db.getEncoding());
}
} }

View File

@ -12,5 +12,6 @@ public class CompareVersionsTest {
assertEquals(Utils.compareVersions("1.0.4", "1.0.4"), Utils.VERSIONS_EQUAL); assertEquals(Utils.compareVersions("1.0.4", "1.0.4"), Utils.VERSIONS_EQUAL);
assertEquals(Utils.compareVersions("1.0.4-pre.2", "1.0.4-pre.1"), Utils.VERSIONS_EQUAL); assertEquals(Utils.compareVersions("1.0.4-pre.2", "1.0.4-pre.1"), Utils.VERSIONS_EQUAL);
assertEquals(Utils.compareVersions("1.0.4", "1.0.4-abcdef-dirty"), Utils.VERSION_2_NEWER); assertEquals(Utils.compareVersions("1.0.4", "1.0.4-abcdef-dirty"), Utils.VERSION_2_NEWER);
assertEquals(Utils.compareVersions("1.0.5", "1.0.5-test.1"), Utils.VERSION_2_NEWER);
} }
} }