com.vodafone360.people.engine.contactsync
Class BaseSyncProcessor

java.lang.Object
  extended by com.vodafone360.people.engine.contactsync.BaseSyncProcessor
Direct Known Subclasses:
DownloadServerContacts, DownloadServerThumbnails_old, FetchNativeContacts, UpdateNativeContacts, UploadServerContacts

public abstract class BaseSyncProcessor
extends java.lang.Object

Base-class for processor handling for the various stages of Contact sync.


Field Summary
protected  IContactSyncCallback mCallback
          Provides useful callback methods in the contact sync engine
protected  DatabaseHelper mDb
          Provides processors with access to the people database.
protected  java.lang.String mFailureList
          String used by processors to compile extra information when a contact sync isn't successful.
 
Constructor Summary
protected BaseSyncProcessor(IContactSyncCallback callback, DatabaseHelper db)
          Base constructor.
 
Method Summary
protected  void cancel()
          Cancel processor
protected  void complete(ServiceStatus status)
          Helper method to complete the processor.
protected abstract  void doCancel()
          Can be called anytime when the processor is active, to cancel the sync.
protected abstract  void doStart()
          Implemented by all contact sync processors to initiate the sync.
protected  BaseEngine getEngine()
          Provides access to the contact sync engine object.
protected  void markDbChanged()
          Called by processors when they make changes to the people database.
 void onComplete()
          Processors may override this function is they have any additional cleanup to do when the processor has finished.
 void onTimeoutEvent()
          Can be overriden by processors which are interested in timeout events.
abstract  void processCommsResponse(ResponseQueue.Response resp)
          Called when a comms response is received from the server.
protected  void setReqId(int reqId)
          Processors can call this method when they issue a comms requests.
protected  void setSyncStatus(SyncStatus syncStatus)
          Used by processors to provide an indication of their current progress.
protected  void setTimeout(long timeout)
          Helper function that can be used by processors to set a timeout.
 void start()
          Start the processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mCallback

protected IContactSyncCallback mCallback
Provides useful callback methods in the contact sync engine


mFailureList

protected java.lang.String mFailureList
String used by processors to compile extra information when a contact sync isn't successful. Currently used to list contacts which the server does not accept during the sync.


mDb

protected DatabaseHelper mDb
Provides processors with access to the people database.

Constructor Detail

BaseSyncProcessor

protected BaseSyncProcessor(IContactSyncCallback callback,
                            DatabaseHelper db)
Base constructor.

Parameters:
callback - Provides access to the contact sync engine
db - The database helper reference
Method Detail

start

public void start()
Start the processor. Once started the processors is in the active state until either it is cancelled by engine, or the processor completes the sync (see complete(ServiceStatus)).


cancel

protected void cancel()
Cancel processor


doStart

protected abstract void doStart()
Implemented by all contact sync processors to initiate the sync. Once called, the processor needs to call the IContactSyncCallback.onProcessorComplete(ServiceStatus, String, Object) method when the sync is finished (the usual way to do this is by calling complete(ServiceStatus)).


doCancel

protected abstract void doCancel()
Can be called anytime when the processor is active, to cancel the sync. Should not complete the sync here because the above method cancel() will take care of this.


onTimeoutEvent

public void onTimeoutEvent()
Can be overriden by processors which are interested in timeout events. A processor will only receive timeout events while it is active.


processCommsResponse

public abstract void processCommsResponse(ResponseQueue.Response resp)
Called when a comms response is received from the server. This may be a response from a request issued by the processor or a push message.

Parameters:
resp - The response data

complete

protected void complete(ServiceStatus status)
Helper method to complete the processor.

Parameters:
status - The result of the sync

getEngine

protected BaseEngine getEngine()
Provides access to the contact sync engine object. This is normally only used for processor to issue comms requests.

Returns:
The contact sync engine

markDbChanged

protected void markDbChanged()
Called by processors when they make changes to the people database. This is implemented outside the database framework to ensure UI updates happen more efficiently during a contact sync.


setTimeout

protected void setTimeout(long timeout)
Helper function that can be used by processors to set a timeout. The onTimeoutEvent() will be called once the timeout completes.

Parameters:
timeout - The timeout value in milliseconds.

setSyncStatus

protected void setSyncStatus(SyncStatus syncStatus)
Used by processors to provide an indication of their current progress.

Parameters:
SyncStatus - Status of the processor, must not be NULL.
Throws:
java.security.InvalidParameterException - when SyncStatus is NULL.

setReqId

protected void setReqId(int reqId)
Processors can call this method when they issue a comms requests. The framework will then only notify the processor when a response is received which matches the request ID.

Parameters:
reqId - The request ID returned by the comms framework.

onComplete

public void onComplete()
Processors may override this function is they have any additional cleanup to do when the processor has finished. Similiar to finalize except it is always called immediately the processor goes inactive.



JavaDoc