com.skype.tutorial.util
Class JavaTutorialListeners

java.lang.Object
  extended by com.skype.tutorial.util.JavaTutorialListeners
All Implemented Interfaces:
com.skype.api.Account.AccountListener, com.skype.api.Contact.ContactListener, com.skype.api.ContactGroup.ContactGroupListener, com.skype.api.ContactSearch.ContactSearchListener, com.skype.api.Conversation.ConversationListener, com.skype.api.Message.MessageListener, com.skype.api.Participant.ParticipantListener, com.skype.api.Skype.SkypeListener, com.skype.api.Sms.SmsListener, com.skype.api.Transfer.TransferListener, com.skype.api.Video.VideoListener, com.skype.api.Voicemail.VoicemailListener

public class JavaTutorialListeners
extends java.lang.Object
implements com.skype.api.Account.AccountListener, com.skype.api.Skype.SkypeListener, com.skype.api.Contact.ContactListener, com.skype.api.ContactGroup.ContactGroupListener, com.skype.api.ContactSearch.ContactSearchListener, com.skype.api.Conversation.ConversationListener, com.skype.api.Message.MessageListener, com.skype.api.Participant.ParticipantListener, com.skype.api.Sms.SmsListener, com.skype.api.Transfer.TransferListener, com.skype.api.Video.VideoListener, com.skype.api.Voicemail.VoicemailListener

SkypeKit API Event Handlers: Java Tutorials.

Since:
1.0
Author:
Andrea Drane (based on skype.javawrapper.client.JavaWrapperListeners and ported/refactored from existing C++ tutorial code)

Field Summary
 boolean appConnected
          Indicates whether OnApp2AppStreamListChange was ever fired with a non-zero stream count.
(package private)  com.skype.api.Conversation isLiveSessionUp
          Whether a call is in progress: Part I.
(package private)  com.skype.api.Participant[] liveSessionParticipants
          Whether a call is in progress: Part II.
private  MySession mySession
          Initialized session instance providing access to this sessions's Skype instance, Account instance, tutorial tag, and so forth
 
