Interoperating with Lync with Publication Grammars
To interoperate with Microsoft Lync 2010, an enhanced presence application must follow the publication grammars defined by Lync 2010. This involves obtaining an XML document of the publication grammar, determining the rules, and implementing the logic.
Receiving Publication Grammars
At the SIP level, receiving the publication grammars set by a server administrator involves submitting a SUBSCRIBE request, specifying publictationGrammar as the name of one of the provisionGroups elements. The result is returned in a SIP response of 200 OK. For details of the SIP messages used, see Receiving In-Band Provisioning Data.
By default there are two publication grammars: one for the open-mode presence publication and the other the privacy-mode publication. The open-mode publication grammar is specified by a container manifest and a category publication manifest. The privacy-mode publication grammar contains only a container manifest.
A container manifest is described by an XML element of <containerManifestList>. It has the following high-level structure.
<provisionGroup name="publicationGrammar">
<containerManifestList>
<containerManifest>
<containers>...</containers>
<members>...</members>
<blockRules>...</blockRules>
<rolePrecedence>...</rolePrecedence>
</containerManifest>
</containerManifestList>
</provisionGroup>
The containers element declares what containers should be used for remote presence publications. The members element stipulates the access control entries for specified containers and how they should be assigned to the containers. The blockRules element describes the types and sources of blocking operations. Finally, the rolePrecedence element specifies the conflict resolution when a user taking multiple roles is added to a container.
A category publication manifest is described by categoryPublicationManifest and it has the following high-level structure.
<categoryPublicationManifest>
<publicationList>
<publicationRule>...</publicationRule>
<!-- more publicationRule element -->
......
</publicationList>
</categoryPublicationManifest>
A category publication manifest is a list of publication rules, each being described by a publicationRule element. A publication rule stipulates that a given type of category should be placed into a specified container in a publication request. Additionally, instance ID, expiration type and a category data value can also be specified for a particular publication. The specification of the category data value is typically generated from the enclosed XSLT routine.
In Microsoft Unified Communications Managed API (UCMA) 3.0, only the publication grammar compatible with the currently enabled privacy policy is exposed. An application can obtain this grammar by reading the ContainerManifest or CategoryPublicationManifest property on a LocalOwnerPresence object.
Enforce Lync 2010-Compatible Presence Publications for Remote Watchers
To make a presence application interoperable with Lync 2010, the client must enforce the Lync 2010-compatible publication grammars for presence publications. Enforcing the publication grammars involves the following tasks, after obtaining the publication grammar appropriate for the presence privacy policy:
Enumerate the grammar-specified containers for remote presence watchers. These include Container 0, 100, 200, 300, 400 and 32000.
Assign members to the containers according to specification of the publication grammar. The expected behavior is discussed in Container Semantics Defined and Conformed by Microsoft Lync.
Publish a given category data following the applicable publication rules as specified in the grammar. The expected behavior is discussed in Presence Category Instances Published or Used by Microsoft Lync.
To help illustrate this point, let us look an example of publishing the following note category instance, created after a user has set a personal note message.
<nt:note xmlns:nt="https://schemas.microsoft.com/2006/09/sip/note"> <nt:body type="personal">I'm away today.</nt:body> </nt:note>
To have this note published in the Lync 2010-compatible way, an application should apply the following publication rules.
<publicationRule ruleType="transformation" categoryName="note" containerId="100"> <categoryData> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="https://schemas.microsoft.com/2006/09/sip/commontypes" xmlns:tns="https://schemas.microsoft.com/2006/09/sip/note" exclude-result-prefixes="tns ct"> <xsl:output method="xml" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()"> <xsl:apply-templates select="//tns:note"/> </xsl:template> <xsl:template match="tns:note"> <xsl:copy /> </xsl:template> </xsl:stylesheet> </categoryData> </publicationRule> <publicationRule ruleType="transformation" categoryName="note" containerId="200" /> <publicationRule ruleType="transformation" categoryName="note" containerId="300" /> <publicationRule ruleType="transformation" categoryName="note" containerId="400" preferredSelfConsumption="true" /> <publicationRule ruleType="transformation" categoryName="note" containerId="32000"> <categoryData> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="https://schemas.microsoft.com/2006/09/sip/commontypes" xmlns:tns="https://schemas.microsoft.com/2006/09/sip/note" exclude-result-prefixes="tns ct"> <xsl:output method="xml" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()"> <xsl:apply-templates select="//tns:note"/> </xsl:template> <xsl:template match="tns:note"> <xsl:copy /> </xsl:template> </xsl:stylesheet> </categoryData> </publicationRule>
According to this grammar, there are five rules to be applied to Container 100, 200, 300, 400 and 32000, respectively. To Container 200, 300 and 400, the note category instance should be published as is. For Container 100 and 32000, the enclosed XSLT routine modifies the original note category instance to produce an empty note category instance.
In Microsoft Unified Communications Managed API (UCMA) 3.0, this grammar-based publication is supported by calling the BeginPublishPresence/EndPublishPresence while encapsulating the note message in a CustomPresenceCategory instance. For more information, see Publishing Enhanced Presence. In Microsoft Lync 2010 SDK, grammar-based presence publication is automatically enforced.