Search in sources :

Example 16 with IEventBroker

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

the class GeoCoding method receivedValidRule.

public void receivedValidRule(ICall call) {
    if (call == null)
        return;
    if (call.getCaller().getPhoneNumber().isClired())
        return;
    ICaller caller = call.getCaller();
    if (caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT) != null && caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG) != null) {
        this.m_logger.info("Call already set with geo data ...");
        return;
    }
    Point p = GeoCoder.getInstance().getCoordinates(caller.getAttributes());
    if (p != null) {
        caller.setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_ACC, Integer.toString(p.getAccurance())));
        caller.setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, Double.toString(p.getLatitude())));
        caller.setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, Double.toString(p.getLongitude())));
        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)) {
                ((IWriteCallRepository) icm).updateCall(call);
                this.m_logger.info("Call update sent with geocoding: " + call);
                eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_UPDATE_CALL, call));
            }
        }
    } else {
        this.m_logger.info("Geocoding not successfully for call: " + call);
    }
}
Also used : ICallManager(de.janrufmonitor.repository.ICallManager) ICaller(de.janrufmonitor.framework.ICaller) List(java.util.List) Point(de.janrufmonitor.util.math.Point) IEventBroker(de.janrufmonitor.framework.event.IEventBroker) Point(de.janrufmonitor.util.math.Point) IWriteCallRepository(de.janrufmonitor.repository.types.IWriteCallRepository)

Example 17 with IEventBroker

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

the class RunConsole method init.

public void init() {
    this.m_logger = LogManager.getLogManager().getLogger(IJAMConst.DEFAULT_LOGGER);
    this.m_logger.info("Starting ...");
    try {
        IEventBroker evtBroker = PIMRuntime.getInstance().getEventBroker();
        evtBroker.register(this);
        evtBroker.register(this, evtBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    } catch (NullPointerException e) {
        System.out.println("WARNING: Registering for call events failed. Please restart jAnrufmonitor...");
        System.out.println();
    }
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 18 with IEventBroker

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

the class Reject 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);
    this.m_logger.info("Reject is started ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 19 with IEventBroker

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

the class Sound method shutdown.

public void shutdown() {
    super.shutdown();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    this.m_logger.info("Sound is shut down ...");
}
Also used : IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 20 with IEventBroker

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

the class Sound method startup.

public void startup() {
    super.startup();
    IEventBroker eventBroker = this.getRuntime().getEventBroker();
    eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
    this.m_logger.info("Sound is started ...");
}
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