PECengine/StorageManager2/ClientSrc/RPEngStorageAdminClient.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:  Used for testing and connection of the Admin sub clients
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "RPEngStorageAdminClient.h"
       
    21 #include <eikdll.h>
       
    22 #include <f32file.h>
       
    23 
       
    24 #include "PEngServerStarter.h"
       
    25 #include "PEngStorageServerCommon.h"
       
    26 #include "TPEngStorageServerMessages.h"
       
    27 #include "PEngMessagePacker.h"
       
    28 
       
    29 // PEC Engine internal constants
       
    30 #include "PEngInternalGlobalConsts.h"
       
    31 
       
    32 #include "PresenceDebugPrint.h"
       
    33 
       
    34 
       
    35 // CONSTANTS
       
    36 // each session can have several subsession, while only one subsession
       
    37 // is using asynchronouse requests, 20 slots shall be enough to cover
       
    38 const TUint KMessageSlotCount = 20;
       
    39 
       
    40 // MACROS
       
    41 #define RETURN_IF_NOT_CONNECTED()\
       
    42     if(!iConnected)\
       
    43         {\
       
    44         return KErrDisconnected;\
       
    45         }
       
    46 
       
    47 
       
    48 // ============================ EXPORTED FUNCTIONS ===============================
       
    49 // ============================ MEMBER FUNCTIONS ===============================
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // RPEngStorageAdminClient::RPEngStorageAdminClient
       
    53 // C++ default constructor can NOT contain any code, that might leave.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C RPEngStorageAdminClient::RPEngStorageAdminClient()
       
    57     {
       
    58     }
       
    59 
       
    60 
       
    61 // Destructor
       
    62 EXPORT_C RPEngStorageAdminClient::~RPEngStorageAdminClient()
       
    63     {
       
    64     }
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // RPEngStorageAdminClient::Connect
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C TInt RPEngStorageAdminClient::Connect()
       
    72     {
       
    73     PENG_DP_TXT( "RPEngStorageAdminClient::Connect()" );
       
    74 
       
    75     //Connects this client to the server.
       
    76     //Launches new server process if one not yet running.
       
    77     TInt err = PEngServerStarter::ConnectServer( *this,
       
    78                                                  KStorageServerName,
       
    79                                                  Version(),
       
    80                                                  KMessageSlotCount,
       
    81                                                  KStorageServerExe );
       
    82 
       
    83     iConnected = ( err == KErrNone );
       
    84     return err;
       
    85     }
       
    86 
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // RPEngStorageAdminClient::Close
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 EXPORT_C void RPEngStorageAdminClient::Close()
       
    93     {
       
    94     PENG_DP_TXT( "RPEngStorageAdminClient::Close()" );
       
    95 
       
    96     // all requests from this session are canceled on the server side
       
    97     RSessionBase::Close();
       
    98     iConnected = EFalse;
       
    99     }
       
   100 
       
   101 
       
   102 // =============================================================================
       
   103 // ----------------------- Testing support -------------------------------------
       
   104 // =============================================================================
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // RPEngStorageAdminClient::WipeSession
       
   108 // Wipe session folder from the storage
       
   109 // (other items were commented in a header).
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 EXPORT_C TInt RPEngStorageAdminClient::WipeSession(
       
   113     const TDesC8& aSessionId )
       
   114     {
       
   115     PENG_DP_TXT( "RPEngStorageAdminClient::WipeSession()" );
       
   116 
       
   117     RETURN_IF_NOT_CONNECTED();
       
   118     TIpcArgs messArgs;
       
   119     messArgs.Set( KMessageSlot0, &aSessionId );
       
   120     return SendReceive( EMainSessWipeSessionFolder, messArgs );
       
   121     }
       
   122 
       
   123 
       
   124 // =============================================================================
       
   125 // ------------ NEW PRIVATE FUNCTIONS ------------------------------------------
       
   126 // =============================================================================
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // RPEngStorageAdminClient::Version
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TVersion RPEngStorageAdminClient::Version() const
       
   133     {
       
   134     return( TVersion( KClientVersionMajor,
       
   135                       KClientVersionMinor,
       
   136                       KClientVersionBuild ) );
       
   137     }
       
   138 
       
   139 //  End of File
       
   140 
       
   141 
       
   142 
       
   143 
       
   144 
       
   145 
       
   146 
       
   147 
       
   148 
       
   149 
       
   150 
       
   151 
       
   152 
       
   153 
       
   154 
       
   155 
       
   156 
       
   157 
       
   158 
       
   159