Skype API Basics – Part 1

What is the Skype API?
The Skype API is an easy way to create plugins that can dramatically change the way Skype functions. For example, we could make a program that reads messages out loud as we receive them instead of having to check for new messages.

The Skype API is potentially very different for each of the operating systems Skype is available for. And, of course, there are different wrappers of the API available for some of the different languages.

What Operating Systems Are Supported?

  • Linux
  • MAC
  • Windows

What Languages Are Supported?
The Windows API,Skype4COM, is supported in literally any language that can import an ActiveX DLL or using a bit of hackery and some Skype commands we can also use Windows Messages via the Win32 SendMessage API .

Wrappers are available for additional languages that aren’t necessarily updated as frequently as Skype4COM. Skype4Java is a completely cross platform, language specific, implementation of the Skype API. Unfortunately, Skype4Java is infrequently updated and often lags behind the other implementations. Skype4Py is the other language specific implementation of the Skype API and can be used with Python on Windows and Linux.

What is Skype4COM?
Skype4COM is an ActiveX dll for use on Windows. Basically, it offers us a collection of properties, objects, and interfaces that we can use to manipulate Skype. By default, Skype4COM is installed with the Skype Extras although I always think it is prudent to provide it with our application and reference the included version.

What is Skype4Java?
Skype4Java is an older language specific wrapper for use with Java and is pretty much outdated and dying. I haven’t personally used Skype4Java, but have noticed it hasn’t been updated since 2006.

What is Skype4Py?
Skype4Py as previously mentioned is the language specific wrapper for Python and is fully supported on Linux and Windows. Skype4Py contains two different naming schemes: one follows the norms of Python, and the other set of naming conventions resembles Skype4COM.

Why use the Skype API?
There are a lot of interesting applications that make use of Skype to do telemarketing (predictive dialing even!), make Skype act like a fax machine, and even completely replace the need for a telephone! Unfortunately, my first use of the Skype API was to monitor employees that were deleting their Skype history and copy all of the messages sent and received to a location.

How should I get started?
Usually, I start reading a little bit about the API before, I begin to use it but I don’t ever focus in enough to learn the API completely unless I absolutely need to. Instead of spending your time focusing on learning APIs you should instead focus on learning computer programming fundamentals or some website development fundamentals.

More coming next week!

Kijiji Advertisement – Are You Kidding?

I was surfing the local Kijiji looking to see if maybe there might be some interesting contract work. Naturally, I wasted approximately forty-five seconds reading the three advertisements until I found this really pathetic offer:

“I need a website built in the next 4 weeks.
Website will have up to or may be more than 50 pages.
Will like people to be able to subscribe to posts and blogs
I will like some admin management to be able to update blogs
Website will have a 6 page flash video on the header
Some pages will have multi columns (2-3)
Some pages will have links to other pages and pictures
I will like to have some forms filled and submitted on the site
Website will have RSS feed and comment compactibility.
I have all the pictures and content ready.
Website will have google adsence
Unfortunately, I have budget restaints, I can only afford $400 for this.

If you are up to it, please send the following info
1. Your name
2. Sample sites you built
3. Phone number
I prefer someone in St. Catharines, or if you don’t mind meeting once a week until job is done.”

I have no doubt, I could implement this using some sort of content management system with a customized template but I also know that if I use WordPress even I would need to spend at least eight hours coming up with the design and then coding it. And of course, that still doesn’t help with the required forms issue does it?

Determine if Skype is Installed

The easiest method of checking whether Skype is installed is actually to check for a Registry Key. We, of course, can’t check C:Program Files for a Skype Directory because the user could have installed elsewhere (or maybe if 64 bit the operating system did?)

Skype’s API Document provides us with the following information:

To check if Skype is installed, in regedit check if the following key exists: HKCUSoftwareSkypePhone, SkypePath . This key points to the location of the skype.exe file. If this key does not exist, check if the HKLMSoftwareSkypePhone, SkypePath key exists. If the HKCU key does not exist but the HKLM key is present, Skype has been installed from an administrator account but not been used from the current account.

