English | Site Directory

Android - An Open Handset Alliance Project

com.google.android.gtalkservice.IGTalkSession

com.google.android.gtalkservice.IGTalkSession IInterface

IGTalkSession interface definition file for GTalk session.

Nested Classes
IGTalkSession.Stub Local-side IPC implementation stub class. 
Known Indirect Subclasses

Summary

Public Methods

        void  addGroupChatInvitationListener(IGroupChatInvitationListener listener)
Adds a group chat invitation listener.
        void  addRemoteChatListener(IChatListener listener)
Adds a chat listener.
        void  addRemoteRosterListener(IRosterListener listener)
Adds a roster listener.
        void  approveSubscriptionRequest(String contact, String nickname)
Approves the subscription request from the contact.
        void  blockContact(String contact)
Blocks the contact from subscribing to user's presence or sending the user messages.
        void  clearConnectionStatistics()
Clears the connection statistics
        IChatSession  createChatSession(String to)
Create a ChatSession with the specified contact.
        void  createGroupChatSession(String nickname, String[] contacts)
Create a group chat session with a list of contacts.
        void  declineGroupChatInvitation(String roomAddress)
Declines the group chat invitation.
        void  declineSubscriptionRequest(String contact)
Declines subscription request from the contact.
        IChatSession  getChatSession(String to)
Get the ChatSession that is associated with the specified contact.
        int  getConnectionState()
Returns the connection state.
        int  getConnectionUptime()
Returns the current connection's uptime.
        String  getJid()
Returns the GTalk JID in the form of username@domain/resource
        long  getLastActivityFromServerTime()
Returns the time (millis since epoch) of the last activity received from the server.
        long  getLastActivityToServerTime()
Returns the time (millis since epoch) of the last activity sent to the server.
        int  getNumberOfConnectionsAttempted()
Returns the number of GTalk connections attempted to the server since the session is started or the stats last cleared by clearConnectionStatistics().
        int  getNumberOfConnectionsMade()
Returns the number of GTalk connections made to the server since the session is started or the stats last cleared by clearConnectionStatistics().
        Presence  getPresence()
Get the login user's presence.
        String  getUsername()
Returns the username for the GTalk session.
        void  inviteContact(String contact, String nickname)
Send an subscription request to the contact.
        boolean  isConnected()
Returns true if the client is connected to the GTalk server.
        void  joinGroupChatSession(String roomAddress, String nickname, String password)
Join the group chat with the specified roomAddress.
        void  logout()
Log out of the GTalk session
        void  removeContact(String contact)
Remove the contact from the roster.
        void  removeGroupChatInvitationListener(IGroupChatInvitationListener listener)
        void  removeRemoteChatListener(IChatListener listener)
Remove a chat listener.
        void  removeRemoteRosterListener(IRosterListener listener)
Remove a roster listener.
        void  requestRoster()
Request the roster from the GTalk server .
        void  sendDataMessage(String to, Intent broadcastIntent)
Sends a data message to the contact.
        void  setPresence(Presence presence)
Set the login user's presence.
        void  unblockContact(String contact)
Unblocks the contact from blocked list.
Methods inherited from interface android.os.IInterface

Details

Public Methods

public void addGroupChatInvitationListener(IGroupChatInvitationListener listener)

Adds a group chat invitation listener. When there is an invitation listener, the GTalk session will call on IGroupChatInvitationListener.onInvitationReceived() to notify of the invitation. When the group chat invitation listeners are removed, the GTalk session will post a notification using the NotificationManager.

public void addRemoteChatListener(IChatListener listener)

Adds a chat listener. This should be a generic chat listener that listen to all incoming chat messages.

public void addRemoteRosterListener(IRosterListener listener)

Adds a roster listener.

public void approveSubscriptionRequest(String contact, String nickname)

Approves the subscription request from the contact. This takes place after the client receives a subscription request from the contact.

Parameters

contact the contact to be approved subscription.
nickname the nickname of the contact, set by the user.

public void blockContact(String contact)

Blocks the contact from subscribing to user's presence or sending the user messages. The contact is put on the blocked list, and is no longer visible in the roster.

Parameters

contact the contact to be blocked.

public void clearConnectionStatistics()

Clears the connection statistics

public IChatSession createChatSession(String to)

Create a ChatSession with the specified contact.

Parameters

to the address of the contact.

Returns

  • the new ChatSession or null if failed.

public void createGroupChatSession(String nickname, String[] contacts)

