Search in sources :

Example 56 with ICall

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

the class ProviderLogo method renderAsImage.

public Image renderAsImage() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICall) {
            this.m_o = ((ICall) this.m_o).getCaller().getPhoneNumber();
        }
        if (this.m_o instanceof ICaller) {
            this.m_o = ((ICaller) this.m_o).getPhoneNumber();
        }
        if (this.m_o instanceof ITreeItemCallerData) {
            this.m_o = ((ITreeItemCallerData) this.m_o).getPhone();
        }
        if (this.m_o instanceof IPhonenumber) {
            if (((IPhonenumber) this.m_o).isClired())
                return null;
            String key = "provider/" + ((IPhonenumber) this.m_o).getIntAreaCode() + "_" + ((IPhonenumber) this.m_o).getAreaCode() + ".jpg";
            File logoFile = new File(PathResolver.getInstance(PIMRuntime.getInstance()).getImageDirectory() + key);
            if (!logoFile.exists() || !logoFile.isFile()) {
                key = "provider/" + ((IPhonenumber) this.m_o).getIntAreaCode() + ".jpg";
                logoFile = new File(PathResolver.getInstance(PIMRuntime.getInstance()).getImageDirectory() + key);
                if (!logoFile.exists() || !logoFile.isFile())
                    return null;
            }
            Image logo = SWTImageManager.getInstance(PIMRuntime.getInstance()).get(key);
            if (logo == null) {
                SWTImageManager.getInstance(PIMRuntime.getInstance()).loadImage(key, 40, 40);
                logo = SWTImageManager.getInstance(PIMRuntime.getInstance()).get(key);
                return logo;
            }
            return logo;
        }
    }
    return null;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) Image(org.eclipse.swt.graphics.Image) File(java.io.File) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 57 with ICall

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

the class NumberType method renderAsText.

public String renderAsText() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICall) {
            this.m_o = ((ICall) this.m_o).getCaller();
        }
        if (this.m_o instanceof ICaller) {
            this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
        }
        if (this.m_o instanceof ITreeItemCallerData) {
            IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
            IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
            if (m.contains(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber())) {
                IAttribute type = m.get(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber());
                if (type != null) {
                    return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
                }
            }
        }
    }
    return "";
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 58 with ICall

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

the class IconBlinker method receivedIdentifiedCall.

