import com.lotus.sametime.telephony.TelephonyStatus; import com.lotus.sametime.telephonymanager.TelephonyAdapterComp; import com.lotus.sametime.telephonymanager.api.TelephonyAdapterErrorEvent; import com.lotus.sametime.telephonymanager.api.TelephonyAdapterListener; import com.lotus.sametime.telephonymanager.exceptions.MissingConfigurationInfoException; /** * Sample application which uses the Telephony Adapter Component to : * * 1. Add (and remove) watch on a user, and receive the Sametime status. * In order to receive the sametimeStatusChanged event after adding * the watch, you need to login to any Sametime client (as this user), * and change his status. In any case, you will always receive his * initial status. * * 2. Publish the user's telephony status to the Sametime server * In order to see that the telephony attribute of this user has changed, * you can run the application ClientSample that is provided * together with this one. * * Note: The Telephony Adapter Component uses its own configuration files * to decide to which Sametime server(s) to login to. For additional information * please refer to the file st.telephony.adapter.properties * * @author Shiri Lupovich, September 2007 * */ public class TelephonySample implements TelephonyAdapterListener { /** * The users on which we will set the attribute. */ private static final String USER_TELEPHONY_ID = "baba4"; /** * The telephony component */ TelephonyAdapterComp _telephonyComp; /** * Construct a new TelephonySample object */ public TelephonySample() { System.out.println("in TelephonySample"); // create the telephony component _telephonyComp = TelephonyAdapterComp.getInstance(); // add myself as a listener to receive sametimeStatusChanged events _telephonyComp.setListener(this); // initiate the component try { _telephonyComp.initiate(); } catch (MissingConfigurationInfoException e) { e.printStackTrace(); } } /** * communityAvailable * The Sametime server is now available for adding watch on users and publishing the * telephony status of users */ public void communityAvailable() { System.out.println("communityAvailable"); // Add watch on the telephony users _telephonyComp.addWatch(USER_TELEPHONY_ID); // Publish the telephony status of the user _telephonyComp.publishTelephonyStatus(USER_TELEPHONY_ID, TelephonyStatus.TELEPHONE_STATUS_BUSY); } /** * communityNotAvailable * The Sametime server is no longer available for adding watch on users and publishing the * telephony status of users */ public void communityNotAvailable() { System.out.println("communityNotAvailable"); } /** * Error has occurred while trying to add watch or * publish a telephony status */ public void errorEvent(TelephonyAdapterErrorEvent event) { System.out.println("errorEvent "+ event.getDescription()); } /** * The Sametime status of a user whom we asked to add watch on, * has changed */ public void sametimeStatusChanged(String telephonyUserId, int sametimeStatus) { System.out.println("sametimeStatusChanged for user: "+ telephonyUserId+ " Sametime status: " + sametimeStatus); } /** * Startup a SA that will update a user's attribute * @param args */ public static void main(String[] args) { System.out.println("main"); new TelephonySample(); } }