Constructor Summary
JavaTutorialListeners(MySession mySession)
           
 
Method Summary
 boolean doPickUpCall()
          Business logic for Answering a Call (Tutorial_5 - Find conversation to join).
 void OnApp2AppDatagram(java.lang.String appname, java.lang.String stream, byte[] data)
          SkypeListener Override: Tutorial Handler - Datagrams.
 void OnAvailableDeviceListChange()
          SkypeListener Override.
 void OnAvailableVideoDeviceListChange()
          SkypeListener Override.
 void OnCaptureRequestCompleted(int requestId, boolean isSuccessful, byte[] image, int width, int height)
          VideoListener Override.
 void OnChange(com.skype.api.Contact contact)
          ContactGroupListener Override: Tutorial Handler - ContactGroup TYPE.
 void OnChangeConversation(com.skype.api.Conversation conversation)
          ContactGroup Override.
 void OnContactGoneOffline(com.skype.api.Contact contact)
          SkypeListener Override.
 void OnContactOnlineAppearance(com.skype.api.Contact contact)
          SkypeListener Override.
 void OnConversationListChange(com.skype.api.Conversation conversation, com.skype.api.Conversation.LIST_TYPE type, boolean added)
          SkypeListener Override: Tutorial Handler - Conversation LIST_TYPE.
 void OnIncomingDTMF(com.skype.api.Participant.DTMF dtmf)
          ParticipantListener Override.
 void OnLastFrameCapture(byte[] image, int width, int height)
          VideoListener Override.
 void OnMessage(com.skype.api.Message message)
          ConversationListener Override.
 void OnMessage(com.skype.api.Message message, boolean changesInboxTimestamp, com.skype.api.Message supersedesHistoryMessage, com.skype.api.Conversation conversation)
          SkypeListener Override: Tutorial Handler - Posted chat message.
 void OnNewCustomContactGroup(com.skype.api.ContactGroup group)
          SkypeListener Override.
 void OnNewResult(com.skype.api.Contact contact, int rankValue)
          ContactSearchListener Override.
 void OnNrgLevelsChange()
          SkypeListener Override.
 void OnParticipantListChange()
          ConversationListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Account.PROPERTY prop, java.lang.Object value)
          AccountListener Override: Tutorial Handler - Account Properties.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Contact.PROPERTY prop, java.lang.Object value)
          ContactListener Override: Tutorial Handler - Availability.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.ContactGroup.PROPERTY prop, java.lang.Object value)
          ContactGroupListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.ContactSearch.PROPERTY prop, java.lang.Object value)
          ContactSearchListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Conversation.PROPERTY prop, java.lang.Object value)
          ConversationListener Override: Tutorial Handler - Conversation "Live Status".
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Message.PROPERTY prop, java.lang.Object value)
          MessageListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Participant.PROPERTY prop, java.lang.Object value)
          ParticipantListener Override: Tutorial Handler - Sound Levels and Voice Status.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Sms.PROPERTY prop, java.lang.Object value)
          SmsListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Transfer.PROPERTY prop, java.lang.Object value)
          TransferListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Video.PROPERTY prop, java.lang.Object value)
          VideoListener Override.
 void OnPropertyChange(com.skype.api.SkypeObject obj, com.skype.api.Voicemail.PROPERTY prop, java.lang.Object value)
          VoicemailListener Override.
 void OnProxyAuthFailure(com.skype.api.Skype.PROXYTYPE type)
          SkypeListener Override.
 void OnSpawnConference(com.skype.api.Conversation spawned)
          ConversationListener Override.
 void registerAllListeners()
           
 void registerListener(int modid)
           
 void unRegisterAllListeners()
           
 void unRegisterListener(int modid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mySession

private MySession mySession
Initialized session instance providing access to this sessions's Skype instance, Account instance, tutorial tag, and so forth

Since:
1.0

isLiveSessionUp

com.skype.api.Conversation isLiveSessionUp
Whether a call is in progress: Part I.

Holds a reference to the affected Conversation instance so it doesn't get garbage-collected in the middle of the call. Initialized to null by caller; set to non-null by Conversation onPropertyChange and ConversationList onChange handlers.

Since:
1.0
See Also:
Conversation, Skype.SkypeListener.OnConversationListChange(com.skype.api.Conversation, com.skype.api.Conversation.LIST_TYPE, boolean)

liveSessionParticipants

com.skype.api.Participant[] liveSessionParticipants
Whether a call is in progress: Part II.

Holds a reference to Participants of the affected Conversation instance so they don't get garbage-collected in the middle of the call. Initialized to null by caller; set to non-null by Conversation onPropertyChange and ConversationList onChange handlers.

Since:
1.0
See Also:
Conversation, Skype.SkypeListener.OnConversationListChange(com.skype.api.Conversation, com.skype.api.Conversation.LIST_TYPE, boolean)

appConnected

public boolean appConnected
Indicates whether OnApp2AppStreamListChange was ever fired with a non-zero stream count.
Basically, this is for "prettiness" - we'll only display the "connection" message once per session.

Since:
1.0
Constructor Detail

JavaTutorialListeners

public JavaTutorialListeners(MySession mySession)
Method Detail

registerListener

public void registerListener(int modid)

registerAllListeners

public void registerAllListeners()

unRegisterListener

public void unRegisterListener(int modid)

unRegisterAllListeners

public void unRegisterAllListeners()

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Voicemail.PROPERTY prop,
                             java.lang.Object value)
VoicemailListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.Voicemail.VoicemailListener
Since:
1.0
See Also:
Voicemail.VoicemailListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Voicemail.PROPERTY, java.lang.Object)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Video.PROPERTY prop,
                             java.lang.Object value)
VideoListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.Video.VideoListener
Since:
1.0
See Also:
Video.VideoListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Video.PROPERTY, java.lang.Object)

