Search in sources :

Example 11 with IAttributeMap

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

the class Formatter method getParsedName.

/**
 * Parses Name object in the specified text representation.
 * The wildcard definitions are taken for parsing.
 *
 * @param text text to parse
 * @param Name object to get the information from
 * @return parsed text
 * @deprecated
 */
public String getParsedName(String text, IName name) {
    if (name == null)
        return text;
    IConfigManager cfg = this.m_runtime.getConfigManagerFactory().getConfigManager();
    // komplex types
    String callernameExpression = cfg.getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_VARIABLE_CALLERNAME);
    text = StringUtils.replaceString(text, IJAMConst.GLOBAL_VARIABLE_CALLERNAME, callernameExpression);
    // parse caller attributes
    IAttributeMap m = this.m_runtime.getCallerFactory().createAttributeMap();
    m.add(this.m_runtime.getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, name.getFirstname()));
    m.add(this.m_runtime.getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, name.getLastname()));
    m.add(this.m_runtime.getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_ADDITIONAL, name.getAdditional()));
    text = this.getParsedAttributes(text, m, true);
    text = StringUtils.replaceString(text, ",  ", " ");
    text = this.cleanString(text.trim());
    return text.trim();
}
Also used : IConfigManager(de.janrufmonitor.framework.configuration.IConfigManager) IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Example 12 with IAttributeMap

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

the class ScoreNumberTellows method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                Object o1 = iter.next();
                Object o = null;
                if (o1 instanceof ICall) {
                    o = ((ICall) o1).getCaller();
                }
                if (o1 instanceof ICaller) {
                    o = o1;
                }
                if (o != null) {
                    if (!((ICaller) o).getPhoneNumber().isClired() && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(((ICaller) o).getPhoneNumber()) && (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))) {
                        final Object o2 = o1;
                        final Object o3 = o;
                        ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
                        try {
                            IRunnableWithProgress r = new IRunnableWithProgress() {

                                public void run(IProgressMonitor progressMonitor) {
                                    progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "scoring", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                                    progressMonitor.worked(1);
                                    try {
                                        IAttributeMap m = TellowsProxy.getInstance().getTellowsData(((ICaller) o3).getPhoneNumber().getTelephoneNumber(), ((ICaller) o3).getPhoneNumber().getIntAreaCode());
                                        if (m.size() > 0) {
                                            ((ICaller) o3).getAttributes().addAll(m);
                                            if (m_app.getController() instanceof IExtendedApplicationController)
                                                ((IExtendedApplicationController) m_app.getController()).updateElement(o2, false);
                                            else
                                                m_app.getController().updateElement(o2);
                                        }
                                    } catch (Exception e) {
                                        PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
                                    }
                                    progressMonitor.done();
                                }
                            };
                            pmd.setBlockOnOpen(false);
                            pmd.run(true, false, r);
                        // ModalContext.run(r, true, pmd.getProgressMonitor(),
                        // DisplayManager.getDefaultDisplay());
                        } catch (InterruptedException e) {
                            m_logger.log(Level.SEVERE, e.getMessage(), e);
                        } catch (InvocationTargetException e) {
                            m_logger.log(Level.SEVERE, e.getMessage(), e);
                        }
                    }
                }
            }
            this.m_app.updateViews(true);
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) Message(de.janrufmonitor.exception.Message) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Iterator(java.util.Iterator) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IExtendedApplicationController(de.janrufmonitor.ui.jface.application.IExtendedApplicationController)

Example 13 with IAttributeMap

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

the class XTapiCall method toCall.

