com.funambol.syncml.spds
Interface SyncListener

All Known Implementing Classes:
BasicSyncListener, TwoPhasesFileSyncSource.ProxySyncListener

public interface SyncListener

This class represents a generic Sync Listener, an object that listens to the synchronization of a repository. The synchronization is a sequence of events that occour in a certain order. There are three different phases:

  • * Connection set up * Modification exchange * Mapping
  • The phases are encapsulated into a sync session which starts with a startSession and is terminated by an endSession. The phases are described in the SyncML specification and their order is fixed as all of them are mandatory. The Modification exchange phase is the most interesting from the point of view of the SyncListener, because it can be further split into more sub events. The modifications are exchanged with a sequence of send/receive sesssion. Each time modifications are about to be sent to the server a startSending event is generated. Then we can have an arbitrary sequence of itemAddSent, itemReplaceSent and itemDeleteSent. At the end of the sending step a endSending event is generated. Similarly for the receiving phase. The Modification exchange phase can thus be described as:
    MODIFICATION -> startSyncing (SEND RECEIVE)+ endSyncing
    SEND -> startSending [itemAddSent | itemReplaceSent | * itemDeleteSent]* endSending
    RECEIVE -> startReceiving [itemReceived | itemDeleted | itemUpdated | dataReceived]* endReceiving


    Field Summary
    static int ACCESS_ERROR
               
    static int BACKEND_AUTH_ERROR
               
    static int BACKEND_ERROR
               
    static int CANCELLED
               
    static int CLIENT_ERROR
               
    static int COMPRESSED_RESPONSE_ERROR
               
    static int CONN_NOT_FOUND
               
    static int CONNECTION_BLOCKED_BY_USER
               
    static int DATA_NULL
               
    static int DEVICE_FULL_ERROR
               
    static int ERROR_RECEIVING_ITEMS
               
    static int ERROR_SENDING_ITEMS
               
    static int FORBIDDEN_ERROR
               
    static int GENERIC_ERROR
               
    static int ILLEGAL_ARGUMENT
               
    static int INVALID_CREDENTIALS
               
    static int ITEMS_NUMBER_UNKNOWN
              Used when the messages to send or received is not know to the mail protocol subsystem
    static int READ_SERVER_RESPONSE_ERROR
               
    static int SERVER_BUSY
               
    static int SERVER_CONNECTION_REQUEST_ERROR
               
    static int SERVER_ERROR
               
    static int SERVER_READ_ERROR
               
    static int SERVER_WRITE_ERROR
               
    static int SMART_SLOW_SYNC_UNSUPPORTED
               
    static int SUCCESS
               
    static int URI_NOT_FOUND_ERROR
               
    static int WRITE_SERVER_REQUEST_ERROR
               
     
    Method Summary
     void dataReceived(java.lang.String date, int size)
              Invoked each time data is received from the server, with the timestamp and the size in bytes of the receive data.
     void endConnecting(int action)
              Invoked at the end of the login phase.
     void endMapping()
              Invoked at the end of the mapping phase
     void endReceiving()
              Invoked at the end of the receiving phase
     void endSending()
              Invoked when the mail protocol subsystem has finished to send message.
     void endSession(SyncReport report)
              Invoked at the end of a session after the last message was exchanged (or an error occurred).
     void endSyncing()
              Invoked at the end of the syncing phase
     void itemAddChunkSent(java.lang.String key, java.lang.String parent, int size)
              Invoked when a chunk of a new item was sent
     void itemAddSendingEnded(java.lang.String key, java.lang.String parent, int size)
              Invoked when the sending of a new item has terminated
     void itemAddSendingStarted(java.lang.String key, java.lang.String parent, int size)
              Invoked when the sending of a new item has started
     void itemDeleted(java.lang.Object item)
              Invoked each time a message is deleted
     void itemDeleteSent(java.lang.Object item)
              Invoked each time an item deleted is sent to the server.
     void itemReceived(java.lang.Object item)
              Invoked each time a message is received and stored successfully in the client.
     void itemReplaceChunkSent(java.lang.String key, java.lang.String parent, int size)
              Invoked when a chunk of a replaced item was sent
     void itemReplaceSendingEnded(java.lang.String key, java.lang.String parent, int size)
              Invoked when the sending of a replaced item has terminated
     void itemReplaceSendingStarted(java.lang.String key, java.lang.String parent, int size)
              Invoked when the sending of a replaced item has started
     void itemUpdated(java.lang.Object item)
              Invoked when an item changes on the other side.
     void itemUpdated(java.lang.Object item, java.lang.Object update)
              Invoked when an item changes on the other side.
     void startConnecting()
              Invoked at the beginning of the login phase.
     void startMapping()
              Invoked at the beginning of the mapping phase
     void startReceiving(int number)
              Invoked when items are ready to be received from the server.
     void startSending(int numNewItems, int numUpdItems, int numDelItems)
              Invoked before beginning to send items to the server.
     void startSession()
              Invoked at the beginning of the session, before opening the connection with the server
     boolean startSyncing(int alertCode, DevInf devInf)
              Invoked at the beginning of the syncing phase
     void syncStarted(int alertCode)
              Invoked when the sync starts
     

    Field Detail

    SUCCESS

    static final int SUCCESS
    See Also:
    Constant Field Values

    INVALID_CREDENTIALS

    static final int INVALID_CREDENTIALS
    See Also:
    Constant Field Values

    FORBIDDEN_ERROR

    static final int FORBIDDEN_ERROR
    See Also:
    Constant Field Values

    CONN_NOT_FOUND

    static final int CONN_NOT_FOUND
    See Also:
    Constant Field Values

    SERVER_READ_ERROR

    static final int SERVER_READ_ERROR
    See Also:
    Constant Field Values

    SERVER_WRITE_ERROR

    static final int SERVER_WRITE_ERROR
    See Also:
    Constant Field Values

    CLIENT_ERROR

    static final int CLIENT_ERROR
    See Also:
    Constant Field Values

    ACCESS_ERROR

    static final int ACCESS_ERROR
    See Also:
    Constant Field Values

    DATA_NULL

    static final int DATA_NULL
    See Also:
    Constant Field Values

    ILLEGAL_ARGUMENT

    static final int ILLEGAL_ARGUMENT
    See Also:
    Constant Field Values

    SERVER_ERROR

    static final int SERVER_ERROR
    See Also:
    Constant Field Values

    SERVER_BUSY

    static final int SERVER_BUSY
    See Also:
    Constant Field Values

    BACKEND_ERROR

    static final int BACKEND_ERROR
    See Also:
    Constant Field Values

    BACKEND_AUTH_ERROR

    static final int BACKEND_AUTH_ERROR
    See Also:
    Constant Field Values

    URI_NOT_FOUND_ERROR

    static final int URI_NOT_FOUND_ERROR
    See Also:
    Constant Field Values

    READ_SERVER_RESPONSE_ERROR

    static final int READ_SERVER_RESPONSE_ERROR
    See Also:
    Constant Field Values

    WRITE_SERVER_REQUEST_ERROR

    static final int WRITE_SERVER_REQUEST_ERROR
    See Also:
    Constant Field Values

    SERVER_CONNECTION_REQUEST_ERROR

    static final int SERVER_CONNECTION_REQUEST_ERROR
    See Also:
    Constant Field Values

    CONNECTION_BLOCKED_BY_USER

    static final int CONNECTION_BLOCKED_BY_USER
    See Also:
    Constant Field Values

    SMART_SLOW_SYNC_UNSUPPORTED

    static final int SMART_SLOW_SYNC_UNSUPPORTED
    See Also:
    Constant Field Values

    CANCELLED

    static final int CANCELLED
    See Also:
    Constant Field Values

    GENERIC_ERROR

    static final int GENERIC_ERROR
    See Also:
    Constant Field Values

    ERROR_SENDING_ITEMS

    static final int ERROR_SENDING_ITEMS
    See Also:
    Constant Field Values

    ERROR_RECEIVING_ITEMS

    static final int ERROR_RECEIVING_ITEMS
    See Also:
    Constant Field Values

    COMPRESSED_RESPONSE_ERROR

    static final int COMPRESSED_RESPONSE_ERROR
    See Also:
    Constant Field Values

    DEVICE_FULL_ERROR

    static final int DEVICE_FULL_ERROR
    See Also:
    Constant Field Values

    ITEMS_NUMBER_UNKNOWN

    static final int ITEMS_NUMBER_UNKNOWN
    Used when the messages to send or received is not know to the mail protocol subsystem

    See Also:
    Constant Field Values
    Method Detail

    startSession

    void startSession()
    Invoked at the beginning of the session, before opening the connection with the server


    endSession

    void endSession(SyncReport report)
    Invoked at the end of a session after the last message was exchanged (or an error occurred).

    Parameters:
    report - this is a summary of what happened during the sync, including the overall status.

    startConnecting

    void startConnecting()
    Invoked at the beginning of the login phase.


    endConnecting

    void endConnecting(int action)
    Invoked at the end of the login phase.

    Parameters:
    action - describes the action the server requires (this value is repository dependent)

    syncStarted

    void syncStarted(int alertCode)
    Invoked when the sync starts

    Parameters:
    alertCode - is the code returned by the server at the end of the connection phase
    serverDevInf - is the

    endSyncing

    void endSyncing()
    Invoked at the end of the syncing phase


    startMapping

    void startMapping()
    Invoked at the beginning of the mapping phase


    endMapping

    void endMapping()
    Invoked at the end of the mapping phase


    startReceiving

    void startReceiving(int number)
    Invoked when items are ready to be received from the server.

    Parameters:
    number - number of items that will be sent during the session, if known, or ITEMS_NUMBER_UNKNOWN otherwise.

    endReceiving

    void endReceiving()
    Invoked at the end of the receiving phase


    itemReceived

    void itemReceived(java.lang.Object item)
    Invoked each time a message is received and stored successfully in the client.

    Parameters:
    item - is the new value received

    itemDeleted

    void itemDeleted(java.lang.Object item)
    Invoked each time a message is deleted

    Parameters:
    itemId - is the id of the value being removed

    itemUpdated

    void itemUpdated(java.lang.Object item,
                     java.lang.Object update)
    Invoked when an item changes on the other side.

    Parameters:
    item - is the item that changed
    update - is an encoding (client depending) of the update

    itemUpdated

    void itemUpdated(java.lang.Object item)
    Invoked when an item changes on the other side.

    Parameters:
    item - is the item that changed

    dataReceived

    void dataReceived(java.lang.String date,
                      int size)
    Invoked each time data is received from the server, with the timestamp and the size in bytes of the receive data.

    Parameters:
    date - is the timestamp
    size - is the number of bytes received

    startSending

    void startSending(int numNewItems,
                      int numUpdItems,
                      int numDelItems)
    Invoked before beginning to send items to the server.

    Parameters:
    numNewItems - number of new items to be sent
    numUpdItems - number of updated items to be sent
    numDelItems - number of deleted items to be sent

    itemAddSendingStarted

    void itemAddSendingStarted(java.lang.String key,
                               java.lang.String parent,
                               int size)
    Invoked when the sending of a new item has started

    Parameters:
    key - is the item key
    parent - is the item parent
    size - is the item size (total size, regardless of chunking)

    itemAddSendingEnded

    void itemAddSendingEnded(java.lang.String key,
                             java.lang.String parent,
                             int size)
    Invoked when the sending of a new item has terminated

    Parameters:
    key - is the item key
    parent - is the item parent
    size - is the item size (total size, regardless of chunking)

    itemAddChunkSent

    void itemAddChunkSent(java.lang.String key,
                          java.lang.String parent,
                          int size)
    Invoked when a chunk of a new item was sent

    Parameters:
    key - is the item key
    parent - is the item parent
    size - is the item size (chunk size)

    itemReplaceSendingStarted

    void itemReplaceSendingStarted(java.lang.String key,
                                   java.lang.String parent,
                                   int size)
    Invoked when the sending of a replaced item has started

    Parameters:
    key - is the item key
    parent - is the item parent
    size - is the item size (total size, regardless of chunking)

    itemReplaceSendingEnded

    void itemReplaceSendingEnded(java.lang.String key,
                                 java.lang.String parent,
                                 int size)
    Invoked when the sending of a replaced item has terminated

    Parameters:
    key - is the item key
    parent - is the item parent
    size - is the item size (total size, regardless of chunking)

    itemReplaceChunkSent

    void itemReplaceChunkSent(java.lang.String key,
                              java.lang.String parent,
                              int size)
    Invoked when a chunk of a replaced item was sent

    Parameters:
    key - is the item key
    parent - is the item parent
    size - is the item size (chunk size)

    itemDeleteSent

    void itemDeleteSent(java.lang.Object item)
    Invoked each time an item deleted is sent to the server. The item has type SyncItem, but we do not want this package to depend on anything else, therefore we use a generic Object.


    endSending

    void endSending()
    Invoked when the mail protocol subsystem has finished to send message.


    startSyncing

    boolean startSyncing(int alertCode,
                         DevInf devInf)
    Invoked at the beginning of the syncing phase

    Parameters:
    alertCode - is the code returned by the server at the end of the connection phase
    serverDevInf - is the server device info if they are provided by the server. The server can send its dev inf if they changed or if the client requested them (@see SyncManager.sync). This value may be null if the server did not provide its device information.
    Returns:
    true if the sync can proceed or null if the client wants to interrupt it


    Copyright © 2001-2009 Funambol.