OnCaptureRequestCompleted

public void OnCaptureRequestCompleted(int requestId,
                                      boolean isSuccessful,
                                      byte[] image,
                                      int width,
                                      int height)
VideoListener Override.

Specified by:
OnCaptureRequestCompleted in interface com.skype.api.Video.VideoListener
Since:
1.0
See Also:
Video.VideoListener.OnCaptureRequestCompleted(int, boolean, byte[], int, int)

OnLastFrameCapture

public void OnLastFrameCapture(byte[] image,
                               int width,
                               int height)
VideoListener Override.

Specified by:
OnLastFrameCapture in interface com.skype.api.Video.VideoListener
Since:
1.0
See Also:
Video.VideoListener.OnLastFrameCapture(byte[], int, int)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Transfer.PROPERTY prop,
                             java.lang.Object value)
TransferListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.Transfer.TransferListener
Since:
1.0
See Also:
Transfer.TransferListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Transfer.PROPERTY, java.lang.Object)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Sms.PROPERTY prop,
                             java.lang.Object value)
SmsListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.Sms.SmsListener
Since:
1.0
See Also:
Sms.SmsListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Sms.PROPERTY, java.lang.Object)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Participant.PROPERTY prop,
                             java.lang.Object value)
ParticipantListener Override: Tutorial Handler - Sound Levels and Voice Status.

Specified by:
OnPropertyChange in interface com.skype.api.Participant.ParticipantListener
Parameters:
obj - The affected Participant.
prop - The Participant property that triggered this event.
value - Ignored.
Since:
1.0
See Also:
Participant.ParticipantListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Participant.PROPERTY, java.lang.Object)

OnIncomingDTMF

public void OnIncomingDTMF(com.skype.api.Participant.DTMF dtmf)
ParticipantListener Override.

Specified by:
OnIncomingDTMF in interface com.skype.api.Participant.ParticipantListener
Since:
1.0
See Also:
Participant.ParticipantListener.OnIncomingDTMF(com.skype.api.Participant.DTMF)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Message.PROPERTY prop,
                             java.lang.Object value)
MessageListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.Message.MessageListener
Since:
1.0
See Also:
Message.MessageListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Message.PROPERTY, java.lang.Object)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Conversation.PROPERTY prop,
                             java.lang.Object value)
ConversationListener Override: Tutorial Handler - Conversation "Live Status".

If it's not a "live status" change, ignore it. Otherwise: Tutorial 6/7 - Looks for:

Specified by:
OnPropertyChange in interface com.skype.api.Conversation.ConversationListener
Parameters:
obj - The affected Conversation.
prop - The Conversation property that triggered this event.
value - Ignored.
Since:
1.0
See Also:
Conversation.ConversationListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Conversation.PROPERTY, java.lang.Object)

OnParticipantListChange

public void OnParticipantListChange()
ConversationListener Override.

Specified by:
OnParticipantListChange in interface com.skype.api.Conversation.ConversationListener
Since:
1.0
See Also:
Conversation.ConversationListener.OnParticipantListChange()

OnMessage

public void OnMessage(com.skype.api.Message message)
ConversationListener Override.

Specified by:
OnMessage in interface com.skype.api.Conversation.ConversationListener
Since:
1.0
See Also:
Conversation.ConversationListener.OnMessage(com.skype.api.Message)

OnSpawnConference

public void OnSpawnConference(com.skype.api.Conversation spawned)
ConversationListener Override.

Specified by:
OnSpawnConference in interface com.skype.api.Conversation.ConversationListener
Since:
1.0
See Also:
Conversation.ConversationListener.OnSpawnConference(com.skype.api.Conversation)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.ContactSearch.PROPERTY prop,
                             java.lang.Object value)
ContactSearchListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.ContactSearch.ContactSearchListener
Since:
1.0
See Also:
ContactSearch.ContactSearchListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.ContactSearch.PROPERTY, java.lang.Object)

OnNewResult

