# IPC e rete

## Clipboards and Drag and Drop

As users work with more and more types of data in different applications, they have an increasing need to share objects and data between their applications. GNOME supports two related methods for transfering data between applications: using drag and drop operations, and copying to and pasting from a system-wide clipboard. Both the clipboard and drag and drop work across multiple applications, including those not developed with GNOME.

The clipboard is used when a user explicitly copies data in an application. The application then claims ownership of the clipboard. When the user pastes the data into another application, that application requests the clipboard data from the first application. Clipboard operations are fully supported in GTK+.

Drag and drop operations are similar, but they require the pointer to be tracked and updated as the user moves across potential drop targets. When an application is notified a pointer is moving over it during an active drag, it must update the cursor to indicate whether or not it can accept the drop. GTK+ provides drag and drop support with a sophisticated API that makes it easy to manage drop targets in your applications.

Both the clipboard and drag and drop operations support content negotation. When an application has data to offer, it advertises which formats are available for that data. Receiving applications can request the most suitable formats. For instance, if a user copies text from a web browser, a word processor can maintain formatting by requesting the data in HTML, while a plain text editor can receive the text without formatting.

You should provide clipboard and drag and drop functionality for any data your application operates on. The clipboard and drag and drop are useful for more than just text: files, graphics, and sound clips are all examples of data that can be transferred between applications. When you use GTK+, you automatically get clipboard and drag and drop support for text areas, color buttons, file choosers, and other built-in user interface controls. You should use the APIs in GTK+ to provide support for any other data in your application.

For more information, see Drag-and-Drop Protocol for the X Window System, X Clipboard Explanation, and The Clipboard Manager Specification.

## D-BUS Messaging

D-Bus is a cross-desktop message bus for sending events between various applications, the desktop, and low-level components of the system. D-Bus provides a simple API for sending messages to particular services and for broadcasting messages to all interested services. D-Bus enables different types of applications to communicate and integrate with each other and with the desktop, providing better interaction and a richer experience for the user.

D-Bus provides a session and a system bus. The session bus is used by applications in a single user session, allowing them to share data and event notifications and to integrate into the user's desktop. For example, movie players can send a D-Bus message to prevent the screensaver from activating when the user is watching a movie.

The system bus is a single message bus which runs independently of any user sessions. It can communicate with applications in any session, enabling those applications to interact with system components without dealing with low-level system details. The system bus is used to provide important functionality that users expect to work on their systems. For example, the system bus is used to monitor when network interfaces go up or down, when external drives get plugged in, and when laptop batteries are low.

D-Bus is developed jointly on freedesktop.org, so you can use it with different desktop environments and applications. Because D-Bus is a cross-desktop project, you use it to create portable and versatile software that seamlessly integrates with the user's desktop, regardless of which desktop it is.

For more information on D-Bus, see The D-BUS Tutorial and The D-BUS Specification.

## Bonobo and CORBA

Bonobo is a framework for creating reusable components for use in applications. Built on top of the industry-standard Common Object Request Broker Architecture (CORBA), Bonobo provides all the common interfaces needed to create and use well-behaved components in GNOME applications.

Bonobo components can be used in a variety of situations, and can help create flexible and extensible software. For example, a component to display multimedia content could be embedded inside a word processor, effectively adding multimedia support to the word processor without the word processor working directly with it. Bonobo components are also used to embed the applets in the GNOME panel. Using Bonobo enables the applets to communicate effectively with the panel, affording users a consistent interface.

Bonobo components are not limited to graphical controls. Bonobo is used by Evolution, GNOME's email and groupware suite, to provide access to users' addressbook and calendar. This allows users to keep all their information in one place, where all applications can access it.

Bonobo is built off of CORBA, allowing components to run in seperate processes. Components can be written in different languages and run on top of different runtimes; they need only adhere to an interface specified with the Interface Definition Language (IDL). CORBA's flexible design even allows components to run on seperate machines over a network.

GNOME provides its own fast and lightweight CORBA implementation with ORBit. The tools and libraries supplied with GNOME even allow components to be written effectively in C, a language often excluded by other CORBA implementations. ORBit is an incredibly fast CORBA implementation.