Create a group chat session with a list of contacts. It will send a group chat request to the server, and invite the given contacts to join the group chat. On success the GTalkService will create a new group chat session, and a corresponding database chat session entry. Applications can query the contacts, which will show live chats at the top of the contact list.

Parameters

nickname the nickname for the user creating the chat room. If null is passed in, then the username will be used as the nickname.
contacts a list of contacts.

public void declineGroupChatInvitation(String roomAddress)

Declines the group chat invitation.

Parameters

roomAddress the group chat room address.

public void declineSubscriptionRequest(String contact)

Declines subscription request from the contact. This takes place after the client receives a subscription request from the contact.

Parameters

contact the contact to be denied subscription.

public IChatSession getChatSession(String to)

Get the ChatSession that is associated with the specified contact. Note this method does not look up in the group chat sessions.

Parameters

to the address of the contact.

Returns

  • the ChatSession with the contact or null if there isn't any active ChatSession with the contact.

public int getConnectionState()

Returns the connection state. The connection state is defined in ConnectionState. The possible values are IDLE, PENDING, CONNECTING, CONNECTED, LOGGED_IN, REQUESTED_ROSTER

public int getConnectionUptime()

Returns the current connection's uptime.

public String getJid()

Returns the GTalk JID in the form of username@domain/resource

public long getLastActivityFromServerTime()

Returns the time (millis since epoch) of the last activity received from the server.

public long getLastActivityToServerTime()

Returns the time (millis since epoch) of the last activity sent to the server.

public int getNumberOfConnectionsAttempted()

Returns the number of GTalk connections attempted to the server since the session is started or the stats last cleared by clearConnectionStatistics().

public int getNumberOfConnectionsMade()

Returns the number of GTalk connections made to the server since the session is started or the stats last cleared by clearConnectionStatistics().

public Presence getPresence()

Get the login user's presence.

public String getUsername()

Returns the username for the GTalk session.

public void inviteContact(String contact, String nickname)

Send an subscription request to the contact. The client will be notified if the contact accepts the invitation.

Parameters

contact the contact to whom we send the subscription request.
nickname the contact's nickname, could be null.

public boolean isConnected()

Returns true if the client is connected to the GTalk server. Even though the GTalk session is active, the client can be disconnected from the service due to variety of reasons, including no data connection, etc.

public void joinGroupChatSession(String roomAddress, String nickname, String password)

Join the group chat with the specified roomAddress. On success the GTalkService will create a new group chat session, and a corresponding database chat session entry.

Parameters

roomAddress the address of the group chat room.
nickname the nickname for the user joining the chat room. If null is passed in, then the username will be used as the nickname.
password the password to join the chat room, if required.

public void logout()

Log out of the GTalk session

public void removeContact(String contact)

Remove the contact from the roster. This also removes the presence subscription to the contact.

Parameters

contact the contact to be deleted.

public void removeGroupChatInvitationListener(IGroupChatInvitationListener listener)

public void removeRemoteChatListener(IChatListener listener)

Remove a chat listener.

public void removeRemoteRosterListener(IRosterListener listener)

Remove a roster listener.

public void requestRoster()

Request the roster from the GTalk server . This should be done if the client wants to retrieve the roster list. This is not needed for the purpose of sync tickle or peer to peer messaging for third party applications. This is required for the IM application. requestRoster is an asynchronous operation. It sends a roster request IQ stanza to the server, but doesn't block and wait for the roster list to be downloaded. In fact, one can call this before the user is successfully logged in. GTalkSession will cache it and make the actual request after a GTalk connection is established. When the roster is received, it will be put into the content provider content://im/contacts and the IGTalkSession will notify the IRosterListeners registered using addRemoteRosterListener(IRosterListener).

public void sendDataMessage(String to, Intent broadcastIntent)

Sends a data message to the contact. A data message is a user non-visible message. This is a mechanism for peer to peer communication between two devices.

Parameters

to the to address, the indended receiver.
broadcastIntent the intent object contains the action to be broadcasted by the receiving device's GTalkService, as well as a Bundle that contains a map of key/value pairs to be send to the other device. Althought the class Bundle can contain data of different types, GTalkService currently only supports string types for the OTA protocol. All non-string values will be ignored. In the future, data types other than string may be supported.

public void setPresence(Presence presence)

Set the login user's presence.

public void unblockContact(String contact)

Unblocks the contact from blocked list.

Parameters

contact the contact to be unblocked.
Build m5-rc15g - 14 May 2008 12:50