mirror of
https://github.com/mirror/jdownloader.git
synced 2024-11-27 14:00:39 +00:00
StatusBar hinzugefügt
git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@17 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
parent
dce98f2644
commit
b6052d50f3
@ -4,6 +4,7 @@ action.move_up = Verschiebt die selektierten Eintr
|
||||
action.move_down = Verschiebt die selektierten Einträge um einen Eintrag nach unten
|
||||
action.start = Startet den Download
|
||||
error.no_download = Es konnte kein weiterer Download ermittelt werden
|
||||
label.status.welcome = JDownloader - der platformunabhängige Downloader
|
||||
label.tab.download = Download Liste
|
||||
label.tab.plugin_activity = Plugin Aktivitäten
|
||||
label.tab.download.column_index = #
|
||||
@ -11,4 +12,6 @@ label.tab.download.column_link = Download
|
||||
label.tab.download.column_host = Host
|
||||
label.tab.download.column_progress = Fortschritt
|
||||
label.tab.plugin_activity.column_plugin = Name
|
||||
label.tab.plugin_activity.column_progress = Fortschritt
|
||||
label.tab.plugin_activity.column_progress = Fortschritt
|
||||
tooltip.status.plugin_decrypt = Zeigt, ob ein Entschlüssel-Plugin aktiv ist
|
||||
tooltip.status.plugin_host = Zeigt, ob Downloads aktiv sind
|
BIN
img/led_empty.gif
Normal file
BIN
img/led_empty.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 865 B |
BIN
img/led_green.gif
Normal file
BIN
img/led_green.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 167 B |
@ -35,7 +35,7 @@ public class CaptchaDialog extends JDialog implements ActionListener{
|
||||
/**
|
||||
* Das ist der eingegebene captcha Text
|
||||
*/
|
||||
private String captchaText=null;
|
||||
private String captchaText = null;
|
||||
/**
|
||||
* Erstellt einen neuen Dialog.
|
||||
*
|
||||
@ -64,6 +64,7 @@ public class CaptchaDialog extends JDialog implements ActionListener{
|
||||
|
||||
pack();
|
||||
setLocation(Utilities.getCenterOfComponent(null, this));
|
||||
textField.requestFocusInWindow();
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(e.getSource() == btnOK){
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
@ -26,7 +27,9 @@ import javax.swing.Action;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.JToolBar;
|
||||
@ -83,6 +86,7 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
*/
|
||||
private StartDownload download = null;
|
||||
private Speedometer speedoMeter = new Speedometer();
|
||||
private StatusBar statusBar;
|
||||
/**
|
||||
* Ein Togglebutton zum Starten / Stoppen der Downloads
|
||||
*/
|
||||
@ -126,6 +130,7 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
tabbedPane = new JTabbedPane();
|
||||
tabDownloadTable = new TabDownloadLinks();
|
||||
tabPluginActivity = new TabPluginActivity();
|
||||
statusBar = new StatusBar();
|
||||
tabbedPane.addTab(Utilities.getResourceString("label.tab.download"), tabDownloadTable);
|
||||
tabbedPane.addTab(Utilities.getResourceString("label.tab.plugin_activity"), tabPluginActivity);
|
||||
|
||||
@ -134,22 +139,19 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
btnStartStop.setFocusPainted(false);
|
||||
btnStartStop.setBorderPainted(false);
|
||||
|
||||
JButton btnUp = new JButton(actionMoveUp); btnUp.setFocusPainted(false); btnUp.setBorderPainted(false);
|
||||
JButton btnDown = new JButton(actionMoveDown); btnDown.setFocusPainted(false); btnDown.setBorderPainted(false);
|
||||
JButton btnAdd = new JButton(actionAdd); btnAdd.setFocusPainted(false); btnAdd.setBorderPainted(false);
|
||||
JButton btnDelete = new JButton(actionDelete); btnDelete.setFocusPainted(false);btnDelete.setBorderPainted(false);
|
||||
|
||||
toolBar.setFloatable(false);
|
||||
toolBar.add(btnStartStop);
|
||||
toolBar.add(btnUp);
|
||||
toolBar.add(btnDown);
|
||||
toolBar.add(btnAdd);
|
||||
toolBar.add(btnDelete);
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
Utilities.addToGridBag(this, toolBar, 0, 0, 1, 1, 0, 0, null, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH);
|
||||
Utilities.addToGridBag(this, tabbedPane, 0, 1, 1, 1, 1, 1, null, GridBagConstraints.BOTH, GridBagConstraints.CENTER);
|
||||
Utilities.addToGridBag(this, speedoMeter, 1, 1, 1, 1, 0, 0, null, GridBagConstraints.VERTICAL, GridBagConstraints.WEST);
|
||||
// Utilities.addToGridBag(this, speedoMeter, 1, 1, 1, 1, 0, 0, null, GridBagConstraints.VERTICAL, GridBagConstraints.WEST);
|
||||
Utilities.addToGridBag(this, statusBar, 0, 2, 1, 1, 0, 0, null, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
|
||||
// setJMenuBar(menuBar);
|
||||
}
|
||||
/**
|
||||
@ -158,13 +160,15 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
private void loadImages(){
|
||||
ClassLoader cl = getClass().getClassLoader();
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
Utilities.addImage("start", toolkit.getImage(cl.getResource("img/start.png")));
|
||||
Utilities.addImage("stop", toolkit.getImage(cl.getResource("img/stop.png")));
|
||||
Utilities.addImage("add", toolkit.getImage(cl.getResource("img/add.png")));
|
||||
Utilities.addImage("delete", toolkit.getImage(cl.getResource("img/delete.png")));
|
||||
Utilities.addImage("up", toolkit.getImage(cl.getResource("img/up.png")));
|
||||
Utilities.addImage("down", toolkit.getImage(cl.getResource("img/down.png")));
|
||||
Utilities.addImage("mind", toolkit.getImage(cl.getResource("img/mind.png")));
|
||||
Utilities.addImage("start", toolkit.getImage(cl.getResource("img/start.png")));
|
||||
Utilities.addImage("stop", toolkit.getImage(cl.getResource("img/stop.png")));
|
||||
Utilities.addImage("add", toolkit.getImage(cl.getResource("img/add.png")));
|
||||
Utilities.addImage("delete", toolkit.getImage(cl.getResource("img/delete.png")));
|
||||
Utilities.addImage("up", toolkit.getImage(cl.getResource("img/up.png")));
|
||||
Utilities.addImage("down", toolkit.getImage(cl.getResource("img/down.png")));
|
||||
Utilities.addImage("mind", toolkit.getImage(cl.getResource("img/mind.png")));
|
||||
Utilities.addImage("led_empty",toolkit.getImage(cl.getResource("img/led_empty.gif")));
|
||||
Utilities.addImage("led_green",toolkit.getImage(cl.getResource("img/led_green.gif")));
|
||||
}
|
||||
/**
|
||||
* Hier werden alle Plugins im aktuellen Verzeichnis geparsed (und im Classpath)
|
||||
@ -219,6 +223,7 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
private String getCaptcha(String captchaAdress){
|
||||
String captchaText=null;
|
||||
CaptchaDialog captchaDialog = new CaptchaDialog(this,captchaAdress);
|
||||
MainWindow.this.toFront();
|
||||
captchaDialog.setVisible(true);
|
||||
return captchaDialog.getCaptchaText();
|
||||
}
|
||||
@ -238,16 +243,9 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
}
|
||||
break;
|
||||
case JDAction.APP_START_STOP_DOWNLOADS:
|
||||
DownloadLink downloadLink = tabDownloadTable.getNextDownloadLink();
|
||||
if(download == null){
|
||||
if (downloadLink != null){
|
||||
download = new StartDownload(downloadLink);
|
||||
download.start();
|
||||
}
|
||||
else{
|
||||
logger.severe("no download in Queue (getNextDownloadLink() == null).");
|
||||
btnStartStop.setSelected(false);
|
||||
}
|
||||
download = new StartDownload();
|
||||
download.start();
|
||||
}
|
||||
else{
|
||||
download.interrupt();
|
||||
@ -369,9 +367,11 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
for(int i=0; i<pluginsForDecrypt.size();i++){
|
||||
pDecrypt = pluginsForDecrypt.elementAt(i);
|
||||
if(pDecrypt.isClipboardEnabled() && pDecrypt.canHandle(data)){
|
||||
statusBar.setPluginForDecryptActive(true);
|
||||
cryptedLinks.addAll(pDecrypt.getMatches(data,pDecrypt.getSupportedLinks()));
|
||||
data = pDecrypt.cutMatches(data);
|
||||
decryptedLinks.addAll(pDecrypt.decryptLinks(cryptedLinks));
|
||||
statusBar.setPluginForDecryptActive(false);
|
||||
}
|
||||
}
|
||||
// Danach wird der (noch verbleibende) Inhalt der Zwischenablage an die Plugins der Hoster geschickt.
|
||||
@ -414,9 +414,8 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
private Plugin plugin;
|
||||
private boolean aborted=false;
|
||||
|
||||
public StartDownload(DownloadLink downloadLink){
|
||||
public StartDownload(){
|
||||
super("JD-StartDownload");
|
||||
this.downloadLink = downloadLink;
|
||||
}
|
||||
public void abortDownload(){
|
||||
aborted=true;
|
||||
@ -424,35 +423,104 @@ public class MainWindow extends JFrame implements ClipboardOwner{
|
||||
plugin.abort();
|
||||
}
|
||||
public void run(){
|
||||
plugin = downloadLink.getPlugin();
|
||||
PluginStep step = plugin.getNextStep(downloadLink);
|
||||
|
||||
// Hier werden alle einzelnen Schritte des Plugins durchgegangen,
|
||||
// bis entwerder null zurückgegeben wird oder ein Fehler auftritt
|
||||
while(!aborted && step != null && step.getStatus()!=PluginStep.STATUS_ERROR){
|
||||
switch(step.getStep()){
|
||||
case PluginStep.STEP_WAIT_TIME:
|
||||
try {
|
||||
logger.info("sleep start");
|
||||
Thread.sleep((Long)step.getParameter());
|
||||
logger.info("sleep finish");
|
||||
|
||||
// while((downloadLink = tabDownloadTable.getNextDownloadLink()) != null){
|
||||
|
||||
plugin = downloadLink.getPlugin();
|
||||
PluginStep step = plugin.getNextStep(downloadLink);
|
||||
|
||||
// Hier werden alle einzelnen Schritte des Plugins durchgegangen,
|
||||
// bis entwerder null zurückgegeben wird oder ein Fehler auftritt
|
||||
statusBar.setPluginForHostActive(true);
|
||||
while(!aborted && step != null && step.getStatus()!=PluginStep.STATUS_ERROR){
|
||||
switch(step.getStep()){
|
||||
case PluginStep.STEP_WAIT_TIME:
|
||||
try {
|
||||
long milliSeconds = (Long)step.getParameter();
|
||||
logger.info("wait "+ milliSeconds+" ms");
|
||||
Thread.sleep(milliSeconds);
|
||||
step.setStatus(PluginStep.STATUS_DONE);
|
||||
}
|
||||
catch (InterruptedException e) { e.printStackTrace(); }
|
||||
break;
|
||||
case PluginStep.STEP_CAPTCHA:
|
||||
String captchaText = getCaptcha((String)step.getParameter());
|
||||
step.setParameter(captchaText);
|
||||
step.setStatus(PluginStep.STATUS_DONE);
|
||||
}
|
||||
catch (InterruptedException e) { e.printStackTrace(); }
|
||||
break;
|
||||
case PluginStep.STEP_CAPTCHA:
|
||||
String captchaText = getCaptcha((String)step.getParameter());
|
||||
step.setParameter(captchaText);
|
||||
step.setStatus(PluginStep.STATUS_DONE);
|
||||
}
|
||||
step = plugin.getNextStep(downloadLink);
|
||||
}
|
||||
step = plugin.getNextStep(downloadLink);
|
||||
}
|
||||
if(aborted){
|
||||
logger.warning("Thread aborted");
|
||||
}
|
||||
if(step != null && step.getStatus() == PluginStep.STATUS_ERROR){
|
||||
logger.severe("Error occurred while downloading file");
|
||||
}
|
||||
statusBar.setPluginForHostActive(false);
|
||||
if(aborted){
|
||||
logger.warning("Thread aborted");
|
||||
}
|
||||
if(step != null && step.getStatus() == PluginStep.STATUS_ERROR){
|
||||
logger.severe("Error occurred while downloading file");
|
||||
}
|
||||
// }
|
||||
btnStartStop.setSelected(false);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Diese Klasse realisiert eine StatusBar
|
||||
*
|
||||
* @author astaldo
|
||||
*/
|
||||
private class StatusBar extends JPanel{
|
||||
/**
|
||||
* serialVersionUID
|
||||
*/
|
||||
private static final long serialVersionUID = 3676496738341246846L;
|
||||
private JLabel lblMessage;
|
||||
private JLabel lblSpeed;
|
||||
private JLabel lblPluginHostActive;
|
||||
private JLabel lblPluginDecryptActive;
|
||||
private ImageIcon imgActive;
|
||||
private ImageIcon imgInactive;
|
||||
|
||||
public StatusBar(){
|
||||
imgActive = new ImageIcon(Utilities.getImage("led_green"));
|
||||
imgInactive = new ImageIcon(Utilities.getImage("led_empty"));
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
lblMessage = new JLabel(Utilities.getResourceString("label.status.welcome"));
|
||||
lblSpeed = new JLabel("450 kb/s");
|
||||
lblPluginHostActive = new JLabel(imgInactive);
|
||||
lblPluginDecryptActive = new JLabel(imgInactive);
|
||||
lblPluginDecryptActive.setToolTipText(Utilities.getResourceString("tooltip.status.plugin_decrypt"));
|
||||
lblPluginHostActive.setToolTipText(Utilities.getResourceString("tooltip.status.plugin_host"));
|
||||
|
||||
Utilities.addToGridBag(this, lblMessage, 0, 0, 1, 1, 1, 1, new Insets(0,5,0,0), GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
|
||||
Utilities.addToGridBag(this, lblSpeed, 1, 0, 1, 1, 0, 0, new Insets(0,5,0,5), GridBagConstraints.NONE, GridBagConstraints.WEST);
|
||||
Utilities.addToGridBag(this, lblPluginHostActive, 2, 0, 1, 1, 0, 0, new Insets(0,5,0,0), GridBagConstraints.NONE, GridBagConstraints.EAST);
|
||||
Utilities.addToGridBag(this, lblPluginDecryptActive, 3, 0, 1, 1, 0, 0, new Insets(0,5,0,5), GridBagConstraints.NONE, GridBagConstraints.EAST);
|
||||
}
|
||||
public void setText(String text){
|
||||
lblMessage.setText(text);
|
||||
}
|
||||
/**
|
||||
* Zeigt, ob die Plugins zum Downloaden von einem Anbieter arbeiten
|
||||
*
|
||||
* @param active wahr, wenn Downloads aktiv sind
|
||||
*/
|
||||
public void setPluginForHostActive(boolean active) { setPluginActive(lblPluginHostActive, active); }
|
||||
/**
|
||||
* Zeigt an, ob die Plugins zum Entschlüsseln von Links arbeiten
|
||||
*
|
||||
* @param active wahr, wenn soeben Links entschlüsselt werden
|
||||
*/
|
||||
public void setPluginForDecryptActive(boolean active) { setPluginActive(lblPluginDecryptActive, active); }
|
||||
/**
|
||||
* Ändert das genutzte Bild eines Labels, um In/Aktivität anzuzeigen
|
||||
*
|
||||
* @param lbl Das zu ändernde Label
|
||||
* @param active soll es als aktiv oder inaktiv gekennzeichnet werden
|
||||
*/
|
||||
private void setPluginActive(JLabel lbl,boolean active){
|
||||
if(active)
|
||||
lbl.setIcon(imgActive);
|
||||
else
|
||||
lbl.setIcon(imgInactive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ public abstract class Plugin{
|
||||
return true;
|
||||
}
|
||||
catch (FileNotFoundException e){
|
||||
logger.severe("fileDescription is wrong. "+e.getLocalizedMessage());
|
||||
logger.severe("file not found. "+e.getLocalizedMessage());
|
||||
}
|
||||
catch (SecurityException e){
|
||||
logger.severe("not enough rights to write the file. "+e.getLocalizedMessage());
|
||||
|
@ -5,16 +5,42 @@
|
||||
* @author astaldo
|
||||
*/
|
||||
public class PluginStep {
|
||||
|
||||
/**
|
||||
* ID für eine gewisse Wartezeit. Der dazugehörige Wert ist die Zeit in Millisekunden
|
||||
*/
|
||||
public final static int STEP_WAIT_TIME = 1 << 1;
|
||||
/**
|
||||
* Das Captcha Bild soll erkannt werden. Als Rückgabe wird der erkannte Text als Parameter übergeben
|
||||
*/
|
||||
public final static int STEP_CAPTCHA = 1 << 2;
|
||||
/**
|
||||
* Der Download soll durchgeführt werden. Als Parameter wird der DownloadLink übergeben
|
||||
*/
|
||||
public final static int STEP_DOWNLOAD = 1 << 3;
|
||||
/**
|
||||
* Ein Link soll entschlüsselt werden
|
||||
*/
|
||||
public final static int STEP_DECRYPT = 1 << 4;
|
||||
|
||||
public final static int STATUS_TODO = 0;
|
||||
public final static int STATUS_ERROR = 1;
|
||||
public final static int STATUS_DONE = 2;
|
||||
public final static int STATUS_INPUT_FROM_USER = 3;
|
||||
/**
|
||||
* Dieser Schritt muß erst noch stattfinden
|
||||
*/
|
||||
public final static int STATUS_TODO = 0;
|
||||
/**
|
||||
* Dieser Schritt wurde fehlerhaft abgearbeitet
|
||||
*/
|
||||
public final static int STATUS_ERROR = 1;
|
||||
/**
|
||||
* Dieser Schritt wurde erfolgreich durchgeführt
|
||||
*/
|
||||
public final static int STATUS_DONE = 2;
|
||||
/**
|
||||
* Dieser Schritt erfordert eine Interaktion
|
||||
*/
|
||||
public final static int STATUS_USER_INPUT = 3;
|
||||
/**
|
||||
* Dieser Schritt sollte nochmal wiederholt werden
|
||||
*/
|
||||
public final static int STATUS_RETRY = 4;
|
||||
/**
|
||||
* Status dieses Schrittes
|
||||
*/
|
||||
@ -37,4 +63,22 @@ public class PluginStep {
|
||||
public void setParameter(Object parameter) { this.parameter = parameter; }
|
||||
public int getStatus() { return status; }
|
||||
public void setStatus(int status) { this.status = status; }
|
||||
public String toString(){
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("step: ");
|
||||
switch(step){
|
||||
case STEP_WAIT_TIME: buffer.append("WAIT_TIME "); break;
|
||||
case STEP_CAPTCHA: buffer.append("CAPTCHA "); break;
|
||||
case STEP_DOWNLOAD: buffer.append("DOWNLOAD "); break;
|
||||
case STEP_DECRYPT: buffer.append("DECRYPT "); break;
|
||||
}
|
||||
buffer.append("status: ");
|
||||
switch(status){
|
||||
case STATUS_DONE: buffer.append("DONE"); break;
|
||||
case STATUS_ERROR: buffer.append("ERROR"); break;
|
||||
case STATUS_TODO: buffer.append("TODO"); break;
|
||||
case STATUS_USER_INPUT: buffer.append("USERINPUT"); break;
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ public class Stealth extends PluginForDecrypt{
|
||||
catch (IOException e) { e.printStackTrace(); }
|
||||
}
|
||||
firePluginEvent(new PluginEvent(this,PluginEvent.PLUGIN_PROGRESS_MAX,countHits));
|
||||
logger.info(cryptedLinks.size()+" crypted link(s) found");
|
||||
|
||||
//Hier werden alle verschlüsselten Links behandelt
|
||||
for(int i=0;i<cryptedLinks.size();i++){
|
||||
@ -74,6 +75,7 @@ public class Stealth extends PluginForDecrypt{
|
||||
decryptedLinks.add(requestInfo.getLocation());
|
||||
}
|
||||
}
|
||||
logger.info(decryptedLinks.size()+" downloads decrypted");
|
||||
firePluginEvent(new PluginEvent(this,PluginEvent.PLUGIN_PROGRESS_FINISH,null));
|
||||
currentStep = null;
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ import jd.plugins.RequestInfo;
|
||||
public class Rapidshare extends PluginForHost{
|
||||
private String host = "rapidshare.com";
|
||||
private String version = "1.0.0.0";
|
||||
private Pattern patternSupported = Pattern.compile("http://rapidshare\\.com/files/[0-9]*/[^\\s\"]+");
|
||||
// http://(?:[^.]*\.)*rapidshare\.com/files/[0-9]*/[^\s"]+
|
||||
private Pattern patternSupported = Pattern.compile("http://(?:[^.]*\\.)*rapidshare\\.com/files/[0-9]*/[^\\s\"]+");
|
||||
/**
|
||||
* Das findet die Ziel URL für den Post
|
||||
*/
|
||||
@ -32,6 +33,11 @@ public class Rapidshare extends PluginForHost{
|
||||
* <form name="dl".* action="([^\n"]*)"(?s).*?<input type="submit" name="actionstring" value="[^\n"]*"
|
||||
*/
|
||||
private Pattern patternForFormData = Pattern.compile("<form name=\"dl\".* action=\"([^\\n\"]*)\"(?s).*?<input type=\"submit\" name=\"actionstring\" value=\"([^\\n\"]*)\"");
|
||||
/**
|
||||
* Das DownloadLimit wurde erreicht
|
||||
* (?s)Downloadlimit.*Oder warte ([0-9]*)
|
||||
*/
|
||||
private Pattern patternDownloadLimitReached = Pattern.compile("(?s)Downloadlimit.*Oder warte ([0-9]*) ");
|
||||
|
||||
private int waitTime = 500;
|
||||
private String captchaAddress;
|
||||
@ -60,7 +66,7 @@ public class Rapidshare extends PluginForHost{
|
||||
public PluginStep getNextStep(Object parameter) {
|
||||
DownloadLink downloadLink = (DownloadLink)parameter;
|
||||
RequestInfo requestInfo;
|
||||
PluginStep toDo=null;
|
||||
PluginStep todo=null;
|
||||
if(currentStep == null){
|
||||
try {
|
||||
//Der Download wird bestätigt
|
||||
@ -79,6 +85,7 @@ public class Rapidshare extends PluginForHost{
|
||||
currentStep = steps.firstElement();
|
||||
if(captchaAddress == null || postTarget == null || actionString == null){
|
||||
currentStep.setStatus(PluginStep.STATUS_ERROR);
|
||||
logger.warning("could not get downloadInfo");
|
||||
return currentStep;
|
||||
}
|
||||
}
|
||||
@ -86,28 +93,32 @@ public class Rapidshare extends PluginForHost{
|
||||
catch (IOException e) { e.printStackTrace(); }
|
||||
}
|
||||
int index = steps.indexOf(currentStep);
|
||||
toDo = currentStep;
|
||||
todo = currentStep;
|
||||
if(index+1 < steps.size())
|
||||
currentStep = steps.elementAt(index+1);
|
||||
switch(toDo.getStep()){
|
||||
logger.info(todo.toString());
|
||||
switch(todo.getStep()){
|
||||
case PluginStep.STEP_WAIT_TIME:
|
||||
toDo.setParameter(new Long(waitTime));
|
||||
todo.setParameter(new Long(waitTime));
|
||||
break;
|
||||
case PluginStep.STEP_CAPTCHA:
|
||||
toDo.setParameter(captchaAddress);
|
||||
toDo.setStatus(PluginStep.STATUS_INPUT_FROM_USER);
|
||||
todo.setParameter(captchaAddress);
|
||||
todo.setStatus(PluginStep.STATUS_USER_INPUT);
|
||||
break;
|
||||
case PluginStep.STEP_DOWNLOAD:
|
||||
postParameter.put("mirror", "on");
|
||||
postParameter.put("accesscode", (String)steps.elementAt(1).getParameter());
|
||||
postParameter.put("actionString",actionString);
|
||||
|
||||
prepareDownload(downloadLink);
|
||||
boolean success = prepareDownload(downloadLink);
|
||||
if(success)
|
||||
todo.setStatus(PluginStep.STATUS_DONE);
|
||||
else
|
||||
todo.setStatus(PluginStep.STATUS_ERROR);
|
||||
break;
|
||||
}
|
||||
return toDo;
|
||||
return todo;
|
||||
}
|
||||
private void prepareDownload(DownloadLink downloadLink){
|
||||
private boolean prepareDownload(DownloadLink downloadLink){
|
||||
try {
|
||||
URLConnection urlConnection = new URL(postTarget).openConnection();
|
||||
urlConnection.setDoOutput(true);
|
||||
@ -122,8 +133,9 @@ public class Rapidshare extends PluginForHost{
|
||||
File fileOutput = downloadLink.getFileOutput();
|
||||
downloadLink.setDownloadLength(length);
|
||||
|
||||
download(downloadLink, urlConnection);
|
||||
return download(downloadLink, urlConnection);
|
||||
}
|
||||
catch (IOException e) { logger.severe("URL could not be opened. "+e.toString());}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user