protected void checkForUpdates() { synchronized (this) { // vuze network always present, no need to check this for updates as we don't auto // update it if (networks.size() < 2 && !LOAD_ALL_NETWORKS) { return; } } PlatformContentNetworkMessenger.listNetworksAync( new listNetworksListener() { public void networkListReturned(List<contentNetworkDetails> cnets) { try { String str = ""; for (contentNetworkDetails details : cnets) { str += (str.length() == 0 ? "" : ", ") + details.getString(); ContentNetwork existing = getContentNetwork(details.getID()); if (existing != null) { ContentNetworkImpl new_net = createNetwork(details); addNetwork(new_net); } else { if (LOAD_ALL_NETWORKS) { ContentNetworkImpl new_net = createNetwork(details); addNetwork(new_net); } } } log("Latest networks: " + str); } catch (Throwable e) { log("Failed to load network list", e); } } }, 11110); }
// @see com.aelitis.azureus.core.cnetwork.ContentNetworkManager#addContentNetwork(long) public void addContentNetwork(final long id) throws ContentNetworkException { try { PlatformContentNetworkMessenger.listNetworksAync( new listNetworksListener() { public void networkListReturned(List<contentNetworkDetails> cnets) { if (cnets == null) { Exception e = new PlatformMessengerException("No networks returned"); for (ContentNetworkListener l : listeners) { l.networkAddFailed(id, e); } return; } for (contentNetworkDetails details : cnets) { if (details.getID() == id) { ContentNetworkImpl new_net; try { new_net = createNetwork(details); addNetwork(new_net); } catch (ContentNetworkException e) { for (ContentNetworkListener l : listeners) { l.networkAddFailed(id, e); } } return; } } Exception e = new ContentNetworkException("Content Network with id " + id + " not found"); for (ContentNetworkListener l : listeners) { l.networkAddFailed(id, e); } } }, 500); } catch (Throwable e) { ContentNetworkException e2 = new ContentNetworkException("Failed to list permitted networks", e); for (ContentNetworkListener l : listeners) { l.networkAddFailed(id, e2); } throw e2; } }