Part 2: Getting Friends Information by Using the Proxy Library for Outlook Social Connector Provider Extensibility
Summary: Learn how to return friend and non-friend information from an Outlook Social Connector Provider by using the Outlook Social Connector Provider Proxy Library framework.
Applies to: Office 2007 | Office 2010 | Outlook | Outlook 2007 | Outlook 2010 | Visual Studio
Published: January 2011
Provided by: Michael Case, iSoftStone | Angela Chu-Hatoun, Microsoft Corporation | Patrick Creehan, Microsoft Corporation
The Microsoft Outlook Social Connector (OSC) provides a communication hub for personal and professional communications. Just by selecting an Outlook item such as an email or meeting request and clicking the sender or a recipient of that item, users can see, in the People Pane, activities, photos, and status updates for the person on their favorite social networks. The OSC obtains social network data by calling an OSC provider, which behaves like a translation layer between Outlook and the social network. The OSC provider model is open, and you can develop a custom OSC provider by implementing the required OSC provider extensibility interfaces. To retrieve social network data, the OSC makes calls to the OSC provider through these interface members. The OSC provider communicates with the social network and returns the social network data to the OSC as a string or as XML that conforms to the Outlook Social Connector XML schema. Figure 1 shows the various components of the sample OfficeTalk OSC provider reviewed in this Visual How To. Figure 1. Relationships of the sample OfficeTalk OSC provider with related components This Visual How To focuses on returning friend social network data from OfficeTalk. OfficeTalk is not publicly available and is being used as an example of the kind of social network you might want to develop a custom OSC provider for. You can use the techniques to return friend social network data from OfficeTalk to return friend social network data from any social network. The OfficeTalk provider uses the Outlook Social Connector Provider Proxy Library to simplify the implementation of the OSC provider extensibility interfaces. The OSC Provider Proxy Library implements all of the OSC provider extensibility interface members. These interface members, in turn, call a consolidated set of abstract and virtual methods that provide the social network data that the OSC requires. To create a custom OSC provider that uses the OSC Provider Proxy Library, a developer overrides these abstract and virtual methods with the business logic to communicate with the social network. The sample solution for this article includes sample code for a custom OSC provider for OfficeTalk. However, this Visual How To does not show all of the code in the sample solution. Instead, it focuses on returning friend social network data from OfficeTalk. The sample solution contains two projects:
The OfficeTalkOSCProvider project includes the following source code files:
The following sections show the procedures to add OSC Provider Proxy Library override methods for friends-related methods in the OTProvider class for the OTProvider_Friends source file. Creating the OfficeTalk OSC Provider Solution Reviewing the steps to create a Visual Studio solution for an OfficeTalk OSC provider is outside the scope of this Visual How To. For information about creating a custom OSC provider solution, see Part 1: Developing a Real Outlook Social Connector Provider by Using a Proxy Library. Creating the OTProvider_Friends Source File Use the OSC Provider Proxy Library to create a subclass of the OSCProvider class, OTProvider, which represents the sample OSC provider. OTProvider is defined as a partial class so that the logic for OSC provider core methods, friends, and activities can be defined in separate source code files. The OTProvider_Friends source file extends the OTProvider partial class and contains the override methods for providing OfficeTalk friends information. Add a class named OTProvider_Friends to the OfficeTalkOSCProvider project. Replace the class definition with the following code. The code example starts with the using statements for the OSC Provider Proxy Library and OfficeTalk API. The code example then defines the OTProvider partial class. The OTProvider source file defines inheriting from the OSCProvider class.
Allowing for Debugging To debug the OfficeTalkOSCProvider, you must modify the OfficeTalkOSCProvider project to start using Outlook and register the OfficeTalkOSCProvider as an Outlook Social Connector. To set up the OfficeTalkOSCProvider project for debugging
The Outlook Social Connector will not call the OfficeTalkOSCProvider until it is registered as an OSC Provider. The sample solution includes a file named RegisterProvider.reg that updates the registry with the entries that are required to register the OfficeTalkOSCProvider as an OSC provider. You can update the registry by opening the RegistryProvider.reg file in Windows Explorer. The RegisterProvider.reg file assumes that the sample solution is located in the C:\temp directory. If the sample solution is located in a different directory, update the CodeBase entry in the RegisterProvider.reg file to point to the correct location. Adding Helper Methods The OfficeTalkHelper class contains helper methods, including the GetOfficeTalkClient and ConvertUserToPerson methods, that are used throughout the sample solution. The following GetOfficeTalkClient method returns an OfficeTalkClient object that is used to communicate with OfficeTalk. If the OfficeTalkClient has not been initialized, GetOfficeTalkClient creates and configures a new OfficeTalkClient by using the API_URL and API_VERSION constants that are defined in OTProvider.
The ConvertUserToPerson method converts an OfficeTalk User object to an OSC Provider Proxy Library Person object that is usable within the OSC Provider Proxy Library. The ConvertUserToPerson method creates a new OSC Provider Proxy Library Person and then maps the User properties to the related Person properties.
Overriding the GetPeopleDetails Method The OfficeTalk OSC provider in the sample solution supports hybrid synchronization of friend social network data. With hybrid synchronization, the OSC calls the ISocialSession2.GetPeopleDetails method to return person and picture details for each person displayed in the People Pane. To support the ISocialSession2.GetPeopleDetails method, the OSC Provider Proxy Library provides a GetPeopleDetails virtual method that you can override to return information from the social network. The GetPeopleDetails virtual method returns people information as a list of friends to match the format that the OSC requires. The OSC calls the ISocialSession2.GetPeopleDetails method with a list of the people who are displayed in the People Pane. Each person can have multiple email addresses, and the email addresses will be hashed. The GetPeopleDetails override method shown in the following code completes these steps:
Overriding the GetFriends Method The OSC ISocialPerson and ISocialProfile interfaces contain members that are dependent on the currently logged-on user's friends on the social network. The OSC Provider Proxy Library provides the GetFriends abstract method, which you can override to return friends information from the social network. The OSC Provider Proxy Library limits how often the social network is contacted by storing this list of friends internally. This internal list of friends will be refreshed after 30 minutes. The GetFriends override method shown in the following code completes these steps:
Overriding the FollowPersonEx Method The OSC ISocialSession and ISocialSession2 interfaces contain methods to add a person as a friend of the currently logged-on user in the social network. Because the OSC Provider Proxy Library implements the ISocialSession2 interface, the OSC calls the ISocialSession2.FollowPersonEx method instead of the ISocialSession.FollowPerson method. The OSC Provider Proxy Library provides the FollowPersonEx virtual method, which you can override to add a person as a friend of the current user in the social network. The FollowPersonEx override method shown in the following code completes these steps:
Overriding the UnFollowPerson Method The OSC ISocialSession interface contains the UnFollowPerson method to remove a person as a friend of the currently logged-on user in the social network. The OSC Provider Proxy Library provides the UnFollowPerson virtual method, which you can override to remove a person as a friend of the current user in the social network. The UnFollowPerson override method shown in the following code completes these steps:
Overriding OSC Provider Proxy Library Core Methods A custom OSC Provider that uses the OSC Provider Proxy Library must override the abstract and virtual methods for returning information about the OSC provider, the social network capabilities, and the current user. In the sample solution, the overrides for these OTProvider methods are located in the OTProvider source file. The core abstract and virtual methods are as follows:
Reviewing these methods is outside the scope of this Visual How To. For more information, see Part 1: Developing a Real Outlook Social Connector Provider by Using a Proxy Library. Overriding OSC Provider Proxy Library Activity Methods A custom OSC Provider that uses the OSC Provider Proxy Library must override the abstract and virtual methods for returning activity social network data. In the sample solution, the overrides for these OTProvider methods are located in the OTProvider_Activities source file. There is only one method to override for activities:
Covering these methods in detail is outside of the scope of this Visual How To. For more information about returning activities social network data, see Part 3: Getting Activities Information by Using the Proxy Library for Outlook Social Connector Provider Extensibility. Creating a custom Outlook Social Connector (OSC) provider for a social network is a straightforward process of implementing the OSC Provider extensibility interfaces to return social network data. The OSC Provider Proxy Library simplifies this process by removing the requirement to implement each individual interface member. Instead the OSC Provider Proxy Library defines a consolidated set of abstract and virtual methods to provide social network data. The developer of the OSC provider can focus on overriding these methods with the business logic required to interface with the social network API. The sample solution for this Visual How To includes sample code for a custom OSC provider for OfficeTalk. This Visual How To does not cover all of the code in the sample solution. This Visual How To focuses on returning friends social network data from OfficeTalk. The social network data that the OfficeTalk provider returns is shown in Figure 2. Figure 2. OSC showing OfficeTalk social network data in the People Pane For more information about creating the OfficeTalk OSC provider, see Part 1: Developing a Real Outlook Social Connector Provider by Using a Proxy Library. For more information about returning activities social network data, see Part 3: Getting Activities Information by Using the Proxy Library for Outlook Social Connector Provider Extensibility. |
> [!VIDEO https://www.microsoft.com/en-us/videoplayer/embed/36e811dc-feb8-489a-8d8a-1d7ff5382eee] Length: 13:46 |