/// <summary> /// Allows the caller to incrementally browse the native hierarchy of the Content Directory objects exposed by the <see cref="ContentDirectoryService"/>, including /// information listing the classes of objects available in any particular object container. /// </summary> /// <param name="objectId"> /// Object currently being browsed. An ObjectID value of zero corresponds to the root object of the Content Directory. /// </param> /// <param name="browseFlag"> /// Specifies a browse option to be used for browsing the Content Directory. /// </param> /// <param name="filter"> /// The comma-separated list of property specifiers (including namespaces) indicates which metadata properties are to be /// returned in the results from browsing or searching. /// </param> /// <param name="startingIndex"> /// Starting zero based offset to enumerate children under the container specified by <paramref name="objectId"/>. Must be 0 if <paramref name="browseFlag"/> is equal /// to <see cref="BrowseFlag.BrowseMetadata"/>. /// </param> /// <param name="requestedCount"> /// Requested number of entries under the object specified by <paramref name="objectId"/>. The value '0' indicates request all entries. /// </param> /// <param name="sortCriteria"> /// A CSV list of signed property names, where signed means preceded by ‘+’ or ‘-’ sign. The ‘+’ and ‘-’Indicate the sort is in ascending or descending order, /// respectively, with regard to the value of its associated property. Properties appear in the list in order of descending sort priority. /// </param> /// <exception cref="WebException"> /// An error occurred when sending request to service. /// </exception> /// <exception cref="FormatException"> /// Received result is in a bad format. /// </exception> /// <exception cref="UPnPServiceException"> /// An internal service error occurred when executing request. /// </exception> public async Task <BrowseResult> BrowseAsync(string objectId, BrowseFlag browseFlag, string filter, int startingIndex, int requestedCount, string sortCriteria) { var arguments = new Dictionary <string, object> { { "ObjectID", objectId }, { "BrowseFlag", browseFlag }, { "Filter", filter }, { "StartingIndex", startingIndex }, { "RequestedCount", requestedCount }, { "SortCriteria", sortCriteria }, }; var response = await this.InvokeActionAsync("Browse", arguments); var resultXml = response["Result"]; var mediaObjects = ParseMediaObjects(resultXml); var result = new BrowseResult { Result = mediaObjects, NumberReturned = Convert.ToInt32(response["NumberReturned"]), TotalMatches = Convert.ToInt32(response["TotalMatches"]), UpdateId = Convert.ToUInt32(response["UpdateId"]) }; return(result); }
protected override string Browse(string objectId, BrowseFlag browseFlag, string filter, int startIndex, int requestCount, string sortCriteria, out int numberReturned, out int totalMatches, out string updateId) { var serializer = new ResultsSerializer(this.serializer); var @object = GetObject(objectId); if (browseFlag == BrowseFlag.BrowseDirectChildren) { numberReturned = VisitChildren(child => serializer.Serialize(child), @object.Id, startIndex, requestCount, sortCriteria, out totalMatches); } else { serializer.Serialize(@object); numberReturned = 1; totalMatches = 1; } updateId = "0"; return(serializer.ToString()); }
internal void Browse(Dictionary <string, string> headers, string objectID, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out string result, out string numberReturned, out string totalMatches) { string host = headers.ContainsKey("host") ? "http://" + headers["host"] : string.Empty; StringBuilder sb = new StringBuilder(); HashSet <string> filterSet = null; if (filter != "*") { filterSet = new HashSet <string>(filter.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), StringComparer.OrdinalIgnoreCase); } int id; string parameters; if (!ParseIdAndParams(objectID, out id, out parameters)) { throw new SoapException(402, "Invalid Args"); } using (XmlWriter writer = XmlWriter.Create(sb, new XmlWriterSettings() { OmitXmlDeclaration = true })) { writer.WriteStartElement("DIDL-Lite", "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"); writer.WriteAttributeString("xmlns", "dc", null, "http://purl.org/dc/elements/1.1/"); writer.WriteAttributeString("xmlns", "upnp", null, "urn:schemas-upnp-org:metadata-1-0/upnp/"); writer.WriteAttributeString("xmlns", "sec", null, "http://www.sec.co.kr/dlna"); writer.WriteAttributeString("xmlns", "av", null, "urn:schemas-sony-com:av"); using (SqlCeConnection conn = new SqlCeConnection(this.dbConnectionString)) using (DataContext context = new DataContext(conn)) { Item mainObject = context.GetTable <Item>().FirstOrDefault(a => a.Id == id); if (mainObject == null) { throw new SoapException(701, "No such object"); } if (browseFlag == BrowseFlag.BrowseMetadata) { mainObject.BrowseMetadata(writer, this.settings, host, parameters, filterSet); numberReturned = "1"; totalMatches = "1"; } else { mainObject.BrowseDirectChildren(writer, this.settings, host, parameters, filterSet, startingIndex, requestedCount, sortCriteria, out numberReturned, out totalMatches); } } writer.WriteEndElement(); } result = sb.ToString(); }
protected override void AppendSpecificMessage(StringBuilder builder) { builder.Append("<ObjectID>").Append(ObjectID).Append("</ObjectID>").Append("\r\n") .Append("<BrowseFlag>").Append(BrowseFlag.ToString()).Append("</BrowseFlag>").Append("\r\n") .Append("<Filter>").Append(Filter).Append("</Filter>").Append("\r\n") .Append("<StartingIndex>").Append(StartingIndex).Append("</StartingIndex>").Append("\r\n") .Append("<RequestedCount>").Append(RequestedCount).Append("</RequestedCount>").Append("\r\n") .Append("<SortCriteria>").Append(SortCriteria).Append("</SortCriteria>").Append("\r\n"); }
protected override string Browse(string objectId, BrowseFlag browseFlag, string filter, int startIndex, int requestCount, string sortCriteria, out int numberReturned, out int totalMatches, out string updateId) { throw new System.NotImplementedException(); }
protected override string Browse (string objectId, BrowseFlag browseFlag, string filter, int startIndex, int requestCount, string sortCriteria, out int numberReturned, out int totalMatches, out string updateId) { throw new System.NotImplementedException(); }
internal void Browse(Dictionary <string, string> headers, string objectId, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out string result, out string numberReturned, out string totalMatches) { string host = headers.ContainsKey("host") ? "http://" + headers["host"] : string.Empty; StringBuilder sb = new StringBuilder(); HashSet <string> filterSet = null; if (filter != "*") { filterSet = new HashSet <string>(filter.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries), StringComparer.OrdinalIgnoreCase); } Item mainObject = null; string[] idParams = objectId.Split(new[] { '_' }, 2, StringSplitOptions.RemoveEmptyEntries); mainObject = _rootItems; using (XmlWriter writer = XmlWriter.Create(sb, new XmlWriterSettings { OmitXmlDeclaration = true })) { writer.WriteStartElement("DIDL-Lite", "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"); writer.WriteAttributeString("xmlns", "dc", null, "http://purl.org/dc/elements/1.1/"); writer.WriteAttributeString("xmlns", "upnp", null, "urn:schemas-upnp-org:metadata-1-0/upnp/"); writer.WriteAttributeString("xmlns", "av", null, "urn:schemas-sony-com:av"); try { if (browseFlag == BrowseFlag.BrowseMetadata) { mainObject.BrowseMetadata(writer, idParams.Length > 1 ? idParams[1] : string.Empty, host, filterSet); numberReturned = "1"; totalMatches = "1"; } else { (mainObject as ItemContainer).BrowseDirectChildren(writer, idParams.Length > 1 ? idParams[1] : string.Empty, startingIndex, requestedCount, sortCriteria, out numberReturned, out totalMatches, host, filterSet); } writer.WriteEndElement(); } catch (Exception ex) { P2pProxyApp.Log.Write(ex.Message, TypeMessage.Error); throw ex; } } result = sb.ToString(); }
/// <summary> /// Gets the string value for the AARGTYPEBrowseFlag state var from its enumeration value. /// </summary> /// <param name="value">The enumeration value to get the string value for.</param> /// <returns>The string value for the enumeration, or string.empty if AARGTYPEBrowseFlagEnum.Invalid or out of range.</returns> public static string ToStringAargtypeBrowseFlag(BrowseFlag value) { switch (value) { case BrowseFlag.BrowseMetadata: return(CsAllowedValAargtypeBrowseFlagBrowseMetadata); case BrowseFlag.BrowseDirectChildren: return(CsAllowedValAargtypeBrowseFlagBrowseDirectChildren); default: return(String.Empty); } }
public virtual void Browse([UpnpArgument("ObjectID")] string objectId, [UpnpArgument("BrowseFlag")] BrowseFlag browseFlag, [UpnpArgument("Filter")] string filter, [UpnpArgument("StartingIndex")] int startingIndex, [UpnpArgument("RequestedCount")] int requestCount, [UpnpArgument("SortCriteria")] string sortCriteria, [UpnpArgument("Result")] out string result, [UpnpArgument("NumberReturned")] out int numberReturned, [UpnpArgument("TotalMatches")] out int totalMatches, [UpnpArgument("UpdateID")] out string updateId) { result = Browse(objectId, browseFlag, filter, startingIndex, requestCount, sortCriteria, out numberReturned, out totalMatches, out updateId); }
internal void Browse(Dictionary<string, string> headers, string objectId, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out string result, out string numberReturned, out string totalMatches) { string host = headers.ContainsKey("host") ? "http://" + headers["host"] : string.Empty; StringBuilder sb = new StringBuilder(); HashSet<string> filterSet = null; if (filter != "*") filterSet = new HashSet<string>(filter.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries), StringComparer.OrdinalIgnoreCase); Item mainObject = null; string[] idParams = objectId.Split(new[] { '_' }, 2, StringSplitOptions.RemoveEmptyEntries); mainObject = _rootItems; using (XmlWriter writer = XmlWriter.Create(sb, new XmlWriterSettings {OmitXmlDeclaration = true})) { writer.WriteStartElement("DIDL-Lite", "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"); writer.WriteAttributeString("xmlns", "dc", null, "http://purl.org/dc/elements/1.1/"); writer.WriteAttributeString("xmlns", "upnp", null, "urn:schemas-upnp-org:metadata-1-0/upnp/"); writer.WriteAttributeString("xmlns", "av", null, "urn:schemas-sony-com:av"); try { if (browseFlag == BrowseFlag.BrowseMetadata) { mainObject.BrowseMetadata(writer, idParams.Length > 1 ? idParams[1] : string.Empty, host, filterSet); numberReturned = "1"; totalMatches = "1"; } else { (mainObject as ItemContainer).BrowseDirectChildren(writer, idParams.Length > 1 ? idParams[1] : string.Empty, startingIndex, requestedCount, sortCriteria, out numberReturned, out totalMatches, host, filterSet); } writer.WriteEndElement(); } catch (Exception ex) { P2pProxyApp.Log.Write(ex.Message, TypeMessage.Error); throw ex; } } result = sb.ToString(); }
public string Browse (string objectId, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out uint numberReturned, out uint totalMatches, out uint updateId) { if (browseFlag < BrowseFlag.BrowseMetadata || browseFlag > BrowseFlag.BrowseDirectChildren) throw new ArgumentOutOfRangeException ("browseFlag"); var in_arguments = new Arguments ( "ObjectID", objectId, "BrowseFlag", browseFlag.ToString (), "Filter", filter, "StartingIndex", startingIndex.ToString (), "RequestedCount", requestedCount.ToString (), "SortCriteria", sortCriteria); var action_result = controller.Actions["Browse"].Invoke (in_arguments, 2); numberReturned = uint.Parse (action_result["NumberReturned"]); totalMatches = uint.Parse (action_result["TotalMatches"]); updateId = uint.Parse (action_result["UpdateID"]); return action_result["Result"]; }
public string Browse(string objectId, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out uint numberReturned, out uint totalMatches, out uint updateId) { if (browseFlag < BrowseFlag.BrowseMetadata || browseFlag > BrowseFlag.BrowseDirectChildren) { throw new ArgumentOutOfRangeException("browseFlag"); } var in_arguments = new Arguments( "ObjectID", objectId, "BrowseFlag", browseFlag.ToString(), "Filter", filter, "StartingIndex", startingIndex.ToString(), "RequestedCount", requestedCount.ToString(), "SortCriteria", sortCriteria); var action_result = controller.Actions["Browse"].Invoke(in_arguments, 2); numberReturned = uint.Parse(action_result["NumberReturned"]); totalMatches = uint.Parse(action_result["TotalMatches"]); updateId = uint.Parse(action_result["UpdateID"]); return(action_result["Result"]); }
/// <summary> /// Executes the Browse action. /// </summary> /// <param name="objectId">In value for the ObjectID action parameter.</param> /// <param name="browseFlag">In value for the BrowseFlag action parameter.</param> /// <param name="filter">In value for the Filter action parameter.</param> /// <param name="startingIndex">In value for the StartingIndex action parameter.</param> /// <param name="requestedCount">In value for the RequestedCount action parameter.</param> /// <param name="sortCriteria">In value for the SortCriteria action parameter.</param> public async Task <ActionResult> Browse(String objectId, BrowseFlag browseFlag, String filter, UInt32 startingIndex, UInt32 requestedCount, String sortCriteria) { var loIn = new object[6]; loIn[0] = objectId; loIn[1] = ContendDirectoryExtensions.ToStringAargtypeBrowseFlag(browseFlag); loIn[2] = filter; loIn[3] = startingIndex; loIn[4] = requestedCount; loIn[5] = sortCriteria; var action = new SoapAction { ArgNames = new[] { "ObjectID", "BrowseFlag", "Filter", "StartingIndex", "RequestedCount", "SortCriteria" }, Name = CsActionBrowse, ExpectedReplyCount = 4 }; var result = await InvokeActionAsync(action, loIn); // TODO: check for execption return(new ActionResult(result.XElement)); }
/// <summary> /// Executes the Browse action. /// </summary> /// <param name="objectID">In value for the ObjectID action parameter.</param> /// <param name="browseFlag">In value for the BrowseFlag action parameter.</param> /// <param name="filter">In value for the Filter action parameter.</param> /// <param name="startingIndex">In value for the StartingIndex action parameter.</param> /// <param name="requestedCount">In value for the RequestedCount action parameter.</param> /// <param name="sortCriteria">In value for the SortCriteria action parameter.</param> /// <param name="result">Out value for the Result action parameter.</param> /// <param name="numberReturned">Out value for the NumberReturned action parameter.</param> /// <param name="totalMatches">Out value for the TotalMatches action parameter.</param> /// <param name="updateID">Out value for the UpdateID action parameter.</param> public async Task <BrowseResult <T> > Browse <T>(String objectID, BrowseFlag browseFlag, String filter, UInt32 startingIndex, UInt32 requestedCount, String sortCriteria) { object[] loIn = new object[6]; loIn[0] = objectID; loIn[1] = Extensions.ContendDirectoryExtensions.ToStringAARGTYPEBrowseFlag(browseFlag); loIn[2] = filter; loIn[3] = startingIndex; loIn[4] = requestedCount; loIn[5] = sortCriteria; var action = new SOAPAction() { ArgNames = new string[] { "ObjectID", "BrowseFlag", "Filter", "StartingIndex", "RequestedCount", "SortCriteria" }, Name = csAction_Browse, ExpectedReplyCount = 4 }; var result = await InvokeActionAsync(action, loIn); if (result.Error == null) { var bResult = new BrowseResult <T>(result.Data); // TEMP if (typeof(T).Equals(typeof(QueueItem))) { foreach (var item in bResult.Result) { QueueItem q = (QueueItem)(object)item; q.AlbumArtUri = base.Description.BaseAddress.Scheme + "://" + base.Description.BaseAddress.Host + ":" + base.Description.BaseAddress.Port + q.AlbumArtUri; } } return(bResult); } return(new BrowseResult <T>()); }
public abstract void BrowseCore(string objectID, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out string result, out uint numberReturned, out uint totalMatches, out uint updateID);
protected abstract string Browse(string objectId, BrowseFlag browseFlag, string filter, int startIndex, int requestCount, string sortCriteria, out int numberReturned, out int totalMatches, out string updateId);
protected abstract string Browse (string objectId, BrowseFlag browseFlag, string filter, int startIndex, int requestCount, string sortCriteria, out int numberReturned, out int totalMatches, out string updateId);
public Task <ActionResult> Browse(string objectId, uint startingIndex, uint requestedCount, BrowseFlag browseFlag = BrowseFlag.BrowseDirectChildren) { const string filter = "dc:title,res,dc:creator,upnp:artist,upnp:album,upnp:albumArtURI"; return(CurrentCoordinator .MediaServer .ContentDirectory1Service .Browse(objectId, browseFlag, filter, startingIndex, requestedCount, "")); }
private async Task <string> BuildXmlAsync() { var browseActionXml = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(envelopeNs + "Envelope", new XAttribute(XNamespace.Xmlns + "s", envelopeNs), new XElement(envelopeNs + "Body", new XElement(upnpNs + "Browse", new XAttribute(XNamespace.Xmlns + "u", upnpNs), new XElement("ObjectID", new XText(ObjectId)), new XElement("BrowseFlag", new XText(BrowseFlag.ToString())), new XElement("Filter", new XText(Filter.ToString())), new XElement("StartingIndex", new XText(StartingIndex.ToString())), new XElement("RequestedCount", new XText(RequestedCount.ToString())), new XElement("SortCriteria", new XText("")))))); using (var memory = new MemoryStream()) { using (var writer = XmlWriter.Create(memory, new XmlWriterSettings() { Indent = true, Encoding = Encoding.UTF8 })) { browseActionXml.WriteTo(writer); writer.Flush(); } memory.Flush(); memory.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(memory)) { return(await reader.ReadToEndAsync()); } } }
/// <summary> /// Allows the caller to incrementally browse the native hierarchy of the Content Directory objects exposed by the <see cref="ContentDirectoryService"/>, including /// information listing the classes of objects available in any particular object container. /// </summary> /// <param name="objectId"> /// Object currently being browsed. An ObjectID value of zero corresponds to the root object of the Content Directory. /// </param> /// <param name="browseFlag"> /// Specifies a browse option to be used for browsing the Content Directory. /// </param> /// <param name="filter"> /// The comma-separated list of property specifiers (including namespaces) indicates which metadata properties are to be /// returned in the results from browsing or searching. /// </param> /// <param name="startingIndex"> /// Starting zero based offset to enumerate children under the container specified by <paramref name="objectId"/>. Must be 0 if <paramref name="browseFlag"/> is equal /// to <see cref="BrowseFlag.BrowseMetadata"/>. /// </param> /// <param name="requestedCount"> /// Requested number of entries under the object specified by <paramref name="objectId"/>. The value '0' indicates request all entries. /// </param> /// <param name="sortCriteria"> /// A CSV list of signed property names, where signed means preceded by ‘+’ or ‘-’ sign. The ‘+’ and ‘-’Indicate the sort is in ascending or descending order, /// respectively, with regard to the value of its associated property. Properties appear in the list in order of descending sort priority. /// </param> /// <exception cref="WebException"> /// An error occurred when sending request to service. /// </exception> /// <exception cref="FormatException"> /// Received result is in a bad format. /// </exception> /// <exception cref="UPnPServiceException"> /// An internal service error occurred when executing request. /// </exception> public async Task<BrowseResult> BrowseAsync(string objectId, BrowseFlag browseFlag, string filter, int startingIndex, int requestedCount, string sortCriteria) { var arguments = new Dictionary<string, object> { {"ObjectID", objectId}, {"BrowseFlag", browseFlag}, {"Filter", filter}, {"StartingIndex", startingIndex}, {"RequestedCount", requestedCount}, {"SortCriteria", sortCriteria}, }; var response = await this.InvokeActionAsync("Browse", arguments); var resultXml = response["Result"]; var mediaObjects = ParseMediaObjects(resultXml); var result = new BrowseResult { Result = mediaObjects, NumberReturned = Convert.ToInt32(response["NumberReturned"]), TotalMatches = Convert.ToInt32(response["TotalMatches"]), UpdateId = Convert.ToUInt32(response["UpdateId"]) }; return result; }