use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.
the class ClientDialerDialog method okPressed.
protected void okPressed() {
if (dialBox != null) {
String dial = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toCallable(dialBox.getText());
// 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) {
String text = getI18nManager().getString("ui.jface.application.dialer.ClientDialerCommand", "success", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
String text2 = this.getI18nManager().getString("ui.jface.application.dialer.ClientDialerCommand", "success", "label", this.getLanguage());
text2 = StringUtils.replaceString(text2, "{%1}", line.getText());
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), text2, text)) {
String selectedTapi = line.getText();
ClientHandle th = (ClientHandle) handlemap.get(selectedTapi);
if (th != null && th.getLine().length() > 0) {
// save the handle for next time selection
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(NAMESPACE, "lineselection", selectedTapi);
getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
if (m_logger.isLoggable(Level.INFO)) {
m_logger.info("Selected Client handle: " + th.toString());
}
try {
IRequester r = this.getRequester(new Dial(dial, URLEncoder.encode(th.getLine(), "UTF-8")));
IHttpResponse resp = r.request();
if (resp.getCode() != 200) {
m_logger.severe("Invalid client call to server. Error code " + resp.getCode());
}
} catch (UnsupportedEncodingException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} else {
m_logger.warning("Invalid Client line for outgoing call selected.");
}
}
}
}
super.okPressed();
}
Aggregations