use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException in project janrufmonitor by tbrandt77.
the class DialerDialog method okPressed.
protected void okPressed() {
if (dialBox != null) {
String dial = PhonenumberAnalyzer.getInstance(getRuntime()).toCallable(dialBox.getText());
if (dials != null) {
int maxnums = Integer.parseInt(this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(FritzBoxMonitor.NAMESPACE, FritzBoxConst.CFG_LAST_DIALED_NUMBERS));
if (dials.size() >= maxnums) {
dials = dials.subList(0, maxnums - 1);
}
dials.add(0, dial);
this.setLast10DialedNumbers(dials);
}
// 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;
}
if (dial.trim().length() > 0) {
if (dialPrefix != null) {
if (dialPrefix.getText().trim().length() > 0) {
dial = dialPrefix.getText().trim() + dial;
}
}
Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
String clickdial = config.getProperty(CFG_CLICKDIAL, "50");
if (clickDial != null) {
if (clickDial.getText().trim().length() > 0) {
if (clickDial.getText().equalsIgnoreCase("FON 1"))
clickdial = "1";
if (clickDial.getText().equalsIgnoreCase("FON 2"))
clickdial = "2";
if (clickDial.getText().equalsIgnoreCase("FON 3"))
clickdial = "3";
if (clickDial.getText().equalsIgnoreCase("Alle ISDN Ger\u00E4te"))
clickdial = "50";
if (clickDial.getText().equalsIgnoreCase("ISDN 1"))
clickdial = "51";
if (clickDial.getText().equalsIgnoreCase("ISDN 2"))
clickdial = "52";
if (clickDial.getText().equalsIgnoreCase("ISDN 3"))
clickdial = "53";
if (clickDial.getText().equalsIgnoreCase("ISDN 4"))
clickdial = "54";
if (clickDial.getText().equalsIgnoreCase("ISDN 5"))
clickdial = "55";
if (clickDial.getText().equalsIgnoreCase("ISDN 6"))
clickdial = "56";
if (clickDial.getText().equalsIgnoreCase("ISDN 7"))
clickdial = "57";
if (clickDial.getText().equalsIgnoreCase("ISDN 8"))
clickdial = "58";
if (clickDial.getText().equalsIgnoreCase("ISDN 9"))
clickdial = "59";
if (clickDial.getText().equalsIgnoreCase("DECT 610"))
clickdial = "60";
if (clickDial.getText().equalsIgnoreCase("DECT 611"))
clickdial = "61";
if (clickDial.getText().equalsIgnoreCase("DECT 612"))
clickdial = "62";
if (clickDial.getText().equalsIgnoreCase("DECT 613"))
clickdial = "63";
if (clickDial.getText().equalsIgnoreCase("DECT 614"))
clickdial = "64";
if (clickDial.getText().equalsIgnoreCase("DECT 615"))
clickdial = "65";
this.getRuntime().getConfigManagerFactory().getConfigManager().setProperty(FritzBoxMonitor.NAMESPACE, "lastext", clickDial.getText());
}
}
String text = getI18nManager().getString("ui.jface.application.fritzbox.action.ClickDialAction", "dial", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
fwm.doCall(dial + "#", clickdial);
text = getI18nManager().getString("ui.jface.application.fritzbox.action.ClickDialAction", "success", "description", getLanguage());
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString("monitor.FritzBoxMonitor", "title", "label", getLanguage()), new Exception(StringUtils.replaceString(text, "{%1}", dial))), "Tray");
} catch (IOException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, "ui.jface.application.fritzbox.action.ClickDialAction", "faileddial", e));
} catch (FritzBoxLoginException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, "ui.jface.application.fritzbox.action.ClickDialAction", "faileddial", e));
} catch (DoCallException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, "ui.jface.application.fritzbox.action.ClickDialAction", "faileddial", e));
}
}
}
super.okPressed();
}
use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException 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.DoCallException in project janrufmonitor by tbrandt77.
the class FritzOS559Firmware method doCall.
public void doCall(String number, String extension) throws DoCallException, IOException {
if (!this.isInitialized())
throw new DoCallException("Could not dial number on FritzBox: FritzBox firmware not initialized.");
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("dial number: " + number + ", extension: " + extension);
StringBuffer data = new StringBuffer();
if (number.endsWith("#"))
number = number.substring(0, number.length() - 1);
String urlstr = getProtocol() + this.m_address + ":" + this.m_port;
if (this.m_firmware != null && this.m_firmware.getMajor() >= 6 && this.m_firmware.getMinor() >= 30) {
String setupporturl = urlstr + "/fon_num/dial_foncalls.lua";
String setupportpost = "sid=" + this.m_sid + "&clicktodial=on&port=" + extension + "&btn_apply=";
String dialurl = urlstr + "/fon_num/fonbook_list.lua?sid=" + this.m_sid + "&dial=" + StringUtils.urlEncode(number);
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("dial URL: " + dialurl);
try {
data.append(this.executeURL(setupporturl, setupportpost, true).trim());
data.append(this.executeURL(dialurl, null, true).trim());
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new DoCallException("Could not dial numer on FritzBox: " + e.getMessage());
}
} else {
urlstr += "/cgi-bin/webcm";
try {
data.append(this.executeURL(urlstr, "&sid=" + this.m_sid + "&telcfg:settings/UseClickToDial=1&telcfg:settings/DialPort=" + extension + "&telcfg:command/Dial=" + number, true).trim());
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new DoCallException("Could not dial number on FritzBox: " + e.getMessage());
}
}
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Data after call initialization: " + data.toString());
}
Aggregations