com.funambol.client.controller
Class SynchronizationController

java.lang.Object
  extended by com.funambol.client.controller.SynchronizationController
All Implemented Interfaces:
SyncEngineListener
Direct Known Subclasses:
AccountScreenController, HomeScreenController

public class SynchronizationController
extends java.lang.Object
implements SyncEngineListener

This class provides a basic controller that can be used by any other controller that needs synchronization support. This controller is just a building block, it does not control any UI component. But it shall be extended by controllers that need synchronization capabilities (e.g. HomeScreenController and AccountScreenController).


Field Summary
protected  AppSyncSourceManager appSyncSourceManager
           
protected  Configuration configuration
           
protected  Controller controller
           
protected  AppSyncSource currentSource
           
protected  Customization customization
           
protected  boolean doCancel
           
protected  SyncEngine engine
           
protected  Localization localization
           
protected  boolean logConnectivityError
           
static java.lang.String MANUAL
           
static java.lang.String PUSH
           
static int REFRESH_FROM_SERVER
           
static int REFRESH_TO_SERVER
           
static java.lang.String SCHEDULED
           
protected  boolean showTCPAlert
           
 
Method Summary
 void beginSync()
          A sync is about to begin.
 void cancelSync()
          Try to cancel the current sync.
 void clearErrors()
           
 boolean confirmDeletes(java.util.Enumeration sourceNameList)
          Invoked if there are many items to delete.
 void connectionClosed()
           
 void connectionConfigurationChanged()
           
 void connectionOpened()
           
 void continueSynchronizationAfterDialogCheck(java.lang.String syncType, java.util.Vector filteredSources, boolean refresh, int direction, int delay, boolean fromOutside, boolean continueSyncFromDialog)
           
protected  SyncEngine createSyncEngine()
           
 void endSync(java.util.Vector sources, boolean hadErrors)
          The synchronizaion has been completed for the given sources.
protected  void forceSynchronization(java.lang.String syncType, java.util.Vector syncSources, boolean refresh, int direction, int delay, boolean fromOutside)
           
 Controller getController()
           
 AppSyncSource getCurrentSource()
          Returns the sync source currently being synchronized.
 java.lang.String getRemoteUri(AppSyncSource appSource)
           
 SyncEngine getSyncEngine()
           
 boolean isCancelled()
          Check if the current sync should be cancelled
 boolean isConnectionConfigurationAllowed(java.lang.String apn)
           
 boolean isSynchronizing()
          Returns true iff a synchronization is in progress
 void noConnection()
          Sync cannot be performed because connections cannot be established
 void noCredentials()
          Sync cannot be performed because the user did not set his credentials
 void noSignal()
          Sync cannot be performed because there is no network coverage
 void noSources()
          Sync cannot be performed because no sources are selected
 void refresh(int mask, int direction)
          Perform a refresh for a set of sources and a given direction.
 void refreshSources(java.util.Vector syncSources, int direction)
           
 void requestWritten()
           
 void responseReceived()
           
 void serverOperationFailed()
           
 void setCancel(boolean value)
           
 void setIsUserConfirmationNeeded(boolean value)
           
protected  void setScreen(Screen screen)
           
 void showPendingFirstSyncQuestion()
           
 void sourceEnded(AppSyncSource appSource)
          This method notifies that a source has completed its synchronization
 void sourceFailed(AppSyncSource appSource, SyncException e)
          This method is invoked when the synchronization of a source throws an exception.
 void sourceStarted(AppSyncSource appSource)
          This method notifies that a new source is about to begin its synchronization.
 void syncEnded()
          Invoked at the end of the synchronization (always invoked, regardless of success or failure)
 void synchronize(java.lang.String syncType, java.util.Vector syncSources)
          Triggers a synchronization for the given syncSources.
 void synchronize(java.lang.String syncType, java.util.Vector syncSources, int delay)
          Schedules a synchronization for the given syncSources.
 void synchronize(java.lang.String syncType, java.util.Vector syncSources, int delay, boolean fromOutside)
          Schedules a synchronization for the given syncSources.
 boolean syncStarted(java.util.Vector sources)
          A sync for the given sources is about to begin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANUAL

