Ignore:
Timestamp:
2011-01-07T00:54:21+01:00 (13 years ago)
Author:
framm
Message:

display re-licensing status in the user list, so mappers can immediately see who has agreed to the new contributor terms and who has not. code is still a little rough on error handling but should work. feedback encouraged.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r3505 r3776  
    77import java.util.List;
    88import java.util.concurrent.atomic.AtomicLong;
     9import org.openstreetmap.josm.io.MirroredInputStream;
     10import java.io.InputStreamReader;
     11import java.io.BufferedReader;
    912
    1013/**
     
    2528     */
    2629    private static HashMap<Long,User> userMap = new HashMap<Long,User>();
     30    private static HashSet<Long> relicensingUsers = null;
    2731
    2832    private static long getNextLocalUid() {
     
    102106    }
    103107
     108    public static void loadRelicensingInformation() {
     109        relicensingUsers = new HashSet<Long>();
     110        try {
     111        MirroredInputStream stream = new MirroredInputStream("http://planet.openstreetmap.org/users_agreed/users_agreed.txt");
     112        InputStreamReader r;
     113        r = new InputStreamReader(stream);
     114        BufferedReader reader = new BufferedReader(r);
     115        String line;
     116        while ((line = reader.readLine()) != null) {
     117            if (line.startsWith("#")) continue;
     118            try {
     119                relicensingUsers.add(new Long(Long.parseLong(line.trim())));
     120            } catch (java.lang.NumberFormatException ex) {
     121            }
     122        }
     123        stream.close();
     124        } catch (java.io.IOException ex) {
     125        }
     126    }
     127
    104128    /** the user name */
    105129    private final HashSet<String> names = new HashSet<String>();
    106130    /** the user id */
    107131    private final long uid;
     132
     133    public static final int STATUS_UNKNOWN = 0;
     134    public static final int STATUS_AGREED = 1;
     135    public static final int STATUS_NOT_AGREED = 2;
     136    public static final int STATUS_AUTO_AGREED = 3;
     137
     138    /**
     139    */
     140    public int getRelicensingStatus() {
     141        if (uid >= 286582) return STATUS_AUTO_AGREED;
     142        if (relicensingUsers == null) return STATUS_UNKNOWN;
     143        return (relicensingUsers.contains(new Long(uid)) ? STATUS_AGREED : STATUS_NOT_AGREED);
     144    }
    108145
    109146    /**
Note: See TracChangeset for help on using the changeset viewer.