parameters: (self, syncml_request, subscription)
docstring: Global method that process the package 3, 4 & 5 of SyncML DS Protocol
docstring_summary: Global method that process the package 3, 4 & 5 of SyncML DS Protocol
docstring_tokens: Global method that process the package 3 4 & 5 of SyncML DS Protocol
function: def processClientSynchronization(self, syncml_request, subscription):
      """ Global method that process the package 3, 4 & 5 of SyncML DS Protocol """
      syncml_logger.info("xxx Client processing data from server (%s) xxx",
                         subscription.getSynchronizationState())
      syncml_logger.info("\tstatus %s, sync %s, final %s",
                         len(syncml_request.status_list),
                         len(syncml_request.sync_command_list),
                         syncml_request.isFinal)
      # We must log in with user defined
      subscription._loginUser()
  
      if syncml_request.alert_list:
        syncml_logger.warning("Got an alert from server not processed : %s",
                              syncml_request.alert_list)
        # Must check what server tell about database synchronization
        # and update the mode if required
  
      # Read status about databases & synchronizations
      self._readStatusList(syncml_request, subscription)
  
      if syncml_request.isFinal and \
        subscription.getSynchronizationState() == "initializing":
        # Server validated authentication ( must be done in readStatus list)
        # Client sends its modifications first before getting the one from server
        subscription.sendModifications()  # Worfklow action
  
      syncml_response = None
      tag = subscription.getRelativeUrl()
  
      # Do action according to synchronization state
      if subscription.getSynchronizationState() == "initializing":
        raise ValueError("Subscription still initializing, must not get here")
      elif subscription.getSynchronizationState() == "sending_modifications":
        # This is the package 3 of the sync process
        if subscription.getSyncmlAlertCode() in ("one_way_from_server",
                                                 "refresh_from_server_only"):
          # We only get data from server
          syncml_response = subscription.generateBaseResponse()
          syncml_response.addFinal()
        else:
          # Make sure it is launched after indexation step
          self.runGetAndActivate(subscription=subscription, tag=tag,
                                 after_method_id=("getAndIndex",
                                                  "SQLCatalog_indexSyncMLDocumentList"))
          syncml_logger.info("X-> Client is sendind modification in activities")
          # As we generated all activities to send data at once, process must not
          # go back here, go into processing state thus status will be applied and
          # if no sync command received, the process will just go on
        subscription.processSyncRequest()
      elif subscription.getSynchronizationState() == "processing_sync_requests":
        # In a second time, clients applied modifications from server
        # This is the package 5 of the protocol
        if syncml_request.isFinal or len(syncml_request.sync_command_list):
          # Either we get no sync command but a final tag notifying it is finished
          # Either we get sync command
          # Either we get both
          # Otherwise, it is just status message, no need to come here
          self.runApplySyncCommand(subscription=subscription,
                                   syncml_request=syncml_request,
                                   tag=tag)
          syncml_logger.info("-> Client apply command in %d activities",
                             len(syncml_request.sync_command_list))
        if syncml_request.isFinal:
          if not syncml_response:
            syncml_response = subscription.generateBaseResponse()
          # We got and process all sync command from server
          # notify it that all modifications were applied
          syncml_response.addFinal()
          # Send the message in activity after all sync command are applied
          subscription.activate(activity="SQLQueue",
                                priority=ACTIVITY_PRIORITY,
                                after_path_and_method_id =
                                (subscription.getPath(),
                                 'applySyncCommand'),
                                 after_tag=tag,).sendMessage(
                                   xml=str(syncml_response))
          # Synchronization process is now finished
          syncml_logger.info("\tClient finished processing messages from server")
          subscription.finish()
          syncml_response = None # XXX Do not resend the message
      else:
        raise ValueError("Unmanaged state of synchronization %s : %s"
                         % (subscription.getRelativeUrl(),
                            subscription.getSynchronizationState()))
  
      if subscription.getSynchronizationState() == "finished":
        # We do not expect anymore message from server
        # XXX Map of UID is not implemented
        syncml_logger.info('--- synchronization ended on the client side ---')
        # Remove authentication
        if subscription.getAuthenticationState() == 'logged_in':
          subscription.logout()
        subscription._edit(authenticated_user=None)
  
      if syncml_response:
        # Send the message in activity to prevent recomputing data in case of
        # transport failure
        syncml_logger.info("....client sending message....")
        subscription.activate(activity="SQLQueue").sendMessage(
          xml=str(syncml_response))
