Use Agent-Specific Commands

This is an extension mechanism to allow a client to perform an agent-specific function. The application needs to know the extended commands that the agent supports and the format of the input and output buffers used in the command. All of this is specified by the CAF agent, not the Content Access Framework.

The manager object must be created using the CManager::NewL() function.

The buffers allow agent specific objects to be externalized by an application, passed through CAF and internalized by the agent. The same principle applies for data returned from the agent to the application.
TInt FancyApplicationFunction(CManager& aManager, CAgent& aAgent, CFancyAgentInputObject& aInputObject, CFancyAgentOutputObject& aOutputObject)
    {
    // Buffer large enough to hold the expected output object 
    TBuf <1000> outputBuffer; 

    // Dynamic buffer to serialize aInputObject 
    CBufFlat* inputBuffer = CBufFlat::NewL(50); 
    CleanupStack::PushL(inputBuffer); 
    RBufWriteStream streamIn(*inputBuffer); 
    CleanupClosePushL(streamIn); 

    // write aInputObject to the dynamic buffer 
    aInputObject.ExternalizeL(streamIn); 
    CleanupStack::PopAndDestroy(&streamIn); 

    // Call the agent specific function #42 
    aManager.AgentSpecificCommand(aAgent, 42 ,inputBuffer->Ptr(0), outputBuffer); 

    // Don't need the input buffer any longer 
    delete *inputBuffer; 
    inputBuffer = NULL; 

    // Create a stream object to read the output buffer             
    RDesReadStream streamOut(outputBuffer); 

    // Build the output object from the output stream 
    aOutputBuffer.InternalizeL(streamOut); 
    }
Related concepts
Managing CAF Agents