public ICall toCall() {
    if (this.m_call == null) {
        IRuntime r = PIMRuntime.getInstance();
        IPhonenumber phone = PhonenumberAnalyzer.getInstance(r).toClirPhonenumber(this.m_number);
        if (phone == null)
            phone = PhonenumberAnalyzer.getInstance(r).toInternalPhonenumber(this.m_number, this.m_msn);
        if (phone == null)
            phone = PhonenumberAnalyzer.getInstance(r).toPhonenumber(this.m_number, this.m_msn);
        ICaller c = r.getCallerFactory().createCaller(phone);
        IMsn msn = null;
        if (this.m_msn == null) {
            msn = r.getCallFactory().createMsn(getFestnetzAlias(), "");
        } else {
            msn = r.getCallFactory().createMsn(this.m_msn, "");
        }
        msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
        if (this.m_name != null && this.m_name.length() > 0) {
            c.setName(r.getCallerFactory().createName("", this.m_name));
        }
        ICip cip = r.getCallFactory().createCip(getDefaultCip(), "");
        cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
        // create attributes
        IAttributeMap am = r.getCallFactory().createAttributeMap();
        am.add(r.getCallFactory().createAttribute("tapi.device", Integer.toString(this.m_device)));
        am.add(r.getCallFactory().createAttribute("tapi.instance", Integer.toString(this.m_instance)));
        am.add(r.getCallFactory().createAttribute("tapi.key", getKey(this.m_device, this.m_instance)));
        am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
        this.m_call = r.getCallFactory().createCall(c, msn, cip, new Date());
        this.m_call.setAttributes(am);
    }
    return this.m_call;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICip(de.janrufmonitor.framework.ICip) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMsn(de.janrufmonitor.framework.IMsn) Date(java.util.Date) IRuntime(de.janrufmonitor.runtime.IRuntime) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 14 with IAttributeMap

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

the class Tellows method receivedValidRule.

public void receivedValidRule(ICall aCall) {
    // call is identified already
    if (!PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(aCall.getCaller().getPhoneNumber()) && !aCall.getCaller().getPhoneNumber().isClired()) {
        if (!aCall.getCaller().getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") && !aCall.getCaller().getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43") && !aCall.getCaller().getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41")) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Country code not supported by tellows: 00" + aCall.getCaller().getPhoneNumber().getIntAreaCode());
            return;
        }
        String num = aCall.getCaller().getPhoneNumber().getTelephoneNumber();
        try {
            IAttributeMap m = TellowsProxy.getInstance().getTellowsData(num, aCall.getCaller().getPhoneNumber().getIntAreaCode());
            if (m.size() > 0) {
                aCall.getCaller().getAttributes().addAll(m);
                IEventBroker eventBroker = this.getRuntime().getEventBroker();
                eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLMARKEDSPAM, aCall));
            }
        } catch (Exception e) {
            PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
        }
    }
}
Also used : Message(de.janrufmonitor.exception.Message) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IEventBroker(de.janrufmonitor.framework.event.IEventBroker) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 15 with IAttributeMap

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

the class FritzBoxMappingManager method mapJamCallerToFritzBox.

