0 Replies Latest reply: May 21, 2009 1:39 AM by 843851 RSS

    Not able to retrieve Service information from SIManager

    843851
      Hi,

      I m using ADB 7822C Developer STB. I 've been trying to retreive Service Info from SIManager.

      The code used is given below.

      {color:#0000ff}public class ChangeChannelApps implements UserEventListener, Xlet, ServiceContextListener
      {

      private XletContext context;


      Service s;
      ServiceContextFactory factory = ServiceContextFactory.getInstance();
      ServiceContext sc;
      SIManager simanager=SIManager.createInstance();
      ServiceList list = null;



      public void initXlet(XletContext context) throws XletStateChangeException
      {
      /* We add the keys for which we want the events to take place*/
      this.context = context;
      UserEventRepository uer = new UserEventRepository("CCA");
      uer.addKey(HRcEvent.VK_LEFT);
      uer.addKey(HRcEvent.VK_RIGHT);
      EventManager.getInstance().addUserEventListener(this, uer);



      try
      {

      sc = factory.getServiceContext(context);

      }
      catch (ServiceContextException sce)
      {
      System.out.println("Not enough resources to create a new service context. Exiting...");
      return;
      }


      }

      public void startXlet() throws XletStateChangeException
      {

      if(sc==null)
      {
      try
      {
      ServiceContext[] ctxs=factory.getServiceContexts();
      if(ctxs.length>0)
      {
      sc=ctxs[0];
      }
      else
      sc=factory.createServiceContext();
      }
      catch (Exception e)
      {
      return;
      }
      sc.addListener(this);
      }

      }

      public void pauseXlet()
      {

      }
      public void destroyXlet(boolean unconditional) throws XletStateChangeException
      {
      }

      public void receiveServiceContextEvent(ServiceContextEvent event)
      {
      System.out.println("Service context has generated an event - " + event);
      }
      public void userEventReceived(UserEvent e)
      {       
      try{
      list = simanager.filterServices(null);
      }catch(Exception exception){
      //
      }
      if (e.getType() != KeyEvent.KEY_PRESSED)
      {
      return;
      }
      int key = e.getCode();
      Service currentService= sc.getService();

      display("list contents", 10, 50, 800, 25);
      display("SI List Size " + list.size(), 10, 25, 800, 25);
      display("index of current service" + list.indexOf(currentService), 10, 50, 800, 25);
      display("list0 service name" + list.getService(0).getName(), 10, 75, 800, 25);
      display("list0 service Locator" + list.getService(0).getLocator(), 10, 100, 800, 25);
      display("list0 service Type" + list.getService(0).getServiceType(), 10, 125, 800, 25);

      display("list1 service name" + list.getService(1).getName(), 10, 150, 800, 25);
      display("list1 service Locator" + list.getService(1).getLocator(), 10, 175, 800, 25);
      display("list1 service Type" + list.getService(1).getServiceType(), 10, 200, 800, 25);

      display("list2 service name" + list.getService(2).getName(), 10, 225, 800, 25);
      display("list2 service Locator" + list.getService(2).getLocator(), 10, 250, 800, 25);
      display("list2 service Type" + list.getService(2).getServiceType(), 10, 275, 800, 25);

      display("list3 service name" + list.getService(3).getName(), 10, 300, 800, 25);
      display("list3 service Locator" + list.getService(3).getLocator(), 10, 325, 800, 25);
      display("list3 service Type" + list.getService(3).getServiceType(), 10, 350, 800, 25);

      display("Current Service name" + currentService.getName(), 10, 375, 800, 25);
      display("Current Service Locator" + currentService.getLocator().toString(), 10, 400, 800, 25);
      display("Current Service Type" + currentService.getServiceType().toString(), 10, 425, 800, 25);



      }

      private void display(String content, int x, int y, int width, int height){
      HScene rootContainer = HSceneFactory.getInstance().getDefaultHScene();
      HStaticText text = new HStaticText(content, x, y, width, height);
      Font font = new Font("Arial", Font.PLAIN,20);
      text.setBackground(Color.white);
      text.setForeground(Color.black);
      text.setFont(font);
      text.setBackgroundMode(HVisible.BACKGROUND_FILL);
      rootContainer.add(text, 0);
      rootContainer.setVisible(true);
      }

      }{color}

      The output i get on triggering a left key event is

      {color:#ff6600}Name : probe-core-service
      Locator : ocap://0x10000
      Service Type : OCAP_ABSTRACT_SERVICE

      Name : probe-menu-service
      Locator : ocap://0x10001
      Service Type : OCAP_ABSTRACT_SERVICE

      Name : probe-scan-service
      Locator : ocap://0x10002
      Service Type : OCAP_ABSTRACT_SERVICE

      Name : probe-taskman-service
      Locator : ocap://0x10003
      Service Type : OCAP_ABSTRACT_SERVICE{color}

      Are these some error messages or some information ?

      Is there any way to retreive the service info other than the one using SIManager???

      Thanks in advance
      RMN