Search in sources :

Example 1 with ICall

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());
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) Formatter(de.janrufmonitor.util.formatter.Formatter) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Properties(java.util.Properties)

Example 2 with ICall

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);
    }
}
Also used : HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) ICall(de.janrufmonitor.framework.ICall) Date(java.util.Date) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException)

Example 3 with ICall

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);
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) ICall(de.janrufmonitor.framework.ICall) ClientDialerDialog(de.janrufmonitor.ui.jface.application.dialer.ClientDialerDialog) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 4 with ICall

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);
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) ICip(de.janrufmonitor.framework.ICip) ICall(de.janrufmonitor.framework.ICall) IName(de.janrufmonitor.framework.IName) IMsn(de.janrufmonitor.framework.IMsn) Date(java.util.Date) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 5 with ICall

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);
    }
}
Also used : HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) ICall(de.janrufmonitor.framework.ICall) Date(java.util.Date) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException)

Aggregations

ICall (de.janrufmonitor.framework.ICall)89 ICaller (de.janrufmonitor.framework.ICaller)41 List (java.util.List)23 Viewer (org.eclipse.jface.viewers.Viewer)20 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)19 ArrayList (java.util.ArrayList)19 IAttribute (de.janrufmonitor.framework.IAttribute)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 ICallList (de.janrufmonitor.framework.ICallList)17 IOException (java.io.IOException)14 Properties (java.util.Properties)14 Date (java.util.Date)13 Iterator (java.util.Iterator)13 Shell (org.eclipse.swt.widgets.Shell)13 File (java.io.File)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)11 ICip (de.janrufmonitor.framework.ICip)10 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)10