This document was generated from CDN thread Created by: Stefan Schallmeiner on 20-11-2009 02:59:22 PM Hi guys! I'm pretty new to JTAPI and I wanted to ask you a question,... Is it possible to to set CallForwardAll on a cisco phone trough JTAPI? I found something in the Developers guide about the interface CallControlAddress but 'cause its an interface I thought it is not implemented yet,... Would someone be so kind to tell me if it is possible and if yes it would be great if someone got a little piece of example code for me! - StefanSubject: RE: Setting CallForwardAll? Replied by: Joseph Moskie on 21-11-2009 01:31:16 AMEdit: I'm sorry for the format of this post. The forums software doesn't like the code tags and is randomly making this italic, and inserting line breaks. You can do this by using the implementation of the CiscoAddress object: AddressImpl. Thefirst thing you have to do is get a reference to the Address you wantto set forwarding on. This can be done by getting a list withCiscoProvider.getAddresses(), and finding the one you want. Cast itstraight to an AddressImpl. 1Address[] addresses = provider.getAddresses ();
2AddressImpl address = (AddressImpl) addresses[i]; // loop or whatever to find the one you want, i is the index
Thenyou have to add a CiscoAddressObserver to the address. You'll need toimplement your own CiscoAddressObserver. As an example, I created adummy Address Observer class that doesn't do anything other than sit onthe CiscoAddress and allow you to invoke features. If you wanted tohandle Address Events, you'd have to implement the dumy method. 1import javax.telephony.events.AddrEv;
2import com.cisco.jtapi.extensions.CiscoAddressObserver;
3
4class MyAddressObserver implements CiscoAddressObserver
5{
6 MyCallObserver() {
7
8 }
9
10 public void addressChangedEvent(AddrEv[] arg0) {
11 // dummy
12 }
13}
You add the CiscoAddressObserver thusly: 1MyCallObserver obs = new MyAddressObserver();
2address.addObserver(obs);
Nowthat you have the Address that you want, and it's observed, you caninvoke the various Cisco APIs on it. The one you're interested in is.setForwarding(). This API is a little tricky, becauseit's intended to be flexible. It takes an array ofCallControlForwarding objects. For a basic call forward all to oneaddress, we only need one, but the code below will allow you to extendit easily later. First we build a Vector with oneCallControlForwarding object in it, whihc will forward all calls,unconditionally, to the DN "1010". Then we convert theVector into an array. You should skip this step if you wanted to justwork with the fixed-sized array from the start. Then we invoke the setForwarding() API on the AddressImpl object we obtained earlier. 1Vector<CallControlForwarding> ccfVector = new Vector<CallControlForwarding>();
2
3ccfVector.add(new CallControlForwarding("1010", CallControlForwarding.FORWARD_UNCONDITIONALLY));
4
5
6
7CallControlForwarding[] ccfArray = new CallControlForwarding[ccfVector.size()];
8
9ccfArray = ccfVector.toArray(ccfArray);
10
11
12
13address.setForwarding(ccfArray);
If the API doesn't throw any exceptions indicating errors, the forward all request was successful. All calls will go to DN 1010. Toundo this, there is a clearForwarding() API on AddressImpl. It doesn'ttake any arguments, so I don't think you'll ned any sample code forthat one ;)Subject: RE: Setting CallForwardAll? Replied by: Stefan Schallmeiner on 23-11-2009 11:19:46 AMHi Joseph! First of all thanks for your fast reply, but I can't find the implementation AddressImpl in which package is it included? (I looked in com.cisco.jtapi and javax.telephony.callcontrol for it) thanks so far - StefanSubject: RE: Setting CallForwardAll? Replied by: Stefan Schallmeiner on 23-11-2009 11:43:11 AMOk I think i've got a different problem: the jar is added and I see the class-file in the left section but eclipse says that the Type is not visible whatever that means, do you know whats wrong with eclipse? ;)Subject: RE: Setting CallForwardAll? Replied by: Stefan Schallmeiner on 23-11-2009 12:06:56 PMOk, I exploded the jar and added it as class-folder now the visible error disappears but at runtime I get an IllegalAccessError Exception,... :/ - StefanSubject: RE: Setting CallForwardAll? Replied by: Joseph Moskie on 23-11-2009 12:23:35 PMHow are you adding the jar to Eclipse? You shouldn't need to "explode" it or anything like that. Make a folder under your project called "lib". Paste the jtapi.jar file there. You can do all of this from the Package Explorer. Refresh the project. Right click on the project name in the Package Explorer, and hit refresh, to make sure it picked up the jar. Right click on the Project from the Package Explorer again, and hit "Properties". Go to "Java Build Path", and then click on the "libraries" tab. Hit "Add JARs...". This is the first button, and not "External JARs." Browse and find your project, and select lib/jtapi.jar from this list. The project should rebuild and refresh. The jtapi.jar file should show up under the "Referenced Libraries" tree in the Package Explorer for this project. The JAR file is now a part of the Java Build path, and you should be able to use all of the classes and methods normally.Subject: RE: Setting CallForwardAll? Replied by: Stefan Schallmeiner on 14-12-2009 02:39:44 PMHi Joseph! Sry, I've been busy lately,... I did exactly like you explained it, but the error stays the same,... (The Type AddressImpl is not visible) - StefanSubject: RE: Setting CallForwardAll? Replied by: Stefan Schallmeiner on 04-01-2010 11:35:11 AMHi everyone! I found the problem. I had to add my Files to the package com.cisco.jtapi where Addressimpl is located,... Now everything works fine,... Thanks a lot - StefanSubject: RE: Setting CallForwardAll? Replied by: Joseph Moskie on 04-01-2010 09:47:56 PMStefan, While that will probably work, it should not be neccessary, and is quite an odd thing to do (putting your code in the package of a library you're using). Something is wrong with your Classpath or your imports if this is required.