BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Windows Share, a New Data Exchange Mechanism in Windows 8

Windows Share, a New Data Exchange Mechanism in Windows 8

This item in japanese

Bookmarks

Microsoft has created a new mechanism for sharing information between applications in Windows 8 called Windows Share. Apps can share text, bitmaps, HTML, URI, files, and other type of data, and the usage scenarios are numerous. For example, the app receiving the information can post it to Tweeter or Facebook make it easy to post information to a social network without actually visiting it.

Billie Sue Chafins, Senior Program Manager Lead, and Steve Seixeiro, Partner Development Manager, Microsoft Corporation, presented the session “Share: your app powers the Windows 8 share experience” at BUILD 2011. They detailed the new sharing feature coming up in Windows 8. Windows Share is sort of a universal live clipboard, allowing applications to transfer information between them, but it is much well integrated into the system and richer compared to the traditional clipboard.

Windows Share accepts the following standard data formats: text, RTF, bitmaps, storage items (e.g. files), URI, HTML, but there is also the extensible format that can be used to transfer any stream of information: addresses, contacts, people, geo-location, etc. When the user wants to share some information from an application, he is presented with a list of applications accepting the respective type of information, and the data is transparently transferred upon selecting one of them.

The Share features defines the following types of participants to the process:

  • Source – any application that has information for sharing with other applications
  • Target – any application consuming the information shared by other apps
  • Broker – the transfer mediator between the source and the target

Most applications can be a source, if it has anything to share, and Microsoft encourages developers to make their applications sources of information. Targets will be those applications interested in receiving and processing information. The advantage of Share is the fact that Windows will have built-in protocol for exchanging information and applications developers no longer need to agree on a certain format in order to be able to exchange data. For extensible formats, the parties involved need to agree on the data format used, so it is recommended to use standardized ones such those supported by Schema.org.

One example is sharing a web page’s URL or some text from IE to social networks such as Twitter or Facebook, the target applications Tweet@rama and Socialite taking care of posting data to the respective networks. The information sharing possibilities are numerous, and it is expected the developers to create many such applications.

To share data the source needs to register with the Data Transfer Manager, and it is informed when the user selects the Share command on Windows, then prepares the Data Package and sends it to the Broker via an asynchronous call. The Broker determines which targets have registered for accepting the corresponding type of data transferred by the source and lists them so the user can select one. When the user has chosen a target the broker activates that application and gives it the data package. The whole process is finished by the target informing that the transfer was complete as depicted in the graphic below:

image

At low level, Share is done the new Windows.ApplicationModel.DataTransfer assembly belonging to Windows Runtime (WinRT). This is what it looks like to prepare a source for sharing in JS:

// set up data transfer manager

var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();

// create event listener to be called on to fill out data package

dataTransferManager.addEventListener("datarequested", function (e) {

// fill in data package with what to share

var request = e.request;

request.data.properties.title = "Title for data";

request.data.properties.description = "Description of the data";

request.data.setText("Text to share");

...

});

The target needs a bit more work including the modification of the application’s manifest file and the creation of an HTML page which is displayed by Windows when the user selects the respective application for sharing. Visual Studio provides basic templates to set up an application for sharing, so the work is half way done.

Windows Share looks like an easy way to exchange information between applications in Windows 8 and fits well with the new Metro interface.

Rate this Article

Adoption
Style

BT