Oboom Deal +

My.JDownloader AutoCaptcha


git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@25223 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
coalado 2014-04-30 14:42:10 +00:00
parent 858049b093
commit 87b2ef7e0b
10 changed files with 348 additions and 24 deletions

View File

@ -90,12 +90,20 @@ public interface CaptchaSettings extends ConfigInterface {
void setCaptchaDialog9kwTimeout(int ms);
@AboutConfig
@DefaultIntValue(0)
@DefaultIntValue(30 * 1000)
@SpinnerValidator(min = 0, max = Integer.MAX_VALUE)
@org.appwork.storage.config.annotations.DescriptionForConfigEntry("Milliseconds after which a Captcha Dialog will appear even if Auto MyJDownloader Service is still running")
int getCaptchaDialogMyJDCESTimeout();
@org.appwork.storage.config.annotations.DescriptionForConfigEntry("Crawler Challenges: Milliseconds after which a Captcha Dialog will appear even if Auto MyJDownloader Service is still running")
int getCaptchaDialogMyJDCESForCrawlerPluginsTimeout();
void setCaptchaDialogMyJDCESTimeout(int ms);
void setCaptchaDialogMyJDCESForCrawlerPluginsTimeout(int ms);
@AboutConfig
@DefaultIntValue(3 * 60 * 1000)
@SpinnerValidator(min = 0, max = Integer.MAX_VALUE)
@org.appwork.storage.config.annotations.DescriptionForConfigEntry("Download Challenges: Milliseconds after which a Captcha Dialog will appear even if Auto MyJDownloader Service is still running")
int getCaptchaDialogMyJDCESForHostPluginsTimeout();
void setCaptchaDialogMyJDCESForHostPluginsTimeout(int ms);
@AboutConfig
@DefaultIntValue(300000)

View File

@ -66,6 +66,7 @@ import jd.gui.swing.jdgui.components.StatusBarImpl;
import jd.gui.swing.jdgui.components.toolbar.MainToolBar;
import jd.gui.swing.jdgui.interfaces.View;
import jd.gui.swing.jdgui.menu.JDMenuBar;
import jd.gui.swing.jdgui.oboom.OboomDialog;
import jd.gui.swing.jdgui.views.settings.ConfigurationView;
import jd.gui.swing.jdgui.views.settings.sidebar.AddonConfig;
import jd.nutils.Screen;
@ -507,6 +508,33 @@ public class JDGui implements UpdaterListener, OwnerFinder {
this.linkgrabberView = new LinkGrabberView();
this.mainTabbedPane.addTab(downloadView);
this.mainTabbedPane.addTab(this.linkgrabberView);
if (MainTabbedPane.SPECIAL_DEALS_ENABLED && CFG_GUI.CFG.isSpecialDealOboomDialogVisibleOnStartup()) {
SecondLevelLaunch.GUI_COMPLETE.executeWhenReached(new Runnable() {
@Override
public void run() {
new Thread() {
@Override
public void run() {
try {
Thread.sleep(20000);
OboomDialog d = new OboomDialog();
UIOManager.I().show(null, d);
CFG_GUI.CFG.setSpecialDealOboomDialogVisibleOnStartup(false);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
});
}
this.mainTabbedPane.addTab(this.linkgrabberView);
SecondLevelLaunch.GUI_COMPLETE.executeWhenReached(new Runnable() {
@Override
public void run() {

View File

@ -44,11 +44,13 @@ import javax.swing.event.ChangeListener;
import jd.gui.swing.jdgui.interfaces.SwitchPanelEvent;
import jd.gui.swing.jdgui.interfaces.View;
import jd.gui.swing.jdgui.maintab.ClosableTabHeader;
import jd.gui.swing.jdgui.oboom.OboomDialog;
import jd.gui.swing.jdgui.views.ClosableView;
import org.appwork.storage.config.ValidationException;
import org.appwork.storage.config.events.GenericConfigEventListener;
import org.appwork.storage.config.handler.KeyHandler;
import org.appwork.uio.UIOManager;
import org.appwork.utils.Application;
import org.appwork.utils.StringUtils;
import org.appwork.utils.swing.EDTRunner;
@ -66,7 +68,7 @@ public class MainTabbedPane extends JTabbedPane implements MouseMotionListener,
private static MainTabbedPane INSTANCE;
protected View latestSelection;
private static final boolean SPECIAL_DEALS_ENABLED = !Application.isJared(null);
public static final boolean SPECIAL_DEALS_ENABLED = !Application.isJared(null);
private AbstractIcon specialDealIcon;
@ -347,8 +349,10 @@ public class MainTabbedPane extends JTabbedPane implements MouseMotionListener,
if (specialDealMouseOver && CFG_GUI.CFG.isSpecialDealsEnabled() && SPECIAL_DEALS_ENABLED) {
new Thread("OSR") {
public void run() {
// OSRSurvey.getInstance().start();
OboomDialog d = new OboomDialog();
UIOManager.I().show(null, d);
}
}.start();

View File

@ -0,0 +1,225 @@
package jd.gui.swing.jdgui.oboom;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dialog.ModalityType;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import jd.controlling.AccountController;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.plugins.Account;
import net.miginfocom.swing.MigLayout;
import org.appwork.storage.JSonStorage;
import org.appwork.swing.MigPanel;
import org.appwork.swing.components.ExtTextField;
import org.appwork.uio.UIOManager;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.swing.SwingUtils;
import org.appwork.utils.swing.dialog.AbstractDialog;
import org.appwork.utils.swing.dialog.DefaultButtonPanel;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;
import org.appwork.utils.swing.dialog.DialogClosedException;
import org.appwork.utils.swing.dialog.ProgressDialog;
import org.appwork.utils.swing.dialog.ProgressDialog.ProgressGetter;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.images.AbstractIcon;
public class OboomDialog extends AbstractDialog<Integer> {
private ExtTextField input;
public OboomDialog() {
super(0, _GUI._.specialdeals_oboom_dialog_title(), new AbstractIcon("logo_oboom_small", 64), _GUI._.lit_continue(), _GUI._.lit_close());
}
@Override
public ModalityType getModalityType() {
return ModalityType.MODELESS;
}
@Override
protected Integer createReturnValue() {
return this.getReturnmask();
}
@Override
protected void setReturnmask(boolean b) {
super.setReturnmask(b);
if (b) {
final ProgressDialog prog = new ProgressDialog(new ProgressGetter() {
@Override
public void run() throws Exception {
requestAccount(input.getText());
}
@Override
public String getString() {
return null;
}
@Override
public int getProgress() {
return -1;
}
@Override
public String getLabelString() {
return null;
}
}, UIOManager.BUTTONS_HIDE_OK, _GUI._.specialdeals_oboom_dialog_request_title(), _GUI._.specialdeals_oboom_dialog_request_msg(), new AbstractIcon("logo_oboom_small", 32), null, null) {
@Override
public ModalityType getModalityType() {
return ModalityType.MODELESS;
}
};
new Thread() {
public void run() {
UIOManager.I().show(null, prog);
};
}.start();
}
}
protected void requestAccount(String email) {
try {
Browser br = new Browser();
br.getPage("https://www.oboom.com/event/jdownloader?email=" + Encoding.urlEncode(email) + "&http_errors=0");
if (br.containsHTML("403,\"E_PREMIUM\"")) {
Dialog.getInstance().showMessageDialog(0, _GUI._.lit_error_occured(), _GUI._.specialdeals_oboom_dialog_request_error_e_premium());
retry();
return;
} else if (br.containsHTML("403,\"Forbidden\"")) {
Dialog.getInstance().showMessageDialog(0, _GUI._.lit_error_occured(), _GUI._.specialdeals_oboom_dialog_request_error_forbidden());
retry();
return;
} else if (br.containsHTML("403,\"EMAIL_FORBIDDEN\"")) {
Dialog.getInstance().showMessageDialog(0, _GUI._.lit_error_occured(), _GUI._.specialdeals_oboom_dialog_request_error_email_forbidden());
retry();
return;
} else if (br.containsHTML("403,\"USED\"")) {
Dialog.getInstance().showMessageDialog(0, _GUI._.lit_error_occured(), _GUI._.specialdeals_oboom_dialog_request_error_used());
retry();
return;
} else if (br.containsHTML("200,\"EXISTING\"")) {
} else {
Object[] data = JSonStorage.restoreFromString(br.toString(), Object[].class);
// String[] data = br.getRegex("200,\"OK\",\"(.+?)\",\"(.+)\"").getRow(0);
final Account ac = new Account(data[2].toString(), data[3].toString());
ac.setHoster("oboom.com");
AccountController.getInstance().addAccount(ac);
try {
Dialog.getInstance().showConfirmDialog(UIOManager.BUTTONS_HIDE_CANCEL, _GUI._.specialdeals_oboom_dialog_request_success_title(), _GUI._.specialdeals_oboom_dialog_request_success_msg(), new AbstractIcon("logo_oboom", 50), _GUI._.lit_close(), null);
} catch (DialogClosedException e) {
e.printStackTrace();
} catch (DialogCanceledException e) {
e.printStackTrace();
}
}
System.out.println(1);
} catch (IOException e) {
e.printStackTrace();
}
}
private void retry() {
new Thread("OSR") {
public void run() {
OboomDialog d = new OboomDialog();
UIOManager.I().show(null, d);
}
}.start();
}
private JComponent header(String lbl) {
JLabel ret = SwingUtils.toBold(new JLabel(lbl));
ret.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, ret.getForeground()));
return ret;
}
protected int getPreferredWidth() {
return 650;
}
protected MigPanel createBottomPanel() {
// TODO Auto-generated method stub
MigPanel ret = new MigPanel("ins 0", "[]20[grow,fill][]", "[]");
return ret;
}
@Override
protected DefaultButtonPanel createBottomButtonPanel() {
DefaultButtonPanel ret = new DefaultButtonPanel("ins 0", "[]", "0[grow,fill]0");
JLabel tocs = new JLabel("<html><a href=\"https://www.oboom.com/#agb\">" + _GUI._.specialdeals_oboom_tocs() + "</a></html>");
tocs.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
tocs.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
CrossSystem.openURL("https://www.oboom.com/#agb");
}
});
ret.add(tocs, "");
return ret;
}
@Override
public JComponent layoutDialogContent() {
JPanel content = new JPanel(new MigLayout("ins 0, wrap 1", "[]"));
content.add(header(_GUI._.specialdeals_oboom_dialog_conditions()), "gapleft 15,pushx,growx");
content.add(new JLabel("<html>" + _GUI._.specialdeals_oboom_dialog_msg() + "</html>"), "gapleft 32,wmin 10");
content.add(header(_GUI._.specialdeals_oboom_dialog_email()), "gapleft 15,spanx,pushx,growx,gaptop 15");
input = new ExtTextField();
input.setHelpText(_GUI._.specialdeals_oboom_dialog_email_help());
content.add(input, "gapleft 32,pushx,growx");
getDialog().addWindowFocusListener(new WindowFocusListener() {
@Override
public void windowLostFocus(final WindowEvent windowevent) {
// TODO Auto-generated method stub
}
@Override
public void windowGainedFocus(final WindowEvent windowevent) {
final Component focusOwner = getDialog().getFocusOwner();
if (focusOwner != null) {
// dialog component has already focus...
return;
}
/* we only want to force focus on first window open */
getDialog().removeWindowFocusListener(this);
input.requestFocus();
}
});
return content;
}
}

View File

@ -57,7 +57,12 @@ public class CESSolverJob<T> {
}
public CESBubble showBubble(CESChallengeSolver<T> cbSolver) throws InterruptedException {
bubble = CESBubbleSupport.getInstance().show(cbSolver, this, CFG_CAPTCHA.CFG.getCaptchaExchangeChanceToSkipBubbleTimeout());
return showBubble(cbSolver, CFG_CAPTCHA.CFG.getCaptchaExchangeChanceToSkipBubbleTimeout());
}
public CESBubble showBubble(CESChallengeSolver<T> cbSolver, int timeout) throws InterruptedException {
bubble = CESBubbleSupport.getInstance().show(cbSolver, this, timeout);
return bubble;
}

View File

@ -5,6 +5,7 @@ import javax.swing.Icon;
import jd.controlling.captcha.BasicCaptchaDialogHandler;
import jd.controlling.captcha.CaptchaSettings;
import jd.controlling.captcha.SkipException;
import jd.plugins.PluginForDecrypt;
import org.appwork.storage.config.JsonConfig;
import org.appwork.utils.StringUtils;
@ -83,19 +84,19 @@ public class DialogBasicCaptchaSolver extends AbstractDialogSolver<String> {
configMyJD = JsonConfig.create(MyJDownloaderSettings.class);
}
/**
* returns true if the dialog solver waits for invisible solvers like captcha exchange services
*
* @return
*/
public boolean hasToWaitForInvisibleSolvers() {
if (configDBC.isEnabled() && config.getCaptchaDialogDBCTimeout() > 0) return true;
if (config9kw.isEnabled() && config.getCaptchaDialog9kwTimeout() > 0) return true;
if (configMyJD.isCESEnabled() && config.getCaptchaDialogMyJDCESTimeout() > 0) return true;
if (configcbh.isEnabled() && config.getCaptchaDialogCaptchaBrotherhoodTimeout() > 0) return true;
if (configresolutor.isEnabled() && config.getCaptchaDialogResolutorCaptchaTimeout() > 0) return true;
return false;
}
// /**
// * returns true if the dialog solver waits for invisible solvers like captcha exchange services
// *
// * @return
// */
// public boolean hasToWaitForInvisibleSolvers() {
// if (configDBC.isEnabled() && config.getCaptchaDialogDBCTimeout() > 0) return true;
// if (config9kw.isEnabled() && config.getCaptchaDialog9kwTimeout() > 0) return true;
// if (configMyJD.isCESEnabled() && config.getCaptchaDialogMyJDCESTimeout() > 0) return true;
// if (configcbh.isEnabled() && config.getCaptchaDialogCaptchaBrotherhoodTimeout() > 0) return true;
// if (configresolutor.isEnabled() && config.getCaptchaDialogResolutorCaptchaTimeout() > 0) return true;
// return false;
// }
@Override
public void solve(final SolverJob<String> job) throws InterruptedException, SkipException {
@ -109,7 +110,12 @@ public class DialogBasicCaptchaSolver extends AbstractDialogSolver<String> {
job.waitFor(config.getCaptchaDialogJAntiCaptchaTimeout(), JACSolver.getInstance());
if (configDBC.isEnabled() && config.getCaptchaDialogDBCTimeout() > 0) job.waitFor(config.getCaptchaDialogDBCTimeout(), DeathByCaptchaSolver.getInstance());
if (config9kw.isEnabled() && config.getCaptchaDialog9kwTimeout() > 0) job.waitFor(config.getCaptchaDialog9kwTimeout(), Captcha9kwSolver.getInstance());
if (configMyJD.isCESEnabled() && config.getCaptchaDialogMyJDCESTimeout() > 0) job.waitFor(config.getCaptchaDialogMyJDCESTimeout(), CaptchaMyJDSolver.getInstance());
if (Challenge.getPlugin(job.getChallenge()) instanceof PluginForDecrypt) {
if (configMyJD.isCESEnabled() && config.getCaptchaDialogMyJDCESForCrawlerPluginsTimeout() > 0) job.waitFor(config.getCaptchaDialogMyJDCESForCrawlerPluginsTimeout(), CaptchaMyJDSolver.getInstance());
} else {
if (configMyJD.isCESEnabled() && config.getCaptchaDialogMyJDCESForHostPluginsTimeout() > 0) job.waitFor(config.getCaptchaDialogMyJDCESForHostPluginsTimeout(), CaptchaMyJDSolver.getInstance());
}
if (configcbh.isEnabled() && config.getCaptchaDialogCaptchaBrotherhoodTimeout() > 0) job.waitFor(config.getCaptchaDialogCaptchaBrotherhoodTimeout(), CBSolver.getInstance());
if (configresolutor.isEnabled() && config.getCaptchaDialogResolutorCaptchaTimeout() > 0) job.waitFor(config.getCaptchaDialogResolutorCaptchaTimeout(), CaptchaResolutorCaptchaSolver.getInstance());

View File

@ -7,7 +7,6 @@ import java.util.LinkedList;
import javax.swing.Icon;
import jd.SecondLevelLaunch;
import jd.controlling.captcha.CaptchaSettings;
import jd.gui.swing.jdgui.components.premiumbar.ServiceCollection;
import jd.gui.swing.jdgui.components.premiumbar.ServicePanel;
@ -93,7 +92,7 @@ public class CaptchaMyJDSolver extends CESChallengeSolver<String> implements Cha
BasicCaptchaChallenge challenge = (BasicCaptchaChallenge) job.getChallenge();
job.getLogger().info(this.getName() + ": Start. GetTypeID: " + challenge.getTypeID() + " - Plugin: " + challenge.getPlugin());
int timeoutthing = (JsonConfig.create(CaptchaSettings.class).getCaptchaDialogMyJDCESTimeout() / 1000);
// int timeoutthing = (JsonConfig.create(CaptchaSettings.class).getCaptchaDialogMyJDCESTimeout() / 1000);
BlackOrWhitelist type = config.getCESBlackOrWhitelistType();
if (type != null) {
@ -140,6 +139,7 @@ public class CaptchaMyJDSolver extends CESChallengeSolver<String> implements Cha
byte[] data = IO.readFile(challenge.getImageFile());
// Browser br = new Browser();
// br.setAllowedResponseCodes(new int[] { 500 });
job.showBubble(this, 0);
String ret = "";
job.setStatus(SolverStatus.UPLOADING);
MyCaptchaChallenge ch = new MyCaptchaChallenge();

View File

@ -4530,7 +4530,49 @@ public interface GuiTranslation extends TranslateInterface {
@Default(lngs = { "en" }, values = { "Always allow Log Upload without asking." })
String UploadSessionLogDialog_getDontShowAgainLabelText_always();
@Default(lngs = { "en" }, values = { "Free Oboom.com Premium" })
@Default(lngs = { "en" }, values = { "Free OBOOM.com Pro Account" })
String special_deal_oboom();
@Default(lngs = { "en" }, values = { "Get a free OBOOM.com Pro Account" })
String specialdeals_oboom_dialog_title();
@Default(lngs = { "en" }, values = { "About that Deal!" })
String specialdeals_oboom_dialog_conditions();
@Default(lngs = { "en" }, values = { "We give away absolutly free OBOOM.com Pro Accounts (while supplies last). All accounts are valid for 2 days, so you can download with full premium conditions for 2 days. <br>You receive your access data after entering your eMail-address." })
String specialdeals_oboom_dialog_msg();
@Default(lngs = { "en" }, values = { "Enter your eMail-address" })
String specialdeals_oboom_dialog_email();
@Default(lngs = { "en" }, values = { "your eMail-address ..." })
String specialdeals_oboom_dialog_email_help();
@Default(lngs = { "en" }, values = { "OBOOM.com Terms of Service" })
String specialdeals_oboom_tocs();
@Default(lngs = { "en" }, values = { "Requesting your account..." })
String specialdeals_oboom_dialog_request_title();
@Default(lngs = { "en" }, values = { "Please wait..." })
String specialdeals_oboom_dialog_request_msg();
@Default(lngs = { "en" }, values = { "This eMail-address is already used for a valid Pro Account." })
String specialdeals_oboom_dialog_request_error_e_premium();
@Default(lngs = { "en" }, values = { "An unknown Error occured. Please try again later or with a different eMail-address." })
String specialdeals_oboom_dialog_request_error_forbidden();
@Default(lngs = { "en" }, values = { "This eMail-address has been rejected." })
String specialdeals_oboom_dialog_request_error_email_forbidden();
@Default(lngs = { "en" }, values = { "This eMail-address has already been used to get a free Account." })
String specialdeals_oboom_dialog_request_error_used();
@Default(lngs = { "en" }, values = { "Congratulations!" })
String specialdeals_oboom_dialog_request_success_title();
@Default(lngs = { "en" }, values = { "Your new OBOOM.com Pro Account is ready to use. \r\nJust start downloading now!" })
String specialdeals_oboom_dialog_request_success_msg();
}

View File

@ -1046,4 +1046,10 @@ public interface GraphicalUserInterfaceSettings extends ConfigInterface {
void setDateTimeFormatDownloadListFinishedDateColumn(String df);
@AboutConfig
@RequiresRestart("Restart is Required")
@DefaultBooleanValue(true)
boolean isSpecialDealOboomDialogVisibleOnStartup();
void setSpecialDealOboomDialogVisibleOnStartup(boolean b);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB