Search in sources :

Example 61 with ICall

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

the class ConsoleSimulate method execute.

public void execute() {
    this.isExecuting = true;
    String number = "";
    String cip = "";
    String msn = "";
    if (this.getExecuteParams().length < 2 || this.getExecuteParams().length > 3) {
        System.out.println("ERROR: Invalid SIMULATE command.");
        System.out.println("USAGE for regular call simulation: SIMULATE <number> <msn> <cip>");
        System.out.println("USAGE for CLIR call simulation: SIMULATE <msn> <cip>");
        this.isExecuting = false;
        return;
    }
    if (this.getExecuteParams().length == 2) {
        msn = this.getExecuteParams()[0];
        cip = this.getExecuteParams()[1];
    }
    if (this.getExecuteParams().length == 3) {
        number = this.getExecuteParams()[0];
        msn = this.getExecuteParams()[1];
        cip = this.getExecuteParams()[2];
    }
    IEventBroker evtBroker = PIMRuntime.getInstance().getEventBroker();
    IPhonenumber phone = PhonenumberAnalyzer.getInstance(getRuntime()).toClirPhonenumber(number);
    if (phone != null)
        System.out.println("Call detected as CLIR: " + phone.isClired());
    if (phone == null) {
        phone = PhonenumberAnalyzer.getInstance(getRuntime()).toInternalPhonenumber(number, msn);
        if (phone != null)
            System.out.println("Call detected as internal: " + number.trim());
    }
    if (phone == null) {
        phone = PhonenumberAnalyzer.getInstance(getRuntime()).toPhonenumber(number, msn);
        if (phone != null)
            System.out.println("Call detected as external: " + number.trim());
    }
    IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
    ICaller aCaller = PIMRuntime.getInstance().getCallerFactory().createCaller(name, phone);
    ICip ocip = PIMRuntime.getInstance().getCallFactory().createCip(cip, "");
    IMsn omsn = PIMRuntime.getInstance().getCallFactory().createMsn(msn, "");
    ICall newCall = PIMRuntime.getInstance().getCallFactory().createCall(aCaller, omsn, ocip);
    evtBroker.register(this);
    IEvent ev = evtBroker.createEvent(IEventConst.EVENT_TYPE_INCOMINGCALL, newCall);
    evtBroker.send(this, ev);
    evtBroker.unregister(this);
    this.isExecuting = false;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICip(de.janrufmonitor.framework.ICip) ICall(de.janrufmonitor.framework.ICall) IEvent(de.janrufmonitor.framework.event.IEvent) IName(de.janrufmonitor.framework.IName) IMsn(de.janrufmonitor.framework.IMsn) IEventBroker(de.janrufmonitor.framework.event.IEventBroker) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 62 with ICall

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

the class DatFileCallImporter method doImport.

public ICallList doImport() {
    m_callList = PIMRuntime.getInstance().getCallFactory().createCallList();
    Date startDate = new Date();
    File db = new File(m_filename);
    try {
        FileReader dbReader = new FileReader(db);
        BufferedReader bufReader = new BufferedReader(dbReader);
        ICall aCall = null;
        boolean isNewDatFormat = false;
        String line = null;
        Transformator tf = null;
        while (bufReader.ready()) {
            line = bufReader.readLine();
            if (!isNewDatFormat && line != null && line.indexOf("***") > -1) {
                if (tf == null)
                    tf = new Transformator();
            } else {
                isNewDatFormat = true;
            }
            try {
                aCall = (isNewDatFormat ? Serializer.toCall(line.getBytes(), PIMRuntime.getInstance()) : tf.transform(line));
                // 2008/11/07: new call status introduced in 5.0.8
                migrateStatus(aCall);
                this.m_callList.add(aCall);
            } catch (SerializerException e) {
                this.m_logger.warning(e.getMessage());
            }
        }
        bufReader.close();
        dbReader.close();
    } catch (FileNotFoundException ex) {
        this.m_logger.warning("Cannot find call backup file " + m_filename);
        return this.m_callList;
    } catch (IOException ex) {
        this.m_logger.severe("IOException on file " + m_filename);
        return this.m_callList;
    } catch (NoSuchElementException ex) {
        this.m_logger.severe("Invalid format in file " + m_filename);
        return this.m_callList;
    }
    Date endDate = new Date();
    this.m_logger.info("Successfully imported call file " + m_filename);
    this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + new Float((endDate.getTime() - startDate.getTime()) / 1000).toString() + " secs.");
    return m_callList;
}
Also used : ICall(de.janrufmonitor.framework.ICall) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) SerializerException(de.janrufmonitor.util.io.SerializerException) Date(java.util.Date) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException)

