presetserver/clientsrc/Psservsession.cpp
changeset 0 09774dfdd46b
child 12 608f67c22514
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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:  Implementation of RPSServSession
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <pscommon.h>
       
    20 #include <psserv.h>
       
    21 
       
    22 #include "psservsession.h"
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // Constructor.
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 RPSServSession::RPSServSession( RPSServ& aServ, TInt aId )
       
    29     : iPresetServ( aServ ), iId( aId )
       
    30     {
       
    31     }
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Closes the session.
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 void RPSServSession::Close()
       
    38     {
       
    39     Rollback();
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Begins a transaction.
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void RPSServSession::BeginTransactionL()
       
    47     {
       
    48     User::LeaveIfError( iPresetServ.SendReceive( EPSOpStartTransaction, TIpcArgs( iId ) ) ); 
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Commits the transaction.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void RPSServSession::CommitL()
       
    56     {
       
    57     User::LeaveIfError( iPresetServ.SendReceive( EPSOpCommitTransaction, TIpcArgs( iId ) ) );
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Reverts all changes done during the transaction.
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void RPSServSession::Rollback()
       
    65     {
       
    66     iPresetServ.Send( EPSOpRollbackTransaction, TIpcArgs( iId ) );
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Sets an integer value.
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void RPSServSession::SetL( TPSOpCode aServerCommand, TInt aValue )
       
    74     {
       
    75     User::LeaveIfError( iPresetServ.SendReceive( aServerCommand, TIpcArgs( iId, aValue ) ) );
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Gets an integer value.
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void RPSServSession::GetL( TPSOpCode aServerCommand, TInt& aValue )
       
    83     {
       
    84     TPckgBuf<TInt> value;
       
    85     User::LeaveIfError( iPresetServ.SendReceive( aServerCommand, TIpcArgs( iId, &value) ) );
       
    86     aValue = value();
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Sets an 8-bit descriptor value.
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void RPSServSession::SetL( TPSOpCode aServerCommand, const TDesC8& aValue )
       
    94     {
       
    95     User::LeaveIfError( iPresetServ.SendReceive( aServerCommand, TIpcArgs( iId, &aValue) ) );
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // Gets a 8-bit descriptor value.
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void RPSServSession::GetL( TPSOpCode aServerCommand, TPSOpCode aLengthCommand, HBufC8*& aValue )
       
   103     {
       
   104     TPckgBuf<TInt> length;
       
   105     User::LeaveIfError( iPresetServ.SendReceive( aLengthCommand, TIpcArgs( iId, &length ) ) );
       
   106 
       
   107     HBufC8* buf = HBufC8::NewLC( length() );
       
   108     TPtr8 ptr( buf->Des() );
       
   109 
       
   110     User::LeaveIfError( iPresetServ.SendReceive( aServerCommand, TIpcArgs( iId, &ptr ) ) );
       
   111     
       
   112     CleanupStack::Pop( buf );
       
   113     
       
   114     aValue = buf;
       
   115     }
       
   116     
       
   117 // ---------------------------------------------------------------------------
       
   118 // Sets a 16-bit descriptor value.
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void RPSServSession::SetL( TPSOpCode aServerCommand, const TDesC& aValue )
       
   122     {
       
   123     User::LeaveIfError( iPresetServ.SendReceive( aServerCommand, TIpcArgs( iId, &aValue) ) );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // Gets a 16-bit descriptor value.
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void RPSServSession::GetL( TPSOpCode aServerCommand, TPSOpCode aLengthCommand, HBufC*& aValue )
       
   131     {
       
   132     TPckgBuf<TInt> length;
       
   133     User::LeaveIfError( iPresetServ.SendReceive( aLengthCommand, TIpcArgs( iId, &length ) ) );
       
   134 
       
   135     HBufC* buf = HBufC::NewLC( length() );
       
   136     TPtr ptr( buf->Des() );
       
   137 
       
   138     User::LeaveIfError( iPresetServ.SendReceive( aServerCommand, TIpcArgs( iId, &ptr ) ) );
       
   139 
       
   140     CleanupStack::Pop( buf );
       
   141     
       
   142     aValue = buf;
       
   143     }