PECengine/PresenceServer2/ClientSrc/RPEngTransferClient.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2002 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:   Sub-session of the Presence Server
       
    15 *  It is used to update date of the PEC engine to network
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 #include "RPEngTransferClient.h"
       
    22 
       
    23 #include "RPEngManagerClient.h"
       
    24 
       
    25 #include "TPEngServerMessages.h"
       
    26 
       
    27 // Global constants of the PEC engine
       
    28 #include "PEngInternalGlobalConsts.h"
       
    29 
       
    30 #include "PresenceDebugPrint.h"
       
    31 
       
    32 
       
    33 // MACROS
       
    34 #define RETURN_ERR_IF_NOT_CONNECTED()\
       
    35     if(!iConnected)\
       
    36         {\
       
    37         return KErrDisconnected;\
       
    38         }
       
    39 
       
    40 #define RETURN_IF_NOT_CONNECTED()\
       
    41     if(!iConnected)\
       
    42         {\
       
    43         return;\
       
    44         }
       
    45 
       
    46 // ============================ EXPORTED FUNCTIONS =============================
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // RPEngTransferClient::RPEngClientNotifyApi
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C RPEngTransferClient::RPEngTransferClient()
       
    53     {
       
    54     }
       
    55 
       
    56 // Destructor
       
    57 EXPORT_C RPEngTransferClient::~RPEngTransferClient()
       
    58     {
       
    59     }
       
    60 
       
    61 // ============================ CONNECT FUNCTIONS ==============================
       
    62 // -----------------------------------------------------------------------------
       
    63 // RPEngTransferClient::Connect
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C TInt RPEngTransferClient::Connect(
       
    67     const TDesC8& aSessSlotId ,
       
    68     const TDesC& aAppId,
       
    69     RPEngManagerClient& aManagerClient )
       
    70     {
       
    71     PENG_DP_TXT( "RPEngTransferClient::Connect()" );
       
    72 
       
    73     TIpcArgs messArguments;
       
    74     messArguments.Set( KMessageSlot0, &aSessSlotId );
       
    75     messArguments.Set( KMessageSlot1, &aAppId );
       
    76 
       
    77     TInt err( RSubSessionBase::CreateSubSession( aManagerClient,
       
    78                                                  EMainSessCreateTransactionSubSession,
       
    79                                                  messArguments ) );
       
    80 
       
    81     iConnected = ( err == KErrNone );
       
    82     return err;
       
    83     }
       
    84 
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // RPEngTransferClient::Close
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C void RPEngTransferClient::Close()
       
    91     {
       
    92     PENG_DP_TXT( "RPEngTransferClient::Close()" );
       
    93 
       
    94     // all requests from this sub-session are canceled by framework
       
    95     CloseSubSession( EMainSessCloseSubSession );
       
    96     iConnected = EFalse;
       
    97     }
       
    98 
       
    99 
       
   100 // ======================= TRANSFER EXPORTED FUNCTIONS ===========================
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // RPEngTransferClient::UpdateData
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 EXPORT_C TInt RPEngTransferClient::UpdateData(
       
   107     TInt aOperation,
       
   108     const TDesC& aData,
       
   109     TRequestStatus& aStatus )
       
   110     {
       
   111     RETURN_ERR_IF_NOT_CONNECTED();
       
   112     TIpcArgs messArgs;
       
   113     messArgs.Set( KMessageSlot0, aOperation );
       
   114     messArgs.Set( KMessageSlot1, &aData );
       
   115     // now when we have still free slots, pass length of data
       
   116     // since some operation simply do not pass data
       
   117     messArgs.Set( KMessageSlot3, aData.Length() );
       
   118     SendReceive( ESubSessUpdateData, messArgs, aStatus );
       
   119     return KErrNone;
       
   120     }
       
   121 
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // RPEngTransferClient::UpdateData
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C TInt RPEngTransferClient::FetchLastRequestResult(
       
   128     TDes8& aRequestResult )
       
   129     {
       
   130     RETURN_ERR_IF_NOT_CONNECTED();
       
   131     TIpcArgs messArgs;
       
   132     messArgs.Set( KMessageSlot0, &aRequestResult );
       
   133     // store there also max length, for information
       
   134     messArgs.Set( KMessageSlot1, aRequestResult.MaxLength() );
       
   135     return SendReceive( ESubSessFetchUpdateRqstResult, messArgs );
       
   136     }
       
   137 
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // RPEngTransferClient::UpdateData
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 EXPORT_C void RPEngTransferClient::CancelUpdateData()
       
   144     {
       
   145     RETURN_IF_NOT_CONNECTED();
       
   146     TIpcArgs messArg;
       
   147     messArg.Set( KMessageSlot0, ESubSessUpdateData );
       
   148     SendReceive( ESubSessCancelRequest, messArg );
       
   149     }
       
   150 
       
   151 //  End of File
       
   152 
       
   153 
       
   154 
       
   155 
       
   156 
       
   157 
       
   158 
       
   159 
       
   160 
       
   161 
       
   162 
       
   163 
       
   164 
       
   165 
       
   166 
       
   167 
       
   168 
       
   169 
       
   170 
       
   171 
       
   172