Example 63 with ICall

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

the class FritzBoxCallListImporter method processModifierServices.

private void processModifierServices(ICallList cl) {
    if (cl != null && cl.size() > 0) {
        List msvc = PIMRuntime.getInstance().getServiceFactory().getModifierServices();
        IModifierService s = null;
        for (int k = 0, l = msvc.size(); k < l; k++) {
            s = (IModifierService) msvc.get(k);
            if (s != null && s.isEnabled()) {
                if (m_logger.isLoggable(Level.INFO))
                    m_logger.info("Processing modifier service <" + s.getServiceID() + ">");
                ICall call = null;
                for (int i = 0, j = cl.size(); i < j; i++) {
                    call = cl.get(i);
                    s.modifyObject(call);
                }
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) IModifierService(de.janrufmonitor.service.IModifierService) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 64 with ICall

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

the class FritzBoxCallListImporter method doImport.

public ICallList doImport() {
    m_callList = PIMRuntime.getInstance().getCallFactory().createCallList();
    try {
        FileInputStream fin = new FileInputStream(m_filename);
        List result = this.getRawCallList(fin);
        if (result.size() > 0) {
            FritzBoxCallCsv call = null;
            Properties conf = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
            ICall c = null;
            for (int i = 0, j = result.size(); i < j; i++) {
                call = new FritzBoxCallCsv((String) result.get(i), conf);
                c = call.toCall();
                if (c != null) {
                    if (!m_callList.contains(c))
                        m_callList.add(c);
                    else {
                        this.m_logger.warning("Call already imported from FritzBox: " + c.toString());
                        c.setUUID(c.getUUID() + "-1");
                        ICip cip = c.getCIP();
                        // just a dirty hack
                        cip.setCIP("4");
                        c.setCIP(cip);
                        if (!m_callList.contains(c))
                            m_callList.add(c);
                    }
                }
            }
        }
    } catch (FileNotFoundException e) {
        this.m_logger.severe("File not found: " + m_filename);
    } catch (IOException e) {
        this.m_logger.severe("IO Error on file " + m_filename + ": " + e.getMessage());
    }
    if (m_callList != null && m_callList.size() > 0) {
        if (m_logger.isLoggable(Level.INFO))
            m_logger.info("Processing modifier services on call list: " + PIMRuntime.getInstance().getServiceFactory().getModifierServices());
        processModifierServices(m_callList);
    }
    return m_callList;
}
Also used : FritzBoxCallCsv(de.janrufmonitor.fritzbox.FritzBoxCallCsv) ICall(de.janrufmonitor.framework.ICall) ICip(de.janrufmonitor.framework.ICip) FileNotFoundException(java.io.FileNotFoundException) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream)

Example 65 with ICall

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

the class SynchronizerService method modifyObject.

@Override
public void modifyObject(Object o) {
    if (!(o instanceof ICall))
        return;
    boolean synctam = SynchronizerService.this.m_configuration.getProperty(CFG_SYNCTAM, "false").equalsIgnoreCase("true");
    if (synctam) {
        if (m_logger.isLoggable(Level.INFO))
            m_logger.info("Sync TAM recordings: " + Boolean.toString(synctam));
        String uuid = ((ICall) o).getUUID();
        if (this.m_tamMap != null && this.m_tamMap.containsKey(uuid)) {
            List l = (List) this.m_tamMap.get(uuid);
            if (l.size() == 6) {
                ((ICall) o).getAttributes().add(this.getRuntime().getCallFactory().createAttribute("fritzbox.tamurl", (String) l.get(4)));
                if (m_logger.isLoggable(Level.INFO))
                    m_logger.info("add TAM attribute fritzbox.tamurl: " + (String) l.get(4));
                ((ICall) o).getAttributes().add(this.getRuntime().getCallFactory().createAttribute("fritzbox.tamduration", (String) l.get(3)));
                if (m_logger.isLoggable(Level.INFO))
                    m_logger.info("add TAM attribute fritzbox.tamduration: " + (String) l.get(3));
                ((ICall) o).getAttributes().add(this.getRuntime().getCallFactory().createAttribute("fritzbox.tam", (String) l.get(5)));
                if (m_logger.isLoggable(Level.INFO))
                    m_logger.info("add TAM attribute fritzbox.tam: " + (String) l.get(5));
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) ICallList(de.janrufmonitor.framework.ICallList) List(java.util.List) ArrayList(java.util.ArrayList)

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