// -----------------------------------------------------------------------------
// TMSCallSession::HandleDataXferBufferGetHndlCallL
//
// -----------------------------------------------------------------------------
//
void TMSCallSession::HandleDataXferBufferGetHndlCallL(
        const RMessage2& aMessage)
    {
    TRACE_PRN_FN_ENT;
    gint status(TMS_RESULT_DOES_NOT_EXIST);
    RChunk chunk;

    if (iCallAdpt &&(iActiveCallType == TMS_CALL_IP))
        {
        TMSCliSrvDataXferChunkHndlDataStructBufPckg pckg;
        aMessage.ReadL(0, pckg);
        status = static_cast<TMSCallIPAdpt*>(iCallAdpt)->GetDataXferBufferHndl(
                pckg().CallType, pckg().StreamType, pckg().StreamId,
                pckg().Key, chunk);
        }

    if (status == TMS_RESULT_SUCCESS && chunk.Handle() > 0)
        {
        aMessage.Complete(chunk);
        }
    else
        {
        // TODO: make sure error code is negative or zero
        aMessage.Complete(0);
        }

    TRACE_PRN_FN_EXT;
    }
Esempio n. 2
0
PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
{
    // On Symbian, global chunks (shared memory segments) have system-unique names, so we pick a random
    // number from the kernel's random pool and use it as a string.
    // Using an integer simplifies serialization of the name in Handle::encode()
    uint32_t random = Math::Random();

    TBuf<KMaxKernelName> chunkName;
    chunkName.Format(_L("%d"), random);

    RChunk chunk;
    TInt error = chunk.CreateGlobal(chunkName, size, size);
    if (error) {
        qCritical() << "Failed to create WK2 shared memory of size " << size << " with error " << error;
        return 0;
    }

    RefPtr<SharedMemory> sharedMemory(adoptRef(new SharedMemory));
    sharedMemory->m_handle = chunk.Handle();
    sharedMemory->m_size = chunk.Size();
    sharedMemory->m_data = static_cast<void*>(chunk.Base());
    return sharedMemory.release();
}
Esempio n. 3
0
PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
{
    if (handle.isNull())
        return 0;

    // Convert number to string, and open the global chunk
    TBuf<KMaxKernelName> chunkName;
    chunkName.Format(_L("%d"), handle.m_chunkID);

    RChunk chunk;
    // NOTE: Symbian OS doesn't support read-only global chunks.
    TInt error = chunk.OpenGlobal(chunkName, false);
    if (error) {
        qCritical() << "Failed to create WK2 shared memory from handle " << error;
        return 0;
    }

    chunk.Adjust(chunk.MaxSize());
    RefPtr<SharedMemory> sharedMemory(adoptRef(new SharedMemory));
    sharedMemory->m_handle = chunk.Handle();
    sharedMemory->m_size = chunk.Size();
    sharedMemory->m_data = static_cast<void*>(chunk.Base());
    return sharedMemory.release();
}