public IPhonebookEntry mapJamCallerToFritzBox(ICaller caller) throws IOException {
    if (this.m_logger.isLoggable(Level.INFO))
        this.m_logger.info("Processing JAM caller: " + caller.toString());
    IPhonebookEntry pe = new FritzBoxPhonebookEntry();
    IAttributeMap attributes = caller.getAttributes();
    String name = "";
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME)) {
        name += attributes.get(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME).getValue() + " ";
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, attributes.get(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME).getValue());
    }
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_LASTNAME)) {
        name += attributes.get(IJAMConst.ATTRIBUTE_NAME_LASTNAME).getValue();
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_LASTNAME, attributes.get(IJAMConst.ATTRIBUTE_NAME_LASTNAME).getValue());
    }
    pe.setName(name.trim());
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_STREET)) {
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_STREET, attributes.get(IJAMConst.ATTRIBUTE_NAME_STREET).getValue());
    }
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_STREET_NO)) {
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_STREET_NO, attributes.get(IJAMConst.ATTRIBUTE_NAME_STREET_NO).getValue());
    }
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_CITY)) {
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_CITY, attributes.get(IJAMConst.ATTRIBUTE_NAME_CITY).getValue());
    }
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE)) {
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, attributes.get(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE).getValue());
    }
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_COUNTRY)) {
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_COUNTRY, attributes.get(IJAMConst.ATTRIBUTE_NAME_COUNTRY).getValue());
    }
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
        pe.addJamInfo(IJAMConst.ATTRIBUTE_NAME_CATEGORY, attributes.get(IJAMConst.ATTRIBUTE_NAME_CATEGORY).getValue());
    }
    if (// hack, since FB only supports integer values
    caller.getUUID().length() < 10)
        pe.setUniqueID(caller.getUUID());
    if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_EMAIL))
        pe.setEmail(attributes.get(IJAMConst.ATTRIBUTE_NAME_EMAIL).getValue());
    if (attributes.contains("fb_entryID"))
        pe.setEntryID(attributes.get("fb_entryID").getValue());
    if (attributes.contains("fb_mod_time"))
        pe.setModTime(attributes.get("fb_mod_time").getValue());
    if (attributes.contains("fb_category"))
        pe.setCategory(attributes.get("fb_category").getValue());
    if (attributes.contains("fb_imageURL")) {
        // replace /download.lua?path=/var by f
        String nurl = attributes.get("fb_imageURL").getValue();
        nurl = StringUtils.replaceString(nurl, "/download.lua?path=/var", "file:///var");
        pe.setImageURL(nurl);
    }
    List phones = new ArrayList();
    if (caller instanceof IMultiPhoneCaller) {
        phones = ((IMultiPhoneCaller) caller).getPhonenumbers();
    } else {
        phones.add(caller.getPhoneNumber());
    }
    for (int i = 0; i < phones.size(); i++) {
        IPhonenumber pn = (IPhonenumber) phones.get(i);
        String number = this.getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, pn);
        if (attributes.contains("fb_number_type_" + pn.getTelephoneNumber())) {
            pe.addNumber(number, attributes.get("fb_number_type_" + pn.getTelephoneNumber()).getValue());
            pe.addNumberType(number, attributes.get("fb_number_type_" + pn.getTelephoneNumber()).getValue());
        } else if (attributes.contains(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber())) {
            if (attributes.get(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber()).getValue().equalsIgnoreCase(IJAMConst.ATTRIBUTE_VALUE_MOBILE_TYPE)) {
                pe.addNumber(number, "mobile");
                pe.addNumberType(number, "mobile");
            } else if (attributes.get(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber()).getValue().equalsIgnoreCase(IJAMConst.ATTRIBUTE_VALUE_FAX_TYPE)) {
                pe.addNumber(number, "fax_work");
                pe.addNumberType(number, "fax_work");
            } else {
                pe.addNumber(number, "home");
                pe.addNumberType(number, "home");
            }
        } else {
            pe.addNumber(number, "home");
            pe.addNumberType(number, "home");
        }
        if (attributes.contains("fb_number_id_" + pn.getTelephoneNumber())) {
            pe.addNumberID(number, attributes.get("fb_number_id_" + pn.getTelephoneNumber()).getValue());
        }
        if (attributes.contains("fb_number_prio_" + pn.getTelephoneNumber())) {
            pe.addNumberPrio(number, attributes.get("fb_number_prio_" + pn.getTelephoneNumber()).getValue());
        }
        if (attributes.contains("fb_number_quickdial_" + pn.getTelephoneNumber())) {
            pe.addNumberQuickDial(number, attributes.get("fb_number_quickdial_" + pn.getTelephoneNumber()).getValue());
        }
        if (attributes.contains("fb_number_vanity_" + pn.getTelephoneNumber())) {
            pe.addNumberVanity(number, attributes.get("fb_number_vanity_" + pn.getTelephoneNumber()).getValue());
        }
    }
    return pe;
}
Also used : ArrayList(java.util.ArrayList) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

IAttributeMap (de.janrufmonitor.framework.IAttributeMap)64 IAttribute (de.janrufmonitor.framework.IAttribute)37 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)36 ICaller (de.janrufmonitor.framework.ICaller)31 List (java.util.List)24 ICallerList (de.janrufmonitor.framework.ICallerList)23 ArrayList (java.util.ArrayList)21 Iterator (java.util.Iterator)17 IOException (java.io.IOException)14 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)13 Date (java.util.Date)12 IMsn (de.janrufmonitor.framework.IMsn)11 File (java.io.File)10 ICip (de.janrufmonitor.framework.ICip)8 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)8 Message (de.janrufmonitor.exception.Message)6 ICall (de.janrufmonitor.framework.ICall)6 SimpleDateFormat (java.text.SimpleDateFormat)6 StringTokenizer (java.util.StringTokenizer)6 IFilter (de.janrufmonitor.repository.filter.IFilter)5