locationsystemui/locationsysui/locpsysettings/locpsysettingseng/src/locpsyconfigclientwrapper.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2004 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:  PSY Configuration UI launching helper class implementations.
       
    15  *
       
    16 */
       
    17 
       
    18  
       
    19 // System Include
       
    20 #include <apgcli.h>
       
    21 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    22 #include <apaid.h>
       
    23 #else
       
    24 #include <apaid.h>
       
    25 #include <apaidpartner.h>
       
    26 #endif
       
    27 #include <barsread2.h>
       
    28 #include <LocPsyConfigUiUID.hrh>
       
    29 
       
    30 // User Include
       
    31 #include "locpsyconfigclientwrapper.h"
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CLocPsyConfigUiReg::CLocPsyConfigUiReg
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CLocPsyConfigUiReg::CLocPsyConfigUiReg()
       
    38 {
       
    39 }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CLocPsyConfigUiReg::NewL
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CLocPsyConfigUiReg* CLocPsyConfigUiReg::NewL( TUid aApp, const TDesC8& aResource )
       
    46 	{
       
    47 	CLocPsyConfigUiReg* reg = new(ELeave) CLocPsyConfigUiReg;
       
    48 	CleanupStack::PushL(reg);
       
    49 	reg->ConstructL( aApp, aResource );
       
    50 	CleanupStack::Pop(reg);
       
    51 	return reg;
       
    52 	}
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CLocPsyConfigUiReg::ConstructL
       
    56 // -----------------------------------------------------------------------------
       
    57 //	
       
    58 void CLocPsyConfigUiReg::ConstructL( TUid aApp, const TDesC8& aResource )
       
    59 	{
       
    60 	iAppUid = aApp;
       
    61 	RResourceReader r;
       
    62 	r.OpenLC(aResource);
       
    63 	iRegId = r.ReadInt32L();					// read psy_uid
       
    64 	CleanupStack::PopAndDestroy(&r);
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CLocPsyConfigUiReg::AppUid
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 TUid CLocPsyConfigUiReg::AppUid()
       
    72 	{
       
    73 	return iAppUid;
       
    74 	}
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CLocPsyConfigUiReg::RegId
       
    78 // -----------------------------------------------------------------------------
       
    79 //	
       
    80 TInt CLocPsyConfigUiReg::RegId()
       
    81 	{
       
    82 	return iRegId;
       
    83 	}
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CLocPsyConfigUiServiceClient::DiscoverLC
       
    87 // -----------------------------------------------------------------------------
       
    88 //	
       
    89 CLocPsyConfigUiReg* CLocPsyConfigUiServiceClient::DiscoverLC( const TInt PsyUid )
       
    90 	{
       
    91 	// Get all of the implementations of the transform service
       
    92 	CLocPsyConfigUiReg* regInfo = NULL;
       
    93 	TInt error;
       
    94 	RApaLsSession ls;
       
    95 	User::LeaveIfError(ls.Connect());
       
    96 	CleanupClosePushL(ls);
       
    97 	CApaAppServiceInfoArray* services = NULL;
       
    98 	do
       
    99 		{
       
   100 		// If Error is EAppListInvalid then try again till you get the list.
       
   101 		// The services structure
       
   102 		TRAP(error, 
       
   103 				services = ls.GetServiceImplementationsLC(
       
   104 									TUid::Uid(KLocPsyConfigServiceUid));
       
   105 				CleanupStack::Pop(services););
       
   106 		} while (error == RApaLsSession::EAppListInvalid);
       
   107 	CleanupStack::PushL(services);
       
   108 	
       
   109 	// If there was an error then leave
       
   110 	User::LeaveIfError(error);
       
   111 
       
   112 	TArray< TApaAppServiceInfo > ServInfoArray = services->Array();
       
   113 	for (TInt i=0; i<ServInfoArray.Count() ; i++)
       
   114 		{
       
   115 		// This is under TRAP so that corrupt resources don't crash the 
       
   116 		// discovery procedure.
       
   117 		// The TRAP's return code is ignored intentionally
       
   118 		const TApaAppServiceInfo& appInfo = ServInfoArray[i];
       
   119 		TRAP(error, regInfo = 
       
   120 			CLocPsyConfigUiReg::NewL(appInfo.Uid(), appInfo.OpaqueData()););
       
   121 		if(	error == KErrNone && regInfo->RegId() == PsyUid )
       
   122 			{
       
   123 			// Found the correct PSY module so just break out of the loop
       
   124 			// and return the regInfo from outside the loop.
       
   125 			break;
       
   126 			}
       
   127 		else
       
   128 			{
       
   129 			delete regInfo;
       
   130 			regInfo = NULL;
       
   131 			}
       
   132 		}
       
   133 	
       
   134 	CleanupStack::PopAndDestroy(services);
       
   135 	CleanupStack::PopAndDestroy() ;// ls
       
   136 	CleanupStack::PushL(regInfo);
       
   137 	return regInfo;
       
   138 	}