X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosPreferences.java;h=0e91e4f475d5673bd4a21ef667d5147d7a84ddda;hp=72cfeb4bc5a47e81c63c2ba0582e0de3438b5263;hb=810f9a4f79b0480973d84595140d3f8948ce26d9;hpb=5872bd10df14b47de0e541bff16d9220af0558aa diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 72cfeb4b..0e91e4f4 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -38,6 +38,9 @@ public class AltosPreferences { /* telemetry rate format preference name */ public final static String telemetryRatePreferenceFormat = "RATE-%d"; + /* log file format preference name */ + public final static String logfilePreferenceFormat = "LOGFILE-%d"; + /* voice preference name */ public final static String voicePreference = "VOICE"; @@ -83,6 +86,9 @@ public class AltosPreferences { /* Telemetry rate (map serial to telemetry format) */ public static Hashtable telemetry_rates; + /* Log file (map serial to logfile name) */ + public static Hashtable logfiles; + /* Voice preference */ public static boolean voice; @@ -300,6 +306,27 @@ public class AltosPreferences { } } + public static void set_logfile(int serial, File new_logfile) { + synchronized(backend) { + logfiles.put(serial, new_logfile); + backend.putString(String.format(logfilePreferenceFormat, serial), new_logfile.getPath()); + flush_preferences(); + } + } + + public static File logfile(int serial) { + synchronized(backend) { + if (logfiles.containsKey(serial)) + return logfiles.get(serial); + String logfile_string = backend.getString(String.format(logfilePreferenceFormat, serial), null); + if (logfile_string == null) + return null; + File logfile = new File(logfile_string); + logfiles.put(serial, logfile); + return logfile; + } + } + public static void set_scanning_telemetry(int new_scanning_telemetry) { synchronized (backend) { scanning_telemetry = new_scanning_telemetry;