Methods Summary |
---|
public void | addMultiTracker(java.lang.String configName, java.util.List groups)
multiTrackers.put(configName,groups);
saveList();
|
public void | addTracker(java.lang.String trackerAnnounceUrl)
if(trackers.contains(trackerAnnounceUrl))
return;
trackers.add(0,trackerAnnounceUrl);
saveList();
|
public void | addWebSeed(java.lang.String configName, java.util.Map ws)
webseeds.put(configName,ws);
saveList();
|
public void | clearAllTrackers(boolean save)
trackers = new ArrayList();
multiTrackers = new HashMap();
webseeds = new HashMap();
if (save) {saveList();}
|
public static org.gudy.azureus2.core3.util.TrackersUtil | getInstance()
try{
class_mon.enter();
if(instance == null)
instance = new TrackersUtil();
return instance;
}finally{
class_mon.exit();
}
|
public java.util.Map | getMultiTrackers()
return new HashMap(multiTrackers);
|
public java.util.List | getTrackersList()
if(trackers != null)
return new ArrayList(trackers);
else
return null;
|
public java.util.Map | getWebSeeds()
return new HashMap(webseeds);
|
private void | loadList()
File fTrackers = FileUtil.getUserFile("trackers.config");
if(fTrackers.exists() && fTrackers.isFile()) {
FileInputStream fin = null;
BufferedInputStream bin = null;
try {
fin = new FileInputStream(fTrackers);
bin = new BufferedInputStream(fin, 8192);
Map map = BDecoder.decode(bin);
List list = (List) map.get("trackers");
if(list != null) {
Iterator iter = list.iterator();
while(iter.hasNext()) {
String tracker = new String((byte[])iter.next());
trackers.add(tracker);
}
}
Map mapMT = (Map) map.get("multi-trackers");
if(mapMT != null) {
Iterator iter = mapMT.keySet().iterator();
while(iter.hasNext()) {
String configName = (String) iter.next();
List groups = (List) mapMT.get(configName);
List resGroups = new ArrayList(groups.size());
Iterator iterGroups = groups.iterator();
while(iterGroups.hasNext()) {
List theseTrackers = (List) iterGroups.next();
List resTrackers = new ArrayList(theseTrackers.size());
Iterator iterTrackers = theseTrackers.iterator();
while(iterTrackers.hasNext()) {
String tracker = new String((byte[]) iterTrackers.next());
resTrackers.add(tracker);
}
resGroups.add(resTrackers);
}
this.multiTrackers.put(configName,resGroups);
}
}
webseeds = (Map)map.get( "webseeds" );
if ( webseeds == null ){
webseeds = new HashMap();
}else{
BDecoder.decodeStrings( webseeds );
}
} catch(Exception e) {
Debug.printStackTrace( e );
}finally{
if ( bin != null ){
try{
bin.close();
}catch( Throwable e ){
}
}
if ( fin != null ){
try{
fin.close();
}catch( Throwable e ){
}
}
}
}
|
public void | removeMultiTracker(java.lang.String configName)
multiTrackers.remove(configName);
saveList();
|
public void | removeWebSeed(java.lang.String configName)
webseeds.remove(configName);
saveList();
|
private void | saveList()
Map map = new HashMap();
map.put("trackers",trackers);
map.put("multi-trackers",multiTrackers);
map.put("webseeds",webseeds );
FileOutputStream fos = null;
try {
// Open the file
File fTrackers = FileUtil.getUserFile("trackers.config");
fos = new FileOutputStream(fTrackers);
fos.write(BEncoder.encode(map));
fos.close();
} catch (Exception e) {
Debug.printStackTrace( e );
} finally{
if ( fos != null ){
try{
fos.close();
}catch( Throwable e ){
}
}
}
|