use of de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException in project janrufmonitor by tbrandt77.
the class Block method doBlock.
private boolean doBlock(IPhonenumber n) {
String dial = n.getTelephoneNumber();
if (!n.getIntAreaCode().equalsIgnoreCase(this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
dial = "00" + n.getIntAreaCode() + dial;
}
if (!dial.startsWith("0"))
dial = "0" + dial;
String text = getI18nManager().getString(getNamespace(), "block", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "block", "label", this.getLanguage()), text)) {
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
fwm.doBlock(dial);
FritzBoxBlockedListManager.invalidate();
} catch (IOException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "failedblock", e));
} catch (FritzBoxLoginException e) {
this.m_logger.warning(e.toString());
} catch (DoBlockException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "failedblock", e));
}
return true;
}
return false;
}
use of de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException in project janrufmonitor by tbrandt77.
the class ClickDialAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Object o = selection.getFirstElement();
if (o instanceof ICall) {
o = ((ICall) o).getCaller();
}
if (o instanceof ICaller) {
o = ((ICaller) o).getPhoneNumber();
}
if (o instanceof ITreeItemCallerData) {
o = ((ITreeItemCallerData) o).getPhone();
}
if (o instanceof IPhonenumber) {
if (((IPhonenumber) o).isClired())
return;
String dial = ((IPhonenumber) o).getTelephoneNumber();
if (!((IPhonenumber) o).getIntAreaCode().equalsIgnoreCase(this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
dial = "00" + ((IPhonenumber) o).getIntAreaCode() + dial;
}
if (!dial.startsWith("0"))
dial = "0" + dial;
Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
String prefixes = getRuntime().getConfigManagerFactory().getConfigManager().getProperty(FritzBoxMonitor.NAMESPACE, "dialprefixes");
if ((prefixes != null && prefixes.length() > 0) || config.getProperty(CFG_CLICKDIAL, "50").equalsIgnoreCase("0")) {
DialerDialog id = new DialerDialog(new Shell(DisplayManager.getDefaultDisplay()), dial);
id.open();
} else {
// added 2010/03/06: check for dial prefix for outgoing calls
if (this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length() > 0) {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Using dial prefix: " + this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX));
dial = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
}
String text = getI18nManager().getString(getNamespace(), "dial", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "success", "label", this.getLanguage()), text)) {
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
fwm.doCall(dial + "#", config.getProperty(CFG_CLICKDIAL, "50"));
try {
final String n = dial;
ModalContext.run(new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.done();
String text = getI18nManager().getString(getNamespace(), "success", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", n);
MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "success", "label", getLanguage()), text);
}
}, false, m_app.getApplication().getStatusLineManager().getProgressMonitor(), m_app.getApplication().getShell().getDisplay());
} catch (InterruptedException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} catch (IOException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddial", e));
} catch (FritzBoxLoginException e) {
this.m_logger.warning(e.toString());
} catch (DoCallException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddial", e));
}
this.m_app.updateViews(false);
}
}
}
}
}
}
use of de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException 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.fritzbox.firmware.exception.FritzBoxLoginException in project janrufmonitor by tbrandt77.
the class Delete method run.
public void run() {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "delete", "label", this.getLanguage()), this.getI18nManager().getString(this.getNamespace(), "delete", "description", this.getLanguage()))) {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "deleteprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "loginprogress", "label", getLanguage()));
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "deleteprogress", "label", getLanguage()));
fwm.deleteCallList();
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "finished", "label", getLanguage()));
} catch (IOException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddelete", e));
} catch (FritzBoxLoginException e) {
m_logger.warning(e.toString());
} catch (DeleteCallListException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddelete", e));
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
m_app.updateViews(true);
}
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
return;
}
Aggregations