// ----------------------------------------------------------------------------- // CMediatorServerCommandHandler::UnregisterCommandListL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CMediatorServerCommandHandler::UnregisterCommandListL( TMediatorCategory aCategory, const RCommandList& aCommands, TSecureId aSecureId ) { LOG(_L("[Mediator Server]\t CMediatorServerCommandHandler::UnregisterCommandListL")); CCategory* category = iObjectHandler.CategoryL( aCategory ); TInt error = KErrNone; if ( category ) { TBool stop = EFalse; TInt index = 0; // Loop through the list of commands and unregister those. for ( index = 0; index < aCommands.Count() && !stop; index++ ) { TInt commandIndex = 0; TCommand removeCommand = aCommands[index]; CCommand* commandPtr = category->FindCommand( removeCommand.iCommandId, commandIndex ); if ( !commandPtr ) { ERROR_LOG(_L("[Mediator] CMediatorServerCommandHandler::UnregisterCommandListL: Command not found\n") ); ERROR_TRACE(Print(_L("[Mediator] Failed to remove command %d in category %d of domain %d\n"), removeCommand.iCommandId, aCategory.iCategory.iUid, aCategory.iDomain.iUid ) ); error = KErrMediatorCommandNotFound; stop = ETrue; } else { // Found the command --> is it own registration? if ( commandPtr->SecureId() != aSecureId ) { ERROR_LOG(_L("[Mediator] CMediatorServerCommandHandler::UnregisterCommandListL: Secure ID mismatch\n") ); ERROR_TRACE(Print(_L("[Mediator] commandPtr()->SecureId()=0x%x, aSecureId=0x%x\n"), commandPtr->SecureId().iId, aSecureId.iId ) ); error = KErrMediatorSecureIdMismatch; stop = ETrue; } else // Should be ok to unregister { commandPtr->SetCommitState( CItem::ERemoved ); } } } TRACE(Print(_L("[Mediator Server]\t Commands unregistered:\n"))); TRACE(Print(_L("[Mediator Server]\t Processed/Total: %d/%d \tstatus: %d"), index, aCommands.Count(), error )); // Check error status --> if there's error, need to roll back if ( error != KErrNone ) { category->RollbackCommands(); } else { category->CommitCommands(); // loop through unregistered commands, and if they can be found from pending commands list, // inform the command issuer for ( TInt i = 0; i < aCommands.Count(); i++ ) { // ignore return value IssueResponse( aCategory, aCommands[i], KNullDesC8, KErrMediatorCommandRemoved ); } // Use the object handler to notify command registration iObjectHandler.CommandsRemoved( aCategory.iDomain, aCategory.iCategory, aCommands ); } } // Leave in case of error situation User::LeaveIfError( error ); }