public static final java.lang.String MANUAL
See Also:
Constant Field Values

SCHEDULED

public static final java.lang.String SCHEDULED
See Also:
Constant Field Values

PUSH

public static final java.lang.String PUSH
See Also:
Constant Field Values

REFRESH_FROM_SERVER

public static final int REFRESH_FROM_SERVER
See Also:
Constant Field Values

REFRESH_TO_SERVER

public static final int REFRESH_TO_SERVER
See Also:
Constant Field Values

controller

protected Controller controller

customization

protected Customization customization

configuration

protected Configuration configuration

appSyncSourceManager

protected AppSyncSourceManager appSyncSourceManager

localization

protected Localization localization

engine

protected SyncEngine engine

doCancel

protected boolean doCancel

currentSource

protected AppSyncSource currentSource

showTCPAlert

protected boolean showTCPAlert

logConnectivityError

protected boolean logConnectivityError
Method Detail

isSynchronizing

public boolean isSynchronizing()
Returns true iff a synchronization is in progress


getCurrentSource

public AppSyncSource getCurrentSource()
Returns the sync source currently being synchronized. If a sync is not in progress, then null is returned. Please note that this method is not completely equivalent to isSynchronizing. At the beginning of a sync, isSynchronizing returns true, but getCurrentSource may return null until the source is prepared for the synchronization.


getSyncEngine

public SyncEngine getSyncEngine()
Returns:
the current SyncEngine instance

cancelSync

public void cancelSync()
Try to cancel the current sync. This works for cooperative sources that check the synchronizationController status.


refresh

public void refresh(int mask,
                    int direction)
Perform a refresh for a set of sources and a given direction. The method gets blocked until the sync terminates.

Parameters:
syncMask - the set of sources to sync
direction - the refresh direction

refreshSources

public void refreshSources(java.util.Vector syncSources,
                           int direction)

syncEnded

public void syncEnded()
Description copied from interface: SyncEngineListener
Invoked at the end of the synchronization (always invoked, regardless of success or failure)

Specified by:
syncEnded in interface SyncEngineListener

synchronize

public void synchronize(java.lang.String syncType,
                        java.util.Vector syncSources)
Triggers a synchronization for the given syncSources. The caller can specify its type (manual, scheduled, push) to change the error handling behavior

Parameters:
syncType - the caller type (SYNC_TYPE_MANUAL, SYNC_TYPE_SCHEDULED)
syncSources - is a vector of AppSyncSource to be synced

synchronize

public void synchronize(java.lang.String syncType,
                        java.util.Vector syncSources,
                        int delay)
Schedules a synchronization for the given syncSources. The sync is scheduled in "delay" milliseconds from now. The caller can specify its type (manual, scheduled, push) to change the error handling behavior

Parameters:
syncType - the caller type (SYNC_TYPE_MANUAL, SYNC_TYPE_SCHEDULED)
syncSources - is a vector of AppSyncSource to be synced
delay - the interval at which the sync shall be performed (relative to now)

synchronize

public void synchronize(java.lang.String syncType,
                        java.util.Vector syncSources,
                        int delay,
                        boolean fromOutside)
Schedules a synchronization for the given syncSources. The sync is scheduled in "delay" milliseconds from now. The caller can specify its type (manual, scheduled, push) to change the error handling behavior. The caller can also specify it the sync request is generated outside of the application. In such a case the handling is special and the synchronization is actually performed by the Sync Client process. This calls notifies the SyncClient to schedule a sync at the given interval. This is useful when syncs are triggered on external events, such as modification of PIM (c2s push).

Parameters:
syncType - the caller type (SYNC_TYPE_MANUAL, SYNC_TYPE_SCHEDULED)
syncSources - is a vector of AppSyncSource to be synced
delay - the interval at which the sync shall be performed (relative to now)
fromOutside - specifies if the request is generated outside of the application

forceSynchronization

