installationservices/swi/source/swisidchecker/swisidchecker.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-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 "swisidchecker.h"
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <ecom/implementationproxy.h>
       
    23 
       
    24 #include "swiinstallmonitor.h"
       
    25 #include <f32file.h>
       
    26 
       
    27 //////////////////////////////
       
    28 // ECOM Implementation Table
       
    29 //////////////////////////////
       
    30 
       
    31 
       
    32 TBool E32Dll()
       
    33 	{
       
    34 	return (ETrue);
       
    35 	}
       
    36 
       
    37 const TImplementationProxy ImplementationTable[] =
       
    38 	{
       
    39 		IMPLEMENTATION_PROXY_ENTRY(0x10281FBD, CSwiSidChecker::NewL)
       
    40 	};
       
    41 
       
    42 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
    43 	{
       
    44 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    45 	return ImplementationTable;
       
    46 	}
       
    47 
       
    48 //////////////////////////////
       
    49 // CSwiSidChecker
       
    50 //////////////////////////////
       
    51 
       
    52 CSwiSidChecker* CSwiSidChecker::NewL()
       
    53 	{
       
    54 	CSwiSidChecker* self = new(ELeave) CSwiSidChecker();
       
    55 	return self;
       
    56 	}
       
    57 
       
    58 CSwiSidChecker::CSwiSidChecker()
       
    59 	{
       
    60 	}
       
    61 	
       
    62 
       
    63 CSwiSidChecker::~CSwiSidChecker()
       
    64 	{
       
    65 	}
       
    66 
       
    67 TBool CSwiSidChecker::AppRegisteredAt(const TUid& aSid, TDriveUnit aDrive)
       
    68 	{
       
    69 	TBool present = EFalse; // init to avoid arm compiler warning
       
    70 	TRAPD(err, present = AppRegisteredAtInternalL(aSid, aDrive));
       
    71 	return (err == KErrNone) && present;
       
    72 	}
       
    73 
       
    74 TBool CSwiSidChecker::AppRegisteredAtInternalL(const TUid& aSid, TDriveUnit aDrive)
       
    75 	{
       
    76 	TBool present = EFalse; // init to avoid arm compiler warning
       
    77 
       
    78 	Swi::RSisRegistrySession sisRegSession;
       
    79 	User::LeaveIfError(sisRegSession.Connect());
       
    80 	CleanupClosePushL(sisRegSession);
       
    81 
       
    82 	present = sisRegSession.IsSidPresentL(aSid);
       
    83 
       
    84 	if(present)
       
    85 		{
       
    86 		// Check drive as well
       
    87 		TFileName fileName;
       
    88 		sisRegSession.SidToFileNameL(aSid, fileName, aDrive);
       
    89 		TInt drive;
       
    90 		User::LeaveIfError(RFs::CharToDrive(fileName[0], drive));
       
    91 		if(drive != aDrive)
       
    92 			{
       
    93 			present = EFalse;
       
    94 			}
       
    95 		}
       
    96 	
       
    97 
       
    98 	CleanupStack::PopAndDestroy(&sisRegSession);
       
    99 	
       
   100 	return present;
       
   101 	}
       
   102 	
       
   103 void CSwiSidChecker::SetRescanCallBackL(const TCallBack &aCallBack)
       
   104 	{
       
   105 	if(iSwiInstallMonitor)
       
   106 		{
       
   107 		delete iSwiInstallMonitor;
       
   108 		iSwiInstallMonitor = 0;
       
   109 		}
       
   110 
       
   111 	if(aCallBack.iFunction)
       
   112 		{
       
   113 		iSwiInstallMonitor = CSwiInstallMonitor::NewL(aCallBack);
       
   114 		iSwiInstallMonitor->Start();
       
   115 		}
       
   116 	}
       
   117 
       
   118 // End of file