installationservices/swcomponentregistry/scrhelper/source/scrhelperclient.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
child 27 e8965914fac7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2008-2009 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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32cmn.h>
       
    20 #include "scrhelperclient.h"
       
    21 
       
    22 using namespace Usif;
       
    23 
       
    24 EXPORT_C RScrHelper::RScrHelper()
       
    25 	:	RScsClientBase()
       
    26 	{
       
    27 	// empty
       
    28 	}
       
    29 
       
    30 EXPORT_C TInt RScrHelper::Connect()
       
    31 	{
       
    32 	DEBUG_PRINTF(_L8("Connecting to SCR Helper Server!"));
       
    33 	TVersion version = ScrHelperServerVersion();
       
    34 	TUidType fullUid = ScrHelperServerImageFullUid();		
       
    35 	return RScsClientBase::Connect(KScrHelperServerName(), version, KScrHelperServerImg(), fullUid);
       
    36 	}
       
    37 
       
    38 EXPORT_C void RScrHelper::Close()
       
    39 	{
       
    40 	DEBUG_PRINTF(_L8("Closing SCR Helper connection!"));
       
    41 	RScsClientBase::Close();
       
    42 	}
       
    43 
       
    44 EXPORT_C void RScrHelper::RetrieveFileHandlesL(RFile& aScrDatabase, RFile& aScrJournal)
       
    45 	{
       
    46 	DEBUG_PRINTF(_L8("Retrieving  database and journal file handles from SCR Helper Server!"));
       
    47 	// First, retrieve database file handle
       
    48 	GetFileHandleL(EGetDatabaseFileHandle, aScrDatabase);
       
    49 	// Then, retrieve journal file handle
       
    50 	GetFileHandleL(EGetJournalFileHandle, aScrJournal);
       
    51 	}
       
    52 
       
    53 void RScrHelper::GetFileHandleL(Usif::TScrHelperServerMessages aFunction, RFile& aFile)
       
    54 	{
       
    55 	// Retrieve the RFs and RFile handles from the server
       
    56 	TInt fsh;          	 // File server handle (RFs - session)
       
    57 	TPckgBuf<TInt> fh;   // File handle (RFile - subsession)
       
    58 		
       
    59 	fsh = CallSessionFunction(aFunction, TIpcArgs(&fh));   // pointer to fh in slot 0
       
    60 	User::LeaveIfError(fsh);
       
    61 	
       
    62 	// Adopt the file using the returned handles
       
    63 	User::LeaveIfError(aFile.AdoptFromServer(fsh, fh()));
       
    64 	}