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 ...");
}
}
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 ...");
}
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 ...");
}
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;
}
}
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));
}
Aggregations