Exemplo n.º 1
1
 private Map<String, Object> makeVuzeCall(
     DaemonMethod method, String serverMethod, Torrent actOnTorrent, Object[] params)
     throws DaemonException {
   return makeVuzeCall(
       method,
       serverMethod,
       Long.parseLong(actOnTorrent.getUniqueID()),
       params,
       actOnTorrent.getStatusCode());
 }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  private List<TorrentFile> onTorrentFilesRetrieved(Object result, Torrent torrent) {

    Map<String, Object> response = (Map<String, Object>) result;

    // We might have an empty list
    if (response == null) {
      return new ArrayList<TorrentFile>();
    }

    // DLog.d(LOG_NAME, response.toString().length() > 300? response.toString().substring(0, 300) +
    // "... (" + response.toString().length() + " chars)": response.toString());

    List<TorrentFile> files = new ArrayList<TorrentFile>();

    // Parse torrent file list from Vuze response, which is a map list of ENTRYs
    for (String key : response.keySet()) {

      /**
       * Every Vuze ENTRY is a map of key-value pairs with information For file lists, it looks
       * something like: ENTRY2={ is_deleted=false, length=298, downloaded=298, is_priority=false,
       * first_piece_number=726, is_skipped=false,
       * file=/var/data/Downloads/Some.Torrent/OneFile.txt, _object_id=443243294889782236,
       * num_pieces=1, access_mode=1 }
       */
      Map<String, Object> info = (Map<String, Object>) response.get(key);
      String file = (String) info.get("file");

      files.add(
          new TorrentFile(
              "" + (Long) info.get("_object_id"),
              new File(file).getName(), // name
              (file.length() > torrent.getLocationDir().length()
                  ? file.substring(torrent.getLocationDir().length())
                  : file), // name
              file, // fullPath
              (Long) info.get("length"), // size
              (Long) info.get("downloaded"), // downloaded
              convertVuzePriority(
                  (String) info.get("is_skipped"), (String) info.get("is_priority")))); // priority
    }

    return files;
  }