Search in sources :

Example 31 with IEventBroker

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

the class Client method startup.

public void startup() {
    super.startup();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_RETURNED_HIBERNATE));
    // start HTTP Server
    if (this.isAutoConnect()) {
        if (this.connect()) {
            ClientStateManager.getInstance().fireState(IClientStateMonitor.CONNECTION_OK, "");
        } else {
            ClientStateManager.getInstance().fireState(IClientStateMonitor.CONNECTION_CLOSED, "");
        }
    } else {
        ClientStateManager.getInstance().fireState(IClientStateMonitor.CONNECTION_CLOSED, "");
        this.m_logger.info("Client is started but not connected with server ...");
    }
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 32 with IEventBroker

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

the class Client method shutdown.

public void shutdown() {
    super.shutdown();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_RETURNED_HIBERNATE));
    this.disconnect();
    ClientStateManager.getInstance().fireState(IClientStateMonitor.CONNECTION_CLOSED, "");
    this.m_logger.info("Client is shut down ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 33 with IEventBroker

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

the class Reject 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);
    if (m_rejectNumbers != null)
        m_rejectNumbers.clear();
    m_rejectNumbers = null;
    this.m_logger.info("Reject is shut down ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 34 with IEventBroker

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

the class Reject method receivedIdentifiedCall.

public void receivedIdentifiedCall(IEvent event) {
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    ICall incommingCall = (ICall) event.getData();
    String rejectAttribute = (incommingCall.getCaller().getAttribute(this.REJECT_ATTRIBUTE) == null ? "" : incommingCall.getCaller().getAttribute(this.REJECT_ATTRIBUTE).getValue());
    boolean isClir = incommingCall.getCaller().getPhoneNumber().isClired();
    // check if the caller has the attribute reject=yes
    if (rejectAttribute != null && rejectAttribute.equalsIgnoreCase(IJAMConst.ATTRIBUTE_VALUE_YES)) {
        incommingCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
        eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, incommingCall));
        this.m_logger.info("Call automatically rejected by caller reject attribute.");
        String msg = getRuntime().getI18nManagerFactory().getI18nManager().getString(getNamespace(), "reject_caller", "description", getLanguage());
        msg = StringUtils.replaceString(msg, "{%1}", Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, incommingCall.getCaller()));
        PropagationFactory.getInstance().fire(new Message(Message.INFO, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
        return;
    }
    // check if a special MSN should be rejected
    if (this.getRuntime().getRuleEngine().validate(this.ID, incommingCall.getMSN(), incommingCall.getCIP(), incommingCall.getCaller().getPhoneNumber())) {
        incommingCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
        eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, incommingCall));
        this.m_logger.info("Call automatically rejected by MSN " + incommingCall.getMSN().getMSN());
        String msg = getRuntime().getI18nManagerFactory().getI18nManager().getString(getNamespace(), "reject_msn", "description", getLanguage());
        msg = StringUtils.replaceString(msg, "{%1}", Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, incommingCall.getCaller()));
        PropagationFactory.getInstance().fire(new Message(Message.INFO, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
        return;
    }
    // check if all CLIR call should be rejected
    if (isClir && (this.m_configuration.getProperty(CONFIG_ALLCLIR) != null && this.m_configuration.getProperty(CONFIG_ALLCLIR).equalsIgnoreCase("true"))) {
        incommingCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
        eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, incommingCall));
        this.m_logger.info("Call automatically rejected because it was a CLIR call.");
        String msg = getRuntime().getI18nManagerFactory().getI18nManager().getString(getNamespace(), "reject_clir", "description", getLanguage());
        msg = StringUtils.replaceString(msg, "{%1}", Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, incommingCall.getCaller()));
        PropagationFactory.getInstance().fire(new Message(Message.INFO, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
        return;
    }
    if (this.isRejectNumber(Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, incommingCall.getCaller()))) {
        incommingCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
        eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, incommingCall));
        this.m_logger.info("Call automatically rejected by a blocked configured number.");
        String msg = getRuntime().getI18nManagerFactory().getI18nManager().getString(getNamespace(), "reject_config", "description", getLanguage());
        msg = StringUtils.replaceString(msg, "{%1}", Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, incommingCall.getCaller()));
        PropagationFactory.getInstance().fire(new Message(Message.INFO, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
        return;
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) Message(de.janrufmonitor.exception.Message) IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 35 with IEventBroker

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

the class MySqlAddressbook method startup.

@Override
public void startup() {
    super.startup();
    IEventBroker eb = getRuntime().getEventBroker();
    eb.register(this, eb.createEvent(IEventConst.EVENT_TYPE_RETURNED_HIBERNATE));
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

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