function_tokens: def processClientSynchronization ( self , syncml_request , subscription ) : syncml_logger . info ( "xxx Client processing data from server (%s) xxx" , subscription . getSynchronizationState ( ) ) syncml_logger . info ( "\tstatus %s, sync %s, final %s" , len ( syncml_request . status_list ) , len ( syncml_request . sync_command_list ) , syncml_request . isFinal ) # We must log in with user defined subscription . _loginUser ( ) if syncml_request . alert_list : syncml_logger . warning ( "Got an alert from server not processed : %s" , syncml_request . alert_list ) # Must check what server tell about database synchronization # and update the mode if required # Read status about databases & synchronizations self . _readStatusList ( syncml_request , subscription ) if syncml_request . isFinal and subscription . getSynchronizationState ( ) == "initializing" : # Server validated authentication ( must be done in readStatus list) # Client sends its modifications first before getting the one from server subscription . sendModifications ( ) # Worfklow action syncml_response = None tag = subscription . getRelativeUrl ( ) # Do action according to synchronization state if subscription . getSynchronizationState ( ) == "initializing" : raise ValueError ( "Subscription still initializing, must not get here" ) elif subscription . getSynchronizationState ( ) == "sending_modifications" : # This is the package 3 of the sync process if subscription . getSyncmlAlertCode ( ) in ( "one_way_from_server" , "refresh_from_server_only" ) : # We only get data from server syncml_response = subscription . generateBaseResponse ( ) syncml_response . addFinal ( ) else : # Make sure it is launched after indexation step self . runGetAndActivate ( subscription = subscription , tag = tag , after_method_id = ( "getAndIndex" , "SQLCatalog_indexSyncMLDocumentList" ) ) syncml_logger . info ( "X-> Client is sendind modification in activities" ) # As we generated all activities to send data at once, process must not # go back here, go into processing state thus status will be applied and # if no sync command received, the process will just go on subscription . processSyncRequest ( ) elif subscription . getSynchronizationState ( ) == "processing_sync_requests" : # In a second time, clients applied modifications from server # This is the package 5 of the protocol if syncml_request . isFinal or len ( syncml_request . sync_command_list ) : # Either we get no sync command but a final tag notifying it is finished # Either we get sync command # Either we get both # Otherwise, it is just status message, no need to come here self . runApplySyncCommand ( subscription = subscription , syncml_request = syncml_request , tag = tag ) syncml_logger . info ( "-> Client apply command in %d activities" , len ( syncml_request . sync_command_list ) ) if syncml_request . isFinal : if not syncml_response : syncml_response = subscription . generateBaseResponse ( ) # We got and process all sync command from server # notify it that all modifications were applied syncml_response . addFinal ( ) # Send the message in activity after all sync command are applied subscription . activate ( activity = "SQLQueue" , priority = ACTIVITY_PRIORITY , after_path_and_method_id = ( subscription . getPath ( ) , 'applySyncCommand' ) , after_tag = tag , ) . sendMessage ( xml = str ( syncml_response ) ) # Synchronization process is now finished syncml_logger . info ( "\tClient finished processing messages from server" ) subscription . finish ( ) syncml_response = None # XXX Do not resend the message else : raise ValueError ( "Unmanaged state of synchronization %s : %s" % ( subscription . getRelativeUrl ( ) , subscription . getSynchronizationState ( ) ) ) if subscription . getSynchronizationState ( ) == "finished" : # We do not expect anymore message from server # XXX Map of UID is not implemented syncml_logger . info ( '--- synchronization ended on the client side ---' ) # Remove authentication if subscription . getAuthenticationState ( ) == 'logged_in' : subscription . logout ( ) subscription . _edit ( authenticated_user = None ) if syncml_response : # Send the message in activity to prevent recomputing data in case of # transport failure syncml_logger . info ( "....client sending message...." ) subscription . activate ( activity = "SQLQueue" ) . sendMessage ( xml = str ( syncml_response ) )