appinstaller/AppMngr2/Sisx/src/appmngr2sisxunknownlist.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   Implementation of CAppMngr2SisxUnknownList class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "appmngr2sisxunknownlist.h"    // CAppMngr2SisxUnknownList
       
    20 #include <appmngr2debugutils.h>         // FLOG macros
       
    21 
       
    22 const TInt KUIDLength = 8;
       
    23 
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // CAppMngr2SisxUnknownList::NewL()
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CAppMngr2SisxUnknownList* CAppMngr2SisxUnknownList::NewL( TInt aDriveNumber )
       
    32     {
       
    33     CAppMngr2SisxUnknownList* self = NewLC( aDriveNumber );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CAppMngr2SisxUnknownList::NewLC()
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CAppMngr2SisxUnknownList* CAppMngr2SisxUnknownList::NewLC( TInt aDriveNumber )
       
    43     {
       
    44     CAppMngr2SisxUnknownList* self = new (ELeave) CAppMngr2SisxUnknownList;
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL( aDriveNumber );
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CAppMngr2SisxUnknownList::~CAppMngr2SisxUnknownList()
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CAppMngr2SisxUnknownList::~CAppMngr2SisxUnknownList()
       
    55     {
       
    56     iUnknownPackages.ResetAndDestroy();
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CAppMngr2SisxUnknownList::PkgCount()
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 TInt CAppMngr2SisxUnknownList::PkgCount() const
       
    64     {
       
    65     return iUnknownPackages.Count();
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CAppMngr2SisxUnknownList::PkgEntry()
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 Swi::CUninstalledPackageEntry& CAppMngr2SisxUnknownList::PkgEntry( TInt aIndex )
       
    73     {
       
    74     return *iUnknownPackages[ aIndex ];     // panics if aIndex out of range
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CAppMngr2SisxUnknownList::FindPkgWithUID()
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 TInt CAppMngr2SisxUnknownList::FindPkgWithUID( const TUid& aUid )
       
    82     {
       
    83     FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUID( 0x%08x )", aUid.iUid );
       
    84 
       
    85     TInt count = iUnknownPackages.Count();
       
    86     FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName, count = %d", count );
       
    87     for( TInt index = 0; index < count; index++ )
       
    88         {
       
    89         if( iUnknownPackages[ index ]->Uid() == aUid )
       
    90             {
       
    91             return index;
       
    92             }
       
    93         }
       
    94     return KErrNotFound;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CAppMngr2SisxUnknownList::FindPkgWithUIDName()
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 TInt CAppMngr2SisxUnknownList::FindPkgWithUIDName( const TDesC& aUIDName )
       
   102     {
       
   103     FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName( %S )", &aUIDName );
       
   104     
       
   105     TInt count = iUnknownPackages.Count();
       
   106     FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName, count = %d", count );
       
   107     if( count && aUIDName.Length() >= KUIDLength )
       
   108         {
       
   109         // Take first 8 characters from the given UID name -> 12345678
       
   110         TPtrC name = aUIDName.Mid( 0, KUIDLength );
       
   111         FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName: name = %S", &name );
       
   112 
       
   113         // Find sis package that has matching UID
       
   114         for( TInt index = 0; index < count; index++ )
       
   115             {
       
   116             TUid packageUID = iUnknownPackages[ index ]->Uid();
       
   117 
       
   118             // UID name is returned as "[12345678]"
       
   119             TBuf<KMaxUidName> packageUIDName = packageUID.Name();
       
   120             FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName: %d 0x%08x %S",
       
   121                     index, packageUID.iUid, &packageUIDName );
       
   122 
       
   123             // Remove square brackets from UID name -> 12345678
       
   124             TPtrC uidName = packageUIDName.Mid( 1, KUIDLength );
       
   125 
       
   126             // If UID name is same we have a match
       
   127             if( name.Compare( uidName ) == KErrNone )
       
   128                 {
       
   129                 FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName: match, return %d",
       
   130                         index );
       
   131                 return index;
       
   132                 }
       
   133             }
       
   134         }
       
   135     FLOG( "CAppMngr2SisxUnknownList::FindPkgWithUIDName: return KErrNotFound" );
       
   136     return KErrNotFound;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CAppMngr2SisxUnknownList::RemovePkgL()
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CAppMngr2SisxUnknownList::RemovePkgL( TInt aPkgListIndex )
       
   144     {
       
   145     Swi::UninstalledSisPackages::RemoveL( *iUnknownPackages[ aPkgListIndex ] );
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CAppMngr2SisxUnknownList::ConstructL()
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CAppMngr2SisxUnknownList::ConstructL( TInt aDriveNumber )
       
   153     {
       
   154     Swi::UninstalledSisPackages::ListL( static_cast< TDriveNumber >( aDriveNumber ),
       
   155             iUnknownPackages );
       
   156     }
       
   157