Search in sources :

Example 11 with ICommand

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.");
        }
    }
}
Also used : FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) Message(de.janrufmonitor.exception.Message) ICommand(de.janrufmonitor.framework.command.ICommand) DeleteCallListException(de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException) GetCallerListException(de.janrufmonitor.fritzbox.firmware.exception.GetCallerListException) GetBlockedListException(de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException) DoCallException(de.janrufmonitor.fritzbox.firmware.exception.DoCallException) GetAddressbooksException(de.janrufmonitor.fritzbox.firmware.exception.GetAddressbooksException) InvalidSessionIDException(de.janrufmonitor.fritzbox.firmware.exception.InvalidSessionIDException) FritzBoxInitializationException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxInitializationException) GetCallListException(de.janrufmonitor.fritzbox.firmware.exception.GetCallListException) GetCallerImageException(de.janrufmonitor.fritzbox.firmware.exception.GetCallerImageException) FritzBoxNotFoundException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxNotFoundException) FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) DoBlockException(de.janrufmonitor.fritzbox.firmware.exception.DoBlockException) IOException(java.io.IOException) SetCallerException(de.janrufmonitor.fritzbox.firmware.exception.SetCallerException) DeleteCallerException(de.janrufmonitor.fritzbox.firmware.exception.DeleteCallerException)

Example 12 with ICommand

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));
            }
        });
    }
}
Also used : StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) Button(org.eclipse.swt.widgets.Button) ICommand(de.janrufmonitor.framework.command.ICommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) BooleanFieldEditor(de.janrufmonitor.ui.jface.configuration.controls.BooleanFieldEditor) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ICommand (de.janrufmonitor.framework.command.ICommand)12 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Message (de.janrufmonitor.exception.Message)3 FritzBoxLoginException (de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException)3 IConsoleCommand (de.janrufmonitor.framework.command.IConsoleCommand)2 DeleteCallListException (de.janrufmonitor.fritzbox.firmware.exception.DeleteCallListException)2 DeleteCallerException (de.janrufmonitor.fritzbox.firmware.exception.DeleteCallerException)2 DoBlockException (de.janrufmonitor.fritzbox.firmware.exception.DoBlockException)2 DoCallException (de.janrufmonitor.fritzbox.firmware.exception.DoCallException)2 FritzBoxInitializationException (de.janrufmonitor.fritzbox.firmware.exception.FritzBoxInitializationException)2 FritzBoxNotFoundException (de.janrufmonitor.fritzbox.firmware.exception.FritzBoxNotFoundException)2 GetAddressbooksException (de.janrufmonitor.fritzbox.firmware.exception.GetAddressbooksException)2 GetBlockedListException (de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException)2 GetCallListException (de.janrufmonitor.fritzbox.firmware.exception.GetCallListException)2 GetCallerImageException (de.janrufmonitor.fritzbox.firmware.exception.GetCallerImageException)2 GetCallerListException (de.janrufmonitor.fritzbox.firmware.exception.GetCallerListException)2 InvalidSessionIDException (de.janrufmonitor.fritzbox.firmware.exception.InvalidSessionIDException)2 SetCallerException (de.janrufmonitor.fritzbox.firmware.exception.SetCallerException)2