com.funambol.util
Interface SyncListener

All Known Implementing Classes:
BasicSyncListener

public interface SyncListener

This class represents a generic Sync Listener, an object that listens to the synchronization of a reporitory. The synchronization is a sequence of events that occour in a certain order. There are three different phases: 1) Connection set up 2) Modification exchange 3) 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 CONN_NOT_FOUND
           
static int CONNECTION_BLOCKED_BY_USER
           
static int DATA_NULL
           
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(int status)
          Invoked at the end of a session, before closing the connection with the remote server.
 void endSyncing()
          Invoked at the end of the syncing phase
 void itemAddSent(java.lang.Object item)
          Invoked each time an item added is sent to the server.
 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 itemReplaceSent(java.lang.Object item)
          Invoked each time an item replaced is sent to the server.
 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)
          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

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(int status)
Invoked at the end of a session, before closing the connection with the remote server.

Parameters:
status - gives an indication if the session was error free or if one or more errors were encountered. The value is encoded as a bit mask according to the value of the STATUS_* constants (see above). If no error was encountered then status has the value STATUS_SUCCESS.

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

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

itemAddSent

void itemAddSent(java.lang.Object item)
Invoked each time an item added 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.


itemReplaceSent

void itemReplaceSent(java.lang.Object item)
Invoked each time an item replaced 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.


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)
Invoked at the beginning of the syncing phase

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


Copyright © 2006 Funambol.