|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.engine.BaseEngine com.vodafone360.people.engine.meprofile.SyncMeEngine
public class SyncMeEngine
This is an implementation for an engine to synchronize Me profile data.
Nested Class Summary | |
---|---|
private static class |
SyncMeEngine.State
Defines the contact sync mode. |
Nested classes/interfaces inherited from class com.vodafone360.people.engine.BaseEngine |
---|
BaseEngine.IEngineEventCallback |
Field Summary | |
---|---|
private static java.lang.String |
CONTACT_CHANGES
The type of datatype we are expecting back from the server for upload/download me profile requests. |
private static int |
MAX_QUALITY
|
private ApplicationCache |
mCache
ApplicationCache reference to update progress bar. |
private DatabaseHelper |
mDbHelper
Database. |
private boolean |
mFirstTimeMeSyncComplete
Indicates if the first time sync has been completed. |
private boolean |
mFirstTimeSyncStarted
Indicates if the first time sync has been ever initiated. |
private long |
mFromRevision
The latest revision of Me Profile. |
private SyncMeEngine.State |
mState
Current engine state. |
private UiAgent |
mUiAgent
UiAgent reference to update progress bar. |
private java.util.ArrayList<ContactDetail> |
mUploadedMeDetails
The Me Profile, as it was uploaded. |
private static int |
PROGRESS_50
Percentage used to show progress when the me sync is half complete. |
Fields inherited from class com.vodafone360.people.engine.BaseEngine |
---|
mActiveUiRequest, mCurrentTimeout, mEngineId, mEventCallback |
Constructor Summary | |
---|---|
SyncMeEngine(BaseEngine.IEngineEventCallback eventCallback,
DatabaseHelper db)
The constructor. |
Method Summary | |
---|---|
void |
addGetMeProfileContactFirstTimeRequest()
This method adds an external request to Contacts/getMyChanges() method to update the Me Profile status server, is called by the UI at the 1st sync. |
private void |
addGetMeProfileContactRequest()
This method adds an external request to Contacts/getMyChanges() method to update the Me Profile status server. |
void |
addUpdateMeProfileContactRequest()
This method adds an external request to Contacts/setMe() method to update the Me Profile... |
void |
addUpdateMyStatusRequest(java.lang.String textStatus)
This method adds an external request to Contacts/setMe() method to update the Me Profile status... |
private boolean |
checkConnectivity()
Get current connectivity state from the NetworkAgent. |
protected void |
completeUiRequest(ServiceStatus status)
A helper function that can be called by the derived engine implementation to complete the current UI request. |
private void |
downloadMeProfileThumbnail(java.lang.String url,
long localContactId)
The call to download the thumbnail picture for the me profile. |
private void |
getMeProfileChanges()
Sends a GetMyChanges request to the server, with the current version of the me profile used as a parameter. |
long |
getNextRunTime()
Return the absolute time in milliseconds when the engine needs to run (based on System.currentTimeMillis). |
boolean |
isFirstTimeMeSyncComplete()
This method TRUE if the Me Profile has been synced once. |
private boolean |
isReady()
The condition for the sync me engine run. |
private void |
newState(SyncMeEngine.State newState)
Changes the state of the engine. |
void |
onCreate()
This will be called immediately after creation. |
void |
onDestroy()
This will be called just before the engine is shutdown. |
protected void |
onRequestComplete()
This function must be implemented in the derived engine implementation. |
void |
onReset()
This method needs to be called as part of removeAllData()/changeUser() routine. |
protected void |
onTimeoutEvent()
The derived engine implementation must call the processTimeout() function (normally from within the run() implementation), otherwise this will not be called. |
void |
processCommsResponse(ResponseQueue.Response resp)
Called by framework when a response to a server request is received. |
private void |
processGetMyChangesResponse(ResponseQueue.Response resp)
Processes the response from a GetMyChanges request. |
private void |
processMeProfileThumbnailResponse(ResponseQueue.Response resp)
This method stores the thumbnail picture for the me profile |
private boolean |
processPushEvent(ResponseQueue.Response resp)
This method process the "pc" push event. |
private void |
processSetMeResponse(ResponseQueue.Response resp)
Processes the response from a SetMe request. |
protected void |
processUiRequest(ServiceUiRequest requestId,
java.lang.Object data)
The derived engine implementation must call the processUiQueue() function (normally from within the run() implementation), otherwise this will not be called. |
private void |
processUpdateStatusResponse(ResponseQueue.Response resp)
This method processes the response to status update by setMe() method |
void |
run()
Do some work but anything that takes longer than 1 second must be broken up. |
private ServiceStatus |
setFirstTimeMeSyncComplete(boolean value)
Helper function to update the database when the state of the mFirstTimeMeSyncComplete flag changes. |
private ServiceStatus |
setFirstTimeSyncStarted(boolean value)
Helper function to update the database when the state of the #mFirstTimeMeSyncStarted flag changes. |
void |
setSyncStatus(SyncStatus syncStatus)
This method sets the current progress. |
private static boolean |
updateRevisionPostUpdate(java.lang.Integer before,
java.lang.Integer after,
long currentFromRevision,
DatabaseHelper db)
Updates the revision of the me profile in the local state table after the SetMe has completed. |
private void |
uploadMeProfile()
* Sends a SetMe request to the server in the case that the me profile has been changed locally. |
private void |
uploadStatusUpdate(ContactDetail statusDetail)
Starts uploading a status update to the server and ignores all other |
Methods inherited from class com.vodafone360.people.engine.BaseEngine |
---|
addUiRequestToQueue, clearTimeout, completeUiRequest, deactivateEngine, emptyUiRequestQueue, engineId, genericHandleResponseType, getCurrentTimeout, isCommsResponseOutstanding, isDeactivated, isUiRequestOutstanding, onCommsInMessage, processCommsInQueue, processTimeout, processUiQueue, setReqId, setTimeout |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private SyncMeEngine.State mState
private DatabaseHelper mDbHelper
private long mFromRevision
private java.util.ArrayList<ContactDetail> mUploadedMeDetails
private boolean mFirstTimeSyncStarted
private boolean mFirstTimeMeSyncComplete
private static final int MAX_QUALITY
private final UiAgent mUiAgent
private final ApplicationCache mCache
private static final java.lang.String CONTACT_CHANGES
private static final int PROGRESS_50
Constructor Detail |
---|
public SyncMeEngine(BaseEngine.IEngineEventCallback eventCallback, DatabaseHelper db)
eventCallback
- IEngineEventCallbackdb
- DatabaseHelper - database.Method Detail |
---|
public long getNextRunTime()
BaseEngine
getNextRunTime
in class BaseEngine
private boolean isReady()
public void run()
BaseEngine
run
in class BaseEngine
public void onCreate()
BaseEngine
onCreate
in class BaseEngine
public void onDestroy()
BaseEngine
onDestroy
in class BaseEngine
protected void onRequestComplete()
BaseEngine
onRequestComplete
in class BaseEngine
protected void onTimeoutEvent()
BaseEngine
onTimeoutEvent
in class BaseEngine
protected final void processUiRequest(ServiceUiRequest requestId, java.lang.Object data)
BaseEngine
processUiRequest
in class BaseEngine
requestId
- The UI request IDdata
- Request data (object type is request specific)private void getMeProfileChanges()
private void downloadMeProfileThumbnail(java.lang.String url, long localContactId)
url
- String - picture url of Me Profile (comes with getMyChanges())localContactId
- long - local contact id of Me Profileprivate void uploadStatusUpdate(ContactDetail statusDetail)
statusDetail
- - status ContactDetailprivate void uploadMeProfile()
private boolean checkConnectivity()
private void newState(SyncMeEngine.State newState)
newState
- The new statepublic final void processCommsResponse(ResponseQueue.Response resp)
processCommsResponse
in class BaseEngine
resp
- The response receivedprivate void processMeProfileThumbnailResponse(ResponseQueue.Response resp)
resp
- Response - normally contains ExternalResponseObject for the
pictureprivate void processGetMyChangesResponse(ResponseQueue.Response resp)
resp
- Response from server.private void processSetMeResponse(ResponseQueue.Response resp)
resp
- Response from server.private void processUpdateStatusResponse(ResponseQueue.Response resp)
resp
- Response - the expected response datatype is ContactChangesprotected void completeUiRequest(ServiceStatus status)
BaseEngine
completeUiRequest
in class BaseEngine
status
- The result of the requestprivate static boolean updateRevisionPostUpdate(java.lang.Integer before, java.lang.Integer after, long currentFromRevision, DatabaseHelper db)
before
- Version before the updateafter
- Version after the updatecurrentFromRevision
- Current version from our databasedb
- Database helper used for storing the change
public void addUpdateMeProfileContactRequest()
meProfile
- Contact - contact to be pushed to the serverpublic void addUpdateMyStatusRequest(java.lang.String textStatus)
textStatus
- String - the new me profile status to be pushed to the
serverprivate void addGetMeProfileContactRequest()
public void addGetMeProfileContactFirstTimeRequest()
private boolean processPushEvent(ResponseQueue.Response resp)
resp
- Response - server response normally containing a "pc"
PushEvent data type
private ServiceStatus setFirstTimeSyncStarted(boolean value)
#mFirstTimeMeSyncStarted
flag changes.
value
- New value to the flag. True indicates that first time sync
has been started. The flag is never set to false again by the
engine, it will be only set to false when a remove user data
is done (and the database is deleted).
private ServiceStatus setFirstTimeMeSyncComplete(boolean value)
mFirstTimeMeSyncComplete
flag changes.
value
- New value to the flag. True indicates that first time sync
has been completed. The flag is never set to false again by
the engine, it will be only set to false when a remove user
data is done (and the database is deleted).
public final void onReset()
onReset
in class BaseEngine
public final boolean isFirstTimeMeSyncComplete()
public void setSyncStatus(SyncStatus syncStatus) throws java.security.InvalidParameterException
SyncStatus
- Status of the processor, must not be NULL.
java.security.InvalidParameterException
- when SyncStatus is NULL.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc