javacommons/comms/ipclib/clientserver/src.s60/rcomms.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: Wrapper for low level Symbian IPC methods
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "logger.h"
       
    20 
       
    21 #include "rcomms.h"
       
    22 #include "common.h"
       
    23 
       
    24 namespace java
       
    25 {
       
    26 namespace comms
       
    27 {
       
    28 const TInt MAX_MESSAGE_SLOTS = 20;
       
    29 
       
    30 TInt RComms::Connect(const TDesC& aName)
       
    31 {
       
    32     TInt rc = CreateSession(aName, TVersion(1,1,1), MAX_MESSAGE_SLOTS, EIpcSession_Sharable);
       
    33 
       
    34     if (rc)
       
    35     {
       
    36         ELOG2(EJavaComms, "%s failed, err = %d", __PRETTY_FUNCTION__, rc);
       
    37     }
       
    38     return rc;
       
    39 }
       
    40 
       
    41 void RComms::Disconnect()
       
    42 {
       
    43     Close();
       
    44 }
       
    45 
       
    46 TInt RComms::Send(const TDesC8& aData)
       
    47 {
       
    48     return SendReceive(ESend, TIpcArgs(&aData));
       
    49 }
       
    50 
       
    51 void RComms::Receive(RBuf8& aBuffer, TPckgBuf<TInt>& aRequiredSize, TRequestStatus& aStatus)
       
    52 {
       
    53     TIpcArgs args;
       
    54     args.Set(0, &aBuffer);
       
    55     args.Set(1, &aRequiredSize);
       
    56 
       
    57     SendReceive(EReceive, args, aStatus);
       
    58 }
       
    59 
       
    60 void RComms::CancelReceive()
       
    61 {
       
    62     SendReceive(ECancelReceive, TIpcArgs());
       
    63 }
       
    64 
       
    65 } // namespace comms
       
    66 } // namespace java