Changeset 1956068 for apps/addressbook


Ignore:
Timestamp:
Feb 8, 2014 4:02:50 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
72e96cd
Parents:
855cae0
Message:
  • Addressbook:
    • Rewrite subscriptions.txt to convert to new default URL
    • Static method call cleanups
Location:
apps/addressbook/java/src/net/i2p/addressbook
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/java/src/net/i2p/addressbook/ConfigParser.java

    r855cae0 r1956068  
    9292        inputLine = input.readLine();
    9393        while (inputLine != null) {
    94             inputLine = ConfigParser.stripComments(inputLine);
     94            inputLine = stripComments(inputLine);
    9595            String[] splitLine = inputLine.split("=");
    9696            if (splitLine.length == 2) {
     
    117117        BufferedReader input = new BufferedReader(new InputStreamReader(
    118118                fileStream));
    119         Map<String, String>  rv = ConfigParser.parse(input);
     119        Map<String, String>  rv = parse(input);
    120120        try {
    121121            fileStream.close();
     
    137137        StringReader stringReader = new StringReader(string);
    138138        BufferedReader input = new BufferedReader(stringReader);
    139         return ConfigParser.parse(input);
     139        return parse(input);
    140140    }
    141141   
     
    154154        Map<String, String>  result;
    155155        try {
    156             result = ConfigParser.parse(file);
     156            result = parse(file);
    157157            for (Map.Entry<String, String> entry : map.entrySet()) {
    158158                if (!result.containsKey(entry.getKey()))
     
    162162            result = map;
    163163            try {
    164                 ConfigParser.write(result, file);
     164                write(result, file);
    165165            } catch (IOException exp2) {
    166166            }
     
    183183        String inputLine = input.readLine();
    184184        while (inputLine != null) {
    185             inputLine = ConfigParser.stripComments(inputLine).trim();
     185            inputLine = stripComments(inputLine).trim();
    186186            if (inputLine.length() > 0) {
    187187                result.add(inputLine);
     
    206206        BufferedReader input = new BufferedReader(new InputStreamReader(
    207207                fileStream));
    208         List<String> rv = ConfigParser.parseSubscriptions(input);
     208        List<String> rv = parseSubscriptions(input);
    209209        try {
    210210            fileStream.close();
     
    225225        StringReader stringReader = new StringReader(string);
    226226        BufferedReader input = new BufferedReader(stringReader);
    227         return ConfigParser.parseSubscriptions(input);
     227        return parseSubscriptions(input);
    228228    }
    229229   
     
    235235     * @param file
    236236     *            A File to attempt to parse.
    237      * @param list list of files to parse
     237     * @param list The default subscriptions to be saved and returned if the file cannot be read
    238238     * @return A List consisting of one element for each line in file, or if
    239239     *         file cannot be read, list.
     
    242242        List<String> result;
    243243        try {
    244             result = ConfigParser.parseSubscriptions(file);
     244            result = parseSubscriptions(file);
     245            // Fix up files that contain the old default
     246            // which was changed in 0.9.11
     247            if (result.remove(Daemon.OLD_DEFAULT_SUB)) {
     248                for (String sub : list) {
     249                    if (!result.contains(sub))
     250                        result.add(sub);
     251                }
     252                try {
     253                    writeSubscriptions(result, file);
     254                    // TODO log
     255                } catch (IOException ioe) {}
     256            }
    245257        } catch (IOException exp) {
    246258            result = list;
    247259            try {
    248                 ConfigParser.writeSubscriptions(result, file);
     260                writeSubscriptions(result, file);
    249261            } catch (IOException exp2) {
    250262            }
     
    290302        if (!isWindows) {
    291303            File tmp = SecureFile.createTempFile("temp-", ".tmp", file.getAbsoluteFile().getParentFile());
    292             ConfigParser
    293                 .write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8")));
     304            write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8")));
    294305            success = tmp.renameTo(file);
    295306            if (!success) {
     
    300311        if (!success) {
    301312            // hmm, that didn't work, try it the old way
    302             ConfigParser
    303                 .write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8")));
     313            write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8")));
    304314        }
    305315    }
     
    338348    public static void writeSubscriptions(List<String> list, File file)
    339349            throws IOException {
    340         ConfigParser.writeSubscriptions(list, new BufferedWriter(
     350        writeSubscriptions(list, new BufferedWriter(
    341351                new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8")));
    342352    }
  • apps/addressbook/java/src/net/i2p/addressbook/Daemon.java

    r855cae0 r1956068  
    5151    private volatile boolean _running;
    5252    private static final boolean DEBUG = false;
     53    private static final String DEFAULT_SUB = "http://i2p-projekt.i2p/hosts.txt";
     54    /** @since 0.9.12 */
     55    static final String OLD_DEFAULT_SUB = "http://www.i2p2.i2p/hosts.txt";
    5356   
    5457    /**
     
    254257        List<String> defaultSubs = new LinkedList<String>();
    255258        // defaultSubs.add("http://i2p/NF2RLVUxVulR3IqK0sGJR0dHQcGXAzwa6rEO4WAWYXOHw-DoZhKnlbf1nzHXwMEJoex5nFTyiNMqxJMWlY54cvU~UenZdkyQQeUSBZXyuSweflUXFqKN-y8xIoK2w9Ylq1k8IcrAFDsITyOzjUKoOPfVq34rKNDo7fYyis4kT5bAHy~2N1EVMs34pi2RFabATIOBk38Qhab57Umpa6yEoE~rbyR~suDRvD7gjBvBiIKFqhFueXsR2uSrPB-yzwAGofTXuklofK3DdKspciclTVzqbDjsk5UXfu2nTrC1agkhLyqlOfjhyqC~t1IXm-Vs2o7911k7KKLGjB4lmH508YJ7G9fLAUyjuB-wwwhejoWqvg7oWvqo4oIok8LG6ECR71C3dzCvIjY2QcrhoaazA9G4zcGMm6NKND-H4XY6tUWhpB~5GefB3YczOqMbHq4wi0O9MzBFrOJEOs3X4hwboKWANf7DT5PZKJZ5KorQPsYRSq0E3wSOsFCSsdVCKUGsAAAA/i2p/hosts.txt");
    256         defaultSubs.add("http://i2p-projekt.i2p/hosts.txt");
     259        defaultSubs.add(DEFAULT_SUB);
    257260       
    258261        SubscriptionList subscriptions = new SubscriptionList(subscriptionFile,
Note: See TracChangeset for help on using the changeset viewer.