mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-28 12:30:23 +02:00
2.22
This commit is contained in:
parent
2074f8b85f
commit
882992edcd
@ -2,13 +2,11 @@ package megabasterd;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JTextField;
|
||||
@ -17,9 +15,6 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MiscTools.BASE642Bin;
|
||||
import static megabasterd.MiscTools.Bin2BASE64;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
||||
import static megabasterd.MiscTools.deleteSelectedTreeItems;
|
||||
import static megabasterd.MiscTools.formatBytes;
|
||||
@ -536,79 +531,16 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
HashMap<String, Object> account_info = (HashMap) _main_panel.getMega_accounts().get(email);
|
||||
MegaAPI ma = null;
|
||||
try {
|
||||
ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
Long[] quota = null;
|
||||
|
||||
MegaAPI ma = _main_panel.getMega_active_accounts().get(account_combobox.getSelectedItem());
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
|
||||
try {
|
||||
|
||||
if (_main_panel.getMaster_pass_hash() != null) {
|
||||
|
||||
if (_main_panel.getMaster_pass() == null) {
|
||||
|
||||
GetMasterPasswordDialog dialog = new GetMasterPasswordDialog((Frame) getParent(), true, _main_panel.getMaster_pass_hash(), _main_panel.getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, tthis);
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", dialog, true);
|
||||
|
||||
if (dialog.isPass_ok()) {
|
||||
|
||||
_main_panel.setMaster_pass(dialog.getPass());
|
||||
|
||||
dialog.deletePass();
|
||||
|
||||
_remember_master_pass = dialog.getRemember_checkbox().isSelected();
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(email, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
_main_panel.getMega_active_accounts().put(email, ma);
|
||||
|
||||
quota = ma.getQuota();
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (ma != null) {
|
||||
quota = ma.getQuota();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import java.awt.Color;
|
||||
import java.awt.Frame;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -27,14 +26,10 @@ import java.util.regex.Pattern;
|
||||
import javax.crypto.CipherInputStream;
|
||||
import static megabasterd.MainPanel.STREAMER_PORT;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MiscTools.BASE642Bin;
|
||||
import static megabasterd.MiscTools.Bin2BASE64;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
import static megabasterd.MiscTools.checkMegaDownloadUrl;
|
||||
import static megabasterd.MiscTools.findFirstRegex;
|
||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
@ -243,83 +238,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
||||
|
||||
MegaAPI ma = null;
|
||||
|
||||
if (mega_account != null) {
|
||||
|
||||
HashMap<String, Object> account_info = (HashMap) _main_panel.getMega_accounts().get(mega_account);
|
||||
|
||||
ma = _main_panel.getMega_active_accounts().get(mega_account);
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
boolean remember_master_pass = false;
|
||||
|
||||
try {
|
||||
|
||||
if (_main_panel.getMaster_pass_hash() != null) {
|
||||
|
||||
if (_main_panel.getMaster_pass() == null) {
|
||||
|
||||
GetMasterPasswordDialog dialog = new GetMasterPasswordDialog((Frame) _main_panel.getView(), true, _main_panel.getMaster_pass_hash(), _main_panel.getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, _main_panel.getView());
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", dialog, true);
|
||||
|
||||
if (dialog.isPass_ok()) {
|
||||
|
||||
_main_panel.setMaster_pass(dialog.getPass());
|
||||
|
||||
dialog.deletePass();
|
||||
|
||||
remember_master_pass = dialog.getRemember_checkbox().isSelected();
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(mega_account, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
_main_panel.getMega_active_accounts().put(mega_account, ma);
|
||||
|
||||
if (!remember_master_pass) {
|
||||
_main_panel.setMaster_pass(null);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if (mega_account == null || (ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, _main_panel.getView(), mega_account)) == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
}
|
||||
@ -357,6 +276,8 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(KissVideoStreamServer.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
} while (error);
|
||||
|
@ -1,13 +1,10 @@
|
||||
package megabasterd;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@ -18,9 +15,6 @@ import javax.swing.JFileChooser;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MiscTools.BASE642Bin;
|
||||
import static megabasterd.MiscTools.Bin2BASE64;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
import static megabasterd.MiscTools.extractMegaLinksFromString;
|
||||
import static megabasterd.MiscTools.extractStringFromClipboardContents;
|
||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||
@ -34,10 +28,13 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
||||
private final ClipboardSpy _clipboardspy;
|
||||
private final MainPanel _main_panel;
|
||||
private volatile String _last_selected_account;
|
||||
private boolean _remember_master_pass;
|
||||
|
||||
public boolean isRemember_master_pass() {
|
||||
return _remember_master_pass;
|
||||
public MainPanel getMain_panel() {
|
||||
return _main_panel;
|
||||
}
|
||||
|
||||
public String getLast_selected_account() {
|
||||
return _last_selected_account;
|
||||
}
|
||||
|
||||
public JComboBox<String> getUse_mega_account_down_combobox() {
|
||||
@ -71,23 +68,20 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
||||
|
||||
_clipboardspy = clipboardspy;
|
||||
|
||||
_last_selected_account = null;
|
||||
|
||||
_remember_master_pass = true;
|
||||
|
||||
swingReflectionInvoke("setText", download_dir_label, truncateText(download_path, 80));
|
||||
|
||||
_main_panel = ((MainPanelView) parent).getMain_panel();
|
||||
|
||||
_last_selected_account = "";
|
||||
|
||||
if (_main_panel.isUse_mega_account_down() && _main_panel.getMega_accounts().size() > 0) {
|
||||
|
||||
for (Object o : _main_panel.getMega_accounts().keySet()) {
|
||||
swingReflectionInvoke("addItem", use_mega_account_down_combobox, _main_panel.getMega_account_down());
|
||||
|
||||
swingReflectionInvoke("addItem", use_mega_account_down_combobox, o);
|
||||
}
|
||||
|
||||
swingReflectionInvoke("addItem", use_mega_account_down_combobox, "");
|
||||
|
||||
|
||||
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 0);
|
||||
|
||||
} else {
|
||||
swingReflectionInvoke("setEnabled", use_mega_account_down_combobox, false);
|
||||
swingReflectionInvoke("setEnabled", use_mega_account_down_label, false);
|
||||
@ -355,7 +349,7 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
||||
private void use_mega_account_down_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_use_mega_account_down_comboboxItemStateChanged
|
||||
String selected_item = (String) use_mega_account_down_combobox.getSelectedItem();
|
||||
|
||||
if (_main_panel.isUse_mega_account_down() && !"".equals(selected_item) && selected_item != null && !selected_item.equals(_last_selected_account)) {
|
||||
if (_main_panel.isUse_mega_account_down() && !"".equals(selected_item) && !selected_item.equals(_last_selected_account)) {
|
||||
|
||||
use_mega_account_down_combobox.setEnabled(false);
|
||||
|
||||
@ -365,81 +359,18 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
||||
|
||||
final String email = selected_item;
|
||||
|
||||
final Dialog tthis = this;
|
||||
final LinkGrabberDialog tthis = this;
|
||||
|
||||
THREAD_POOL.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
HashMap<String, Object> account_info = (HashMap) _main_panel.getMega_accounts().get(email);
|
||||
try {
|
||||
MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
||||
} catch (Exception ex) {
|
||||
|
||||
MegaAPI ma = _main_panel.getMega_active_accounts().get(use_mega_account_down_combobox.getSelectedItem());
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
|
||||
try {
|
||||
|
||||
if (_main_panel.getMaster_pass_hash() != null) {
|
||||
|
||||
if (_main_panel.getMaster_pass() == null) {
|
||||
|
||||
GetMasterPasswordDialog dialog = new GetMasterPasswordDialog((Frame) getParent(), true, _main_panel.getMaster_pass_hash(), _main_panel.getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, tthis);
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", dialog, true);
|
||||
|
||||
if (dialog.isPass_ok()) {
|
||||
|
||||
_main_panel.setMaster_pass(dialog.getPass());
|
||||
|
||||
dialog.deletePass();
|
||||
|
||||
_remember_master_pass = dialog.getRemember_checkbox().isSelected();
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(email, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
_main_panel.getMega_active_accounts().put(email, ma);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
//getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
_last_selected_account = null;
|
||||
|
||||
swingReflectionInvoke("setSelectedIndex", ((LinkGrabberDialog) tthis).getUse_mega_account_down_combobox(), -1);
|
||||
}
|
||||
_last_selected_account = "";
|
||||
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 1);
|
||||
}
|
||||
|
||||
swingReflectionInvokeAndWait("setEnabled", ((LinkGrabberDialog) tthis).getUse_mega_account_down_combobox(), true);
|
||||
@ -447,8 +378,6 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
||||
swingReflectionInvokeAndWait("setEnabled", ((LinkGrabberDialog) tthis).getDance_button(), true);
|
||||
}
|
||||
});
|
||||
} else if(!selected_item.equals(_last_selected_account)) {
|
||||
_last_selected_account=null;
|
||||
}
|
||||
}//GEN-LAST:event_use_mega_account_down_comboboxItemStateChanged
|
||||
|
||||
|
@ -42,11 +42,9 @@ import static megabasterd.DBTools.selectSettingValueFromDB;
|
||||
import static megabasterd.DBTools.selectUploads;
|
||||
import static megabasterd.DBTools.setupSqliteTables;
|
||||
import static megabasterd.MiscTools.BASE642Bin;
|
||||
import static megabasterd.MiscTools.Bin2BASE64;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
import static megabasterd.MiscTools.setNimbusLookAndFeel;
|
||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
||||
import static megabasterd.Transference.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
||||
import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
|
||||
@ -59,7 +57,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "2.21";
|
||||
public static final String VERSION = "2.22";
|
||||
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;
|
||||
@ -705,76 +703,7 @@ public final class MainPanel {
|
||||
|
||||
MegaAPI ma;
|
||||
|
||||
if (tthis.isUse_mega_account_down() && _mega_accounts.get(email) != null) {
|
||||
|
||||
final HashMap<String, Object> account_info = (HashMap) _mega_accounts.get(email);
|
||||
|
||||
ma = _mega_active_accounts.get(email);
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
|
||||
if (getMaster_pass_hash() != null) {
|
||||
|
||||
if (getMaster_pass() == null) {
|
||||
|
||||
getView().getjTabbedPane1().setSelectedIndex(1);
|
||||
|
||||
GetMasterPasswordDialog dialog = new GetMasterPasswordDialog(getView(), true, getMaster_pass_hash(), getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, getView());
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", dialog, true);
|
||||
|
||||
if (dialog.isPass_ok()) {
|
||||
|
||||
setMaster_pass(dialog.getPass());
|
||||
|
||||
dialog.deletePass();
|
||||
|
||||
remember_pass = dialog.getRemember_checkbox().isSelected();
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(email, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
_mega_active_accounts.put(email, ma);
|
||||
|
||||
} else {
|
||||
|
||||
ma = new MegaAPI();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!tthis.isUse_mega_account_down() || _mega_accounts.get(email) == null || (ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(tthis, getView(), email)) == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
}
|
||||
@ -894,8 +823,6 @@ public final class MainPanel {
|
||||
|
||||
int conta_uploads = 0;
|
||||
|
||||
boolean remember_pass = true;
|
||||
|
||||
ArrayList<HashMap<String, Object>> res = selectUploads();
|
||||
|
||||
for (HashMap<String, Object> o : res) {
|
||||
@ -908,68 +835,8 @@ public final class MainPanel {
|
||||
|
||||
if (_mega_accounts.get(email) != null) {
|
||||
|
||||
final HashMap<String, Object> account_info = (HashMap) _mega_accounts.get(email);
|
||||
|
||||
ma = _mega_active_accounts.get(email);
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
if ((ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(tthis, getView(), email)) == null) {
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
|
||||
if (getMaster_pass_hash() != null) {
|
||||
|
||||
if (getMaster_pass() == null) {
|
||||
|
||||
getView().getjTabbedPane1().setSelectedIndex(1);
|
||||
|
||||
GetMasterPasswordDialog dialog = new GetMasterPasswordDialog(getView(), true, getMaster_pass_hash(), getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, getView());
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", dialog, true);
|
||||
|
||||
if (dialog.isPass_ok()) {
|
||||
|
||||
setMaster_pass(dialog.getPass());
|
||||
|
||||
dialog.deletePass();
|
||||
|
||||
remember_pass = dialog.getRemember_checkbox().isSelected();
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(email, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
_mega_active_accounts.put(email, ma);
|
||||
|
||||
}
|
||||
|
||||
Upload upload = new Upload(tthis, ma, (String) o.get("filename"), (String) o.get("parent_node"), (String) o.get("ul_key") != null ? bin2i32a(BASE642Bin((String) o.get("ul_key"))) : null, (String) o.get("url"), (String) o.get("root_node"), BASE642Bin((String) o.get("share_key")), (String) o.get("folder_link"), _use_slots_up, _default_slots_up, false);
|
||||
@ -996,11 +863,6 @@ public final class MainPanel {
|
||||
|
||||
}
|
||||
|
||||
if (!remember_pass) {
|
||||
|
||||
setMaster_pass(null);
|
||||
}
|
||||
|
||||
swingReflectionInvoke("setText", getView().getStatus_up_label(), "");
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -486,7 +486,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
if (getMain_panel().isUse_mega_account_down()) {
|
||||
final String mega_account = (String) dialog.getUse_mega_account_down_combobox().getSelectedItem();
|
||||
|
||||
if (mega_account == null) {
|
||||
if ("".equals(mega_account)) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
@ -621,11 +621,6 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
new_download_menu.setEnabled(true);
|
||||
}
|
||||
|
||||
if (!dialog.isRemember_master_pass()) {
|
||||
|
||||
_main_panel.setMaster_pass(null);
|
||||
}
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
}//GEN-LAST:event_new_download_menuActionPerformed
|
||||
@ -806,11 +801,6 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
|
||||
dialog.setVisible(true);
|
||||
|
||||
if (!dialog.isRemember_master_pass()) {
|
||||
|
||||
_main_panel.setMaster_pass(null);
|
||||
}
|
||||
|
||||
_main_panel.getClipboardspy().detachObserver(dialog);
|
||||
}//GEN-LAST:event_new_stream_menuActionPerformed
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package megabasterd;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
@ -81,6 +83,7 @@ public final class MiscTools {
|
||||
public static final int EXP_BACKOFF_BASE = 2;
|
||||
public static final int EXP_BACKOFF_SECS_RETRY = 1;
|
||||
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 64;
|
||||
public static final Object _password_lock = new Object();
|
||||
|
||||
private static final ConcurrentHashMap<String, Method> REFLECTION_METHOD_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -1082,4 +1085,81 @@ public final class MiscTools {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static MegaAPI checkMegaAccountLoginAndShowMasterPassDialog(MainPanel main_panel, Container container, String email) throws Exception {
|
||||
|
||||
boolean remember_master_pass = true;
|
||||
|
||||
HashMap<String, Object> account_info = (HashMap) main_panel.getMega_accounts().get(email);
|
||||
|
||||
MegaAPI ma = main_panel.getMega_active_accounts().get(email);
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
synchronized (_password_lock) {
|
||||
|
||||
if (main_panel.getMaster_pass_hash() != null) {
|
||||
|
||||
if (main_panel.getMaster_pass() == null) {
|
||||
|
||||
GetMasterPasswordDialog pdialog = new GetMasterPasswordDialog((Frame) container.getParent(), true, main_panel.getMaster_pass_hash(), main_panel.getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", pdialog, container);
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", pdialog, true);
|
||||
|
||||
if (pdialog.isPass_ok()) {
|
||||
|
||||
main_panel.setMaster_pass(pdialog.getPass());
|
||||
|
||||
pdialog.deletePass();
|
||||
|
||||
remember_master_pass = pdialog.getRemember_checkbox().isSelected();
|
||||
|
||||
pdialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
pdialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(email, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
main_panel.getMega_active_accounts().put(email, ma);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!remember_master_pass) {
|
||||
|
||||
main_panel.setMaster_pass(null);
|
||||
}
|
||||
|
||||
return ma;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -391,7 +391,7 @@
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Ubuntu" size="16" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Default account:"/>
|
||||
<Property name="text" type="java.lang.String" value="Mega account:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="megacrypter_reverse_checkbox">
|
||||
|
@ -626,7 +626,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
use_mega_account_down_combobox.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||
|
||||
use_mega_label.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
|
||||
use_mega_label.setText("Default account:");
|
||||
use_mega_label.setText("Mega account:");
|
||||
|
||||
megacrypter_reverse_checkbox.setFont(new java.awt.Font("Ubuntu", 1, 20)); // NOI18N
|
||||
megacrypter_reverse_checkbox.setText("Use Megacrypter reverse mode");
|
||||
|
@ -1,10 +1,8 @@
|
||||
package megabasterd;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.WindowEvent;
|
||||
import static java.awt.event.WindowEvent.WINDOW_CLOSING;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
@ -12,9 +10,6 @@ import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JOptionPane;
|
||||
import static megabasterd.MainPanel.THREAD_POOL;
|
||||
import static megabasterd.MiscTools.BASE642Bin;
|
||||
import static megabasterd.MiscTools.Bin2BASE64;
|
||||
import static megabasterd.MiscTools.bin2i32a;
|
||||
import static megabasterd.MiscTools.extractFirstMegaLinkFromString;
|
||||
import static megabasterd.MiscTools.extractStringFromClipboardContents;
|
||||
import static megabasterd.MiscTools.findFirstRegex;
|
||||
@ -32,10 +27,9 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
||||
private final MainPanelView _mainPanelView;
|
||||
private final MainPanel _main_panel;
|
||||
private volatile String _last_selected_account;
|
||||
private boolean _remember_master_pass;
|
||||
|
||||
public boolean isRemember_master_pass() {
|
||||
return _remember_master_pass;
|
||||
public String getLast_selected_account() {
|
||||
return _last_selected_account;
|
||||
}
|
||||
|
||||
public JButton getDance_button() {
|
||||
@ -46,6 +40,10 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
||||
return use_mega_account_down_combobox;
|
||||
}
|
||||
|
||||
public MainPanel getMain_panel() {
|
||||
return _main_panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form Streamer
|
||||
*
|
||||
@ -56,20 +54,21 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
||||
initComponents();
|
||||
|
||||
_clipboardspy = clipboardspy;
|
||||
|
||||
_mainPanelView = (MainPanelView) parent;
|
||||
_last_selected_account = null;
|
||||
_remember_master_pass = true;
|
||||
|
||||
_main_panel = ((MainPanelView) parent).getMain_panel();
|
||||
|
||||
_last_selected_account = "";
|
||||
|
||||
if (_main_panel.isUse_mega_account_down() && _main_panel.getMega_accounts().size() > 0) {
|
||||
|
||||
for (Object o : _main_panel.getMega_accounts().keySet()) {
|
||||
swingReflectionInvoke("addItem", use_mega_account_down_combobox, _main_panel.getMega_account_down());
|
||||
|
||||
swingReflectionInvoke("addItem", use_mega_account_down_combobox, o);
|
||||
}
|
||||
|
||||
swingReflectionInvoke("addItem", use_mega_account_down_combobox, "");
|
||||
|
||||
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 0);
|
||||
|
||||
} else {
|
||||
swingReflectionInvoke("setEnabled", use_mega_account_down_combobox, false);
|
||||
swingReflectionInvoke("setEnabled", use_mega_account_down_label, false);
|
||||
@ -247,9 +246,9 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
||||
}//GEN-LAST:event_dance_buttonActionPerformed
|
||||
|
||||
private void use_mega_account_down_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_use_mega_account_down_comboboxItemStateChanged
|
||||
String selected_item = (String) use_mega_account_down_combobox.getSelectedItem();
|
||||
final String selected_item = (String) use_mega_account_down_combobox.getSelectedItem();
|
||||
|
||||
if (_main_panel.isUse_mega_account_down() && !"".equals(selected_item) && selected_item != null && !selected_item.equals(_last_selected_account)) {
|
||||
if (_main_panel.isUse_mega_account_down() && !selected_item.equals(_last_selected_account) && !"".equals(selected_item)) {
|
||||
|
||||
use_mega_account_down_combobox.setEnabled(false);
|
||||
|
||||
@ -259,90 +258,25 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
||||
|
||||
final String email = selected_item;
|
||||
|
||||
final Dialog tthis = this;
|
||||
final StreamerDialog tthis = this;
|
||||
|
||||
THREAD_POOL.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
HashMap<String, Object> account_info = (HashMap) _main_panel.getMega_accounts().get(email);
|
||||
try {
|
||||
MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
||||
} catch (Exception ex) {
|
||||
|
||||
MegaAPI ma = _main_panel.getMega_active_accounts().get(use_mega_account_down_combobox.getSelectedItem());
|
||||
|
||||
if (ma == null) {
|
||||
|
||||
ma = new MegaAPI();
|
||||
|
||||
String password_aes, user_hash;
|
||||
|
||||
try {
|
||||
|
||||
if (_main_panel.getMaster_pass_hash() != null) {
|
||||
|
||||
if (_main_panel.getMaster_pass() == null) {
|
||||
|
||||
GetMasterPasswordDialog dialog = new GetMasterPasswordDialog((Frame) getParent(), true, _main_panel.getMaster_pass_hash(), _main_panel.getMaster_pass_salt());
|
||||
|
||||
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, tthis);
|
||||
|
||||
swingReflectionInvokeAndWait("setVisible", dialog, true);
|
||||
|
||||
if (dialog.isPass_ok()) {
|
||||
|
||||
_main_panel.setMaster_pass(dialog.getPass());
|
||||
|
||||
dialog.deletePass();
|
||||
|
||||
_remember_master_pass = dialog.getRemember_checkbox().isSelected();
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
} else {
|
||||
|
||||
dialog.dispose();
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("password_aes")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) account_info.get("user_hash")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
password_aes = (String) account_info.get("password_aes");
|
||||
|
||||
user_hash = (String) account_info.get("user_hash");
|
||||
}
|
||||
|
||||
ma.fastLogin(email, bin2i32a(BASE642Bin(password_aes)), user_hash);
|
||||
|
||||
_main_panel.getMega_active_accounts().put(email, ma);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
//getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
_last_selected_account = null;
|
||||
|
||||
swingReflectionInvoke("setSelectedIndex", ((StreamerDialog) tthis).getUse_mega_account_down_combobox(), -1);
|
||||
}
|
||||
_last_selected_account = "";
|
||||
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 1);
|
||||
}
|
||||
|
||||
swingReflectionInvokeAndWait("setEnabled", ((StreamerDialog) tthis).getUse_mega_account_down_combobox(), true);
|
||||
|
||||
swingReflectionInvokeAndWait("setEnabled", ((StreamerDialog) tthis).getDance_button(), true);
|
||||
swingReflectionInvokeAndWaitForReturn("setEnabled", ((StreamerDialog) tthis).getDance_button(), true);
|
||||
}
|
||||
});
|
||||
} else if(!selected_item.equals(_last_selected_account)) {
|
||||
_last_selected_account=null;
|
||||
}
|
||||
}//GEN-LAST:event_use_mega_account_down_comboboxItemStateChanged
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user