diff --git a/pom.xml b/pom.xml
index d4aceb304..558f6adb4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.tonikelope
MegaBasterd
- 6.33
+ 6.34
jar
diff --git a/src/main/java/com/tonikelope/megabasterd/FileDropHandler.java b/src/main/java/com/tonikelope/megabasterd/FileDropHandler.java
new file mode 100644
index 000000000..3e52119f3
--- /dev/null
+++ b/src/main/java/com/tonikelope/megabasterd/FileDropHandler.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 tonikelope
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.tonikelope.megabasterd;
+
+import static com.tonikelope.megabasterd.MainPanel.THREAD_POOL;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import javax.swing.TransferHandler;
+
+/**
+ *
+ * @author tonikelope
+ *
+ * Thanks to -> https://stackoverflow.com/users/6286694/abika
+ */
+final class FileDropHandler extends TransferHandler {
+
+ final FileDropHandlerNotifiable _notifiable;
+
+ public FileDropHandler(FileDropHandlerNotifiable notifiable) {
+ super();
+
+ _notifiable = notifiable;
+ }
+
+ @Override
+ public boolean canImport(TransferHandler.TransferSupport support) {
+ for (DataFlavor flavor : support.getDataFlavors()) {
+ if (flavor.isFlavorJavaFileListType()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean importData(TransferHandler.TransferSupport support) {
+ if (!this.canImport(support)) {
+ return false;
+ }
+
+ List files;
+
+ try {
+ files = (List) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
+ } catch (UnsupportedFlavorException | IOException ex) {
+ // should never happen (or JDK is buggy)
+ return false;
+ }
+
+ THREAD_POOL.execute(new Runnable() {
+ @Override
+ public void run() {
+ _notifiable.file_drop_notify(files);
+ }
+ });
+
+ return true;
+ }
+}
diff --git a/src/main/java/com/tonikelope/megabasterd/FileDropHandlerNotifiable.java b/src/main/java/com/tonikelope/megabasterd/FileDropHandlerNotifiable.java
new file mode 100644
index 000000000..4c3bbceda
--- /dev/null
+++ b/src/main/java/com/tonikelope/megabasterd/FileDropHandlerNotifiable.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2019 tonikelope
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.tonikelope.megabasterd;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ *
+ * @author tonikelope
+ */
+public interface FileDropHandlerNotifiable {
+
+ public void file_drop_notify(List file);
+
+}
diff --git a/src/main/java/com/tonikelope/megabasterd/FileGrabberDialog.java b/src/main/java/com/tonikelope/megabasterd/FileGrabberDialog.java
index 926efe0b0..cc6dd65a6 100644
--- a/src/main/java/com/tonikelope/megabasterd/FileGrabberDialog.java
+++ b/src/main/java/com/tonikelope/megabasterd/FileGrabberDialog.java
@@ -7,6 +7,7 @@ import java.awt.Dialog;
import java.io.File;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.logging.Logger;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
@@ -22,7 +23,7 @@ import javax.swing.tree.TreeNode;
*
* @author tonikelope
*/
-public final class FileGrabberDialog extends javax.swing.JDialog {
+public final class FileGrabberDialog extends javax.swing.JDialog implements FileDropHandlerNotifiable {
private boolean _upload;
private final ArrayList _files;
@@ -32,6 +33,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
private final boolean _remember_master_pass;
private boolean _inserting_mega_accounts;
private int _last_selected_index;
+ private List _drag_drop_files;
public JCheckBox getUpload_log_checkbox() {
return upload_log_checkbox;
@@ -61,12 +63,14 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
return _remember_master_pass;
}
- public FileGrabberDialog(MainPanelView parent, boolean modal) {
+ public FileGrabberDialog(MainPanelView parent, boolean modal, List files) {
super(parent, modal);
_main_panel = parent.getMain_panel();
+ _drag_drop_files = files;
+
initComponents();
updateFonts(this, GUI_FONT, _main_panel.getZoom_factor());
@@ -77,6 +81,8 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
translateLabels(this);
+ jPanel1.setTransferHandler(new FileDropHandler(this));
+
_total_space = 0L;
_base_path = null;
_upload = false;
@@ -87,56 +93,64 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
dir_name_textfield.addMouseListener(new ContextMenuMouseListener());
+ pack();
+
+ }
+
+ public void init_dialog() {
+
if (_main_panel.getMega_accounts().size() > 0) {
- THREAD_POOL.execute(new Runnable() {
+ swingInvoke(new Runnable() {
@Override
public void run() {
- swingInvoke(new Runnable() {
- @Override
- public void run() {
+ if (!_main_panel.getMega_active_accounts().isEmpty()) {
+ _inserting_mega_accounts = true;
- if (!_main_panel.getMega_active_accounts().isEmpty()) {
- _inserting_mega_accounts = true;
+ for (Object o : _main_panel.getMega_accounts().keySet()) {
- for (Object o : _main_panel.getMega_accounts().keySet()) {
-
- account_combobox.addItem((String) o);
- }
-
- _inserting_mega_accounts = false;
-
- for (Object o : _main_panel.getMega_active_accounts().keySet()) {
-
- account_combobox.setSelectedItem(o);
-
- account_comboboxItemStateChanged(null);
-
- break;
- }
-
- } else {
-
- for (Object o : _main_panel.getMega_accounts().keySet()) {
-
- account_combobox.addItem((String) o);
- }
- }
+ account_combobox.addItem((String) o);
}
- });
- }
+ _inserting_mega_accounts = false;
+
+ for (Object o : _main_panel.getMega_active_accounts().keySet()) {
+
+ account_combobox.setSelectedItem(o);
+
+ account_comboboxItemStateChanged(null);
+
+ break;
+ }
+
+ } else {
+
+ for (Object o : _main_panel.getMega_accounts().keySet()) {
+
+ account_combobox.addItem((String) o);
+ }
+ }
+
+ if (_drag_drop_files != null) {
+
+ file_drop_notify(_drag_drop_files);
+ }
+ }
});
} else {
+ swingInvoke(new Runnable() {
+ @Override
+ public void run() {
- used_space_label.setForeground(Color.red);
- used_space_label.setText(LabelTranslatorSingleton.getInstance().translate("No MEGA accounts available (Go to Settings > Accounts)"));
+ used_space_label.setForeground(Color.red);
+ used_space_label.setText(LabelTranslatorSingleton.getInstance().translate("No MEGA accounts available (Go to Settings > Accounts)"));
+
+ }
+ });
}
- pack();
-
}
/**
@@ -451,6 +465,9 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
skip_rest_button.setEnabled(root_childs);
upload_log_checkbox.setEnabled(root_childs);
+ revalidate();
+ repaint();
+
} else {
if (filechooser.getSelectedFile() != null && !filechooser.getSelectedFile().canRead()) {
@@ -514,7 +531,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(filechooser.getSelectedFile().getAbsolutePath());
- _genFileTree(filechooser.getSelectedFile().getAbsolutePath(), root);
+ _genFileTree(filechooser.getSelectedFile().getAbsolutePath(), root, null);
DefaultTreeModel tree_model = new DefaultTreeModel(sortTree(root));
@@ -530,8 +547,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
boolean root_childs = ((TreeNode) tree_model.getRoot()).getChildCount() > 0;
- file_tree.setRootVisible(root_childs);
-
file_tree.setRootVisible(root_childs);
file_tree.setEnabled(root_childs);
warning_label.setEnabled(root_childs);
@@ -541,6 +556,9 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
skip_rest_button.setEnabled(root_childs);
upload_log_checkbox.setEnabled(root_childs);
+ revalidate();
+ repaint();
+
} else {
if (filechooser.getSelectedFile() != null && !filechooser.getSelectedFile().canRead()) {
@@ -642,7 +660,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
used_space_label.setForeground(used_space_color);
- for (JComponent c : new JComponent[]{add_files_button, add_folder_button, account_combobox, account_label}) {
+ for (JComponent c : new JComponent[]{add_files_button, add_folder_button, account_combobox, account_label, upload_log_checkbox}) {
c.setEnabled(true);
}
@@ -671,6 +689,16 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
used_space_label.setText(LabelTranslatorSingleton.getInstance().translate("ERROR checking account quota!"));
_last_selected_index = account_combobox.getSelectedIndex();
+
+ dance_button.setEnabled(false);
+ total_file_size_label.setEnabled(false);
+ skip_button.setEnabled(false);
+ skip_rest_button.setEnabled(false);
+ warning_label.setEnabled(false);
+ file_tree.setEnabled(false);
+ add_files_button.setEnabled(false);
+ add_folder_button.setEnabled(false);
+ upload_log_checkbox.setEnabled(false);
}
});
@@ -694,6 +722,16 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
used_space_label.setText(LabelTranslatorSingleton.getInstance().translate("ERROR checking account quota!"));
_last_selected_index = account_combobox.getSelectedIndex();
+
+ dance_button.setEnabled(false);
+ total_file_size_label.setEnabled(false);
+ skip_button.setEnabled(false);
+ skip_rest_button.setEnabled(false);
+ warning_label.setEnabled(false);
+ file_tree.setEnabled(false);
+ add_files_button.setEnabled(false);
+ add_folder_button.setEnabled(false);
+ upload_log_checkbox.setEnabled(false);
}
});
@@ -752,11 +790,11 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
}
}//GEN-LAST:event_skip_buttonActionPerformed
- private void _genFileTree(String directoryName, DefaultMutableTreeNode root) {
+ private void _genFileTree(String directoryName, DefaultMutableTreeNode root, File[] files) {
File directory = new File(directoryName);
- File[] fList = directory.listFiles();
+ File[] fList = files == null ? directory.listFiles() : files;
if (fList != null) {
@@ -770,11 +808,18 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
} else if (file.isDirectory() && file.canRead() && file.listFiles().length > 0) {
- DefaultMutableTreeNode current_dir = new DefaultMutableTreeNode(file.getName());
+ if (files == null || files.length > 1) {
- root.add(current_dir);
+ DefaultMutableTreeNode current_dir = new DefaultMutableTreeNode(file.getName());
+
+ root.add(current_dir);
+
+ _genFileTree(file.getAbsolutePath(), current_dir, null);
+
+ } else {
+ _genFileTree(file.getAbsolutePath(), root, null);
+ }
- _genFileTree(file.getAbsolutePath(), current_dir);
}
}
@@ -844,4 +889,58 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
private javax.swing.JLabel warning_label;
// End of variables declaration//GEN-END:variables
private static final Logger LOG = Logger.getLogger(FileGrabberDialog.class.getName());
+
+ @Override
+ public void file_drop_notify(List files) {
+
+ add_files_button.setEnabled(false);
+ add_folder_button.setEnabled(false);
+ warning_label.setEnabled(false);
+ skip_button.setEnabled(false);
+ skip_rest_button.setEnabled(false);
+ dance_button.setEnabled(false);
+ dir_name_textfield.setEnabled(false);
+ dir_name_label.setEnabled(false);
+ upload_log_checkbox.setEnabled(false);
+
+ total_file_size_label.setText("[0 B]");
+
+ _base_path = (files.size() == 1 && files.get(0).isDirectory()) ? files.get(0).getAbsolutePath() : files.get(0).getParentFile().getAbsolutePath();
+
+ dir_name_textfield.setText(((files.size() == 1 && files.get(0).isDirectory()) ? files.get(0).getName() : files.get(0).getParentFile().getName()) + "_" + genID(10));
+
+ dir_name_textfield.setEnabled(true);
+
+ dir_name_label.setEnabled(true);
+
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode(_base_path);
+
+ _genFileTree(_base_path, root, files.toArray(new File[files.size()]));
+
+ DefaultTreeModel tree_model = new DefaultTreeModel(sortTree(root));
+
+ file_tree.setModel(tree_model);
+
+ _genFileList();
+
+ add_files_button.setEnabled(true);
+
+ add_folder_button.setEnabled(true);
+
+ add_folder_button.setText(LabelTranslatorSingleton.getInstance().translate("Add folder"));
+
+ boolean root_childs = ((TreeNode) tree_model.getRoot()).getChildCount() > 0;
+
+ file_tree.setRootVisible(root_childs);
+ file_tree.setEnabled(root_childs);
+ warning_label.setEnabled(root_childs);
+ dance_button.setEnabled(root_childs);
+ total_file_size_label.setEnabled(root_childs);
+ skip_button.setEnabled(root_childs);
+ skip_rest_button.setEnabled(root_childs);
+ upload_log_checkbox.setEnabled(root_childs);
+ revalidate();
+ repaint();
+
+ }
}
diff --git a/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.form b/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.form
index bb1a739cd..225cde79c 100644
--- a/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.form
+++ b/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.form
@@ -4,6 +4,9 @@
+
+
+
diff --git a/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.java b/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.java
index e0f2786e8..5d0acf804 100644
--- a/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.java
+++ b/src/main/java/com/tonikelope/megabasterd/GetMasterPasswordDialog.java
@@ -97,6 +97,7 @@ public class GetMasterPasswordDialog extends javax.swing.JDialog {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Master password unlock");
+ setModalExclusionType(java.awt.Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
current_pass_textfield.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
current_pass_textfield.setDoubleBuffered(true);
diff --git a/src/main/java/com/tonikelope/megabasterd/LabelTranslatorSingleton.java b/src/main/java/com/tonikelope/megabasterd/LabelTranslatorSingleton.java
index 57ab472b5..0089ef77d 100644
--- a/src/main/java/com/tonikelope/megabasterd/LabelTranslatorSingleton.java
+++ b/src/main/java/com/tonikelope/megabasterd/LabelTranslatorSingleton.java
@@ -36,6 +36,9 @@ public final class LabelTranslatorSingleton {
private void Spanish() {
+ _addTranslation("Split content in different uploads", "Separar contenido en diferentes subidas");
+ _addTranslation("Merge content in the same upload", "Juntar todo en la misma subida");
+ _addTranslation("How do you want to proceed?", "¿Qué quieres hacer?");
_addTranslation("Freeze transferences before start", "Congelar transferencias antes de empezar");
_addTranslation("UNFREEZE WAITING TRANSFERENCES", "DESCONGELAR TRANSFERENCIAS A LA ESPERA");
_addTranslation("(FROZEN) Waiting to start...", "(CONGELADA) Esperando para empezar...");
diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanel.java b/src/main/java/com/tonikelope/megabasterd/MainPanel.java
index 435c471c3..1b114f956 100644
--- a/src/main/java/com/tonikelope/megabasterd/MainPanel.java
+++ b/src/main/java/com/tonikelope/megabasterd/MainPanel.java
@@ -50,7 +50,7 @@ import javax.swing.UIManager;
*/
public final class MainPanel {
- public static final String VERSION = "6.33";
+ public static final String VERSION = "6.34";
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;
diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanelView.form b/src/main/java/com/tonikelope/megabasterd/MainPanelView.form
index 737371d9e..f4bc4b9e1 100644
--- a/src/main/java/com/tonikelope/megabasterd/MainPanelView.form
+++ b/src/main/java/com/tonikelope/megabasterd/MainPanelView.form
@@ -335,6 +335,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -470,140 +604,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanelView.java b/src/main/java/com/tonikelope/megabasterd/MainPanelView.java
index 0332eb8a5..4e42ff951 100644
--- a/src/main/java/com/tonikelope/megabasterd/MainPanelView.java
+++ b/src/main/java/com/tonikelope/megabasterd/MainPanelView.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -30,6 +31,8 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
+import static javax.swing.JOptionPane.DEFAULT_OPTION;
+import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
import static javax.swing.JOptionPane.showOptionDialog;
@@ -40,7 +43,7 @@ import javax.swing.JTabbedPane;
*
* @author tonikelope
*/
-public final class MainPanelView extends javax.swing.JFrame {
+public final class MainPanelView extends javax.swing.JFrame implements FileDropHandlerNotifiable {
private final MainPanel _main_panel;
@@ -202,6 +205,214 @@ public final class MainPanelView extends javax.swing.JFrame {
}
+ private void _new_upload_dialog(FileGrabberDialog dialog) {
+
+ try {
+
+ dialog.setLocationRelativeTo(this);
+
+ dialog.setVisible(true);
+
+ if (dialog.isUpload() && dialog.getFiles().size() > 0) {
+
+ getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().addAll(dialog.getFiles());
+
+ getMain_panel().getUpload_manager().secureNotify();
+
+ final String mega_account = (String) dialog.getAccount_combobox().getSelectedItem();
+
+ final String base_path = dialog.getBase_path();
+
+ final String dir_name = dialog.getDir_name_textfield().getText();
+
+ jTabbedPane1.setSelectedIndex(1);
+
+ Runnable run = new Runnable() {
+ @Override
+ public void run() {
+
+ MegaAPI ma = getMain_panel().getMega_active_accounts().get(mega_account);
+
+ try {
+
+ byte[] parent_key = ma.genFolderKey();
+
+ byte[] share_key = ma.genShareKey();
+
+ HashMap res = ma.createDir(dir_name != null ? dir_name : dialog.getFiles().get(0).getName() + "_" + genID(10), ma.getRoot_id(), parent_key, i32a2bin(ma.getMaster_key()));
+
+ String parent_node = (String) ((Map) ((List) res.get("f")).get(0)).get("h");
+
+ LOG.log(Level.INFO, "{0} Dir {1} created", new Object[]{Thread.currentThread().getName(), parent_node});
+
+ ma.shareFolder(parent_node, parent_key, share_key);
+
+ String folder_link = ma.getPublicFolderLink(parent_node, share_key);
+
+ if (dialog.getUpload_log_checkbox().isSelected()) {
+
+ File upload_log = new File(System.getProperty("user.home") + "/megabasterd_upload_" + parent_node + ".log");
+ upload_log.createNewFile();
+
+ FileWriter fr;
+ try {
+ fr = new FileWriter(upload_log, true);
+ fr.write("***** MegaBasterd UPLOAD LOG FILE *****\n\n");
+ fr.write(dir_name + " " + folder_link + "\n\n");
+ fr.close();
+ } catch (IOException ex) {
+ Logger.getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ MegaDirNode file_paths = new MegaDirNode(parent_node);
+
+ for (File f : dialog.getFiles()) {
+
+ String file_path = f.getParentFile().getAbsolutePath().replace(base_path, "");
+
+ String[] dirs = file_path.split("/");
+
+ MegaDirNode current_node = file_paths;
+
+ String file_parent = current_node.getNode_id();
+
+ for (String d : dirs) {
+
+ if (!d.isEmpty()) {
+
+ if (current_node.getChildren().get(d) != null) {
+
+ current_node = current_node.getChildren().get(d);
+
+ file_parent = current_node.getNode_id();
+
+ } else {
+
+ res = ma.createDirInsideAnotherSharedDir(d, current_node.getNode_id(), ma.genFolderKey(), i32a2bin(ma.getMaster_key()), parent_node, share_key);
+
+ file_parent = (String) ((Map) ((List) res.get("f")).get(0)).get("h");
+
+ current_node.getChildren().put(d, new MegaDirNode(file_parent));
+
+ current_node = current_node.getChildren().get(d);
+ }
+ }
+ }
+
+ while (getMain_panel().getUpload_manager().getTransference_waitstart_queue().size() >= TransferenceManager.MAX_WAIT_QUEUE) {
+
+ synchronized (getMain_panel().getUpload_manager().getWait_queue_lock()) {
+ getMain_panel().getUpload_manager().getWait_queue_lock().wait(1000);
+ }
+ }
+
+ if (!getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().isEmpty()) {
+
+ Upload upload = new Upload(getMain_panel(), ma, f.getAbsolutePath(), file_parent, null, null, parent_node, share_key, folder_link);
+
+ getMain_panel().getUpload_manager().getTransference_provision_queue().add(upload);
+
+ getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().remove(f);
+
+ getMain_panel().getUpload_manager().secureNotify();
+
+ } else {
+ break;
+ }
+
+ }
+
+ } catch (Exception ex) {
+
+ LOG.log(SEVERE, null, ex);
+ }
+ }
+
+ };
+
+ getMain_panel().getUpload_manager().getTransference_preprocess_queue().add(run);
+
+ getMain_panel().getUpload_manager().secureNotify();
+
+ }
+
+ } catch (Exception ex) {
+ }
+
+ if (!dialog.isRemember_master_pass()) {
+
+ _main_panel.setMaster_pass(null);
+ }
+
+ dialog.dispose();
+
+ }
+
+ @Override
+ public void file_drop_notify(List files) {
+
+ final MainPanelView tthis = this;
+
+ THREAD_POOL.execute(new Runnable() {
+ @Override
+ public void run() {
+
+ Object[] options = {LabelTranslatorSingleton.getInstance().translate("Split content in different uploads"), LabelTranslatorSingleton.getInstance().translate("Merge content in the same upload")};
+
+ int n = showOptionDialog(_main_panel.getView(),
+ LabelTranslatorSingleton.getInstance().translate("How do you want to proceed?"),
+ LabelTranslatorSingleton.getInstance().translate("File Grabber"), DEFAULT_OPTION, INFORMATION_MESSAGE,
+ null,
+ options,
+ options[0]);
+
+ if (n == 0) {
+
+ List single_files = new ArrayList<>();
+
+ for (File file : files) {
+
+ List aux = new ArrayList<>();
+
+ if (file.isDirectory()) {
+
+ aux.add(file);
+
+ final FileGrabberDialog dialog = new FileGrabberDialog(tthis, true, aux);
+
+ dialog.init_dialog();
+
+ _new_upload_dialog(dialog);
+ } else {
+ single_files.add(file);
+ }
+
+ }
+
+ if (single_files.size() > 0) {
+ final FileGrabberDialog dialog = new FileGrabberDialog(tthis, true, single_files);
+
+ dialog.init_dialog();
+
+ _new_upload_dialog(dialog);
+ }
+
+ } else if (n == 1) {
+
+ final FileGrabberDialog dialog = new FileGrabberDialog(tthis, true, files);
+
+ dialog.init_dialog();
+
+ _new_upload_dialog(dialog);
+
+ }
+
+ }
+
+ });
+ }
+
public MainPanelView(MainPanel main_panel) {
_main_panel = main_panel;
@@ -212,6 +423,8 @@ public final class MainPanelView extends javax.swing.JFrame {
translateLabels(this);
+ uploads_panel.setTransferHandler(new FileDropHandler(this));
+
for (JComponent c : new JComponent[]{unfreeze_transferences_button, global_speed_down_label, global_speed_up_label, down_remtime_label, up_remtime_label, close_all_finished_down_button, close_all_finished_up_button, pause_all_down_button, pause_all_up_button}) {
c.setVisible(false);
@@ -251,14 +464,6 @@ public final class MainPanelView extends javax.swing.JFrame {
mc_reverse_status = new javax.swing.JLabel();
smart_proxy_status = new javax.swing.JLabel();
jTabbedPane1 = new javax.swing.JTabbedPane();
- downloads_panel = new javax.swing.JPanel();
- global_speed_down_label = new javax.swing.JLabel();
- status_down_label = new javax.swing.JLabel();
- close_all_finished_down_button = new javax.swing.JButton();
- jScrollPane_down = new javax.swing.JScrollPane();
- jPanel_scroll_down = new javax.swing.JPanel();
- pause_all_down_button = new javax.swing.JButton();
- down_remtime_label = new javax.swing.JLabel();
uploads_panel = new javax.swing.JPanel();
global_speed_up_label = new javax.swing.JLabel();
status_up_label = new javax.swing.JLabel();
@@ -267,6 +472,14 @@ public final class MainPanelView extends javax.swing.JFrame {
jPanel_scroll_up = new javax.swing.JPanel();
pause_all_up_button = new javax.swing.JButton();
up_remtime_label = new javax.swing.JLabel();
+ downloads_panel = new javax.swing.JPanel();
+ global_speed_down_label = new javax.swing.JLabel();
+ status_down_label = new javax.swing.JLabel();
+ close_all_finished_down_button = new javax.swing.JButton();
+ jScrollPane_down = new javax.swing.JScrollPane();
+ jPanel_scroll_down = new javax.swing.JPanel();
+ pause_all_down_button = new javax.swing.JButton();
+ down_remtime_label = new javax.swing.JLabel();
unfreeze_transferences_button = new javax.swing.JButton();
main_menubar = new javax.swing.JMenuBar();
file_menu = new javax.swing.JMenu();
@@ -308,6 +521,76 @@ public final class MainPanelView extends javax.swing.JFrame {
jTabbedPane1.setDoubleBuffered(true);
jTabbedPane1.setFont(new java.awt.Font("Dialog", 1, 20)); // NOI18N
+ global_speed_up_label.setFont(new java.awt.Font("Dialog", 1, 54)); // NOI18N
+ global_speed_up_label.setText("Speed");
+ global_speed_up_label.setDoubleBuffered(true);
+
+ status_up_label.setFont(new java.awt.Font("Dialog", 0, 16)); // NOI18N
+ status_up_label.setForeground(new java.awt.Color(102, 102, 102));
+
+ close_all_finished_up_button.setFont(new java.awt.Font("Dialog", 1, 16)); // NOI18N
+ close_all_finished_up_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-ok-30.png"))); // NOI18N
+ close_all_finished_up_button.setText("Clear finished");
+ close_all_finished_up_button.setDoubleBuffered(true);
+ close_all_finished_up_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ close_all_finished_up_buttonActionPerformed(evt);
+ }
+ });
+
+ jScrollPane_up.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
+
+ jPanel_scroll_up.setLayout(new javax.swing.BoxLayout(jPanel_scroll_up, javax.swing.BoxLayout.Y_AXIS));
+ jScrollPane_up.setViewportView(jPanel_scroll_up);
+
+ pause_all_up_button.setBackground(new java.awt.Color(255, 153, 0));
+ pause_all_up_button.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
+ pause_all_up_button.setForeground(new java.awt.Color(255, 255, 255));
+ pause_all_up_button.setText("PAUSE ALL");
+ pause_all_up_button.setDoubleBuffered(true);
+ pause_all_up_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ pause_all_up_buttonActionPerformed(evt);
+ }
+ });
+
+ up_remtime_label.setFont(new java.awt.Font("Dialog", 1, 20)); // NOI18N
+
+ javax.swing.GroupLayout uploads_panelLayout = new javax.swing.GroupLayout(uploads_panel);
+ uploads_panel.setLayout(uploads_panelLayout);
+ uploads_panelLayout.setHorizontalGroup(
+ uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(uploads_panelLayout.createSequentialGroup()
+ .addComponent(global_speed_up_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pause_all_up_button))
+ .addGroup(uploads_panelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(status_up_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(close_all_finished_up_button))
+ .addComponent(jScrollPane_up)
+ .addComponent(up_remtime_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ );
+ uploads_panelLayout.setVerticalGroup(
+ uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, uploads_panelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(close_all_finished_up_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(status_up_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane_up, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(up_remtime_label)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(global_speed_up_label)
+ .addComponent(pause_all_up_button)))
+ );
+
+ jTabbedPane1.addTab("Uploads", new javax.swing.ImageIcon(getClass().getResource("/images/icons8-upload-to-ftp-30.png")), uploads_panel); // NOI18N
+
global_speed_down_label.setFont(new java.awt.Font("Dialog", 1, 54)); // NOI18N
global_speed_down_label.setText("Speed");
global_speed_down_label.setDoubleBuffered(true);
@@ -379,76 +662,6 @@ public final class MainPanelView extends javax.swing.JFrame {
jTabbedPane1.addTab("Downloads", new javax.swing.ImageIcon(getClass().getResource("/images/icons8-download-from-ftp-30.png")), downloads_panel); // NOI18N
- global_speed_up_label.setFont(new java.awt.Font("Dialog", 1, 54)); // NOI18N
- global_speed_up_label.setText("Speed");
- global_speed_up_label.setDoubleBuffered(true);
-
- status_up_label.setFont(new java.awt.Font("Dialog", 0, 16)); // NOI18N
- status_up_label.setForeground(new java.awt.Color(102, 102, 102));
-
- close_all_finished_up_button.setFont(new java.awt.Font("Dialog", 1, 16)); // NOI18N
- close_all_finished_up_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-ok-30.png"))); // NOI18N
- close_all_finished_up_button.setText("Clear finished");
- close_all_finished_up_button.setDoubleBuffered(true);
- close_all_finished_up_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- close_all_finished_up_buttonActionPerformed(evt);
- }
- });
-
- jScrollPane_up.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
-
- jPanel_scroll_up.setLayout(new javax.swing.BoxLayout(jPanel_scroll_up, javax.swing.BoxLayout.Y_AXIS));
- jScrollPane_up.setViewportView(jPanel_scroll_up);
-
- pause_all_up_button.setBackground(new java.awt.Color(255, 153, 0));
- pause_all_up_button.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
- pause_all_up_button.setForeground(new java.awt.Color(255, 255, 255));
- pause_all_up_button.setText("PAUSE ALL");
- pause_all_up_button.setDoubleBuffered(true);
- pause_all_up_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- pause_all_up_buttonActionPerformed(evt);
- }
- });
-
- up_remtime_label.setFont(new java.awt.Font("Dialog", 1, 20)); // NOI18N
-
- javax.swing.GroupLayout uploads_panelLayout = new javax.swing.GroupLayout(uploads_panel);
- uploads_panel.setLayout(uploads_panelLayout);
- uploads_panelLayout.setHorizontalGroup(
- uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(uploads_panelLayout.createSequentialGroup()
- .addComponent(global_speed_up_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(pause_all_up_button))
- .addGroup(uploads_panelLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(status_up_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(close_all_finished_up_button))
- .addComponent(jScrollPane_up)
- .addComponent(up_remtime_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- uploads_panelLayout.setVerticalGroup(
- uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, uploads_panelLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(close_all_finished_up_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(status_up_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane_up, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(up_remtime_label)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(global_speed_up_label)
- .addComponent(pause_all_up_button)))
- );
-
- jTabbedPane1.addTab("Uploads", new javax.swing.ImageIcon(getClass().getResource("/images/icons8-upload-to-ftp-30.png")), uploads_panel); // NOI18N
-
unfreeze_transferences_button.setBackground(new java.awt.Color(255, 255, 255));
unfreeze_transferences_button.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
unfreeze_transferences_button.setForeground(new java.awt.Color(0, 153, 255));
@@ -1049,154 +1262,11 @@ public final class MainPanelView extends javax.swing.JFrame {
private void new_upload_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_new_upload_menuActionPerformed
- final FileGrabberDialog dialog = new FileGrabberDialog(this, true);
+ final FileGrabberDialog dialog = new FileGrabberDialog(this, true, null);
- try {
-
- new_upload_menu.setEnabled(false);
-
- dialog.setLocationRelativeTo(this);
-
- dialog.setVisible(true);
-
- if (dialog.isUpload() && dialog.getFiles().size() > 0) {
-
- getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().addAll(dialog.getFiles());
-
- getMain_panel().getUpload_manager().secureNotify();
-
- final String mega_account = (String) dialog.getAccount_combobox().getSelectedItem();
-
- final String base_path = dialog.getBase_path();
-
- final String dir_name = dialog.getDir_name_textfield().getText();
-
- jTabbedPane1.setSelectedIndex(1);
-
- Runnable run = new Runnable() {
- @Override
- public void run() {
-
- MegaAPI ma = getMain_panel().getMega_active_accounts().get(mega_account);
-
- try {
-
- byte[] parent_key = ma.genFolderKey();
-
- byte[] share_key = ma.genShareKey();
-
- HashMap res = ma.createDir(dir_name != null ? dir_name : dialog.getFiles().get(0).getName() + "_" + genID(10), ma.getRoot_id(), parent_key, i32a2bin(ma.getMaster_key()));
-
- String parent_node = (String) ((Map) ((List) res.get("f")).get(0)).get("h");
-
- LOG.log(Level.INFO, "{0} Dir {1} created", new Object[]{Thread.currentThread().getName(), parent_node});
-
- ma.shareFolder(parent_node, parent_key, share_key);
-
- String folder_link = ma.getPublicFolderLink(parent_node, share_key);
-
- if (dialog.getUpload_log_checkbox().isSelected()) {
-
- File upload_log = new File(System.getProperty("user.home") + "/megabasterd_upload_" + parent_node + ".log");
- upload_log.createNewFile();
-
- FileWriter fr;
- try {
- fr = new FileWriter(upload_log, true);
- fr.write("***** MegaBasterd UPLOAD LOG FILE *****\n\n");
- fr.write(dir_name + " " + folder_link + "\n\n");
- fr.close();
- } catch (IOException ex) {
- Logger.getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- MegaDirNode file_paths = new MegaDirNode(parent_node);
-
- for (File f : dialog.getFiles()) {
-
- String file_path = f.getParentFile().getAbsolutePath().replace(base_path, "");
-
- String[] dirs = file_path.split("/");
-
- MegaDirNode current_node = file_paths;
-
- String file_parent = current_node.getNode_id();
-
- for (String d : dirs) {
-
- if (!d.isEmpty()) {
-
- if (current_node.getChildren().get(d) != null) {
-
- current_node = current_node.getChildren().get(d);
-
- file_parent = current_node.getNode_id();
-
- } else {
-
- res = ma.createDirInsideAnotherSharedDir(d, current_node.getNode_id(), ma.genFolderKey(), i32a2bin(ma.getMaster_key()), parent_node, share_key);
-
- file_parent = (String) ((Map) ((List) res.get("f")).get(0)).get("h");
-
- current_node.getChildren().put(d, new MegaDirNode(file_parent));
-
- current_node = current_node.getChildren().get(d);
- }
- }
- }
-
- while (getMain_panel().getUpload_manager().getTransference_waitstart_queue().size() >= TransferenceManager.MAX_WAIT_QUEUE) {
-
- synchronized (getMain_panel().getUpload_manager().getWait_queue_lock()) {
- getMain_panel().getUpload_manager().getWait_queue_lock().wait(1000);
- }
- }
-
- if (!getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().isEmpty()) {
-
- Upload upload = new Upload(getMain_panel(), ma, f.getAbsolutePath(), file_parent, null, null, parent_node, share_key, folder_link);
-
- getMain_panel().getUpload_manager().getTransference_provision_queue().add(upload);
-
- getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().remove(f);
-
- getMain_panel().getUpload_manager().secureNotify();
-
- } else {
- break;
- }
-
- }
-
- } catch (Exception ex) {
-
- LOG.log(SEVERE, null, ex);
- }
- }
-
- };
-
- getMain_panel().getUpload_manager().getTransference_preprocess_queue().add(run);
-
- getMain_panel().getUpload_manager().secureNotify();
-
- new_upload_menu.setEnabled(true);
-
- } else {
- new_upload_menu.setEnabled(true);
- }
-
- } catch (Exception ex) {
- }
-
- if (!dialog.isRemember_master_pass()) {
-
- _main_panel.setMaster_pass(null);
- }
-
- dialog.dispose();
+ dialog.init_dialog();
+ _new_upload_dialog(dialog);
}//GEN-LAST:event_new_upload_menuActionPerformed
private void close_all_finished_up_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_close_all_finished_up_buttonActionPerformed
diff --git a/src/main/java/com/tonikelope/megabasterd/MegaProxyServer.java b/src/main/java/com/tonikelope/megabasterd/MegaProxyServer.java
index 590742fd5..10e3f999e 100644
--- a/src/main/java/com/tonikelope/megabasterd/MegaProxyServer.java
+++ b/src/main/java/com/tonikelope/megabasterd/MegaProxyServer.java
@@ -12,8 +12,8 @@ import java.util.regex.Pattern;
/**
*
* @author tonikelope
- */
-/**
+ *
+ *
* Thanks to -> https://stackoverflow.com/users/6477541/sarvesh-agarwal
*/
public class MegaProxyServer implements Runnable {
diff --git a/src/main/resources/images/mbasterd_screen.png b/src/main/resources/images/mbasterd_screen.png
index 3ea7b3a3e..b33370909 100644
Binary files a/src/main/resources/images/mbasterd_screen.png and b/src/main/resources/images/mbasterd_screen.png differ