javacommons/comms/ipclib/clientserver/src.s60/common.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Comms helper functions and constants
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "logger.h"
       
    20 
       
    21 #include "common.h"
       
    22 
       
    23 
       
    24 namespace java
       
    25 {
       
    26 namespace comms
       
    27 {
       
    28 
       
    29 HBufC8* messageToDes(const ipcMessage_t& aMsg)
       
    30 {
       
    31     HBufC8* resultBuf = 0;
       
    32 
       
    33     int len = aMsg.ipcHeader.length;
       
    34     resultBuf = HBufC8::New(len);
       
    35     TPtr8 ptr = resultBuf->Des();
       
    36     TPtr8 ptr8((TUint8 *)&aMsg, len);
       
    37     ptr8.SetLength(len);
       
    38     ptr.Copy(ptr8);
       
    39 
       
    40     return resultBuf;
       
    41 }
       
    42 
       
    43 char* desToMessage(const TDesC8& aDes)
       
    44 {
       
    45     int len = aDes.Length();
       
    46     char* buf = new char[len];
       
    47     ::memcpy(buf, aDes.Ptr(), len);
       
    48     return buf;
       
    49 }
       
    50 
       
    51 
       
    52 } // namespace comms
       
    53 } // namespace java
       
    54