Skypekit.NET

Published:
Introduction

Some developers today tend to use Skypekit in their applications to make it more interactive with the user. Skype API is very awesome indeed but the problem is it is only available in C++, Java and Python. I can't understand why Microsoft didn't develop API for .NET so we can develop it in C# or VB.NET.

I'm one of those, I needed to embed Skype into my graduation project and after I paid the 5$ fees and downloaded the SDK and Runtime I was surprised when I found that there is no support for the .NET languages.

So, the only way I found is to convert C++ methods into a COM component then I can call it in C# using DLLImport. And I spent weeks trying to do this solution but all in vain.

A punch of errors came to my face when I tried to create a new C++ project away from their pre-made tutorials. I was very sad with this result.

I tried to do it in Python but for some reason the socket couldn't make the connection to Skype.

Then I found the magic tool IKVM.

Background

IKVM is a tool that is used to convert Java Applications to .NET Executables (.exe) and Assemblies (.dll).

I used it to convert the Skype Class in their ready-made Java Classes into a .NET 'skypekit' class

Then I manually converted all the Java utilities Code to their corresponding C# code including:

   
AppKeyPairMgr Class
   
Listeners Class
   
MySession Class
   
ParseSkypeKitVersion Class
   
PrintStream Class
   
SignInMgr Class
   
XmlStrMgr Class

And I added an additional Class containing the variables needed and the two main variables which are:

   
myAppKeyPairMgr
   
mySession

I then managed to use Skypekit in my C# application very easy and I could access all its features.

In the uploaded project I included all the 12 Java tutorials done in C# to assure that my .NET DLL is working.

You can find the download link at the end of the article.

Using the code

To use it, First you have to add the following references:

   
IKVM.OpenJDK.Core.dll : Java main classes converted to .NET
   
IKVM.OpenJDK.Security.dll : Java Security Classes (needed for the PrivateKey Class and X509Certificate Class)
   
IKVM.OpenJDK.Text.dll (Rarely Needed) : Needed for the DateFormat Class
   
IKVM.Runtime.dll : IKVM Runtime libraries
   
skypekit.dll : Skype Main Class converted from Java Jar Application using IKVM
   
Skypekit.NET.dll : My classes created manually based on Java classes

And this is an example of a C# code To make Login

public SkypeMain skypeMain;
                      public void Login(string user, string pass)
                              {
                                  skypeMain = new SkypeMain();
                                  if ((!skypeMain.myAppKeyPairMgr.resolveAppKeyPairPath()) ||
                                      (!skypeMain.myAppKeyPairMgr.isValidCertificate()))
                                  {
                                      return;
                                  }
                      
                                  skypeMain.mySession.doCreateSession(skypeMain.MY_CLASS_TAG, user, skypeMain.myAppKeyPairMgr.getPemFilePathname());
                      
                                  if (skypeMain.mySession.mySignInMgr.Login(skypeMain.MY_CLASS_TAG, skypeMain.mySession, pass))
                                  {
                                      //Do Something
                                  }
                              }
                      

Open in new window


Remember to Do these step before running any Skype application.

    - Download your Keypair (*.pem)
    - execute
    openssl pkcs8 -topk8 -nocrypt -inform PEM -outform DER -in myKeyPair.pem -out myKeyPair.der 
                      

Open in new window

   to create the certificate file (*.dem)
    - Make sure that skype runtime console is running before you run your app.

Points of Interest

I learnt a lot from this painful experiences. So, I need you to know that every problem has a solution but needs some patience and deep thinking.

I reached this powerful and complete solution after weeks of search and thinking.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Keep track of it on My Code Project Article :
http://www.codeproject.com/Articles/330778/Skypekit-NET

Download

You can download it from my MediaFire Account:
Skypekit API and Tutorials
3
4,347 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.