Generally, I only care if the Current User has configured Skype, so I will ignore the HKEY_LOCAL_Machine information and instead rely entirely on the HKEY_CURRENT_USER information.

You must make sure you reference: Microsoft.Win32 for the registry functions or modify the snippet slightly.

        using Microsoft.Win32;

        //Function uses Microsoft.Win32 to check registry value of 
        //HKEY_CURRENT_USERSoftwareSkypePhoneSkypePath and returns false if
        //the key is null
        private bool isSkypeUser()
        {
            RegistryKey skype = Registry.CurrentUser.OpenSubKey(@"SoftwareSkypePhone");

            if (skype != null && skype.GetValue("SkypePath") != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

Inline vs External JavaScript

In general, we never should have embed JavaScript inside the same file as the HTML markup and should instead place the JavaScript into an external file.

The content, presentation, and interaction code should all be separate to make your life easier as a website developer.

  • Cleaner Code. Cleaner code is much quicker to find errors in, and will reduce the complexity. In addition, changes only need to be made in one file instead of in potentially dozen resulting in a significant saving of your time and money for your client.
  • JavaScript will be better cached for future use and will reduce the size of the HTML file. Users won’t need to download the file every time the user revisits resulting in very quick retrieval.
  • Different Parsing Systems. The parsing systems used for HTML/XHTML are vastly different from the parsing/compiler systems used for JavaScript are different and can introduce nested quote problems.

JavaScript And Site Performance

JavaScript and the respective frameworks have really began to gain traction over the last couple of years. I would argue that most of the JavaScript frameworks are excellent, and truly are great for the user experience and for the programmer experience.

Unfortunately, many of the JavaScript frameworks are quite large for a web page. jQuery, for example, minified is nearly 56KB. Personally, I wouldn’t use jQuery or another JavaScript framework for static pages that might only read an XML file or display a simple animation: frameworks really are elegant for web applications. The size of frameworks isn’t much of an issue for people on broadband (cable, dsl, etc), but now as web developers we are beginning to see iPODs, iPhones, Blackberries, and other smaller electronics beginning to view our websites where the size and download speed of the frameworks, and website markup can begin to create havoc.

First, we should move all of the JavaScript to the bottom of the body because each HTTP request for an external document will block the rendering of the HTML until downloading has completed. JavaScript according to the W3C can “appear any number of times in the HEAD or BODY of an HTML document.”

Web Developers should also minimize the number of HTTP requests by combining all of the JavaScript into one file, and all of the css into a single css file. The Yahoo developer blog contains some really helpful tips. Yahoo also provides an excellent plugin for Firefox/Firebug that provides some tips and debug-type of information.

The Rise and Fall of Waterfall

Sadly, I still think there are a lot of companies that still just think,code, guess, code, guess some more and maybe eventually come up with something. We need a repeatable process that should be fairly iterative.

The Ten Commandments for C Programmers

by Henry Spencer

1. Thou shalt run lint frequently and study its pronouncements with care, for verily its perception and judgement oft exceed thine.

2. Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end.

3. Thou shalt cast all function arguments to the expected type if they are not of that type already, even when thou art convinced that this is unnecessary, lest they take cruel vengeance upon thee when thou least expect it.

4. If thy header files fail to declare the return types of thy library functions, thou shalt declare them thyself with the most meticulous care, lest grievous harm befall thy program.

5. Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest “foo” someone someday shall type “supercalifragilisticexpialidocious”.

6. If a function be advertised to return an error code in the event of difficulties, thou shalt check for that code, yea, even though the checks triple the size of thy code and produce aches in thy typing fingers, for if thou thinkest “it cannot happen to me”, the gods shall surely punish thee for thy arrogance.

7. Thou shalt study thy libraries and strive not to re-invent them without cause, that thy code may be short and readable and thy days pleasant and productive.

8. Thou shalt make thy program’s purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding.

9. Thy external identifiers shall be unique in the first six characters, though this harsh discipline be irksome and the years of its necessity stretch before thee seemingly without end, lest thou tear thy hair out and go mad on that fateful day when thou desirest to make thy program run on an old system.

10. Thou shalt foreswear, renounce, and abjure the vile heresy which claimeth that “All the world’s a VAX”, and have no commerce with the benighted heathens who cling to this barbarous belief, that the days of thy program may be long even though the days of thy current machine be short.

Dell Studio: Epic Fail

Dell fails again, this time with a Dell Studio 1550.Keys being pressed weren’t being sent properly to Windows 7, and LEDs weren’t properly lit. Solution seems to be removing the battery and pressing the power button for 10seconds.

Continue reading

Browser Redirection – Yahoo Answers

I am having problems getting mozilla firefox to display my website correctly. It works fine on Internet Explorer. So I was thinking of making a mirror of the website that is made specifically for firefox browsers. Is it possible to code a website so that it detects what browser a visitor is using and them sends them to the correct mirror ?(i.e. index_firefox.html or index_ie.html)

Background Information
At the root of this question, there lies a huge problem that really never would have occured if browser creators followed the w3c recommendations. Microsoft and Netscape fought the original browser wars in the 1990s and throughout this time both created proprietary nonstandard tags and didn’t always follow the w3c recommendations. Eventually, Microsoft’s Internet Explorer won the war and Netscape disappeared into the oblivion to eventually become the Mozilla Project.

Mozilla Firefox, Opera, Safari and Chrome basically render almost exactly (99% of the time) the current w3c recommendations for css,html, and javscript and most of the draft recommendations are followed in the current builds of these browsers. Internet Explorer on the other hand, barely follows any of the w3c recommendations from even the year 2000. IE’s terrible rendering results in us having to perform significant testing and spend significant amounts of time doing IE6, IE7, and probably now IE8 hacks.

Problems With Potential Solution
I believe that redirecting based on a browser is a terrible idea, and should be avoided at all costs because of the potential doubling or trippling of work with regards to content.

Also, what happens if the browser doesn’t have javascript support of a user has turned it off? Chrome, Firefox,Opera, and Safari users would continue to be dished out a crap website that only works on some version of IE.

My Solution
Avoid the use of redirections for different browsers and instead developing a website that is 100% standards compliant and than start to add IE hacks as necessary.

Open Source Week 2009

I am so excited to say that I finally booked everything I need to attend the Toronto Open Source Week. In a couple of weeks time, I will be spending a couple of days in Toronto while attending the many conferences, workshops and presentations on open source software (GNU Linux, PHP, etc.)

I am hoping to do some serious networking for my consulting business, along with getting more experience with web programming and the rest of the LAMP stack which seem to be creating an IT revolution.

I hope to see you at some of the events!

Difference between HTTP Methods (Get & Post)

It has been quite a while since I have used Yahoo! Answers. I often find many of the answers to questions are blatantly wrong or that the person answering doesn’t really provide a link to additional information. This blog post is designed to include additional information on the Get & Post methods of HTTP and what should be one of the simplest topics, but isn’t because some people insist on using large words like idempotent.

HTTP uses two methods of getting and receiving data from a webserver, generally these two methods can be split into two simple phrases:

  • Get = operations that can be safely repeated because there’s no side effects. Never use get for sensitive operations, or when uploading files.
  • Post = operations that might have side effects. I always use post for any operation, I don’t want repeated again; usually this is any operation that involve database manipulation like creates, updates, or deletes.
  • The default for form submission, or even just simple website browsing is a get request. Basically, every time you click a link this a get request and most of the time you submit a form this is a post request. When using a get request to pass information, you will often see what variables after a question mark, called parameters in the url.

    Get Method
    This blog post’s web address ( http://brcline.com/blog/?p=98 ) makes use of a parameter in it’s url. The parameter or variable is simply the letter p which we can easily see is equal to 98 and because of the parameters being in URL.

    Unfortunately as a result of the parameters being in the url there is a limit of how much data can be submitted (256 bytes is the limit in some browsers.) Obviously, using get requests is not a secure operation as the user can clearly see what is being passed along and what each value is equal to. One of my favourite uses of the Get request is to use it for anything, I would want the user to be able to link or bookmark as this page should always work.

    Post Method
    Post is the slightly more secure of the two methods but should never be the only technique used for operations involving Credit Cards, Identification Card Numbers (Social Insurance Number, Driver’s License Number,etc ).

    Post relies on data being sent back to the server in a content message that contains the parameters and their respective values. The content messages do not have a defined maximum length, so this is the prefered method of submitting anything with lenghty text or many answers.

    Questions to Ask In An Interview

    I’ve been involved in interviewing people, and like everyone I have also been interviewed. I believe that when you are interviewing for a company, it is a time for both parties to determine if you will fit into the corporate culture so everyone should ask questions. I strongly believe that if something really bothers you in an interview that you should walk away if you have any doubts.

    I usually ask at least these four questions, although sometimes I will ask more to clarify something I’m concerned with or to show that I don’t quite understand but would like to understand.

    Do programmers have quiet working conditions?
    This question really determines if I will be able to get into a really productive mind set or if I will struggle most of my day getting in and out of the zone. I believe that there’s no harm with a programmer sharing an office with someone else, but it wouldn’t be very logical to put a programmer beside someone else that is always on the phone.

    On average, how long does an employee remain with your company?
    You should never suggest or use the phrase “turnover” because you will probably just receive a simple response like “low.” Obviously, if the company is younger or a startup this question might be completely meaningless. Ideally, you will hear that there are some programmers that have been with the company for several years.

    Could you explain to me how the development process works here?
    I don’t usually expect much of a response to this question if the person works in Human Resources, but hopefully you will hear about processes being documented.

    How do you track/follow bugs/issues?
    This question is used to probe how organized the development and maitenance processes are. Ideally, the team will be highly organized which should make your time used effectively and software released with fewer bugs.

    Books I’ve Read

    Sometimes, when I have applied for full time employment in the past I have seen job ads or received responses from companies asking what books I’ve read. Nearly every time, I have heard this question I was so shocked because I didn’t ever keep track of what I had read or where I had gleamed those little bits of valuable information.

    This list will be updated at least monthly, although when I have an abundance of extra time I might be able to read an additonal book or two. Please note that this list only contains books I am interested in professionally and in no specific order.

    Books Finished:

    • ASP.NET 2.0 Unleashed
    • Beginning Ubuntu Linux
    • C# How to Program
    • Code Craft: The Practice of Writing Excellent Code
    • Don’t Make Me Think: A Common Sense Approach to Web Usability
    • jQuery In Action
    • Network+ Guide to Networks
    • Learn to Program With C++
    • Practical Web 2.0 Applications with PHP
    • Systems Analysis and Design in a Changing World
    • Teach Yourself HTML 4 in 24 Hours
    • Visual Basic 6 Complete
    • Web Style Guide: Basic Design Principles for Creating Web Sites

    Currently Reading:

    • Operating System Concepts

    Although the list is getting pretty extensive, please understand that these are books I can verify as of September 7th 2009. The title suggests this is only books, so please remember that I definitely have visited many websites along the way.

    Read a Whole Textfile Into a String

    At work, I’ve been working on an auto html emailer.   I’ve been receiving files from our Latin American office that are completely in spanish and trying to sift through the HTML and recreate the email taking into account size and the fact that Outlook 2007 still doesn’t accept background images and most CSS.

    Anyway, one of the files they sent originally that the old software produced didn’t work. And to prove this, I had to somehow figure out how to loop through this text file they’ve been sending and prove this to my boss. I eventually found a function, that would let me avoid the looping, the steam writer and just do it.

    System.IO.File.ReadAllText(String fileName)