use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException in project janrufmonitor by tbrandt77.
the class AbstractFritzBoxFirmware method doCall.
public void doCall(String number, String extension) throws DoCallException, IOException {
try {
login();
number = number.replaceAll("\\+", "00");
String portStr = "";
if (extension.equals("Fon 1")) {
portStr = "1";
} else if (extension.equals("Fon 2")) {
portStr = "2";
} else if (extension.equals("Fon 3")) {
portStr = "3";
} else if (extension.equals("analog_telephones_all")) {
portStr = "9";
} else if (extension.equals("ISDN Alle")) {
portStr = "50";
} else if (extension.equals("ISDN 1")) {
portStr = "51";
} else if (extension.equals("ISDN 2")) {
portStr = "52";
} else if (extension.equals("ISDN 3")) {
portStr = "53";
} else if (extension.equals("ISDN 4")) {
portStr = "54";
} else if (extension.equals("ISDN 5")) {
portStr = "55";
} else if (extension.equals("ISDN 6")) {
portStr = "56";
} else if (extension.equals("ISDN 7")) {
portStr = "57";
} else if (extension.equals("ISDN 8")) {
portStr = "58";
} else if (extension.equals("ISDN 9")) {
portStr = "59";
} else {
portStr = extension;
}
String postdata = getCallPOSTData().replaceAll("\\$PASSWORT", URLEncoder.encode(getCallURLAuthenticator().getAuthenticationToken(), "ISO-8859-1"));
postdata = postdata.replaceAll("\\$NUMMER", number);
postdata = postdata.replaceAll("\\$NEBENSTELLE", portStr);
postdata = (this.m_language.equalsIgnoreCase("en") ? getAccessMethodPOSTData()[1] : getAccessMethodPOSTData()[0]) + postdata;
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + getBaseURL();
this.executeURL(urlstr, postdata, false);
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Call with FritzBox succuessfully triggered.");
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (FritzBoxLoginException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new DoCallException("Dialing of number " + number + " failed: " + e.getMessage());
}
}
use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException in project janrufmonitor by tbrandt77.
the class FritzOSFirmware 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.");
StringBuffer data = new StringBuffer();
if (number.endsWith("#"))
number = number.substring(0, number.length() - 1);
// 2013/02/05: removed dial via wahlhilfe only
// String urlstr = getProtocol() + this.m_address +":" + this.m_port + "/fon_num/fonbook_list.lua?sid="+this.m_sid+"&dial="+number+"&xhr=1";
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + "/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 numer on FritzBox: " + e.getMessage());
}
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Data after call initialization: " + data.toString());
}
use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException in project janrufmonitor by tbrandt77.
the class TR064FritzBoxFirmware 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 u = "http://" + this.m_server + ":" + this.m_port;
if (this.m_firmware != null && this.m_firmware.getMajor() >= 6 && this.m_firmware.getMinor() >= 30) {
try {
String body = "sid=" + FritzBoxTR064Manager.getInstance().getSID(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https")) + "&clicktodial=on&port=" + extension + "&btn_apply=";
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Set up extension for dialing: " + body);
data.append(doHttpCall(u + "/fon_num/dial_foncalls.lua", "POST", body, new String[][] { { "Content-Length", Integer.toString(body.length()) } }));
String dial_u = u + "/fon_num/fonbook_list.lua?sid=" + FritzBoxTR064Manager.getInstance().getSID(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https")) + "&dial=" + StringUtils.urlEncode(number);
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Dial URL: " + dial_u);
data.append(doHttpCall(dial_u, "GET", null, new String[][] {}));
} 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 {
try {
String body = "&sid=" + FritzBoxTR064Manager.getInstance().getSID(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https")) + "&telcfg:settings/UseClickToDial=1&telcfg:settings/DialPort=" + extension + "&telcfg:command/Dial=" + number;
data.append(doHttpCall(u + "/cgi-bin/webcm", "POST", body, new String[][] { { "Content-Length", Integer.toString(body.length()) } }));
} 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());
}
use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException in project janrufmonitor by tbrandt77.
the class FritzBoxDialogPlugin method run.
public void run() {
new SWTExecuter(this.getLabel()) {
protected void execute() {
ICaller o = m_dialog.getCall().getCaller();
String dial = ((ICaller) o).getPhoneNumber().getTelephoneNumber();
if (!((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase(getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
dial = "00" + ((ICaller) o).getPhoneNumber().getIntAreaCode() + dial;
}
if (!dial.startsWith("0"))
dial = "0" + dial;
String text = getI18nManager().getString(getNamespaceDial(), "dial", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespaceDial(), "success", "label", getLanguage()), text)) {
Properties config = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
fwm.doCall(dial, config.getProperty(CFG_CLICKDIAL, "50"));
text = getI18nManager().getString(getNamespaceDial(), "success", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespaceDial(), "success", "label", getLanguage()), text);
} catch (IOException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
} catch (FritzBoxLoginException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
} catch (DoCallException e) {
m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
}
}
}
}.start();
}
use of de.janrufmonitor.fritzbox.firmware.exception.DoCallException in project janrufmonitor by tbrandt77.
the class UnitymediaFirmware 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.");
StringBuffer data = new StringBuffer();
if (number.endsWith("#"))
number = number.substring(0, number.length() - 1);
// 2013/02/05: removed dial via wahlhilfe only
// String urlstr = getProtocol() + this.m_address +":" + this.m_port + "/fon_num/fonbook_list.lua?sid="+this.m_sid+"&dial="+number+"&xhr=1";
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + "/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 numer on FritzBox: " + e.getMessage());
}
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Data after call initialization: " + data.toString());
}
Aggregations