Tutorials - Click To Dial Eclipse Address Book Demo

From Open CSTA

Jump to: navigation, search

This tutorial was written in 2006. It needs clearer instructions and some pictures to explain some things.

Adding Functionality to the Demo AddressBook from Eclipse SWT Examples

  • Copy the sources to a new directory. I put them in /usr/local/src/java/oscsta/AddressBookDemo/src/au/com/mrvoip/oscsta/demo/addressbook/
  • Create a new java project using existing sources pointing to the src directory of where they live so the package declaration works.
  • Name the project CSTA Address Book
  • Add to the build path the org.eclipse.swt project
  • At this stage everything should work as if the address book demo program still lives in the SWT Examples package from eclipse.org
  • I'm aiming to add a Call menu item when you right click on a contact.
  • Add the jar files required to the build path of the project by right clicking on the project name and going to Configure Build Path - from here, Add External JARs. Put the four jar files from the lib directory in the build path. The four jar files are:
au.com.mrvoip.communications.jar
this has all the communications classes for the project. The ones used by the client are only for connecting to the server via the network.
au.com.mrvoip.config.jar
this just reads in the config file oscsta-j.conf which should be in the /usr/local/src/java directory.
au.com.mrvoip.oscsta.client.jar
This is the guts of the CSTA on the client side
au.com.mrvoip.oscsta.stack.jar
CSTA data
  • In the AddressBook.java file add into the createPopUpMenu() method on line 728 a line for the pop up menu to display the word Call. Note: All of the code examples below apply to the AddressBook.java file unless otherwise specified.
items[8].setEnabled(count != 0);//call
  • Add in the right click pop up menu item - it doesn't do anything at the moment
//Call
item = new MenuItem(popUpMenu, SWT.CASCADE);
item.setText(resAddressBook.getString("Pop_up_call"));
item.addSelectionListener(new SelectionAdapter() {
	public void widgetSelected(SelectionEvent e) {
            //COME BACK IN FILL IN THE IMPLEMENTATION
            //THIS IS JUST TO CHECK THAT WE HAVE GOT THE CORRECT UI STUFF HAPPENING
	}
});
  • Create an entry in the resource bundle properties file
Pop_up_call = &Call
  • Add in the import statments for CSTA functionality
import au.com.mrvoip.apps.objects.CSTAApplication;
import au.com.mrvoip.oscsta.client.CSTAFunctions;
import au.com.mrvoip.oscsta.client.hipath3000.CSTAClient3000;
import au.com.mrvoip.oscsta.common.AgentEvent;
import au.com.mrvoip.oscsta.common.CallEvent;
  • Implement the CSTAApplication interface
change:
public class AddressBook{
to
public class AddressBook implements CSTAApplication{

As a result, there are three methods that need to be implemented:

public void CSTACallEventReceived(CallEvent event) ;
public void CSTAAgentEventReceived(AgentEvent event) ;
public void TDSDataReceived(String dev, String code, String data) ;

So put them in at the bottom of the AddressBook.java file

public void CSTACallEventReceived(CallEvent event){
   //CODE WILL GO HERE LATER ON A CALL EVENT
}
public void CSTAAgentEventReceived(AgentEvent event){
   //CODE WILL GO HERE LATER FOR ANY AGENT EVENTS
}
public void TDSDataReceived(String dev, String code, String data){
   //IF THE TELEPHONE DATA SERVICE IS EVER USED, THAT DATA WILL LAND HERE
}
  • Declare the CSTA logic. The highest level interface is called CSTAFunctions which supports a number of CSTA supported PBXs.
private static CSTAFunctions csta;
  • Make an object of the CSTA Functions... This example uses CSTAClient3000 which works with the Siemens Hipath 3000 PBX. (Formerly Hicom 150 series)
csta = new CSTAClient3000();
  • Now, run the program as is and you should be able to add and entry, then when you right click on it a Call option is presented in the menu. Now it is time to go back and actually make the call work.
  • Add in an entry into the resource bundle (examples_addressbook.properties) so that the instance of the AddressBook can be associated with your extension.
MY_EXT = 4800
  • Declare MY_EXT as a variable in the AddressBook program so that it reads in the MY_EXT variable from the properties file.
private static String MY_EXT = resAddressBook.getString("MY_EXT");
  • Make the Call section of the pop up menu call the CSTA MakeCall method.
Replace these lines:
//COME BACK IN FILL IN THE IMPLEMENTATION
//THIS IS JUST TO CHECK THAT WE HAVE GOT THE CORRECT UI STUFF HAPPENING

With these lines:
 	   TableItem[] items = table.getSelection();
	   if (items.length == 0) return;
	   copyBuffer = new String[table.getColumnCount()];
	   for (int i = 0; i < copyBuffer.length; i++) {
            if( i == 2 ){
		csta.MakeCall(MY_EXT, items[0].getText(i) );
	     }
	   }
  • Congratulations, that's it. It took me about 3 hours to write this tutorial. It's probably a 30 minute job following these instructions. Go and find some java email clients and add this functionality. Siemens will love you ;)
Personal tools