Search in sources :

Example 1 with IRuntime

use of de.janrufmonitor.runtime.IRuntime 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 2 with IRuntime

use of de.janrufmonitor.runtime.IRuntime in project janrufmonitor by tbrandt77.

the class NcidCallRaw method toCall.

public ICall toCall() {
    if (this.m_line == null || this.m_line.length() == 0)
        return null;
    if (this.m_call == null) {
        IRuntime r = PIMRuntime.getInstance();
        String[] call = this.m_line.split("\\*");
        if (call.length >= 8 && (call[0].trim().equalsIgnoreCase("CID:") || call[0].trim().equalsIgnoreCase("CIDLOG:"))) {
            // create MSN
            IMsn msn = r.getCallFactory().createMsn(getFestnetzAlias(call[6]), "");
            msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
            IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[8].trim());
            // if no CLIR call, check internal
            if (pn == null)
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[8].trim(), msn.getMSN());
            // if no internal call, check regular
            if (pn == null) {
                // if incoming call does not start with 0, the Provider number seems to have the wrong format
                // assume it is an international format 4971657110
                boolean onlyNumbers = call[8].matches("[+-]?[0-9]+");
                if (!call[8].startsWith("0") && onlyNumbers) {
                    call[8] = "00" + call[8];
                }
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[8].trim(), msn.getMSN());
            }
            ICaller caller = r.getCallerFactory().createCaller(pn);
            // create call data
            // added 2009/05/01
            String dateformat = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(NcidMonitor.NAMESPACE, "dateformat");
            if (dateformat == null || dateformat.trim().length() == 0)
                dateformat = "ddMMyyyyHHmm";
            if (Logger.getLogger(IJAMConst.DEFAULT_LOGGER).isLoggable(Level.INFO))
                Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Setting date format to #" + dateformat + "#");
            SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
            Date date = new Date(0);
            try {
                date = sdf.parse(call[2] + call[4]);
            } catch (ParseException e) {
                Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected. " + call[2] + call[4] + " does not match #" + dateformat + "#");
            }
            ICip cip = r.getCallFactory().createCip(getCip("sip"), "");
            cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
            // create attributes
            IAttributeMap am = r.getCallFactory().createAttributeMap();
            am.add(r.getCallFactory().createAttribute("ncid.key", call[6]));
            if (call.length >= 12) {
                am.add(r.getCallFactory().createAttribute("ncid.msg", call[10]));
                am.add(r.getCallFactory().createAttribute("ncid.callername", call[12]));
            }
            am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
            // create UUID
            StringBuffer uuid = new StringBuffer();
            uuid.append(date.getTime());
            uuid.append("-");
            uuid.append(pn.getTelephoneNumber());
            uuid.append("-");
            uuid.append(msn.getMSN());
            // limit uuid to 32 chars
            if (uuid.length() > 31) {
                // reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
                uuid = new StringBuffer(uuid.substring(0, 31));
            }
            this.m_call = r.getCallFactory().createCall(uuid.toString(), caller, msn, cip, date);
            this.m_call.setAttributes(am);
        }
        if (call.length >= 8 && call[0].trim().equalsIgnoreCase("OUT:")) {
            // create msn
            IMsn msn = r.getCallFactory().createMsn(getFestnetzAlias(call[6]), "");
            msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
            // create caller data
            String callByCall = null;
            IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[8].trim());
            // if no CLIR call, check internal
            if (pn == null)
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[8].trim(), msn.getMSN());
            // if no internal call, check regular
            if (pn == null) {
                // added 2006/08/10: trim call-by-call information
                // only can occure on state CALL (out-going calls)
                callByCall = getCallByCall(call[8]);
                if (callByCall != null) {
                    call[8] = call[8].substring(callByCall.length());
                }
                // requires addition of areacode
                if (!call[8].startsWith("0")) {
                    Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Assuming number " + call[8] + " has missing areacode.");
                    call[8] = this.getGeneralAreaCode() + call[8];
                    Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Added areacode to number " + call[8]);
                }
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[8].trim(), msn.getMSN());
            }
            ICaller caller = r.getCallerFactory().createCaller(pn);
            // create call data
            // added 2009/05/27
            String dateformat = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(NcidMonitor.NAMESPACE, "dateformat");
            if (dateformat == null || dateformat.trim().length() == 0)
                dateformat = "ddMMyyyyHHmm";
            if (Logger.getLogger(IJAMConst.DEFAULT_LOGGER).isLoggable(Level.INFO))
                Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Setting date format to #" + dateformat + "#");
            SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
            Date date = new Date(0);
            try {
                date = sdf.parse(call[2] + call[4]);
            } catch (ParseException e) {
                Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected. " + call[2] + call[4] + " does not match #" + dateformat + "#");
            }
            ICip cip = r.getCallFactory().createCip(getCip("sip"), "");
            cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
            // create attributes
            IAttributeMap am = r.getCallFactory().createAttributeMap();
            am.add(r.getCallFactory().createAttribute("ncid.key", call[6]));
            if (call.length >= 12) {
                am.add(r.getCallFactory().createAttribute("ncid.msg", call[10]));
                am.add(r.getCallFactory().createAttribute("ncid.callername", call[12]));
            }
            am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
            if (callByCall != null)
                am.add(r.getCallFactory().createAttribute("ncid.callbycall", callByCall));
            // create UUID
            StringBuffer uuid = new StringBuffer();
            uuid.append(date.getTime());
            uuid.append("-");
            uuid.append(pn.getTelephoneNumber());
            uuid.append("-");
            uuid.append(msn.getMSN());
            // limit uuid to 32 chars
            if (uuid.length() > 31) {
                // reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
                uuid = new StringBuffer(uuid.substring(0, 31));
            }
            this.m_call = r.getCallFactory().createCall(uuid.toString(), caller, msn, cip, date);
            this.m_call.setAttributes(am);
        }
    }
    return this.m_call;
}
Also used : ICip(de.janrufmonitor.framework.ICip) Date(java.util.Date) IRuntime(de.janrufmonitor.runtime.IRuntime) ICaller(de.janrufmonitor.framework.ICaller) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ParseException(java.text.ParseException) IMsn(de.janrufmonitor.framework.IMsn) SimpleDateFormat(java.text.SimpleDateFormat) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 3 with IRuntime