public void receivedIdentifiedCall(IEvent event) {
    super.receivedIdentifiedCall(event);
    ICall aCall = (ICall) event.getData();
    if (aCall != null) {
        if (getRuntime().getRuleEngine().validate(this.getID(), aCall.getMSN(), aCall.getCIP(), aCall.getCaller().getPhoneNumber())) {
            this.startBlinker();
        } else {
            this.m_logger.info("No rule assigned to execute this service for call: " + aCall);
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall)

Example 59 with ICall

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

the class Journaling method receivedOtherEventCall.

public void receivedOtherEventCall(IEvent event) {
    if (event.getType() == IEventConst.EVENT_TYPE_CALLACCEPTED || event.getType() == IEventConst.EVENT_TYPE_CALLCLEARED || event.getType() == IEventConst.EVENT_TYPE_MANUALCALLACCEPTED || event.getType() == IEventConst.EVENT_TYPE_CALLREJECTED || event.getType() == IEventConst.EVENT_TYPE_CALLMARKEDSPAM || event.getType() == IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL_ACCEPTED) {
        // checks wether this service is available for the incoming MSN or not.
        ICall updateCall = (ICall) event.getData();
        if (updateCall == null) {
            this.m_logger.warning("Call reference is null.");
            return;
        }
        if (this.getRuntime().getRuleEngine().validate(this.ID, updateCall.getMSN(), updateCall.getCIP(), updateCall.getCaller().getPhoneNumber())) {
            List callManagerList = this.getRuntime().getCallManagerFactory().getAllCallManagers();
            ICallManager icm = null;
            IEventBroker eventBroker = this.getRuntime().getEventBroker();
            for (int i = 0; i < callManagerList.size(); i++) {
                icm = (ICallManager) callManagerList.get(i);
                // check if the repository manager allows read/write access
                if (icm.isActive() && icm.isSupported(IWriteCallRepository.class)) {
                    // try to keep old attribute information of call and caller
                    if (icm.isSupported(IReadCallRepository.class)) {
                        this.m_logger.info("Call manager <" + icm.getManagerID() + "> is supporting read mode.");
                        ICallList cl = ((IReadCallRepository) icm).getCalls(new UUIDFilter(new String[] { updateCall.getUUID() }));
                        if (cl.size() == 1) {
                            this.m_logger.info("Found exact 1 old call in call manager <" + icm.getManagerID() + "> with UUID " + updateCall.getUUID());
                            ICall oldCall = cl.get(0);
                            if (oldCall != null) {
                                this.m_logger.info("Setting old call info : " + oldCall + " to new call : " + updateCall);
                                oldCall.getCaller().getAttributes().addAll(updateCall.getCaller().getAttributes());
                                oldCall.getAttributes().addAll(updateCall.getAttributes());
                                updateCall = oldCall;
                                this.m_logger.info("Updated new call : " + updateCall);
                            }
                        }
                    }
                    ((IWriteCallRepository) icm).updateCall(updateCall);
                    this.m_logger.info("Call update sent to repository manager <" + icm.getManagerID() + ">: " + updateCall);
                    eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_UPDATE_CALL, updateCall));
                }
            }
        }
    }
}
Also used : ICallManager(de.janrufmonitor.repository.ICallManager) IReadCallRepository(de.janrufmonitor.repository.types.IReadCallRepository) ICall(de.janrufmonitor.framework.ICall) ICallList(de.janrufmonitor.framework.ICallList) UUIDFilter(de.janrufmonitor.repository.filter.UUIDFilter) ICallList(de.janrufmonitor.framework.ICallList) List(java.util.List) IEventBroker(de.janrufmonitor.framework.event.IEventBroker) IWriteCallRepository(de.janrufmonitor.repository.types.IWriteCallRepository)

Example 60 with ICall

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

the class OldDatFileCallImporter method migrateCallFromString.

private ICall migrateCallFromString(String scall, String datePattern) {
    if (scall != null && scall.trim().length() == 0)
        return null;
    try {
        StringTokenizer st = new StringTokenizer(scall, "%$");
        if (st.countTokens() < 5) {
            this.m_logger.warning("Invalid entry found: entry was dropped for migration.");
            return null;
        }
        String state = st.nextToken().trim();
        String msn = st.nextToken().trim();
        String caller = st.nextToken().trim();
        String cip = st.nextToken().trim();
        String date = st.nextToken().trim();
        // parse MSN
        IMsn parsedMSN = this.parseMsn(msn);
        ICip parsedCIP = this.parseCip(cip);
        IAttribute att = this.parseState(state);
        IPhonenumber phone = this.parsePhone(caller);
        IName name = this.parseName(caller);
        ICaller parsedCaller = PIMRuntime.getInstance().getCallerFactory().createCaller(name, phone);
        Date parsedDate = this.parseDate(date, datePattern);
        ICall aCall = PIMRuntime.getInstance().getCallFactory().createCall(parsedCaller, parsedMSN, parsedCIP, parsedDate);
        if (!att.getName().equalsIgnoreCase("")) {
            aCall.setAttribute(att);
        }
        this.m_logger.info(aCall.toString());
        return aCall;
    } catch (NoSuchElementException ex) {
        this.m_logger.warning("FormatException: migration failed due to incompatible format information.");
    } catch (NullPointerException ex) {
        this.m_logger.warning("Invalid entry found: entry was dropped for migration.");
    }
    return null;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) StringTokenizer(java.util.StringTokenizer) ICip(de.janrufmonitor.framework.ICip) ICall(de.janrufmonitor.framework.ICall) IAttribute(de.janrufmonitor.framework.IAttribute) IMsn(de.janrufmonitor.framework.IMsn) IName(de.janrufmonitor.framework.IName) Date(java.util.Date) NoSuchElementException(java.util.NoSuchElementException) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

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