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