Removed outdated stuff

ExtractionIndicator: hidden if addon is not loaded
Vimeo: fixed login
Extraction:
-updated Indicator stuff
ContainerPluginController: updated

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@15336 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
jiaz 2011-11-18 16:09:41 +00:00
parent 607439a6ac
commit 8c44cadf2b
42 changed files with 287 additions and 1144 deletions

View File

@ -39,6 +39,7 @@ import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
import org.appwork.utils.images.IconIO;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.EDTHelper;
public class EasyMethodFile implements JDLabelContainer, Serializable {
@ -260,7 +261,7 @@ public class EasyMethodFile implements JDLabelContainer, Serializable {
* öffnet den Captchaordner
*/
public void openCaptchaFolder() {
JDUtilities.openExplorer(this.getCaptchaFolder());
CrossSystem.openFile(this.getCaptchaFolder());
}
public void setFile(final File file) {

View File

@ -52,6 +52,7 @@ import jd.parser.html.HTMLParser;
import jd.parser.html.InputField;
import jd.utils.JDUtilities;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.EDTHelper;
public class LoadCaptchas {
@ -309,7 +310,7 @@ public class LoadCaptchas {
private static void openDir(final String dir) {
new EDTHelper<Object>() {
public Object edtRun() {
if (JOptionPane.showConfirmDialog(null, "Captcha Ordner:" + dir + " jetzt öffnen?") == JOptionPane.YES_OPTION) JDUtilities.openExplorer(new File(dir));
if (JOptionPane.showConfirmDialog(null, "Captcha Ordner:" + dir + " jetzt öffnen?") == JOptionPane.YES_OPTION) CrossSystem.openFile(new File(dir));
return null;
}

View File

@ -21,8 +21,6 @@ import java.util.ArrayList;
import javax.swing.ImageIcon;
import jd.controlling.ListController;
/**
* Diese Klasse speichert die GUI-Dialog Informationen. Jede GUI kann diese
* Infos Abfragen und Entsprechend verarbeiten
@ -124,7 +122,7 @@ public class ConfigContainer implements Serializable {
*
* @see ConfigEntry#ConfigEntry(int, ListController, String)
*/
public static final int TYPE_LISTCONTROLLED = 110;
/**
* ConfigElement ist ein Combobox dessen Index (und nicht Text) gespeichert
* und geladen wird

View File

@ -522,7 +522,7 @@ public class AccountController implements AccountControllerListener {
acc = event.getAccount();
/* we do a new accountcheck as this account got updated */
/* WARNING: DO NOT FORCE check here, it might end up in a loop */
if (acc != null && acc.isEnabled()) AccountChecker.getInstance().check(acc, false);
if (acc != null && acc.isEnabled() && this == acc.getAccountController()) AccountChecker.getInstance().check(acc, false);
break;
case AccountControllerEvent.ACCOUNT_REMOVED:
case AccountControllerEvent.ACCOUNT_EXPIRED:

View File

@ -213,6 +213,7 @@ public final class ClipboardHandler extends Thread {
}
}
} catch (final Exception e2) {
// JDLogger.exception(e2);
}
try {
@ -323,7 +324,7 @@ public final class ClipboardHandler extends Thread {
}
}
} catch (final Exception e) {
// JDLogger.exception(e);
e.printStackTrace();
}
return what;
}

View File

@ -1,112 +0,0 @@
package jd.controlling;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import jd.http.Browser;
import jd.utils.locale.JDL;
import org.appwork.storage.JSonStorage;
import org.appwork.storage.Storage;
import org.appwork.utils.Hash;
import org.appwork.utils.swing.dialog.ConfirmDialog;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;
import org.appwork.utils.swing.dialog.DialogClosedException;
/**
* Checks files and resources, if they are valid. If not, user is asked if he
* wants to import them
*
* @author thomas
*/
public class CodeVerifier {
public enum State {
/** not tested */
NOT_VERIFIED,
/** asked user, and he trusted the file */
USER_DECIDED_TRUSTED,
/** asked user, and he decided not to trust the file */
USER_DECIDED_NOT_TRUSTED,
/** whitelist (server) ok */
TRUSTED;
}
private final Storage storage;
private final Browser br;
private static final CodeVerifier INSTANCE = new CodeVerifier();
public static CodeVerifier getInstance() {
return INSTANCE;
}
private CodeVerifier() {
this.storage = JSonStorage.getStorage("CodeVerifier");
this.br = new Browser();
}
/**
* calls jd server to verify the hash
*
* @param hash
* @param file
* @return
* @throws IOException
*/
private State checkWhitelist(final String hash, final File file) throws IOException {
// perhaps we should allow paralell requests. but we cannot use one
// single Browser instance then
synchronized (this.br) {
this.br.getPage("http://service.jdownloader.org/verify/" + hash + "/" + file.getName());
return State.valueOf(this.br.toString().trim());
}
}
public boolean isJarAllowed(final File file) throws NoSuchAlgorithmException, IOException {
if (true) return true;
final String hash = Hash.getMD5(file);
if (hash == null) { return false; }
State state = this.storage.get(hash, State.NOT_VERIFIED);
if (state == State.NOT_VERIFIED) {
try {
state = this.checkWhitelist(hash, file);
} catch (final Throwable e) {
e.printStackTrace();
}
}
if (state != State.TRUSTED && state != State.USER_DECIDED_TRUSTED) {
final ConfirmDialog dialog = new ConfirmDialog(Dialog.STYLE_SHOW_DO_NOT_DISPLAY_AGAIN, "Unknown author", JDL.LF("jd.controlling.CodeVerifier.isJarAllowed.message", "The file %s is not an offical part of JDownloader.\r\n\r\nDo only accept and load it, if you trust the author or content provider!\r\nLoad this file?", file.getName()), null, null, null) {
private static final long serialVersionUID = 1L;
@Override
protected String getDontShowAgainKey() {
// override to have an hash dependend don't
// show_again_trigger key
return "ABSTRACTDIALOG_DONT_SHOW_AGAIN_" + hash;
}
};
Integer ret;
try {
ret = Dialog.getInstance().showDialog(dialog);
ret = Dialog.getInstance().showConfirmDialog(0, JDL.LF("jd.controlling.CodeVerifier.isJarAllowed.rlymessage", "The untrusted file %s will be loaded now.\r\nAre you sure that you want to load this file?", file.getName()));
} catch (DialogClosedException e) {
state = State.USER_DECIDED_NOT_TRUSTED;
this.storage.put(hash, state);
} catch (DialogCanceledException e) {
state = State.USER_DECIDED_NOT_TRUSTED;
this.storage.put(hash, state);
}
return state == State.USER_DECIDED_TRUSTED || state == State.TRUSTED;
}
return false;
}
}

View File

@ -1,47 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// 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 jd.controlling;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import jd.config.Property;
public class DataBox extends Property {
/**
*
*/
private static final long serialVersionUID = 5147254150196577471L;
public Entry<String, Object> getEntry(int id) {
HashMap<String, Object> props = this.getProperties();
if (props != null) {
for (final Iterator<Entry<String, Object>> it = props.entrySet().iterator(); it.hasNext();) {
if (id < 0) return null;
if (id == 0) {
return it.next();
} else {
it.next();
}
id--;
}
}
return null;
}
}

View File

@ -16,60 +16,19 @@
package jd.controlling;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import javax.swing.Timer;
import jd.config.SubConfiguration;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import org.appwork.utils.Regex;
@Deprecated
/**
* @Deprecated Only here for stable plugin compatibility
*/
public class HTACCESSController implements ActionListener, ListController {
private transient static SubConfiguration CONFIG = null;
private transient HashMap<String, String[]> LIST;
private transient static HTACCESSController INSTANCE = null;
public class HTACCESSController {
private final Timer asyncSaveIntervalTimer;
private boolean saveinprogress;
public static synchronized HTACCESSController getInstance() {
if (INSTANCE == null) {
INSTANCE = new HTACCESSController();
}
return INSTANCE;
}
private final static HTACCESSController INSTANCE = new HTACCESSController();
private HTACCESSController() {
CONFIG = SubConfiguration.getConfig("HTACCESSLIST");
final HashMap<String, String[]> defaultentry = new HashMap<String, String[]>();
defaultentry.put("example.com", new String[] { "username", "passwd" });
LIST = CONFIG.getGenericProperty("LIST2", defaultentry);
asyncSaveIntervalTimer = new Timer(2000, this);
asyncSaveIntervalTimer.setInitialDelay(2000);
asyncSaveIntervalTimer.setRepeats(false);
asyncSaveIntervalTimer.stop();
saveSync();
}
public void add(final String url, String username, String passwd) {
if (url != null && url.length() > 0) {
final String host = Browser.getHost(url.trim()).toLowerCase();
if (username == null) username = "";
if (passwd == null) passwd = "";
synchronized (LIST) {
LIST.remove(host);
LIST.put(host, new String[] { username.trim(), passwd.trim() });
}
}
}
public static String[] getUserDatafromBasicauth(String basicauth) {
@ -85,91 +44,28 @@ public class HTACCESSController implements ActionListener, ListController {
final String host = Browser.getHost(url.trim()).toLowerCase();
final String[] user = getUserDatafromBasicauth(basicauth);
if (user == null) return;
synchronized (LIST) {
LIST.remove(host);
LIST.put(host, user);
}
}
}
public String get(final String url) {
if (url != null && url.length() > 0) {
final String host = Browser.getHost(url.trim()).toLowerCase();
synchronized (LIST) {
if (!LIST.containsKey(host)) return null;
return "Basic " + Encoding.Base64Encode(LIST.get(host)[0] + ":" + LIST.get(host)[1]);
}
// return "Basic " + Encoding.Base64Encode(LIST.get(host)[0] + ":" +
// LIST.get(host)[1]);
}
return null;
}
public void remove(final String url) {
if (url != null && url.length() > 0) {
final String host = Browser.getHost(url.trim()).toLowerCase();
synchronized (LIST) {
LIST.remove(host);
}
}
}
public HashMap<String, String[]> getPasswordList() {
return LIST;
@Deprecated
public static HTACCESSController getInstance() {
return INSTANCE;
}
public void setList(final String list) {
final String[] pws = Regex.getLines(list);
synchronized (LIST) {
LIST.clear();
for (final String pw : pws) {
final String[] dat = new Regex(pw, "(.*?)%%%%(.*?)%%%%(.*?)$").getRow(0);
if (dat != null) {
add(dat[0], dat[1], dat[2]);
}
}
}
}
public String getList() {
synchronized (LIST) {
final StringBuilder sb = new StringBuilder();
for (final String host : LIST.keySet()) {
final String auth[] = LIST.get(host);
sb.append(host).append(" %%%% ").append(auth[0]).append(" %%%% ").append(auth[1]);
sb.append(new char[] { '\r', '\n' });
}
return sb.toString().trim();
}
}
public void save() {
asyncSaveIntervalTimer.restart();
}
public void saveAsync() {
if (saveinprogress) return;
new Thread() {
@Override
public void run() {
this.setName("PasswordList: Saving");
saveinprogress = true;
saveSync();
saveinprogress = false;
}
}.start();
}
public void saveSync() {
final String id = JDController.requestDelayExit("htaccesscontroller");
synchronized (LIST) {
CONFIG.setProperty("LIST", LIST);
CONFIG.save();
}
JDController.releaseDelayExit(id);
}
public void actionPerformed(final ActionEvent event) {
if (event.getSource() == asyncSaveIntervalTimer) {
saveAsync();
}
}
}

View File

@ -16,13 +16,6 @@
package jd.controlling;
/**
* Diese Klasse kann dazu verwendet werden einen Fortschritt in der GUI
* anzuzeigen. Sie bildet dabei die schnittstelle zwischen Interactionen,
* plugins etc und der GUI
*
* @author JD-Team
*/
public class ProgressController {
public ProgressController() {

View File

@ -5,6 +5,9 @@ import java.util.ArrayList;
import org.appwork.shutdown.ShutdownController;
import org.appwork.shutdown.ShutdownEvent;
import org.appwork.storage.config.JsonConfig;
import org.appwork.utils.StringUtils;
import org.appwork.utils.event.predefined.changeevent.ChangeEvent;
import org.appwork.utils.event.predefined.changeevent.ChangeEventSender;
public class AuthenticationController {
private static final AuthenticationController INSTANCE = new AuthenticationController();
@ -21,6 +24,7 @@ public class AuthenticationController {
private AuthenticationControllerSettings config;
private ArrayList<AuthenticationInfo> list;
private ChangeEventSender eventSender = new ChangeEventSender();
/**
* Create a new instance of AuthenticationController. This is a singleton
@ -28,7 +32,7 @@ public class AuthenticationController {
*/
private AuthenticationController() {
config = JsonConfig.create(AuthenticationControllerSettings.class);
list = config.getList();
list = cleanup(config.getList());
if (list == null) list = new ArrayList<AuthenticationInfo>();
ShutdownController.getInstance().addShutdownEvent(new ShutdownEvent() {
@Override
@ -45,16 +49,32 @@ public class AuthenticationController {
});
}
public ChangeEventSender getEventSender() {
return eventSender;
}
public synchronized ArrayList<AuthenticationInfo> list() {
return new ArrayList<AuthenticationInfo>(list);
}
private ArrayList<AuthenticationInfo> cleanup(ArrayList<AuthenticationInfo> input) {
if (input == null) return null;
ArrayList<AuthenticationInfo> ret = new ArrayList<AuthenticationInfo>(input.size());
for (AuthenticationInfo item : input) {
if (StringUtils.isEmpty(item.getHostmask())) continue;
if (StringUtils.isEmpty(item.getPassword()) && StringUtils.isEmpty(item.getPassword())) continue;
ret.add(item);
}
return ret;
}
public void add(AuthenticationInfo a) {
if (a == null) return;
synchronized (this) {
list.add(a);
config.setList(list);
}
eventSender.fireEvent(new ChangeEvent(this));
}
public void remove(AuthenticationInfo a) {
@ -63,6 +83,7 @@ public class AuthenticationController {
list.remove(a);
config.setList(list);
}
eventSender.fireEvent(new ChangeEvent(this));
}
public void remove(ArrayList<AuthenticationInfo> selectedObjects) {
@ -71,6 +92,7 @@ public class AuthenticationController {
list.removeAll(selectedObjects);
config.setList(list);
}
eventSender.fireEvent(new ChangeEvent(this));
}
}

View File

@ -432,7 +432,6 @@ public class LinkCrawler implements IOPermission {
for (final PluginsC pCon : ContainerPluginController.getInstance().list()) {
if (pCon.canHandle(url)) {
try {
ArrayList<CrawledLink> allPossibleCryptedLinks = pCon.getContainerLinks(url);
if (allPossibleCryptedLinks != null) {
for (final CrawledLink decryptThis : allPossibleCryptedLinks) {

View File

@ -5,7 +5,6 @@ import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -17,7 +16,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jd.config.Configuration;
import jd.controlling.CodeVerifier;
import jd.controlling.JDLogger;
import jd.controlling.reconnect.ipcheck.IPController;
import jd.controlling.reconnect.pluginsinc.batch.ExternBatchReconnectPlugin;
@ -289,14 +287,10 @@ public class ReconnectPluginController {
for (int i = 0; i < length; i++) {
try {
if (CodeVerifier.getInstance().isJarAllowed(files[i])) {
urls.add(files[i].toURI().toURL());
Application.addUrlToClassPath(files[i].toURI().toURL(), getClass().getClassLoader());
}
} catch (final IOException e) {
e.printStackTrace();
} catch (final NoSuchAlgorithmException e) {
e.printStackTrace();
urls.add(files[i].toURI().toURL());
Application.addUrlToClassPath(files[i].toURI().toURL(), getClass().getClassLoader());
} catch (final Throwable e) {
Log.exception(e);
}
}
}

View File

@ -1,230 +0,0 @@
package jd.gui.swing.dialog;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.util.Locale;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import jd.config.ConfigContainer;
import jd.config.ConfigEntry;
import jd.config.ConfigGroup;
import jd.config.SubConfiguration;
import jd.gui.UserIO;
import jd.gui.swing.components.BrowseFile;
import jd.gui.swing.jdgui.views.settings.sidebar.AddonConfig;
import jd.utils.JDGeoCode;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import jd.utils.locale.JDLocale;
import net.miginfocom.swing.MigLayout;
import org.appwork.storage.config.JsonConfig;
import org.appwork.utils.Application;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.dialog.AbstractDialog;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;
import org.appwork.utils.swing.dialog.DialogClosedException;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.settings.GeneralSettings;
public class InstallerDialog extends AbstractDialog<Object> {
private static final long serialVersionUID = 1869417100230097511L;
public static boolean showDialog(final File dlFolder) {
final InstallerDialog dialog = new InstallerDialog(dlFolder);
try {
Dialog.getInstance().showDialog(dialog);
return JsonConfig.create(GeneralSettings.class).getDefaultDownloadFolder() != null;
} catch (DialogClosedException e) {
e.printStackTrace();
} catch (DialogCanceledException e) {
e.printStackTrace();
}
return false;
}
private String language = null;
private final File dlFolder;
private BrowseFile browseFile;
private final String getScriptCode(String cntry) {
// TODO Serbian Cyrillic / Latin
// es-castillian: remove
// español and castellano correspond to the same language!
if (cntry.equals("CN") || cntry.equals("SG")) {
return "hans";
} else if (cntry.equals("HK") || cntry.equals("MO") || cntry.equals("TW")) { return "hant"; }
return null;
}
private InstallerDialog(final File dlFolder) {
super(UserIO.NO_ICON, _GUI._.installer_gui_title(), null, null, null);
Locale l = Locale.getDefault();
// ISO 3166 alpha-2 country code or UN M.49 numeric-3 area code
final String countryCode = JDGeoCode.COUNTRIES.containsKey(l.getCountry()) ? l.getCountry() : JDL.getCountryCodeByIP();
// ISO 639 alpha-2 or alpha-3 language code, or registered language
// subtags up to 8 alpha letters (for future enhancements).
final String languageCode = JDGeoCode.LANGUAGES.containsKey(l.getLanguage()) ? l.getLanguage() : null;
// ISO 15924 alpha-4 script code
String scriptCode = (countryCode != null ? getScriptCode(countryCode) : null);
if (Application.getJavaVersion() >= 17000000) {
// 1.7! Locale.getScript
try {
String sc = ((String) Locale.class.getMethod("getScript", new Class[] {}).invoke(l, new Object[] {})).toLowerCase();
if (JDGeoCode.EXTENSIONS.containsKey(sc)) {
scriptCode = sc;
}
} catch (Throwable e) {
e.printStackTrace();
}
}
if (languageCode != null) {
boolean C_Set = false;
boolean S_Set = false;
for (final JDLocale id : JDL.getLocaleIDs()) {
if (id.getLanguageCode().equalsIgnoreCase(languageCode)) {
if (countryCode != null && id.getCountryCode() != null && id.getCountryCode().equalsIgnoreCase(countryCode)) {
if (!C_Set) {
S_Set = false;
}
C_Set = true;
} else if (C_Set) {
continue;
}
if (scriptCode != null && id.getLngGeoCode().contains(scriptCode)) {
S_Set = true;
this.language = id.getLngGeoCode();
} else if (!S_Set) {
this.language = id.getLngGeoCode();
}
}
}
}
if (this.language == null) {
this.language = "en";
}
if (dlFolder != null) {
this.dlFolder = dlFolder;
} else {
if (CrossSystem.isLinux()) {
String outdir = null;
try {
outdir = JDUtilities.runCommand("xdg-user-dir", new String[] { "DOWNLOAD" }, null, 10).trim();
if (!new File(outdir).isDirectory()) {
outdir = null;
}
} catch (Throwable e) {
outdir = null;
}
if (outdir == null) outdir = System.getProperty("user.home");
this.dlFolder = new File(outdir);
} else if (CrossSystem.isMac()) {
this.dlFolder = new File(System.getProperty("user.home") + "/Downloads");
} else if (CrossSystem.isWindows() && new File(System.getProperty("user.home") + "/Downloads").exists()) {
this.dlFolder = new File(System.getProperty("user.home") + "/Downloads");
} else if (CrossSystem.isWindows() && new File(System.getProperty("user.home") + "/Download").exists()) {
this.dlFolder = new File(System.getProperty("user.home") + "/Download");
} else {
this.dlFolder = JDUtilities.getResourceFile("downloads");
}
}
}
@Override
protected Object createReturnValue() {
return this.getReturnmask();
}
@Override
public JComponent layoutDialogContent() {
final JDLocale sel = SubConfiguration.getConfig(JDL.CONFIG).getGenericProperty(JDL.LOCALE_PARAM_ID, JDL.getInstance(this.language));
JDL.setLocale(sel);
this.browseFile = new BrowseFile();
this.browseFile.setFileSelectionMode(BrowseFile.DIRECTORIES_ONLY);
this.browseFile.setCurrentPath(this.dlFolder);
final JList list = new JList(JDL.getLocaleIDs().toArray());
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setSelectedValue(sel, true);
list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
JDL.setConfigLocale((JDLocale) list.getSelectedValue());
JDL.setLocale(JDL.getConfigLocale());
InstallerDialog.this.dispose();
InstallerDialog.showDialog(InstallerDialog.this.browseFile.getCurrentPath());
}
});
final ConfigContainer container = new ConfigContainer();
container.setGroup(new ConfigGroup(_GUI._.gui_config_gui_language(), "language"));
container.addEntry(new ConfigEntry(ConfigContainer.TYPE_COMPONENT, new JScrollPane(list), "growx,pushx"));
container.setGroup(new ConfigGroup(_GUI._.gui_config_general_downloaddirectory(), "home"));
container.addEntry(new ConfigEntry(ConfigContainer.TYPE_COMPONENT, this.browseFile, "growx,pushx"));
final JLabel lbl = new JLabel(_GUI._.installer_gui_message());
lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
lbl.setHorizontalAlignment(SwingConstants.CENTER);
if (CrossSystem.getID() == CrossSystem.OS_WINDOWS_VISTA || CrossSystem.getID() == CrossSystem.OS_WINDOWS_7) {
final String dir = JDUtilities.getResourceFile("downloads").getParent().substring(3).toLowerCase();
if (!JDUtilities.getResourceFile("uninstall.exe").exists() && (dir.startsWith("programme\\") || dir.startsWith("program files\\"))) {
lbl.setText(_GUI._.installer_vistaDir_warning(JDUtilities.getResourceFile("downloads").getParent()));
lbl.setForeground(Color.RED);
}
if (!JDUtilities.getResourceFile("JD.port").canWrite()) {
lbl.setText(_GUI._.installer_nowriteDir_warning(JDUtilities.getResourceFile("downloads").getParent()));
lbl.setForeground(Color.RED);
}
}
final JPanel panel = new JPanel(new MigLayout("ins 0,wrap 1", "[grow,fill]", "[]25[grow,fill]push[]"));
panel.add(lbl, "pushx");
panel.add(AddonConfig.getInstance(container, "", true).getPanel());
panel.add(new JSeparator(), "pushx");
return panel;
}
@Override
protected void packed() {
this.setAlwaysOnTop(true);
}
@Override
protected void setReturnmask(final boolean b) {
super.setReturnmask(b);
if (b) {
JsonConfig.create(GeneralSettings.class).setDefaultDownloadFolder(browseFile.getText());
}
}
}

View File

@ -32,13 +32,13 @@ import jd.gui.UserIO;
import jd.gui.swing.SwingGui;
import jd.gui.swing.jdgui.views.settings.panels.addons.ExtensionManager;
import jd.nutils.JDFlags;
import jd.utils.JDUtilities;
import jd.utils.WebUpdate;
import org.appwork.storage.config.JsonConfig;
import org.appwork.storage.config.ValidationException;
import org.appwork.storage.config.events.GenericConfigEventListener;
import org.appwork.storage.config.handler.KeyHandler;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.EDTRunner;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.settings.GeneralSettings;
@ -493,7 +493,12 @@ public class ActionController {
public void onAction(final ActionEvent e) {
final String dlDir = JsonConfig.create(GeneralSettings.class).getDefaultDownloadFolder();
if (dlDir == null) { return; }
JDUtilities.openExplorer(new File(dlDir));
CrossSystem.openFile(new File(dlDir));
}
@Override
public boolean isEnabled() {
return CrossSystem.isOpenFileSupported();
}
@Override

View File

@ -232,6 +232,7 @@ public class StatusBarImpl extends JPanel {
extractIndicator = new IconedProcessIndicator(NewTheme.I().getIcon("archive", 16));
extractIndicator.setEnabled(false);
extractIndicator.setVisible(false);
extractIndicator.setTitle(_GUI._.StatusBarImpl_initGUI_extract());
// extractIndicator.setToolTipText("<html><img src=\"" +
// NewTheme.I().getImageUrl("archive") +
@ -240,7 +241,7 @@ public class StatusBarImpl extends JPanel {
add(Box.createHorizontalGlue());
add(reconnectIndicator, "height 22!,width 22!");
add(linkGrabberIndicator, "height 22!,width 22!");
add(extractIndicator, "height 22!,width 22!");
add(extractIndicator, "height 22!,width 22!,hidemode 2");
}
public IconedProcessIndicator getLinkGrabberIndicator() {
@ -266,94 +267,5 @@ public class StatusBarImpl extends JPanel {
}
};
}
// private void colorizeSpinnerSpeed() {
// /* färbt den spinner ein, falls speedbegrenzung aktiv */
// if (spMaxSpeed.getValue() > 0) {
// spMaxSpeed.setColor(new Color(255, 12, 3));
// } else {
// spMaxSpeed.setColor(null);
// }
// }
// /**
// * Setzt die Downloadgeschwindigkeit
// *
// * @param speed
// * bytes pro sekunde
// */
// public void setSpeed(int speed) {
// if (speed <= 0) {
// spMaxSpeed.setText(_GUI._.gui_statusbar_speed());
// } else {
// spMaxSpeed.setText("(" + Formatter.formatReadable(speed) + "/s)");
// }
// }
// public void setSpinnerSpeed(Integer speed) {
// try {
// spMaxSpeed.setValue(speed);
// colorizeSpinnerSpeed();
// } catch (Throwable e) {
// }
// }
// public void stateChanged(ChangeEvent e) {
// if (e.getSource() == spMaxSpeed.getSpinner()) {
// // dlConfig.setProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,
// // spMaxSpeed.getValue());
// // dlConfig.save();
// config.setDownloadSpeedLimit(spMaxSpeed.getValue());
// } else if (e.getSource() == spMaxDls.getSpinner()) {
// // dlConfig.setProperty(Configuration.PARAM_DOWNLOAD_MAX_SIMULTAN,
// // spMaxDls.getValue());
// // dlConfig.save();
// config.setMaxSimultaneDownloads(spMaxDls.getValue());
// } else if (e.getSource() == spMaxChunks.getSpinner()) {
// // dlConfig.setProperty(Configuration.PARAM_DOWNLOAD_MAX_CHUNKS,
// // spMaxChunks.getValue());
// // dlConfig.save();
// config.setMaxChunksPerFile(spMaxChunks.getValue());
// }
// }
//
// public void onConfigValidatorError(ConfigInterface config, Throwable
// validateException, KeyHandler methodHandler) {
// }
//
// public void onConfigValueModified(ConfigInterface config2, String key,
// Object newValue) {
//
// if ("downloadSpeedLimit".equalsIgnoreCase(key)) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// DownloadWatchDog.getInstance().getConnectionManager().setIncommingBandwidthLimit(config.getDownloadSpeedLimit()
// * 1024);
// setSpinnerSpeed(config.getDownloadSpeedLimit());
// }
// });
// } else if ("MaxSimultaneDownloads".equalsIgnoreCase(key)) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// try {
// spMaxDls.setValue(config.getMaxSimultaneDownloads());
// } catch (Throwable e) {
// config.setMaxSimultaneDownloads(2);
// spMaxDls.setValue(2);
// }
// }
// });
// } else if ("MaxChunksPerFile".equalsIgnoreCase(key)) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// try {
// spMaxChunks.setValue(config.getMaxChunksPerFile());
// } catch (Throwable e) {
// spMaxChunks.setValue(1);
// config.setMaxChunksPerFile(1);
// }
// }
// });
// }
// }
}

View File

@ -103,7 +103,6 @@ public abstract class ConfigPanel extends SwitchPanel {
if (guiEntry.getDecoration() != null) {
switch (entry.getType()) {
case ConfigContainer.TYPE_TEXTAREA:
case ConfigContainer.TYPE_LISTCONTROLLED:
panel.add(guiEntry.getDecoration(), gapLeft + "spanx");
break;
case ConfigContainer.TYPE_COMPONENT:
@ -121,7 +120,6 @@ public abstract class ConfigPanel extends SwitchPanel {
panel.add(guiEntry.getInput(), (guiEntry.getDecoration() == null ? gapLeft + "spanx," : "") + "wmax 250");
break;
case ConfigContainer.TYPE_TEXTAREA:
case ConfigContainer.TYPE_LISTCONTROLLED:
panel.add(new JScrollPane(guiEntry.getInput()), gapLeft + "spanx, growy, pushy");
break;
default:

View File

@ -98,7 +98,6 @@ public class GUIConfigEntry implements GuiConfigListener, ActionListener, Change
doc.addDocumentListener(this);
break;
case ConfigContainer.TYPE_TEXTAREA:
case ConfigContainer.TYPE_LISTCONTROLLED:
input = new JDTextArea();
doc = ((JDTextArea) input).getDocument();
doc.addDocumentListener(this);
@ -219,7 +218,6 @@ public class GUIConfigEntry implements GuiConfigListener, ActionListener, Change
return new String(((JPasswordField) input).getPassword());
case ConfigContainer.TYPE_TEXTFIELD:
case ConfigContainer.TYPE_TEXTAREA:
case ConfigContainer.TYPE_LISTCONTROLLED:
return ((JTextComponent) input).getText();
case ConfigContainer.TYPE_CHECKBOX:
return ((JCheckBox) input).isSelected();
@ -289,7 +287,6 @@ public class GUIConfigEntry implements GuiConfigListener, ActionListener, Change
switch (configEntry.getType()) {
case ConfigContainer.TYPE_PASSWORDFIELD:
case ConfigContainer.TYPE_TEXTFIELD:
case ConfigContainer.TYPE_LISTCONTROLLED:
case ConfigContainer.TYPE_TEXTAREA:
((JTextComponent) input).setText(text == null ? "" : text.toString());
break;

View File

@ -12,5 +12,4 @@ public interface SettingsComponent {
public void setToolTipText(String text);
public void addStateUpdateListener(StateUpdateListener listener);
}

View File

@ -7,6 +7,7 @@ import javax.swing.DefaultComboBoxModel;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;
import jd.controlling.authentication.AuthenticationController;
import jd.controlling.authentication.AuthenticationInfo;
import org.appwork.swing.exttable.ExtTableHeaderRenderer;
@ -15,14 +16,17 @@ import org.appwork.swing.exttable.columns.ExtCheckColumn;
import org.appwork.swing.exttable.columns.ExtComboColumn;
import org.appwork.swing.exttable.columns.ExtPasswordEditorColumn;
import org.appwork.swing.exttable.columns.ExtTextColumn;
import org.appwork.utils.event.predefined.changeevent.ChangeEvent;
import org.appwork.utils.event.predefined.changeevent.ChangeListener;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.images.NewTheme;
public class AuthTableModel extends ExtTableModel<AuthenticationInfo> {
public class AuthTableModel extends ExtTableModel<AuthenticationInfo> implements ChangeListener {
private static final long serialVersionUID = 1L;
public AuthTableModel() {
super("AuthTableModel");
AuthenticationController.getInstance().getEventSender().addListener(this, true);
}
@Override
@ -222,4 +226,8 @@ public class AuthTableModel extends ExtTableModel<AuthenticationInfo> {
});
}
public void onChangeEvent(ChangeEvent event) {
this._fireTableStructureChanged(AuthenticationController.getInstance().list(), false);
}
}

View File

@ -7,7 +7,6 @@ import javax.swing.JScrollPane;
import jd.controlling.IOEQ;
import jd.controlling.authentication.AuthenticationController;
import jd.gui.swing.jdgui.views.settings.components.SettingsComponent;
import jd.gui.swing.jdgui.views.settings.components.StateUpdateListener;
import net.miginfocom.swing.MigLayout;
import org.appwork.app.gui.MigPanel;
@ -52,10 +51,6 @@ public class BasicAuthenticationPanel extends JPanel implements SettingsComponen
}
public void addStateUpdateListener(StateUpdateListener listener) {
throw new IllegalStateException("Not implemented");
}
public String getConstraints() {
return "wmin 10,height 60:n:n,pushy,growy";
}
@ -65,6 +60,7 @@ public class BasicAuthenticationPanel extends JPanel implements SettingsComponen
}
public void update() {
/* refresh table when we switch to it */
IOEQ.add(new Runnable() {
public void run() {

View File

@ -13,10 +13,8 @@ public class NewAction extends AbstractAddAction {
*
*/
private static final long serialVersionUID = 1L;
private AuthTable table;
public NewAction(AuthTable table) {
this.table = table;
this.setIconKey("add");
}
@ -24,7 +22,6 @@ public class NewAction extends AbstractAddAction {
IOEQ.add(new Runnable() {
public void run() {
AuthenticationController.getInstance().add(new AuthenticationInfo());
table.getExtTableModel()._fireTableStructureChanged(AuthenticationController.getInstance().list(), false);
}
});

View File

@ -38,7 +38,6 @@ public class RemoveAction extends AbstractRemoveAction {
IOEQ.add(new Runnable() {
public void run() {
AuthenticationController.getInstance().remove(selection);
table.getExtTableModel()._fireTableStructureChanged(AuthenticationController.getInstance().list(), false);
}
});

View File

@ -176,7 +176,6 @@ public class LookAndFeelController {
* setups the correct Look and Feel
*/
public void setUIManager() {
if (uiInitated) return;
uiInitated = true;
long t = System.currentTimeMillis();

View File

@ -73,6 +73,10 @@ public class Account extends Property {
this.ac = ac;
}
public AccountController getAccountController() {
return ac;
}
/**
*
* @param user

View File

@ -26,6 +26,7 @@ import java.util.regex.Pattern;
import jd.controlling.linkcrawler.CrawledLink;
import jd.controlling.linkcrawler.LinkCrawler;
import jd.gui.UserIO;
import jd.nutils.Formatter;
import jd.nutils.JDFlags;
import jd.nutils.encoding.Encoding;
import jd.utils.JDUtilities;
@ -51,14 +52,14 @@ public abstract class PluginsC {
private String name;
private int version;
private long version;
public PluginsC(String name, String pattern, String rev) {
this.pattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
this.name = name;
try {
version = Integer.parseInt(rev.substring(rev.indexOf(" ") + 1, rev.lastIndexOf(" ")));
version = Formatter.getRevision(rev);
} catch (Throwable e) {
version = -1;
}
@ -70,8 +71,6 @@ public abstract class PluginsC {
protected ArrayList<DownloadLink> cls = new ArrayList<DownloadLink>();
private ContainerStatus containerStatus = null;
protected ArrayList<String> dlU;
protected String md5;
@ -100,7 +99,7 @@ public abstract class PluginsC {
return name;
}
public int getVersion() {
public long getVersion() {
return version;
}
@ -216,7 +215,7 @@ public abstract class PluginsC {
if (!res.exists()) {
Log.L.severe("Could not copy file to homedir");
}
containerStatus = callDecryption(res);
callDecryption(res);
}
return;
}

View File

@ -669,7 +669,6 @@ public class DirectHTTP extends PluginForHost {
private void setConfigElements() {
if (oldStyle()) {
getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_LISTCONTROLLED, HTACCESSController.getInstance(), JDL.L("plugins.http.htaccess", "List of all HTAccess passwords. Each line one password.")));
} else {
ConfigEntry ce;
getConfig().addEntry(ce = new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), LASTMODIFIED, JDL.L("plugins.http.lastmodified", "Set file time to last modified time(server).")));

View File

@ -36,11 +36,11 @@ import jd.plugins.PluginForHost;
@HostPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "vimeo.com" }, urls = { "http://(www\\.)?vimeo\\.com/\\d+" }, flags = { 2 })
public class VimeoCom extends PluginForHost {
private static final String MAINPAGE = "http://www.vimeo.com";
static private final String AGB = "http://www.vimeo.com/terms";
private String clipData;
private String finalURL;
private static final Object LOCK = new Object();
private static final String MAINPAGE = "http://vimeo.com";
static private final String AGB = "http://www.vimeo.com/terms";
private String clipData;
private String finalURL;
private static final Object LOCK = new Object();
public VimeoCom(PluginWrapper wrapper) {
super(wrapper);
@ -123,50 +123,55 @@ public class VimeoCom extends PluginForHost {
@SuppressWarnings("unchecked")
private void login(final Account account, final boolean force) throws Exception {
synchronized (LOCK) {
this.setBrowserExclusive();
br.setFollowRedirects(true);
br.setDebug(true);
final Object ret = account.getProperty("cookies", null);
boolean acmatch = account.getUser().matches(account.getStringProperty("name", account.getUser()));
if (acmatch) acmatch = account.getPass().matches(account.getStringProperty("pass", account.getPass()));
if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
final HashMap<String, String> cookies = (HashMap<String, String>) ret;
if (cookies.containsKey("vimeo") && account.isValid()) {
for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
final String key = cookieEntry.getKey();
final String value = cookieEntry.getValue();
this.br.setCookie(MAINPAGE, key, value);
try {
this.setBrowserExclusive();
br.setFollowRedirects(true);
br.setDebug(true);
final Object ret = account.getProperty("cookies", null);
boolean acmatch = account.getUser().matches(account.getStringProperty("name", account.getUser()));
if (acmatch) acmatch = account.getPass().matches(account.getStringProperty("pass", account.getPass()));
if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
final HashMap<String, String> cookies = (HashMap<String, String>) ret;
if (cookies.containsKey("vimeo") && account.isValid()) {
for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
final String key = cookieEntry.getKey();
final String value = cookieEntry.getValue();
this.br.setCookie(MAINPAGE, key, value);
}
return;
}
return;
}
}
br.getPage(MAINPAGE);
br.getPage(MAINPAGE + "/log_in");
final String token = br.getRegex("name=\"token\" value=\"(.*?)\"").getMatch(0);
if (token == null) {
br.getPage(MAINPAGE);
br.getPage(MAINPAGE + "/log_in");
final String token = br.getRegex("name=\"token\" value=\"(.*?)\"").getMatch(0);
if (token == null) {
account.setProperty("cookies", null);
logger.warning("Login is broken!");
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
}
/* important, else we get a 401 */
br.setCookie(MAINPAGE, "xsrft", token);
if (!new Regex(account.getUser(), ".*?@.*?\\..+").matches()) {
account.setProperty("cookies", null);
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
}
br.postPage(MAINPAGE + "/log_in", "sign_in%5Bemail%5D=" + Encoding.urlEncode(account.getUser()) + "&sign_in%5Bpassword%5D=" + Encoding.urlEncode(account.getPass()) + "&token=" + Encoding.urlEncode(token));
if (br.getCookie(MAINPAGE, "vimeo") == null) {
account.setProperty("cookies", null);
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
}
final HashMap<String, String> cookies = new HashMap<String, String>();
final Cookies add = this.br.getCookies(MAINPAGE);
for (final Cookie c : add.getCookies()) {
cookies.put(c.getKey(), c.getValue());
}
account.setProperty("name", account.getUser());
account.setProperty("pass", account.getPass());
account.setProperty("cookies", cookies);
} catch (final PluginException e) {
account.setProperty("cookies", null);
logger.warning("Login is broken!");
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
throw e;
}
/* important, else we get a 401 */
br.setCookie(MAINPAGE, "xsrft", token);
if (!new Regex(account.getUser(), ".*?@.*?\\..+").matches()) {
account.setProperty("cookies", null);
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
}
br.postPage(MAINPAGE + "/log_in", "sign_in%5Bemail%5D=" + Encoding.urlEncode(account.getUser()) + "&sign_in%5Bpassword%5D=" + Encoding.urlEncode(account.getPass()) + "&token=" + Encoding.urlEncode(token));
if (br.getCookie(MAINPAGE, "vimeo") == null) {
account.setProperty("cookies", null);
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
}
final HashMap<String, String> cookies = new HashMap<String, String>();
final Cookies add = this.br.getCookies(MAINPAGE);
for (final Cookie c : add.getCookies()) {
cookies.put(c.getKey(), c.getValue());
}
account.setProperty("name", account.getUser());
account.setProperty("pass", account.getPass());
account.setProperty("cookies", cookies);
}
}

View File

@ -1,101 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// 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 jd.utils;
import jd.controlling.JDLogger;
public final class BinCode {
/**
* Don't let anyone instantiate this class.
*/
private BinCode() {
}
private static String addZero(final String bin, final int minCount) {
final StringBuilder ret = new StringBuilder(bin == null ? "" : bin);
for (int j = ret.length(); j < minCount; j++) {
ret.insert(0, '0');
}
return ret.toString();
}
private static String[] binArrayToCodeArray(final String[] binArray) {
final int length = binArray.length;
final String[] codeArray = new String[length];
for (int i = 0; i < length; i++) {
codeArray[i] = BinCode.prBinToCode(binArray[i]);
}
return codeArray;
}
public static String binToCode(final String bin) {
try {
final String[] sts = bin.split("\\|");
final String[] codeArray = BinCode.binArrayToCodeArray(sts);
final int minCount = sts[0].length();
final StringBuilder ret = new StringBuilder();
ret.append(minCount);
final int stsLength = sts.length;
for (int i = 0; i < stsLength; i++) {
ret.append("|" + codeArray[i]);
}
return ret.toString();
} catch (Exception e) {
JDLogger.exception(e);
}
return null;
}
private static String[] codeArrayToBinArray(final String[] codeArray) {
final int length = codeArray.length;
final String[] binArray = new String[length - 1];
final int minCount = Integer.parseInt(codeArray[0]);
for (int i = 1; i < length; i++) {
binArray[i - 1] = BinCode.addZero(BinCode.prCodeToBin(codeArray[i]), minCount);
}
return binArray;
}
public static String codeToString(final String code) {
try {
final String[] binArray = BinCode.codeToStringArray(code);
final StringBuilder ret = new StringBuilder();
boolean last = false;
for (String element : binArray) {
ret.append((last ? "|" : "") + element);
last = true;
}
return ret.toString();
} catch (Exception e) {
JDLogger.exception(e);
}
return null;
}
public static String[] codeToStringArray(final String code) {
return BinCode.codeArrayToBinArray(code.split("\\|"));
}
private static String prBinToCode(final String bin) {
return Integer.toString(Integer.parseInt(bin, 2), 36);
}
private static String prCodeToBin(final String Code) {
return Integer.toBinaryString(Integer.parseInt(Code, 36));
}
}

View File

@ -1,116 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// 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 jd.utils;
import java.util.Date;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Email {
private final String host;
private String user;
private String pass;
private String senderEmail;
private String senderName;
public Email(final String smtpHost) {
this.host = smtpHost;
}
public Email(final String smtpHost, final String user, final String pass) {
this.host = smtpHost;
this.user = user;
this.pass = pass;
}
public void setSender(final String email, final String name) {
this.senderEmail = email;
this.senderName = name;
}
public String getSenderName() {
return this.senderName;
}
public void sendEmail(final String email, final String name, final String subject, final String message) throws MessagingException {
final Properties props = new Properties();
props.put("mail.smtp.host", host);
Session session;
if (user != null) {
props.put("mail.smtp.auth", "true");
session = Session.getDefaultInstance(props, new MailAuthenticator(user, pass));
} else {
session = Session.getDefaultInstance(props);
}
final Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(senderEmail));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(email));
msg.setSentDate(new Date());
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
static class MailAuthenticator extends Authenticator {
/**
* Ein String, der den Usernamen nach der Erzeugung eines Objektes<br>
* dieser Klasse enthalten wird.
*/
private final String user;
/**
* Ein String, der das Passwort nach der Erzeugung eines Objektes<br>
* dieser Klasse enthalten wird.
*/
private final String password;
/**
* Der Konstruktor erzeugt ein MailAuthenticator Objekt<br>
* aus den beiden Parametern user und passwort.
*
* @param user
* String, der Username fuer den Mailaccount.
* @param password
* String, das Passwort fuer den Mailaccount.
*/
public MailAuthenticator(final String user, final String password) {
this.user = user;
this.password = password;
}
/**
* Diese Methode gibt ein neues PasswortAuthentication Objekt zurueck.
*
* @see javax.mail.Authenticator#getPasswordAuthentication()
*/
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(this.user, this.password);
}
}
}

View File

@ -1,115 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// 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 jd.utils;
import java.awt.Desktop;
import java.io.File;
import jd.controlling.JDLogger;
import jd.nutils.OSDetector;
import org.appwork.utils.Application;
public class GetExplorer {
private static final String PARAM_FILE_BROWSER = "PARAM_FILE_BROWSER";
private static Object[] explorer = JDUtilities.getConfiguration().getGenericProperty(PARAM_FILE_BROWSER, (Object[]) null);
/**
* Versucht den Programmpfad zum Explorer zu finden
*
* @return
*/
private static Object[] autoGetExplorerCommand() {
if (OSDetector.isWindows()) {
return new Object[] { "Explorer", "explorer", new String[] { "%%path%%" } };
} else if (OSDetector.isMac()) {
return new Object[] { "Open", "/usr/bin/open", new String[] { "%%path%%" } };
} else {
final Object[][] programms = new Object[][] { { "dolphin", new String[] { "%%path%%" } }, { "konqueror", new String[] { "%%path%%" } }, { "thunar", new String[] { "%%path%%" } }, { "rox", new String[] { "%%path%%" } }, { "pcmanfm", new String[] { "%%path%%" } }, { "nautilus", new String[] { "--browser", "--no-desktop", "%%path%%" } } };
try {
final String[] charset = System.getenv("PATH").split(":");
for (String element : charset) {
for (Object[] element2 : programms) {
final File fi = new File(element, (String) element2[0]);
if (fi.isFile()) return new Object[] { (String) element2[0], fi.getAbsolutePath(), element2[1] };
}
}
} catch (Throwable e) {
}
}
return null;
}
/**
* Object[0] = Browsername Object[1] = Befehl zum Browser Object[2] =
* String[] Parameter
*
* @return
*/
private static Object[] getExplorerCommand() {
if (explorer != null && !new File((String) explorer[1]).exists()) {
explorer = null;
JDUtilities.getConfiguration().setProperty(PARAM_FILE_BROWSER, null);
}
if (explorer == null) {
explorer = GetExplorer.autoGetExplorerCommand();
if (explorer == null) {
JDLogger.getLogger().severe("Can't find explorer command");
} else {
JDUtilities.getConfiguration().setProperty(PARAM_FILE_BROWSER, explorer);
}
}
return explorer;
}
public static boolean openExplorer(File path) {
if (path == null) return false;
if (Application.getJavaVersion() >= 16000000) {
try {
Desktop.getDesktop().open(path);
return true;
} catch (Exception e) {
e.printStackTrace();
}
}
getExplorerCommand();
while (path != null && !path.isDirectory()) {
path = path.getParentFile();
}
if (path != null && explorer != null) {
final String spath = path.getAbsolutePath();
final String[] paramsArray = (String[]) explorer[2];
final int length = paramsArray.length;
final String[] finalParams = new String[length];
for (int i = 0; i < length; i++) {
finalParams[i] = paramsArray[i].replace("%%path%%", spath);
}
JDUtilities.runCommand((String) explorer[1], finalParams, null, 0);
return true;
}
return false;
}
}

View File

@ -50,6 +50,7 @@ import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import org.appwork.utils.Application;
import org.appwork.utils.os.CrossSystem;
import org.jdownloader.plugins.controller.crawler.CrawlerPluginController;
import org.jdownloader.plugins.controller.crawler.LazyCrawlerPlugin;
import org.jdownloader.plugins.controller.host.HostPluginController;
@ -383,15 +384,6 @@ public class JDUtilities {
return DB_CONNECT;
}
public static boolean openExplorer(final File path) {
try {
return GetExplorer.openExplorer(path);
} catch (Exception e) {
JDLogger.exception(e);
return false;
}
}
public static Document parseXmlString(final String xmlString, final boolean validating) {
if (xmlString == null) return null;
try {
@ -444,4 +436,9 @@ public class JDUtilities {
return att.getNamedItem(key).getNodeValue();
}
@Deprecated
public static void openExplorer(File file) {
CrossSystem.openFile(file);
}
}

View File

@ -1,33 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// 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 jd.utils;
/**
*
* @author JDTeam
*
*/
public final class StringUtil {
/**
* Don't let anyone instantiate this class.
*/
private StringUtil() {
}
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
public static final String CRLF = "\r\n";
}

View File

@ -46,8 +46,6 @@ public class ExtensionController {
private ExtensionControllerEventSender eventSender;
private boolean rebuildCache = false;
/**
* Create a new instance of ExtensionController. This is a singleton class.
* Access the only existing instance by using {@link #getInstance()}.
@ -102,13 +100,16 @@ public class ExtensionController {
if (ret.size() == 0) {
Log.L.severe("@ExtensionController: WTF, no extensions!");
}
try {
Collections.sort(ret, new Comparator<LazyExtension>() {
Collections.sort(ret, new Comparator<LazyExtension>() {
public int compare(LazyExtension o1, LazyExtension o2) {
return o1.getName().compareTo(o2.getName());
}
});
public int compare(LazyExtension o1, LazyExtension o2) {
return o1.getName().compareTo(o2.getName());
}
});
} catch (final Throwable e) {
Log.exception(e);
}
list = Collections.unmodifiableList(ret);
Main.GUI_COMPLETE.executeWhenReached(new Runnable() {

View File

@ -60,6 +60,15 @@ public class ExtractionController extends QueueAction<Void, RuntimeException> {
passwordList = new ArrayList<String>();
}
public ExtractionQueue getExtractionQueue() {
return (ExtractionQueue) super.getQueue();
}
@Override
protected boolean allowAsync() {
return true;
}
/**
* Checks if the extracted file(s) has enough space. Only works with Java 6
* or higher.

View File

@ -27,6 +27,7 @@ import java.util.List;
import javax.swing.filechooser.FileFilter;
import jd.Main;
import jd.controlling.JDController;
import jd.controlling.JDLogger;
import jd.controlling.downloadcontroller.DownloadController;
@ -43,9 +44,9 @@ import jd.plugins.AddonPanel;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.LinkStatus;
import jd.utils.JDUtilities;
import org.appwork.utils.event.queue.Queue;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.EDTRunner;
import org.jdownloader.extensions.AbstractExtension;
import org.jdownloader.extensions.ExtensionConfigPanel;
import org.jdownloader.extensions.StartException;
@ -81,9 +82,7 @@ public class ExtractionExtension extends AbstractExtension<ExtractionConfig> imp
private static MenuAction menuAction = null;
private Queue ExtractionQueue = new Queue("Extraction") {
};
private ExtractionQueue ExtractionQueue = new ExtractionQueue();
private ExtractionEventSender broadcaster = new ExtractionEventSender();
@ -95,6 +94,8 @@ public class ExtractionExtension extends AbstractExtension<ExtractionConfig> imp
private static ExtractionExtension INSTANCE;
private ExtractionListenerIcon statusbarListener = null;
public ExtractionExtension() throws StartException {
super(T._.name());
INSTANCE = this;
@ -316,7 +317,7 @@ public class ExtractionExtension extends AbstractExtension<ExtractionConfig> imp
if (!new File(path).exists()) {
UserIO.getInstance().requestMessageDialog(T._.plugins_optional_extraction_messages(path));
} else {
JDUtilities.openExplorer(new File(path));
CrossSystem.openFile(new File(path));
}
break;
@ -736,11 +737,51 @@ public class ExtractionExtension extends AbstractExtension<ExtractionConfig> imp
@Override
protected void stop() throws StopException {
JDController.getInstance().removeControlListener(this);
Main.GUI_COMPLETE.executeWhenReached(new Runnable() {
public void run() {
new EDTRunner() {
@Override
protected void runInEDT() {
new EDTRunner() {
@Override
protected void runInEDT() {
JDGui.getInstance().getStatusBar().getExtractionIndicator().setVisible(false);
}
};
if (statusbarListener != null) removeListener(statusbarListener);
}
};
}
});
}
@Override
protected void start() throws StartException {
JDController.getInstance().addControlListener(this);
Main.GUI_COMPLETE.executeWhenReached(new Runnable() {
public void run() {
new EDTRunner() {
@Override
protected void runInEDT() {
new EDTRunner() {
@Override
protected void runInEDT() {
JDGui.getInstance().getStatusBar().getExtractionIndicator().setVisible(true);
JDGui.getInstance().getStatusBar().getExtractionIndicator().setDescription("No Job active");
}
};
addListener(statusbarListener = new ExtractionListenerIcon());
}
};
}
});
}
void fireEvent(ExtractionEvent event) {
@ -809,7 +850,6 @@ public class ExtractionExtension extends AbstractExtension<ExtractionConfig> imp
initExtractors();
addListener(new ExtractionListenerIcon(JDGui.getInstance().getStatusBar().getExtractionIndicator()));
// addListener(new ExtractionListenerFile());
addListener(new ExtractionListenerList());

View File

@ -1,7 +1,5 @@
package org.jdownloader.extensions.extraction;
import java.util.LinkedHashSet;
import jd.gui.swing.jdgui.JDGui;
import jd.gui.swing.jdgui.components.IconedProcessIndicator;
@ -9,17 +7,12 @@ import org.appwork.utils.swing.EDTRunner;
import org.jdownloader.extensions.extraction.translate.T;
public class ExtractionListenerIcon implements ExtractionListener {
private IconedProcessIndicator pi;
private LinkedHashSet<String> queue;
private String cacheQueue = "";
private String cacheJobName = "";
private String cacheJobStatus = "No Job active";
private boolean running = false;
private String cacheQueue = "";
private String cacheJobName = "";
private String cacheJobStatus = "No Job active";
public ExtractionListenerIcon(final IconedProcessIndicator pi) {
this.pi = pi;
queue = new LinkedHashSet<String>();
public ExtractionListenerIcon() {
}
public void onExtractionEvent(final ExtractionEvent event) {
@ -27,16 +20,10 @@ public class ExtractionListenerIcon implements ExtractionListener {
switch (event.getType()) {
case QUEUED:
if (pi == null) pi = JDGui.getInstance().getStatusBar().getExtractionIndicator();
queue.add(con.getArchiv().getFirstDownloadLink().getName());
updateQueue();
break;
case START:
queue.remove(con.getArchiv().getFirstDownloadLink().getName());
cacheJobName = con.getArchiv().getFirstDownloadLink().getName();
cacheJobStatus = T._.plugins_optional_extraction_status_openingarchive();
running = true;
updateQueue();
break;
case START_CRACK_PASSWORD:
cacheJobStatus = "Start password finding";
@ -62,53 +49,43 @@ public class ExtractionListenerIcon implements ExtractionListener {
case CLEANUP:
cacheJobName = "";
cacheJobStatus = "No Job active";
running = false;
break;
}
final StringBuilder sb = new StringBuilder();
if (!cacheQueue.equals("")) sb.append(cacheQueue);
if (!cacheJobName.equals("")) sb.append(cacheJobName);
sb.append(cacheJobStatus);
final IconedProcessIndicator pi = JDGui.getInstance().getStatusBar().getExtractionIndicator();
new EDTRunner() {
@Override
protected void runInEDT() {
switch (event.getType()) {
case START:
case QUEUED:
if (queue.size() == 1 && !running) {
pi.setEnabled(true);
pi.setIndeterminate(true);
if (con.getExtractionQueue().size() > 0) {
if (pi != null && !pi.isEnabled()) {
pi.setIndeterminate(true);
pi.setEnabled(true);
}
}
break;
case FINISHED:
if (queue.size() == 0) {
pi.setIndeterminate(false);
pi.setEnabled(false);
if (con.getExtractionQueue().size() <= 1) {
/*
* <=1 because current element is still running at this
* point
*/
if (pi != null && pi.isEnabled()) {
pi.setIndeterminate(false);
pi.setEnabled(false);
}
}
break;
}
StringBuilder sb = new StringBuilder();
if (!cacheQueue.equals("")) sb.append(cacheQueue);
if (!cacheJobName.equals("")) sb.append(cacheJobName);
sb.append(cacheJobStatus);
pi.setDescription(sb.toString());
if (pi != null) pi.setDescription(sb.toString());
}
};
}
private void updateQueue() {
final StringBuilder sb = new StringBuilder();
if (queue.size() > 0) {
sb.append("Queue:\n");
int i = 1;
for (String link : queue) {
sb.append(" " + i++ + ": " + link + "\n");
}
sb.append("\nCurrent:\n");
}
cacheQueue = sb.toString();
}
}

View File

@ -0,0 +1,46 @@
package org.jdownloader.extensions.extraction;
import java.util.ListIterator;
import org.appwork.utils.event.queue.Queue;
import org.appwork.utils.event.queue.QueueAction;
public class ExtractionQueue extends Queue {
private ExtractionController currentItem = null;
public ExtractionQueue() {
super("ExtractionQueue");
}
public ExtractionController getCurrentQueueEntry() {
return this.currentItem;
}
@Override
protected <T extends Throwable> void startItem(final QueueAction<?, T> item, final boolean callExceptionhandler) throws T {
this.currentItem = (ExtractionController) item;
try {
super.startItem(item, callExceptionhandler);
} finally {
this.currentItem = null;
}
}
public int size() {
int counter = 0;
synchronized (this.queueLock) {
if (currentItem != null) {
counter++;
}
for (final QueuePriority prio : this.prios) {
ListIterator<QueueAction<?, ? extends Throwable>> li = this.queue.get(prio).listIterator();
while (li.hasNext()) {
QueueAction<?, ? extends Throwable> next = li.next();
counter++;
}
}
}
return counter;
}
}

View File

@ -42,9 +42,9 @@ import jd.gui.UserIO;
import jd.nutils.JDFlags;
import jd.nutils.JDHash;
import jd.nutils.OSDetector;
import jd.utils.JDUtilities;
import net.miginfocom.swing.MigLayout;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.EDTRunner;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.Dialog.FileChooserSelectionMode;
@ -247,9 +247,7 @@ public class FolderWatchExtension extends AbstractExtension<FolderWatchConfig> i
File dir = new File(path);
if (dir.exists()) {
JDUtilities.openExplorer(dir);
} else {
UserIO.getInstance().requestConfirmDialog(UserIO.NO_COUNTDOWN, T._.plugins_optional_folderwatch_JDFolderWatch_action_openfolder_errormessage());
CrossSystem.openFile(dir);
}
}

View File

@ -40,7 +40,6 @@ import jd.plugins.AddonPanel;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.utils.Replacer;
import jd.utils.StringUtil;
import org.jdownloader.extensions.AbstractExtension;
import org.jdownloader.extensions.ExtensionConfigPanel;
@ -168,7 +167,7 @@ public class InfoFileWriterExtension extends AbstractExtension<InfoFileWriterCon
try {
if (dest.createNewFile() && dest.canWrite()) {
String rawContent = subConfig.getStringProperty(PARAM_INFO_STRING, INFO_STRING_DEFAULT);
String content = Replacer.insertVariables(rawContent.replaceAll("(\r\n|\n)", StringUtil.LINE_SEPARATOR), lastDownloadFinished);
String content = Replacer.insertVariables(rawContent.replaceAll("(\r\n|\n)", System.getProperty("line.separator")), lastDownloadFinished);
JDIO.writeLocalFile(dest, content);
logger.severe("JDInfoFileWriter: info file " + dest.getAbsolutePath() + " successfully created");

View File

@ -4,8 +4,8 @@ import java.awt.event.ActionEvent;
import java.io.File;
import jd.gui.swing.jdgui.interfaces.ContextMenuAction;
import jd.utils.JDUtilities;
import org.appwork.utils.os.CrossSystem;
import org.jdownloader.gui.translate._GUI;
public class OpenDirectoryAction extends ContextMenuAction {
@ -16,7 +16,6 @@ public class OpenDirectoryAction extends ContextMenuAction {
public OpenDirectoryAction(File folder) {
this.folder = folder;
init();
}
@ -31,7 +30,13 @@ public class OpenDirectoryAction extends ContextMenuAction {
}
public void actionPerformed(ActionEvent e) {
JDUtilities.openExplorer(folder);
if (!isEnabled()) return;
CrossSystem.openFile(folder);
}
@Override
public boolean isEnabled() {
return CrossSystem.isOpenFileSupported() && folder != null && folder.exists();
}
}

View File

@ -21,7 +21,6 @@ import javax.swing.Timer;
import jd.controlling.packagecontroller.AbstractNode;
import jd.event.ControlEvent;
import jd.gui.swing.jdgui.JDGui;
import jd.gui.swing.jdgui.actions.ActionController;
import jd.gui.swing.jdgui.actions.ToolBarAction;
import jd.gui.swing.jdgui.menu.MenuAction;
import jd.plugins.DownloadLink;
@ -312,7 +311,6 @@ public class DownloadsTable extends PackageControllerTable<FilePackage, Download
ret.add(new RatedMenuItem(new SetPasswordAction(alllinks), 0));
ret.add(new RatedMenuItem(new CopyPasswordAction(alllinks), 0));
ret.add(new RatedMenuItem(ActionController.getToolBarAction("action.passwordlist"), 0));
ret.add(new RatedMenuItem(new DeleteAction(alllinks), 0));
ret.add(new RatedMenuItem(new DeleteFromDiskAction(alllinks), 0));

View File

@ -7,6 +7,7 @@ import java.util.List;
import jd.plugins.PluginsC;
import org.appwork.utils.Regex;
import org.appwork.utils.logging.Log;
import org.jdownloader.container.AMZ;
import org.jdownloader.container.C;
import org.jdownloader.container.D;
@ -29,11 +30,15 @@ public class ContainerPluginController {
public void init() {
List<PluginsC> plugins = new ArrayList<PluginsC>();
plugins.add(new AMZ());
plugins.add(new C());
plugins.add(new D());
plugins.add(new MetaLink());
plugins.add(new R());
try {
plugins.add(new AMZ());
plugins.add(new C());
plugins.add(new D());
plugins.add(new MetaLink());
plugins.add(new R());
} catch (final Throwable e) {
Log.exception(e);
}
list = Collections.unmodifiableList(plugins);
}