Search in sources :

Example 6 with CallType

use of org.openhab.library.tel.types.CallType in project openhab1-addons by openhab.

the class FreeswitchBinding method handleNewCallEvent.

/**
     * Handle Answer or Media (ringing) events and add an entry to our cache
     *
     * @param event
     */
private void handleNewCallEvent(EslEvent event) {
    String uuid = getHeader(event, UUID);
    logger.debug("Adding Call with uuid " + uuid);
    Channel channel = new Channel(event);
    // we should not get duplicate events, but lets be safe
    if (eventCache.containsKey(uuid)) {
        return;
    }
    eventCache.put(uuid, channel);
    itemMap.put(uuid, new LinkedList<FreeswitchBindingConfig>());
    CallType call = channel.getCall();
    logger.debug("new call to : {} from : {}", call.getDestNum(), call.getOrigNum());
    for (FreeswitchBindingProvider provider : providers) {
        for (String itemName : provider.getItemNames()) {
            FreeswitchBindingConfig config = provider.getFreeswitchBindingConfig(itemName);
            if (config.getType() == FreeswitchBindingType.ACTIVE) {
                /*
                     * Add the item if it is filtered and matches or if it is
                     * un-filtered and inbound
                     */
                if ((config.filtered() && matchCall(channel, config.getArgument())) || (!config.filtered() && isInboundCall(channel))) {
                    itemMap.get(uuid).add(config);
                    newCallItemUpdate(config, channel);
                }
            }
        }
    }
}
Also used : CallType(org.openhab.library.tel.types.CallType) FreeswitchBindingProvider(org.openhab.binding.freeswitch.FreeswitchBindingProvider)

Aggregations

CallType (org.openhab.library.tel.types.CallType)6 CallItem (org.openhab.library.tel.items.CallItem)4 DecimalType (org.openhab.core.library.types.DecimalType)3 StringType (org.openhab.core.library.types.StringType)3 Calendar (java.util.Calendar)2 ColorItem (org.openhab.core.library.items.ColorItem)2 ContactItem (org.openhab.core.library.items.ContactItem)2 DateTimeItem (org.openhab.core.library.items.DateTimeItem)2 DimmerItem (org.openhab.core.library.items.DimmerItem)2 LocationItem (org.openhab.core.library.items.LocationItem)2 NumberItem (org.openhab.core.library.items.NumberItem)2 RollershutterItem (org.openhab.core.library.items.RollershutterItem)2 SwitchItem (org.openhab.core.library.items.SwitchItem)2 DateTimeType (org.openhab.core.library.types.DateTimeType)2 HSBType (org.openhab.core.library.types.HSBType)2 PercentType (org.openhab.core.library.types.PercentType)2 PointType (org.openhab.core.library.types.PointType)2 State (org.openhab.core.types.State)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1