Search in sources :

Example 41 with IEventBroker

use of de.janrufmonitor.framework.event.IEventBroker in project janrufmonitor by tbrandt77.

the class GeoCoding method startup.

public void startup() {
    super.startup();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL));
    eventBroker.register(this);
    this.m_logger.info("GeoCoding is started ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 42 with IEventBroker

use of de.janrufmonitor.framework.event.IEventBroker in project janrufmonitor by tbrandt77.

the class Journaling method shutdown.

public void shutdown() {
    super.shutdown();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL_ACCEPTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLACCEPTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLCLEARED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_MANUALCALLACCEPTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLMARKEDSPAM));
    eventBroker.unregister(this);
    this.m_logger.info("Journaling is shut down ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 43 with IEventBroker

use of de.janrufmonitor.framework.event.IEventBroker 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 44 with IEventBroker

use of de.janrufmonitor.framework.event.IEventBroker in project janrufmonitor by tbrandt77.

the class Journaling method startup.

public void startup() {
    super.startup();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL_ACCEPTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLACCEPTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLCLEARED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_MANUALCALLACCEPTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLMARKEDSPAM));
    eventBroker.register(this);
    this.m_logger.info("Journaling is started ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 45 with IEventBroker

use of de.janrufmonitor.framework.event.IEventBroker 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)

Aggregations

IEventBroker (de.janrufmonitor.framework.event.IEventBroker)52 ICall (de.janrufmonitor.framework.ICall)5 Message (de.janrufmonitor.exception.Message)4 IEvent (de.janrufmonitor.framework.event.IEvent)4 ICaller (de.janrufmonitor.framework.ICaller)3 ICip (de.janrufmonitor.framework.ICip)3 ICallManager (de.janrufmonitor.repository.ICallManager)3 IWriteCallRepository (de.janrufmonitor.repository.types.IWriteCallRepository)3 IOException (java.io.IOException)3 List (java.util.List)3 ICallList (de.janrufmonitor.framework.ICallList)2 IMsn (de.janrufmonitor.framework.IMsn)2 IName (de.janrufmonitor.framework.IName)2 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)2 IReadCallRepository (de.janrufmonitor.repository.types.IReadCallRepository)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)1 FritzBoxCallCsv (de.janrufmonitor.fritzbox.FritzBoxCallCsv)1 FirmwareManager (de.janrufmonitor.fritzbox.firmware.FirmwareManager)1