Skip to content

Commit

Permalink
8.9
Browse files Browse the repository at this point in the history
Fix #599
  • Loading branch information
tonikelope committed Oct 27, 2023
1 parent 2356e99 commit c0bb5f6
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 63 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>8.8</version>
<version>8.9</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event
THREAD_POOL.execute(() -> {

if (_midi == null) {
_midi = MiscTools.midiLoopPlay("/midis/a-team.mid");
_midi = MiscTools.midiLoopPlay("/midis/a-team.mid", 70);
} else {
_midi.start();
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/tonikelope/megabasterd/DownloadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ public void remove(Transference[] downloads) {

getTransference_waitstart_queue().remove(d);

if (getTransference_waitstart_queue().isEmpty()) {
_frozen = false;
}

getTransference_running_list().remove(d);

getTransference_finished_queue().remove(d);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/tonikelope/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
public final class MainPanel {

public static final String VERSION = "8.8";
public static final String VERSION = "8.9";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
Expand Down Expand Up @@ -1525,9 +1525,6 @@ public void resumeUploads() {
getUpload_manager().getTransference_provision_queue().add(upload);

conta_uploads++;

uploads_queue_iterator.remove();

}

} else {
Expand Down
52 changes: 35 additions & 17 deletions src/main/java/com/tonikelope/megabasterd/MainPanelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
import static javax.swing.JOptionPane.showOptionDialog;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;

/**
Expand All @@ -64,6 +65,14 @@ public final class MainPanelView extends javax.swing.JFrame {

private static volatile MainPanelView INSTANCE = null;

public JProgressBar getDownload_status_bar() {
return download_status_bar;
}

public JProgressBar getUpload_status_bar() {
return upload_status_bar;
}

public static MainPanelView getINSTANCE() {
return INSTANCE;
}
Expand Down Expand Up @@ -214,7 +223,7 @@ private void _new_upload_dialog(FileGrabberDialog dialog) {

MiscTools.GUIRun(() -> {
upload_status_bar.setIndeterminate(true);

upload_status_bar.setMaximum(getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().size() + dialog.getFiles().size());
upload_status_bar.setVisible(true);
});

Expand Down Expand Up @@ -351,31 +360,28 @@ private void _new_upload_dialog(FileGrabberDialog dialog) {
}
}

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, dialog.getPriority_checkbox().isSelected());

Upload upload = new Upload(getMain_panel(), ma, f.getAbsolutePath(), file_parent, null, null, parent_node, share_key, folder_link, dialog.getPriority_checkbox().isSelected());
getMain_panel().getUpload_manager().getTransference_provision_queue().add(upload);

getMain_panel().getUpload_manager().getTransference_provision_queue().add(upload);
getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().remove(f);

getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().remove(f);

getMain_panel().getUpload_manager().secureNotify();

}
getMain_panel().getUpload_manager().secureNotify();

} catch (Exception ex) {

if (!getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().isEmpty()) {

getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().remove(f);

getMain_panel().getUpload_manager().secureNotify();
getMain_panel().getUpload_manager().getTransference_preprocess_global_queue().remove(f);

}
getMain_panel().getUpload_manager().secureNotify();

LOG.log(SEVERE, null, ex);
}

MiscTools.GUIRun(() -> {
upload_status_bar.setIndeterminate(false);
upload_status_bar.setValue(upload_status_bar.getValue() + 1);
});

}

} catch (Exception ex) {
Expand All @@ -385,7 +391,7 @@ private void _new_upload_dialog(FileGrabberDialog dialog) {

if (getMain_panel().getUpload_manager().getTransference_preprocess_queue().isEmpty()) {
MiscTools.GUIRun(() -> {

upload_status_bar.setValue(upload_status_bar.getMinimum());
upload_status_bar.setVisible(false);
});
}
Expand Down Expand Up @@ -470,6 +476,12 @@ public MainPanelView(MainPanel main_panel) {
c.setVisible(false);
}

download_status_bar.setMinimum(0);
upload_status_bar.setMinimum(0);

download_status_bar.setValue(download_status_bar.getMinimum());
upload_status_bar.setValue(upload_status_bar.getMinimum());

clean_all_down_menu.setEnabled(false);
clean_all_up_menu.setEnabled(false);
cancel_all_downloads_menu.setEnabled(false);
Expand Down Expand Up @@ -1090,7 +1102,7 @@ private void new_download_menuActionPerformed(java.awt.event.ActionEvent evt) {/
if (!urls.isEmpty()) {
MiscTools.GUIRun(() -> {
download_status_bar.setIndeterminate(true);

download_status_bar.setMaximum(getMain_panel().getDownload_manager().getTransference_preprocess_global_queue().size() + urls.size());
download_status_bar.setVisible(true);
});

Expand Down Expand Up @@ -1232,10 +1244,16 @@ private void new_download_menuActionPerformed(java.awt.event.ActionEvent evt) {/
Logger.getLogger(MainPanelView.class.getName()).log(Level.SEVERE, ex.getMessage());
}

MiscTools.GUIRun(() -> {
download_status_bar.setIndeterminate(false);
download_status_bar.setValue(upload_status_bar.getValue() + 1);
});

}

if (getMain_panel().getDownload_manager().getTransference_preprocess_global_queue().isEmpty()) {
MiscTools.GUIRun(() -> {
download_status_bar.setValue(download_status_bar.getMinimum());
download_status_bar.setVisible(false);
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/tonikelope/megabasterd/MegaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -1052,14 +1053,14 @@ public String cryptoHandleauth(String h) {
}

public boolean existsCachedFolderNodes(String folder_id) {
return Files.exists(Path.of(System.getProperty("java.io.tmpdir") + File.separator + "megabasterd_folder_cache_" + folder_id));
return Files.exists(Paths.get(System.getProperty("java.io.tmpdir") + File.separator + "megabasterd_folder_cache_" + folder_id));
}

private String getCachedFolderNodes(String folder_id) {

String file_path = System.getProperty("java.io.tmpdir") + File.separator + "megabasterd_folder_cache_" + folder_id;

if (Files.exists(Path.of(file_path))) {
if (Files.exists(Paths.get(file_path))) {

LOG.log(Level.INFO, "MEGA FOLDER {0} USING CACHED JSON FILE TREE", new Object[]{folder_id});

Expand Down
29 changes: 22 additions & 7 deletions src/main/java/com/tonikelope/megabasterd/MiscTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Synthesizer;
import javax.sound.midi.Track;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
Expand Down Expand Up @@ -474,19 +478,30 @@ public static void translateLabels(final Component component) {
}
}

public static Sequencer midiLoopPlay(String midi) {
public static Sequencer midiLoopPlay(String midi, int volume) {
try {
Sequencer sequencer = MidiSystem.getSequencer(); // Get the default Sequencer
Sequencer sequencer = MidiSystem.getSequencer();

if (sequencer == null) {
System.err.println("Sequencer device not supported");
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, "MIDI Sequencer device not supported");
return null;
}
sequencer.open(); // Open device
// Create sequence, the File must contain MIDI file data.

Synthesizer synthesizer = MidiSystem.getSynthesizer();

Sequence sequence = MidiSystem.getSequence(MiscTools.class.getResource(midi));
sequencer.setSequence(sequence); // load it into sequencer

for (Track t : sequence.getTracks()) {

for (int k = 0; k < synthesizer.getChannels().length; k++) {
t.add(new MidiEvent(new ShortMessage(ShortMessage.CONTROL_CHANGE, k, 7, volume), t.ticks()));
}
}

sequencer.open();
sequencer.setSequence(sequence);
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
sequencer.start(); // start the playback
sequencer.start();
return sequencer;
} catch (MidiUnavailableException | InvalidMidiDataException | IOException ex) {
ex.printStackTrace();
Expand Down
Loading

0 comments on commit c0bb5f6

Please sign in to comment.