Brecham.Obex — An OBEX library for the .NET Framework

ObexFolderListingParser Class

Provides means to use OBEX Folder-Listing objects, which are XML documents. See OBEX13.pdf section 9.1. In particular it is a parser for the Folder-listing XML documents.

For a list of all members of this type, see ObexFolderListingParser Members.

System.Object
   Brecham.Obex.Objects.ObexFolderListingParser

[Visual Basic]
Public Class ObexFolderListingParser
[C#]
public class ObexFolderListingParser

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The class provides a parser to read the OBEX folder-listing XML objects and return a list of the parent-folder, folder, and file items that it contains. It can be used in various ways, firstly via ObexClientSession’s GetFolderListing method, otherwise it can be used directly see the example below. The input is generally the Stream returned by a GET operation for the unnamed item of type x-obex/folder-listing (ie ObexConstant.Type.FolderListing).

In normal usage all the items are returned as an instance of the ObexFolderListing class, this is the case for the GetAllItems method, and for the GetFolderListing method on ObexClientSession as mentioned above. The GetNextItem method on the other hand returns each individual item as its content arrives, this can be used if for instance the download is slow and you want to be show items as they arrive before the complete listing has been downloaded.

The parser uses the DTD and is also strict even if the document being parsed does not reference the DTD, or as on the Compact Framework where XmlReader cannot use DTDs. During testing it was found that not all devices follow the specification. The Nokia 6670, for instance, produces documents where the folder item can contain mem-type and label attributes. The IgnoreUnknownAttributeNames property controls whether we will produce an error for undefined attributes, or instead ignore and discard them.

Example

[Visual Basic]
Private Sub DisplayFolderListing(sess As ObexClientSession)
   Dim xmlStrm As Stream = sess.Get(Nothing, ObexConstant.Type.FolderListing)
   Dim parser As New ObexFolderListingParser(xmlStrm)
   Dim listing As ObexFolderListing = parser.GetAllItems
   If (listing.HasParentFolder) Then Console.WriteLine("<DIR> ..")
   For Each folder As ObexFolderItem In listing.Folders
      Console.WriteLine("<DIR> {0}", folder.Name)
   Next
   For Each file As ObexFileItem In listing.Files
      Console.WriteLine("      {0}", file.Name)
   Next
End Sub

Requirements

Namespace: Brecham.Obex.Objects

Assembly: Brecham.Obex (in Brecham.Obex.dll)

See Also

ObexFolderListingParser Members | Brecham.Obex.Objects Namespace