org.fourthline.cling.model.action.ActionInvocation Java Examples
The following examples show how to use
org.fourthline.cling.model.action.ActionInvocation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SOAPActionProcessorImpl.java From DroidDLNA with GNU General Public License v3.0 | 6 votes |
protected Element readActionResponseElement(Element bodyElement, ActionInvocation actionInvocation) { NodeList bodyChildren = bodyElement.getChildNodes(); for (int i = 0; i < bodyChildren.getLength(); i++) { Node bodyChild = bodyChildren.item(i); if (bodyChild.getNodeType() != Node.ELEMENT_NODE) continue; if (getUnprefixedNodeName(bodyChild).equals(actionInvocation.getAction().getName() + "Response")) { log.fine("Reading action response element: " + getUnprefixedNodeName(bodyChild)); return (Element) bodyChild; } } log.fine("Could not read action response element"); return null; }
Example #2
Source File: PullSOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
protected void readBodyResponse(XmlPullParser xpp, ActionInvocation actionInvocation) throws Exception { // We're in the "Body" tag int event; do { event = xpp.next(); if (event == XmlPullParser.START_TAG) { if (xpp.getName().equals("Fault")) { ActionException e = readFaultElement(xpp); actionInvocation.setFailure(e); return; } else if (xpp.getName().equals(actionInvocation.getAction().getName() + "Response")) { readActionOutputArguments(xpp, actionInvocation); return; } } } while (event != XmlPullParser.END_DOCUMENT && (event != XmlPullParser.END_TAG || !xpp.getName().equals("Body"))); throw new ActionException( ErrorCode.ACTION_FAILED, String.format("Action SOAP response do not contain %s element", actionInvocation.getAction().getName() + "Response" ) ); }
Example #3
Source File: OutgoingActionRequestMessage.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
public OutgoingActionRequestMessage(ActionInvocation actionInvocation, URL controlURL) { this(actionInvocation.getAction(), new UpnpRequest(UpnpRequest.Method.POST, controlURL)); // For proxy remote invocations, pass through the user agent header if (actionInvocation instanceof RemoteActionInvocation) { RemoteActionInvocation remoteActionInvocation = (RemoteActionInvocation) actionInvocation; if (remoteActionInvocation.getRemoteClientInfo() != null && remoteActionInvocation.getRemoteClientInfo().getRequestUserAgent() != null) { getHeaders().add( UpnpHeader.Type.USER_AGENT, new UserAgentHeader(remoteActionInvocation.getRemoteClientInfo().getRequestUserAgent()) ); } } else if (actionInvocation.getClientInfo() != null) { getHeaders().putAll(actionInvocation.getClientInfo().getRequestHeaders()); } }
Example #4
Source File: UpnpControlSet.java From HPlayer with Apache License 2.0 | 6 votes |
/** * 设置静音 */ public void setDeviceMute(boolean mute) { ActionCallback setMute = new SetMute(renderingControlService, mute) { @Override public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) { onFailureCallBack(SET_MUTE, arg2); } @Override public void success(ActionInvocation invocation) { onSuccessCallBack(SET_MUTE); } }; mUpnpService.getControlPoint().execute(setMute); }
Example #5
Source File: RecoveringSOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
public void readBody(ActionRequestMessage requestMessage, ActionInvocation actionInvocation) throws UnsupportedDataException { try { super.readBody(requestMessage, actionInvocation); } catch (UnsupportedDataException ex) { // Can't recover from this if (!requestMessage.isBodyNonEmptyString()) throw ex; log.warning("Trying to recover from invalid SOAP XML request: " + ex); String body = getMessageBody(requestMessage); // TODO: UPNP VIOLATION: TwonkyMobile sends unencoded '&' in SetAVTransportURI action calls: // <CurrentURI>http://192.168.1.14:56923/content/12a470d854dbc6887e4103e3140783fd.wav?profile_id=0&convert=wav</CurrentURI> String fixedBody = XmlPullParserUtils.fixXMLEntities(body); try { // Try again, if this fails, we are done... requestMessage.setBody(fixedBody); super.readBody(requestMessage, actionInvocation); } catch (UnsupportedDataException ex2) { handleInvalidMessage(actionInvocation, ex, ex2); } } }
Example #6
Source File: Browse.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
/** * @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used. */ public Browse(Service service, String objectID, BrowseFlag flag, String filter, long firstResult, Long maxResults, SortCriterion... orderBy) { super(new ActionInvocation(service.getAction("Browse"))); log.fine("Creating browse action for object ID: " + objectID); getActionInvocation().setInput("ObjectID", objectID); getActionInvocation().setInput("BrowseFlag", flag.toString()); getActionInvocation().setInput("Filter", filter); getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult)); getActionInvocation().setInput("RequestedCount", new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults) ); getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy)); }
Example #7
Source File: PortMappingAdd.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
protected PortMappingAdd(Service service, ControlPoint controlPoint, PortMapping portMapping) { super(new ActionInvocation(service.getAction("AddPortMapping")), controlPoint); this.portMapping = portMapping; getActionInvocation().setInput("NewExternalPort", portMapping.getExternalPort()); getActionInvocation().setInput("NewProtocol", portMapping.getProtocol()); getActionInvocation().setInput("NewInternalClient", portMapping.getInternalClient()); getActionInvocation().setInput("NewInternalPort", portMapping.getInternalPort()); getActionInvocation().setInput("NewLeaseDuration", portMapping.getLeaseDurationSeconds()); getActionInvocation().setInput("NewEnabled", portMapping.isEnabled()); if (portMapping.hasRemoteHost()) getActionInvocation().setInput("NewRemoteHost", portMapping.getRemoteHost()); if (portMapping.hasDescription()) getActionInvocation().setInput("NewPortMappingDescription", portMapping.getDescription()); }
Example #8
Source File: GetStatusInfo.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
@Override public void success(ActionInvocation invocation) { try { Connection.Status status = Connection.Status.valueOf(invocation.getOutput("NewConnectionStatus").getValue().toString()); Connection.Error lastError = Connection.Error.valueOf(invocation.getOutput("NewLastConnectionError").getValue().toString()); success(new Connection.StatusInfo(status, (UnsignedIntegerFourBytes) invocation.getOutput("NewUptime").getValue(), lastError)); } catch (Exception ex) { invocation.setFailure( new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid status or last error string: " + ex, ex ) ); failure(invocation, null); } }
Example #9
Source File: PrepareForConnection.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public PrepareForConnection(Service service, ControlPoint controlPoint, ProtocolInfo remoteProtocolInfo, ServiceReference peerConnectionManager, int peerConnectionID, ConnectionInfo.Direction direction) { super(new ActionInvocation(service.getAction("PrepareForConnection")), controlPoint); getActionInvocation().setInput("RemoteProtocolInfo", remoteProtocolInfo.toString()); getActionInvocation().setInput("PeerConnectionManager", peerConnectionManager.toString()); getActionInvocation().setInput("PeerConnectionID", peerConnectionID); getActionInvocation().setInput("Direction", direction.toString()); }
Example #10
Source File: GetPortMappingEntryAction.java From portmapper with GNU General Public License v3.0 | 5 votes |
@Override public PortMapping convert(final ActionInvocation<RemoteService> response) { final Protocol protocol = Protocol.getProtocol(getStringValue(response, "NewProtocol")); final String remoteHost = getStringValue(response, "NewRemoteHost"); final int externalPort = getIntValue(response, "NewExternalPort"); final String internalClient = getStringValue(response, "NewInternalClient"); final int internalPort = getIntValue(response, "NewInternalPort"); final String description = getStringValue(response, "NewPortMappingDescription"); final boolean enabled = getBooleanValue(response, "NewEnabled"); final long leaseDuration = getLongValue(response, "NewLeaseDuration"); return new PortMapping(protocol, remoteHost, externalPort, internalClient, internalPort, description, enabled, leaseDuration); }
Example #11
Source File: SOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public void readBody(ActionResponseMessage responseMsg, ActionInvocation actionInvocation) throws UnsupportedDataException { log.fine("Reading body of " + responseMsg + " for: " + actionInvocation); if (log.isLoggable(Level.FINER)) { log.finer("===================================== SOAP BODY BEGIN ============================================"); log.finer(responseMsg.getBodyString()); log.finer("-===================================== SOAP BODY END ============================================"); } String body = getMessageBody(responseMsg); try { DocumentBuilderFactory factory = createDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); documentBuilder.setErrorHandler(this); Document d = documentBuilder.parse(new InputSource(new StringReader(body))); Element bodyElement = readBodyElement(d); ActionException failure = readBodyFailure(d, bodyElement); if (failure == null) { readBodyResponse(d, bodyElement, responseMsg, actionInvocation); } else { actionInvocation.setFailure(failure); } } catch (Exception ex) { throw new UnsupportedDataException("Can't transform message payload: " + ex, ex, body); } }
Example #12
Source File: SetMuteCalllback.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void success(ActionInvocation paramActionInvocation) { Log.e("set mute success", "set mute success"); if (desiredMute) { desiredMute = false; } Message localMessage = new Message(); localMessage.what = DMCControlMessage.SETMUTESUC; Bundle localBundle = new Bundle(); localBundle.putBoolean("mute", desiredMute); localMessage.setData(localBundle); this.handler.sendMessage(localMessage); }
Example #13
Source File: SOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
protected void writeActionInputArguments(Document d, Element actionRequestElement, ActionInvocation actionInvocation) { for (ActionArgument argument : actionInvocation.getAction().getInputArguments()) { log.fine("Writing action input argument: " + argument.getName()); String value = actionInvocation.getInput(argument) != null ? actionInvocation.getInput(argument).toString() : ""; XMLUtil.appendNewElement(d, actionRequestElement, argument.getName(), value); } }
Example #14
Source File: SetAVTransportURI.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public SetAVTransportURI(UnsignedIntegerFourBytes instanceId, Service service, String uri, String metadata) { super(new ActionInvocation(service.getAction("SetAVTransportURI"))); log.fine("Creating SetAVTransportURI action for URI: " + uri); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("CurrentURI", uri); getActionInvocation().setInput("CurrentURIMetaData", metadata); }
Example #15
Source File: AddMessage.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public AddMessage(Service service, Message message) { super(new ActionInvocation(service.getAction("AddMessage"))); getActionInvocation().setInput("MessageID", Integer.toString(message.getId())); getActionInvocation().setInput("MessageType", mimeType.toString()); getActionInvocation().setInput("Message", message.toString()); }
Example #16
Source File: GetTransportInfoCallback.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@Override public void received(ActionInvocation paramActionInvocation, TransportInfo paramTransportInfo) { Log.e("GetTransportInfoCallback", "" + paramTransportInfo.getCurrentTransportState()); Log.e("GetTransportInfoCallback", "" + paramTransportInfo.getCurrentTransportStatus()); Log.e("isOnlyGetState", Boolean.toString(this.isOnlyGetState)); handler.sendEmptyMessage(DMCControlMessage.SETURL); //TODO //XGF // if (!this.isOnlyGetState) // if (paramTransportInfo.getCurrentTransportState() == // TransportState.NO_MEDIA_PRESENT // || paramTransportInfo.getCurrentTransportState() == // TransportState.STOPPED // || paramTransportInfo.getCurrentTransportState() == // TransportState.PAUSED_PLAYBACK) { // this.handler.sendEmptyMessage(DMCControlMessage.SETURL); // } else if (paramTransportInfo.getCurrentTransportState() == // TransportState.PLAYING) { // this.handler.sendEmptyMessage(DMCControlMessage.STOP); // } else if (paramTransportInfo.getCurrentTransportStatus() == // TransportStatus.CUSTOM) { // this.handler.sendEmptyMessage(DMCControlMessage.CONNECTIONFAILED); // } else if (paramTransportInfo.getCurrentTransportState() == // TransportState.NO_MEDIA_PRESENT) { // this.handler.sendEmptyMessage(DMCControlMessage.REMOTE_NOMEDIA); // } }
Example #17
Source File: SOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
protected void readBodyResponse(Document d, Element bodyElement, ActionResponseMessage message, ActionInvocation actionInvocation) throws Exception { Element actionResponse = readActionResponseElement(bodyElement, actionInvocation); readActionOutputArguments(actionResponse, actionInvocation); }
Example #18
Source File: AddMessage.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public AddMessage(Service service, Message message) { super(new ActionInvocation(service.getAction("AddMessage"))); getActionInvocation().setInput("MessageID", Integer.toString(message.getId())); getActionInvocation().setInput("MessageType", mimeType.toString()); getActionInvocation().setInput("Message", message.toString()); }
Example #19
Source File: RecoveringSOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public void readBody(ActionResponseMessage responseMsg, ActionInvocation actionInvocation) throws UnsupportedDataException { try { super.readBody(responseMsg, actionInvocation); } catch (UnsupportedDataException ex) { // Can't recover from this if (!responseMsg.isBodyNonEmptyString()) throw ex; log.warning("Trying to recover from invalid SOAP XML response: " + ex); String body = getMessageBody(responseMsg); // TODO: UPNP VIOLATION: TwonkyMobile doesn't properly encode '&' String fixedBody = XmlPullParserUtils.fixXMLEntities(body); // TODO: UPNP VIOLATION: YAMAHA NP-S2000 does not terminate XML with </s:Envelope> // (at least for action GetPositionInfo) if (fixedBody.endsWith("</s:Envelop")) { fixedBody += "e>"; } try { // Try again, if this fails, we are done... responseMsg.setBody(fixedBody); super.readBody(responseMsg, actionInvocation); } catch (UnsupportedDataException ex2) { handleInvalidMessage(actionInvocation, ex, ex2); } } }
Example #20
Source File: Browse.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public boolean receivedRaw(ActionInvocation actionInvocation, BrowseResult browseResult) { /* if (log.isLoggable(Level.FINER)) { log.finer("-------------------------------------------------------------------------------------"); log.finer("\n" + XML.pretty(browseResult.getDidl())); log.finer("-------------------------------------------------------------------------------------"); } */ return true; }
Example #21
Source File: SOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
protected void writeBodyRequest(Document d, Element bodyElement, ActionRequestMessage message, ActionInvocation actionInvocation) throws Exception { Element actionRequestElement = writeActionRequestElement(d, bodyElement, message, actionInvocation); writeActionInputArguments(d, actionRequestElement, actionInvocation); message.setBody(toString(d)); }
Example #22
Source File: GetVolumeCallback.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void received(ActionInvocation paramActionInvocation, int paramInt) { Log.e("getcurrentvolume", "" + paramInt); Message localMessage = new Message(); localMessage.what = DMCControlMessage.SETVOLUME; Bundle localBundle = new Bundle(); localBundle.putLong("getVolume", paramInt); localBundle.putInt("isSetVolume", isSetVolumeFlag); localMessage.setData(localBundle); handler.sendMessage(localMessage); }
Example #23
Source File: ActionCallback.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
protected String createDefaultFailureMessage(ActionInvocation invocation, UpnpResponse operation) { String message = "Error: "; final ActionException exception = invocation.getFailure(); if (exception != null) { message = message + exception.getMessage(); } if (operation != null) { message = message + " (HTTP response was: " + operation.getResponseDetails() + ")"; } return message; }
Example #24
Source File: GetVolumeCallback.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void failure(ActionInvocation paramActionInvocation, UpnpResponse paramUpnpResponse, String paramString) { if (this.type == 1) { this.handler.sendEmptyMessage(DMCControlMessage.PLAYIMAGEFAILED); } else if (this.type == 2) { this.handler.sendEmptyMessage(DMCControlMessage.PLAYAUDIOFAILED); } else if (this.type == 3) { this.handler.sendEmptyMessage(DMCControlMessage.PLAYVIDEOFAILED); } }
Example #25
Source File: SOAPActionProcessorImpl.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void writeBody(ActionResponseMessage responseMessage, ActionInvocation actionInvocation) throws UnsupportedDataException { log.fine("Writing body of " + responseMessage + " for: " + actionInvocation); try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().newDocument(); Element body = writeBodyElement(d); if (actionInvocation.getFailure() != null) { writeBodyFailure(d, body, responseMessage, actionInvocation); } else { writeBodyResponse(d, body, responseMessage, actionInvocation); } if (log.isLoggable(Level.FINER)) { log.finer("===================================== SOAP BODY BEGIN ============================================"); log.finer(responseMessage.getBodyString()); log.finer("-===================================== SOAP BODY END ============================================"); } } catch (Exception ex) { throw new UnsupportedDataException("Can't transform message payload: " + ex, ex); } }
Example #26
Source File: PortMappingDelete.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
protected PortMappingDelete(Service service, ControlPoint controlPoint, PortMapping portMapping) { super(new ActionInvocation(service.getAction("DeletePortMapping")), controlPoint); this.portMapping = portMapping; getActionInvocation().setInput("NewExternalPort", portMapping.getExternalPort()); getActionInvocation().setInput("NewProtocol", portMapping.getProtocol()); if (portMapping.hasRemoteHost()) getActionInvocation().setInput("NewRemoteHost", portMapping.getRemoteHost()); }
Example #27
Source File: GetVolume.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public void success(ActionInvocation invocation) { boolean ok = true; int currentVolume = 0; try { currentVolume = Integer.valueOf(invocation.getOutput("CurrentVolume").getValue().toString()); // UnsignedIntegerTwoBytes... } catch (Exception ex) { invocation.setFailure( new ActionException(ErrorCode.ACTION_FAILED, "Can't parse ProtocolInfo response: " + ex, ex) ); failure(invocation, null); ok = false; } if (ok) received(invocation, currentVolume); }
Example #28
Source File: SOAPActionProcessorImpl.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void readActionInputArguments(Element actionRequestElement, ActionInvocation actionInvocation) throws ActionException { actionInvocation.setInput( readArgumentValues( actionRequestElement.getChildNodes(), actionInvocation.getAction().getInputArguments() ) ); }
Example #29
Source File: SOAPActionProcessorImpl.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
protected void writeActionInputArguments(Document d, Element actionRequestElement, ActionInvocation actionInvocation) { for (ActionArgument argument : actionInvocation.getAction().getInputArguments()) { log.fine("Writing action input argument: " + argument.getName()); String value = actionInvocation.getInput(argument) != null ? actionInvocation.getInput(argument).toString() : ""; XMLUtil.appendNewElement(d, actionRequestElement, argument.getName(), value); } }
Example #30
Source File: GetPositionInfoCallback.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void received(ActionInvocation paramActionInvocation, PositionInfo paramPositionInfo) { Bundle localBundle = new Bundle(); localBundle.putString("TrackDuration", paramPositionInfo.getTrackDuration()); localBundle.putString("RelTime", paramPositionInfo.getRelTime()); Intent localIntent = new Intent(Action.PLAY_UPDATE); localIntent.putExtras(localBundle); activity.sendBroadcast(localIntent); }