use of de.janrufmonitor.runtime.IRuntime in project janrufmonitor by tbrandt77.

the class FritzBoxCallCsv method toCall.

public ICall toCall() {
    Logger logger = Logger.getLogger(IJAMConst.DEFAULT_LOGGER);
    if (this.m_line == null || this.m_line.trim().length() == 0) {
        if (logger != null && logger.isLoggable(Level.INFO))
            logger.info("No call data found in CSV line: " + this.m_line);
        return null;
    }
    /**
     * Added 2011/01/05: added do to NumberFormatException in log, remove the header
     *
     * Format: Typ;Datum;Name;Rufnummer;Nebenstelle;Eigene Rufnummer;Dauer
     */
    if (this.m_line.trim().toLowerCase().startsWith("typ;")) {
        if (logger != null && logger.isLoggable(Level.INFO))
            logger.info("Ignore CSV header line: " + this.m_line);
        return null;
    }
    if (this.m_call == null) {
        try {
            IRuntime r = PIMRuntime.getInstance();
            String[] call = this.m_line.split(";");
            if (call.length >= 7) {
                if (logger != null && logger.isLoggable(Level.INFO))
                    logger.info("Tokens in CSV line: " + call.length);
                // create msn
                IMsn msn = r.getCallFactory().createMsn(getMsn(call[5]), "");
                msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
                if (logger != null && logger.isLoggable(Level.INFO))
                    logger.info("MSN set to: " + msn.toString());
                // create caller data
                int state = Integer.parseInt(call[0]);
                if (logger != null && logger.isLoggable(Level.INFO))
                    logger.info("State set to: " + state);
                // added 2016/01/26: ignore incoming active (5) and outgoung active calls (6)
                if (state == 5 || state == 6) {
                    if (logger != null && logger.isLoggable(Level.INFO))
                        logger.info("Ignoring call state: " + state);
                    return null;
                }
                String callByCall = null;
                ICaller caller = null;
                IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[3].trim());
                // if no CLIR call, check internal
                if (pn == null && state != this.getOutgoingState())
                    pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[3].trim(), msn.getMSN());
                // if no internal call, check regular
                if (pn == null && state != this.getOutgoingState()) {
                    // if incoming call does not start with 0, the Provider number seems to have the wrong format
                    // assume it is an international format 4971657110
                    boolean onlyNumbers = call[3].matches("[+-]?[0-9]+");
                    if (!call[3].startsWith("0") && onlyNumbers) {
                        if (logger != null && logger.isLoggable(Level.INFO))
                            logger.info("Assuming international call: " + call[3]);
                        call[3] = "00" + call[3];
                    }
                    pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[3].trim(), msn.getMSN());
                }
                if (pn == null && state == this.getOutgoingState()) {
                    // added 2006/08/10: trim call-by-call information
                    // only can occure on state 3/4 (out-going calls)
                    callByCall = getCallByCall(call[3]);
                    if (callByCall != null) {
                        call[3] = call[3].substring(callByCall.length());
                    }
                    pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[3].trim(), msn.getMSN());
                    if (pn == null) {
                        // requires addition of areacode
                        if (!call[3].startsWith("0")) {
                            if (logger != null && logger.isLoggable(Level.INFO))
                                logger.info("Assuming number " + call[3] + " has missing areacode.");
                            call[3] = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).getAreaCode() + call[3];
                            if (logger != null && logger.isLoggable(Level.INFO))
                                logger.info("Added areacode to number " + call[3]);
                        }
                        pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[3].trim(), msn.getMSN());
                    }
                }
                if (logger != null && logger.isLoggable(Level.INFO))
                    logger.info("Phonenumber set to: " + pn);
                caller = Identifier.identify(r, pn);
                if (caller == null) {
                    caller = r.getCallerFactory().createCaller(r.getCallerFactory().createName("", call[2]), pn);
                    if (logger != null && logger.isLoggable(Level.INFO))
                        logger.info("Setting CSV name field as caller name: " + call[2]);
                }
                // added 2016/01/19: FB Name data if jAnrufmonitor did not find any in his callermanagers
                if (caller.getName().getLastname().length() == 0 && caller.getName().getFirstname().length() == 0 && call[2].trim().length() > 0) {
                    caller.getAttributes().add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, call[2]));
                    caller.getAttributes().add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, FritzBoxPhonebookManager.ID));
                    caller.getAttributes().remove(IJAMConst.ATTRIBUTE_NAME_CITY);
                }
                // create call data
                SimpleDateFormat sdf = new SimpleDateFormat(this.m_config.getProperty(CFG_DATEFORMAT, "dd.MM.yy HH:mm"));
                Date date = new Date(0);
                try {
                    date = sdf.parse(call[1]);
                } catch (ParseException e) {
                    if (logger != null && logger.isLoggable(Level.SEVERE))
                        logger.severe("Wrong date format detected: " + e.getMessage());
                }
                ICip cip = r.getCallFactory().createCip(getCip(call[4]), "");
                cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
                if (logger != null && logger.isLoggable(Level.INFO))
                    logger.info("Set CIP to: " + cip);
                // create attributes
                IAttributeMap am = r.getCallFactory().createAttributeMap();
                if (state == 1) {
                    am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_ACCEPTED));
                } else if (state == this.getOutgoingState()) {
                    am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
                } else if (this.hasRejectedState() && state == this.getRejectedState()) {
                    am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
                } else {
                    am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
                }
                am.add(r.getCallFactory().createAttribute("fritzbox.line", call[4]));
                am.add(r.getCallFactory().createAttribute("fritzbox.duration", Integer.toString(getTime(call[6]))));
                am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALL_DURATION, Integer.toString(getTime(call[6]))));
                am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALL_ACTIVE_INDICATOR, IJAMConst.ATTRIBUTE_VALUE_NO));
                if (callByCall != null)
                    am.add(r.getCallFactory().createAttribute("fritzbox.callbycall", callByCall));
                if (isSpoofingnumber(call[2])) {
                    if (logger != null && logger.isLoggable(Level.INFO))
                        logger.info("Spoofing number detected: " + call[2]);
                    String sn = getSpoofingnumber(call[2]);
                    IPhonenumber pnx = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(sn.trim());
                    ICaller cx = Identifier.identify(r, pnx);
                    if (cx != null) {
                        am.add(r.getCallFactory().createAttribute("fritzbox.spoofing", cx.getPhoneNumber().getIntAreaCode() + ";" + cx.getPhoneNumber().getAreaCode() + ";" + cx.getPhoneNumber().getCallNumber()));
                        am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_SPOOFED, "true"));
                    }
                }
                if (logger != null && logger.isLoggable(Level.INFO))
                    logger.info("Set attributes to: " + am);
                // // create UUID
                // StringBuffer uuid = new StringBuffer();
                // uuid.append(date.getTime());
                // uuid.append("-");
                // uuid.append(pn.getTelephoneNumber());
                // uuid.append("-");
                // uuid.append(msn.getMSN());
                // 
                // if (logger!=null && logger.isLoggable(Level.INFO))
                // logger.info("Set UUID to: "+uuid);
                // 
                // // limit uuid to 32 chars
                // if (uuid.length()>31) {
                // // reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
                // uuid = new StringBuffer(uuid.substring(0,31));
                // if (logger!=null && logger.isLoggable(Level.INFO))
                // logger.info("Reduce UUID to: "+uuid);
                // }
                this.m_call = r.getCallFactory().createCall(FritzBoxUUIDManager.getInstance().getUUID(date, pn, msn), caller, msn, cip, date);
                this.m_call.setAttributes(am);
            }
        } catch (NumberFormatException ex) {
            if (logger != null && logger.isLoggable(Level.SEVERE))
                logger.log(Level.SEVERE, ex.toString(), ex);
        } catch (Exception ex) {
            if (logger != null && logger.isLoggable(Level.WARNING))
                logger.log(Level.WARNING, ex.toString() + ":" + ex.getMessage() + " : problem with line parsing : " + this.m_line, ex);
            if (ex instanceof NullPointerException)
                if (logger != null && logger.isLoggable(Level.SEVERE))
                    logger.log(Level.SEVERE, ex.toString(), ex);
            return null;
        }
    }
    return this.m_call;
}
Also used : ICip(de.janrufmonitor.framework.ICip) Logger(java.util.logging.Logger) Date(java.util.Date) ParseException(java.text.ParseException) IRuntime(de.janrufmonitor.runtime.IRuntime) ICaller(de.janrufmonitor.framework.ICaller) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ParseException(java.text.ParseException) IMsn(de.janrufmonitor.framework.IMsn) SimpleDateFormat(java.text.SimpleDateFormat) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 4 with IRuntime