public void OnNewResult(com.skype.api.Contact contact,
                        int rankValue)
ContactSearchListener Override.

Specified by:
OnNewResult in interface com.skype.api.ContactSearch.ContactSearchListener
Since:
1.0
See Also:
ContactSearch.ContactSearchListener.OnNewResult(com.skype.api.Contact, int)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.ContactGroup.PROPERTY prop,
                             java.lang.Object value)
ContactGroupListener Override.

Specified by:
OnPropertyChange in interface com.skype.api.ContactGroup.ContactGroupListener
Since:
1.0
See Also:
ContactGroup.ContactGroupListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.ContactGroup.PROPERTY, java.lang.Object)

OnChangeConversation

public void OnChangeConversation(com.skype.api.Conversation conversation)
ContactGroup Override.

Specified by:
OnChangeConversation in interface com.skype.api.ContactGroup.ContactGroupListener
Since:
1.0
See Also:
ContactGroup.ContactGroupListener.OnChangeConversation(com.skype.api.Conversation)

OnChange

public void OnChange(com.skype.api.Contact contact)
ContactGroupListener Override: Tutorial Handler - ContactGroup TYPE.

This handler fires for all ContactGroups. If it's not a pending authorization request, log and ignore it.

Tutorial 9 - Process authorization requests

Specified by:
OnChange in interface com.skype.api.ContactGroup.ContactGroupListener
Since:
1.0
See Also:
ContactGroup.ContactGroupListener.OnChange(com.skype.api.Contact)

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Contact.PROPERTY prop,
                             java.lang.Object value)
ContactListener Override: Tutorial Handler - Availability.

Maps an availability property ENUM code to a text string, and writes that string to the console. If it's not an availability change, ignore it.

The implementation here follows the C++ pattern - a switch statement with cases for each defined code. For Java 5.0, the Enum class' name method eliminates this need the entire switch statement could be eliminated by coding the printf as
     MySession.myConsole.printf("%s: Availability of %s is now %s%n",
                       mySession.myTutorialTag,
                       affectedContact.GetStrProperty(Contact.PROPERTY.displayname),
                       availability.name());
 
where both statusAsText and availability.name() yield the same string value (as demonstrated by using both in the printf parameter list). Implementing this functionality as a switch statement, however, enables you to perform additional processing for specific cases.

Specified by:
OnPropertyChange in interface com.skype.api.Contact.ContactListener
Parameters:
obj - The affected Contact.
prop - The Contact property that triggered this event.
value - Ignored.
Since:
1.0
See Also:
Contact.ContactListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Contact.PROPERTY, java.lang.Object)

OnNewCustomContactGroup

public void OnNewCustomContactGroup(com.skype.api.ContactGroup group)
SkypeListener Override.

Specified by:
OnNewCustomContactGroup in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnNewCustomContactGroup(com.skype.api.ContactGroup)

OnContactOnlineAppearance

public void OnContactOnlineAppearance(com.skype.api.Contact contact)
SkypeListener Override.

Specified by:
OnContactOnlineAppearance in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnContactOnlineAppearance(com.skype.api.Contact)

OnContactGoneOffline

public void OnContactGoneOffline(com.skype.api.Contact contact)
SkypeListener Override.

Specified by:
OnContactGoneOffline in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnContactGoneOffline(com.skype.api.Contact)

OnConversationListChange

public void OnConversationListChange(com.skype.api.Conversation conversation,
                                     com.skype.api.Conversation.LIST_TYPE type,
                                     boolean added)
SkypeListener Override: Tutorial Handler - Conversation LIST_TYPE.

If it's not a LIVE_CONVERSATIONS change, ignore it; if it's not a type we're interested in, simply write it to the console.

Specified by:
OnConversationListChange in interface com.skype.api.Skype.SkypeListener
Parameters:
conversation - The affected Conversation.
type - The Conversation list type that triggered this event.
added - Ignored.
Since:
1.0
See Also:
Skype.SkypeListener.OnConversationListChange(com.skype.api.Conversation, com.skype.api.Conversation.LIST_TYPE, boolean)

