mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-05 09:04:32 +02:00
1.42
-Cleaning
This commit is contained in:
parent
fc274e9a1f
commit
6b5ac57673
@ -6,7 +6,6 @@ import javax.swing.JOptionPane;
|
|||||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
import static megabasterd.MainPanel.VERSION;
|
import static megabasterd.MainPanel.VERSION;
|
||||||
import static megabasterd.MiscTools.copyTextToClipboard;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
@ -22,7 +21,6 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
private static final String SPAIN_URL = "https://en.wikipedia.org/wiki/Spain";
|
private static final String SPAIN_URL = "https://en.wikipedia.org/wiki/Spain";
|
||||||
private static final String MEGABASTERD_GITHUB_URL = "https://github.com/tonikelope/megabasterd";
|
private static final String MEGABASTERD_GITHUB_URL = "https://github.com/tonikelope/megabasterd";
|
||||||
|
|
||||||
|
|
||||||
public AboutDialog(MainPanelView parent, boolean modal) {
|
public AboutDialog(MainPanelView parent, boolean modal) {
|
||||||
|
|
||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
@ -34,11 +32,13 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() { updateFont(title_label, FONT_DEFAULT, Font.BOLD);
|
public void run() {
|
||||||
|
updateFont(title_label, FONT_DEFAULT, Font.BOLD);
|
||||||
updateFont(subtitle_label, FONT_DEFAULT, Font.BOLD);
|
updateFont(subtitle_label, FONT_DEFAULT, Font.BOLD);
|
||||||
updateFont(mcdown_url_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(mcdown_url_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(check_version_button, FONT_DEFAULT, Font.PLAIN);}}, true);
|
updateFont(check_version_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void mcdown_url_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mcdown_url_buttonActionPerformed
|
private void mcdown_url_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mcdown_url_buttonActionPerformed
|
||||||
|
|
||||||
copyTextToClipboard(MEGA_URL);
|
MiscTools.copyTextToClipboard(MEGA_URL);
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(this, "MEGA URL was copied to clipboard!");
|
JOptionPane.showMessageDialog(this, "MEGA URL was copied to clipboard!");
|
||||||
}//GEN-LAST:event_mcdown_url_buttonActionPerformed
|
}//GEN-LAST:event_mcdown_url_buttonActionPerformed
|
||||||
@ -222,7 +222,8 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEnabled", check_version_button, true);
|
swingReflectionInvoke("setEnabled", check_version_button, true);
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}//GEN-LAST:event_check_version_buttonActionPerformed
|
}//GEN-LAST:event_check_version_buttonActionPerformed
|
||||||
|
|
||||||
@ -250,7 +251,6 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.openBrowserURL(MEGABASTERD_GITHUB_URL);
|
MiscTools.openBrowserURL(MEGABASTERD_GITHUB_URL);
|
||||||
}//GEN-LAST:event_title_labelMouseReleased
|
}//GEN-LAST:event_title_labelMouseReleased
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JLabel author_webpage_label;
|
private javax.swing.JLabel author_webpage_label;
|
||||||
private javax.swing.JButton check_version_button;
|
private javax.swing.JButton check_version_button;
|
||||||
|
@ -16,15 +16,12 @@ public final class Chunk {
|
|||||||
private final ByteArrayOutputStream _data_os;
|
private final ByteArrayOutputStream _data_os;
|
||||||
private final String _url;
|
private final String _url;
|
||||||
|
|
||||||
|
public Chunk(long id, long file_size, String file_url) throws ChunkInvalidIdException {
|
||||||
public Chunk(long id, long file_size, String file_url) throws ChunkInvalidIdException
|
|
||||||
{
|
|
||||||
_id = id;
|
_id = id;
|
||||||
|
|
||||||
_offset = calculateOffset();
|
_offset = calculateOffset();
|
||||||
|
|
||||||
if(file_size > 0)
|
if (file_size > 0) {
|
||||||
{
|
|
||||||
if (_offset >= file_size) {
|
if (_offset >= file_size) {
|
||||||
throw new ChunkInvalidIdException(valueOf(id));
|
throw new ChunkInvalidIdException(valueOf(id));
|
||||||
}
|
}
|
||||||
@ -68,8 +65,7 @@ public final class Chunk {
|
|||||||
return new ByteArrayInputStream(_data_os.toByteArray());
|
return new ByteArrayInputStream(_data_os.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calculateSize(long file_size)
|
private long calculateSize(long file_size) {
|
||||||
{
|
|
||||||
long chunk_size = (_id >= 1 && _id <= 7) ? _id * 128 * 1024 : 1024 * 1024;
|
long chunk_size = (_id >= 1 && _id <= 7) ? _id * 128 * 1024 : 1024 * 1024;
|
||||||
|
|
||||||
if (_offset + chunk_size > file_size) {
|
if (_offset + chunk_size > file_size) {
|
||||||
@ -79,8 +75,7 @@ public final class Chunk {
|
|||||||
return chunk_size;
|
return chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calculateOffset()
|
private long calculateOffset() {
|
||||||
{
|
|
||||||
long[] offs = {0, 128, 384, 768, 1280, 1920, 2688};
|
long[] offs = {0, 128, 384, 768, 1280, 1920, 2688};
|
||||||
|
|
||||||
return (_id <= 7 ? offs[(int) _id - 1] : (3584 + (_id - 8) * 1024)) * 1024;
|
return (_id <= 7 ? offs[(int) _id - 1] : (3584 + (_id - 8) * 1024)) * 1024;
|
||||||
|
@ -14,7 +14,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
|||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -28,9 +27,7 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
private volatile boolean _error_wait;
|
private volatile boolean _error_wait;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
|
|
||||||
|
public ChunkDownloader(int id, Download download) {
|
||||||
public ChunkDownloader(int id, Download download)
|
|
||||||
{
|
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_exit = false;
|
_exit = false;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
@ -63,10 +60,8 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
_error_wait = error_wait;
|
_error_wait = error_wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -78,8 +73,7 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -105,8 +99,7 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
String worker_url = null;
|
String worker_url = null;
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int reads, conta_error, http_status;
|
int reads, conta_error, http_status;
|
||||||
@ -116,14 +109,12 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
System.out.println("Worker [" + _id + "]: let's do some work!");
|
System.out.println("Worker [" + _id + "]: let's do some work!");
|
||||||
|
|
||||||
try(CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient())
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
{
|
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
while(!_exit && !_download.isStopped())
|
while (!_exit && !_download.isStopped()) {
|
||||||
{
|
|
||||||
if (worker_url == null || error) {
|
if (worker_url == null || error) {
|
||||||
|
|
||||||
worker_url = _download.getDownloadUrlForWorker();
|
worker_url = _download.getDownloadUrlForWorker();
|
||||||
@ -145,16 +136,14 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
http_status = httpresponse.getStatusLine().getStatusCode();
|
http_status = httpresponse.getStatusLine().getStatusCode();
|
||||||
|
|
||||||
if ( http_status != HttpStatus.SC_OK )
|
if (http_status != HttpStatus.SC_OK) {
|
||||||
{
|
|
||||||
System.out.println("Failed : HTTP error code : " + http_status);
|
System.out.println("Failed : HTTP error code : " + http_status);
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
while(!_exit && !_download.isStopped() && !_download.getChunkwriter().isExit() && chunk.getOutputStream().size() < chunk.getSize() && (reads=is.read(buffer))!=-1 )
|
while (!_exit && !_download.isStopped() && !_download.getChunkwriter().isExit() && chunk.getOutputStream().size() < chunk.getSize() && (reads = is.read(buffer)) != -1) {
|
||||||
{
|
|
||||||
chunk.getOutputStream().write(buffer, 0, reads);
|
chunk.getOutputStream().write(buffer, 0, reads);
|
||||||
|
|
||||||
_download.getPartialProgressQueue().add(reads);
|
_download.getPartialProgressQueue().add(reads);
|
||||||
@ -173,8 +162,7 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
if (chunk.getOutputStream().size() < chunk.getSize()) {
|
if (chunk.getOutputStream().size() < chunk.getSize()) {
|
||||||
|
|
||||||
if(chunk.getOutputStream().size() > 0)
|
if (chunk.getOutputStream().size() > 0) {
|
||||||
{
|
|
||||||
_download.getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
_download.getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
||||||
|
|
||||||
_download.getProgress_meter().secureNotify();
|
_download.getProgress_meter().secureNotify();
|
||||||
@ -219,15 +207,12 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
_download.rejectChunkId(chunk.getId());
|
_download.rejectChunkId(chunk.getId());
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
_download.rejectChunkId(chunk.getId());
|
_download.rejectChunkId(chunk.getId());
|
||||||
|
|
||||||
if(chunk.getOutputStream().size() > 0)
|
if (chunk.getOutputStream().size() > 0) {
|
||||||
{
|
|
||||||
_download.getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
_download.getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
||||||
|
|
||||||
_download.getProgress_meter().secureNotify();
|
_download.getProgress_meter().secureNotify();
|
||||||
@ -257,6 +242,4 @@ public class ChunkDownloader implements Runnable, SecureNotifiable {
|
|||||||
System.out.println("Worker [" + _id + "]: bye bye");
|
System.out.println("Worker [" + _id + "]: bye bye");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
|||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -26,8 +25,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
String worker_url = null;
|
String worker_url = null;
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int reads, max_reads, conta_error, http_status = 200;
|
int reads, max_reads, conta_error, http_status = 200;
|
||||||
@ -38,16 +36,14 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
System.out.println("Worker [" + getId() + "]: let's do some work!");
|
System.out.println("Worker [" + getId() + "]: let's do some work!");
|
||||||
|
|
||||||
try(CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient())
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
{
|
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
|
|
||||||
while(!isExit() && !getDownload().isStopped())
|
while (!isExit() && !getDownload().isStopped()) {
|
||||||
{
|
|
||||||
if (worker_url == null || error) {
|
if (worker_url == null || error) {
|
||||||
|
|
||||||
worker_url = getDownload().getDownloadUrlForWorker();
|
worker_url = getDownload().getDownloadUrlForWorker();
|
||||||
@ -84,10 +80,9 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(!isExit() && !getDownload().isStopped()) {
|
if (!isExit() && !getDownload().isStopped() && is != null) {
|
||||||
|
|
||||||
while(!getDownload().isStopped() && !getDownload().getChunkwriter().isExit() && chunk.getOutputStream().size() < chunk.getSize() && (reads=is.read(buffer, 0, (max_reads=(int)(chunk.getSize() - chunk.getOutputStream().size())) <= buffer.length?max_reads:buffer.length))!=-1 )
|
while (!getDownload().isStopped() && !getDownload().getChunkwriter().isExit() && chunk.getOutputStream().size() < chunk.getSize() && (reads = is.read(buffer, 0, (max_reads = (int) (chunk.getSize() - chunk.getOutputStream().size())) <= buffer.length ? max_reads : buffer.length)) != -1) {
|
||||||
{
|
|
||||||
chunk.getOutputStream().write(buffer, 0, reads);
|
chunk.getOutputStream().write(buffer, 0, reads);
|
||||||
|
|
||||||
getDownload().getPartialProgressQueue().add(reads);
|
getDownload().getPartialProgressQueue().add(reads);
|
||||||
@ -104,8 +99,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
if (chunk.getOutputStream().size() < chunk.getSize()) {
|
if (chunk.getOutputStream().size() < chunk.getSize()) {
|
||||||
|
|
||||||
if(chunk.getOutputStream().size() > 0)
|
if (chunk.getOutputStream().size() > 0) {
|
||||||
{
|
|
||||||
getDownload().getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
getDownload().getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
||||||
|
|
||||||
getDownload().getProgress_meter().secureNotify();
|
getDownload().getProgress_meter().secureNotify();
|
||||||
@ -142,15 +136,12 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
getDownload().rejectChunkId(chunk.getId());
|
getDownload().rejectChunkId(chunk.getId());
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
getDownload().rejectChunkId(chunk.getId());
|
getDownload().rejectChunkId(chunk.getId());
|
||||||
|
|
||||||
if(chunk.getOutputStream().size() > 0)
|
if (chunk.getOutputStream().size() > 0) {
|
||||||
{
|
|
||||||
getDownload().getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
getDownload().getPartialProgressQueue().add(-1 * chunk.getOutputStream().size());
|
||||||
|
|
||||||
getDownload().getProgress_meter().secureNotify();
|
getDownload().getProgress_meter().secureNotify();
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package megabasterd;
|
package megabasterd;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
*/
|
*/
|
||||||
public final class ChunkInvalidIdException extends Exception {
|
public final class ChunkInvalidIdException extends Exception {
|
||||||
|
|
||||||
public ChunkInvalidIdException(String message)
|
public ChunkInvalidIdException(String message) {
|
||||||
{
|
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@ import org.apache.http.client.methods.HttpPost;
|
|||||||
import org.apache.http.entity.InputStreamEntity;
|
import org.apache.http.entity.InputStreamEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -43,8 +41,7 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
private volatile boolean _error_wait;
|
private volatile boolean _error_wait;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
|
|
||||||
public ChunkUploader(int id, Upload upload)
|
public ChunkUploader(int id, Upload upload) {
|
||||||
{
|
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_id = id;
|
_id = id;
|
||||||
@ -62,8 +59,7 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -75,8 +71,7 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -117,11 +112,8 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
this._error_wait = _error_wait;
|
this._error_wait = _error_wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
System.out.println("ChunkUploader " + _id + " hello!");
|
System.out.println("ChunkUploader " + _id + " hello!");
|
||||||
|
|
||||||
String worker_url = _upload.getUl_url();
|
String worker_url = _upload.getUl_url();
|
||||||
@ -131,20 +123,17 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
boolean error;
|
boolean error;
|
||||||
OutputStream out;
|
OutputStream out;
|
||||||
|
|
||||||
try(final CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient())
|
try (final CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
{
|
|
||||||
RandomAccessFile f = new RandomAccessFile(_upload.getFile_name(), "r");
|
RandomAccessFile f = new RandomAccessFile(_upload.getFile_name(), "r");
|
||||||
|
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
while(!_exit && !_upload.isStopped())
|
while (!_exit && !_upload.isStopped()) {
|
||||||
{
|
|
||||||
chunk = new Chunk(_upload.nextChunkId(), _upload.getFile_size(), worker_url);
|
chunk = new Chunk(_upload.nextChunkId(), _upload.getFile_size(), worker_url);
|
||||||
|
|
||||||
f.seek(chunk.getOffset());
|
f.seek(chunk.getOffset());
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
to_read = chunk.getSize() - chunk.getOutputStream().size() >= buffer.length ? buffer.length : (int) (chunk.getSize() - chunk.getOutputStream().size());
|
to_read = chunk.getSize() - chunk.getOutputStream().size() >= buffer.length ? buffer.length : (int) (chunk.getSize() - chunk.getOutputStream().size());
|
||||||
|
|
||||||
re = f.read(buffer, 0, to_read);
|
re = f.read(buffer, 0, to_read);
|
||||||
@ -191,8 +180,7 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
System.out.println(" Subiendo chunk " + chunk.getId() + " desde worker " + _id + "...");
|
System.out.println(" Subiendo chunk " + chunk.getId() + " desde worker " + _id + "...");
|
||||||
|
|
||||||
while( !_exit && !_upload.isStopped() && (reads=cis.read(buffer))!=-1 )
|
while (!_exit && !_upload.isStopped() && (reads = cis.read(buffer)) != -1) {
|
||||||
{
|
|
||||||
out.write(buffer, 0, reads);
|
out.write(buffer, 0, reads);
|
||||||
|
|
||||||
_upload.getPartialProgress().add(reads);
|
_upload.getPartialProgress().add(reads);
|
||||||
@ -226,16 +214,14 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
httpresponse = null;
|
httpresponse = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpresponse != null && (http_status = httpresponse.getStatusLine().getStatusCode()) != HttpStatus.SC_OK )
|
if (httpresponse != null && (http_status = httpresponse.getStatusLine().getStatusCode()) != HttpStatus.SC_OK) {
|
||||||
{
|
|
||||||
System.out.println("Failed : HTTP error code : " + http_status);
|
System.out.println("Failed : HTTP error code : " + http_status);
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(tot_bytes_up < chunk.getSize())
|
if (tot_bytes_up < chunk.getSize()) {
|
||||||
{
|
|
||||||
if (tot_bytes_up > 0) {
|
if (tot_bytes_up > 0) {
|
||||||
|
|
||||||
_upload.getPartialProgress().add(-1 * tot_bytes_up);
|
_upload.getPartialProgress().add(-1 * tot_bytes_up);
|
||||||
@ -262,8 +248,7 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
if (response.length() > 0) {
|
if (response.length() > 0) {
|
||||||
|
|
||||||
if( MegaAPI.checkMEGAError(response) != 0 )
|
if (MegaAPI.checkMEGAError(response) != 0) {
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -307,8 +292,8 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(ExecutionException exception){}
|
} catch (ExecutionException exception) {
|
||||||
finally{
|
} finally {
|
||||||
|
|
||||||
if (httpresponse != null) {
|
if (httpresponse != null) {
|
||||||
|
|
||||||
@ -318,14 +303,11 @@ public class ChunkUploader implements Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (_exit) {
|
} else if (_exit) {
|
||||||
|
|
||||||
_upload.rejectChunkId(chunk.getId());
|
_upload.rejectChunkId(chunk.getId());
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
_upload.rejectChunkId(chunk.getId());
|
_upload.rejectChunkId(chunk.getId());
|
||||||
|
|
||||||
if (tot_bytes_up > 0) {
|
if (tot_bytes_up > 0) {
|
||||||
|
@ -44,8 +44,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
System.out.println("ChunkUploader " + getId() + " hello!");
|
System.out.println("ChunkUploader " + getId() + " hello!");
|
||||||
|
|
||||||
String worker_url = getUpload().getUl_url();
|
String worker_url = getUpload().getUl_url();
|
||||||
@ -54,8 +53,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
byte[] buffer = new byte[MainPanel.THROTTLE_SLICE_SIZE];
|
byte[] buffer = new byte[MainPanel.THROTTLE_SLICE_SIZE];
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
|
|
||||||
try(CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient())
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
{
|
|
||||||
RandomAccessFile f = new RandomAccessFile(getUpload().getFile_name(), "r");
|
RandomAccessFile f = new RandomAccessFile(getUpload().getFile_name(), "r");
|
||||||
|
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
@ -64,16 +62,14 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
FutureTask<CloseableHttpResponse> futureTask = null;
|
FutureTask<CloseableHttpResponse> futureTask = null;
|
||||||
|
|
||||||
while(!isExit() && !getUpload().isStopped())
|
while (!isExit() && !getUpload().isStopped()) {
|
||||||
{
|
|
||||||
CloseableHttpResponse httpresponse = null;
|
CloseableHttpResponse httpresponse = null;
|
||||||
|
|
||||||
chunk = new Chunk(getUpload().nextChunkId(), getUpload().getFile_size(), null);
|
chunk = new Chunk(getUpload().nextChunkId(), getUpload().getFile_size(), null);
|
||||||
|
|
||||||
f.seek(chunk.getOffset());
|
f.seek(chunk.getOffset());
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
to_read = chunk.getSize() - chunk.getOutputStream().size() >= buffer.length ? buffer.length : (int) (chunk.getSize() - chunk.getOutputStream().size());
|
to_read = chunk.getSize() - chunk.getOutputStream().size() >= buffer.length ? buffer.length : (int) (chunk.getSize() - chunk.getOutputStream().size());
|
||||||
|
|
||||||
re = f.read(buffer, 0, to_read);
|
re = f.read(buffer, 0, to_read);
|
||||||
@ -122,8 +118,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
System.out.println(" Subiendo chunk " + chunk.getId() + " desde worker " + getId() + "...");
|
System.out.println(" Subiendo chunk " + chunk.getId() + " desde worker " + getId() + "...");
|
||||||
|
|
||||||
while( !isExit() && !getUpload().isStopped() && (reads=cis.read(buffer))!=-1 && out != null )
|
while (!isExit() && !getUpload().isStopped() && (reads = cis.read(buffer)) != -1 && out != null) {
|
||||||
{
|
|
||||||
out.write(buffer, 0, reads);
|
out.write(buffer, 0, reads);
|
||||||
|
|
||||||
getUpload().getPartialProgress().add(reads);
|
getUpload().getPartialProgress().add(reads);
|
||||||
@ -142,8 +137,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
if (!getUpload().isStopped()) {
|
if (!getUpload().isStopped()) {
|
||||||
|
|
||||||
if(tot_bytes_up < chunk.getSize())
|
if (tot_bytes_up < chunk.getSize()) {
|
||||||
{
|
|
||||||
if (tot_bytes_up > 0) {
|
if (tot_bytes_up > 0) {
|
||||||
|
|
||||||
getUpload().getPartialProgress().add(-1 * tot_bytes_up);
|
getUpload().getPartialProgress().add(-1 * tot_bytes_up);
|
||||||
@ -187,9 +181,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
getUpload().rejectChunkId(chunk.getId());
|
getUpload().rejectChunkId(chunk.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
getUpload().rejectChunkId(chunk.getId());
|
getUpload().rejectChunkId(chunk.getId());
|
||||||
@ -216,8 +208,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
http_status = httpresponse.getStatusLine().getStatusCode();
|
http_status = httpresponse.getStatusLine().getStatusCode();
|
||||||
|
|
||||||
if (http_status != HttpStatus.SC_OK )
|
if (http_status != HttpStatus.SC_OK) {
|
||||||
{
|
|
||||||
throw new IOException("UPLOAD FAILED! (HTTP STATUS: " + http_status + ")");
|
throw new IOException("UPLOAD FAILED! (HTTP STATUS: " + http_status + ")");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -235,8 +226,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
if (response.length() > 0) {
|
if (response.length() > 0) {
|
||||||
|
|
||||||
if( MegaAPI.checkMEGAError(response) != 0 )
|
if (MegaAPI.checkMEGAError(response) != 0) {
|
||||||
{
|
|
||||||
throw new IOException("UPLOAD FAILED! (MEGA ERROR: " + MegaAPI.checkMEGAError(response) + ")");
|
throw new IOException("UPLOAD FAILED! (MEGA ERROR: " + MegaAPI.checkMEGAError(response) + ")");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -248,8 +238,8 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(ExecutionException exception) {}
|
} catch (ExecutionException exception) {
|
||||||
finally{
|
} finally {
|
||||||
|
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -11,7 +11,6 @@ import static java.util.logging.Logger.getLogger;
|
|||||||
import javax.crypto.CipherInputStream;
|
import javax.crypto.CipherInputStream;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
|
||||||
|
|
||||||
public final class ChunkWriter implements Runnable, SecureNotifiable {
|
public final class ChunkWriter implements Runnable, SecureNotifiable {
|
||||||
|
|
||||||
private long _last_chunk_id_written;
|
private long _last_chunk_id_written;
|
||||||
@ -25,8 +24,8 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
private final ConcurrentLinkedQueue<Long> _rejectedChunkIds;
|
private final ConcurrentLinkedQueue<Long> _rejectedChunkIds;
|
||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
public ChunkWriter(Download downloader) throws Exception
|
|
||||||
{
|
public ChunkWriter(Download downloader) throws Exception {
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_exit = false;
|
_exit = false;
|
||||||
_download = downloader;
|
_download = downloader;
|
||||||
@ -37,16 +36,13 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
_chunk_queue = new ConcurrentHashMap();
|
_chunk_queue = new ConcurrentHashMap();
|
||||||
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
if(_download.getProgress() == 0)
|
if (_download.getProgress() == 0) {
|
||||||
{
|
|
||||||
_download.setLast_chunk_id_dispatched(0);
|
_download.setLast_chunk_id_dispatched(0);
|
||||||
|
|
||||||
_last_chunk_id_written = 0;
|
_last_chunk_id_written = 0;
|
||||||
|
|
||||||
_bytes_written = 0;
|
_bytes_written = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
_last_chunk_id_written = calculateLastWrittenChunk(_download.getProgress());
|
_last_chunk_id_written = calculateLastWrittenChunk(_download.getProgress());
|
||||||
|
|
||||||
_download.setLast_chunk_id_dispatched(_last_chunk_id_written);
|
_download.setLast_chunk_id_dispatched(_last_chunk_id_written);
|
||||||
@ -55,10 +51,8 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -70,8 +64,7 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -104,7 +97,6 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
return _rejectedChunkIds;
|
return _rejectedChunkIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isExit() {
|
public boolean isExit() {
|
||||||
return _exit;
|
return _exit;
|
||||||
}
|
}
|
||||||
@ -117,15 +109,12 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
return _last_chunk_id_written;
|
return _last_chunk_id_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConcurrentHashMap getChunk_queue() {
|
||||||
public ConcurrentHashMap getChunk_queue()
|
|
||||||
{
|
|
||||||
return _chunk_queue;
|
return _chunk_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
Chunk current_chunk;
|
Chunk current_chunk;
|
||||||
CipherInputStream cis;
|
CipherInputStream cis;
|
||||||
byte[] buffer = new byte[16 * 1024];
|
byte[] buffer = new byte[16 * 1024];
|
||||||
@ -135,18 +124,14 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
System.out.println("Filewriter: let's do some work!");
|
System.out.println("Filewriter: let's do some work!");
|
||||||
|
|
||||||
if(_file_size > 0)
|
if (_file_size > 0) {
|
||||||
{
|
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||||
while(!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size)
|
while (_chunk_queue.containsKey(_last_chunk_id_written + 1)) {
|
||||||
{
|
|
||||||
while(_chunk_queue.containsKey(_last_chunk_id_written+1))
|
|
||||||
{
|
|
||||||
current_chunk = _chunk_queue.get(_last_chunk_id_written + 1);
|
current_chunk = _chunk_queue.get(_last_chunk_id_written + 1);
|
||||||
|
|
||||||
cis = new CipherInputStream(current_chunk.getInputStream(), CryptTools.genDecrypter("AES", "AES/CTR/NoPadding", _byte_file_key, CryptTools.forwardMEGALinkKeyIV(_byte_iv, _bytes_written)));
|
cis = new CipherInputStream(current_chunk.getInputStream(), CryptTools.genDecrypter("AES", "AES/CTR/NoPadding", _byte_file_key, CryptTools.forwardMEGALinkKeyIV(_byte_iv, _bytes_written)));
|
||||||
|
|
||||||
while((reads=cis.read(buffer))!=-1)
|
while ((reads = cis.read(buffer)) != -1) {
|
||||||
{
|
|
||||||
_download.getOutput_stream().write(buffer, 0, reads);
|
_download.getOutput_stream().write(buffer, 0, reads);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +145,7 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size)
|
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||||
{
|
|
||||||
|
|
||||||
System.out.println("Filewriter waiting for chunk [" + (_last_chunk_id_written + 1) + "]...");
|
System.out.println("Filewriter waiting for chunk [" + (_last_chunk_id_written + 1) + "]...");
|
||||||
|
|
||||||
@ -184,18 +168,13 @@ public final class ChunkWriter implements Runnable, SecureNotifiable {
|
|||||||
System.out.println("Filewriter: bye bye" + _download.getFile().getName());
|
System.out.println("Filewriter: bye bye" + _download.getFile().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calculateLastWrittenChunk(long temp_file_size)
|
private long calculateLastWrittenChunk(long temp_file_size) {
|
||||||
{
|
if (temp_file_size > 3584 * 1024) {
|
||||||
if(temp_file_size > 3584*1024)
|
|
||||||
{
|
|
||||||
return 7 + (long) Math.ceil((temp_file_size - 3584 * 1024) / (1024 * 1024));
|
return 7 + (long) Math.ceil((temp_file_size - 3584 * 1024) / (1024 * 1024));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int i = 0, tot = 0;
|
int i = 0, tot = 0;
|
||||||
|
|
||||||
while(tot < temp_file_size)
|
while (tot < temp_file_size) {
|
||||||
{
|
|
||||||
i++;
|
i++;
|
||||||
tot += i * 128 * 1024;
|
tot += i * 128 * 1024;
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,11 @@ import java.awt.datatransfer.Transferable;
|
|||||||
public interface ClipboardChangeObservable {
|
public interface ClipboardChangeObservable {
|
||||||
|
|
||||||
void attachObserver(ClipboardChangeObserver observer);
|
void attachObserver(ClipboardChangeObserver observer);
|
||||||
|
|
||||||
void detachObserver(ClipboardChangeObserver observer);
|
void detachObserver(ClipboardChangeObserver observer);
|
||||||
|
|
||||||
Transferable getContents();
|
Transferable getContents();
|
||||||
|
|
||||||
void notifyChangeToMyObservers();
|
void notifyChangeToMyObservers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,11 @@ import static java.awt.Toolkit.getDefaultToolkit;
|
|||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.ClipboardOwner;
|
import java.awt.datatransfer.ClipboardOwner;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import static java.lang.System.out;
|
|
||||||
import static java.lang.Thread.sleep;
|
import static java.lang.Thread.sleep;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
|
||||||
|
|
||||||
public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotifiable, ClipboardChangeObservable {
|
public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotifiable, ClipboardChangeObservable {
|
||||||
|
|
||||||
private static final int SLEEP = 50;
|
private static final int SLEEP = 50;
|
||||||
@ -25,8 +23,6 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
|
|
||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ClipboardSpy() {
|
public ClipboardSpy() {
|
||||||
_sysClip = getDefaultToolkit().getSystemClipboard();
|
_sysClip = getDefaultToolkit().getSystemClipboard();
|
||||||
_notified = false;
|
_notified = false;
|
||||||
@ -34,14 +30,14 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_observers = new ConcurrentLinkedQueue<>();
|
_observers = new ConcurrentLinkedQueue<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Transferable getContents() {
|
public Transferable getContents() {
|
||||||
return _contents;
|
return _contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -53,8 +49,7 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -79,7 +74,6 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
@ -87,12 +81,11 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
|
|
||||||
gainOwnership(_contents);
|
gainOwnership(_contents);
|
||||||
|
|
||||||
out.println("Spying clipboard...");
|
System.out.println("Spying clipboard...");
|
||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lostOwnership(Clipboard c, Transferable t) {
|
public void lostOwnership(Clipboard c, Transferable t) {
|
||||||
|
|
||||||
@ -103,7 +96,6 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
gainOwnership(_contents);
|
gainOwnership(_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Transferable getClipboardContents() {
|
private Transferable getClipboardContents() {
|
||||||
|
|
||||||
boolean error;
|
boolean error;
|
||||||
@ -133,7 +125,6 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureNotif
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void gainOwnership(Transferable t) {
|
private void gainOwnership(Transferable t) {
|
||||||
|
|
||||||
boolean error;
|
boolean error;
|
||||||
|
@ -6,7 +6,6 @@ public final class ContentType {
|
|||||||
|
|
||||||
private final HashMap<String, String> _content_type;
|
private final HashMap<String, String> _content_type;
|
||||||
|
|
||||||
|
|
||||||
public ContentType() {
|
public ContentType() {
|
||||||
|
|
||||||
_content_type = new HashMap();
|
_content_type = new HashMap();
|
||||||
@ -48,12 +47,12 @@ public final class ContentType {
|
|||||||
_content_type.put("mov", "video/quicktime");
|
_content_type.put("mov", "video/quicktime");
|
||||||
_content_type.put("qt", "video/quicktime");
|
_content_type.put("qt", "video/quicktime");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, String> getContent_type() {
|
public HashMap<String, String> getContent_type() {
|
||||||
return _content_type;
|
return _content_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMIME(String ext)
|
public String getMIME(String ext) {
|
||||||
{
|
|
||||||
return _content_type.get(ext);
|
return _content_type.get(ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@ public final class ContextMenuMouseListener extends MouseAdapter {
|
|||||||
private String _savedString;
|
private String _savedString;
|
||||||
private _Actions _lastActionSelected;
|
private _Actions _lastActionSelected;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ContextMenuMouseListener() {
|
public ContextMenuMouseListener() {
|
||||||
_savedString = "";
|
_savedString = "";
|
||||||
_popup = new JPopupMenu();
|
_popup = new JPopupMenu();
|
||||||
@ -121,5 +119,8 @@ public final class ContextMenuMouseListener extends MouseAdapter {
|
|||||||
_popup.show(e.getComponent(), nx, e.getY() - _popup.getSize().height);
|
_popup.show(e.getComponent(), nx, e.getY() - _popup.getSize().height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private enum _Actions { UNDO, CUT, COPY, PASTE, SELECT_ALL }
|
|
||||||
|
private enum _Actions {
|
||||||
|
UNDO, CUT, COPY, PASTE, SELECT_ALL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import static megabasterd.MiscTools.hex2bin;
|
|||||||
import static megabasterd.MiscTools.i32a2bin;
|
import static megabasterd.MiscTools.i32a2bin;
|
||||||
import static megabasterd.MiscTools.long2bytearray;
|
import static megabasterd.MiscTools.long2bytearray;
|
||||||
|
|
||||||
|
|
||||||
public final class CryptTools {
|
public final class CryptTools {
|
||||||
|
|
||||||
public static final int[] AES_ZERO_IV_I32A = {0, 0, 0, 0};
|
public static final int[] AES_ZERO_IV_I32A = {0, 0, 0, 0};
|
||||||
@ -37,8 +36,7 @@ public final class CryptTools {
|
|||||||
|
|
||||||
public static final int PBKDF2_ITERATIONS = 0x10000;
|
public static final int PBKDF2_ITERATIONS = 0x10000;
|
||||||
|
|
||||||
public static Cipher genDecrypter(String algo, String mode, byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException
|
public static Cipher genDecrypter(String algo, String mode, byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
|
||||||
{
|
|
||||||
SecretKeySpec skeySpec = new SecretKeySpec(key, algo);
|
SecretKeySpec skeySpec = new SecretKeySpec(key, algo);
|
||||||
|
|
||||||
Cipher decryptor = Cipher.getInstance(mode);
|
Cipher decryptor = Cipher.getInstance(mode);
|
||||||
@ -57,8 +55,7 @@ public final class CryptTools {
|
|||||||
return decryptor;
|
return decryptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cipher genCrypter(String algo, String mode, byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException
|
public static Cipher genCrypter(String algo, String mode, byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
|
||||||
{
|
|
||||||
SecretKeySpec skeySpec = new SecretKeySpec(key, algo);
|
SecretKeySpec skeySpec = new SecretKeySpec(key, algo);
|
||||||
|
|
||||||
Cipher cryptor = Cipher.getInstance(mode);
|
Cipher cryptor = Cipher.getInstance(mode);
|
||||||
@ -204,8 +201,7 @@ public final class CryptTools {
|
|||||||
return plainText;
|
return plainText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] initMEGALinkKey(String key_string) throws Exception
|
public static byte[] initMEGALinkKey(String key_string) throws Exception {
|
||||||
{
|
|
||||||
int[] int_key = bin2i32a(UrlBASE642Bin(key_string));
|
int[] int_key = bin2i32a(UrlBASE642Bin(key_string));
|
||||||
int[] k = new int[4];
|
int[] k = new int[4];
|
||||||
|
|
||||||
@ -217,8 +213,7 @@ public final class CryptTools {
|
|||||||
return i32a2bin(k);
|
return i32a2bin(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] initMEGALinkKeyIV(String key_string) throws Exception
|
public static byte[] initMEGALinkKeyIV(String key_string) throws Exception {
|
||||||
{
|
|
||||||
int[] int_key = bin2i32a(UrlBASE642Bin(key_string));
|
int[] int_key = bin2i32a(UrlBASE642Bin(key_string));
|
||||||
int[] iv = new int[4];
|
int[] iv = new int[4];
|
||||||
|
|
||||||
@ -230,8 +225,7 @@ public final class CryptTools {
|
|||||||
return i32a2bin(iv);
|
return i32a2bin(iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] forwardMEGALinkKeyIV(byte[] iv, long forward_bytes)
|
public static byte[] forwardMEGALinkKeyIV(byte[] iv, long forward_bytes) {
|
||||||
{
|
|
||||||
byte[] new_iv = new byte[iv.length];
|
byte[] new_iv = new byte[iv.length];
|
||||||
|
|
||||||
System.arraycopy(iv, 0, new_iv, 0, iv.length / 2);
|
System.arraycopy(iv, 0, new_iv, 0, iv.length / 2);
|
||||||
@ -243,15 +237,13 @@ public final class CryptTools {
|
|||||||
return new_iv;
|
return new_iv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String decryptMegaDownloaderLink(String link) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, Exception, IllegalBlockSizeException, BadPaddingException
|
public static String decryptMegaDownloaderLink(String link) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, Exception, IllegalBlockSizeException, BadPaddingException {
|
||||||
{
|
|
||||||
String[] keys = {"6B316F36416C2D316B7A3F217A30357958585858585858585858585858585858", "ED1F4C200B35139806B260563B3D3876F011B4750F3A1A4A5EFD0BBE67554B44"};
|
String[] keys = {"6B316F36416C2D316B7A3F217A30357958585858585858585858585858585858", "ED1F4C200B35139806B260563B3D3876F011B4750F3A1A4A5EFD0BBE67554B44"};
|
||||||
String iv = "79F10A01844A0B27FF5B2D4E0ED3163E";
|
String iv = "79F10A01844A0B27FF5B2D4E0ED3163E";
|
||||||
|
|
||||||
String enc_type, folder, dec_link;
|
String enc_type, folder, dec_link;
|
||||||
|
|
||||||
if((enc_type=findFirstRegex("mega://f?(enc[0-9]*)\\?", link, 1)) != null)
|
if ((enc_type = findFirstRegex("mega://f?(enc[0-9]*)\\?", link, 1)) != null) {
|
||||||
{
|
|
||||||
Cipher decrypter;
|
Cipher decrypter;
|
||||||
|
|
||||||
String the_key = null;
|
String the_key = null;
|
||||||
@ -339,7 +331,6 @@ public final class CryptTools {
|
|||||||
return f.generateSecret(ks).getEncoded();
|
return f.generateSecret(ks).getEncoded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CryptTools() {
|
private CryptTools() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,6 @@ public final class DBTools {
|
|||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void insertMegaAccount(String email, String password, String password_aes, String user_hash) throws SQLException {
|
public static void insertMegaAccount(String email, String password, String password_aes, String user_hash) throws SQLException {
|
||||||
|
|
||||||
try (Connection conn = SqliteSingleton.getInstance().getConn(); PreparedStatement ps = conn.prepareStatement("INSERT OR REPLACE INTO mega_accounts (email,password,password_aes,user_hash) VALUES (?, ?, ?, ?)")) {
|
try (Connection conn = SqliteSingleton.getInstance().getConn(); PreparedStatement ps = conn.prepareStatement("INSERT OR REPLACE INTO mega_accounts (email,password,password_aes,user_hash) VALUES (?, ?, ?, ?)")) {
|
||||||
|
@ -12,7 +12,6 @@ import static java.lang.Integer.MAX_VALUE;
|
|||||||
import static java.lang.Integer.parseInt;
|
import static java.lang.Integer.parseInt;
|
||||||
import static java.lang.Long.valueOf;
|
import static java.lang.Long.valueOf;
|
||||||
import static java.lang.Math.ceil;
|
import static java.lang.Math.ceil;
|
||||||
import static java.lang.System.out;
|
|
||||||
import static java.lang.Thread.sleep;
|
import static java.lang.Thread.sleep;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
@ -23,7 +22,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import static java.util.concurrent.Executors.newCachedThreadPool;
|
import static java.util.concurrent.Executors.newCachedThreadPool;
|
||||||
import static java.util.concurrent.TimeUnit.DAYS;
|
import java.util.concurrent.TimeUnit;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
@ -126,7 +125,6 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
_thread_pool = newCachedThreadPool();
|
_thread_pool = newCachedThreadPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isChecking_cbc() {
|
public boolean isChecking_cbc() {
|
||||||
return _checking_cbc;
|
return _checking_cbc;
|
||||||
}
|
}
|
||||||
@ -221,7 +219,6 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
return _provision_ok;
|
return _provision_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpeedMeter getSpeed_meter() {
|
public SpeedMeter getSpeed_meter() {
|
||||||
|
|
||||||
@ -393,16 +390,13 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
return _partialProgressQueue;
|
return _partialProgressQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFile_size() {
|
public long getFile_size() {
|
||||||
return _file_size;
|
return _file_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setVisible", getView().getClose_button(), false);
|
swingReflectionInvoke("setVisible", getView().getClose_button(), false);
|
||||||
|
|
||||||
String exit_message;
|
String exit_message;
|
||||||
@ -411,27 +405,23 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(!_exit)
|
if (!_exit) {
|
||||||
{
|
|
||||||
String filename = _download_path + "/" + _file_name;
|
String filename = _download_path + "/" + _file_name;
|
||||||
|
|
||||||
_file = new File(filename);
|
_file = new File(filename);
|
||||||
|
|
||||||
if(_file.getParent()!=null)
|
if (_file.getParent() != null) {
|
||||||
{
|
|
||||||
File path = new File(_file.getParent());
|
File path = new File(_file.getParent());
|
||||||
|
|
||||||
path.mkdirs();
|
path.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_file.exists())
|
if (!_file.exists()) {
|
||||||
{
|
|
||||||
getView().printStatusNormal("Starting download (retrieving MEGA temp link), please wait...");
|
getView().printStatusNormal("Starting download (retrieving MEGA temp link), please wait...");
|
||||||
|
|
||||||
_last_download_url = getMegaFileDownloadUrl(_url);
|
_last_download_url = getMegaFileDownloadUrl(_url);
|
||||||
|
|
||||||
if(!_exit)
|
if (!_exit) {
|
||||||
{
|
|
||||||
_retrying_request = false;
|
_retrying_request = false;
|
||||||
|
|
||||||
swingReflectionInvoke("setMinimum", getView().getProgress_pbar(), 0);
|
swingReflectionInvoke("setMinimum", getView().getProgress_pbar(), 0);
|
||||||
@ -444,27 +434,22 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
_file = new File(filename + ".mctemp");
|
_file = new File(filename + ".mctemp");
|
||||||
|
|
||||||
if(_file.exists())
|
if (_file.exists()) {
|
||||||
{
|
|
||||||
getView().printStatusNormal("File exists, resuming download...");
|
getView().printStatusNormal("File exists, resuming download...");
|
||||||
|
|
||||||
long max_size = calculateMaxTempFileSize(_file.length());
|
long max_size = calculateMaxTempFileSize(_file.length());
|
||||||
|
|
||||||
if(max_size != _file.length())
|
if (max_size != _file.length()) {
|
||||||
{
|
|
||||||
getView().printStatusNormal("Truncating temp file...");
|
getView().printStatusNormal("Truncating temp file...");
|
||||||
|
|
||||||
try (FileChannel out_truncate = new FileOutputStream(filename+".mctemp", true).getChannel())
|
try (FileChannel out_truncate = new FileOutputStream(filename + ".mctemp", true).getChannel()) {
|
||||||
{
|
|
||||||
out_truncate.truncate(max_size);
|
out_truncate.truncate(max_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_progress = _file.length();
|
_progress = _file.length();
|
||||||
swingReflectionInvoke("setValue", getView().getProgress_pbar(), (int) ceil(_progress_bar_rate * _progress));
|
swingReflectionInvoke("setValue", getView().getProgress_pbar(), (int) ceil(_progress_bar_rate * _progress));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
_progress = 0;
|
_progress = 0;
|
||||||
swingReflectionInvoke("setValue", getView().getProgress_pbar(), 0);
|
swingReflectionInvoke("setValue", getView().getProgress_pbar(), 0);
|
||||||
}
|
}
|
||||||
@ -485,8 +470,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
if (_use_slots) {
|
if (_use_slots) {
|
||||||
|
|
||||||
for(int t=1; t <= _slots; t++)
|
for (int t = 1; t <= _slots; t++) {
|
||||||
{
|
|
||||||
ChunkDownloader c = new ChunkDownloader(t, this);
|
ChunkDownloader c = new ChunkDownloader(t, this);
|
||||||
|
|
||||||
_chunkworkers.add(c);
|
_chunkworkers.add(c);
|
||||||
@ -524,7 +508,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
|
|
||||||
out.println("Chunkdownloaders finished!");
|
System.out.println("Chunkdownloaders finished!");
|
||||||
|
|
||||||
getSpeed_meter().setExit(true);
|
getSpeed_meter().setExit(true);
|
||||||
|
|
||||||
@ -536,18 +520,24 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
_thread_pool.shutdown();
|
_thread_pool.shutdown();
|
||||||
|
|
||||||
while(!_thread_pool.isTerminated())
|
while (!_thread_pool.isTerminated()) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
_thread_pool.awaitTermination(MAX_VALUE, DAYS);
|
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.println("Downloader thread pool finished!");
|
if (!_thread_pool.isTerminated()) {
|
||||||
|
|
||||||
|
System.out.println("Cerrando thread pool a lo mecagüen...");
|
||||||
|
|
||||||
|
_thread_pool.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Downloader thread pool finished!");
|
||||||
|
|
||||||
getMain_panel().getGlobal_dl_speed().detachSpeedMeter(getSpeed_meter());
|
getMain_panel().getGlobal_dl_speed().detachSpeedMeter(getSpeed_meter());
|
||||||
|
|
||||||
@ -557,11 +547,9 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
swingReflectionInvoke("setVisible", new Object[]{getView().getSpeed_label(), getView().getRemtime_label(), getView().getPause_button(), getView().getStop_button(), getView().getSlots_label(), getView().getSlots_spinner(), getView().getKeep_temp_checkbox()}, false);
|
swingReflectionInvoke("setVisible", new Object[]{getView().getSpeed_label(), getView().getRemtime_label(), getView().getPause_button(), getView().getStop_button(), getView().getSlots_label(), getView().getSlots_spinner(), getView().getKeep_temp_checkbox()}, false);
|
||||||
|
|
||||||
|
|
||||||
getMain_panel().getDownload_manager().secureNotify();
|
getMain_panel().getDownload_manager().secureNotify();
|
||||||
|
|
||||||
if(_progress == _file_size)
|
if (_progress == _file_size) {
|
||||||
{
|
|
||||||
if (_file.length() != _file_size) {
|
if (_file.length() != _file_size) {
|
||||||
|
|
||||||
throw new IOException("El tamaño del fichero es incorrecto!");
|
throw new IOException("El tamaño del fichero es incorrecto!");
|
||||||
@ -573,8 +561,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
String verify_file = selectSettingValueFromDB("verify_down_file");
|
String verify_file = selectSettingValueFromDB("verify_down_file");
|
||||||
|
|
||||||
if(verify_file!=null && verify_file.equals("yes"))
|
if (verify_file != null && verify_file.equals("yes")) {
|
||||||
{
|
|
||||||
_checking_cbc = true;
|
_checking_cbc = true;
|
||||||
|
|
||||||
getView().printStatusNormal("Waiting to check file integrity...");
|
getView().printStatusNormal("Waiting to check file integrity...");
|
||||||
@ -595,22 +582,17 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
getMain_panel().getDownload_manager().secureNotify();
|
getMain_panel().getDownload_manager().secureNotify();
|
||||||
|
|
||||||
if(verifyFileCBCMAC(filename))
|
if (verifyFileCBCMAC(filename)) {
|
||||||
{
|
|
||||||
exit_message = "File successfully downloaded! (Integrity check PASSED)";
|
exit_message = "File successfully downloaded! (Integrity check PASSED)";
|
||||||
|
|
||||||
getView().printStatusOK(exit_message);
|
getView().printStatusOK(exit_message);
|
||||||
}
|
} else if (!_exit) {
|
||||||
else if(!_exit)
|
|
||||||
{
|
|
||||||
exit_message = "BAD NEWS :( File is DAMAGED!";
|
exit_message = "BAD NEWS :( File is DAMAGED!";
|
||||||
|
|
||||||
getView().printStatusError(exit_message);
|
getView().printStatusError(exit_message);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
exit_message = "File successfully downloaded! (but integrity check CANCELED)";
|
exit_message = "File successfully downloaded! (but integrity check CANCELED)";
|
||||||
|
|
||||||
getView().printStatusOK(exit_message);
|
getView().printStatusOK(exit_message);
|
||||||
@ -624,17 +606,13 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
swingReflectionInvoke("setValue", getView().getProgress_pbar(), MAX_VALUE);
|
swingReflectionInvoke("setValue", getView().getProgress_pbar(), MAX_VALUE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
exit_message = "File successfully downloaded!";
|
exit_message = "File successfully downloaded!";
|
||||||
|
|
||||||
getView().printStatusOK(exit_message);
|
getView().printStatusOK(exit_message);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else if (_exit && _fatal_error == null) {
|
||||||
else if(_exit && _fatal_error == null)
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
exit_message = "Download CANCELED!";
|
exit_message = "Download CANCELED!";
|
||||||
@ -647,19 +625,14 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
_file.delete();
|
_file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (_fatal_error != null) {
|
||||||
else if(_fatal_error != null)
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
getView().printStatusError(_fatal_error);
|
getView().printStatusError(_fatal_error);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
exit_message = "OOOPS!! Something (bad) happened but... what?";
|
exit_message = "OOOPS!! Something (bad) happened but... what?";
|
||||||
@ -670,19 +643,13 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (_fatal_error != null) {
|
||||||
|
|
||||||
}
|
|
||||||
else if(_fatal_error != null)
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
getView().printStatusError(_fatal_error);
|
getView().printStatusError(_fatal_error);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
exit_message = "Download CANCELED!";
|
exit_message = "Download CANCELED!";
|
||||||
@ -709,17 +676,13 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (_fatal_error != null) {
|
||||||
else if(_fatal_error != null)
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
getView().printStatusError(_fatal_error);
|
getView().printStatusError(_fatal_error);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
exit_message = "Download CANCELED!";
|
exit_message = "Download CANCELED!";
|
||||||
@ -732,18 +695,17 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
_file.delete();
|
_file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex) {
|
|
||||||
exit_message = "I/O ERROR " + ex.getMessage();
|
exit_message = "I/O ERROR " + ex.getMessage();
|
||||||
|
|
||||||
getView().printStatusError(exit_message);
|
getView().printStatusError(exit_message);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
|
|
||||||
out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_exit) {
|
if (!_exit) {
|
||||||
@ -771,7 +733,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
swingReflectionInvoke("setVisible", getView().getRestart_button(), true);
|
swingReflectionInvoke("setVisible", getView().getRestart_button(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.println(_file_name+" Downloader: bye bye");
|
System.out.println(_file_name + " Downloader: bye bye");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void provisionIt(boolean retry) throws MegaAPIException, MegaCrypterAPIException {
|
public void provisionIt(boolean retry) throws MegaAPIException, MegaCrypterAPIException {
|
||||||
@ -785,8 +747,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
String exit_message = null;
|
String exit_message = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(_file_name == null)
|
if (_file_name == null) {
|
||||||
{
|
|
||||||
file_info = getMegaFileMetadata(_url, getMain_panel().getView(), retry);
|
file_info = getMegaFileMetadata(_url, getMain_panel().getView(), retry);
|
||||||
|
|
||||||
if (file_info == null) {
|
if (file_info == null) {
|
||||||
@ -801,8 +762,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
_file_key = file_info[2];
|
_file_key = file_info[2];
|
||||||
|
|
||||||
if(file_info.length == 5)
|
if (file_info.length == 5) {
|
||||||
{
|
|
||||||
_file_pass = file_info[3];
|
_file_pass = file_info[3];
|
||||||
|
|
||||||
_file_noexpire = file_info[4];
|
_file_noexpire = file_info[4];
|
||||||
@ -895,10 +855,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized String getDownloadUrlForWorker() throws IOException {
|
||||||
|
|
||||||
public synchronized String getDownloadUrlForWorker() throws IOException
|
|
||||||
{
|
|
||||||
if (_last_download_url != null && checkMegaDownloadUrl(_last_download_url)) {
|
if (_last_download_url != null && checkMegaDownloadUrl(_last_download_url)) {
|
||||||
|
|
||||||
return _last_download_url;
|
return _last_download_url;
|
||||||
@ -915,14 +872,11 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", _url, 0) != null )
|
if (findFirstRegex("://mega(\\.co)?\\.nz/", _url, 0) != null) {
|
||||||
{
|
|
||||||
MegaAPI ma = new MegaAPI();
|
MegaAPI ma = new MegaAPI();
|
||||||
|
|
||||||
download_url = ma.getMegaFileDownloadUrl(_url);
|
download_url = ma.getMegaFileDownloadUrl(_url);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
download_url = MegaCrypterAPI.getMegaFileDownloadUrl(_url, _file_pass, _file_noexpire);
|
download_url = MegaCrypterAPI.getMegaFileDownloadUrl(_url, _file_pass, _file_noexpire);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,11 +893,11 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
for(long i=getWaitTimeExpBackOff(api_error_retry++); i>0 && !_exit; i--)
|
for (long i = getWaitTimeExpBackOff(api_error_retry++); i > 0 && !_exit; i--) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
} catch (InterruptedException ex) {}
|
} catch (InterruptedException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,8 +906,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
return _last_download_url;
|
return _last_download_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void startSlot()
|
public synchronized void startSlot() {
|
||||||
{
|
|
||||||
|
|
||||||
int chunk_id = _chunkworkers.size() + 1;
|
int chunk_id = _chunkworkers.size() + 1;
|
||||||
|
|
||||||
@ -965,11 +918,12 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
_thread_pool.execute(c);
|
_thread_pool.execute(c);
|
||||||
|
|
||||||
}catch(java.util.concurrent.RejectedExecutionException e){out.println(e.getMessage());}
|
} catch (java.util.concurrent.RejectedExecutionException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stopLastStartedSlot()
|
public synchronized void stopLastStartedSlot() {
|
||||||
{
|
|
||||||
if (!_chunkworkers.isEmpty()) {
|
if (!_chunkworkers.isEmpty()) {
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", getView().getSlots_spinner(), false);
|
swingReflectionInvoke("setEnabled", getView().getSlots_spinner(), false);
|
||||||
@ -998,10 +952,8 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stopThisSlot(ChunkDownloader chunkdownloader)
|
public synchronized void stopThisSlot(ChunkDownloader chunkdownloader) {
|
||||||
{
|
if (_chunkworkers.remove(chunkdownloader)) {
|
||||||
if(_chunkworkers.remove(chunkdownloader))
|
|
||||||
{
|
|
||||||
if (!chunkdownloader.isExit()) {
|
if (!chunkdownloader.isExit()) {
|
||||||
|
|
||||||
_finishing_download = true;
|
_finishing_download = true;
|
||||||
@ -1028,9 +980,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean verifyFileCBCMAC(String filename) throws FileNotFoundException, Exception, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
|
||||||
private boolean verifyFileCBCMAC(String filename) throws FileNotFoundException, Exception, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException
|
|
||||||
{
|
|
||||||
int[] int_key = bin2i32a(UrlBASE642Bin(_file_key));
|
int[] int_key = bin2i32a(UrlBASE642Bin(_file_key));
|
||||||
|
|
||||||
int[] iv = new int[2];
|
int[] iv = new int[2];
|
||||||
@ -1057,18 +1007,15 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
byte[] byte_block = new byte[16];
|
byte[] byte_block = new byte[16];
|
||||||
int[] int_block;
|
int[] int_block;
|
||||||
int re, reads, to_read;
|
int re, reads, to_read;
|
||||||
try
|
try {
|
||||||
{
|
while (!_exit) {
|
||||||
while(!_exit)
|
|
||||||
{
|
|
||||||
Chunk chunk = new Chunk(chunk_id++, _file_size, null);
|
Chunk chunk = new Chunk(chunk_id++, _file_size, null);
|
||||||
|
|
||||||
tot += chunk.getSize();
|
tot += chunk.getSize();
|
||||||
|
|
||||||
int[] chunk_mac = {iv[0], iv[1], iv[0], iv[1]};
|
int[] chunk_mac = {iv[0], iv[1], iv[0], iv[1]};
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
to_read = chunk.getSize() - chunk.getOutputStream().size() >= chunk_buffer.length ? chunk_buffer.length : (int) (chunk.getSize() - chunk.getOutputStream().size());
|
to_read = chunk.getSize() - chunk.getOutputStream().size() >= chunk_buffer.length ? chunk_buffer.length : (int) (chunk.getSize() - chunk.getOutputStream().size());
|
||||||
|
|
||||||
re = is.read(chunk_buffer, 0, to_read);
|
re = is.read(chunk_buffer, 0, to_read);
|
||||||
@ -1079,26 +1026,23 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
InputStream chunk_is = chunk.getInputStream();
|
InputStream chunk_is = chunk.getInputStream();
|
||||||
|
|
||||||
while(!_exit && (reads=chunk_is.read(byte_block))!=-1)
|
while (!_exit && (reads = chunk_is.read(byte_block)) != -1) {
|
||||||
{
|
if (reads < byte_block.length) {
|
||||||
if(reads<byte_block.length)
|
for (int i = reads; i < byte_block.length; i++) {
|
||||||
{
|
|
||||||
for(int i=reads; i<byte_block.length; i++)
|
|
||||||
byte_block[i] = 0;
|
byte_block[i] = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int_block = bin2i32a(byte_block);
|
int_block = bin2i32a(byte_block);
|
||||||
|
|
||||||
for(int i=0; i<chunk_mac.length; i++)
|
for (int i = 0; i < chunk_mac.length; i++) {
|
||||||
{
|
|
||||||
chunk_mac[i] ^= int_block[i];
|
chunk_mac[i] ^= int_block[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_mac = bin2i32a(cryptor.doFinal(i32a2bin(chunk_mac)));
|
chunk_mac = bin2i32a(cryptor.doFinal(i32a2bin(chunk_mac)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<file_mac.length; i++)
|
for (int i = 0; i < file_mac.length; i++) {
|
||||||
{
|
|
||||||
file_mac[i] ^= chunk_mac[i];
|
file_mac[i] ^= chunk_mac[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,7 +1052,8 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ChunkInvalidIdException e){}
|
} catch (ChunkInvalidIdException e) {
|
||||||
|
}
|
||||||
|
|
||||||
int[] cbc = {file_mac[0] ^ file_mac[1], file_mac[2] ^ file_mac[3]};
|
int[] cbc = {file_mac[0] ^ file_mac[1], file_mac[2] ^ file_mac[3]};
|
||||||
|
|
||||||
@ -1117,10 +1062,8 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stopDownloader()
|
public synchronized void stopDownloader() {
|
||||||
{
|
if (!_exit) {
|
||||||
if(!_exit)
|
|
||||||
{
|
|
||||||
setExit(true);
|
setExit(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1139,20 +1082,15 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
getMain_panel().getDownload_manager().secureNotify();
|
getMain_panel().getDownload_manager().secureNotify();
|
||||||
|
|
||||||
if(isRetrying_request())
|
if (isRetrying_request()) {
|
||||||
{
|
|
||||||
getView().printStatusNormal("Retrying cancelled!");
|
getView().printStatusNormal("Retrying cancelled!");
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", getView().getStop_button(), false);
|
swingReflectionInvoke("setEnabled", getView().getStop_button(), false);
|
||||||
}
|
} else if (isChecking_cbc()) {
|
||||||
else if(isChecking_cbc())
|
|
||||||
{
|
|
||||||
getView().printStatusNormal("Verification cancelled!");
|
getView().printStatusNormal("Verification cancelled!");
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", getView().getStop_button(), false);
|
swingReflectionInvoke("setEnabled", getView().getStop_button(), false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().stop();
|
getView().stop();
|
||||||
|
|
||||||
for (ChunkDownloader downloader : _chunkworkers) {
|
for (ChunkDownloader downloader : _chunkworkers) {
|
||||||
@ -1163,30 +1101,23 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void emergencyStopDownloader(String reason)
|
public synchronized void emergencyStopDownloader(String reason) {
|
||||||
{
|
if (_fatal_error == null) {
|
||||||
if(_fatal_error == null)
|
|
||||||
{
|
|
||||||
_fatal_error = reason != null ? reason : "FATAL ERROR!";
|
_fatal_error = reason != null ? reason : "FATAL ERROR!";
|
||||||
|
|
||||||
stopDownloader();
|
stopDownloader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long calculateMaxTempFileSize(long size)
|
public long calculateMaxTempFileSize(long size) {
|
||||||
{
|
if (size > 3584 * 1024) {
|
||||||
if(size > 3584*1024)
|
|
||||||
{
|
|
||||||
long reminder = (size - 3584 * 1024) % (1024 * 1024);
|
long reminder = (size - 3584 * 1024) % (1024 * 1024);
|
||||||
|
|
||||||
return reminder == 0 ? size : (size - reminder);
|
return reminder == 0 ? size : (size - reminder);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int i = 0, tot = 0;
|
int i = 0, tot = 0;
|
||||||
|
|
||||||
while(tot < size)
|
while (tot < size) {
|
||||||
{
|
|
||||||
i++;
|
i++;
|
||||||
tot += i * 128 * 1024;
|
tot += i * 128 * 1024;
|
||||||
}
|
}
|
||||||
@ -1195,42 +1126,31 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getMegaFileMetadata(String link, MainPanelView panel, boolean retry_request) throws IOException, InterruptedException, MegaAPIException, MegaCrypterAPIException {
|
||||||
|
|
||||||
public String[] getMegaFileMetadata(String link, MainPanelView panel, boolean retry_request) throws IOException, InterruptedException, MegaAPIException,MegaCrypterAPIException
|
|
||||||
{
|
|
||||||
|
|
||||||
String[] file_info = null;
|
String[] file_info = null;
|
||||||
int retry = 0, error_code;
|
int retry = 0, error_code;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
|
|
||||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null)
|
if (findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null) {
|
||||||
{
|
|
||||||
MegaAPI ma = new MegaAPI();
|
MegaAPI ma = new MegaAPI();
|
||||||
|
|
||||||
file_info = ma.getMegaFileMetadata(link);
|
file_info = ma.getMegaFileMetadata(link);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel);
|
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
||||||
catch(MegaAPIException | MegaCrypterAPIException ex)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
error_code = parseInt(ex.getMessage());
|
error_code = parseInt(ex.getMessage());
|
||||||
|
|
||||||
switch(error_code)
|
switch (error_code) {
|
||||||
{
|
|
||||||
case -2:
|
case -2:
|
||||||
emergencyStopDownloader("Mega link is not valid!");
|
emergencyStopDownloader("Mega link is not valid!");
|
||||||
break;
|
break;
|
||||||
@ -1270,20 +1190,17 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
swingReflectionInvoke("setText", getView().getStop_button(), "CANCEL RETRY");
|
swingReflectionInvoke("setText", getView().getStop_button(), "CANCEL RETRY");
|
||||||
|
|
||||||
for(long i=getWaitTimeExpBackOff(retry++); i>0 && !_exit; i--)
|
for (long i = getWaitTimeExpBackOff(retry++); i > 0 && !_exit; i--) {
|
||||||
{
|
if (error_code == -18) {
|
||||||
if(error_code == -18)
|
|
||||||
{
|
|
||||||
getView().printStatusError("File temporarily unavailable! (Retrying in " + i + " secs...)");
|
getView().printStatusError("File temporarily unavailable! (Retrying in " + i + " secs...)");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().printStatusError("Mega/MC APIException error " + ex.getMessage() + " (Retrying in " + i + " secs...)");
|
getView().printStatusError("Mega/MC APIException error " + ex.getMessage() + " (Retrying in " + i + " secs...)");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
} catch (InterruptedException ex2) {}
|
} catch (InterruptedException ex2) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -1299,44 +1216,33 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
return file_info;
|
return file_info;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMegaFileDownloadUrl(String link) throws IOException, InterruptedException
|
public String getMegaFileDownloadUrl(String link) throws IOException, InterruptedException {
|
||||||
{
|
|
||||||
|
|
||||||
String dl_url = null;
|
String dl_url = null;
|
||||||
int retry = 0, error_code;
|
int retry = 0, error_code;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (findFirstRegex("://mega(\\.co)?\\.nz/", _url, 0) != null) {
|
||||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", _url, 0) != null)
|
|
||||||
{
|
|
||||||
MegaAPI ma = new MegaAPI();
|
MegaAPI ma = new MegaAPI();
|
||||||
|
|
||||||
dl_url = ma.getMegaFileDownloadUrl(link);
|
dl_url = ma.getMegaFileDownloadUrl(link);
|
||||||
|
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, _file_pass, _file_noexpire);
|
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, _file_pass, _file_noexpire);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
||||||
catch(MegaAPIException | MegaCrypterAPIException ex)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
error_code = parseInt(ex.getMessage());
|
error_code = parseInt(ex.getMessage());
|
||||||
|
|
||||||
switch(error_code)
|
switch (error_code) {
|
||||||
{
|
|
||||||
case 22:
|
case 22:
|
||||||
emergencyStopDownloader("MegaCrypter link is not valid!");
|
emergencyStopDownloader("MegaCrypter link is not valid!");
|
||||||
break;
|
break;
|
||||||
@ -1357,20 +1263,17 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
|
|
||||||
swingReflectionInvoke("setText", getView().getStop_button(), "CANCEL RETRY");
|
swingReflectionInvoke("setText", getView().getStop_button(), "CANCEL RETRY");
|
||||||
|
|
||||||
for(long i=getWaitTimeExpBackOff(retry++); i>0 && !_exit; i--)
|
for (long i = getWaitTimeExpBackOff(retry++); i > 0 && !_exit; i--) {
|
||||||
{
|
if (error_code == -18) {
|
||||||
if(error_code == -18)
|
|
||||||
{
|
|
||||||
getView().printStatusError("File temporarily unavailable! (Retrying in " + i + " secs...)");
|
getView().printStatusError("File temporarily unavailable! (Retrying in " + i + " secs...)");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().printStatusError("Mega/MC APIException error " + ex.getMessage() + " (Retrying in " + i + " secs...)");
|
getView().printStatusError("Mega/MC APIException error " + ex.getMessage() + " (Retrying in " + i + " secs...)");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
} catch (InterruptedException ex2) {}
|
} catch (InterruptedException ex2) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1385,27 +1288,22 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
return dl_url;
|
return dl_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized long nextChunkId() {
|
||||||
public synchronized long nextChunkId()
|
|
||||||
{
|
|
||||||
Long next_id;
|
Long next_id;
|
||||||
|
|
||||||
if ((next_id = _rejectedChunkIds.poll()) != null) {
|
if ((next_id = _rejectedChunkIds.poll()) != null) {
|
||||||
return next_id;
|
return next_id;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return ++_last_chunk_id_dispatched;
|
return ++_last_chunk_id_dispatched;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rejectChunkId(long chunk_id)
|
public void rejectChunkId(long chunk_id) {
|
||||||
{
|
|
||||||
_rejectedChunkIds.add(chunk_id);
|
_rejectedChunkIds.add(chunk_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -1417,8 +1315,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1451,6 +1348,4 @@ public final class Download implements Transference, Runnable, SecureNotifiable
|
|||||||
getView().updateProgressBar(_progress, _progress_bar_rate);
|
getView().updateProgressBar(_progress, _progress_bar_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,7 +7,6 @@ import static java.util.logging.Logger.getLogger;
|
|||||||
import static megabasterd.DBTools.deleteDownload;
|
import static megabasterd.DBTools.deleteDownload;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
|
|
||||||
|
|
||||||
public final class DownloadManager extends TransferenceManager {
|
public final class DownloadManager extends TransferenceManager {
|
||||||
|
|
||||||
public DownloadManager(MainPanel main_panel) {
|
public DownloadManager(MainPanel main_panel) {
|
||||||
@ -39,8 +38,7 @@ public final class DownloadManager extends TransferenceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void provision(final Transference download)
|
public void provision(final Transference download) {
|
||||||
{
|
|
||||||
getScroll_panel().add(((Download) download).getView());
|
getScroll_panel().add(((Download) download).getView());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -68,7 +66,8 @@ public final class DownloadManager extends TransferenceManager {
|
|||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,10 @@ import javax.swing.JSpinner;
|
|||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
import static megabasterd.MiscTools.copyTextToClipboard;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
|
|
||||||
public final class DownloadView extends javax.swing.JPanel implements TransferenceView {
|
public final class DownloadView extends javax.swing.JPanel implements TransferenceView {
|
||||||
|
|
||||||
private final Download _download;
|
private final Download _download;
|
||||||
@ -105,8 +103,9 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
updateFont(close_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(close_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(copy_link_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(copy_link_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(restart_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(restart_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(slot_status_label, FONT_DEFAULT, Font.BOLD);}}, true);
|
updateFont(slot_status_label, FONT_DEFAULT, Font.BOLD);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setModel", slots_spinner, new SpinnerNumberModel(_download.getMain_panel().getDefault_slots_down(), Download.MIN_WORKERS, Download.MAX_WORKERS, 1));
|
swingReflectionInvokeAndWait("setModel", slots_spinner, new SpinnerNumberModel(_download.getMain_panel().getDefault_slots_down(), Download.MIN_WORKERS, Download.MAX_WORKERS, 1));
|
||||||
|
|
||||||
@ -118,8 +117,7 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideAllExceptStatus()
|
public void hideAllExceptStatus() {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setVisible", new Object[]{speed_label, remtime_label, slots_spinner, slots_label, slot_status_label, slot_status_label, pause_button, stop_button, progress_pbar, keep_temp_checkbox}, false);
|
swingReflectionInvoke("setVisible", new Object[]{speed_label, remtime_label, slots_spinner, slots_label, slot_status_label, slot_status_label, pause_button, stop_button, progress_pbar, keep_temp_checkbox}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +333,6 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
});
|
});
|
||||||
}//GEN-LAST:event_slots_spinnerStateChanged
|
}//GEN-LAST:event_slots_spinnerStateChanged
|
||||||
|
|
||||||
|
|
||||||
private void close_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_close_buttonActionPerformed
|
private void close_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_close_buttonActionPerformed
|
||||||
|
|
||||||
_download.close();
|
_download.close();
|
||||||
@ -343,7 +340,7 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
|
|
||||||
private void copy_link_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copy_link_buttonActionPerformed
|
private void copy_link_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copy_link_buttonActionPerformed
|
||||||
|
|
||||||
copyTextToClipboard(_download.getUrl());
|
MiscTools.copyTextToClipboard(_download.getUrl());
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(_download.getMain_panel().getView(), "Link was copied to clipboard!");
|
JOptionPane.showMessageDialog(_download.getMain_panel().getView(), "Link was copied to clipboard!");
|
||||||
}//GEN-LAST:event_copy_link_buttonActionPerformed
|
}//GEN-LAST:event_copy_link_buttonActionPerformed
|
||||||
@ -393,7 +390,6 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
swingReflectionInvoke("setEnabled", new Object[]{pause_button, keep_temp_checkbox, stop_button, speed_label, slots_label, slots_spinner}, false);
|
swingReflectionInvoke("setEnabled", new Object[]{pause_button, keep_temp_checkbox, stop_button, speed_label, slots_label, slots_spinner}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSpeed(String speed, Boolean visible) {
|
public void updateSpeed(String speed, Boolean visible) {
|
||||||
|
|
||||||
@ -430,22 +426,19 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printStatusError(String message)
|
public void printStatusError(String message) {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", status_label, Color.red);
|
swingReflectionInvoke("setForeground", status_label, Color.red);
|
||||||
swingReflectionInvoke("setText", status_label, message);
|
swingReflectionInvoke("setText", status_label, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printStatusOK(String message)
|
public void printStatusOK(String message) {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", status_label, new Color(0, 128, 0));
|
swingReflectionInvoke("setForeground", status_label, new Color(0, 128, 0));
|
||||||
swingReflectionInvoke("setText", status_label, message);
|
swingReflectionInvoke("setText", status_label, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printStatusNormal(String message)
|
public void printStatusNormal(String message) {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", status_label, Color.BLACK);
|
swingReflectionInvoke("setForeground", status_label, Color.BLACK);
|
||||||
swingReflectionInvoke("setText", status_label, message);
|
swingReflectionInvoke("setText", status_label, message);
|
||||||
}
|
}
|
||||||
@ -504,6 +497,4 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
private javax.swing.JButton stop_button;
|
private javax.swing.JButton stop_button;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ import javax.swing.JFileChooser;
|
|||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
import javax.swing.tree.TreeModel;
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
import static megabasterd.MiscTools.BASE642Bin;
|
||||||
@ -70,6 +72,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form FileGrabber
|
* Creates new form FileGrabber
|
||||||
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param modal
|
* @param modal
|
||||||
*/
|
*/
|
||||||
@ -89,7 +92,8 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(dance_button, FONT_DEFAULT, Font.PLAIN);
|
public void run() {
|
||||||
|
updateFont(dance_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(add_files_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(add_files_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(add_folder_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(add_folder_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(account_combobox, FONT_DEFAULT, Font.PLAIN);
|
updateFont(account_combobox, FONT_DEFAULT, Font.PLAIN);
|
||||||
@ -101,7 +105,9 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
updateFont(warning_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(warning_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(dir_name_textfield, FONT_DEFAULT, Font.PLAIN);
|
updateFont(dir_name_textfield, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(skip_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(skip_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(skip_rest_button, FONT_DEFAULT, Font.PLAIN);}}, true);
|
updateFont(skip_rest_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("addMouseListener", dir_name_textfield, new ContextMenuMouseListener());
|
swingReflectionInvokeAndWait("addMouseListener", dir_name_textfield, new ContextMenuMouseListener());
|
||||||
|
|
||||||
@ -111,7 +117,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
for (Object o : _main_panel.getMega_accounts().keySet()) {
|
for (Object o : _main_panel.getMega_accounts().keySet()) {
|
||||||
|
|
||||||
swingReflectionInvoke("addItem", account_combobox, (String)o);
|
swingReflectionInvoke("addItem", account_combobox, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -356,7 +362,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
dir_name_textfield.setEnabled(false);
|
dir_name_textfield.setEnabled(false);
|
||||||
dir_name_label.setEnabled(false);
|
dir_name_label.setEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
JFileChooser filechooser = new javax.swing.JFileChooser();
|
JFileChooser filechooser = new javax.swing.JFileChooser();
|
||||||
|
|
||||||
filechooser.setDialogTitle("Add files");
|
filechooser.setDialogTitle("Add files");
|
||||||
@ -402,7 +407,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
add_files_button.setText("Add files");
|
add_files_button.setText("Add files");
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)tree_model.getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) tree_model.getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
file_tree.setRootVisible(root_childs);
|
file_tree.setRootVisible(root_childs);
|
||||||
file_tree.setEnabled(root_childs);
|
file_tree.setEnabled(root_childs);
|
||||||
@ -477,7 +482,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
add_folder_button.setText("Add folder");
|
add_folder_button.setText("Add folder");
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)tree_model.getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) tree_model.getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
file_tree.setRootVisible(root_childs);
|
file_tree.setRootVisible(root_childs);
|
||||||
|
|
||||||
@ -525,7 +530,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
used_space_label.setForeground(Color.black);
|
used_space_label.setForeground(Color.black);
|
||||||
|
|
||||||
|
|
||||||
used_space_label.setText("Checking account quota, please wait...");
|
used_space_label.setText("Checking account quota, please wait...");
|
||||||
|
|
||||||
account_combobox.setEnabled(false);
|
account_combobox.setEnabled(false);
|
||||||
@ -540,7 +544,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
warning_label.setEnabled(false);
|
warning_label.setEnabled(false);
|
||||||
file_tree.setEnabled(false);
|
file_tree.setEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
THREAD_POOL.execute(new Runnable() {
|
THREAD_POOL.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -549,7 +552,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
Long[] quota = null;
|
Long[] quota = null;
|
||||||
|
|
||||||
MegaAPI ma = _main_panel.getMega_active_accounts().get((String)account_combobox.getSelectedItem());
|
MegaAPI ma = _main_panel.getMega_active_accounts().get(account_combobox.getSelectedItem());
|
||||||
|
|
||||||
if (ma == null) {
|
if (ma == null) {
|
||||||
|
|
||||||
@ -616,7 +619,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
quota = ma.getQuota();
|
quota = ma.getQuota();
|
||||||
@ -637,7 +639,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
swingReflectionInvoke("setForeground", used_space_label, Color.red);
|
swingReflectionInvoke("setForeground", used_space_label, Color.red);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)((DefaultTreeModel)swingReflectionInvokeAndWaitForReturn("getModel", file_tree)).getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) ((TreeModel) swingReflectionInvokeAndWaitForReturn("getModel", file_tree)).getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
swingReflectionInvoke("setText", used_space_label, formatBytes(quota[0]) + " / " + formatBytes(quota[1]));
|
swingReflectionInvoke("setText", used_space_label, formatBytes(quota[0]) + " / " + formatBytes(quota[1]));
|
||||||
|
|
||||||
@ -645,7 +647,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEnabled", new Object[]{dir_name_textfield, dir_name_label, warning_label, dance_button, file_tree, total_file_size_label, skip_button, skip_rest_button}, root_childs);
|
swingReflectionInvoke("setEnabled", new Object[]{dir_name_textfield, dir_name_label, warning_label, dance_button, file_tree, total_file_size_label, skip_button, skip_rest_button}, root_childs);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
_last_selected_account = null;
|
_last_selected_account = null;
|
||||||
@ -661,7 +662,8 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
swingReflectionInvoke("setText", used_space_label, "ERROR checking account quota!");
|
swingReflectionInvoke("setText", used_space_label, "ERROR checking account quota!");
|
||||||
}
|
}
|
||||||
|
|
||||||
} });
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +675,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_genFileList();
|
_genFileList();
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)file_tree.getModel().getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
warning_label.setEnabled(root_childs);
|
warning_label.setEnabled(root_childs);
|
||||||
dance_button.setEnabled(root_childs);
|
dance_button.setEnabled(root_childs);
|
||||||
@ -697,7 +699,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_genFileList();
|
_genFileList();
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)file_tree.getModel().getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
warning_label.setEnabled(root_childs);
|
warning_label.setEnabled(root_childs);
|
||||||
dance_button.setEnabled(root_childs);
|
dance_button.setEnabled(root_childs);
|
||||||
@ -786,7 +788,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
total_file_size_label.setText("[" + formatBytes(_total_space) + "]");
|
total_file_size_label.setText("[" + formatBytes(_total_space) + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JComboBox<String> account_combobox;
|
private javax.swing.JComboBox<String> account_combobox;
|
||||||
private javax.swing.JLabel account_label;
|
private javax.swing.JLabel account_label;
|
||||||
|
@ -11,6 +11,8 @@ import static java.util.logging.Level.SEVERE;
|
|||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
import javax.swing.tree.TreeModel;
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
||||||
@ -51,9 +53,9 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
return _mega_error;
|
return _mega_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form FolderLink
|
* Creates new form FolderLink
|
||||||
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param link
|
* @param link
|
||||||
*/
|
*/
|
||||||
@ -72,7 +74,8 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(file_tree, FONT_DEFAULT, PLAIN);
|
public void run() {
|
||||||
|
updateFont(file_tree, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(link_detected_label, FONT_DEFAULT, PLAIN);
|
updateFont(link_detected_label, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(warning_label, FONT_DEFAULT, PLAIN);
|
updateFont(warning_label, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(skip_button, FONT_DEFAULT, PLAIN);
|
updateFont(skip_button, FONT_DEFAULT, PLAIN);
|
||||||
@ -80,9 +83,9 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
updateFont(restore_button, FONT_DEFAULT, PLAIN);
|
updateFont(restore_button, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(skip_rest_button, FONT_DEFAULT, PLAIN);
|
updateFont(skip_rest_button, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(total_space_label, FONT_DEFAULT, BOLD);
|
updateFont(total_space_label, FONT_DEFAULT, BOLD);
|
||||||
updateFont(folder_link_label, FONT_DEFAULT, PLAIN);}}, true);
|
updateFont(folder_link_label, FONT_DEFAULT, PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
swingReflectionInvoke("setText", folder_link_label, link);
|
swingReflectionInvoke("setText", folder_link_label, link);
|
||||||
|
|
||||||
@ -249,7 +252,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
restore_button.setVisible(true);
|
restore_button.setVisible(true);
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)file_tree.getModel().getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
dance_button.setEnabled(root_childs);
|
dance_button.setEnabled(root_childs);
|
||||||
|
|
||||||
@ -275,7 +278,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
restore_button.setVisible(true);
|
restore_button.setVisible(true);
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)file_tree.getModel().getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
dance_button.setEnabled(root_childs);
|
dance_button.setEnabled(root_childs);
|
||||||
|
|
||||||
@ -307,13 +310,12 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setText", restore_button, "Restore folder data");
|
swingReflectionInvoke("setText", restore_button, "Restore folder data");
|
||||||
|
|
||||||
boolean root_childs = ((DefaultMutableTreeNode)((DefaultTreeModel)swingReflectionInvokeAndWaitForReturn("getModel", file_tree)).getRoot()).getChildCount()>0;
|
boolean root_childs = ((TreeNode) ((TreeModel) swingReflectionInvokeAndWaitForReturn("getModel", file_tree)).getRoot()).getChildCount() > 0;
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", new Object[]{restore_button, dance_button, skip_button, skip_rest_button, file_tree}, root_childs);
|
swingReflectionInvoke("setEnabled", new Object[]{restore_button, dance_button, skip_button, skip_rest_button, file_tree}, root_childs);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}});
|
|
||||||
|
|
||||||
}//GEN-LAST:event_restore_buttonActionPerformed
|
}//GEN-LAST:event_restore_buttonActionPerformed
|
||||||
|
|
||||||
@ -392,7 +394,6 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEnabled", file_tree, true);
|
swingReflectionInvoke("setEnabled", file_tree, true);
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
getLogger(FolderLinkDialog.class.getName()).log(SEVERE, null, ex);
|
getLogger(FolderLinkDialog.class.getName()).log(SEVERE, null, ex);
|
||||||
@ -408,7 +409,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_download_links.clear();
|
_download_links.clear();
|
||||||
|
|
||||||
MegaMutableTreeNode root = (MegaMutableTreeNode)((DefaultTreeModel)swingReflectionInvokeAndWaitForReturn("getModel", file_tree)).getRoot();
|
MegaMutableTreeNode root = (MegaMutableTreeNode) ((TreeModel) swingReflectionInvokeAndWaitForReturn("getModel", file_tree)).getRoot();
|
||||||
|
|
||||||
Enumeration files_tree = root.depthFirstEnumeration();
|
Enumeration files_tree = root.depthFirstEnumeration();
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import static megabasterd.MiscTools.HashBin;
|
|||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -67,12 +66,14 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() { updateFont(ok_button, FONT_DEFAULT, Font.PLAIN);
|
public void run() {
|
||||||
|
updateFont(ok_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(cancel_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(cancel_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(please_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(please_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(status_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(status_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(remember_checkbox, FONT_DEFAULT, Font.PLAIN);}}, true);
|
updateFont(remember_checkbox, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
_current_pass_hash = current_pass_hash;
|
_current_pass_hash = current_pass_hash;
|
||||||
|
|
||||||
@ -206,7 +207,8 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
THREAD_POOL.execute(new Runnable() {
|
THREAD_POOL.execute(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {try {
|
public void run() {
|
||||||
|
try {
|
||||||
byte[] pass = CryptTools.PBKDF2HMACSHA256(new String(current_pass_textfield.getPassword()), MiscTools.BASE642Bin(_salt), CryptTools.PBKDF2_ITERATIONS);
|
byte[] pass = CryptTools.PBKDF2HMACSHA256(new String(current_pass_textfield.getPassword()), MiscTools.BASE642Bin(_salt), CryptTools.PBKDF2_ITERATIONS);
|
||||||
|
|
||||||
String pass_hash = Bin2BASE64(HashBin("SHA-1", pass));
|
String pass_hash = Bin2BASE64(HashBin("SHA-1", pass));
|
||||||
@ -221,7 +223,6 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("grabFocus", current_pass_textfield);
|
swingReflectionInvoke("grabFocus", current_pass_textfield);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
_pass = pass;
|
_pass = pass;
|
||||||
@ -235,7 +236,9 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(GetMegaMasterPasswordDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(GetMegaMasterPasswordDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}}});
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}//GEN-LAST:event_ok_buttonActionPerformed
|
}//GEN-LAST:event_ok_buttonActionPerformed
|
||||||
|
|
||||||
@ -247,7 +250,6 @@ public class GetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
}//GEN-LAST:event_current_pass_textfieldKeyPressed
|
}//GEN-LAST:event_current_pass_textfieldKeyPressed
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton cancel_button;
|
private javax.swing.JButton cancel_button;
|
||||||
private javax.swing.JPasswordField current_pass_textfield;
|
private javax.swing.JPasswordField current_pass_textfield;
|
||||||
|
@ -7,16 +7,14 @@ import javax.swing.JLabel;
|
|||||||
import static megabasterd.MiscTools.formatBytes;
|
import static megabasterd.MiscTools.formatBytes;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||||
|
|
||||||
public final class GlobalSpeedMeter implements Runnable, SecureNotifiable
|
public final class GlobalSpeedMeter implements Runnable, SecureNotifiable {
|
||||||
{
|
|
||||||
private final JLabel _speed_label;
|
private final JLabel _speed_label;
|
||||||
private final ConcurrentLinkedQueue<SpeedMeter> _speedmeters;
|
private final ConcurrentLinkedQueue<SpeedMeter> _speedmeters;
|
||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
|
|
||||||
|
GlobalSpeedMeter(JLabel sp_label) {
|
||||||
GlobalSpeedMeter(JLabel sp_label)
|
|
||||||
{
|
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_speed_label = sp_label;
|
_speed_label = sp_label;
|
||||||
@ -24,8 +22,7 @@ public final class GlobalSpeedMeter implements Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -37,8 +34,7 @@ public final class GlobalSpeedMeter implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -75,25 +71,21 @@ public final class GlobalSpeedMeter implements Runnable, SecureNotifiable
|
|||||||
|
|
||||||
long sp = 0;
|
long sp = 0;
|
||||||
|
|
||||||
for(SpeedMeter speed:_speedmeters)
|
for (SpeedMeter speed : _speedmeters) {
|
||||||
{
|
|
||||||
sp += speed.getLastSpeed();
|
sp += speed.getLastSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
long sp;
|
long sp;
|
||||||
|
|
||||||
swingReflectionInvoke("setText", _speed_label, "------");
|
swingReflectionInvoke("setText", _speed_label, "------");
|
||||||
swingReflectionInvoke("setVisible", _speed_label, true);
|
swingReflectionInvoke("setVisible", _speed_label, true);
|
||||||
|
|
||||||
while(true)
|
while (true) {
|
||||||
{
|
|
||||||
secureWait();
|
secureWait();
|
||||||
|
|
||||||
sp = calcSpeed();
|
sp = calcSpeed();
|
||||||
@ -102,9 +94,7 @@ public final class GlobalSpeedMeter implements Runnable, SecureNotifiable
|
|||||||
|
|
||||||
swingReflectionInvoke("setText", _speed_label, formatBytes(sp) + "/s");
|
swingReflectionInvoke("setText", _speed_label, formatBytes(sp) + "/s");
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
swingReflectionInvoke("setText", _speed_label, "------");
|
swingReflectionInvoke("setText", _speed_label, "------");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
|||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
|
||||||
|
|
||||||
public final class KissVideoStreamServer implements HttpHandler, SecureNotifiable {
|
public final class KissVideoStreamServer implements HttpHandler, SecureNotifiable {
|
||||||
|
|
||||||
public static final int WORKER_STATUS_FILE_INFO = 0x01;
|
public static final int WORKER_STATUS_FILE_INFO = 0x01;
|
||||||
@ -74,8 +73,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -87,8 +85,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -113,8 +110,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(int port, String context) throws IOException
|
public void start(int port, String context) throws IOException {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", _main_panel.getView().getKiss_server_status(), new Color(0, 128, 0));
|
swingReflectionInvoke("setForeground", _main_panel.getView().getKiss_server_status(), new Color(0, 128, 0));
|
||||||
|
|
||||||
swingReflectionInvoke("setText", _main_panel.getView().getKiss_server_status(), "Kissvideostreamer on localhost:" + STREAMER_PORT + " (Waiting for request...)");
|
swingReflectionInvoke("setText", _main_panel.getView().getKiss_server_status(), "Kissvideostreamer on localhost:" + STREAMER_PORT + " (Waiting for request...)");
|
||||||
@ -194,38 +190,29 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
swingReflectionInvoke("setText", _main_panel.getView().getKiss_server_status(), status);
|
swingReflectionInvoke("setText", _main_panel.getView().getKiss_server_status(), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getMegaFileMetadata(String link, MainPanelView panel) throws IOException, InterruptedException
|
private String[] getMegaFileMetadata(String link, MainPanelView panel) throws IOException, InterruptedException {
|
||||||
{
|
|
||||||
String[] file_info = null;
|
String[] file_info = null;
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
updateStatus(WORKER_STATUS_FILE_INFO);
|
updateStatus(WORKER_STATUS_FILE_INFO);
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null) {
|
||||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null)
|
|
||||||
{
|
|
||||||
MegaAPI ma = new MegaAPI();
|
MegaAPI ma = new MegaAPI();
|
||||||
|
|
||||||
file_info = ma.getMegaFileMetadata(link);
|
file_info = ma.getMegaFileMetadata(link);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel);
|
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (MegaAPIException | MegaCrypterAPIException e) {
|
||||||
catch(MegaAPIException | MegaCrypterAPIException e)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
switch(Integer.parseInt(e.getMessage()))
|
switch (Integer.parseInt(e.getMessage())) {
|
||||||
{
|
|
||||||
case -2:
|
case -2:
|
||||||
throw new IOException("Mega link is not valid!");
|
throw new IOException("Mega link is not valid!");
|
||||||
|
|
||||||
@ -245,11 +232,11 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
updateStatus(WORKER_STATUS_RETRY);
|
updateStatus(WORKER_STATUS_RETRY);
|
||||||
|
|
||||||
for(long i=getWaitTimeExpBackOff(retry++); i>0; i--)
|
for (long i = getWaitTimeExpBackOff(retry++); i > 0; i--) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ex) {}
|
} catch (InterruptedException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,43 +244,33 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} while (error);
|
} while (error);
|
||||||
|
|
||||||
return file_info;
|
return file_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMegaFileDownloadUrl(String link, String pass_hash, String noexpire_token) throws IOException, InterruptedException
|
private String getMegaFileDownloadUrl(String link, String pass_hash, String noexpire_token) throws IOException, InterruptedException {
|
||||||
{
|
|
||||||
String dl_url = null;
|
String dl_url = null;
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
updateStatus(WORKER_STATUS_FILE_INFO);
|
updateStatus(WORKER_STATUS_FILE_INFO);
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null) {
|
||||||
if( findFirstRegex("://mega(\\.co)?\\.nz/", link, 0) != null)
|
|
||||||
{
|
|
||||||
MegaAPI ma = new MegaAPI();
|
MegaAPI ma = new MegaAPI();
|
||||||
|
|
||||||
dl_url = ma.getMegaFileDownloadUrl(link);
|
dl_url = ma.getMegaFileDownloadUrl(link);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, pass_hash, noexpire_token);
|
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, pass_hash, noexpire_token);
|
||||||
}
|
}
|
||||||
}
|
} catch (MegaAPIException | MegaCrypterAPIException e) {
|
||||||
catch(MegaAPIException | MegaCrypterAPIException e)
|
|
||||||
{
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
switch(Integer.parseInt(e.getMessage()))
|
switch (Integer.parseInt(e.getMessage())) {
|
||||||
{
|
|
||||||
case 22:
|
case 22:
|
||||||
throw new IOException("MegaCrypter link is not valid!");
|
throw new IOException("MegaCrypter link is not valid!");
|
||||||
|
|
||||||
@ -307,11 +284,11 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
updateStatus(WORKER_STATUS_RETRY);
|
updateStatus(WORKER_STATUS_RETRY);
|
||||||
|
|
||||||
for(long i=getWaitTimeExpBackOff(retry++); i>0; i--)
|
for (long i = getWaitTimeExpBackOff(retry++); i > 0; i--) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ex) {}
|
} catch (InterruptedException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,22 +298,19 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
return dl_url;
|
return dl_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long[] parseRangeHeader(String header)
|
private long[] parseRangeHeader(String header) {
|
||||||
{
|
|
||||||
Pattern pattern = Pattern.compile("bytes\\=([0-9]+)\\-([0-9]+)?");
|
Pattern pattern = Pattern.compile("bytes\\=([0-9]+)\\-([0-9]+)?");
|
||||||
|
|
||||||
Matcher matcher = pattern.matcher(header);
|
Matcher matcher = pattern.matcher(header);
|
||||||
|
|
||||||
long[] ranges = new long[2];
|
long[] ranges = new long[2];
|
||||||
|
|
||||||
if(matcher.find())
|
if (matcher.find()) {
|
||||||
{
|
|
||||||
ranges[0] = Long.valueOf(matcher.group(1));
|
ranges[0] = Long.valueOf(matcher.group(1));
|
||||||
|
|
||||||
if (matcher.group(2) != null) {
|
if (matcher.group(2) != null) {
|
||||||
ranges[1] = Long.valueOf(matcher.group(2));
|
ranges[1] = Long.valueOf(matcher.group(2));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
ranges[1] = -1;
|
ranges[1] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,8 +318,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
return ranges;
|
return ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String cookRangeUrl(String url, long[] ranges, int sync_bytes)
|
private String cookRangeUrl(String url, long[] ranges, int sync_bytes) {
|
||||||
{
|
|
||||||
return url + "/" + String.valueOf(ranges[0] - sync_bytes) + (ranges[1] >= 0 ? "-" + String.valueOf(ranges[1]) : "");
|
return url + "/" + String.valueOf(ranges[0] - sync_bytes) + (ranges[1] >= 0 ? "-" + String.valueOf(ranges[1]) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,12 +345,9 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
String link = url_path.substring(url_path.indexOf("/video/") + 7);
|
String link = url_path.substring(url_path.indexOf("/video/") + 7);
|
||||||
|
|
||||||
if(link.indexOf("mega/") == 0)
|
if (link.indexOf("mega/") == 0) {
|
||||||
{
|
|
||||||
link = link.replaceAll("mega/", "https://mega.co.nz/#");
|
link = link.replaceAll("mega/", "https://mega.co.nz/#");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
String mc_host = findFirstRegex("^[^/]+/", link, 0);
|
String mc_host = findFirstRegex("^[^/]+/", link, 0);
|
||||||
|
|
||||||
link = "http://" + mc_host + link;
|
link = "http://" + mc_host + link;
|
||||||
@ -413,8 +383,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
String pass_hash, noexpire_token;
|
String pass_hash, noexpire_token;
|
||||||
|
|
||||||
if(file_info.length >= 5)
|
if (file_info.length >= 5) {
|
||||||
{
|
|
||||||
pass_hash = file_info[3];
|
pass_hash = file_info[3];
|
||||||
|
|
||||||
noexpire_token = file_info[4];
|
noexpire_token = file_info[4];
|
||||||
@ -427,8 +396,6 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
String file_ext = file_name.substring(file_name.lastIndexOf('.') + 1).toLowerCase();
|
String file_ext = file_name.substring(file_name.lastIndexOf('.') + 1).toLowerCase();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (httpmethod.equals("HEAD")) {
|
if (httpmethod.equals("HEAD")) {
|
||||||
|
|
||||||
resheaders.add("Accept-Ranges", "bytes");
|
resheaders.add("Accept-Ranges", "bytes");
|
||||||
@ -494,8 +461,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
|
|
||||||
if(reqheaders.containsKey("Range"))
|
if (reqheaders.containsKey("Range")) {
|
||||||
{
|
|
||||||
header_range = "Range";
|
header_range = "Range";
|
||||||
|
|
||||||
} else if (reqheaders.containsKey("range")) {
|
} else if (reqheaders.containsKey("range")) {
|
||||||
@ -503,8 +469,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
header_range = "range";
|
header_range = "range";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(header_range != null)
|
if (header_range != null) {
|
||||||
{
|
|
||||||
List<String> ranges_raw = reqheaders.get(header_range);
|
List<String> ranges_raw = reqheaders.get(header_range);
|
||||||
|
|
||||||
String range_header = ranges_raw.get(0);
|
String range_header = ranges_raw.get(0);
|
||||||
@ -561,10 +526,8 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch(Exception ex){ }
|
} finally {
|
||||||
finally
|
|
||||||
{
|
|
||||||
xchg.close();
|
xchg.close();
|
||||||
|
|
||||||
updateStatus(WORKER_STATUS_EXIT);
|
updateStatus(WORKER_STATUS_EXIT);
|
||||||
@ -574,4 +537,3 @@ public final class KissVideoStreamServer implements HttpHandler, SecureNotifiabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import static megabasterd.MiscTools.swingReflectionInvoke;
|
|||||||
import static megabasterd.MiscTools.truncateText;
|
import static megabasterd.MiscTools.truncateText;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
|
|
||||||
public final class LinkGrabberDialog extends javax.swing.JDialog implements ClipboardChangeObserver {
|
public final class LinkGrabberDialog extends javax.swing.JDialog implements ClipboardChangeObserver {
|
||||||
|
|
||||||
private boolean _download;
|
private boolean _download;
|
||||||
@ -30,8 +29,6 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
return links_textarea;
|
return links_textarea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public LinkGrabberDialog(java.awt.Frame parent, boolean modal, String download_path, ClipboardSpy clipboardspy) {
|
public LinkGrabberDialog(java.awt.Frame parent, boolean modal, String download_path, ClipboardSpy clipboardspy) {
|
||||||
|
|
||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
@ -42,12 +39,14 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(links_label, FONT_DEFAULT, Font.PLAIN);
|
public void run() {
|
||||||
|
updateFont(links_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(dance_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(dance_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(down_dir_to_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(down_dir_to_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(change_dir_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(change_dir_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(download_dir_label, FONT_DEFAULT, Font.PLAIN);}}, true);
|
updateFont(download_dir_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
_download_path = download_path;
|
_download_path = download_path;
|
||||||
|
|
||||||
@ -58,7 +57,6 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
notifyClipboardChange();
|
notifyClipboardChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called from within the constructor to initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
@ -187,7 +185,6 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
}
|
}
|
||||||
}//GEN-LAST:event_change_dir_buttonActionPerformed
|
}//GEN-LAST:event_change_dir_buttonActionPerformed
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton change_dir_button;
|
private javax.swing.JButton change_dir_button;
|
||||||
private javax.swing.JButton dance_button;
|
private javax.swing.JButton dance_button;
|
||||||
|
@ -52,14 +52,13 @@ import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|||||||
import static megabasterd.Transference.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
import static megabasterd.Transference.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
||||||
import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
|
import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION="1.41";
|
public static final String VERSION = "1.42";
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
public static final int WATCHDOG_PORT = 1338;
|
public static final int WATCHDOG_PORT = 1338;
|
||||||
@ -166,7 +165,8 @@ public final class MainPanel {
|
|||||||
|
|
||||||
JOptionPane.showMessageDialog(getView(), "MegaBasterd NEW VERSION (" + new_version + ") is available!\n\n(HELP > ABOUT for more info)");
|
JOptionPane.showMessageDialog(getView(), "MegaBasterd NEW VERSION (" + new_version + ") is available!\n\n(HELP > ABOUT for more info)");
|
||||||
}
|
}
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrayIcon getTrayicon() {
|
public TrayIcon getTrayicon() {
|
||||||
@ -185,7 +185,6 @@ public final class MainPanel {
|
|||||||
return _mega_master_pass_salt;
|
return _mega_master_pass_salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] getMega_master_pass() {
|
public byte[] getMega_master_pass() {
|
||||||
return _mega_master_pass;
|
return _mega_master_pass;
|
||||||
}
|
}
|
||||||
@ -312,9 +311,7 @@ public final class MainPanel {
|
|||||||
return _limit_upload_speed;
|
return _limit_upload_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadUserSettings() {
|
||||||
public void loadUserSettings()
|
|
||||||
{
|
|
||||||
String def_slots = selectSettingValueFromDB("default_slots_down");
|
String def_slots = selectSettingValueFromDB("default_slots_down");
|
||||||
|
|
||||||
if (def_slots != null) {
|
if (def_slots != null) {
|
||||||
@ -391,7 +388,6 @@ public final class MainPanel {
|
|||||||
_limit_upload_speed = LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
_limit_upload_speed = LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String max_download_speed = selectSettingValueFromDB("max_download_speed");
|
String max_download_speed = selectSettingValueFromDB("max_download_speed");
|
||||||
|
|
||||||
if (max_download_speed != null) {
|
if (max_download_speed != null) {
|
||||||
@ -485,8 +481,7 @@ public final class MainPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAppIsRunning()
|
private boolean checkAppIsRunning() {
|
||||||
{
|
|
||||||
boolean app_is_running = false;
|
boolean app_is_running = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -514,7 +509,8 @@ public final class MainPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
||||||
@ -576,8 +572,8 @@ public final class MainPanel {
|
|||||||
|
|
||||||
swingReflectionInvoke("setText", getView().getStatus_down_label(), "");
|
swingReflectionInvoke("setText", getView().getStatus_down_label(), "");
|
||||||
|
|
||||||
|
}
|
||||||
}});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,14 +624,11 @@ public final class MainPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
if(!(boolean)swingReflectionInvokeAndWaitForReturn("isVisible", getView()))
|
if (!(boolean) swingReflectionInvokeAndWaitForReturn("isVisible", getView())) {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setExtendedState", getView(), NORMAL);
|
swingReflectionInvoke("setExtendedState", getView(), NORMAL);
|
||||||
|
|
||||||
swingReflectionInvoke("setVisible", getView(), true);
|
swingReflectionInvoke("setVisible", getView(), true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
swingReflectionInvoke("dispatchEvent", getView(), new WindowEvent(getView(), WINDOW_CLOSING));
|
swingReflectionInvoke("dispatchEvent", getView(), new WindowEvent(getView(), WINDOW_CLOSING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,7 +649,6 @@ public final class MainPanel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void resumeUploads() {
|
private void resumeUploads() {
|
||||||
|
|
||||||
swingReflectionInvoke("setText", getView().getStatus_up_label(), "Resuming previous uploads, please wait...");
|
swingReflectionInvoke("setText", getView().getStatus_up_label(), "Resuming previous uploads, please wait...");
|
||||||
@ -679,7 +671,6 @@ public final class MainPanel {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
String email = (String) o.get("email");
|
String email = (String) o.get("email");
|
||||||
|
|
||||||
MegaAPI ma;
|
MegaAPI ma;
|
||||||
@ -692,7 +683,6 @@ public final class MainPanel {
|
|||||||
|
|
||||||
if (ma == null) {
|
if (ma == null) {
|
||||||
|
|
||||||
|
|
||||||
ma = new MegaAPI();
|
ma = new MegaAPI();
|
||||||
|
|
||||||
String password_aes, user_hash;
|
String password_aes, user_hash;
|
||||||
@ -749,7 +739,6 @@ public final class MainPanel {
|
|||||||
|
|
||||||
_mega_active_accounts.put(email, ma);
|
_mega_active_accounts.put(email, ma);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Upload upload = new Upload(tthis, ma, (String) o.get("filename"), (String) o.get("parent_node"), (String) o.get("ul_key") != null ? bin2i32a(BASE642Bin((String) o.get("ul_key"))) : null, (String) o.get("url"), (String) o.get("root_node"), BASE642Bin((String) o.get("share_key")), (String) o.get("folder_link"), _use_slots_up, _default_slots_up, false);
|
Upload upload = new Upload(tthis, ma, (String) o.get("filename"), (String) o.get("parent_node"), (String) o.get("ul_key") != null ? bin2i32a(BASE642Bin((String) o.get("ul_key"))) : null, (String) o.get("url"), (String) o.get("root_node"), BASE642Bin((String) o.get("share_key")), (String) o.get("folder_link"), _use_slots_up, _default_slots_up, false);
|
||||||
@ -787,9 +776,9 @@ public final class MainPanel {
|
|||||||
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package megabasterd;
|
package megabasterd;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import static java.awt.Font.BOLD;
|
import static java.awt.Font.BOLD;
|
||||||
import static java.awt.Font.PLAIN;
|
import static java.awt.Font.PLAIN;
|
||||||
@ -37,10 +36,8 @@ import static megabasterd.MiscTools.swingReflectionInvoke;
|
|||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
|
|
||||||
public final class MainPanelView extends javax.swing.JFrame {
|
public final class MainPanelView extends javax.swing.JFrame {
|
||||||
|
|
||||||
|
|
||||||
private final MainPanel _main_panel;
|
private final MainPanel _main_panel;
|
||||||
|
|
||||||
public JLabel getKiss_server_status() {
|
public JLabel getKiss_server_status() {
|
||||||
@ -111,8 +108,6 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
return jTabbedPane1;
|
return jTabbedPane1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MainPanelView(MainPanel main_panel) {
|
public MainPanelView(MainPanel main_panel) {
|
||||||
|
|
||||||
_main_panel = main_panel;
|
_main_panel = main_panel;
|
||||||
@ -126,7 +121,8 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(file_menu, FONT_DEFAULT, PLAIN);
|
public void run() {
|
||||||
|
updateFont(file_menu, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(edit_menu, FONT_DEFAULT, PLAIN);
|
updateFont(edit_menu, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(help_menu, FONT_DEFAULT, PLAIN);
|
updateFont(help_menu, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(new_download_menu, FONT_DEFAULT, PLAIN);
|
updateFont(new_download_menu, FONT_DEFAULT, PLAIN);
|
||||||
@ -147,9 +143,9 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
updateFont(close_all_finished_up_button, FONT_DEFAULT, BOLD);
|
updateFont(close_all_finished_up_button, FONT_DEFAULT, BOLD);
|
||||||
updateFont(pause_all_down_button, FONT_DEFAULT, BOLD);
|
updateFont(pause_all_down_button, FONT_DEFAULT, BOLD);
|
||||||
updateFont(pause_all_up_button, FONT_DEFAULT, BOLD);
|
updateFont(pause_all_up_button, FONT_DEFAULT, BOLD);
|
||||||
updateFont(jTabbedPane1, FONT_DEFAULT, PLAIN);}}, true);
|
updateFont(jTabbedPane1, FONT_DEFAULT, PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
swingReflectionInvoke("setVisible", global_speed_down_label, false);
|
swingReflectionInvoke("setVisible", global_speed_down_label, false);
|
||||||
swingReflectionInvoke("setVisible", global_speed_up_label, false);
|
swingReflectionInvoke("setVisible", global_speed_up_label, false);
|
||||||
@ -518,8 +514,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
for (String url : urls) {
|
for (String url : urls) {
|
||||||
|
|
||||||
if(getMain_panel().getDownload_manager().getPre_count() > 0)
|
if (getMain_panel().getDownload_manager().getPre_count() > 0) {
|
||||||
{
|
|
||||||
url = url.replaceAll("^mega://", "https://mega.nz");
|
url = url.replaceAll("^mega://", "https://mega.nz");
|
||||||
|
|
||||||
Download download;
|
Download download;
|
||||||
@ -567,7 +562,8 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
getMain_panel().getDownload_manager().getTransference_preprocess_queue().add(run);
|
getMain_panel().getDownload_manager().getTransference_preprocess_queue().add(run);
|
||||||
|
|
||||||
@ -765,8 +761,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
for (File f : dialog.getFiles()) {
|
for (File f : dialog.getFiles()) {
|
||||||
|
|
||||||
if(getMain_panel().getUpload_manager().getPre_count() > 0)
|
if (getMain_panel().getUpload_manager().getPre_count() > 0) {
|
||||||
{
|
|
||||||
String file_path = f.getParentFile().getAbsolutePath().replace(base_path, "");
|
String file_path = f.getParentFile().getAbsolutePath().replace(base_path, "");
|
||||||
|
|
||||||
String[] dirs = file_path.split("/");
|
String[] dirs = file_path.split("/");
|
||||||
@ -825,12 +820,12 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
new_upload_menu.setEnabled(true);
|
new_upload_menu.setEnabled(true);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
new_upload_menu.setEnabled(true);
|
new_upload_menu.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(Exception ex) {}
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
|
||||||
if (!dialog.isRemember_master_pass()) {
|
if (!dialog.isRemember_master_pass()) {
|
||||||
|
|
||||||
@ -903,8 +898,4 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
private javax.swing.JPanel uploads_panel;
|
private javax.swing.JPanel uploads_panel;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,17 +32,13 @@ import org.apache.http.entity.StringEntity;
|
|||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final class MegaAPI {
|
public final class MegaAPI {
|
||||||
|
|
||||||
public static final String API_URL = "https://g.api.mega.co.nz";
|
public static final String API_URL = "https://g.api.mega.co.nz";
|
||||||
public static final String API_KEY = null;
|
public static final String API_KEY = null;
|
||||||
public static final int REQ_ID_LENGTH = 10;
|
public static final int REQ_ID_LENGTH = 10;
|
||||||
|
|
||||||
|
public static int checkMEGAError(String data) {
|
||||||
public static int checkMEGAError(String data)
|
|
||||||
{
|
|
||||||
String error = findFirstRegex("^\\[?(\\-[0-9]+)\\]?$", data, 1);
|
String error = findFirstRegex("^\\[?(\\-[0-9]+)\\]?$", data, 1);
|
||||||
|
|
||||||
return error != null ? Integer.parseInt(error) : 0;
|
return error != null ? Integer.parseInt(error) : 0;
|
||||||
@ -70,9 +66,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
private String _req_id;
|
private String _req_id;
|
||||||
|
|
||||||
|
public MegaAPI() {
|
||||||
public MegaAPI()
|
|
||||||
{
|
|
||||||
_req_id = null;
|
_req_id = null;
|
||||||
_trashbin_id = null;
|
_trashbin_id = null;
|
||||||
_email = null;
|
_email = null;
|
||||||
@ -90,12 +84,15 @@ public final class MegaAPI {
|
|||||||
_seqno = randomno.nextLong() & 0xffffffffL;
|
_seqno = randomno.nextLong() & 0xffffffffL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return _email;
|
return _email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getPassword_aes() {
|
public int[] getPassword_aes() {
|
||||||
return _password_aes;
|
return _password_aes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser_hash() {
|
public String getUser_hash() {
|
||||||
return _user_hash;
|
return _user_hash;
|
||||||
}
|
}
|
||||||
@ -124,8 +121,6 @@ public final class MegaAPI {
|
|||||||
return _trashbin_id;
|
return _trashbin_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void _realLogin() throws Exception, MegaAPIException {
|
private void _realLogin() throws Exception, MegaAPIException {
|
||||||
|
|
||||||
String request = "[{\"a\":\"us\", \"user\":\"" + _email + "\", \"uh\":\"" + _user_hash + "\"}]";
|
String request = "[{\"a\":\"us\", \"user\":\"" + _email + "\", \"uh\":\"" + _user_hash + "\"}]";
|
||||||
@ -154,7 +149,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
_rsa_priv_key = _extractRSAPrivKey(privk_byte);
|
_rsa_priv_key = _extractRSAPrivKey(privk_byte);
|
||||||
|
|
||||||
|
|
||||||
byte[] raw_sid = CryptTools.rsaDecrypt(mpi2big(UrlBASE642Bin(csid)), _rsa_priv_key[0], _rsa_priv_key[1], _rsa_priv_key[2]);
|
byte[] raw_sid = CryptTools.rsaDecrypt(mpi2big(UrlBASE642Bin(csid)), _rsa_priv_key[0], _rsa_priv_key[1], _rsa_priv_key[2]);
|
||||||
|
|
||||||
_sid = Bin2UrlBASE64(Arrays.copyOfRange(raw_sid, 0, 43));
|
_sid = Bin2UrlBASE64(Arrays.copyOfRange(raw_sid, 0, 43));
|
||||||
@ -303,8 +297,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
||||||
|
|
||||||
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
|
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||||
{
|
|
||||||
System.out.println("Failed : HTTP error code : " + httpresponse.getStatusLine().getStatusCode());
|
System.out.println("Failed : HTTP error code : " + httpresponse.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -328,8 +321,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
int mega_error;
|
int mega_error;
|
||||||
|
|
||||||
if( (mega_error=checkMEGAError(response))!=0 )
|
if ((mega_error = checkMEGAError(response)) != 0) {
|
||||||
{
|
|
||||||
if (mega_error != -3) {
|
if (mega_error != -3) {
|
||||||
throw new MegaAPIException(String.valueOf(mega_error));
|
throw new MegaAPIException(String.valueOf(mega_error));
|
||||||
}
|
}
|
||||||
@ -369,8 +361,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMegaFileDownloadUrl(String link) throws IOException, MegaAPIException
|
public String getMegaFileDownloadUrl(String link) throws IOException, MegaAPIException {
|
||||||
{
|
|
||||||
link = link.replace("/#!N?", "/#N!");
|
link = link.replace("/#!N?", "/#N!");
|
||||||
|
|
||||||
String file_id = findFirstRegex("#.*?!([^!]+)", link, 1);
|
String file_id = findFirstRegex("#.*?!([^!]+)", link, 1);
|
||||||
@ -379,8 +370,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
URL url_api;
|
URL url_api;
|
||||||
|
|
||||||
if(findFirstRegex("#N!", link, 0) != null)
|
if (findFirstRegex("#N!", link, 0) != null) {
|
||||||
{
|
|
||||||
String folder_id = findFirstRegex("###n=(.+)$", link, 1);
|
String folder_id = findFirstRegex("###n=(.+)$", link, 1);
|
||||||
|
|
||||||
request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]";
|
request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]";
|
||||||
@ -402,9 +392,7 @@ public final class MegaAPI {
|
|||||||
return (String) res_map[0].get("g");
|
return (String) res_map[0].get("g");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getMegaFileMetadata(String link) throws Exception, MegaAPIException {
|
||||||
public String[] getMegaFileMetadata(String link) throws Exception, MegaAPIException
|
|
||||||
{
|
|
||||||
|
|
||||||
link = link.replace("/#!N?", "/#N!");
|
link = link.replace("/#!N?", "/#N!");
|
||||||
|
|
||||||
@ -416,8 +404,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
URL url_api;
|
URL url_api;
|
||||||
|
|
||||||
if(findFirstRegex("#N!", link, 0) != null)
|
if (findFirstRegex("#N!", link, 0) != null) {
|
||||||
{
|
|
||||||
String folder_id = findFirstRegex("###n=(.+)$", link, 1);
|
String folder_id = findFirstRegex("###n=(.+)$", link, 1);
|
||||||
|
|
||||||
request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]";
|
request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]";
|
||||||
@ -459,7 +446,6 @@ public final class MegaAPI {
|
|||||||
return file_data;
|
return file_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private byte[] _encAttr(String attr, byte[] key) {
|
private byte[] _encAttr(String attr, byte[] key) {
|
||||||
|
|
||||||
byte[] attr_byte = ("MEGA" + attr).getBytes();
|
byte[] attr_byte = ("MEGA" + attr).getBytes();
|
||||||
@ -499,8 +485,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
res_map = objectMapper.readValue(att, HashMap.class);
|
res_map = objectMapper.readValue(att, HashMap.class);
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -616,7 +601,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HashMap<String, Object> createDirInsideAnotherSharedDir(String name, String parent_node, byte[] node_key, byte[] master_key, String root_node, byte[] share_key) {
|
public HashMap<String, Object> createDirInsideAnotherSharedDir(String name, String parent_node, byte[] node_key, byte[] master_key, String root_node, byte[] share_key) {
|
||||||
|
|
||||||
HashMap[] res_map = null;
|
HashMap[] res_map = null;
|
||||||
@ -649,7 +633,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getPublicFileLink(String node, byte[] node_key) {
|
public String getPublicFileLink(String node, byte[] node_key) {
|
||||||
|
|
||||||
String public_link = null;
|
String public_link = null;
|
||||||
@ -731,7 +714,6 @@ public final class MegaAPI {
|
|||||||
return genRandomByteArray(16);
|
return genRandomByteArray(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void shareFolder(String node, byte[] node_key, byte[] share_key) {
|
public void shareFolder(String node, byte[] node_key, byte[] share_key) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -757,7 +739,6 @@ public final class MegaAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String cryptoHandleauth(String h) {
|
public String cryptoHandleauth(String h) {
|
||||||
|
|
||||||
String ch = null;
|
String ch = null;
|
||||||
@ -773,7 +754,6 @@ public final class MegaAPI {
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HashMap<String, Object> getFolderNodes(String folder_id, String folder_key) throws Exception {
|
public HashMap<String, Object> getFolderNodes(String folder_id, String folder_key) throws Exception {
|
||||||
|
|
||||||
HashMap<String, Object> folder_nodes;
|
HashMap<String, Object> folder_nodes;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package megabasterd;
|
package megabasterd;
|
||||||
|
|
||||||
|
|
||||||
public final class MegaAPIException extends Exception {
|
public final class MegaAPIException extends Exception {
|
||||||
|
|
||||||
public MegaAPIException(String message)
|
public MegaAPIException(String message) {
|
||||||
{
|
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import org.apache.http.entity.StringEntity;
|
|||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -46,8 +45,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
|
|
||||||
try(CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient())
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
{
|
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
int conta_error = 0;
|
int conta_error = 0;
|
||||||
@ -71,8 +69,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
||||||
|
|
||||||
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
|
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||||
{
|
|
||||||
System.out.println("Failed : HTTP error code : " + httpresponse.getStatusLine().getStatusCode());
|
System.out.println("Failed : HTTP error code : " + httpresponse.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -96,8 +93,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
int mc_error;
|
int mc_error;
|
||||||
|
|
||||||
if( (mc_error=MegaCrypterAPI.checkMCError(response))!=0 )
|
if ((mc_error = MegaCrypterAPI.checkMCError(response)) != 0) {
|
||||||
{
|
|
||||||
throw new MegaCrypterAPIException(String.valueOf(mc_error));
|
throw new MegaCrypterAPIException(String.valueOf(mc_error));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -131,8 +127,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMegaFileDownloadUrl(String link, String pass_hash, String noexpire_token) throws IOException, MegaCrypterAPIException
|
public static String getMegaFileDownloadUrl(String link, String pass_hash, String noexpire_token) throws IOException, MegaCrypterAPIException {
|
||||||
{
|
|
||||||
String request = noexpire_token != null ? "{\"m\":\"dl\", \"link\": \"" + link + "\", \"noexpire\": \"" + noexpire_token + "\"}" : "{\"m\":\"dl\", \"link\": \"" + link + "\"}";
|
String request = noexpire_token != null ? "{\"m\":\"dl\", \"link\": \"" + link + "\", \"noexpire\": \"" + noexpire_token + "\"}" : "{\"m\":\"dl\", \"link\": \"" + link + "\"}";
|
||||||
|
|
||||||
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
||||||
@ -145,8 +140,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
String dl_url = (String) res_map.get("url");
|
String dl_url = (String) res_map.get("url");
|
||||||
|
|
||||||
if(pass_hash != null)
|
if (pass_hash != null) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
String pass = (String) res_map.get("pass");
|
String pass = (String) res_map.get("pass");
|
||||||
|
|
||||||
@ -166,8 +160,7 @@ public final class MegaCrypterAPI {
|
|||||||
return dl_url;
|
return dl_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getMegaFileMetadata(String link, MainPanelView panel) throws Exception, MegaCrypterAPIException
|
public static String[] getMegaFileMetadata(String link, MainPanelView panel) throws Exception, MegaCrypterAPIException {
|
||||||
{
|
|
||||||
String request = "{\"m\":\"info\", \"link\": \"" + link + "\"}";
|
String request = "{\"m\":\"info\", \"link\": \"" + link + "\"}";
|
||||||
|
|
||||||
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
||||||
@ -236,12 +229,10 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
System.out.println(noexpire_token);
|
System.out.println(noexpire_token);
|
||||||
|
|
||||||
if(pass != null)
|
if (pass != null) {
|
||||||
{
|
|
||||||
String[] pass_items = pass.split("#");
|
String[] pass_items = pass.split("#");
|
||||||
|
|
||||||
if(pass_items.length != 4)
|
if (pass_items.length != 4) {
|
||||||
{
|
|
||||||
throw new MegaCrypterAPIException("Bad password data!");
|
throw new MegaCrypterAPIException("Bad password data!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,8 +256,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
LinkedList<String> pass_list = new LinkedList(PASS_CACHE);
|
LinkedList<String> pass_list = new LinkedList(PASS_CACHE);
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
bad_pass = true;
|
bad_pass = true;
|
||||||
|
|
||||||
if ((password = pass_list.poll()) == null) {
|
if ((password = pass_list.poll()) == null) {
|
||||||
@ -291,20 +281,19 @@ public final class MegaCrypterAPI {
|
|||||||
PASS_CACHE.add(password);
|
PASS_CACHE.add(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalBlockSizeException | BadPaddingException ex) {}
|
} catch (IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
} catch (InvalidKeySpecException ex) {}
|
} catch (InvalidKeySpecException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (password != null && bad_pass);
|
} while (password != null && bad_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bad_pass)
|
if (bad_pass) {
|
||||||
{
|
|
||||||
throw new MegaCrypterAPIException("25");
|
throw new MegaCrypterAPIException("25");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
||||||
|
|
||||||
byte[] decrypted_key = decrypter.doFinal(BASE642Bin(fkey));
|
byte[] decrypted_key = decrypter.doFinal(BASE642Bin(fkey));
|
||||||
@ -317,8 +306,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
fname = new String(decrypted_name);
|
fname = new String(decrypted_name);
|
||||||
|
|
||||||
if(fpath != null)
|
if (fpath != null) {
|
||||||
{
|
|
||||||
byte[] decrypted_fpath = decrypter.doFinal(BASE642Bin(fpath));
|
byte[] decrypted_fpath = decrypter.doFinal(BASE642Bin(fpath));
|
||||||
|
|
||||||
fpath = new String(decrypted_fpath);
|
fpath = new String(decrypted_fpath);
|
||||||
@ -330,8 +318,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fpath != null)
|
if (fpath != null) {
|
||||||
{
|
|
||||||
fname = fpath + fname;
|
fname = fpath + fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,8 +327,7 @@ public final class MegaCrypterAPI {
|
|||||||
return file_data;
|
return file_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int checkMCError(String data)
|
private static int checkMCError(String data) {
|
||||||
{
|
|
||||||
String error = findFirstRegex("\"error\" *: *([0-9-]+)", data, 1);
|
String error = findFirstRegex("\"error\" *: *([0-9-]+)", data, 1);
|
||||||
|
|
||||||
return error != null ? Integer.parseInt(error) : 0;
|
return error != null ? Integer.parseInt(error) : 0;
|
||||||
|
@ -2,8 +2,7 @@ package megabasterd;
|
|||||||
|
|
||||||
public final class MegaCrypterAPIException extends Exception {
|
public final class MegaCrypterAPIException extends Exception {
|
||||||
|
|
||||||
public MegaCrypterAPIException(String message)
|
public MegaCrypterAPIException(String message) {
|
||||||
{
|
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.MutableTreeNode;
|
import javax.swing.tree.MutableTreeNode;
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
import static megabasterd.MainPanel.VERSION;
|
import static megabasterd.MainPanel.VERSION;
|
||||||
@ -78,8 +79,8 @@ public final class MiscTools {
|
|||||||
|
|
||||||
private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = new Comparator< DefaultMutableTreeNode>() {
|
private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = new Comparator< DefaultMutableTreeNode>() {
|
||||||
|
|
||||||
@Override public int compare(DefaultMutableTreeNode a, DefaultMutableTreeNode b) {
|
@Override
|
||||||
|
public int compare(DefaultMutableTreeNode a, DefaultMutableTreeNode b) {
|
||||||
|
|
||||||
if (a.isLeaf() && !b.isLeaf()) {
|
if (a.isLeaf() && !b.isLeaf()) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -126,8 +127,7 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] bin2i32a(byte[] bin)
|
public static int[] bin2i32a(byte[] bin) {
|
||||||
{
|
|
||||||
int l = (int) (4 * Math.ceil((double) bin.length / 4));
|
int l = (int) (4 * Math.ceil((double) bin.length / 4));
|
||||||
|
|
||||||
byte[] new_bin = Arrays.copyOfRange(bin, 0, l);
|
byte[] new_bin = Arrays.copyOfRange(bin, 0, l);
|
||||||
@ -139,9 +139,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
if (int_buffer.hasArray()) {
|
if (int_buffer.hasArray()) {
|
||||||
return int_buffer.array();
|
return int_buffer.array();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ArrayList<Integer> list = new ArrayList<>();
|
ArrayList<Integer> list = new ArrayList<>();
|
||||||
|
|
||||||
while (int_buffer.hasRemaining()) {
|
while (int_buffer.hasRemaining()) {
|
||||||
@ -158,17 +156,14 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] i32a2bin(int[] i32a)
|
public static byte[] i32a2bin(int[] i32a) {
|
||||||
{
|
|
||||||
ByteBuffer bin_buffer = ByteBuffer.allocate(i32a.length * 4);
|
ByteBuffer bin_buffer = ByteBuffer.allocate(i32a.length * 4);
|
||||||
IntBuffer int_buffer = bin_buffer.asIntBuffer();
|
IntBuffer int_buffer = bin_buffer.asIntBuffer();
|
||||||
int_buffer.put(i32a);
|
int_buffer.put(i32a);
|
||||||
|
|
||||||
if (bin_buffer.hasArray()) {
|
if (bin_buffer.hasArray()) {
|
||||||
return bin_buffer.array();
|
return bin_buffer.array();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ArrayList<Byte> list = new ArrayList<>();
|
ArrayList<Byte> list = new ArrayList<>();
|
||||||
|
|
||||||
while (int_buffer.hasRemaining()) {
|
while (int_buffer.hasRemaining()) {
|
||||||
@ -185,7 +180,6 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static BigInteger mpi2big(byte[] s) {
|
public static BigInteger mpi2big(byte[] s) {
|
||||||
|
|
||||||
byte[] ns = Arrays.copyOfRange(s, 2, s.length);
|
byte[] ns = Arrays.copyOfRange(s, 2, s.length);
|
||||||
@ -235,8 +229,7 @@ public final class MiscTools {
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String findFirstRegex(String regex, String data, int group)
|
public static String findFirstRegex(String regex, String data, int group) {
|
||||||
{
|
|
||||||
Pattern pattern = Pattern.compile(regex);
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
|
||||||
Matcher matcher = pattern.matcher(data);
|
Matcher matcher = pattern.matcher(data);
|
||||||
@ -244,8 +237,7 @@ public final class MiscTools {
|
|||||||
return matcher.find() ? matcher.group(group) : null;
|
return matcher.find() ? matcher.group(group) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> findAllRegex(String regex, String data, int group)
|
public static ArrayList<String> findAllRegex(String regex, String data, int group) {
|
||||||
{
|
|
||||||
Pattern pattern = Pattern.compile(regex);
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
|
||||||
Matcher matcher = pattern.matcher(data);
|
Matcher matcher = pattern.matcher(data);
|
||||||
@ -259,14 +251,11 @@ public final class MiscTools {
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateFont(javax.swing.JComponent label, Font font, int layout)
|
public static void updateFont(javax.swing.JComponent label, Font font, int layout) {
|
||||||
{
|
|
||||||
label.setFont(font.deriveFont(layout, label.getFont().getSize()));
|
label.setFont(font.deriveFont(layout, label.getFont().getSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String HashString(String algo, String data) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||||
public static String HashString(String algo, String data) throws NoSuchAlgorithmException, UnsupportedEncodingException
|
|
||||||
{
|
|
||||||
MessageDigest md = MessageDigest.getInstance(algo);
|
MessageDigest md = MessageDigest.getInstance(algo);
|
||||||
|
|
||||||
byte[] thedigest = md.digest(data.getBytes("UTF-8"));
|
byte[] thedigest = md.digest(data.getBytes("UTF-8"));
|
||||||
@ -274,8 +263,7 @@ public final class MiscTools {
|
|||||||
return bin2hex(thedigest);
|
return bin2hex(thedigest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String HashString(String algo, byte[] data) throws NoSuchAlgorithmException
|
public static String HashString(String algo, byte[] data) throws NoSuchAlgorithmException {
|
||||||
{
|
|
||||||
MessageDigest md = MessageDigest.getInstance(algo);
|
MessageDigest md = MessageDigest.getInstance(algo);
|
||||||
|
|
||||||
byte[] thedigest = md.digest(data);
|
byte[] thedigest = md.digest(data);
|
||||||
@ -283,41 +271,34 @@ public final class MiscTools {
|
|||||||
return bin2hex(thedigest);
|
return bin2hex(thedigest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] HashBin(String algo, String data) throws NoSuchAlgorithmException, UnsupportedEncodingException
|
public static byte[] HashBin(String algo, String data) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||||
{
|
|
||||||
MessageDigest md = MessageDigest.getInstance(algo);
|
MessageDigest md = MessageDigest.getInstance(algo);
|
||||||
|
|
||||||
return md.digest(data.getBytes("UTF-8"));
|
return md.digest(data.getBytes("UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] HashBin(String algo, byte[] data) throws NoSuchAlgorithmException
|
public static byte[] HashBin(String algo, byte[] data) throws NoSuchAlgorithmException {
|
||||||
{
|
|
||||||
MessageDigest md = MessageDigest.getInstance(algo);
|
MessageDigest md = MessageDigest.getInstance(algo);
|
||||||
|
|
||||||
return md.digest(data);
|
return md.digest(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] BASE642Bin(String data) throws Exception
|
public static byte[] BASE642Bin(String data) throws Exception {
|
||||||
{
|
|
||||||
return Base64.getDecoder().decode(data);
|
return Base64.getDecoder().decode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String Bin2BASE64(byte[] data) throws Exception
|
public static String Bin2BASE64(byte[] data) throws Exception {
|
||||||
{
|
|
||||||
return Base64.getEncoder().encodeToString(data);
|
return Base64.getEncoder().encodeToString(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] UrlBASE642Bin(String data) throws Exception
|
public static byte[] UrlBASE642Bin(String data) throws Exception {
|
||||||
{
|
|
||||||
return Base64.getUrlDecoder().decode(data);
|
return Base64.getUrlDecoder().decode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String Bin2UrlBASE64(byte[] data) throws Exception
|
public static String Bin2UrlBASE64(byte[] data) throws Exception {
|
||||||
{
|
|
||||||
return Base64.getUrlEncoder().withoutPadding().encodeToString(data);
|
return Base64.getUrlEncoder().withoutPadding().encodeToString(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static long getWaitTimeExpBackOff(int retryCount) {
|
public static long getWaitTimeExpBackOff(int retryCount) {
|
||||||
|
|
||||||
long waitTime = ((long) Math.pow(EXP_BACKOFF_BASE, retryCount) * EXP_BACKOFF_SECS_RETRY);
|
long waitTime = ((long) Math.pow(EXP_BACKOFF_BASE, retryCount) * EXP_BACKOFF_SECS_RETRY);
|
||||||
@ -431,7 +412,6 @@ public final class MiscTools {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Object swingReflectionInvokeAndWaitForReturn(final String method_name, final Object obj, final Object... params) {
|
public static Object swingReflectionInvokeAndWaitForReturn(final String method_name, final Object obj, final Object... params) {
|
||||||
|
|
||||||
Callable c = new Callable() {
|
Callable c = new Callable() {
|
||||||
@ -502,7 +482,6 @@ public final class MiscTools {
|
|||||||
return swingInvokeItAndWaitForReturn(c);
|
return swingInvokeItAndWaitForReturn(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void swingInvokeIt(Runnable r, boolean wait) {
|
public static void swingInvokeIt(Runnable r, boolean wait) {
|
||||||
|
|
||||||
if (wait) {
|
if (wait) {
|
||||||
@ -528,8 +507,7 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object swingInvokeItAndWaitForReturn(Callable c)
|
public static Object swingInvokeItAndWaitForReturn(Callable c) {
|
||||||
{
|
|
||||||
Object ret = null;
|
Object ret = null;
|
||||||
|
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
@ -731,7 +709,7 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
swingReflectionInvoke("setRootVisible", tree, ((MutableTreeNode)tree_model.getRoot()).getChildCount() > 0 );
|
swingReflectionInvoke("setRootVisible", tree, ((TreeNode) tree_model.getRoot()).getChildCount() > 0);
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", tree, true);
|
swingReflectionInvoke("setEnabled", tree, true);
|
||||||
|
|
||||||
@ -767,15 +745,14 @@ public final class MiscTools {
|
|||||||
|
|
||||||
for (TreePath path : paths) {
|
for (TreePath path : paths) {
|
||||||
|
|
||||||
if((MutableTreeNode)path.getLastPathComponent() != (MutableTreeNode)tree_model.getRoot())
|
if ((MutableTreeNode) path.getLastPathComponent() != (MutableTreeNode) tree_model.getRoot()) {
|
||||||
{
|
|
||||||
Object parent = new_root;
|
Object parent = new_root;
|
||||||
|
|
||||||
for (Object path_element : path.getPath()) {
|
for (Object path_element : path.getPath()) {
|
||||||
|
|
||||||
if ((MutableTreeNode) path_element != (MutableTreeNode) tree_model.getRoot()) {
|
if ((MutableTreeNode) path_element != (MutableTreeNode) tree_model.getRoot()) {
|
||||||
|
|
||||||
if(hashmap_old.get((MutableTreeNode)path_element) == null) {
|
if (hashmap_old.get(path_element) == null) {
|
||||||
|
|
||||||
Object node = null;
|
Object node = null;
|
||||||
|
|
||||||
@ -800,7 +777,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
((DefaultMutableTreeNode) parent).add((MutableTreeNode) node);
|
((DefaultMutableTreeNode) parent).add((MutableTreeNode) node);
|
||||||
|
|
||||||
if(!((MutableTreeNode)path_element).isLeaf()) {
|
if (!((TreeNode) path_element).isLeaf()) {
|
||||||
|
|
||||||
hashmap_old.put((MutableTreeNode) path_element, (MutableTreeNode) node);
|
hashmap_old.put((MutableTreeNode) path_element, (MutableTreeNode) node);
|
||||||
|
|
||||||
@ -810,7 +787,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
parent = hashmap_old.get((MutableTreeNode)path_element);
|
parent = hashmap_old.get(path_element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -823,7 +800,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
swingReflectionInvokeAndWait("setModel", tree, new DefaultTreeModel(sortTree((DefaultMutableTreeNode) new_root)));
|
swingReflectionInvokeAndWait("setModel", tree, new DefaultTreeModel(sortTree((DefaultMutableTreeNode) new_root)));
|
||||||
|
|
||||||
swingReflectionInvoke("setRootVisible", tree, new_root!=null?((DefaultMutableTreeNode)new_root).getChildCount() > 0:false);
|
swingReflectionInvoke("setRootVisible", tree, new_root != null ? ((TreeNode) new_root).getChildCount() > 0 : false);
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", tree, true);
|
swingReflectionInvoke("setEnabled", tree, true);
|
||||||
|
|
||||||
@ -883,7 +860,8 @@ public final class MiscTools {
|
|||||||
ret = (String) o;
|
ret = (String) o;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {}
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -932,7 +910,6 @@ public final class MiscTools {
|
|||||||
|
|
||||||
boolean url_ok = false;
|
boolean url_ok = false;
|
||||||
|
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
|
|
||||||
HttpGet httpget = new HttpGet(new URI(string_url + "/0"));
|
HttpGet httpget = new HttpGet(new URI(string_url + "/0"));
|
||||||
@ -953,7 +930,6 @@ public final class MiscTools {
|
|||||||
return url_ok;
|
return url_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private MiscTools() {
|
private MiscTools() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,8 +977,7 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CloseableHttpClient getApacheKissHttpClient()
|
public static CloseableHttpClient getApacheKissHttpClient() {
|
||||||
{
|
|
||||||
return HttpClients.custom()
|
return HttpClients.custom()
|
||||||
.addInterceptorFirst(new RequestDefaultHeaders())
|
.addInterceptorFirst(new RequestDefaultHeaders())
|
||||||
.addInterceptorFirst(new RequestContent())
|
.addInterceptorFirst(new RequestContent())
|
||||||
@ -1034,5 +1009,4 @@ public final class MiscTools {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,15 @@ package megabasterd;
|
|||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
|
||||||
public final class ProgressMeter implements Runnable, SecureNotifiable
|
public final class ProgressMeter implements Runnable, SecureNotifiable {
|
||||||
{
|
|
||||||
private final Transference _transference;
|
private final Transference _transference;
|
||||||
private volatile boolean _exit;
|
private volatile boolean _exit;
|
||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
private long _progress;
|
private long _progress;
|
||||||
|
|
||||||
ProgressMeter(Transference transference)
|
ProgressMeter(Transference transference) {
|
||||||
{
|
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_transference = transference;
|
_transference = transference;
|
||||||
@ -20,14 +19,12 @@ public final class ProgressMeter implements Runnable, SecureNotifiable
|
|||||||
_exit = false;
|
_exit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExit(boolean value)
|
public void setExit(boolean value) {
|
||||||
{
|
|
||||||
_exit = value;
|
_exit = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -39,8 +36,7 @@ public final class ProgressMeter implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -66,23 +62,19 @@ public final class ProgressMeter implements Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
System.out.println("ProgressMeter hello!");
|
System.out.println("ProgressMeter hello!");
|
||||||
|
|
||||||
while(!_exit || !_transference.getPartialProgress().isEmpty())
|
while (!_exit || !_transference.getPartialProgress().isEmpty()) {
|
||||||
{
|
|
||||||
Integer reads;
|
Integer reads;
|
||||||
|
|
||||||
while( (reads=_transference.getPartialProgress().poll()) !=null )
|
while ((reads = _transference.getPartialProgress().poll()) != null) {
|
||||||
{
|
|
||||||
_progress += reads;
|
_progress += reads;
|
||||||
}
|
}
|
||||||
|
|
||||||
_transference.setProgress(_progress);
|
_transference.setProgress(_progress);
|
||||||
|
|
||||||
if(!_exit)
|
if (!_exit) {
|
||||||
{
|
|
||||||
secureWait();
|
secureWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import static megabasterd.MiscTools.HashBin;
|
|||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -61,14 +60,15 @@ public class SetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(new_pass_label, FONT_DEFAULT, Font.PLAIN);
|
public void run() {
|
||||||
|
updateFont(new_pass_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(confirm_pass_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(confirm_pass_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(ok_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(ok_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(cancel_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(cancel_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(warning_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(warning_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(status_label, FONT_DEFAULT, Font.PLAIN);}}, true);
|
updateFont(status_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
_pass_ok = false;
|
_pass_ok = false;
|
||||||
|
|
||||||
@ -255,7 +255,8 @@ public class SetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SetMegaMasterPasswordDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(SetMegaMasterPasswordDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_ok_buttonActionPerformed
|
}//GEN-LAST:event_ok_buttonActionPerformed
|
||||||
|
|
||||||
private void confirm_pass_textfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_confirm_pass_textfieldKeyPressed
|
private void confirm_pass_textfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_confirm_pass_textfieldKeyPressed
|
||||||
@ -266,7 +267,6 @@ public class SetMegaMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
}//GEN-LAST:event_confirm_pass_textfieldKeyPressed
|
}//GEN-LAST:event_confirm_pass_textfieldKeyPressed
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton cancel_button;
|
private javax.swing.JButton cancel_button;
|
||||||
private javax.swing.JLabel confirm_pass_label;
|
private javax.swing.JLabel confirm_pass_label;
|
||||||
|
@ -38,7 +38,6 @@ import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|||||||
import static megabasterd.MiscTools.truncateText;
|
import static megabasterd.MiscTools.truncateText;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
|
|
||||||
|
|
||||||
public final class SettingsDialog extends javax.swing.JDialog {
|
public final class SettingsDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
private String _download_path;
|
private String _download_path;
|
||||||
@ -61,6 +60,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form Settings
|
* Creates new form Settings
|
||||||
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param modal
|
* @param modal
|
||||||
*/
|
*/
|
||||||
@ -71,7 +71,8 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(change_download_dir_button, FONT_DEFAULT, Font.PLAIN);
|
public void run() {
|
||||||
|
updateFont(change_download_dir_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(down_dir_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(down_dir_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(ok_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(ok_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(cancel_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(cancel_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
@ -100,9 +101,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
updateFont(default_dir_label, FONT_DEFAULT, Font.PLAIN);
|
updateFont(default_dir_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(encrypt_pass_checkbox, FONT_DEFAULT, Font.PLAIN);
|
updateFont(encrypt_pass_checkbox, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(unlock_accounts_button, FONT_DEFAULT, Font.PLAIN);
|
updateFont(unlock_accounts_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(delete_all_accounts_button, FONT_DEFAULT, Font.PLAIN);}}, true);
|
updateFont(delete_all_accounts_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
_main_panel = ((MainPanelView) parent).getMain_panel();
|
_main_panel = ((MainPanelView) parent).getMain_panel();
|
||||||
|
|
||||||
@ -140,7 +141,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) default_slots_up_spinner.getEditor()).getTextField(), false);
|
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) default_slots_up_spinner.getEditor()).getTextField(), false);
|
||||||
|
|
||||||
|
|
||||||
String max_down = DBTools.selectSettingValueFromDB("max_downloads");
|
String max_down = DBTools.selectSettingValueFromDB("max_downloads");
|
||||||
|
|
||||||
int max_dl = Download.SIM_TRANSFERENCES_DEFAULT;
|
int max_dl = Download.SIM_TRANSFERENCES_DEFAULT;
|
||||||
@ -149,11 +149,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
max_dl = Integer.parseInt(max_down);
|
max_dl = Integer.parseInt(max_down);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setModel", max_downloads_spinner, new SpinnerNumberModel(max_dl, 1, Download.MAX_SIM_TRANSFERENCES, 1));
|
swingReflectionInvokeAndWait("setModel", max_downloads_spinner, new SpinnerNumberModel(max_dl, 1, Download.MAX_SIM_TRANSFERENCES, 1));
|
||||||
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_downloads_spinner.getEditor()).getTextField(), false);
|
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_downloads_spinner.getEditor()).getTextField(), false);
|
||||||
|
|
||||||
|
|
||||||
String max_up = DBTools.selectSettingValueFromDB("max_uploads");
|
String max_up = DBTools.selectSettingValueFromDB("max_uploads");
|
||||||
|
|
||||||
int max_ul = Upload.SIM_TRANSFERENCES_DEFAULT;
|
int max_ul = Upload.SIM_TRANSFERENCES_DEFAULT;
|
||||||
@ -162,11 +160,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
max_ul = Integer.parseInt(max_up);
|
max_ul = Integer.parseInt(max_up);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setModel", max_uploads_spinner, new SpinnerNumberModel(max_ul, 1, Upload.MAX_SIM_TRANSFERENCES, 1));
|
swingReflectionInvokeAndWait("setModel", max_uploads_spinner, new SpinnerNumberModel(max_ul, 1, Upload.MAX_SIM_TRANSFERENCES, 1));
|
||||||
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_uploads_spinner.getEditor()).getTextField(), false);
|
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_uploads_spinner.getEditor()).getTextField(), false);
|
||||||
|
|
||||||
|
|
||||||
boolean limit_dl_speed = Download.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
boolean limit_dl_speed = Download.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
||||||
|
|
||||||
String limit_download_speed = DBTools.selectSettingValueFromDB("limit_download_speed");
|
String limit_download_speed = DBTools.selectSettingValueFromDB("limit_download_speed");
|
||||||
@ -194,12 +190,10 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
max_download_speed = Integer.parseInt(max_dl_speed);
|
max_download_speed = Integer.parseInt(max_dl_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setModel", max_down_speed_spinner, new SpinnerNumberModel(max_download_speed, 1, Integer.MAX_VALUE, 5));
|
swingReflectionInvokeAndWait("setModel", max_down_speed_spinner, new SpinnerNumberModel(max_download_speed, 1, Integer.MAX_VALUE, 5));
|
||||||
|
|
||||||
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_down_speed_spinner.getEditor()).getTextField(), true);
|
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_down_speed_spinner.getEditor()).getTextField(), true);
|
||||||
|
|
||||||
|
|
||||||
boolean limit_ul_speed = Upload.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
boolean limit_ul_speed = Upload.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
||||||
|
|
||||||
String limit_upload_speed = DBTools.selectSettingValueFromDB("limit_upload_speed");
|
String limit_upload_speed = DBTools.selectSettingValueFromDB("limit_upload_speed");
|
||||||
@ -231,7 +225,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_up_speed_spinner.getEditor()).getTextField(), true);
|
swingReflectionInvoke("setEditable", ((JSpinner.DefaultEditor) max_up_speed_spinner.getEditor()).getTextField(), true);
|
||||||
|
|
||||||
|
|
||||||
boolean cbc_mac = Download.VERIFY_CBC_MAC_DEFAULT;
|
boolean cbc_mac = Download.VERIFY_CBC_MAC_DEFAULT;
|
||||||
|
|
||||||
String verify_file = DBTools.selectSettingValueFromDB("verify_down_file");
|
String verify_file = DBTools.selectSettingValueFromDB("verify_down_file");
|
||||||
@ -261,7 +254,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
swingReflectionInvoke("setEnabled", default_slots_down_spinner, true);
|
swingReflectionInvoke("setEnabled", default_slots_down_spinner, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
use_slots = Upload.USE_SLOTS_DEFAULT;
|
use_slots = Upload.USE_SLOTS_DEFAULT;
|
||||||
|
|
||||||
use_slots_val = DBTools.selectSettingValueFromDB("use_slots_up");
|
use_slots_val = DBTools.selectSettingValueFromDB("use_slots_up");
|
||||||
@ -769,7 +761,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void change_download_dir_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_change_download_dir_buttonActionPerformed
|
private void change_download_dir_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_change_download_dir_buttonActionPerformed
|
||||||
|
|
||||||
|
|
||||||
javax.swing.JFileChooser filechooser = new javax.swing.JFileChooser();
|
javax.swing.JFileChooser filechooser = new javax.swing.JFileChooser();
|
||||||
|
|
||||||
filechooser.setCurrentDirectory(new java.io.File(_download_path));
|
filechooser.setCurrentDirectory(new java.io.File(_download_path));
|
||||||
@ -812,7 +803,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
insertSettingValueInDB("limit_upload_speed", (boolean) swingReflectionInvokeAndWaitForReturn("isSelected", limit_upload_speed_checkbox) ? "yes" : "no");
|
insertSettingValueInDB("limit_upload_speed", (boolean) swingReflectionInvokeAndWaitForReturn("isSelected", limit_upload_speed_checkbox) ? "yes" : "no");
|
||||||
insertSettingValueInDB("max_upload_speed", String.valueOf((int) swingReflectionInvokeAndWaitForReturn("getValue", max_up_speed_spinner)));
|
insertSettingValueInDB("max_upload_speed", String.valueOf((int) swingReflectionInvokeAndWaitForReturn("getValue", max_up_speed_spinner)));
|
||||||
|
|
||||||
|
|
||||||
if (mega_accounts_table.isEnabled()) {
|
if (mega_accounts_table.isEnabled()) {
|
||||||
|
|
||||||
final DefaultTableModel model = (DefaultTableModel) mega_accounts_table.getModel();
|
final DefaultTableModel model = (DefaultTableModel) mega_accounts_table.getModel();
|
||||||
@ -971,7 +961,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@ -1042,10 +1031,8 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void limit_download_speed_checkboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_limit_download_speed_checkboxStateChanged
|
private void limit_download_speed_checkboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_limit_download_speed_checkboxStateChanged
|
||||||
|
|
||||||
|
|
||||||
if (!limit_download_speed_checkbox.isSelected()) {
|
if (!limit_download_speed_checkbox.isSelected()) {
|
||||||
|
|
||||||
|
|
||||||
max_down_speed_label.setEnabled(false);
|
max_down_speed_label.setEnabled(false);
|
||||||
max_down_speed_spinner.setEnabled(false);
|
max_down_speed_spinner.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
@ -1056,7 +1043,6 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void limit_upload_speed_checkboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_limit_upload_speed_checkboxStateChanged
|
private void limit_upload_speed_checkboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_limit_upload_speed_checkboxStateChanged
|
||||||
|
|
||||||
|
|
||||||
if (!limit_upload_speed_checkbox.isSelected()) {
|
if (!limit_upload_speed_checkbox.isSelected()) {
|
||||||
|
|
||||||
max_up_speed_label.setEnabled(false);
|
max_up_speed_label.setEnabled(false);
|
||||||
@ -1171,7 +1157,8 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEnabled", encrypt_pass_checkbox, true);
|
swingReflectionInvoke("setEnabled", encrypt_pass_checkbox, true);
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}//GEN-LAST:event_encrypt_pass_checkboxActionPerformed
|
}//GEN-LAST:event_encrypt_pass_checkboxActionPerformed
|
||||||
|
|
||||||
@ -1242,7 +1229,8 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
swingReflectionInvoke("setEnabled", unlock_accounts_button, true);
|
swingReflectionInvoke("setEnabled", unlock_accounts_button, true);
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}//GEN-LAST:event_unlock_accounts_buttonActionPerformed
|
}//GEN-LAST:event_unlock_accounts_buttonActionPerformed
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import java.util.logging.Level;
|
|||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
import static megabasterd.MiscTools.formatBytes;
|
||||||
|
|
||||||
public final class SpeedMeter implements Runnable, SecureNotifiable
|
public final class SpeedMeter implements Runnable, SecureNotifiable {
|
||||||
{
|
|
||||||
public static final int SLEEP = 3000;
|
public static final int SLEEP = 3000;
|
||||||
private long _progress;
|
private long _progress;
|
||||||
private final Transference _transference;
|
private final Transference _transference;
|
||||||
@ -16,9 +16,7 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
|
|
||||||
|
SpeedMeter(Transference transference, GlobalSpeedMeter gspeed) {
|
||||||
SpeedMeter(Transference transference, GlobalSpeedMeter gspeed)
|
|
||||||
{
|
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_transference = transference;
|
_transference = transference;
|
||||||
@ -29,8 +27,7 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -42,8 +39,7 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -68,18 +64,15 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setExit(boolean exit) {
|
public void setExit(boolean exit) {
|
||||||
_exit = exit;
|
_exit = exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastSpeed()
|
public long getLastSpeed() {
|
||||||
{
|
|
||||||
return _lastSpeed;
|
return _lastSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastSpeed(long speed)
|
public void setLastSpeed(long speed) {
|
||||||
{
|
|
||||||
_lastSpeed = speed;
|
_lastSpeed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +82,7 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
System.out.println("SpeedMeter hello!");
|
System.out.println("SpeedMeter hello!");
|
||||||
|
|
||||||
long last_progress = _progress, sp;
|
long last_progress = _progress, sp;
|
||||||
@ -99,16 +91,13 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
_transference.getView().updateSpeed("------", true);
|
_transference.getView().updateSpeed("------", true);
|
||||||
_transference.getView().updateRemainingTime("--d --:--:--", true);
|
_transference.getView().updateRemainingTime("--d --:--:--", true);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
no_data_count = 0;
|
no_data_count = 0;
|
||||||
|
|
||||||
while(!_exit)
|
while (!_exit) {
|
||||||
{
|
|
||||||
Thread.sleep(SpeedMeter.SLEEP * (no_data_count + 1));
|
Thread.sleep(SpeedMeter.SLEEP * (no_data_count + 1));
|
||||||
|
|
||||||
if(!_exit)
|
if (!_exit) {
|
||||||
{
|
|
||||||
updateProgress();
|
updateProgress();
|
||||||
|
|
||||||
if (_transference.isPaused()) {
|
if (_transference.isPaused()) {
|
||||||
@ -160,29 +149,26 @@ public final class SpeedMeter implements Runnable, SecureNotifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (InterruptedException ex) {
|
||||||
catch (InterruptedException ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String calculateRemTime(long seconds)
|
private String calculateRemTime(long seconds) {
|
||||||
{
|
|
||||||
int days = (int) TimeUnit.SECONDS.toDays(seconds);
|
int days = (int) TimeUnit.SECONDS.toDays(seconds);
|
||||||
|
|
||||||
long hours = TimeUnit.SECONDS.toHours(seconds) -
|
long hours = TimeUnit.SECONDS.toHours(seconds)
|
||||||
TimeUnit.DAYS.toHours(days);
|
- TimeUnit.DAYS.toHours(days);
|
||||||
|
|
||||||
long minutes = TimeUnit.SECONDS.toMinutes(seconds) -
|
long minutes = TimeUnit.SECONDS.toMinutes(seconds)
|
||||||
TimeUnit.DAYS.toMinutes(days) -
|
- TimeUnit.DAYS.toMinutes(days)
|
||||||
TimeUnit.HOURS.toMinutes(hours);
|
- TimeUnit.HOURS.toMinutes(hours);
|
||||||
|
|
||||||
long secs = TimeUnit.SECONDS.toSeconds(seconds) -
|
long secs = TimeUnit.SECONDS.toSeconds(seconds)
|
||||||
TimeUnit.DAYS.toSeconds(days) -
|
- TimeUnit.DAYS.toSeconds(days)
|
||||||
TimeUnit.HOURS.toSeconds(hours) -
|
- TimeUnit.HOURS.toSeconds(hours)
|
||||||
TimeUnit.MINUTES.toSeconds(minutes);
|
- TimeUnit.MINUTES.toSeconds(minutes);
|
||||||
|
|
||||||
return String.format("%dd %d:%02d:%02d", days, hours, minutes, secs);
|
return String.format("%dd %d:%02d:%02d", days, hours, minutes, secs);
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,15 @@ import static java.util.logging.Logger.getLogger;
|
|||||||
public final class SqliteSingleton {
|
public final class SqliteSingleton {
|
||||||
|
|
||||||
public static final String SQLITE_FILE = "megabasterd.db";
|
public static final String SQLITE_FILE = "megabasterd.db";
|
||||||
|
|
||||||
public static SqliteSingleton getInstance() {
|
public static SqliteSingleton getInstance() {
|
||||||
|
|
||||||
return LazyHolder.INSTANCE;
|
return LazyHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SqliteSingleton() {}
|
private SqliteSingleton() {
|
||||||
|
}
|
||||||
|
|
||||||
public Connection getConn() {
|
public Connection getConn() {
|
||||||
|
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
|
@ -64,10 +64,8 @@ public final class StreamThrottlerSupervisor implements Runnable, SecureNotifiab
|
|||||||
return _output_slice_queue;
|
return _output_slice_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -79,8 +77,7 @@ public final class StreamThrottlerSupervisor implements Runnable, SecureNotifiab
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -116,8 +113,7 @@ public final class StreamThrottlerSupervisor implements Runnable, SecureNotifiab
|
|||||||
|
|
||||||
int slice_num = (int) Math.floor((double) _maxBytesPerSecInput / _slice_size);
|
int slice_num = (int) Math.floor((double) _maxBytesPerSecInput / _slice_size);
|
||||||
|
|
||||||
for(int i=0; i<slice_num; i++)
|
for (int i = 0; i < slice_num; i++) {
|
||||||
{
|
|
||||||
_input_slice_queue.add(_slice_size);
|
_input_slice_queue.add(_slice_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +129,7 @@ public final class StreamThrottlerSupervisor implements Runnable, SecureNotifiab
|
|||||||
|
|
||||||
int slice_num = (int) Math.floor((double) _maxBytesPerSecOutput / _slice_size);
|
int slice_num = (int) Math.floor((double) _maxBytesPerSecOutput / _slice_size);
|
||||||
|
|
||||||
for(int i=0; i<slice_num; i++)
|
for (int i = 0; i < slice_num; i++) {
|
||||||
{
|
|
||||||
_output_slice_queue.add(_slice_size);
|
_output_slice_queue.add(_slice_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import static java.util.logging.Logger.getLogger;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
import static megabasterd.MiscTools.copyTextToClipboard;
|
|
||||||
import static megabasterd.MiscTools.deflateURL;
|
import static megabasterd.MiscTools.deflateURL;
|
||||||
import static megabasterd.MiscTools.extractFirstMegaLinkFromString;
|
import static megabasterd.MiscTools.extractFirstMegaLinkFromString;
|
||||||
import static megabasterd.MiscTools.extractStringFromClipboardContents;
|
import static megabasterd.MiscTools.extractStringFromClipboardContents;
|
||||||
@ -30,6 +29,7 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form Streamer
|
* Creates new form Streamer
|
||||||
|
*
|
||||||
* @param clipboardspy
|
* @param clipboardspy
|
||||||
*/
|
*/
|
||||||
public StreamerDialog(java.awt.Frame parent, boolean modal, ClipboardSpy clipboardspy) {
|
public StreamerDialog(java.awt.Frame parent, boolean modal, ClipboardSpy clipboardspy) {
|
||||||
@ -41,11 +41,12 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
MiscTools.swingInvokeIt(new Runnable() {
|
MiscTools.swingInvokeIt(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {updateFont(put_label, FONT_DEFAULT, Font.PLAIN);
|
public void run() {
|
||||||
|
updateFont(put_label, FONT_DEFAULT, Font.PLAIN);
|
||||||
updateFont(dance_button, FONT_DEFAULT, Font.PLAIN);}}, true);
|
|
||||||
|
|
||||||
|
|
||||||
|
updateFont(dance_button, FONT_DEFAULT, Font.PLAIN);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
notifyClipboardChange();
|
notifyClipboardChange();
|
||||||
}
|
}
|
||||||
@ -150,8 +151,7 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
|
|
||||||
link = link.replace("/#!N?", "/#N!");
|
link = link.replace("/#!N?", "/#N!");
|
||||||
|
|
||||||
if( findFirstRegex("://mega(\\.co)?\\.nz/#[^fF]", link, 0) != null)
|
if (findFirstRegex("://mega(\\.co)?\\.nz/#[^fF]", link, 0) != null) {
|
||||||
{
|
|
||||||
data = findFirstRegex("/#(N?!.+)", link, 1);
|
data = findFirstRegex("/#(N?!.+)", link, 1);
|
||||||
|
|
||||||
stream_link = "http://localhost:1337/video/mega/" + data;
|
stream_link = "http://localhost:1337/video/mega/" + data;
|
||||||
@ -184,7 +184,7 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
copyTextToClipboard(deflateURL(stream_link));
|
MiscTools.copyTextToClipboard(deflateURL(stream_link));
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(tthis, "Streaming link was copied to clipboard!\n(Remember to keep MegaBasterd running in background while playing)");
|
JOptionPane.showMessageDialog(tthis, "Streaming link was copied to clipboard!\n(Remember to keep MegaBasterd running in background while playing)");
|
||||||
|
|
||||||
@ -197,7 +197,8 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_dance_buttonActionPerformed
|
}//GEN-LAST:event_dance_buttonActionPerformed
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -211,7 +212,6 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton dance_button;
|
private javax.swing.JButton dance_button;
|
||||||
private javax.swing.JTextField original_link_textfield;
|
private javax.swing.JTextField original_link_textfield;
|
||||||
|
@ -17,7 +17,6 @@ public final class ThrottledInputStream extends InputStream {
|
|||||||
|
|
||||||
private boolean _stream_finish;
|
private boolean _stream_finish;
|
||||||
|
|
||||||
|
|
||||||
public ThrottledInputStream(InputStream rawStream, StreamThrottlerSupervisor stream_supervisor) {
|
public ThrottledInputStream(InputStream rawStream, StreamThrottlerSupervisor stream_supervisor) {
|
||||||
|
|
||||||
_rawStream = rawStream;
|
_rawStream = rawStream;
|
||||||
@ -29,7 +28,6 @@ public final class ThrottledInputStream extends InputStream {
|
|||||||
_slice_size = null;
|
_slice_size = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
|
|
||||||
@ -69,7 +67,6 @@ public final class ThrottledInputStream extends InputStream {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] b) throws IOException {
|
public int read(byte[] b) throws IOException {
|
||||||
|
|
||||||
@ -123,7 +120,6 @@ public final class ThrottledInputStream extends InputStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
public int read(byte[] b, int off, int len) throws IOException {
|
||||||
|
|
||||||
@ -187,7 +183,6 @@ public final class ThrottledInputStream extends InputStream {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() throws IOException {
|
public void reset() throws IOException {
|
||||||
|
|
||||||
@ -197,7 +192,6 @@ public final class ThrottledInputStream extends InputStream {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void throttle(int size) throws IOException {
|
private void throttle(int size) throws IOException {
|
||||||
|
|
||||||
_slice_size = null;
|
_slice_size = null;
|
||||||
|
@ -15,7 +15,6 @@ public final class ThrottledOutputStream extends OutputStream {
|
|||||||
|
|
||||||
private Integer slice_size;
|
private Integer slice_size;
|
||||||
|
|
||||||
|
|
||||||
public ThrottledOutputStream(OutputStream rawStream, StreamThrottlerSupervisor stream_supervisor) {
|
public ThrottledOutputStream(OutputStream rawStream, StreamThrottlerSupervisor stream_supervisor) {
|
||||||
|
|
||||||
_rawStream = rawStream;
|
_rawStream = rawStream;
|
||||||
@ -26,7 +25,6 @@ public final class ThrottledOutputStream extends OutputStream {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
|
|
||||||
@ -74,7 +72,6 @@ public final class ThrottledOutputStream extends OutputStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void throttle(int size) throws IOException {
|
private void throttle(int size) throws IOException {
|
||||||
|
|
||||||
slice_size = null;
|
slice_size = null;
|
||||||
|
@ -16,6 +16,7 @@ public interface Transference {
|
|||||||
int SIM_TRANSFERENCES_DEFAULT = 2;
|
int SIM_TRANSFERENCES_DEFAULT = 2;
|
||||||
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
|
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
|
||||||
int MAX_TRANSFERENCE_SPEED_DEFAULT = 5;
|
int MAX_TRANSFERENCE_SPEED_DEFAULT = 5;
|
||||||
|
int MAX_WAIT_WORKERS_SHUTDOWN = 10;
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
private volatile boolean _starting_transferences;
|
private volatile boolean _starting_transferences;
|
||||||
private volatile boolean _preprocessing_transferences;
|
private volatile boolean _preprocessing_transferences;
|
||||||
private volatile int _pre_count;
|
private volatile int _pre_count;
|
||||||
|
|
||||||
public TransferenceManager(MainPanel main_panel, int max_running_trans, javax.swing.JLabel status, javax.swing.JPanel scroll_panel, javax.swing.JButton close_all_button, javax.swing.JButton pause_all_button, javax.swing.MenuElement clean_all_menu) {
|
public TransferenceManager(MainPanel main_panel, int max_running_trans, javax.swing.JLabel status, javax.swing.JPanel scroll_panel, javax.swing.JButton close_all_button, javax.swing.JButton pause_all_button, javax.swing.MenuElement clean_all_menu) {
|
||||||
_notified = false;
|
_notified = false;
|
||||||
_removing_transferences = false;
|
_removing_transferences = false;
|
||||||
@ -110,11 +111,8 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
this._max_running_trans = _max_running_trans;
|
this._max_running_trans = _max_running_trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -126,8 +124,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -188,8 +185,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
return _scroll_panel;
|
return _scroll_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeAllFinished()
|
public void closeAllFinished() {
|
||||||
{
|
|
||||||
_transference_remove_queue.addAll(new ArrayList(_transference_finished_queue));
|
_transference_remove_queue.addAll(new ArrayList(_transference_finished_queue));
|
||||||
|
|
||||||
_transference_finished_queue.clear();
|
_transference_finished_queue.clear();
|
||||||
@ -197,8 +193,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
secureNotify();
|
secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeAllPreProWaiting()
|
public void closeAllPreProWaiting() {
|
||||||
{
|
|
||||||
_transference_preprocess_queue.clear();
|
_transference_preprocess_queue.clear();
|
||||||
|
|
||||||
_pre_count = 0;
|
_pre_count = 0;
|
||||||
@ -223,8 +218,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
secureNotify();
|
secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pauseAll()
|
public void pauseAll() {
|
||||||
{
|
|
||||||
for (Transference transference : _transference_running_list) {
|
for (Transference transference : _transference_running_list) {
|
||||||
|
|
||||||
if (!transference.isPaused()) {
|
if (!transference.isPaused()) {
|
||||||
@ -236,8 +230,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
secureNotify();
|
secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sortTransferenceStartQueue()
|
public void sortTransferenceStartQueue() {
|
||||||
{
|
|
||||||
ArrayList<Transference> trans_list = new ArrayList(_transference_waitstart_queue);
|
ArrayList<Transference> trans_list = new ArrayList(_transference_waitstart_queue);
|
||||||
|
|
||||||
trans_list.sort(new Comparator<Transference>() {
|
trans_list.sort(new Comparator<Transference>() {
|
||||||
@ -315,8 +308,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
while(true)
|
while (true) {
|
||||||
{
|
|
||||||
if (!isPreprocessing_transferences() && !getTransference_preprocess_queue().isEmpty()) {
|
if (!isPreprocessing_transferences() && !getTransference_preprocess_queue().isEmpty()) {
|
||||||
|
|
||||||
setPreprocessing_transferences(true);
|
setPreprocessing_transferences(true);
|
||||||
@ -325,8 +317,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
while(!getTransference_preprocess_queue().isEmpty())
|
while (!getTransference_preprocess_queue().isEmpty()) {
|
||||||
{
|
|
||||||
Runnable run = getTransference_preprocess_queue().poll();
|
Runnable run = getTransference_preprocess_queue().poll();
|
||||||
|
|
||||||
if (run != null) {
|
if (run != null) {
|
||||||
@ -339,7 +330,8 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isProvisioning_transferences() && !getTransference_provision_queue().isEmpty()) {
|
if (!isProvisioning_transferences() && !getTransference_provision_queue().isEmpty()) {
|
||||||
@ -350,8 +342,7 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
while(!getTransference_provision_queue().isEmpty())
|
while (!getTransference_provision_queue().isEmpty()) {
|
||||||
{
|
|
||||||
Transference transference = getTransference_provision_queue().poll();
|
Transference transference = getTransference_provision_queue().poll();
|
||||||
|
|
||||||
if (transference != null) {
|
if (transference != null) {
|
||||||
@ -365,7 +356,8 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +382,8 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isStarting_transferences() && !getTransference_waitstart_queue().isEmpty() && getTransference_running_list().size() < _max_running_trans) {
|
if (!isStarting_transferences() && !getTransference_waitstart_queue().isEmpty() && getTransference_running_list().size() < _max_running_trans) {
|
||||||
@ -414,7 +407,8 @@ abstract public class TransferenceManager implements Runnable, SecureNotifiable
|
|||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateView();
|
updateView();
|
||||||
|
@ -7,14 +7,23 @@ package megabasterd;
|
|||||||
public interface TransferenceView {
|
public interface TransferenceView {
|
||||||
|
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
void resume();
|
void resume();
|
||||||
|
|
||||||
void updateSpeed(String speed, Boolean visible);
|
void updateSpeed(String speed, Boolean visible);
|
||||||
|
|
||||||
void updateRemainingTime(String rem_time, Boolean visible);
|
void updateRemainingTime(String rem_time, Boolean visible);
|
||||||
|
|
||||||
void updateProgressBar(long progress, double bar_rate);
|
void updateProgressBar(long progress, double bar_rate);
|
||||||
|
|
||||||
void updateSlotsStatus();
|
void updateSlotsStatus();
|
||||||
|
|
||||||
void printStatusNormal(String msg);
|
void printStatusNormal(String msg);
|
||||||
|
|
||||||
void printStatusOK(String msg);
|
void printStatusOK(String msg);
|
||||||
|
|
||||||
void printStatusError(String msg);
|
void printStatusError(String msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -329,8 +329,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -342,8 +341,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -368,7 +366,6 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void provisionIt() {
|
public void provisionIt() {
|
||||||
|
|
||||||
printStatus("Provisioning upload, please wait...");
|
printStatus("Provisioning upload, please wait...");
|
||||||
@ -469,7 +466,6 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
swingReflectionInvoke("setVisible", getView().getClose_button(), true);
|
swingReflectionInvoke("setVisible", getView().getClose_button(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
||||||
@ -570,14 +566,12 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
return getPartialProgressQueue();
|
return getPartialProgressQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MainPanel getMain_panel() {
|
public MainPanel getMain_panel() {
|
||||||
return _main_panel;
|
return _main_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void startSlot()
|
public synchronized void startSlot() {
|
||||||
{
|
|
||||||
int chunkthiser_id = _chunkworkers.size() + 1;
|
int chunkthiser_id = _chunkworkers.size() + 1;
|
||||||
|
|
||||||
ChunkUploader c = new ChunkUploader(chunkthiser_id, this);
|
ChunkUploader c = new ChunkUploader(chunkthiser_id, this);
|
||||||
@ -588,15 +582,16 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
_thread_pool.execute(c);
|
_thread_pool.execute(c);
|
||||||
|
|
||||||
}catch(java.util.concurrent.RejectedExecutionException e){System.out.println(e.getMessage());}
|
} catch (java.util.concurrent.RejectedExecutionException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPause(boolean pause) {
|
public void setPause(boolean pause) {
|
||||||
_pause = pause;
|
_pause = pause;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stopLastStartedSlot()
|
public synchronized void stopLastStartedSlot() {
|
||||||
{
|
|
||||||
if (!_chunkworkers.isEmpty()) {
|
if (!_chunkworkers.isEmpty()) {
|
||||||
|
|
||||||
swingReflectionInvoke("setEnabled", getView().getSlots_spinner(), false);
|
swingReflectionInvoke("setEnabled", getView().getSlots_spinner(), false);
|
||||||
@ -625,8 +620,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rejectChunkId(long chunk_id)
|
public void rejectChunkId(long chunk_id) {
|
||||||
{
|
|
||||||
_rejectedChunkIds.add(chunk_id);
|
_rejectedChunkIds.add(chunk_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,8 +633,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
printStatus("Starting upload, please wait...");
|
printStatus("Starting upload, please wait...");
|
||||||
|
|
||||||
if(!_exit)
|
if (!_exit) {
|
||||||
{
|
|
||||||
if (_ul_url == null) {
|
if (_ul_url == null) {
|
||||||
|
|
||||||
_ul_url = _ma.initUploadFile(_file_name);
|
_ul_url = _ma.initUploadFile(_file_name);
|
||||||
@ -648,8 +641,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
DBTools.updateUploadUrl(_file_name, _ma.getEmail(), _ul_url);
|
DBTools.updateUploadUrl(_file_name, _ma.getEmail(), _ul_url);
|
||||||
}
|
} catch (SQLException ex) {
|
||||||
catch (SQLException ex) {
|
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,8 +652,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
_byte_file_iv = i32a2bin(file_iv);
|
_byte_file_iv = i32a2bin(file_iv);
|
||||||
|
|
||||||
if(!_exit)
|
if (!_exit) {
|
||||||
{
|
|
||||||
|
|
||||||
swingReflectionInvoke("setMinimum", getView().getProgress_pbar(), 0);
|
swingReflectionInvoke("setMinimum", getView().getProgress_pbar(), 0);
|
||||||
swingReflectionInvoke("setMaximum", getView().getProgress_pbar(), Integer.MAX_VALUE);
|
swingReflectionInvoke("setMaximum", getView().getProgress_pbar(), Integer.MAX_VALUE);
|
||||||
@ -692,8 +683,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
if (_use_slots) {
|
if (_use_slots) {
|
||||||
|
|
||||||
for(int t=1; t <= _slots; t++)
|
for (int t = 1; t <= _slots; t++) {
|
||||||
{
|
|
||||||
ChunkUploader c = new ChunkUploader(t, this);
|
ChunkUploader c = new ChunkUploader(t, this);
|
||||||
|
|
||||||
_chunkworkers.add(c);
|
_chunkworkers.add(c);
|
||||||
@ -707,7 +697,6 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
swingReflectionInvoke("setVisible", getView().getSlot_status_label(), true);
|
swingReflectionInvoke("setVisible", getView().getSlot_status_label(), true);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ChunkUploaderMono c = new ChunkUploaderMono(this);
|
ChunkUploaderMono c = new ChunkUploaderMono(this);
|
||||||
@ -745,27 +734,31 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
|
|
||||||
_thread_pool.shutdown();
|
_thread_pool.shutdown();
|
||||||
|
|
||||||
while(!_thread_pool.isTerminated())
|
while (!_thread_pool.isTerminated()) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
_thread_pool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
|
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_thread_pool.isTerminated()) {
|
||||||
|
|
||||||
|
System.out.println("Cerrando thread pool a lo mecagüen...");
|
||||||
|
|
||||||
|
_thread_pool.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("Uploader thread pool finished!");
|
System.out.println("Uploader thread pool finished!");
|
||||||
|
|
||||||
getMain_panel().getGlobal_up_speed().detachSpeedMeter(getSpeed_meter());
|
getMain_panel().getGlobal_up_speed().detachSpeedMeter(getSpeed_meter());
|
||||||
|
|
||||||
getMain_panel().getGlobal_up_speed().secureNotify();
|
getMain_panel().getGlobal_up_speed().secureNotify();
|
||||||
|
|
||||||
|
|
||||||
swingReflectionInvoke("setVisible", new Object[]{getView().getSpeed_label(), getView().getRemtime_label(), getView().getPause_button(), getView().getStop_button(), getView().getSlots_label(), getView().getSlots_spinner()}, false);
|
swingReflectionInvoke("setVisible", new Object[]{getView().getSpeed_label(), getView().getRemtime_label(), getView().getPause_button(), getView().getStop_button(), getView().getSlots_label(), getView().getSlots_spinner()}, false);
|
||||||
|
|
||||||
|
|
||||||
getMain_panel().getUpload_manager().secureNotify();
|
getMain_panel().getUpload_manager().secureNotify();
|
||||||
|
|
||||||
if (!_exit) {
|
if (!_exit) {
|
||||||
@ -834,17 +827,13 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (_fatal_error != null) {
|
||||||
else if(_fatal_error != null)
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
printStatusError(_fatal_error);
|
printStatusError(_fatal_error);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
_exit_message = "Upload CANCELED!";
|
_exit_message = "Upload CANCELED!";
|
||||||
@ -854,9 +843,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (_fatal_error != null) {
|
||||||
else if(_fatal_error != null)
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
_exit_message = _fatal_error;
|
_exit_message = _fatal_error;
|
||||||
@ -864,9 +851,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
printStatusError(_fatal_error);
|
printStatusError(_fatal_error);
|
||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
_exit_message = "Upload CANCELED!";
|
_exit_message = "Upload CANCELED!";
|
||||||
@ -905,7 +890,6 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
System.out.println("Uploader BYE BYE");
|
System.out.println("Uploader BYE BYE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized void pause_worker() {
|
public synchronized void pause_worker() {
|
||||||
|
|
||||||
if (++_paused_workers >= _chunkworkers.size() && !_exit) {
|
if (++_paused_workers >= _chunkworkers.size() && !_exit) {
|
||||||
@ -916,10 +900,8 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stopThisSlot(ChunkUploader chunkuploader)
|
public synchronized void stopThisSlot(ChunkUploader chunkuploader) {
|
||||||
{
|
if (_chunkworkers.remove(chunkuploader)) {
|
||||||
if(_chunkworkers.remove(chunkuploader))
|
|
||||||
{
|
|
||||||
if (!chunkuploader.isExit()) {
|
if (!chunkuploader.isExit()) {
|
||||||
|
|
||||||
_finishing_upload = true;
|
_finishing_upload = true;
|
||||||
@ -944,24 +926,20 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void emergencyStopUploader(String reason)
|
public synchronized void emergencyStopUploader(String reason) {
|
||||||
{
|
if (_fatal_error == null) {
|
||||||
if(_fatal_error == null)
|
|
||||||
{
|
|
||||||
_fatal_error = reason != null ? reason : "FATAL ERROR!";
|
_fatal_error = reason != null ? reason : "FATAL ERROR!";
|
||||||
|
|
||||||
stopUploader();
|
stopUploader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized long nextChunkId()
|
public synchronized long nextChunkId() {
|
||||||
{
|
|
||||||
Long next_id;
|
Long next_id;
|
||||||
|
|
||||||
if ((next_id = _rejectedChunkIds.poll()) != null) {
|
if ((next_id = _rejectedChunkIds.poll()) != null) {
|
||||||
return next_id;
|
return next_id;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return ++_last_chunk_id_dispatched;
|
return ++_last_chunk_id_dispatched;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -970,10 +948,8 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
_exit = exit;
|
_exit = exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stopUploader()
|
public synchronized void stopUploader() {
|
||||||
{
|
if (!_exit) {
|
||||||
if(!_exit)
|
|
||||||
{
|
|
||||||
setExit(true);
|
setExit(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1001,21 +977,17 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void printStatusError(String message) {
|
||||||
private void printStatusError(String message)
|
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", getView().getStatus_label(), Color.red);
|
swingReflectionInvoke("setForeground", getView().getStatus_label(), Color.red);
|
||||||
swingReflectionInvoke("setText", getView().getStatus_label(), message);
|
swingReflectionInvoke("setText", getView().getStatus_label(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printStatusOK(String message)
|
private void printStatusOK(String message) {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", getView().getStatus_label(), new Color(0, 128, 0));
|
swingReflectionInvoke("setForeground", getView().getStatus_label(), new Color(0, 128, 0));
|
||||||
swingReflectionInvoke("setText", getView().getStatus_label(), message);
|
swingReflectionInvoke("setText", getView().getStatus_label(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printStatus(String message)
|
private void printStatus(String message) {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setForeground", getView().getStatus_label(), Color.BLACK);
|
swingReflectionInvoke("setForeground", getView().getStatus_label(), Color.BLACK);
|
||||||
swingReflectionInvoke("setText", getView().getStatus_label(), message);
|
swingReflectionInvoke("setText", getView().getStatus_label(), message);
|
||||||
}
|
}
|
||||||
@ -1026,5 +998,4 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
|
|||||||
getView().updateProgressBar(_progress, _progress_bar_rate);
|
getView().updateProgressBar(_progress, _progress_bar_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public final class UploadMACGenerator implements Runnable, SecureNotifiable {
|
|||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
private volatile boolean _exit;
|
private volatile boolean _exit;
|
||||||
private long _bytes_read;
|
private long _bytes_read;
|
||||||
|
|
||||||
public UploadMACGenerator(Upload upload) {
|
public UploadMACGenerator(Upload upload) {
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_notified = false;
|
_notified = false;
|
||||||
@ -41,10 +42,8 @@ public final class UploadMACGenerator implements Runnable, SecureNotifiable {
|
|||||||
_exit = false;
|
_exit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void secureNotify()
|
public void secureNotify() {
|
||||||
{
|
|
||||||
synchronized (_secure_notify_lock) {
|
synchronized (_secure_notify_lock) {
|
||||||
|
|
||||||
_notified = true;
|
_notified = true;
|
||||||
@ -56,8 +55,7 @@ public final class UploadMACGenerator implements Runnable, SecureNotifiable {
|
|||||||
@Override
|
@Override
|
||||||
public void secureWait() {
|
public void secureWait() {
|
||||||
|
|
||||||
synchronized(_secure_notify_lock)
|
synchronized (_secure_notify_lock) {
|
||||||
{
|
|
||||||
while (!_notified) {
|
while (!_notified) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -106,7 +104,6 @@ public final class UploadMACGenerator implements Runnable, SecureNotifiable {
|
|||||||
_exit = exit;
|
_exit = exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
@ -123,38 +120,32 @@ public final class UploadMACGenerator implements Runnable, SecureNotifiable {
|
|||||||
String temp_file_data = "";
|
String temp_file_data = "";
|
||||||
boolean new_chunk = false;
|
boolean new_chunk = false;
|
||||||
|
|
||||||
while(!_exit && (!_upload.isStopped() || !_upload.getChunkworkers().isEmpty()) && (_bytes_read < _upload.getFile_size() || (_upload.getFile_size() == 0 && _last_chunk_id_read < 1)))
|
while (!_exit && (!_upload.isStopped() || !_upload.getChunkworkers().isEmpty()) && (_bytes_read < _upload.getFile_size() || (_upload.getFile_size() == 0 && _last_chunk_id_read < 1))) {
|
||||||
{
|
while (_chunk_queue.containsKey(_last_chunk_id_read + 1)) {
|
||||||
while(_chunk_queue.containsKey(_last_chunk_id_read+1))
|
|
||||||
{
|
|
||||||
chunk = _chunk_queue.get(_last_chunk_id_read + 1);
|
chunk = _chunk_queue.get(_last_chunk_id_read + 1);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
int[] chunk_mac = {file_iv[0], file_iv[1], file_iv[0], file_iv[1]};
|
int[] chunk_mac = {file_iv[0], file_iv[1], file_iv[0], file_iv[1]};
|
||||||
|
|
||||||
InputStream chunk_is = chunk.getInputStream();
|
InputStream chunk_is = chunk.getInputStream();
|
||||||
|
|
||||||
while( (reads=chunk_is.read(byte_block)) != -1 )
|
while ((reads = chunk_is.read(byte_block)) != -1) {
|
||||||
{
|
if (reads < byte_block.length) {
|
||||||
if(reads<byte_block.length)
|
for (int i = reads; i < byte_block.length; i++) {
|
||||||
{
|
|
||||||
for(int i=reads; i<byte_block.length; i++)
|
|
||||||
byte_block[i] = 0;
|
byte_block[i] = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int_block = bin2i32a(byte_block);
|
int_block = bin2i32a(byte_block);
|
||||||
|
|
||||||
for(int i=0; i<chunk_mac.length; i++)
|
for (int i = 0; i < chunk_mac.length; i++) {
|
||||||
{
|
|
||||||
chunk_mac[i] ^= int_block[i];
|
chunk_mac[i] ^= int_block[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_mac = CryptTools.aes_cbc_encrypt_ia32(chunk_mac, bin2i32a(_upload.getByte_file_key()), mac_iv);
|
chunk_mac = CryptTools.aes_cbc_encrypt_ia32(chunk_mac, bin2i32a(_upload.getByte_file_key()), mac_iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<file_mac.length; i++)
|
for (int i = 0; i < file_mac.length; i++) {
|
||||||
{
|
|
||||||
file_mac[i] ^= chunk_mac[i];
|
file_mac[i] ^= chunk_mac[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,8 +180,7 @@ public final class UploadMACGenerator implements Runnable, SecureNotifiable {
|
|||||||
new_chunk = false;
|
new_chunk = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_exit && (!_upload.isStopped() || !_upload.getChunkworkers().isEmpty()) && (_bytes_read < _upload.getFile_size() || (_upload.getFile_size() == 0 && _last_chunk_id_read < 1)))
|
if (!_exit && (!_upload.isStopped() || !_upload.getChunkworkers().isEmpty()) && (_bytes_read < _upload.getFile_size() || (_upload.getFile_size() == 0 && _last_chunk_id_read < 1))) {
|
||||||
{
|
|
||||||
System.out.println("METAMAC wait...");
|
System.out.println("METAMAC wait...");
|
||||||
secureWait();
|
secureWait();
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import static java.util.logging.Logger.getLogger;
|
|||||||
import static megabasterd.DBTools.deleteUpload;
|
import static megabasterd.DBTools.deleteUpload;
|
||||||
import static megabasterd.MiscTools.HashString;
|
import static megabasterd.MiscTools.HashString;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tonikelope
|
* @author tonikelope
|
||||||
@ -23,8 +21,7 @@ public final class UploadManager extends TransferenceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void provision(Transference upload)
|
public void provision(Transference upload) {
|
||||||
{
|
|
||||||
getScroll_panel().add(((Upload) upload).getView());
|
getScroll_panel().add(((Upload) upload).getView());
|
||||||
|
|
||||||
((Upload) upload).provisionIt();
|
((Upload) upload).provisionIt();
|
||||||
@ -57,7 +54,6 @@ public final class UploadManager extends TransferenceManager {
|
|||||||
secureNotify();
|
secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(Transference upload) {
|
public void remove(Transference upload) {
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import javax.swing.JSpinner;
|
|||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import static megabasterd.MainPanel.FONT_DEFAULT;
|
import static megabasterd.MainPanel.FONT_DEFAULT;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.THREAD_POOL;
|
||||||
import static megabasterd.MiscTools.copyTextToClipboard;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
||||||
import static megabasterd.MiscTools.updateFont;
|
import static megabasterd.MiscTools.updateFont;
|
||||||
@ -82,7 +81,6 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
return status_label;
|
return status_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UploadView(Upload upload) {
|
public UploadView(Upload upload) {
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
@ -110,8 +108,8 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
updateFont(restart_button, FONT_DEFAULT, PLAIN);
|
updateFont(restart_button, FONT_DEFAULT, PLAIN);
|
||||||
updateFont(slot_status_label, FONT_DEFAULT, BOLD);
|
updateFont(slot_status_label, FONT_DEFAULT, BOLD);
|
||||||
|
|
||||||
|
}
|
||||||
}}, true);
|
}, true);
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setModel", slots_spinner, new SpinnerNumberModel(_upload.getMain_panel().getDefault_slots_up(), MIN_WORKERS, MAX_WORKERS, 1));
|
swingReflectionInvokeAndWait("setModel", slots_spinner, new SpinnerNumberModel(_upload.getMain_panel().getDefault_slots_up(), MIN_WORKERS, MAX_WORKERS, 1));
|
||||||
|
|
||||||
@ -356,8 +354,7 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
|
|
||||||
}//GEN-LAST:event_pause_buttonActionPerformed
|
}//GEN-LAST:event_pause_buttonActionPerformed
|
||||||
|
|
||||||
public void hideAllExceptStatus()
|
public void hideAllExceptStatus() {
|
||||||
{
|
|
||||||
swingReflectionInvoke("setVisible", new Object[]{speed_label, remtime_label, slots_spinner, slots_label, slot_status_label, pause_button, stop_button, progress_pbar}, false);
|
swingReflectionInvoke("setVisible", new Object[]{speed_label, remtime_label, slots_spinner, slots_label, slot_status_label, pause_button, stop_button, progress_pbar}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +364,7 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
|
|
||||||
folder_link_button.setText("Please wait...");
|
folder_link_button.setText("Please wait...");
|
||||||
|
|
||||||
copyTextToClipboard(_upload.getFolder_link());
|
MiscTools.copyTextToClipboard(_upload.getFolder_link());
|
||||||
|
|
||||||
folder_link_button.setText("Copy folder link");
|
folder_link_button.setText("Copy folder link");
|
||||||
|
|
||||||
@ -382,7 +379,7 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
|
|
||||||
file_link_button.setText("Please wait...");
|
file_link_button.setText("Please wait...");
|
||||||
|
|
||||||
copyTextToClipboard(_upload.getFile_link());
|
MiscTools.copyTextToClipboard(_upload.getFile_link());
|
||||||
|
|
||||||
file_link_button.setText("Copy file link");
|
file_link_button.setText("Copy file link");
|
||||||
|
|
||||||
@ -392,7 +389,6 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
|
|
||||||
}//GEN-LAST:event_file_link_buttonActionPerformed
|
}//GEN-LAST:event_file_link_buttonActionPerformed
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
|
|
||||||
@ -510,7 +506,6 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
swingReflectionInvoke("setText", slot_status_label, (conta_exit > 0 ? "Removing: " + conta_exit : "") + (conta_error > 0 ? ((conta_exit > 0 ? " / " : "") + "Error: " + conta_error) : ""));
|
swingReflectionInvoke("setText", slot_status_label, (conta_exit > 0 ? "Removing: " + conta_exit : "") + (conta_error > 0 ? ((conta_exit > 0 ? " / " : "") + "Error: " + conta_error) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton close_button;
|
private javax.swing.JButton close_button;
|
||||||
private javax.swing.JButton file_link_button;
|
private javax.swing.JButton file_link_button;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user