use of de.janrufmonitor.runtime.IRuntime in project janrufmonitor by tbrandt77.

the class FritzBoxCallRaw method toCall.

public ICall toCall() {
    if (this.m_line == null || this.m_line.length() == 0)
        return null;
    if (this.m_call == null) {
        IRuntime r = PIMRuntime.getInstance();
        String[] call = this.m_line.split(";");
        if (call.length >= 4 && call[1].equalsIgnoreCase("RING")) {
            // create MSN
            IMsn msn = r.getCallFactory().createMsn(getMsn(call[4]), "");
            msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
            IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[3].trim());
            // if no CLIR call, check internal
            if (pn == null)
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[3].trim(), msn.getMSN());
            // if no internal call, check regular
            if (pn == null) {
                // if incoming call does not start with 0, the Provider number seems to have the wrong format
                // assume it is an international format 4971657110
                boolean onlyNumbers = call[3].matches("[+-]?[0-9]+");
                if (!call[3].startsWith("0") && onlyNumbers) {
                    call[3] = "00" + call[3];
                }
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[3].trim(), msn.getMSN());
            }
            ICaller caller = r.getCallerFactory().createCaller(pn);
            // create call data
            // added 2009/05/01
            SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
            Date date = new Date(0);
            try {
                date = sdf.parse(call[0]);
                date = this.toFritzboxDate(date);
            } catch (ParseException e) {
                Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected.");
                sdf = new SimpleDateFormat(this.m_config.getProperty(CFG_DATEFORMAT, "dd.MM.yy HH:mm"));
                try {
                    date = sdf.parse(call[0]);
                    date = this.toFritzboxDate(date);
                } catch (ParseException ex) {
                    Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong custom date format detected.");
                }
            }
            ICip cip = r.getCallFactory().createCip(getCip(call[5]), "");
            cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
            // create attributes
            IAttributeMap am = r.getCallFactory().createAttributeMap();
            am.add(r.getCallFactory().createAttribute("fritzbox.key", call[2]));
            am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
            this.m_call = r.getCallFactory().createCall(FritzBoxUUIDManager.getInstance().calculateUUID(FritzBoxUUIDManager.getInstance().getUUID(date, pn, msn)), caller, msn, cip, date);
            this.m_call.setAttributes(am);
        }
        if (call.length >= 4 && call[1].equalsIgnoreCase("CALL")) {
            // create msn
            String s_msn = null;
            if (call.length >= 7) {
                s_msn = getMsn(call[6]);
                if (s_msn == null || call[6].equalsIgnoreCase(s_msn))
                    s_msn = getMsn(call[4]);
            } else {
                s_msn = getMsn(call[4]);
            }
            IMsn msn = r.getCallFactory().createMsn((s_msn == null ? "" : s_msn), "");
            msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
            // create caller data
            String callByCall = null;
            IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[5].trim());
            // if no CLIR call, check internal
            if (pn == null)
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[5].trim(), msn.getMSN());
            // if no internal call, check regular
            if (pn == null) {
                // added 2006/08/10: trim call-by-call information
                // only can occure on state CALL (out-going calls)
                callByCall = getCallByCall(call[5]);
                if (callByCall != null) {
                    call[5] = call[5].substring(callByCall.length());
                }
                // requires addition of areacode
                if (!call[5].startsWith("0")) {
                    Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Assuming number " + call[5] + " has missing areacode.");
                    call[5] = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).getAreaCode() + call[5];
                    Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Added areacode to number " + call[5]);
                }
                pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[5].trim(), msn.getMSN());
            }
            ICaller caller = r.getCallerFactory().createCaller(pn);
            // create call data
            // added 2009/05/27
            SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
            Date date = new Date(0);
            try {
                date = sdf.parse(call[0]);
                date = this.toFritzboxDate(date);
            } catch (ParseException e) {
                Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected.");
                sdf = new SimpleDateFormat(this.m_config.getProperty(CFG_DATEFORMAT, "dd.MM.yy HH:mm"));
                try {
                    date = sdf.parse(call[0]);
                    date = this.toFritzboxDate(date);
                } catch (ParseException ex) {
                    Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong custom date format detected.");
                }
            }
            ICip cip = r.getCallFactory().createCip(getCip(call[6]), "");
            cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
            // create attributes
            IAttributeMap am = r.getCallFactory().createAttributeMap();
            am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
            am.add(r.getCallFactory().createAttribute("fritzbox.key", call[2]));
            if (callByCall != null)
                am.add(r.getCallFactory().createAttribute("fritzbox.callbycall", callByCall));
            this.m_call = r.getCallFactory().createCall(FritzBoxUUIDManager.getInstance().calculateUUID(FritzBoxUUIDManager.getInstance().getUUID(date, pn, msn)), caller, msn, cip, 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) ParseException(java.text.ParseException) IMsn(de.janrufmonitor.framework.IMsn) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) IRuntime(de.janrufmonitor.runtime.IRuntime) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

IAttributeMap (de.janrufmonitor.framework.IAttributeMap)4 ICaller (de.janrufmonitor.framework.ICaller)4 ICip (de.janrufmonitor.framework.ICip)4 IMsn (de.janrufmonitor.framework.IMsn)4 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)4 IRuntime (de.janrufmonitor.runtime.IRuntime)4 Date (java.util.Date)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Logger (java.util.logging.Logger)1