appinstaller/AppinstUi/Plugin/SisxUI/Src/SisxUIAppInfo.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2002-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:   This module contains the implementation of CSisxUIAppInfo 
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <StringLoader.h>
       
    23 #include <SWInstCommonUI.rsg>
       
    24 #include <AknUtils.h>
       
    25 
       
    26 #include "SisxUIAppInfo.h"
       
    27 #include "CUIUtils.h"
       
    28 
       
    29 _LIT( KSymbian, "Symbian OS\x2122" );
       
    30 _LIT( KLRE, "\x202A" );
       
    31 _LIT( KPDF, "\x202C" );
       
    32 _LIT( KLeftParenthes, "(" );
       
    33 
       
    34 using namespace SwiUI;
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CSisxUIAppInfo::CSisxUIAppInfo
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CSisxUIAppInfo::CSisxUIAppInfo( TBool aIsTrusted )
       
    45     : iIsTrusted( aIsTrusted )
       
    46     {
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CSisxUIAppInfo::ConstructL
       
    51 // Symbian 2nd phase constructor can leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CSisxUIAppInfo::ConstructL( const Swi::CAppInfo& aInfo )
       
    55     {
       
    56     iName = aInfo.AppName().AllocL();
       
    57     iVendor = aInfo.AppVendor().AllocL();    
       
    58     iVersion = aInfo.AppVersion();      
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CSisxUIAppInfo::NewL
       
    63 // Two-phased constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CSisxUIAppInfo* CSisxUIAppInfo::NewL( const Swi::CAppInfo& aInfo, TBool aIsTrusted )
       
    67     {
       
    68     CSisxUIAppInfo* self = new ( ELeave ) CSisxUIAppInfo( aIsTrusted );
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL( aInfo );
       
    71     CleanupStack::Pop( self );
       
    72     return self; 
       
    73     }
       
    74     
       
    75 // Destructor
       
    76 CSisxUIAppInfo::~CSisxUIAppInfo()
       
    77     {  
       
    78     FreeIterator();
       
    79 
       
    80     delete iName;
       
    81     delete iVendor;    
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSisxUIAppInfo::Name
       
    86 // Return name of the package.
       
    87 // (other items were commented in a header).
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 const TDesC& CSisxUIAppInfo::Name() const
       
    91     {
       
    92     return *iName;    
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CSisxUIAppInfo::SetNameL
       
    97 // Set the name of the package
       
    98 // (other items were commented in a header).
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CSisxUIAppInfo::SetNameL( const TDesC& aName )
       
   102     {
       
   103     delete iName;
       
   104     iName = NULL;
       
   105     iName = aName.AllocL();    
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CSisxUIAppInfo::Vendor
       
   110 // Return the package vendor. 
       
   111 // (other items were commented in a header).
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 const TDesC& CSisxUIAppInfo::Vendor() const
       
   115     {
       
   116     return *iVendor;    
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CSisxUIAppInfo::SetVendorL
       
   121 // Set the vendor of the package
       
   122 // (other items were commented in a header).
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CSisxUIAppInfo::SetVendorL( const TDesC& aVendor )
       
   126     {
       
   127     delete iVendor;
       
   128     iVendor = NULL;
       
   129     iVendor = aVendor.AllocL();    
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CSisxUIAppInfo::Version
       
   134 // Return the package version.
       
   135 // (other items were commented in a header).
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 const TVersion& CSisxUIAppInfo::Version() const
       
   139     {
       
   140     return iVersion;    
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CSisxUIAppInfo::SetTrusted
       
   145 // Set the trusted status of the package. 
       
   146 // (other items were commented in a header).
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CSisxUIAppInfo::SetTrusted( TBool aIsTrusted )
       
   150     {
       
   151     iIsTrusted = aIsTrusted;    
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CSisxUIAppInfo::IsTrusted
       
   156 // Indicates the trusted status of the package.
       
   157 // (other items were commented in a header).
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 TBool CSisxUIAppInfo::IsTrusted() const
       
   161     {
       
   162     return iIsTrusted;
       
   163     }
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CSisxUIAppInfo::SetUid
       
   167 // Sets the Uid of the package.
       
   168 // (other items were commented in a header).
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CSisxUIAppInfo::SetUid( const TUid& aUid )
       
   172     {
       
   173     iUid.iUid = aUid.iUid;    
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CSisxUIAppInfo::Uid
       
   178 // Return the Uid of the package.
       
   179 // (other items were commented in a header).
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 TUid CSisxUIAppInfo::Uid() const
       
   183     {
       
   184     return iUid;    
       
   185     }
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // CSisxUIAppInfo::PrepareIteratorL
       
   189 // Prepares the iterator to be shown in details dialog.
       
   190 // (other items were commented in a header).
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 void CSisxUIAppInfo::PrepareIteratorL( const Swi::CAppInfo& /*aInfo*/ )
       
   194     {
       
   195     FreeIterator();
       
   196 
       
   197     iKeys = new( ELeave )CDesCArrayFlat( 6 );
       
   198     iValues = new( ELeave )CDesCArrayFlat( 6 );
       
   199 
       
   200     // Name
       
   201     SetFieldL( R_SWCOMMON_DETAIL_NAME, Name() );
       
   202 
       
   203     // Version
       
   204     HBufC* stringBuf = CommonUI::CUIUtils::ConstructVersionStringLC( Version().iMajor,
       
   205                                                                      Version().iMinor,
       
   206                                                                      Version().iBuild );    
       
   207     TPtr ptr = stringBuf->Des();
       
   208     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
       
   209     HBufC* tmpBuf = HBufC::NewLC( KLRE().Length() + stringBuf->Length() + KPDF().Length() ); 
       
   210     TInt position = stringBuf->Find( KLeftParenthes() );
       
   211     if ( position >= 0 )
       
   212         {
       
   213         tmpBuf->Des() = stringBuf->Mid( 0, position );
       
   214         tmpBuf->Des() += KLRE();
       
   215         tmpBuf->Des() += stringBuf->Mid( position, stringBuf->Length() - position );
       
   216         tmpBuf->Des() += KPDF();
       
   217         }
       
   218     else
       
   219         {
       
   220         tmpBuf->Des() = *stringBuf;	
       
   221         }   
       
   222     SetFieldL( R_SWCOMMON_DETAIL_VERSION, *tmpBuf );
       
   223     CleanupStack::PopAndDestroy( tmpBuf );
       
   224     CleanupStack::PopAndDestroy( stringBuf );
       
   225 
       
   226      // Supplier
       
   227     if ( IsTrusted() )
       
   228         {        
       
   229         SetFieldL( R_SWCOMMON_DETAIL_SUPPLIER, Vendor() );
       
   230         }
       
   231     else
       
   232         {
       
   233         tmpBuf = StringLoader::LoadLC( R_SWCOMMON_DETAIL_VALUE_UNKNOWN_SUPPLIER );
       
   234         SetFieldL( R_SWCOMMON_DETAIL_SUPPLIER, *tmpBuf );
       
   235         CleanupStack::PopAndDestroy( tmpBuf );        
       
   236         }  
       
   237 
       
   238     // size
       
   239     tmpBuf = StringLoader::LoadLC( R_SWCOMMON_DETAIL_VALUE_UNKNOWN_SIZE );
       
   240     SetFieldL( R_SWCOMMON_DETAIL_APPSIZE, *tmpBuf );  
       
   241     CleanupStack::PopAndDestroy( tmpBuf );
       
   242 
       
   243     // Technology
       
   244     tmpBuf = HBufC::NewLC( KLRE().Length() + KSymbian().Length() + KPDF().Length() );
       
   245     tmpBuf->Des() = KLRE(); 
       
   246     tmpBuf->Des() += KSymbian();
       
   247     tmpBuf->Des() += KPDF();
       
   248     SetFieldL( R_SWCOMMON_DETAIL_TECHNOLOGY, *tmpBuf ); 
       
   249     CleanupStack::PopAndDestroy( tmpBuf );  
       
   250 
       
   251     // Type
       
   252     tmpBuf = StringLoader::LoadLC( R_SWCOMMON_DETAIL_VALUE_APPLICATION );    
       
   253     SetFieldL( R_SWCOMMON_DETAIL_TYPE, *tmpBuf );
       
   254     CleanupStack::PopAndDestroy( tmpBuf );    
       
   255     }
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CSisxUIAppInfo::FreeIterator
       
   259 // Frees the memory reserved for the iterator.
       
   260 // (other items were commented in a header).
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 void CSisxUIAppInfo::FreeIterator()     
       
   264     {
       
   265     if ( iKeys )
       
   266         {        
       
   267         iKeys->Reset();
       
   268         }
       
   269     delete iKeys;
       
   270     iKeys = NULL;    
       
   271 
       
   272     if ( iValues )
       
   273         {        
       
   274         iValues->Reset();    
       
   275         }    
       
   276     delete iValues;
       
   277     iValues = NULL;    
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // CSisxUIAppInfo::HasNext
       
   282 // Indicates if the iterator has any more fields left. 
       
   283 // (other items were commented in a header).
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 TBool CSisxUIAppInfo::HasNext() const
       
   287     {
       
   288     return ( ( iKeys->Count() ) > iCurrentIndex );    
       
   289     }
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CSisxUIAppInfo::Next
       
   293 // Get the next field.
       
   294 // (other items were commented in a header).
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 void CSisxUIAppInfo::Next( TPtrC& aKey, TPtrC& aValue )
       
   298     {
       
   299     aKey.Set( ( *iKeys )[iCurrentIndex] );
       
   300     aValue.Set( ( *iValues )[iCurrentIndex] );
       
   301     iCurrentIndex++;    
       
   302     }
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // CSisxUIAppInfo::Reset
       
   306 // Reset the iterator. After calling this, Next() will return the first value.
       
   307 // (other items were commented in a header).
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 void CSisxUIAppInfo::Reset()
       
   311     {
       
   312     iCurrentIndex = 0;    
       
   313     }
       
   314 
       
   315 // -----------------------------------------------------------------------------
       
   316 // CSisxUIAppInfo::SetFieldL
       
   317 // Sets a new field for the iterator with given parameter values.
       
   318 // (other items were commented in a header).
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 void CSisxUIAppInfo::SetFieldL( TInt aResourceId, const TDesC& aValue )
       
   322     {
       
   323      HBufC* temp = StringLoader::LoadLC( aResourceId );
       
   324      iKeys->AppendL( temp->Des() );
       
   325      CleanupStack::PopAndDestroy( temp );
       
   326      iValues->AppendL( aValue );
       
   327     }
       
   328 
       
   329 
       
   330 //  End of File