use of de.janrufmonitor.framework.command.ICommand in project janrufmonitor by tbrandt77.
the class FirmwareManager method promptPassword.
private void promptPassword() throws FritzBoxLoginException {
boolean dnl = false;
// check for password
// password is mandatory
String pw = this.getFritzBoxPassword();
if (pw.trim().length() == 0) {
int i = Integer.parseInt(System.getProperty("jam.fritzbox.session.counter", "0"));
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
dnl = Boolean.parseBoolean(System.getProperty("jam.fritzbox.session.donotlogin", "false"));
boolean isPWDialogRunning = Boolean.parseBoolean(System.getProperty("jam.fritzbox.session.ispwdialogvisible", "false"));
pw = this.getFritzBoxPassword();
if (!isPWDialogRunning && pw.trim().length() == 0 && i < 4 && !dnl) {
final ICommand c = this.getRuntime().getCommandFactory().getCommand("PasswordDialog");
if (c != null && c.isExecutable() && !c.isExecuting())
try {
c.execute();
} catch (Exception e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
i = Integer.parseInt(System.getProperty("jam.fritzbox.session.counter", "0"));
} while (pw.trim().length() == 0 && i < 4 && !dnl);
if (i >= 4 || dnl) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, "fritzbox.firmware.login", "loginfailed", new Exception("No password set for login."), true));
this.m_isLoggingIn = false;
throw new FritzBoxLoginException("No password set for login.");
}
}
}
use of de.janrufmonitor.framework.command.ICommand in project janrufmonitor by tbrandt77.
the class TwitterService method createFieldEditors.
protected void createFieldEditors() {
super.createFieldEditors();
BooleanFieldEditor bfe = new BooleanFieldEditor(this.getConfigNamespace() + SEPARATOR + "incoming", this.m_i18n.getString(this.getNamespace(), "incoming", "label", this.m_language), this.getFieldEditorParent());
addField(bfe);
StringFieldEditor sfe = new StringFieldEditor(getConfigNamespace() + SEPARATOR + "inmessage", this.m_i18n.getString(this.getNamespace(), "inmessage", "label", this.m_language), this.getFieldEditorParent());
sfe.setEmptyStringAllowed(false);
sfe.setTextLimit(160);
addField(sfe);
bfe = new BooleanFieldEditor(this.getConfigNamespace() + SEPARATOR + "outgoing", this.m_i18n.getString(this.getNamespace(), "outgoing", "label", this.m_language), this.getFieldEditorParent());
addField(bfe);
sfe = new StringFieldEditor(getConfigNamespace() + SEPARATOR + "outmessage", this.m_i18n.getString(this.getNamespace(), "outmessage", "label", this.m_language), this.getFieldEditorParent());
sfe.setEmptyStringAllowed(false);
sfe.setTextLimit(160);
addField(sfe);
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty("service.TwitterService", "auth1").length() == 0 || getRuntime().getConfigManagerFactory().getConfigManager().getProperty("service.TwitterService", "auth2").length() == 0) {
Button authenticate = new Button(this.getFieldEditorParent(), SWT.PUSH);
authenticate.setText(this.m_i18n.getString(this.getNamespace(), "auth", "label", this.m_language));
authenticate.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
}
public void widgetSelected(SelectionEvent arg0) {
ICommand c = getRuntime().getCommandFactory().getCommand("TwitterPINCommand");
if (c != null && c.isExecutable()) {
try {
c.execute();
} catch (Exception ex) {
m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
});
} else {
final Label l = new Label(this.getFieldEditorParent(), SWT.NORMAL);
l.setText(this.m_i18n.getString(this.getNamespace(), "isauth", "label", this.m_language));
GridData gd = new GridData();
gd.horizontalSpan = 2;
gd.widthHint = 500;
l.setLayoutData(gd);
Button unauthenticate = new Button(this.getFieldEditorParent(), SWT.PUSH);
unauthenticate.setLayoutData(gd);
unauthenticate.setText(this.m_i18n.getString(this.getNamespace(), "unauth", "label", this.m_language));
unauthenticate.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
}
public void widgetSelected(SelectionEvent arg0) {
getRuntime().getConfigManagerFactory().getConfigManager().setProperty("service.TwitterService", "auth1", "");
getRuntime().getConfigManagerFactory().getConfigManager().setProperty("service.TwitterService", "auth2", "");
getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
l.setText(m_i18n.getString(getNamespace(), "isnotauth", "label", m_language));
}
});
}
}
Aggregations