How to Make Skype Calls & Skype Chats in Servoy

What is Skype?

Skype is one of the most popular free messenger tool used to do text & voice chat over internet. You can also make a call to any Landline or Mobile Phones through Skype. For more information, please browse www.skype.com.

In this Tip, we will see how to integrate Skype with your Servoy Solution. How can we make Skype Call or start a Skype Chat straight from your Servoy Application.

Further Details

I have written two Servoy methods, startCallUsingSkype() & startChatUsingSkype() to make a Skype Call or start a Skype Chat. The Servoy Methods can be used for Windows and Macintosh platform and for Servoy Smart/Rich & Web Client.

Servoy Methods

function startCallUsingSkype()

{

/*

method name : startCallUsingSkype

usage: startCallUsingSkype(countryCode, phoneNumber

, [isSkypeName])

input: countryCode: text representing valid country code,

prefixed by sign ‘+’.Ex. +91 – For India.

phoneNumber: integer representing the phone number to

make a call.

isSkypeName (opt): boolean value indicating whether

want to call a skype name. Calling to

a skype name does not require a country code.

output: The script will establish a call to the specified number

or the specified skype name, if the third argument,

isSkypeName, has been passed as true, from your servoy

solution. The script can be used in Windows and Mac to

make call from your Servoy Solution.

note:

Change history:

04/04/09 Arup Ranjan Sahoo Created method

*********************************************************************/

var countryCode = arguments[0];

var phoneNumber = arguments[1];

var isSkypeName = arguments[2] != null?arguments[2]:false;

//Check for OS Type

if(utils.stringMiddle(application.getOSName(),1,7)

== “Windows”) {

//Windows Detected

//Check for Client Type

if(application.getApplicationType() == 2

|| application.getApplicationType() == 3

|| application.getApplicationType() == 4 ) {

//Make a Skype Call for Rich Client in Windows

//Prepare a Call String to call the Number Using Skype

var callString = '';

if(isSkypeName){

callString = ‘/callto:’ + phoneNumber;

} else {

callString = ‘/callto:’ + countryCode + phoneNumber;

}

//Get the Path for Skype Executable

//Default Path is C:\Documents and Settings

//\Program Files\Skype\Phone\Skype.exe

var pathToSkype =

plugins.file.getHomeDirectory().getAbsolutePath()

pathToSkype = pathToSkype.substring(0

,pathToSkype.indexOf(“Documents and Settings”))

+ “Program Files\\Skype\\Phone\\Skype.exe”;

//Call the number Using Skype

application.executeProgram(pathToSkype, callString)

} else if(application.getApplicationType() == 5) {

//Make a Skype Call for WebClient in Windows

//Call the number Using Skype

if(isSkypeName){

application.showURL(‘skype:’

+ phoneNumber +’?call’,’_self’);

} else {

application.showURL(‘skype:’

+ countryCode + phoneNumber +’?call’,’_self’);

}

}

} else if(utils.stringMiddle(application.getOSName(),1,3)

== “Mac”) {

//Mac OS Detected

//Check for Client Type

if(application.getApplicationType() == 2

|| application.getApplicationType() == 3

|| application.getApplicationType() == 4 ) {

//Make a Skype Call for Rich Client in Mac

//Prepare a Call String to call the Number Using Skype

var callString = '';

if(isSkypeName){

callString = ‘skype:’

+ phoneNumber + ‘?call’;

}else {

callString = ‘skype:’

+ countryCode + phoneNumber + ‘?call’;

}

//Call the number Using Skype

application.executeProgram("open", callString);

} else if(application.getApplicationType() == 5) {

//Make a Skype Call for WebClient in Windows

//Call the number Using Skype

if(isSkypeName){

application.showURL(‘skype:’

+ phoneNumber +’?call’,’_self’);

} else {

application.showURL(‘skype:’

+ countryCode + phoneNumber +’?call’,’_self’);

}

}

}

}

function startChatUsingSkype()

{

/*

method name : startChatUsingSkype

usage: startChatUsingSkype(skypeName)

input: skypeName: text representing the Skype Name to start

the Chat with.

output: The script will start a chart with the Skype Name

passed as an argument to the method. The script

can be used in Windows and Mac to start the Skype Chat.

note:

Change history:

04/04/09 Arup Ranjan Sahoo Created method

*******************************************************************/

var skypeName = arguments[0];

//Check for OS Type

if(utils.stringMiddle(application.getOSName(),1,7)

== “Windows”) {

//Windows Detected

//Check for Client Type

if(application.getApplicationType() == 2

|| application.getApplicationType() == 3

|| application.getApplicationType() == 4 ) {

//Start a Skype Chat for Rich Client in Windows

//Prepare a chat String to chat with the Skype Name

var chatString = ‘skype:’+ skypeName +’?chat’;

//Start the Chat

application.executeProgram(‘rundll32’

, ‘url.dll,FileProtocolHandler’,chatString);

} else if(application.getApplicationType() == 5) {

//Start a Skype Chat for WebClient in Windows

application.showURL(‘skype:’

+ skypeName +’?chat’,’_self’);

}

} else if(utils.stringMiddle(application.getOSName(),1,3)

== “Mac”) {

//Mac OS Detected

//Check for Client Type

if(application.getApplicationType() == 2

|| application.getApplicationType() == 3

|| application.getApplicationType() == 4 ) {

//Start a Skype Chat for Rich Client in Mac

//Prepare a chat String to chat with the Skype Name

var callString = ‘skype:’

+ skypeName + ‘?chat’;

//Start the Chat

application.executeProgram(“open”, callString);

} else if(application.getApplicationType() == 5) {

//Start a Skype Chat for Web Client in Mac

application.showURL(‘skype:’

+ skypeName +’?chat’,’_self’);

}

}

}

How to Use

Uses of these methods are summarized below.

Start calling in Skype:

Syntax:

startCallUsingSkype(countryCode, phoneNumber, [isSkypeName])

countryCode: text representing valid country code,

prefixed by sign ‘+’.Ex. +91 – For India.

phoneNumber: integer representing the phone number to

make a call.

isSkypeName (opt): boolean value indicating whether

want to call a skype name. Calling to

a skype name does not require a country code.

Use:

//Calling to another number

startCallUsingSkype(“+91”,”9853225678”,false);

//Calling to a Skype Name

startCallUsingSkype(“”,”Skype_name”,true);

Start chatting in Skype:

Syntax:

startChatUsingSkype(skypeName)

skypeName: text representing the Skype Name to start

the Chat with.

Use:

//Start Chatting with a Skype Name

startChatUsingSkype (”Skype_name”);

150 150 Burnignorance | Where Minds Meet And Sparks Fly!