2009-10-23

CTI (Computer Telephony Integration) for SugarCRM

Recently I come across SugarCRM. It has a Community Edition which I do not need to pay. Moreover, since it is open-source, I can realize some customization easily.

I have experience in CTI (Computer Telephony Integration). But what I can search around SugarCRM is its integration with Asterisk, which is also an open source telephony project.

Because I have already an Avaya installation base, I study whether I can do some quick start work easily.

What I need are two functions:

(1) Screen Pop
To pop up the SugarCRM screen based on the Calling Line Identity (CLI)

(2) Click to Dial
Turn the phone number in the SugarCRM screen to a link that is clickable and activate automatic phone dialling

For those readers which are familar with CTI, these are just very basic features. But it is achievable for SugarCRM, this is already a great time-saver for the CRM users.

I tackle the problem in the following ways:

(1) Screen Pop
Since SugarCRM is web-based, I can simply ask the browser to navigate to a specific link.

The first question is what the link is.

In SugarCRM, I make a search with a phone number. Then I get the following screen.


Great, I find the URL is
http://127.0.0.1/sugarcrm/index.php?module=Home&query_string=test&advanced=true&action=UnifiedSearch&search_form=false&query_string=5551888&search_mod_Contacts=true
5551888 is the phone number I have typed.
Therefore in .NET code, I use:
url_str = "http://127.0.0.1/sugarcrm/index.php?action=UnifiedSearch&search_form=false&advanced=false&query_string=" _
& SkpSock1.CLID & "&search_mod_Contacts=true"
System.Diagnostics.Process.Start(url_str)
Here, SkpSock1.CLID is my CTI object to collect the CLID (Calling Line Identity) property.

(2) Click to Dial
I find SugarCRM has Skype integration, in which it will convert a phone number to a clickable link. First you need to turn this feature on in the Administration screen, as follows:

After the feature activation, you will find that when you put a mouse pointer over a phone number, you can find it the associated link is :
callto://5551234/

In Windows, each URL protocol can be managed by the "Folder Option" in the Windows Explorer. (Someone suggested registry hack. But I prefer the conventional way.)

After pressing the "Advanced" button and then the "Edit" button, you can set your preferred program to handle this protocol. In my case, I have

written a program called "qcallto.exe". Windows will pass the link a program parameter to it.

Finally, a point of SugarCRM hack. As shown in the SugarCRM adminstration screen, it requires a phone number to conform to certain format (e.g. prefixed with a plus sign). I do not like this convention. Why cannot SugarCRM simply treat all the phone number clickable?

Thanks to the PHP open sources, I find that in "c:\Inetpub\wwwroot\sugarcrm\include\utils.php" (the actual directory depends on your installation), there is a php function will determine whether a phone number is clickable:

Original:
function skype_formatted($number){
 if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
  return false;
  }
 else {
   return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' ||
   substr($number, 0, 2) == '011';
  }
 }

I change it to
function skype_formatted($number){
 if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
  return false;
  }
 else {
  return 1;
 }
}

Some final words... Although my implemented solution is Avaya-based, it is easily portable to other platforms (even for a modem connected phone line) easily.

2009-10-12

Why DC cannot shoot a picture with shallow depth of field

I carry an Optio S3 to make ad hoc photography.

According to the specification, the tiny camera has an aperture f2.6 - f4.8

However, even at an aperture f2.6, I can never shoot a picture with sufficient shallow depth of field (DOF), except in macro mode of course.

I start to ask why.

The most authoritative reference (but hard to understand) about Depth of Field is at Wiki (link http://en.wikipedia.org/wiki/Depth_of_field)

It gives complicated formula to show the relation of DOF vs. format size (though roughly speaking, DOF is inversely proportional to format size). Since my DC has a small CCD, the DOF is less shallow than the conventional SLR.

However, I try to associate the problem with APS-C or Four Thirds or micro Four Thirds.

In these cases, usually, we will use a crop factor to represent the effective focal length at full-frame (FF, at 35mm) format size . For instance, even you use a lens with 18mm on DSLR with crop factor 1.6, its effective angle of view is just same as 28.8mm at FF.

Please note that aperture is actually stated in F-number (the ratio of focal length to effective aperture diameter).

Then why not use similar the crop factor to calculate the effective DOF?

For instance, my Optio S3 has the focal length 5.8mm (equivalent to 35mm at FF). This means that the crop factor is about 6X.

Then even at aperture f2.6, the "equivalent" aperture at FF is already 6x2.6 = 15.6

This explains why I cannot shoot at shallow DOF even with the largest aperture (smallest F-number) because its FF-equivalent aperture at 15.6!

2009-10-09

Using COM objects in VB.NET

I am an old-fashioned guy and right now even though I uses VB.NET for my new programming, I still need to resort to old COM objects sometimes.

I find there is not much references to facilitate the process (e.g. I do not like command line tools). If I have a VB6 project orginally, the Studio Express can import it automatically. But if I starts a new .NET project, I find the following procedures is the quickest:

(1) Add the COM reference in the "Tools" | "Choose Toolbox Items" menu, so that the object is selectable in the left Toolbox


(2) Choose the COM Components Tab. If your object has been registered before hand, it is listed. Otherwise, click the Browse button to include it in the list


(3) Then you will find the Componet will appear in the left Toolbox. You then can drag it into your form.


(4) You will find VB.NET will automatically add appropriate references in your Project Properties, as in the following screen dump. In my cases, VB.NET add two references: one is the Interop and one is the AxInterop