Search in sources :

Example 6 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class HttpCallerManager method addCallerManagerAttribute.

private void addCallerManagerAttribute(ICallerList l) {
    // add caller manager attribute to callers
    for (int i = 0; i < l.size(); i++) {
        ICaller c = (ICaller) l.get(i);
        if (c != null) {
            IAttribute cm = this.getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, this.getID());
            c.setAttribute(cm);
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) IAttribute(de.janrufmonitor.framework.IAttribute)

Example 7 with ICaller

use of de.janrufmonitor.framework.ICaller 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 8 with ICaller

use of de.janrufmonitor.framework.ICaller 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 9 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class EditorController method deleteElements.

public synchronized void deleteElements(Object list) {
    if (list != null && list instanceof ICallerList) {
        Map cms = new HashMap();
        ICallerList tmplist = null;
        ICaller c = null;
        for (int i = 0; i < ((ICallerList) list).size(); i++) {
            c = ((ICallerList) list).get(i);
            IAttribute att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
            String cname = (att == null ? "all" : att.getValue());
            if (cms.containsKey(cname)) {
                tmplist = (ICallerList) cms.get(cname);
                tmplist.add(c);
            } else {
                tmplist = this.getRuntime().getCallerFactory().createCallerList(1);
                tmplist.add(c);
                cms.put(cname, tmplist);
            }
        }
        List managers = this.getActiveCallerManagers();
        ICallerManager mgr = null;
        for (int i = 0; i < managers.size(); i++) {
            mgr = this.getRuntime().getCallerManagerFactory().getCallerManager((String) managers.get(i));
            if (mgr != null) {
                if (mgr.isSupported(IWriteCallerRepository.class)) {
                    tmplist = (ICallerList) cms.get("all");
                    if (tmplist != null) {
                        this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
                        ((IWriteCallerRepository) mgr).removeCaller(tmplist);
                    }
                    tmplist = (ICallerList) cms.get(mgr.getManagerID());
                    if (tmplist != null) {
                        this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
                        ((IWriteCallerRepository) mgr).removeCaller(tmplist);
                    }
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) HashMap(java.util.HashMap) IWriteCallerRepository(de.janrufmonitor.repository.types.IWriteCallerRepository) IAttribute(de.janrufmonitor.framework.IAttribute) ArrayList(java.util.ArrayList) List(java.util.List) ICallerList(de.janrufmonitor.framework.ICallerList) HashMap(java.util.HashMap) Map(java.util.Map) ICallerManager(de.janrufmonitor.repository.ICallerManager)

Example 10 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class DeleteAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof TreeViewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator i = selection.iterator();
            ICallerList list = getRuntime().getCallerFactory().createCallerList();
            Object o = null;
            while (i.hasNext()) {
                o = i.next();
                if (o instanceof ICaller) {
                    list.add((ICaller) o);
                }
            }
            if (list.size() > 0) {
                if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "delete", "label", this.getLanguage()), this.getI18nManager().getString(this.getNamespace(), "delete", "description", this.getLanguage()))) {
                    this.m_app.getController().deleteElements(list);
                    this.m_app.getApplication().initializeController();
                    this.m_app.updateViews(true);
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) ICallerList(de.janrufmonitor.framework.ICallerList) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ICaller (de.janrufmonitor.framework.ICaller)144 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)62 ICallerList (de.janrufmonitor.framework.ICallerList)49 List (java.util.List)46 IAttribute (de.janrufmonitor.framework.IAttribute)42 ICall (de.janrufmonitor.framework.ICall)41 ArrayList (java.util.ArrayList)40 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)32 SQLException (java.sql.SQLException)26 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)25 IOException (java.io.IOException)25 Viewer (org.eclipse.jface.viewers.Viewer)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 File (java.io.File)20 Date (java.util.Date)17 Iterator (java.util.Iterator)17 Shell (org.eclipse.swt.widgets.Shell)17 IMsn (de.janrufmonitor.framework.IMsn)16 Properties (java.util.Properties)15 ICip (de.janrufmonitor.framework.ICip)14