use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class GenericWebAction 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 instanceof ICaller) {
Properties configuration = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(this.getNamespace());
if (configuration != null) {
String url = configuration.getProperty("url");
if (url != null && url.trim().length() > 0) {
this.m_logger.info("Found valid web url to execute: " + url);
Formatter f = Formatter.getInstance(this.getRuntime());
url = f.parse(url, o);
this.m_logger.info("Parsed web url to execute: " + url);
Program.launch(url);
}
} else {
this.m_logger.warning("Found invalid configuration for namespace: " + this.getNamespace());
}
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class Accept method handleWithException.
public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
try {
String phone = req.getParameter(Accept.PARAMETER_NUMBER);
String msn = req.getParameter(Accept.PARAMETER_MSN);
if (phone == null || phone.length() == 0)
phone = IJAMConst.CLIRED_CALL;
ICall call = ClientCallMap.getInstance().getCall(phone + "/" + msn);
this.m_logger.info("Key for ClientCallMap: " + phone + "/" + msn);
if (call != null) {
long end = new Date().getTime();
long start = this.getStartTime(call);
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_ENDRING, Long.toString(end)));
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_RINGDURATION, Long.toString((end - start) / 1000)));
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_ACCEPTED));
if (ClientCallMap.getInstance().removeCall(phone + "/" + msn))
this.m_logger.info("Successfully found call: " + phone + "/" + msn);
Thread sender = new Thread(new HandlerThread(call, this));
sender.start();
resp.getContentStreamForWrite().close();
}
} catch (Exception e) {
throw new HandlerException(e.getMessage(), 500);
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class ClientClickDialAction 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 (PhonenumberAnalyzer.getInstance(getRuntime()).isInternal((IPhonenumber) o)) {
dial = ((IPhonenumber) o).getCallNumber();
} else {
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;
}
ClientDialerDialog id = new ClientDialerDialog(new Shell(DisplayManager.getDefaultDisplay()), dial);
id.open();
this.m_app.updateViews(false);
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class IncomingCall method handleWithException.
public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
IPhonenumber pn = null;
try {
String phone = req.getParameter(IncomingCall.PARAMETER_NUMBER);
if (phone == null || phone.length() == 0)
pn = PIMRuntime.getInstance().getCallerFactory().createPhonenumber(true);
else
pn = PIMRuntime.getInstance().getCallerFactory().createPhonenumber(phone);
IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
ICaller c = PIMRuntime.getInstance().getCallerFactory().createCaller(name, pn);
ICip cip = PIMRuntime.getInstance().getCallFactory().createCip(req.getParameter(IncomingCall.PARAMETER_CIP), "");
IMsn msn = PIMRuntime.getInstance().getCallFactory().createMsn(req.getParameter(IncomingCall.PARAMETER_MSN), "");
Date date = new Date(Long.parseLong(req.getParameter(IncomingCall.PARAMETER_DATE)));
ICall call = PIMRuntime.getInstance().getCallFactory().createCall(c, msn, cip, date);
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STARTRING, Long.toString(new Date().getTime())));
ClientCallMap.getInstance().setCall((pn.isClired() ? IJAMConst.CLIRED_CALL : pn.getTelephoneNumber()) + "/" + msn.getMSN(), call);
Thread sender = new Thread(new HandlerThread(call, this));
sender.start();
resp.getContentStreamForWrite().close();
} catch (Exception e) {
throw new HandlerException(e.getMessage(), 500);
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class Clear method handleWithException.
public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
try {
String phone = req.getParameter(Clear.PARAMETER_NUMBER);
String msn = req.getParameter(Clear.PARAMETER_MSN);
if (phone == null || phone.length() == 0)
phone = IJAMConst.CLIRED_CALL;
ICall call = ClientCallMap.getInstance().getCall(phone + "/" + msn);
this.m_logger.info("Key for ClientCallMap: " + phone + "/" + msn);
if (call != null) {
long end = new Date().getTime();
long start = this.getStartTime(call);
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_ENDRING, Long.toString(end)));
call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_RINGDURATION, Long.toString((end - start) / 1000)));
if (ClientCallMap.getInstance().removeCall(phone + "/" + msn))
this.m_logger.info("Successfully found call: " + phone + "/" + msn);
Thread sender = new Thread(new HandlerThread(call, this));
sender.start();
resp.getContentStreamForWrite().close();
}
} catch (Exception e) {
throw new HandlerException(e.getMessage(), 500);
}
}
Aggregations