Chapter 14 The Skype API

What Is the Skype API?

This chapter is for advanced users and those who have programming skills or who want to develop a hardware or software solution for Skype. So if you are a typical user, skip this chapter. The Skype development team recognizes that you might want to extend Skype in ways that they have not foreseen or add functionality to the Skype program that is not a priority on the Skype feature list. To enable you to write your own external applications that access Skype functionality, the Skype developers have released the Skype application programming interface (API). The Skype API is supported on Windows, Mac OS X, and Linux operating system platforms. On Windows platforms, the Skype API is supported on Windows 2000 or Windows XP. Although it might function on Windows 98/ME systems, it is not supported. There is nothing for the Pocket PC as of yet. On a Mac, you must be using Mac OS X v10.3 (Panther) or later, and the latest version of the Skype Client for Mac OS X. Linux platforms supported are Fedora Core 3, SuSe 9, Mandriva 10.1 Debian; and Gentoo 1.4, all of which require Skype For Linux, version 1.1.0.3 or later.

Simply put, the Skype API allows you to control Skype from within your own applications and to monitor information received about your Skype contacts. The Skype API supports a wide range of control commands and status messages. Some of these commands include allowing you to search for users, create chats, and send messages. Additional commands allow you to make calls to Skype users, leave voice-mail messages, and answer incoming calls from your own applications.

There are many examples of uses for the API, including personalized call forwarding, home security monitoring and control, and integration of the Skype application into enterprise systems such as call center support. To see more examples visit the Skype Developer Zone at http://share.skype.com/share/developer_blog/.

The Skype Phone API and the Skype Access API

The API itself is divided into two main sections, the Skype Phone API and the Skype Access API. The Phone API is an interface Skype uses to connect with hardware devices, such as a USB phone, or virtual software devices, such as one of the many “soft phone” applications available. For hardware devices you find the Phone API implemented as an operating system device driver. This driver exchanges messages with Skype, indicating events such as the handset going off the hook and keypad presses when dialing. Similarly, Skype issues commands through the Phone API, such as instructing the device to mute itself.

The Access API is likely to be of more interest to you as general Skype users because this interface supports the commands to send and receive messages, place and answer calls, and so forth.

An Overview of the Access API

The Access API functionality is fairly consistent across the supported operating system (OS) platforms. You should be aware that using the Access API to control the Skype client differs on each OS platform. For instance, on the Windows platform, the Skype API uses WM_COPYDATA messages exchange to handle commands sent to and received from Skype. On the Mac OS X platform, you use delegates, which are classes that are used to register for and handle events sent from other components. The Linux version uses D-Bus to hook in to the Skype application and exchange messages. D-Bus can be downloaded for free at www.freedesktop.org/wiki/Software_2fdbus.

Information on how to use the D-BUS libraries is located on the Skype domain at:

The Access API can be broken down into the following smaller API descriptions:

  • Ap2Ap API Applications attach to Skype, providing a direct connection over the Skype peer-to-peer network to each other. An example would be to use the Skype connection to relay video to the other peers on a call.
  • Call API Allows you to call Skype contacts, answer Skype calls, or use the Skype Out feature, and access the call logs.
  • Call Forwarding API This rule engine helps manage redirection of incoming calls to one or more contacts.
  • Chat API Provides the capability to send and receive text chat messages and search the chat logs.
  • Conference API Control conference call functions such as joining, leaving, and initiating conference calls.
  • Contacts API Allows you to add and delete contacts, respond to new client invitations, and set Skype status.
  • Device API Allows access to manipulate audio devices, such as choosing which device to use for input audio, output, and ringing.
  • DTMF API Use this to generate and process DTMF tones/notifications through the API. This could be useful for dialing from address books, modems, faxes, and so on.
  • Expressive API Similar to features on today’s mobile phones, this API allows the definition of images and ringtones for different call events.
  • MultiChat API Allows you to initiate, join, and leave text-based group chats.
  • Profile API Update personal data on your Skype profile and update presence status.
  • Skype Dialog Control Provides the capability to invoke built-in Skype dialogs and windows. This capability is very effective in providing your components a consistent look and feel as the Skype client application.
  • User API Provides the capability to search and view user profiles stored in the global Skype Directory.
  • Voice Mail API Provides the capability to notify users of new voice-mail messages, as well as to play and delete voice-mail messages.

Skype API Plug-ins

Many plug-ins have been developed using the example code provided at the Skype developer site, and you can see these in the Skype Directory published at http://share.skype.com/directory/.

Plug-ins are written by third-party developers. Plug-ins are not supported by Skype; rather, they are supported by the developers of the respective plug-in. Plug-ins can be certified by Skype, and as a developer, that should be a main goal for your design. To identify the criteria your product must meet to be “Skype Certified,” visit the Skype Certification Program site at http://share.skype.com/developer_zone/certification/certification_program/.

Note that, even though most of the certification program is focused on hardware devices, a programmer must be involved to write the software that allows the hardware device to interact with the Skype application.

The Skype API for Windows

The implementation of the API for Windows is such that messages are sent between the plug-in application and Skype by using the Win32 SendMessage() function. This standard mechanism for communication under the Windows operating system can be difficult to implement if you are not used to low-level Win32 communications.

