示例#1
0
 public boolean postControlAction() {
   // Thanks for Giordano Sassaroli <*****@*****.**> (08/30/03)
   ArgumentList actionArgList = getArgumentList();
   ArgumentList actionInputArgList = getInputArgumentList();
   ActionRequest ctrlReq = new ActionRequest();
   ctrlReq.setRequest(this, actionInputArgList);
   if (Debug.isOn() == true) ctrlReq.print();
   ActionResponse ctrlRes = ctrlReq.post();
   if (Debug.isOn() == true) ctrlRes.print();
   setControlResponse(ctrlRes);
   // Thanks for Dimas <*****@*****.**> and Stefano Lenzi
   // <*****@*****.**> (07/09/04)
   int statCode = ctrlRes.getStatusCode();
   setStatus(statCode);
   if (ctrlRes.isSuccessful() == false) return false;
   ArgumentList outArgList = ctrlRes.getResponse();
   try {
     actionArgList.setResArgs(outArgList);
   } catch (IllegalArgumentException ex) {
     setStatus(
         UPnPStatus.INVALID_ARGS, "Action succesfully delivered but invalid arguments returned.");
     return false;
   }
   return true;
 }
示例#2
0
 private void clearOutputAgumentValues() {
   ArgumentList allArgList = getArgumentList();
   int allArgCnt = allArgList.size();
   for (int n = 0; n < allArgCnt; n++) {
     Argument arg = allArgList.getArgument(n);
     if (arg.isOutDirection() == false) continue;
     arg.setValue("");
   }
 }
示例#3
0
 /** @deprecated */
 public void set(ArgumentList inArgList) {
   int nInArgs = inArgList.size();
   for (int n = 0; n < nInArgs; n++) {
     Argument inArg = inArgList.getArgument(n);
     String inArgName = inArg.getName();
     Argument arg = getArgument(inArgName);
     if (arg == null) continue;
     arg.setValue(inArg.getValue());
   }
 }
示例#4
0
 void updateArgumentList(TreeNode parentNode, Action action) {
   ArgumentList argList = action.getArgumentList();
   int nArguments = argList.size();
   for (int n = 0; n < nArguments; n++) {
     Argument arg = argList.getArgument(n);
     String argName = arg.getName() + "(" + arg.getDirection() + ")";
     TreeNode argNode = new TreeNode(argName);
     argNode.setUserData(arg);
     parentNode.add(argNode);
   }
 }
示例#5
0
 public Argument getArgument(String name) {
   ArgumentList argList = getArgumentList();
   int nArgs = argList.size();
   for (int n = 0; n < nArgs; n++) {
     Argument arg = argList.getArgument(n);
     String argName = arg.getName();
     if (argName == null) continue;
     if (name.equals(argName) == true) return arg;
   }
   return null;
 }
示例#6
0
 public ArgumentList getOutputArgumentList() {
   ArgumentList allArgList = getArgumentList();
   int allArgCnt = allArgList.size();
   ArgumentList argList = new ArgumentList();
   for (int n = 0; n < allArgCnt; n++) {
     Argument arg = allArgList.getArgument(n);
     if (arg.isOutDirection() == false) continue;
     argList.add(arg);
   }
   return argList;
 }
示例#7
0
 public void print() {
   Debug.message("Action : " + getName());
   ArgumentList argList = getArgumentList();
   int nArgs = argList.size();
   for (int n = 0; n < nArgs; n++) {
     Argument arg = argList.getArgument(n);
     String name = arg.getName();
     String value = arg.getValue();
     String dir = arg.getDirection();
     Debug.message(" [" + n + "] = " + dir + ", " + name + ", " + value);
   }
 }
示例#8
0
 public ArgumentList getArgumentList() {
   ArgumentList argumentList = new ArgumentList();
   Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME);
   if (argumentListNode == null) return argumentList;
   int nodeCnt = argumentListNode.getNNodes();
   for (int n = 0; n < nodeCnt; n++) {
     Node node = argumentListNode.getNode(n);
     if (Argument.isArgumentNode(node) == false) continue;
     Argument argument = new Argument(getServiceNode(), node);
     argumentList.add(argument);
   }
   return argumentList;
 }
示例#9
0
 /**
  * Set all the Argument which are Output Argoument to the given value in the argument list
  *
  * @param outArgList
  */
 public void setResArgs(ArgumentList outArgList) {
   int nArgs = size();
   for (int n = 0; n < nArgs; n++) {
     Argument arg = getArgument(n);
     if (arg.isOutDirection()) {
       String argName = arg.getName();
       Argument outArg = outArgList.getArgument(argName);
       if (outArg == null)
         throw new IllegalArgumentException("Argument \"" + argName + "\" missing.");
       arg.setValue(outArg.getValue());
     }
   }
 }
示例#10
0
 public void setArgumentList(ArgumentList al) {
   Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME);
   if (argumentListNode == null) {
     argumentListNode = new Node(ArgumentList.ELEM_NAME);
     getActionNode().addNode(argumentListNode);
   } else {
     argumentListNode.removeAllNodes();
   }
   Iterator<Argument> i = al.iterator();
   while (i.hasNext()) {
     Argument a = i.next();
     a.setService(getService());
     argumentListNode.addNode(a.getArgumentNode());
   }
 }