/** * SkypeListener Override: Tutorial Handler - Conversation ListType. * <br /><br /> * If it's <em>not</em> a LIVE_CONVERSATIONS change, ignore it; if it's not a * type we're interested in, simply write it to the console. * <ul> * <li>Tutorial 5 - Looks for RINGING_FOR_ME so we can join in.</li> * <li>Tutorial 6 - Looks for IM_LIVE or RECENTLY_LIVE/NONE. Former case, indicates * that a call is in progress; latter case, indicates that a call has ended.</li> * </ul> * * @param conversation * The affected Conversation. * @param type * The Conversation list type that triggered this event. * @param added * Ignored. * * @since 1.0 * */ public void onConversationListChange(Skype obj, Conversation conversation, Conversation.ListType type, bool added) { MySession.myConsole.printf("%s: ConversationListChange fired on: %s%n", mySession.myTutorialTag, conversation.getDisplayName()); if (type == Conversation.ListType.LIVE_CONVERSATIONS) { Conversation.LocalLiveStatus liveStatus = conversation.getLocalLiveStatus(); MySession.myConsole.printf("%s: Live status changed to %s%n", mySession.myTutorialTag, liveStatus); if (liveStatus == Conversation.LocalLiveStatus.RINGING_FOR_ME) { activeConversation = conversation; activeConversationParticipants = conversation.getParticipants(Conversation.ParticipantFilter.ALL); conversation.join(); mySession.callActive = true; } else if (liveStatus == Conversation.LocalLiveStatus.RECENTLY_LIVE || liveStatus == Conversation.LocalLiveStatus.NONE) { MySession.myConsole.printf("%s: Call finished.%n", mySession.myTutorialTag); activeConversation = null; activeConversationParticipants = null; mySession.callActive = false; } else if (liveStatus == Conversation.LocalLiveStatus.IM_LIVE) { MySession.myConsole.printf("%s: Live session is up.%n", mySession.myTutorialTag); } else { MySession.myConsole.printf("%s: Ignoring Conversation status %s%n", mySession.myTutorialTag, liveStatus); } } }
/** * Business logic for answering a call (Tutorial_5 - Find conversation to join). * <br /><br /> * Since this method is invoked from the Conversation event handler * {@link #onPropertyChange(com.skype.api.Conversation, com.skype.api.Conversation.Property, int, String)}, * it's most convenient to place it here in the JavaTutorialListeners class. * * @return * <ul> * <li>true: call picked up</li> * <li>false: no call to pick up/call not answered/error</li> * </ul> * * @since 1.0 */ public bool doPickUpCall() { Conversation[] liveConversations = mySession.mySkype.getConversationList(Conversation.ListType.LIVE_CONVERSATIONS); if (liveConversations.Length == 0) { MySession.myConsole.printf("%s: No live conversations to pick up!%n", mySession.myTutorialTag); return(false); } Conversation targetConversation = liveConversations[0]; Participant[] callerList = targetConversation.getParticipants(Conversation.ParticipantFilter.OTHER_CONSUMERS); StringBuilder displayParticipantsStr = new StringBuilder(); displayParticipantsStr.Length = 0; int i; int j = callerList.Length; for (i = 0; i < j; i++) { displayParticipantsStr.Append((" " + callerList[i].getIdentity())); } Conversation.LocalLiveStatus liveStatus = targetConversation.getLocalLiveStatus(); if (liveStatus == Conversation.LocalLiveStatus.RINGING_FOR_ME) { MySession.myConsole.println("RING RING..."); MySession.myConsole.printf("Incoming call from: %s %n", displayParticipantsStr); targetConversation.joinLiveSession(targetConversation.getJoinBlob()); return(true); } else if (liveStatus == Conversation.LocalLiveStatus.IM_LIVE) { MySession.myConsole.printf("Another call is coming in from : %s %n", displayParticipantsStr); MySession.myConsole.println("As we already have a live session up, we will reject it."); targetConversation.leaveLiveSession(true); } else { MySession.myConsole.println(mySession.myTutorialTag + ": Ignoring LiveStatus " + liveStatus); } return(false); }
/** * ConversationListener Override: Tutorial Handler - Conversation "Live Status". * <br /><br /> * If it's <em>not</em> a "live status" change, ignore it. Otherwise: * <ul> * <li>display changes to our live status</li> * <li>handle answering calls for us</li> * </ul> * * Tutorial 6/7 - Looks for: * <ul> * <li>RINGING_FOR_ME so we can pick up the call</li> * <li>IM_LIVE to indicate that a call is in progress</li> * <li>RECENTLY_LIVE/NONE to indicate that a call has ended</li> * </ul> * * @param obj * The affected Conversation. * @param prop * The Conversation property that triggered this event. * @param value * Ignored. * * @since 1.0 * * @see com.skype.api.ConversationListener#onPropertyChange(com.skype.api.Conversation, com.skype.api.Conversation.Property, int, String) */ public void onPropertyChange(com.skype.api.Conversation obj, com.skype.api.Conversation.Property prop, int value, String svalue) { if (prop == Conversation.Property.P_LOCAL_LIVE_STATUS) { Conversation affectedConversation = (Conversation)obj; Conversation.LocalLiveStatus liveStatus = affectedConversation.getLocalLiveStatus(); MySession.myConsole.printf("%s: Live status changed to %s%n", mySession.myTutorialTag, liveStatus); if (liveStatus == Conversation.LocalLiveStatus.RINGING_FOR_ME) { MySession.myConsole.println("RING RING..."); if (doPickUpCall()) { MySession.myConsole.println("Conv: Call answered!"); activeConversation = affectedConversation; activeConversationParticipants = affectedConversation.getParticipants(Conversation.ParticipantFilter.ALL); mySession.callActive = true; } } else if (liveStatus == Conversation.LocalLiveStatus.RECENTLY_LIVE || liveStatus == Conversation.LocalLiveStatus.NONE) { activeConversation = null; activeConversationParticipants = null; mySession.callActive = false; MySession.myConsole.println("Conv: Call has ended/never started."); } else if (liveStatus == Conversation.LocalLiveStatus.IM_LIVE) { MySession.myConsole.println("Conv: Live session is up!"); } else { MySession.myConsole.println(mySession.myTutorialTag + ": Conv - Ignoring LiveStatus " + liveStatus); } } }