Bonobo helps fill the gaps in CORBA, providing the additional interfaces and specifications needed to support consistent components. Although you will rarely need to use CORBA without Bonobo, it can be used directly. For instance, GNOME's accessibility infastructure uses CORBA to allow assistive tools to inspect and interact with running applications.

You may wish to use Bonobo to provide complex graphical components that can be embedded into applications. For most IPC needs, however, GNOME is moving towards D-Bus, as integrating D-Bus into applications is considerably easier.

For more information on Bonobo, see the Libbonobo Reference Manual and the LibbonoboUI Reference Manual. For information on ORBit, GNOME's CORBA implementation, see the ORBit2 Reference Manual.

## Service Discovery

DNS Service Discovery, or Zeroconf, is a technology for automatically locating available services on a network. Zeroconf allows users to access network resources without having to provide explicit addresses or configure their applications manually.

DNS Service Discovery is already used in numerous places throughout GNOME, and further support will be added in the future. For example, Nautilus, the GNOME file manager, uses DNS Service Discovery to locate various file servers on the local network. Ekiga, the videoconferencing and telephony application in GNOME, can locate and publish the user's presence and locate other users on a local network using DNS Service Discovery.

Full DNS Service Discovery support is provided by the Avahi library. For more information on Avahi, visit the Avahi web site.

## XML and Web Services

In our increasingly inter-connected world, more and more applications need to provide support for various web services. Sometimes web services simply provide added functionality, while other times they are the core purpose of the application. Even applications that have been providing a standalone user experience for years have found innovative new uses for web services.

The GNOME Platform provides support for using web services from within your application, as well as comprehensive libraries for consuming, managing, and transforming XML, the language of the web.

### SOAP

With the libsoup library, GNOME provides support for the SOAP, a widely-used protocol for passing XML messages over HTTP. SOAP allows developers to expose an interface over the web, which can then be used by applications to retrieve information, send data, make transactions, or use any number of other services provided.

SOAP can be used to search and retrieve information, to interact with an online store, to manage users' accounts on other systems, or for many other purposes. Web services are being used more and more to provide essential functionality for users, and applications using SOAP can provide a more integrated and featureful user experience.

The libsoup library contains an HTTP implementation and a set of API for constructing and consuming SOAP messages. It also allows for secure authentication, so you can use web services to access private accounts over a secure connection. Using libsoup makes it easy to use web services without manually parsing and interpreting the messages sent through SOAP.

For more information on libsoup, see the libsoup Reference Manual.

### XML Processing

Since its formal introduction in 1998, XML (eXtensible Markup Langauge) has been used in increasingly more applications. It is used for a wide variety of purposes, from document formats like XHMTL and DocBook to internet protocols like SOAP and Jabber. XML provides a clean and simple base syntax, allowing applications to focus on their particular needs.

GNOME ships with the libxml2 library, and uses it extensively throughout the desktop. The libxml2 library is a fast and fully standards-compliant XML processing library, providing everything you need to use XML in your application.

The libxml2 library provides a number of different APIs for working with XML, so you can use whatever best suits your application development needs. In addition to a native tree API, libxml2 also provides the callback-based SAX2 API, streaming XML reader and writer interfaces, and complete support for XPath.

In addition to DTD support, libxml2 also provides full support for validing documents using RELAX NG, which allows a more flexible validation model while remaining simple to use. There is also partial support for XML Schema, the new schema language produced by W3C.

You should use libxml2 whenever you need to work directly with XML in your application. Using libxml2 ensures that you have fully standards-compliant parsing, processing, and XML output. This means developers can stop worrying about incompatibilities between applications.

For more information on libxml2, see The Libxml Tutorial and The Reference Manual for libxml2.

### Transforming XML with XSLT

XSLT is an XML-based language for transforming XML into other formats. XSLT is a template-based language, allowing you to match particular types of XML elements and create output accordingly. Based on XML and XPath, XSLT enables developers to create clean and modularized templates to convert an XML dialect into another format more suitable for the application.

GNOME ships with the libxslt library, a complete implementation of XSLT. The libxslt library is built on top of the XML and XPath support in libxml2, allowing it to be fast and fully standards-compliant.

You should use libxslt if you need to transform XML documents. Although XSLT is not always the right solution for XML processing, it can often simplify development. Since libxslt allows you to add extension elements and extension functions, you can customize it to fit your application.

For more information on libxslt, see The XSLT C library for Gnome.