Channel Service page

This page shows how to use channel service.


var scanObj = null;
var channelserviceObj;
var queryConditions = new Array();
var requestedProperties = new Array();

// Channel service obj
ChannelService = function ()
{
  var opId = null;
  try {
    this.cs = toi.channelService;
    this.operationManager = toi.channelService.getOperationManager();
  }
  catch (e) {
    DumpLog ("create channelService" + e);
  }

  this.runQuery = function (queryConditions,requestedProperties)
  {
    try {
      opId = this.operationManager.createOperation("runQuery");
      this.cs.runQuery(opId,queryConditions,requestedProperties);
    }
    catch (e) {
      DumpLog("runQuery() Caught exception:" +e);
    }
  };

  this.onOperationResult = function (event)
  {
    if (event.operation.userData == "runQuery") {
      channelInfoSequence =
          toi.channelService.getChannelInfoResult(event.operation.id);
      dvbChannelList.clearOptions();

      var dvbCTvChannels = "";
      var dvbCTvChannelsNames = "";
      for (var i in channelInfoSequence) {
        dvbChannelList.addOption(i,channelInfoSequence[i].name);
        for (var j in channelInfoSequence[i].properties) {
          DumpLog("channel-"+i+" properties-" +j+ " " +
                   channelInfoSequence[i].properties[j].id +" value: "+
                   channelInfoSequence[i].properties[j].value);
        }

        var dsdUri = getPropertyValue(channelInfoSequence[i].properties,
                     toi.consts.ToiChannelService.PROPERTY_URI);
        dvbCTvChannels += "," + dsdUri;
        dvbCTvChannelsNames += "," + channelInfoSequence[i].name;
      }

      toi.informationService.setObject("dvbCTvChannels",
         dvbCTvChannels, toi.informationService.STORAGE_PERMANENT);
      toi.informationService.setObject("dvbCTvChannelsNames",
         dvbCTvChannelsNames, toi.informationService.STORAGE_PERMANENT);
    }
  };

  this.onChannelsAdded = function ()
  {
    DumpLog("Received onChannelsAdded event");
    scanStateLabel.setText("Note: New service to add");
  };

  this.onChannelsRemoved = function ()
  {
    DumpLog("Received onChannelsRemoved event");
    scanStateLabel.setText("Note: New service to remove");
  };

  this.onChannelsChanged = function ()
  {
    DumpLog("Received onChannelsChanged event");
    scanStateLabel.setText("Note: New service for update");
  };

  this.addEventListener = function (event)
  {
    this.operationManager.addEventListener
      (this.operationManager.ON_OPERATION_RESULT,
       this.onOperationResult);
    toi.channelService.addEventListener
     (toi.channelService.ON_CHANNELS_ADDED, this.onChannelsAdded);
    toi.channelService.addEventListener
     (toi.channelService.ON_CHANNELS_REMOVED, this.onChannelsRemoved);
    toi.channelService.addEventListener
      (toi.channelService.ON_CHANNELS_CHANGED , this.onChannefunction getFrontends()
{
  var frontends = new Array();
  frontends= toi.frontendService.getFrontends();
  var frontendsValue = "";
  for (var i in frontends) {
    frontendsValue += i;
    frontendsValue += "  ";
  }
  frontendListResult.setText(frontendsValue);
}