protected void forceSynchronization(java.lang.String syncType,
                                    java.util.Vector syncSources,
                                    boolean refresh,
                                    int direction,
                                    int delay,
                                    boolean fromOutside)

showPendingFirstSyncQuestion

public void showPendingFirstSyncQuestion()

continueSynchronizationAfterDialogCheck

public void continueSynchronizationAfterDialogCheck(java.lang.String syncType,
                                                    java.util.Vector filteredSources,
                                                    boolean refresh,
                                                    int direction,
                                                    int delay,
                                                    boolean fromOutside,
                                                    boolean continueSyncFromDialog)

confirmDeletes

public boolean confirmDeletes(java.util.Enumeration sourceNameList)
Description copied from interface: SyncEngineListener
Invoked if there are many items to delete. "Many" means more than 1/3 of the total number of items. If the method returns true the sync proceeds, otherwise it is aborted (for this source).

Specified by:
confirmDeletes in interface SyncEngineListener
Returns:
true if the sync shall proceed

isConnectionConfigurationAllowed

public boolean isConnectionConfigurationAllowed(java.lang.String apn)

noCredentials

public void noCredentials()
Description copied from interface: SyncEngineListener
Sync cannot be performed because the user did not set his credentials

Specified by:
noCredentials in interface SyncEngineListener

noSources

public void noSources()
Description copied from interface: SyncEngineListener
Sync cannot be performed because no sources are selected

Specified by:
noSources in interface SyncEngineListener

noConnection

public void noConnection()
Description copied from interface: SyncEngineListener
Sync cannot be performed because connections cannot be established

Specified by:
noConnection in interface SyncEngineListener

noSignal

public void noSignal()
Description copied from interface: SyncEngineListener
Sync cannot be performed because there is no network coverage

Specified by:
noSignal in interface SyncEngineListener

setCancel

public void setCancel(boolean value)

isCancelled

public boolean isCancelled()
Check if the current sync should be cancelled

Specified by:
isCancelled in interface SyncEngineListener
Returns:

setIsUserConfirmationNeeded

public void setIsUserConfirmationNeeded(boolean value)

beginSync

public void beginSync()
Description copied from interface: SyncEngineListener
A sync is about to begin. This is always invoked when the SyncEngine starts a synchronization

Specified by:
beginSync in interface SyncEngineListener

syncStarted

public boolean syncStarted(java.util.Vector sources)
Description copied from interface: SyncEngineListener
A sync for the given sources is about to begin.

Specified by:
syncStarted in interface SyncEngineListener

endSync

public void endSync(java.util.Vector sources,
                    boolean hadErrors)
Description copied from interface: SyncEngineListener
The synchronizaion has been completed for the given sources.

Specified by:
endSync in interface SyncEngineListener
Parameters:
sources - the list of sources being synchronized

sourceStarted

public void sourceStarted(AppSyncSource appSource)
Description copied from interface: SyncEngineListener
This method notifies that a new source is about to begin its synchronization.

Specified by:
sourceStarted in interface SyncEngineListener

sourceEnded

public void sourceEnded(AppSyncSource appSource)
Description copied from interface: SyncEngineListener
This method notifies that a source has completed its synchronization

Specified by:
sourceEnded in interface SyncEngineListener

sourceFailed

public void sourceFailed(AppSyncSource appSource,
                         SyncException e)
Description copied from interface: SyncEngineListener
This method is invoked when the synchronization of a source throws an exception. The exception is provided so the upper layers can decide if an error message shall be shown.

Specified by:
sourceFailed in interface SyncEngineListener

getRemoteUri

public java.lang.String getRemoteUri(AppSyncSource appSource)

serverOperationFailed

public void serverOperationFailed()

getController

public Controller getController()

clearErrors

public void clearErrors()

connectionOpened

public void connectionOpened()

requestWritten

public void requestWritten()

responseReceived

public void responseReceived()

connectionClosed

public void connectionClosed()

connectionConfigurationChanged

public void connectionConfigurationChanged()

setScreen

protected void setScreen(Screen screen)

createSyncEngine

protected SyncEngine createSyncEngine()


Copyright © 2001-2009 Funambol.