OnMessage

public void OnMessage(com.skype.api.Message message,
                      boolean changesInboxTimestamp,
                      com.skype.api.Message supersedesHistoryMessage,
                      com.skype.api.Conversation conversation)
SkypeListener Override: Tutorial Handler - Posted chat message.

If it's not a POSTED_TEXT message, ignore it.

Specified by:
OnMessage in interface com.skype.api.Skype.SkypeListener
Parameters:
message - The affected Message.
changesInboxTimestamp - Ignored.
supersedesHistoryMessage - Ignored.
conversation - The affected Conversation.
Since:
1.0
See Also:
Skype.SkypeListener.OnMessage(com.skype.api.Message, boolean, com.skype.api.Message, com.skype.api.Conversation)

OnAvailableVideoDeviceListChange

public void OnAvailableVideoDeviceListChange()
SkypeListener Override.

Specified by:
OnAvailableVideoDeviceListChange in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnAvailableVideoDeviceListChange()

OnAvailableDeviceListChange

public void OnAvailableDeviceListChange()
SkypeListener Override.

Specified by:
OnAvailableDeviceListChange in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnAvailableDeviceListChange()

OnNrgLevelsChange

public void OnNrgLevelsChange()
SkypeListener Override.

Specified by:
OnNrgLevelsChange in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnNrgLevelsChange()

OnProxyAuthFailure

public void OnProxyAuthFailure(com.skype.api.Skype.PROXYTYPE type)
SkypeListener Override. Fires on P2P connection failure during account login, which (by default) attempts direct connection to the network, then falls back to connection via proxy.

Specified by:
OnProxyAuthFailure in interface com.skype.api.Skype.SkypeListener
Since:
1.0
See Also:
Skype.SkypeListener.OnProxyAuthFailure(Skype.PROXYTYPE)

OnApp2AppDatagram

public void OnApp2AppDatagram(java.lang.String appname,
                              java.lang.String stream,
                              byte[] data)
SkypeListener Override: Tutorial Handler - Datagrams.

In the context of Tutorial 11 datagrams, this event fires when we receive a datagram. Writes the name of the affected stream and the actual datagram content to the console.

Parameters:
appname - The name of the application associated with this datagram connection.
stream - The name of the affected stream.
data - The payload of this datagram.
Since:
1.0
See Also:
com.skype.api.Skype.SkypeListener#OnApp2AppDatagram(java.lang.String, java.lang.String, byte[])

OnPropertyChange

public void OnPropertyChange(com.skype.api.SkypeObject obj,
                             com.skype.api.Account.PROPERTY prop,
                             java.lang.Object value)
AccountListener Override: Tutorial Handler - Account Properties.

Status changes: Writes change notice to both the log and the console. Specifically looks for/handles login/logout changes (but does not use Account.GetStatusWithProgressResult.progress to implement a progress bar).

Logout reasons: Writes reason for logout to both the log and the console. Useful for differentiating explicit logout by user () and forced logout by the SkypeKit runtime.

Other property changes: Writes the name of the changed property to the console.

Specified by:
OnPropertyChange in interface com.skype.api.Account.AccountListener
Parameters:
obj - Ignored - always assumes our account, so references effected through mySession.myAccount.
prop - The Account property that triggered this event.
value - Ignored.
Since:
1.0
See Also:
Account.AccountListener.OnPropertyChange(com.skype.api.SkypeObject, com.skype.api.Account.PROPERTY, java.lang.Object)

doPickUpCall

public boolean doPickUpCall()
Business logic for Answering a Call (Tutorial_5 - Find conversation to join).

Since this method is invoked from the Conversation OnPropertyChange(SkypeObject, com.skype.api.Conversation.PROPERTY, Object ) event handler, it's most convenient to place it here in the JavaTutorialListener class.

Returns:
  • true: call picked up
  • false: no call to pick up/call not answered/error
Since:
1.0