There are C++ source code examples provided at the Skype developer site. Fortunately, a number of projects have done the hard work for you, providing an implementation of Windows messaging and leaving you to add your Skype API specific functionality. If you are using C++ and developing for Windows and Linux, you can use ++Skype to greatly simplify your development task. ++Skype is Open Source and can be obtained at Ice Brains Software: www.icebrains-soft.com/skype_library_download.

If you are not a C++ programmer, you should take a look at SkypeX. SkypeX, a product from Beesync Technologies, provides a COM library that allows you to use the Skype API from a variety of ActiveX-enabled programming and scripting languages, including Microsoft .Net Framework programming languages. Further information on SkypeX is available at www.beesync.com.

Another extremely comprehensive implementation, ActiveS, is available from Khaoslabs at www.khaoslabs.com. ActiveS does a similar job of wrapping the message-sending layers of the Skype API for you, making it much easier to communicate with Skype. The library is available under a BSD-style license; you can use it within your own application (commercial or otherwise) without having to pay a fee or release the source code.

The aforementioned alternative implementations allow for development of Skype API programs using virtually any of the popular programming languages in use today. Some of those languages include C#, VB.Net, J#, Visual BASIC 6.0, JavaScript, JScript, VBScript, VBA, Java, and ActivePerl for Windows.

As is the standard practice with all free software and add-ins, you should carefully read the copyright, licensing, and distribution documents before you commit to using them as part of you application project.

The Skype API for Mac OS X

The Skype API for Mac OS X provides interfaces for Carbon, Cocoa, and AppleScript programming languages. You must be running Mac OS X vi 0.3 (Panther) or later. If you are creating Widgets, you must be running Mac OS X v10.4 (Tiger). First you must download the Skype.framework at http://download.skype.com/share/devzone/example_macosx.dmg.

You must include the Skype framework with your application, and you should abide by Skype’s recommendation to include it as an embedded framework. Simply copy the Skype.framework into your application bundle. Once you have the framework in the application bundle, you can link it to your application.

As mentioned earlier in this chapter, the Skype API for Mac OS X should be implemented by creating a delegate class and implementing the appropriate SkypeDelegate interface for the language you choose. The delegate architecture is available for only Cocoa and Carbon. AppleScript has only one command. This command allows you to send any command string that complies with the Skype API protocol documentation.

The Skype API for Linux

If you are running Fedora Core 3, SuSe 9, Mandriva 10.1 Debian, or Gentoo 1.4., you should not have any trouble using the Skype API. As previously mentioned, to write to the Skype API on Linux, you must have the D-BUS distributions. Once you have built the D-BUS components, you can update the /etc/dbus-1/system.d/skype.conf and add the following XML code:

image

Once you have completed the configuration file, you will receive a message when initializing to confirm that you want to allow the external program to use Skype.

The Skype API for SkypeNet

The SkypeNet API enables you to access the Skype instant messaging and presence system without having to install the full Skype application on your computer system. This capability allows you to build Skype support directly into your application in a much more lightweight fashion than was previously supported. SkypeNet also greatly simplifies installation and distribution of Skype-aware client applications.

The Skype API for SkypeWeb

SkypeWeb, currently under development by the Skype development team, is touted as being able to allow you to publish your Skype online status on the Internet. You simply copy the HTML code provided by Skype and paste it into the Web site of your choice. Your colleagues and friends are then able to view your status simply by browsing the page.

If you can’t wait for SkypeWeb, Skype plug-ins that provide similar functionality are available now. One such example is Jyve, at www.jyve.com, which provides Web presence.

To use Jyve Web presence simply install the plug-in and add the following code to your Web site of choice, replacing SkypeUserName with your user name:

<img src=“http://www.skypepresence.com/SkypeUserName.png” border=“0”’>

Depending on your current online status, or that of the user name you entered, you will then see an image something like one of the following:

image

Some Simple API Tricks

Before you get started, visit some of the sites referenced in this chapter. These sites include many useful sources of information, including code examples in many different programming languages. The examples, combined with the documentation resources and the free API helper interfaces, will provide you with a good foundation for developing your own useful utilities. Another crucial step in the development of any project is design. It is very important to answer some basic questions before you start the project.

The first question you have to ask is “What platform will I support?” The answer will determine the programming language you will use to write your component. If you are planning to write a component for all platforms, C++ is the best route to take. It is important to note that most Skype users are on the Windows platform, and it just happens to be the OS that has the most code samples, includes the most tutorials, and is the easiest platform on which to build.

The following is an example of a Visual Studio 2003 C# project that uses the ActiveS COM library from KhaosLabs to access the Skype API and open the Sound Devices options page:

using System;

using System. Drawing;

using System. Collections;

using System. ComponentModel;

using System. Windows. Forms;

using System. Data;

using SKYPEAPILib;

image
image
image
image
image
image

The source code for this sample project can be downloaded from Dan Douglass’s Web site at www.codehatchery.com/SkypeSoundTool.Zip.

With relatively little code, I have utilized the Skype API to provide the user with quick access to a standard Skype dialog to configure settings. It is possible to enumerate all the sound devices and allow the user to define and quickly choose configuration profiles or any number of useful tasks. The seemingly limitless power and potential for this functionality, combined with the Skype Certification program, have made a vast new market open for creative new ideas.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.120.202