-Drag and drop file upload
This commit is contained in:
tonikelope 2019-09-08 18:16:06 +02:00
parent c082c65451
commit a90abccd64
12 changed files with 693 additions and 409 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>6.33</version>
<version>6.34</version>
<packaging>jar</packaging>
<dependencies>
<dependency>

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<File> files;
try {
files = (List<File>) 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package com.tonikelope.megabasterd;
import java.io.File;
import java.util.List;
/**
*
* @author tonikelope
*/
public interface FileDropHandlerNotifiable {
public void file_drop_notify(List<File> file);
}

View File

@ -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<File> _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<File> _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<File> 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,11 +93,13 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
dir_name_textfield.addMouseListener(new ContextMenuMouseListener());
if (_main_panel.getMega_accounts().size() > 0) {
pack();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
}
public void init_dialog() {
if (_main_panel.getMega_accounts().size() > 0) {
swingInvoke(new Runnable() {
@Override
@ -123,19 +131,25 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
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)"));
}
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) {
if (files == null || files.length > 1) {
DefaultMutableTreeNode current_dir = new DefaultMutableTreeNode(file.getName());
root.add(current_dir);
_genFileTree(file.getAbsolutePath(), current_dir);
_genFileTree(file.getAbsolutePath(), current_dir, null);
} else {
_genFileTree(file.getAbsolutePath(), root, null);
}
}
}
@ -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<File> 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();
}
}

View File

@ -4,6 +4,9 @@
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="Master password unlock"/>
<Property name="modalExclusionType" type="java.awt.Dialog$ModalExclusionType" editor="org.netbeans.modules.form.editors.EnumEditor">
<Value id="TOOLKIT_EXCLUDE"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>

View File

@ -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);

View File

@ -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...");

View File

@ -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;

View File

@ -335,6 +335,140 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="uploads_panel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Uploads">
<Property name="tabTitle" type="java.lang.String" value="Uploads"/>
<Property name="tabIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/images/icons8-upload-to-ftp-30.png"/>
</Property>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="global_speed_up_label" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pause_all_up_button" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="status_up_label" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="close_all_finished_up_button" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane_up" alignment="0" max="32767" attributes="0"/>
<Component id="up_remtime_label" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="close_all_finished_up_button" alignment="0" max="32767" attributes="0"/>
<Component id="status_up_label" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane_up" pref="288" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="up_remtime_label" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="global_speed_up_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="pause_all_up_button" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="global_speed_up_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="54" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Speed"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="status_up_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="16" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="close_all_finished_up_button">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="16" style="1"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/images/icons8-ok-30.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Clear finished"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="close_all_finished_up_buttonActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane_up">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder>
<Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel_scroll_up">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="pause_all_up_button">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="99" red="ff" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="18" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="PAUSE ALL"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pause_all_up_buttonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="up_remtime_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="20" style="1"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="downloads_panel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
@ -470,140 +604,6 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="uploads_panel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Uploads">
<Property name="tabTitle" type="java.lang.String" value="Uploads"/>
<Property name="tabIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/images/icons8-upload-to-ftp-30.png"/>
</Property>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="global_speed_up_label" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pause_all_up_button" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="status_up_label" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="close_all_finished_up_button" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane_up" alignment="0" max="32767" attributes="0"/>
<Component id="up_remtime_label" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="close_all_finished_up_button" alignment="0" max="32767" attributes="0"/>
<Component id="status_up_label" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane_up" pref="288" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="up_remtime_label" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="global_speed_up_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="pause_all_up_button" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="global_speed_up_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="54" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Speed"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="status_up_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="16" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="close_all_finished_up_button">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="16" style="1"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/images/icons8-ok-30.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Clear finished"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="close_all_finished_up_buttonActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane_up">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder>
<Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel_scroll_up">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="pause_all_up_button">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="99" red="ff" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="18" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="PAUSE ALL"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pause_all_up_buttonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="up_remtime_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="20" style="1"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="unfreeze_transferences_button">

View File

@ -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<String, Object> 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<File> 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<File> single_files = new ArrayList<>();
for (File file : files) {
List<File> 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<String, Object> 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

View File

@ -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 {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 204 KiB