Search in sources :

Example 1 with IEvent

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

the class CallSimulator method sendAcceptEvent.

protected void sendAcceptEvent() {
    if (this.m_currentIdentifiedCall != null) {
        IEventBroker evtBroker = this.getRuntime().getEventBroker();
        evtBroker.register(this);
        this.m_currentIdentifiedCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_REASON, Integer.toString(IEventConst.EVENT_TYPE_CALLACCEPTED)));
        this.m_currentIdentifiedCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_ACCEPTED));
        IEvent ev = evtBroker.createEvent(IEventConst.EVENT_TYPE_CALLACCEPTED, this.m_currentIdentifiedCall);
        evtBroker.send(this, ev);
        evtBroker.unregister(this);
        evtBroker.unregister(this, evtBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    }
}
Also used : IEvent(de.janrufmonitor.framework.event.IEvent) IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 2 with IEvent

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

the class CallSimulator method sendClirEvent.

protected void sendClirEvent() {
    if (this.m_currentIdentifiedCall != null) {
        IEventBroker evtBroker = this.getRuntime().getEventBroker();
        evtBroker.register(this);
        this.m_currentIdentifiedCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_REASON, Integer.toString(IEventConst.EVENT_TYPE_CALLCLEARED)));
        this.m_currentIdentifiedCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
        IEvent ev = evtBroker.createEvent(IEventConst.EVENT_TYPE_CALLCLEARED, this.m_currentIdentifiedCall);
        evtBroker.send(this, ev);
        evtBroker.unregister(this);
        evtBroker.unregister(this, evtBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    }
}
Also used : IEvent(de.janrufmonitor.framework.event.IEvent) IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 3 with IEvent

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

the class CallSimulator method sendEvent.

protected void sendEvent(String number, String msn, String cip) {
    if (number != null && number.length() > 0)
        number = PhonenumberAnalyzer.getInstance(this.getRuntime()).toCallable(number);
    if (!number.startsWith("0") && isRaw) {
        number = "0" + number;
    }
    IEventBroker evtBroker = this.getRuntime().getEventBroker();
    evtBroker.register(this);
    evtBroker.register(this, evtBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    IPhonenumber phone = PhonenumberAnalyzer.getInstance(this.getRuntime()).toClirPhonenumber(number);
    if (phone == null)
        phone = PhonenumberAnalyzer.getInstance(this.getRuntime()).toInternalPhonenumber(number, msn);
    if (phone == null)
        phone = PhonenumberAnalyzer.getInstance(this.getRuntime()).toPhonenumber(number, msn);
    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 currentCall = PIMRuntime.getInstance().getCallFactory().createCall(aCaller, omsn, ocip);
    currentCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
    IEvent ev = evtBroker.createEvent(IEventConst.EVENT_TYPE_INCOMINGCALL, currentCall);
    evtBroker.send(this, ev);
    evtBroker.unregister(this);
}
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 4 with IEvent

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

IEvent (de.janrufmonitor.framework.event.IEvent)4 IEventBroker (de.janrufmonitor.framework.event.IEventBroker)4 ICall (de.janrufmonitor.framework.ICall)2 ICaller (de.janrufmonitor.framework.ICaller)2 ICip (de.janrufmonitor.framework.ICip)2 IMsn (de.janrufmonitor.framework.IMsn)2 IName (de.janrufmonitor.framework.IName)2 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)2