Package org.cybergarage.upnp

Examples of org.cybergarage.upnp.Argument


                                +actions[j].getName()+" with the Input argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");
                            valid=false;
                            break;
                        }
                        Argument a = new Argument();
            a.setDirection(Argument.IN);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
        names=actions[j].getOutputArgumentNames();
        if(names!=null && valid){
          for (int k = 0; k < names.length; k++) {
                        UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
                        if(variable==null){
                            /*
                             * //TODO Create a stict and relaxed behavior of the base driver which
                             * export as much it can or export only 100% complaint UPnPDevice service
                             */
                            Activator.logger.WARNING(
                                "UPnP Device that cotains serviceId="+id+" contains the action "
                                +actions[j].getName()+" with the Output argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");                           
                        }
            Argument a = new Argument();
            a.setDirection(Argument.OUT);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
                if(valid) {
            act.setArgumentList(al);
View Full Code Here


    }

    public boolean actionControlReceived(Action action){
            String actionName = action.getName();
            if (actionName.equals("GetLANAddress") == true) {
                    Argument timeArg = action.getArgument("LANAddress");
                    timeArg.setValue(serverInfo.getValue());
                    return true;
            }
            return false;
    }
View Full Code Here

        if (!getIP.postControlAction()) {
                _logger.info("couldn't get our external address");
                return null;
        }

        Argument ret = getIP.getOutputArgumentList().getArgument("NewExternalIPAddress");
        return InetAddress.getByName(ret.getValue());
    }
View Full Code Here

      // TODO: remove
      private String list(java.util.List l) {
          String s = "";
          for(Iterator i = l.iterator(); i.hasNext(); ) {
              Argument next = (Argument)i.next();
              s += next.getName() + "->" + next.getValue() + ", ";
          }
          return s;
      }
View Full Code Here

    ArgumentList alOut = upnpAct.getOutputArgumentList();
    String[] inArg = osgiAct.getInputArgumentNames();
    boolean invalidAction=false;
    if(inArg!=null){
      inArgs = new Properties();
      Argument arg;
      for (int j = 0; j < inArg.length; j++) {
        arg=alIn.getArgument(inArg[j]);
        try {
          inArgs.put(
              inArg[j],
              Converter.parseString(
                  arg.getValue(),
                  arg.getRelatedStateVariable().getDataType()
                  /*osgiServ.getStateVariable(arg.getRelatedStateVariableName()).getUPnPDataType()*/
              )
          );
        } catch (Exception e) {
          invalidAction=true;
          break;
        }
      }
    }
    Dictionary outArgs=null;
    try {
      outArgs=osgiAct.invoke(inArgs);
    } catch (UPnPException e) {
      //TODO Activator.logger.log()
      upnpAct.setStatus(e.getUPnPError_Code(),e.getMessage());
      invalidAction=true;
    } catch (Exception e){
      //TODO Activator.logger.log()
      upnpAct.setStatus(UPnPStatus.ACTION_FAILED);
      invalidAction=true;
    }   
    if(invalidAction)
      return exiting(false);
    String[] outArg = osgiAct.getOutputArgumentNames();
    if(outArg!=null){
      Argument arg;
      for (int j = 0; j < outArg.length; j++) {
        arg = alOut.getArgument(outArg[j]);               
        try {
          arg.setValue(
            Converter.toString(
                outArgs.get(outArg[j]),
                arg.getRelatedStateVariable().getDataType()
                /*osgiServ.getStateVariable(arg.getRelatedStateVariableName()).getUPnPDataType()*/
            )
          );
        } catch (Exception e) {
          e.printStackTrace();
View Full Code Here

                                +actions[j].getName()+" with the Input argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");
                            valid=false;
                            break;
                        }
                        Argument a = new Argument();
            a.setDirection(Argument.IN);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
        names=actions[j].getOutputArgumentNames();
        if(names!=null && valid){
          for (int k = 0; k < names.length; k++) {
                        UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
                        if(variable==null){
                            /*
                             * //TODO Create a stict and relaxed behavior of the base driver which
                             * export as much it can or export only 100% complaint UPnPDevice service
                             */
                            Activator.logger.WARNING(
                                "UPnP Device that cotains serviceId="+id+" contains the action "
                                +actions[j].getName()+" with the Output argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");                           
                        }
            Argument a = new Argument();
            a.setDirection(Argument.OUT);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
                if(valid) {
            act.setArgumentList(al);
View Full Code Here

    /*
   
    check if the way to obtain the UPnPStateVariabile is not too bad
   
    */
    Argument arg=act.getArgument(argumentName);
    if(arg==null){
      return null;
    }
    String varName=arg.getRelatedStateVariableName();
    return actsFather.getStateVariable(varName);
  }
View Full Code Here

      /*     
       * I assert that .getArgument(i) will return to me an Argument with only the name of the
       * Argument and not it's value. I'll set the associated value by myself and
       * Also I assert that the Argument are ordered
       */
      Argument argument=argsList.getArgument(i);
      String argumentName=argument.getName();
      //String relateVar=argument.getRelatedStateVariableName();
      UPnPStateVariable stateVar=this.getStateVariable(argumentName);
      String upnpType=stateVar.getUPnPDataType();
      /*Class javaClass=stateVar.getJavaDataType();*/
      //setting the value related to the input argument
      argument.setValue(Converter.toString(args.get(argumentName),upnpType));
    }
    act.setInArgumentValues(argsList);
    if(act.postControlAction()==true){
      //TODO check what happen if I don't have any output argument
      Properties outDic=new Properties();
      ArgumentList outArgs=act.getOutputArgumentList();
      if(outArgs.size()==0){
        return null;
      }
      for(int i=0;i<outArgs.size();i++){
        Argument argument=outArgs.getArgument(i);
        String argumentName=outArgs.getArgument(i).getName();
        //String relateVar=argument.getRelatedStateVariableName();
        UPnPStateVariable stateVar=getStateVariable(argumentName);
        //String javaType=stateVar.getJavaDataType().getName();
        //TODO rember to catch number exception
        String upnpType=stateVar.getUPnPDataType();
        outDic.put(argumentName,Converter.parseString(argument.getValue(),upnpType));
      }
      return outDic;
    }else{
            UPnPStatus controlStatus = act.getControlStatus();
            throw new UPnPException(controlStatus.getCode(),controlStatus.getDescription());
View Full Code Here

TOP

Related Classes of org.cybergarage.upnp.Argument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.