SyncStatusListener API

You can implement a synchronization status listener to track synchronization progress.

Note: This topic is not applicable for DOE-based applications.

As the application synchronization progresses, the method defined by the SUPSyncStatusListener protocol is called and is passed an SUPSyncStatusInfo object. The SUPSyncStatusInfo object contains information about the MBO being synchronized, the connection to which it is related, and the current state of the synchronization process. By testing the State property of the SUPSyncStatusInfo object and comparing it to the possible values in the SUPSyncStatusState enumeration, the application can react accordingly to the state of the synchronization.

The synchronization can be aborted by setting the "state" property of the SUPSyncStatusInfo object to the value SYNC_STATUS_CANCEL before the method returns.

info.state = SYNC_STATE_CANCEL;

This setting may be needed if the application goes into the background during a long synchronization.

The method returns false to allow synchronization to continue. If the method returns true, the synchronization is aborted.

Possible uses of method include changing form elements on the client screen to show synchronization progress, such as a green image when the synchronization is in progress, a red image if the synchronization fails, and a gray image when the synchronization has completed successfully and disconnected from the server.

Note: The method of SUPSyncStatusListener is called and executed in the data synchronization thread. If a client runs synchronizations in a thread other than the primary user interface thread, the client cannot update its screen as the status changes. The client must instruct the primary user interface thread to update the screen regarding the current synchronization status.

This is an example of SUPSyncStatusListener implementation:

// The interface file

#import "SUPSyncStatusListener.h"
#import "SUPSyncStatusInfo.h"

@interface MySyncStatusListner : NSObject <SUPSyncStatusListener>

@end



// The implementation file

#import "MySyncStatusListner.h"

@implementation MySyncStatusListner


-(void) onGetSyncStatusChange:(SUPSyncStatusInfo*)info
{
  switch(info.state)
  {
      case SYNC_STATE_NONE:
          MBOLogDebug(@"SYNC_STATE_NONE");
          break;
      case SYNC_STATE_STARTING:
          MBOLogDebug(@"SYNC_STATE_STARTING");
          break;
      case SYNC_STATE_CONNECTING:
          MBOLogDebug(@"SYNC_STATE_CONNECTING");
          break;
      case SYNC_STATE_SENDING_HEADER:   
          MBOLogDebug(@"SYNC_STATE_SENDING_HEADER");
          break;
      case SYNC_STATE_SENDING_TABLE:
          MBOLogDebug(@"SYNC_STATE_SENDING_TABLE");
          break;
      case SYNC_STATE_SENDING_DATA:
          MBOLogDebug(@"SYNC_STATE_SENDING_DATA");
          break;
      case SYNC_STATE_FINISHING_UPLOAD:
          MBOLogDebug(@"SYNC_STATE_FINISHING_UPLOAD");
          break;
      case SYNC_STATE_RECEIVING_UPLOAD_ACK:
          MBOLogDebug(@"SYNC_STATE_RECEIVING_UPLOAD_ACK");
          break;
      case SYNC_STATE_RECEIVING_TABLE:
          MBOLogDebug(@"SYNC_STATE_RECEIVING_TABLE");
          break;
      case SYNC_STATE_RECEIVING_DATA:
          MBOLogDebug(@"SYNC_STATE_RECEIVING_DATA");
          break;
      case SYNC_STATE_COMMITTING_DOWNLOAD:
          MBOLogDebug(@"SYNC_STATE_COMMITTING_DOWNLOAD");
          break;
      case SYNC_STATE_SENDING_DOWNLOAD_ACK:
          MBOLogDebug(@"SYNC_STATE_SENDING_DOWNLOAD_ACK");
          break;
      case SYNC_STATE_DISCONNECTING:
          MBOLogDebug(@"SYNC_STATE_DISCONNECTING");
          break;
      case SYNC_STATE_DONE:
          MBOLogDebug(@"SYNC_STATE_DONE");
          break;           
      default:
          MBOLogDebug(@"DEFAULT");
          break;       
  }
}

@end