public void update() {
   try {
     if (download.getFd() == null) {
       if (download.getNConnections() == 0) {
         name = download.getAuxInfoFilename();
       } else {
         name = download.getAuxInfoFilename() + " - starting...";
       }
       size = "?";
     } else {
       name = download.getFd().getSubpath();
       size = TextUtils.formatByteSize(download.getFd().getSize());
     }
     percentComplete = download.getPercentComplete();
     numberOfConnections = download.getNConnections();
     speed = download.getBandwidth().getCPSHumanReadable();
     complete = download.isComplete();
     state = download.getState();
     if (download.getBandwidth().hasGoodAverage()) {
       eta = formatETA(download.getETAInMinutes());
     } else {
       eta = "?";
     }
   } catch (IOException e) {
     if (T.t) {
       T.error("Exception while updating downloadwrapper: " + e);
     }
   }
 }
예제 #2
0
  private void share(ArrayList<String> params) throws IOException {
    printer.println("All complete files: ");
    // ArrayList<Hash> al = new
    // ArrayList<Hash>(core.getFileManager().getFileDatabase().getAllHashes());
    // for (Hash h : al) {
    //    FileDescriptor fd = core.getFileManager().getFileDatabase().getFd(h);
    // //    printer.println("  " + fd);
    //   }
    printer.println("");

    printer.println("Incomplete files in cache: ");
    for (Hash h : core.getFileManager().getCache().rootHashes()) {
      BlockFile bf = core.getFileManager().getCache().getBlockFile(h);
      printer.println("  " + bf);
    }
    printer.println("");

    printer.println("Incomplete files in downloads: ");
    for (Hash h : core.getFileManager().getDownloadStorage().rootHashes()) {
      BlockFile bf = core.getFileManager().getDownloadStorage().getBlockFile(h);
      printer.println("  " + bf);
    }
    printer.println("");

    printer.println(
        "Sharing "
            + TextUtils.formatByteSize(core.getShareManager().getFileDatabase().getShareSize())
            + " in "
            + core.getShareManager().getFileDatabase().getNumberOfShares()
            + " files.");
    printer.println("");
  }
예제 #3
0
 private void gc() {
   System.gc();
   System.gc();
   long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
   printer.println(
       "Garbage collected. Using " + TextUtils.formatNumber("" + used) + " bytes of memory.");
 }
예제 #4
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table,
     Object value,
     boolean isSelected,
     boolean hasFocus,
     int rowIndex,
     int vColIndex) {
   super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, vColIndex);
   setText(TextUtils.formatByteSize((Long) value));
   setToolTipText(String.valueOf(value));
   return this;
 }
예제 #5
0
 private void dir(String sharebase, String path) {
   printer.println("Directory listing for " + path + ": ");
   sharebase = TextUtils.makeSurePathIsMultiplatform(sharebase);
   ShareBase b = core.getFileManager().getShareManager().getBaseByPath(sharebase);
   if (b == null) {
     printer.println("Could not find share base for " + sharebase);
     return;
   }
   printer.println("Found share base: " + b);
   /*  for (String s : core.getFileManager().getFileDatabase().getDirectoryListing(b, path)) {
   printer.println(s);
   }*/
 }
 private void showTotalBytesReceived() {
   status.setText(
       "Total bytes received: "
           + TextUtils.formatByteSize(
               ui.getCore().getNetworkManager().getBandwidthIn().getTotalBytes()));
 }