testexecfw/statsrv/device/source/statapi/src/appinstall.cpp
changeset 0 3e07fef1e154
equal deleted inserted replaced
-1:000000000000 0:3e07fef1e154
       
     1 /*
       
     2 * Copyright (c) 2005-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 "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 
       
    20 #include <e32base.h>
       
    21 #include <e32cons.h>
       
    22 #include <hal.h>
       
    23 #include <iniparser.h>
       
    24 
       
    25 // Epoc Includes
       
    26 #include <swi/launcher.h>
       
    27 
       
    28 
       
    29 #include "appinstall.h"
       
    30 #include "testsecurityinstuihandler.h"
       
    31 
       
    32 
       
    33 CAppInstall::CAppInstall()
       
    34 	{
       
    35 	}
       
    36 
       
    37 TInt CAppInstall::Install(const TDesC& aFileName)
       
    38 	{
       
    39 	
       
    40 	TInt error = KErrNone;
       
    41 
       
    42 	TFileName fileName(aFileName);
       
    43 	
       
    44 	fileName.PtrZ();	
       
    45 	
       
    46 	Swi::CInstallPrefs* iInstallPrefs = Swi::CInstallPrefs::NewL();
       
    47 	
       
    48 	CTestSecurityInstUIHandler* iUIHandler = CTestSecurityInstUIHandler::NewL();
       
    49 	
       
    50 	error = Swi::Launcher::Install(*iUIHandler,fileName,*iInstallPrefs);
       
    51 
       
    52 	delete iUIHandler;
       
    53 	delete iInstallPrefs;
       
    54 	
       
    55 	return error;
       
    56 	
       
    57 	}
       
    58 
       
    59 TInt CAppInstall::Uninstall(const TDesC& aUid)
       
    60 	{
       
    61 	
       
    62 	TInt error = KErrNone;
       
    63 
       
    64 	TLex conv(aUid);
       
    65 	
       
    66 	TUint32 id;
       
    67 	
       
    68 	error = conv.Val(id,EHex);
       
    69 	
       
    70 	if(error!=KErrNone)
       
    71 		{
       
    72 		return error;
       
    73 		}
       
    74 		
       
    75 	TUid uid = TUid::Uid(id);
       
    76 		
       
    77 	
       
    78 	CTestSecurityInstUIHandler* iUIHandler = CTestSecurityInstUIHandler::NewL();
       
    79 
       
    80 	error = Swi::Launcher::Uninstall(*iUIHandler, uid);
       
    81 	
       
    82 	delete iUIHandler;
       
    83 
       
    84 	return error;
       
    85 		
       
    86 	}
       
    87